@aceshooting/lyra-ui 30.2.0 → 30.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/ai/adapters/a2ui.d.ts +10 -4
  3. package/dist/ai/adapters/a2ui.js +1 -1
  4. package/dist/ai/adapters/ag-ui.d.ts +17 -4
  5. package/dist/ai/adapters/ag-ui.js +1 -1
  6. package/dist/ai/adapters/ai-sdk.js +1 -1
  7. package/dist/ai/runtime.js +1 -1
  8. package/dist/components/agent-tools/mcp-app/mcp-app-protocol.d.ts +15 -0
  9. package/dist/components/agent-tools/mcp-app/mcp-app-protocol.js +36 -0
  10. package/dist/components/agent-tools/mcp-app/mcp-app.class.d.ts +31 -4
  11. package/dist/components/agent-tools/mcp-app/mcp-app.class.js +4 -4
  12. package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +2 -2
  13. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  14. package/dist/components/conversation/message-actions/message-actions.class.d.ts +3 -3
  15. package/dist/components/conversation/message-parts/message-parts.class.d.ts +13 -4
  16. package/dist/components/conversation/message-parts/message-parts.class.js +12 -10
  17. package/dist/components/conversation/message-parts/message-parts.d.ts +1 -1
  18. package/dist/components/conversation/message-parts/message-parts.js +1 -1
  19. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +1 -1
  20. package/dist/components/data/flow-minimap/flow-minimap.class.d.ts +1 -1
  21. package/dist/components/forms/select/select.class.js +1 -1
  22. package/dist/components/layout/app-rail/app-rail.class.d.ts +1 -1
  23. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  24. package/dist/components/layout/multi-split/multi-split.class.d.ts +4 -1
  25. package/dist/components/layout/multi-split/multi-split.class.js +6 -3
  26. package/dist/components/layout/multi-split/multi-split.styles.js +1 -1
  27. package/dist/components/layout/navigation-menu/navigation-menu.class.js +1 -1
  28. package/dist/components/layout/page/page.class.d.ts +3 -1
  29. package/dist/components/layout/page/page.class.js +1 -1
  30. package/dist/components/layout/responsive-panel/responsive-panel.class.d.ts +6 -4
  31. package/dist/components/layout/responsive-panel/responsive-panel.class.js +1 -1
  32. package/dist/components/layout/scroller/scroller.class.d.ts +1 -1
  33. package/dist/components/layout/scroller/scroller.class.js +1 -1
  34. package/dist/components/layout/split-panel/split-panel.class.d.ts +1 -1
  35. package/dist/components/layout/split-panel/split-panel.class.js +1 -1
  36. package/dist/components/layout/stepper/stepper.class.d.ts +1 -1
  37. package/dist/components/layout/stepper/stepper.class.js +1 -1
  38. package/dist/components/layout/widget/widget.class.d.ts +1 -1
  39. package/dist/components/layout/widget/widget.class.js +1 -1
  40. package/dist/components/media/file-input/file-input.styles.js +1 -1
  41. package/dist/components/media/map/map-control-chrome.js +1 -0
  42. package/dist/components/media/map/map-control-options.d.ts +6 -2
  43. package/dist/components/media/map/map-control-options.js +1 -1
  44. package/dist/components/media/map/map-controls-lifecycle.js +1 -1
  45. package/dist/components/media/map/map-controls-readiness.js +1 -0
  46. package/dist/components/media/map/map.class.d.ts +39 -2
  47. package/dist/components/media/map/map.class.js +13 -7
  48. package/dist/components/media/map/map.styles.js +1 -1
  49. package/dist/components/overlays/dialog/dialog.class.d.ts +2 -2
  50. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  51. package/dist/components/utility/copy-button/copy-button.class.d.ts +13 -15
  52. package/dist/components/utility/copy-button/copy-button.class.js +3 -3
  53. package/dist/components/utility/copy-button/copy-button.styles.js +1 -1
  54. package/dist/components/utility/tour/tour.class.d.ts +2 -2
  55. package/dist/components/utility/tour/tour.class.js +1 -1
  56. package/dist/events.d.ts +10 -1
  57. package/dist/framework-types.d.ts +1 -1
  58. package/dist/internal/localization-types.d.ts +1 -1
  59. package/dist/internal/localization.js +1 -1
  60. package/dist/internal/modal-host.styles.js +1 -0
  61. package/dist/internal/modal-surface-controller.js +1 -1
  62. package/dist/internal/overlay-stack.d.ts +1 -1
  63. package/dist/internal/overlay-stack.js +1 -1
  64. package/dist/internal/package-metadata.js +1 -1
  65. package/dist/internal/scoped-definitions.generated.js +1 -1
  66. package/dist/internal/style-property-lease.js +1 -1
  67. package/dist/lyra.d.ts +1 -1
  68. package/llms/components/lr-app-rail.md +4 -0
  69. package/llms/components/lr-badge.md +3 -0
  70. package/llms/components/lr-copy-button.md +15 -7
  71. package/llms/components/lr-file-input.md +5 -0
  72. package/llms/components/lr-map.md +80 -8
  73. package/llms/components/lr-mcp-app.md +94 -4
  74. package/llms/components/lr-message-parts.md +18 -0
  75. package/llms/components/lr-multi-split.md +4 -0
  76. package/llms/components/lr-page.md +5 -1
  77. package/llms/components/lr-responsive-panel.md +5 -1
  78. package/llms/components/lr-select.md +3 -2
  79. package/llms/components/lr-token-input.md +4 -3
  80. package/llms/components/lr-tooltip.md +4 -4
  81. package/llms/peers.md +1 -1
  82. package/llms/shared/ai-and-peers.md +88 -3
  83. package/llms/shared/events-and-types.md +25 -1
  84. package/llms/shared/localization-and-rtl.md +29 -0
  85. package/llms/shared/styles-and-tokens.md +75 -14
  86. package/llms/shared.md +217 -18
  87. package/locales.json +1 -1
  88. package/package.json +8 -4
  89. package/registrations.json +1 -1
  90. package/skills/compose-lyra-interfaces/SKILL.md +5 -3
  91. package/skills/compose-lyra-interfaces/references/composition-patterns.md +8 -1
  92. package/skills/lyra-ui/SKILL.md +17 -8
  93. package/skills/lyra-ui/lyra-gen.md +95 -0
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{resolveIdReferencesIn}from"../../../internal/aria-reflection.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{isRtl}from"../../../internal/rtl.js";import{repairComposedFocus}from"../../../internal/focus-navigation.js";import{cancelDeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{nextId}from"../../../internal/a11y.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{finiteRange}from"../../../internal/numbers.js";import{SeparatorDragController,separatorArrowDirection,separatorCoordinate,separatorDelta}from"../../../internal/separator-drag.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{CollapseBreakpointController,OrientationBreakpointController}from"../../../internal/orientation-breakpoint.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{resolveCssLength}from"../../../internal/css-length.js";import{styles}from"./multi-split.styles.js";import{LYRA_DEFAULT_resizeDivider,LYRA_DEFAULT_resizeValuePercent}from"../../../internal/default-strings/layout.generated.js";const KEYBOARD_STEP=2;function isPersistedPanelLayout(value){if(typeof value!="object"||value===null)return!1;const candidate=value;return candidate.version!==1||!Array.isArray(candidate.panels)?!1:candidate.panels.every(panel=>{if(typeof panel!="object"||panel===null)return!1;const record=panel;return typeof record.panelId=="string"&&record.panelId!==""&&record.panelId.trim()===record.panelId&&typeof record.size=="number"&&Number.isFinite(record.size)&&record.size>=0})}const NO_MIN_PX=0,NO_MAX_PX=1e6,OWNED_PANEL_STYLE_PROPERTIES=["flex","order","inline-size","--_lr-multi-split-panel-min"];class LyraMultiSplit extends LyraElement{constructor(){super(...arguments),this.toggleProposalDepth=0,this.toggleProposalMutationVersion=0,this.forcedCloseVersion=0,this.sizes=[],this.defaultSizes=[],this.min=10,this.orientation="horizontal",this.orientationBreakpointBasis="container",this.narrowOrientation="vertical",this.panelConstraints=[],this.collapse="none",this.railWidth="3.5rem",this.railBreakpoint=640,this.floatBreakpoint=400,this.collapseBreakpointBasis="container",this.releasePinOnBreakpoint=!1,this.open=!1,this.trigger=null,this.for="",this.panelCount=0,this.sizesReconciledForMembership=!1,this._collapseState="wide",this._forced=!1,this.overlayActive=!1,this.justOpened=!1,this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1)},onUnexpectedClose:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1),this.overlayActive&&this.nativeModal.show()}}),this.syncNativeModalGeometry=()=>{if(!this.nativeModal.requested||!this.isConnected)return;if(!this.nativeModalView){this.nativeModalView=this.ownerDocument.defaultView??void 0,this.nativeModalView?.addEventListener("scroll",this.syncNativeModalGeometry,!0),this.nativeModalView?.addEventListener("resize",this.syncNativeModalGeometry);const Observer=this.nativeModalView?.ResizeObserver;if(Observer){const observer=new Observer(this.syncNativeModalGeometry);this.nativeModalResizeObserver=observer,observer.observe(this)}}const frame=this.shadowRoot?.querySelector("[data-native-modal-carrier]");if(!frame)return;const rect=this.getBoundingClientRect();Object.assign(frame.style,{top:`${rect.top}px`,left:`${rect.left}px`,right:"auto",bottom:"auto",width:`${rect.width}px`,height:`${rect.height}px`,padding:"0"})},this.overlayReturnTarget=null,this.overlayOpener=null,this.floatingDialogPanel=null,this.floatingDialogPreviousRole=null,this.floatingDialogPreviousAriaModal=null,this.drags=new Map,this.dragController=new SeparatorDragController(this,event=>this.onPointerMove(event),event=>this.onPointerUp(event)),this.ownedPanels=[],this.panelOwnership=new Map,this.constraintIssueKey="",this.constraintConfigVersion=0,this.renderConstraintBounds=[],this.initializedSizes=!1,this.measuredInlineSize=Number.POSITIVE_INFINITY,this._effectiveOrientation="horizontal",this.collapseObserverGeneration=0,this.gutterObservedDividers=[],this.gutterObservedContainerSize=0,this.orientationBreakpoints=new OrientationBreakpointController(this,()=>this.updateEffectiveOrientation(this.measuredInlineSize,!0)),this.collapseBreakpoints=new CollapseBreakpointController(this,()=>this.updateCollapseState(this.measuredInlineSize,!0)),this.onSlotChange=()=>{this.updateBrowserDerivedState(()=>this.syncPanelMembership())},this.onBackdropClick=()=>{this.overlayHandle?.dismissBackdrop()},this.onModalLayerClick=event=>{event.target===this.baseEl&&this.overlayHandle?.dismissBackdrop()},this.onPointerDown=(e,index)=>{if(e.button!==0||this.isDividerDisabled(index))return;const divider=e.currentTarget;this.dragController.start(e,divider)&&this.drags.set(e.pointerId,{index,startPos:separatorCoordinate(e,this.effectiveOrientation==="vertical"?"block":"inline"),base:this.baseEl,rtl:this.effectiveOrientation==="horizontal"&&isRtl(this),appliedDelta:0,acceptedResize:!1})},this.onPointerMove=e=>{const drag=this.drags.get(e.pointerId);if(!drag)return;if(this.isDividerDisabled(drag.index)){this.endDragGestures();return}if(this.effectiveOrientation==="horizontal"&&isRtl(this)!==drag.rtl){this.endDragGestures();return}const total=this.effectiveOrientation==="vertical"?drag.base.clientHeight:drag.base.clientWidth;if(!Number.isFinite(total)||total<=0){this.endDragGestures();return}const incremental=separatorDelta(drag.startPos,e,this.effectiveOrientation==="vertical"?"block":"inline",drag.rtl)/total*100-drag.appliedDelta,priorValue=this.sizes[drag.index];if(priorValue===void 0)return;const paired=this.clampPair(this.sizes,drag.index,incremental,total),pairedA=paired[drag.index],pairedB=paired[drag.index+1];if(pairedA===void 0||pairedB===void 0)return;const next=[...this.sizes];next[drag.index]=pairedA,next[drag.index+1]=pairedB,this.requestResize(next,!1)&&(drag.appliedDelta+=pairedA-priorValue,drag.acceptedResize=!0)},this.onPointerUp=e=>{const drag=this.drags.get(e.pointerId);drag&&(this.drags.delete(e.pointerId),e.type==="pointerup"&&drag.acceptedResize&&this.settle(),this.dragController.end(e.pointerId))},this.onDividerKeyDown=(e,index)=>{if(this.isDividerDisabled(index)||e.altKey||e.ctrlKey||e.metaKey||e.isComposing)return;const direction=separatorArrowDirection(e,this.effectiveOrientation==="vertical"?"block":"inline",this.effectiveOrientation==="horizontal"&&isRtl(this));if(e.key==="Home"||e.key==="End"){const{min,max}=this.dividerValueRange(index),current=this.sizes[index];if(current!==void 0){const target=e.key==="Home"?min:max;this.applyDelta(index,target-current,!0)&&e.preventDefault()}}else direction===1?this.applyDelta(index,KEYBOARD_STEP,!0)&&e.preventDefault():direction===-1&&this.applyDelta(index,-KEYBOARD_STEP,!0)&&e.preventDefault()}}static{this.defaultStrings={...super.defaultStrings,resizeDivider:LYRA_DEFAULT_resizeDivider,resizeValuePercent:LYRA_DEFAULT_resizeValuePercent}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["sizes","defaultSizes","panelConstraints"])}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-resize-request","lr-resize","lr-resize-change"])}static{this.properties={collapseState:{reflect:!0,attribute:"collapse-state",noAccessor:!0}}}stopNativeModalGeometry(){this.nativeModalView?.removeEventListener("scroll",this.syncNativeModalGeometry,!0),this.nativeModalView?.removeEventListener("resize",this.syncNativeModalGeometry),this.nativeModalView=void 0,this.nativeModalResizeObserver?.disconnect(),this.nativeModalResizeObserver=void 0}nativeModalLabel(){const panel=this.floatingPanelEl;return panel?panel.hasAttribute("aria-label")?panel.getAttribute("aria-label"):resolveIdReferencesIn(panel.getRootNode(),panel.getAttribute("aria-labelledby")).map(element=>element.textContent?.trim()).filter(Boolean).join(" ")||this.getAttribute("aria-label"):this.getAttribute("aria-label")}connectedCallback(){super.connectedCallback();const hostWidth=this.getBoundingClientRect().width;hostWidth>0&&(this.measuredInlineSize=hostWidth),this.seedFirstRenderState(()=>this.syncPanelMembership(!1)),this.hasUpdated&&this.syncPanelMembership(!1),this.initializedSizes&&this.ensureSizes(),this.responsiveObservationEnabled&&this.armCollapseObserver(),this.hasUpdated&&this.overlayActive&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateFloatingOverlay(),queueMicrotask(()=>{this.syncNativeModalGeometry(),this.nativeModal.show(),this.overlayHandle?.focusInitial()})),this.hasUpdated&&this.syncExternalTriggerA11y()}disconnectedCallback(){this.stopNativeModalGeometry(),this.nativeModal.hide(),super.disconnectedCallback(),this.endDragGestures(),this.resetCollapseObserver(),this.resetGutterObserver(),this.overlayHandle?.suspend(),cancelDeferredFocusReturn(this),this.releaseExternalTriggerA11y(),this.releaseOwnedPanels()}adoptedCallback(){super.adoptedCallback(),cancelDeferredFocusReturn(this),this.releaseExternalTriggerA11y(),this.endDragGestures(),this.resetCollapseObserver(),this.resetGutterObserver(),this.releaseOwnedPanels()}firstUpdated(changed){super.firstUpdated(changed),this.responsiveObservationEnabled&&this.armCollapseObserver()}willUpdate(changed){if(super.willUpdate(changed),!this.ownerDocument&&this.panelCount===0&&(this.panelCount=Math.max(this.sizes.length,this.defaultSizes.length,this.panelConstraints.length)),!this.initializedSizes)this.initializeSizes(),this.initializedSizes=!0;else if(changed.has("sizes")){const previous=changed.get("sizes");this.sizesReconciledForMembership?this.sizesReconciledForMembership=!1:this.validLiveSizes(this.sizes)||(Array.isArray(previous)&&this.validLiveSizes(previous)?this.sizes=[...previous]:(this.sizes=[],this.ensureSizes()))}else this.sizes.length===0&&this.ensureSizes();if((changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.orientationBreakpoints.configure(this.orientationBreakpoint,this.orientationBreakpointBasis),(changed.has("orientation")||changed.has("narrowOrientation")||changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.updateEffectiveOrientation(this.measuredInlineSize,this.hasUpdated&&this.orientationBreakpointBasis==="viewport"),changed.has("collapse")||changed.has("railBreakpoint")||changed.has("floatBreakpoint")||changed.has("collapseBreakpointBasis")){const previousEffective=changed.has("collapse")?this.effectiveCollapseStateFor(changed.get("collapse")??"none"):this.collapseState;changed.has("collapse")&&previousEffective!=="wide"&&this.endDragGestures(),this.collapseBreakpoints.configure(this.railBreakpoint,this.floatBreakpoint,this.collapseBreakpointBasis),this.collapsingIndex!==-1&&!this._forced&&(this._collapseState=this.collapseBreakpoints.classify(this.measuredInlineSize)),this.applyEffectiveCollapseTransition(previousEffective,this.collapseState,this.hasUpdated)}if(changed.has("open")||changed.has("collapseState")||changed.has("collapse")||changed.has("panelCount")){const next=this.collapseState==="floating"&&this.open;next!==this.overlayActive&&(this.overlayActive=next,next?(this.justOpened=!0,this.activateFloatingOverlay()):this.deactivateFloatingOverlay())}this.renderConstraintBounds=this.resolveConstraintBounds(this.getContainerSize()).bounds}get collapseState(){return this.effectiveCollapseStateFor(this.collapse)}set collapseState(next){if(next==="auto"){this.releaseCollapsePin(),this.updateCollapseState(this.currentMeasuredWidth());return}this._forced=!0,this.pinnedBand=this.collapseBreakpoints.classify(this.pinMeasurementWidth()),this.setRequestedCollapseState(next)}expandPane(){this.applyPaneIntent(!0)}collapsePane(){this.applyPaneIntent(!1)}togglePane(){this.applyPaneIntent(!this.paneExpanded)}get paneExpanded(){const state=this.collapseState;return state==="floating"?this.open:state==="wide"}applyPaneIntent(expanded){if(this.collapsingIndex===-1)return;const band=this.collapseBreakpoints.classify(this.pinMeasurementWidth());if(band==="floating"){this.collapseState!=="floating"&&(this.releaseCollapsePin(),this.setRequestedCollapseState("floating")),this.open=expanded;return}const target=expanded?"wide":"rail";if(this.collapseState!==target){if(target===band){this.releaseCollapsePin(),this.setRequestedCollapseState(target);return}this.collapseState=target}}releaseCollapsePin(){this._forced=!1,this.pinnedBand=void 0}pinMeasurementWidth(){const live=this.currentMeasuredWidth();return live>0?live:this.measuredInlineSize}get effectiveOrientation(){return this._effectiveOrientation}get responsiveObservationEnabled(){return this.collapse!=="none"||this.orientationBreakpoints.containerObservationEnabled}updateEffectiveOrientation(width,shouldEmit){const next=this.orientationBreakpoints.isBelow(width)?this.narrowOrientation:this.orientation;next!==this._effectiveOrientation&&(this.endDragGestures(),this._effectiveOrientation=next,this.requestUpdate(),shouldEmit&&this.emit("lr-multi-split-orientation-change",{orientation:next}),this._forced&&this.releasePinOnBreakpoint&&(this.releaseCollapsePin(),this.updateCollapseState(width,this.hasUpdated)))}currentMeasuredWidth(){return this.baseEl?.clientWidth??0}effectiveCollapseStateFor(collapse){return collapse!=="none"&&this.panelCount>=2?this._collapseState:"wide"}applyEffectiveCollapseTransition(previous,next,shouldEmit=!0){if(previous===next)return;this.endDragGestures(),this.requestUpdate("collapseState",previous);const forceClose=previous==="floating"&&next!=="floating"&&this.open,forcedCloseVersion=this.forcedCloseVersion;shouldEmit&&(this.relocateFocusOutOfCollapsingPanel(next),this.decorateOwnedPanels(),this.emit("lr-multi-split-collapse-change",{state:next})),forceClose&&this.forcedCloseVersion===forcedCloseVersion&&this.collapseState!=="floating"&&this.setOpen(!1,{force:!0})}relocateFocusOutOfCollapsingPanel(next){if(next==="wide"||next==="floating"&&this.open)return;const index=this.collapsingIndex;if(index===-1)return;const panel=this.ownedPanels[index];panel&&repairComposedFocus(panel,()=>this.collapseFocusFallbacks(panel))}collapseFocusFallbacks(collapsing){const dividers=[...this.renderRoot.querySelectorAll('[part="divider"]')];return[...new Set([...this.ownedPanels.filter(panel=>panel!==collapsing),...dividers.filter((_,index)=>!this.isDividerDisabled(index)),...dividers])]}setOpen(next,options){if(options?.force){this.open=next,this.forcedCloseVersion+=1,this.emit("lr-toggle",{expanded:next});return}if(this.open===next)return;const collapseState=this.collapseState,open=this.open,mutationVersion=this.toggleProposalMutationVersion;this.toggleProposalDepth+=1;try{if(this.emit("lr-toggle-request",{expanded:next},{cancelable:!0}).defaultPrevented||this.toggleProposalMutationVersion!==mutationVersion||this.collapseState!==collapseState||this.open!==open)return}finally{this.toggleProposalDepth-=1}this.open=next,this.emit("lr-toggle",{expanded:next})}requestUpdate(name,oldValue,options){this.toggleProposalDepth>0&&(name==="open"&&oldValue!==this.open||name==="collapse"&&oldValue!==this.collapse||name==="collapseState"&&oldValue!==this.collapseState)&&(this.toggleProposalMutationVersion+=1),super.requestUpdate(name,oldValue,options)}setRequestedCollapseState(next,shouldEmit=!0){const previousEffective=this.collapseState;if(next===this._collapseState)return;this._collapseState=next;const nextEffective=this.collapseState;this.applyEffectiveCollapseTransition(previousEffective,nextEffective,shouldEmit),previousEffective===nextEffective&&next!==nextEffective&&this.requestUpdate("collapseState",next)}get storageFullKey(){return this.storageKey?`lr-multi-split:${this.storageKey}:panels`:void 0}panelIdsFor(panels){const ids=[],seen=new Set;for(const panel of panels){const panelId=panel.getAttribute("panel-id")??"";if(!panelId||panelId.trim()!==panelId||seen.has(panelId))return null;seen.add(panelId),ids.push(panelId)}return ids}reconcileIdentitySizes(previousIds,previousValues,nextIds){if(previousIds.length!==previousValues.length||nextIds.length===0)return null;const previousSizes=new Map;previousIds.forEach((panelId,index)=>{previousSizes.set(panelId,previousValues[index])});const retainedTotal=nextIds.reduce((total,panelId)=>total+(previousSizes.get(panelId)??0),0),missingCount=nextIds.filter(panelId=>!previousSizes.has(panelId)).length;if(!(retainedTotal>0)){const equal=100/nextIds.length;return nextIds.map(()=>equal)}const newShare=100/nextIds.length,retainedScale=(100-newShare*missingCount)/retainedTotal;return nextIds.map(panelId=>{const previous=previousSizes.get(panelId);return previous===void 0?newShare:previous*retainedScale})}reconcileSizesByPanelId(previousPanels,nextPanels){if(previousPanels.length!==this.sizes.length||nextPanels.length===0)return null;const previousIds=this.panelIdsFor(previousPanels),nextIds=this.panelIdsFor(nextPanels);return!previousIds||!nextIds?null:this.reconcileIdentitySizes(previousIds,this.sizes,nextIds)}validInitialSizes(value){return!Array.isArray(value)||value.length!==this.panelCount||!value.every(size=>Number.isFinite(size)&&size>=this.safeMin)?!1:Math.abs(value.reduce((sum,size)=>sum+size,0)-100)<.01}validLiveSizes(value){if(!Array.isArray(value)||value.length!==this.panelCount)return!1;const floor=this.normalizedDefaultMin();return value.every(size=>Number.isFinite(size)&&size>=floor)?Math.abs(value.reduce((sum,size)=>sum+size,0)-100)<.01:!1}resolveDefaultSizes(){if(this.defaultSizes.length===0)return null;if(!this.defaultSizes.some(entry=>typeof entry=="string")){const numbers=this.defaultSizes;return this.validInitialSizes(numbers)?[...numbers]:null}const containerSize=this.currentMeasuredWidth()||this.getBoundingClientRect().width;if(!(containerSize>0))return null;const resolvedPx=[];for(const entry of this.defaultSizes){if(typeof entry=="number"){if(!Number.isFinite(entry))return null;resolvedPx.push(entry/100*containerSize);continue}const px=resolveCssLength(entry,{host:this,percentBase:containerSize,viewportBasis:this.ownerDocument.defaultView??void 0});if(px==null||!(px>=0))return null;resolvedPx.push(px)}const sum=resolvedPx.reduce((total,size)=>total+size,0);if(!(sum>0))return null;const normalized=resolvedPx.map(size=>size/sum*100);return this.validInitialSizes(normalized)?normalized:null}initializeSizes(){if(this.validInitialSizes(this.sizes)||this.loadPersisted())return;const resolved=this.resolveDefaultSizes();if(resolved){this.sizes=resolved;return}this.sizes=[],this.ensureSizes()}loadPersisted(){const panelIds=this.panelIdsFor(this.ownedPanels);if(!panelIds)return!1;const parsed=readPersistedState(this.storageFullKey,isPersistedPanelLayout);if(!parsed||parsed.panels.length===0)return!1;const persistedIds=[],persistedSizes=[],seen=new Set;for(const panel of parsed.panels){if(seen.has(panel.panelId))return!1;seen.add(panel.panelId),persistedIds.push(panel.panelId),persistedSizes.push(panel.size)}if(Math.abs(persistedSizes.reduce((sum,size)=>sum+size,0)-100)>=.01)return!1;const normalized=this.reconcileIdentitySizes(persistedIds,persistedSizes,panelIds);return normalized&&this.validInitialSizes(normalized)?(this.sizes=normalized,!0):!1}persist(){const panelIds=this.panelIdsFor(this.ownedPanels);if(!panelIds||panelIds.length!==this.sizes.length)return;const layout={version:1,panels:panelIds.map((panelId,index)=>({panelId,size:this.sizes[index]}))};writePersistedState(this.storageFullKey,layout)}ensureSizes(){if(this.panelCount===this.sizes.length)return;if(this.panelCount<=0){this.sizes=[];return}if(this.sizes.length===0){const equal=100/this.panelCount;this.sizes=Array.from({length:this.panelCount},()=>equal);return}const diff=this.panelCount-this.sizes.length;if(diff>0){const newShare=100/this.panelCount,scale=(100-newShare*diff)/100;this.sizes=[...this.sizes.map(s=>s*scale),...Array.from({length:diff},()=>newShare)]}else{const kept=this.sizes.slice(0,this.panelCount),removedTotal=this.sizes.slice(this.panelCount).reduce((sum,s)=>sum+s,0),keptTotal=kept.reduce((sum,s)=>sum+s,0)||1;this.sizes=kept.map(s=>s+s/keptTotal*removedTotal)}}readPanelStyle(panel,property2){return{value:panel.style.getPropertyValue(property2),priority:panel.style.getPropertyPriority(property2)}}samePanelStyle(left,right){return left.value===right.value&&left.priority===right.priority}snapshotPanelOwnership(panel){const styles2=new Map;for(const property2 of OWNED_PANEL_STYLE_PROPERTIES)styles2.set(property2,this.readPanelStyle(panel,property2));return{styles:styles2,appliedStyles:new Map,hidden:panel.hidden,collapseState:panel.getAttribute("data-collapse-state")}}adoptPanelOwnership(panel,snapshot){for(const property2 of OWNED_PANEL_STYLE_PROPERTIES){const current=this.readPanelStyle(panel,property2),applied=snapshot.appliedStyles.get(property2);(applied&&!this.samePanelStyle(current,applied)||!applied&&!this.samePanelStyle(current,snapshot.styles.get(property2)))&&snapshot.styles.set(property2,current)}(snapshot.appliedHidden!==void 0&&panel.hidden!==snapshot.appliedHidden||snapshot.appliedHidden===void 0&&panel.hidden!==snapshot.hidden)&&(snapshot.hidden=panel.hidden);const collapseState=panel.getAttribute("data-collapse-state");(snapshot.appliedCollapseState!==void 0&&collapseState!==snapshot.appliedCollapseState||snapshot.appliedCollapseState===void 0&&collapseState!==snapshot.collapseState)&&(snapshot.collapseState=collapseState)}applyOwnedPanelStyle(panel,snapshot,property2,value){value.value===""?panel.style.removeProperty(property2):panel.style.setProperty(property2,value.value,value.priority),snapshot.appliedStyles.set(property2,this.readPanelStyle(panel,property2))}applyOwnedPanelStyleValue(panel,snapshot,property2,value){this.applyOwnedPanelStyle(panel,snapshot,property2,{value,priority:""})}applyOwnedPanelHidden(panel,snapshot,hidden){panel.hidden=hidden,snapshot.appliedHidden=panel.hidden}applyOwnedPanelCollapseState(panel,snapshot,state){state===null?panel.removeAttribute("data-collapse-state"):panel.setAttribute("data-collapse-state",state),snapshot.appliedCollapseState=panel.getAttribute("data-collapse-state")}restorePanelOwnership(panel,snapshot){this.adoptPanelOwnership(panel,snapshot);for(const property2 of OWNED_PANEL_STYLE_PROPERTIES){const value=snapshot.styles.get(property2);value.value===""?panel.style.removeProperty(property2):panel.style.setProperty(property2,value.value,value.priority)}panel.hidden=snapshot.hidden,snapshot.collapseState===null?panel.removeAttribute("data-collapse-state"):panel.setAttribute("data-collapse-state",snapshot.collapseState)}panelProjectionDiverged(panel,snapshot){for(const property2 of OWNED_PANEL_STYLE_PROPERTIES){const current=this.readPanelStyle(panel,property2),expected=snapshot.appliedStyles.get(property2)??snapshot.styles.get(property2);if(!this.samePanelStyle(current,expected))return!0}if(panel.hidden!==(snapshot.appliedHidden??snapshot.hidden))return!0;const expectedCollapseState=snapshot.appliedCollapseState!==void 0?snapshot.appliedCollapseState:snapshot.collapseState;return panel.getAttribute("data-collapse-state")!==expectedCollapseState}resetPanelOwnershipObserver(){this.panelOwnershipObserver?.disconnect(),this.panelOwnershipObserver=void 0}observeOwnedPanels(){this.resetPanelOwnershipObserver();const MutationObserverConstructor=this.ownerDocument.defaultView?.MutationObserver;if(!MutationObserverConstructor||!this.isConnected||this.ownedPanels.length===0)return;const observer=new MutationObserverConstructor(records=>{records.some(record=>{const panel=record.target,snapshot=this.panelOwnership.get(panel);return snapshot?this.panelProjectionDiverged(panel,snapshot):!1})&&this.requestUpdate()});this.panelOwnershipObserver=observer;for(const panel of this.ownedPanels)observer.observe(panel,{attributes:!0,attributeFilter:["style","hidden","data-collapse-state"]})}samePanelSequence(next){return next.length===this.ownedPanels.length&&next.every((panel,index)=>panel===this.ownedPanels[index])}syncPanelMembership(reconcileSizes=!0){const next=[...this.children].filter(child=>child!==this.nativeModal.helperMount);if(this.samePanelSequence(next))return;const previousPanels=this.ownedPanels,identitySizes=reconcileSizes?this.reconcileSizesByPanelId(previousPanels,next):null,previousEffective=this.collapseState,nextSet=new Set(next);for(const panel of this.ownedPanels){if(nextSet.has(panel))continue;const snapshot=this.panelOwnership.get(panel);snapshot&&this.restorePanelOwnership(panel,snapshot),this.panelOwnership.delete(panel)}for(const panel of next)this.panelOwnership.has(panel)||this.panelOwnership.set(panel,this.snapshotPanelOwnership(panel));const countChanged=next.length!==this.panelCount;this.ownedPanels=next,this.panelCount=next.length,this.collapsingIndex!==-1&&!this._forced&&(this._collapseState=this.collapseBreakpoints.classify(this.currentMeasuredWidth())),this.applyEffectiveCollapseTransition(previousEffective,this.collapseState,this.hasUpdated),identitySizes?(this.sizesReconciledForMembership=!0,this.sizes=identitySizes):countChanged&&reconcileSizes&&(this.sizesReconciledForMembership=!0,this.ensureSizes()),this.observeOwnedPanels(),this.hasUpdated&&this.requestUpdate()}releaseOwnedPanels(){this.resetPanelOwnershipObserver();for(const panel of this.ownedPanels){const snapshot=this.panelOwnership.get(panel);snapshot&&this.restorePanelOwnership(panel,snapshot)}this.ownedPanels=[],this.panelOwnership.clear()}getContainerSize(){return this.baseEl?this.effectiveOrientation==="vertical"?this.baseEl.clientHeight:this.baseEl.clientWidth:0}resetGutterObserver(){this.gutterObserverFrame!==void 0&&(this.gutterObserverDocument?.defaultView?.cancelAnimationFrame(this.gutterObserverFrame),this.gutterObserverFrame=void 0),this.gutterResizeObserver?.disconnect(),this.gutterResizeObserver=void 0,this.gutterObserverDocument=void 0,this.gutterObservedDividers=[],this.baseEl?.style.removeProperty("--_lr-multi-split-gutters")}updateGutterBudget(){const view=this.ownerDocument.defaultView,base=this.baseEl;if(!view||!base)return;const vertical=this.effectiveOrientation==="vertical",value=`${this.gutterObservedDividers.reduce((total,divider)=>{const style=view.getComputedStyle(divider),properties=vertical?["height","padding-top","padding-bottom","border-top-width","border-bottom-width"]:["width","padding-left","padding-right","border-left-width","border-right-width"],boxProperties=style.boxSizing==="border-box"?properties.slice(0,1):properties;return total+boxProperties.reduce((size,property2)=>size+finiteRange(parseFloat(style.getPropertyValue(property2)),0,0),0)},0)}px`;base.style.getPropertyValue("--_lr-multi-split-gutters")!==value&&base.style.setProperty("--_lr-multi-split-gutters",value)}syncGutterObserver(enabled){const base=this.baseEl;if(!enabled||!this.isConnected||!base){this.resetGutterObserver();return}const ownerDocument=this.ownerDocument,dividers=[...base.querySelectorAll('[part="divider"]')];if(this.gutterResizeObserver&&this.gutterObserverDocument===ownerDocument&&dividers.length===this.gutterObservedDividers.length&&dividers.every((divider,index)=>divider===this.gutterObservedDividers[index])){this.updateGutterBudget();return}this.resetGutterObserver(),this.gutterObservedDividers=dividers,this.gutterObserverDocument=ownerDocument,this.gutterObservedContainerSize=this.getContainerSize(),this.updateGutterBudget();const ownerWindow=ownerDocument.defaultView,ResizeObserverConstructor=ownerWindow?.ResizeObserver;if(!ownerWindow||!ResizeObserverConstructor)return;const observer=new ResizeObserverConstructor(()=>{if(this.gutterResizeObserver!==observer||!this.isConnected||this.ownerDocument!==ownerDocument)return;this.updateGutterBudget();const size=this.getContainerSize();size!==this.gutterObservedContainerSize&&(this.gutterObservedContainerSize=size,this.requestUpdate())});this.gutterResizeObserver=observer;const frame=ownerWindow.requestAnimationFrame(()=>{if(!(this.gutterObserverFrame!==frame||this.gutterResizeObserver!==observer||!this.isConnected||this.ownerDocument!==ownerDocument||this.baseEl!==base)){this.gutterObserverFrame=void 0,observer.observe(base,{box:"border-box"});for(const divider of dividers)observer.observe(divider,{box:"border-box"})}});this.gutterObserverFrame=frame}get collapsingIndex(){return this.collapse==="none"||this.panelCount<2?-1:this.collapse==="start"?0:this.panelCount-1}get collapseActive(){return this.collapsingIndex!==-1&&this.collapseState!=="wide"}isDividerDisabled(index){if(!this.collapseActive)return!1;const adjacent=this.collapsingIndex===0?0:this.panelCount-2;return index===adjacent}updateCollapseState(width,shouldEmit=!0){if(this.collapse==="none")return;const classified=this.collapseBreakpoints.classify(width);if(this._forced){if(!this.releasePinOnBreakpoint||classified===this.pinnedBand)return;this.releaseCollapsePin()}this.setRequestedCollapseState(classified,shouldEmit)}armCollapseObserver(){const observedElement=this.baseEl;if(!this.isConnected||!observedElement)return;const ownerDocument=this.ownerDocument;if(this.collapseResizeObserver&&this.collapseObservedElement===observedElement&&this.collapseObserverOwnerDocument===ownerDocument)return;this.resetCollapseObserver();const ResizeObserverConstructor=ownerDocument.defaultView?.ResizeObserver;if(!ResizeObserverConstructor)return;const generation=this.collapseObserverGeneration,observer=new ResizeObserverConstructor(entries=>{if(this.collapseResizeObserver!==observer||this.collapseObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.baseEl!==observedElement)return;const box=entries[0]?.contentBoxSize?.[0],width=box?box.inlineSize:observedElement.getBoundingClientRect().width;this.measuredInlineSize=width,this.updateCollapseState(width),this.updateEffectiveOrientation(width,!0)});this.collapseResizeObserver=observer,this.collapseObservedElement=observedElement,this.collapseObserverOwnerDocument=ownerDocument,observer.observe(observedElement)}resetCollapseObserver(){this.collapseObserverGeneration+=1,this.collapseResizeObserver?.disconnect(),this.collapseResizeObserver=void 0,this.collapseObservedElement=void 0,this.collapseObserverOwnerDocument=void 0}syncCollapseObserver(){if(!this.responsiveObservationEnabled){this.resetCollapseObserver();return}this.armCollapseObserver()}get safeMin(){return finiteRange(this.min,10,0)}normalizedDefaultMin(){if(this.panelCount<=0)return 0;const requested=this.safeMin,available=Math.max(0,100-KEYBOARD_STEP);return Math.min(requested,available/this.panelCount)}resolveConstraintBounds(containerSize){const fallbackMin=this.normalizedDefaultMin(),fallback=Array.from({length:this.panelCount},()=>({min:fallbackMin,max:1/0}));if(this.panelCount<=0)return{bounds:[],usePanelConstraints:!0};const bounds=[];let minimumTotal=0,maximumTotal=0,hasUnboundedMaximum=!1,issueReason;for(let index=0;index<this.panelCount;index++){const constraint=this.panelConstraints[index];let min=this.safeMin,max=1/0,minSet=!1,maxSet=!1;constraint&&(constraint.minPx!=null&&Number.isFinite(constraint.minPx)&&constraint.minPx>=0&&containerSize>0&&(min=constraint.minPx/containerSize*100,minSet=!0),constraint.minPercent!=null&&Number.isFinite(constraint.minPercent)&&constraint.minPercent>=0&&(min=minSet?Math.max(min,constraint.minPercent):constraint.minPercent,minSet=!0),constraint.maxPx!=null&&Number.isFinite(constraint.maxPx)&&constraint.maxPx>=0&&containerSize>0&&(max=constraint.maxPx/containerSize*100,maxSet=!0),constraint.maxPercent!=null&&Number.isFinite(constraint.maxPercent)&&constraint.maxPercent>=0&&(max=maxSet?Math.min(max,constraint.maxPercent):constraint.maxPercent,maxSet=!0),(constraint.minPx!=null&&(!Number.isFinite(constraint.minPx)||constraint.minPx<0)||constraint.maxPx!=null&&(!Number.isFinite(constraint.maxPx)||constraint.maxPx<0)||constraint.minPercent!=null&&(!Number.isFinite(constraint.minPercent)||constraint.minPercent<0)||constraint.maxPercent!=null&&(!Number.isFinite(constraint.maxPercent)||constraint.maxPercent<0))&&(issueReason??="minimum-exceeds-maximum")),min>max&&(issueReason??="minimum-exceeds-maximum"),bounds.push({min,max}),minimumTotal+=min,Number.isFinite(max)?maximumTotal+=max:hasUnboundedMaximum=!0}return issueReason==null&&minimumTotal>100+1e-9&&(issueReason="minimum-total"),issueReason==null&&!hasUnboundedMaximum&&maximumTotal<100-1e-9&&(issueReason="maximum-total"),issueReason==null?{bounds,usePanelConstraints:!0}:{bounds:fallback,usePanelConstraints:!1,issue:{reason:issueReason,panelCount:this.panelCount,minimumTotal,maximumTotal:hasUnboundedMaximum?null:maximumTotal,containerSize}}}hasClampConstraint(constraint){return!!constraint&&(constraint.minPx!=null||constraint.maxPx!=null||constraint.minPercent!=null||constraint.maxPercent!=null)}minSideExpr(constraint){const terms=[];return constraint?.minPx!=null&&Number.isFinite(constraint.minPx)&&constraint.minPx>=0&&terms.push(`${constraint.minPx}px`),constraint?.minPercent!=null&&Number.isFinite(constraint.minPercent)&&constraint.minPercent>=0&&terms.push(`${constraint.minPercent}%`),terms.length===0?`${NO_MIN_PX}px`:terms.length===1?terms[0]:`max(${this.safeMin}%, ${terms.join(", ")})`}maxSideExpr(constraint){const terms=[];return constraint?.maxPx!=null&&Number.isFinite(constraint.maxPx)&&constraint.maxPx>=0&&terms.push(`${constraint.maxPx}px`),constraint?.maxPercent!=null&&Number.isFinite(constraint.maxPercent)&&constraint.maxPercent>=0&&terms.push(`${constraint.maxPercent}%`),terms.length===0?`${NO_MAX_PX}px`:terms.length===1?terms[0]:`min(${terms.join(", ")})`}clampPair(sizes,i,delta,containerSize=0){const next=[...sizes],currentA=next[i],currentB=next[i+1];if(currentA===void 0||currentB===void 0)return next;const pairTotal=currentA+currentB,bounds=this.resolveConstraintBounds(containerSize).bounds,a=bounds[i]??{min:0,max:1/0},b=bounds[i+1]??{min:0,max:1/0},loRaw=Math.max(a.min,pairTotal-b.max),hiRaw=Math.min(a.max,pairTotal-b.min),lo=Math.min(loRaw,pairTotal),hi=Math.max(hiRaw,lo),clampedA=Math.min(Math.max(currentA+delta,lo),hi);return next[i]=clampedA,next[i+1]=pairTotal-clampedA,next}requestResize(next,commit){return next.length===this.sizes.length&&next.every((size,index)=>Math.abs(size-this.sizes[index])<=1e-9)||this.emit("lr-resize-request",{sizes:[...next]},{cancelable:!0}).defaultPrevented?!1:(this.sizes=next,this.emit("lr-resize",{sizes:[...this.sizes]}),commit&&this.settle(),!0)}settle(){this.persist(),this.emit("lr-resize-change",{sizes:[...this.sizes]})}applyDelta(index,delta,commit){const next=this.clampPair(this.sizes,index,delta,this.getContainerSize());return next.length!==this.sizes.length||next.some((size,currentIndex)=>Math.abs(size-this.sizes[currentIndex])>1e-9)?(this.requestResize(next,commit),!0):!1}get floatingPanelEl(){const index=this.collapsingIndex;return index===-1?null:this.ownedPanels[index]??null}activateFloatingOverlay(){this.nativeModal.prepare();const opener=deepActiveElement(this.ownerDocument);this.overlayOpener=isHtmlElement(opener)?opener:null;const trigger=this.resolveExternalTrigger();this.overlayReturnTarget=trigger??this.overlayOpener;const panel=this.floatingPanelEl;panel&&(this.floatingDialogPanel=panel,this.floatingDialogPreviousRole=panel.getAttribute("role"),this.floatingDialogPreviousAriaModal=panel.getAttribute("aria-modal"),this.nativeModal.requested||(panel.setAttribute("role","dialog"),panel.setAttribute("aria-modal","true"))),this.overlayHandle=activateOverlay({host:this,panel:()=>this.floatingPanelEl,modalRoot:()=>this.floatingPanelEl,auxiliaryRoots:()=>{const root=this.nativeModal.helperMount;return root?[root]:[]},restoreFocusTo:trigger??void 0,onEscape:()=>this.setOpen(!1),onBackdrop:()=>this.setOpen(!1),lockScroll:!0,suspendWhenUnrendered:!0,deferredReturn:()=>{if(!(this.resolveExternalTrigger()||this.trigger||this.for))return;const panel2=this.floatingDialogPanel;return{candidates:()=>[this.resolveExternalTrigger(),this.overlayReturnTarget,this.overlayOpener],stranded:active=>panel2!==null&&composedContains(panel2,active),isCurrent:()=>!this.overlayActive}}})}deactivateFloatingOverlay(){this.stopNativeModalGeometry(),this.nativeModal.hide(),this.nativeModal.prepare(!1);const trigger=this.resolveExternalTrigger(),panel=this.floatingDialogPanel;trigger&&this.overlayHandle?.updateRestoreFocusTo(trigger),this.overlayHandle?.deactivate(),this.overlayHandle=void 0,this.floatingDialogPanel=null,panel&&(this.floatingDialogPreviousRole===null?panel.removeAttribute("role"):panel.setAttribute("role",this.floatingDialogPreviousRole),this.floatingDialogPreviousAriaModal===null?panel.removeAttribute("aria-modal"):panel.setAttribute("aria-modal",this.floatingDialogPreviousAriaModal))}endDragGestures(){this.drags.clear(),this.dragController.cancelAll()}dividerName(index){let label;try{label=this.dividerLabel?.(index,this.panelCount)}catch{}return typeof label=="string"&&label.trim()?label:this.localize("resizeDivider",void 0,{a:getNumberFormat(this.effectiveLocale).format(index+1),b:getNumberFormat(this.effectiveLocale).format(index+2)})}dividerValueRange(index,bounds=this.resolveConstraintBounds(this.getContainerSize()).bounds){const pairTotal=(this.sizes[index]??0)+(this.sizes[index+1]??0),leading=bounds[index],trailing=bounds[index+1],min=Math.max(leading.min,pairTotal-trailing.max);return{min,max:Math.max(min,Math.min(leading.max,pairTotal-trailing.min))}}updated(changed){super.updated(changed),this.overlayActive&&(this.syncNativeModalGeometry(),this.nativeModal.show()),(changed.has("collapse")||changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.syncCollapseObserver(),this.orientationBreakpoints.active?this.setAttribute("data-effective-orientation",this._effectiveOrientation):this.removeAttribute("data-effective-orientation"),(changed.has("panelConstraints")||changed.has("min"))&&(this.constraintConfigVersion+=1);const constraintResolution=this.resolveConstraintBounds(this.getContainerSize()),issue=constraintResolution.issue,issueKey=issue?`${issue.reason}:${issue.panelCount}:${this.constraintConfigVersion}`:"";issueKey!==this.constraintIssueKey&&(this.constraintIssueKey=issueKey,issue&&this.emit("lr-multi-split-constraints-invalid",issue));const collapsingIndex=this.collapseActive?this.collapsingIndex:-1;this.syncGutterObserver(collapsingIndex===-1&&this.panelConstraints.some(constraint=>finiteRange(constraint?.minPx??0,0,0)>0)),this.decorateOwnedPanels(constraintResolution),this.syncExternalTriggerA11y(),this.justOpened&&(this.justOpened=!1,this.overlayHandle?.focusInitial())}resolveExternalTrigger(){if(this.trigger)return this.trigger;if(!this.for)return null;const found=this.getRootNode().getElementById?.(this.for);return isHtmlElement(found)?found:null}syncExternalTriggerA11y(){const panel=this.ownedPanels[this.collapsingIndex],trigger=panel&&this.panelCount>1?this.resolveExternalTrigger():null;if(!this.isConnected||!panel||!trigger){this.releaseExternalTriggerA11y();return}this.triggerPanel!==panel&&(this.releaseExternalTriggerA11y(),this.triggerPanel=panel),panel.id||(this.generatedTriggerPanelId=nextId("multi-split-panel"),panel.id=this.generatedTriggerPanelId);const contribution={attributes:{"aria-expanded":this.paneExpanded?"true":"false"},controls:[panel]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution)}releaseExternalTriggerA11y(){this.triggerAria?.release(),this.triggerAria=void 0,this.triggerPanel&&this.generatedTriggerPanelId&&this.triggerPanel.id===this.generatedTriggerPanelId&&this.triggerPanel.removeAttribute("id"),this.triggerPanel=void 0,this.generatedTriggerPanelId=void 0}decorateOwnedPanels(constraintResolution=this.resolveConstraintBounds(this.getContainerSize())){const panels=this.ownedPanels;for(const panel of panels){const snapshot=this.panelOwnership.get(panel);snapshot&&this.adoptPanelOwnership(panel,snapshot)}const collapsingIndex=this.collapseActive?this.collapsingIndex:-1,pixelMinimumTotal=constraintResolution.usePanelConstraints?this.panelConstraints.slice(0,this.panelCount).reduce((total,constraint)=>total+finiteRange(constraint?.minPx??0,0,0),0):0,redistributedShare=new Array(panels.length).fill(0);if(collapsingIndex===-1){let freedPercent=0;const growableIndexes=[];let growableTotal=0;for(let i=0;i<panels.length;i++){const percent=this.sizes[i]??0,constraint=constraintResolution.usePanelConstraints?this.panelConstraints[i]:void 0;if(this.hasClampConstraint(constraint)){const bounds=constraintResolution.bounds[i],clamped=bounds?Math.min(Math.max(percent,bounds.min),bounds.max):percent;clamped<percent&&(freedPercent+=percent-clamped)}else growableIndexes.push(i),growableTotal+=percent}if(freedPercent>0&&growableTotal>0)for(const i of growableIndexes)redistributedShare[i]=freedPercent*((this.sizes[i]??0)/growableTotal)}panels.forEach((panel,i)=>{const snapshot=this.panelOwnership.get(panel);if(!snapshot)return;const percent=this.sizes[i]??0,constraint=constraintResolution.usePanelConstraints?this.panelConstraints[i]:void 0,pixelMinimum=finiteRange(constraint?.minPx??0,0,0);if(collapsingIndex===-1&&pixelMinimum>0&&pixelMinimumTotal>0?this.applyOwnedPanelStyleValue(panel,snapshot,"--_lr-multi-split-panel-min",`min(${pixelMinimum}px, max(0px, calc((100% - var(--_lr-multi-split-gutters, 0px)) * ${pixelMinimum/pixelMinimumTotal})))`):this.applyOwnedPanelStyle(panel,snapshot,"--_lr-multi-split-panel-min",snapshot.styles.get("--_lr-multi-split-panel-min")),this.applyOwnedPanelStyle(panel,snapshot,"inline-size",snapshot.styles.get("inline-size")),this.applyOwnedPanelHidden(panel,snapshot,snapshot.hidden),collapsingIndex===i&&this.collapseState==="rail")this.applyOwnedPanelStyleValue(panel,snapshot,"flex",`0 0 ${this.railWidth}`);else if(collapsingIndex===i&&this.collapseState==="floating"&&!this.open)this.applyOwnedPanelStyleValue(panel,snapshot,"flex","none"),this.applyOwnedPanelHidden(panel,snapshot,!0);else if(collapsingIndex===i&&this.collapseState==="floating")this.applyOwnedPanelStyleValue(panel,snapshot,"inline-size",`var(--lr-multi-split-floating-panel-inline-size, ${percent}%)`);else if(collapsingIndex!==-1&&i!==collapsingIndex)this.applyOwnedPanelStyleValue(panel,snapshot,"flex",this.hasClampConstraint(constraint)?`0 1 clamp(${this.minSideExpr(constraint)}, ${percent}%, ${this.maxSideExpr(constraint)})`:`${percent} 1 0%`);else{const adjustedPercent=percent+(redistributedShare[i]??0);this.applyOwnedPanelStyleValue(panel,snapshot,"flex",this.hasClampConstraint(constraint)?`0 1 clamp(${this.minSideExpr(constraint)}, ${percent}%, ${this.maxSideExpr(constraint)})`:`0 1 ${adjustedPercent}%`)}this.applyOwnedPanelStyleValue(panel,snapshot,"order",String(i*2)),collapsingIndex===i?this.applyOwnedPanelCollapseState(panel,snapshot,this.collapseState):this.applyOwnedPanelCollapseState(panel,snapshot,null)}),collapsingIndex!==-1?this.setAttribute("data-collapse-state",this.collapseState):this.removeAttribute("data-collapse-state")}render(){const dividers=[],bounds=this.renderConstraintBounds;for(let i=0;i<this.panelCount-1;i++){const{min:valueMin,max:valueMax}=this.dividerValueRange(i,bounds),disabled=this.isDividerDisabled(i);dividers.push(html`<div
1
+ import{__decorate}from"tslib";import{resolveIdReferencesIn}from"../../../internal/aria-reflection.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{leaseInlineStyleProperty}from"../../../internal/style-property-lease.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{isRtl}from"../../../internal/rtl.js";import{repairComposedFocus}from"../../../internal/focus-navigation.js";import{cancelDeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{nextId}from"../../../internal/a11y.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{finiteRange}from"../../../internal/numbers.js";import{SeparatorDragController,separatorArrowDirection,separatorCoordinate,separatorDelta}from"../../../internal/separator-drag.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{CollapseBreakpointController,OrientationBreakpointController}from"../../../internal/orientation-breakpoint.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{resolveCssLength}from"../../../internal/css-length.js";import{styles}from"./multi-split.styles.js";import{LYRA_DEFAULT_resizeDivider,LYRA_DEFAULT_resizeValuePercent}from"../../../internal/default-strings/layout.generated.js";const KEYBOARD_STEP=2;function isPersistedPanelLayout(value){if(typeof value!="object"||value===null)return!1;const candidate=value;return candidate.version!==1||!Array.isArray(candidate.panels)?!1:candidate.panels.every(panel=>{if(typeof panel!="object"||panel===null)return!1;const record=panel;return typeof record.panelId=="string"&&record.panelId!==""&&record.panelId.trim()===record.panelId&&typeof record.size=="number"&&Number.isFinite(record.size)&&record.size>=0})}const NO_MIN_PX=0,NO_MAX_PX=1e6,OWNED_PANEL_STYLE_PROPERTIES=["flex","order","inline-size","--_lr-multi-split-panel-min"];class LyraMultiSplit extends LyraElement{constructor(){super(...arguments),this.toggleProposalDepth=0,this.toggleProposalMutationVersion=0,this.forcedCloseVersion=0,this.sizes=[],this.defaultSizes=[],this.min=10,this.orientation="horizontal",this.orientationBreakpointBasis="container",this.narrowOrientation="vertical",this.panelConstraints=[],this.collapse="none",this.railWidth="3.5rem",this.railBreakpoint=640,this.floatBreakpoint=400,this.collapseBreakpointBasis="container",this.releasePinOnBreakpoint=!1,this.open=!1,this.trigger=null,this.for="",this.panelCount=0,this.sizesReconciledForMembership=!1,this._collapseState="wide",this._forced=!1,this.overlayActive=!1,this.justOpened=!1,this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1)},onUnexpectedClose:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1),this.overlayActive&&this.modalSurface.show()}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal,()=>this.baseEl??null),this.floatingGeometry=new Map,this.openingBlockSize=0,this.syncNativeModalGeometry=()=>{if(!this.overlayActive||!this.isConnected)return;const allocation=this.shadowRoot?.querySelector(".allocation"),reservation=this.shadowRoot?.querySelector(".allocation-reservation"),frame=this.nativeModal.requested?this.shadowRoot?.querySelector("[data-native-modal-carrier]"):this.baseEl;if(!allocation||!reservation||!frame)return;if(!this.nativeModalView){this.nativeModalView=this.ownerDocument.defaultView??void 0,this.nativeModalView?.addEventListener("scroll",this.syncNativeModalGeometry,!0),this.nativeModalView?.addEventListener("resize",this.syncNativeModalGeometry);const Observer=this.nativeModalView?.ResizeObserver;if(Observer){const observer=new Observer(this.syncNativeModalGeometry);this.nativeModalResizeObserver=observer,observer.observe(allocation)}}if(this.floatingFrame!==frame){for(const lease of this.floatingGeometry.values())lease.release();this.floatingGeometry.clear(),this.floatingFrame=frame}const set=(property2,value)=>{const lease=this.floatingGeometry.get(property2);lease?(frame.style.getPropertyValue(property2)!==value||frame.style.getPropertyPriority(property2))&&lease.set(value):this.floatingGeometry.set(property2,leaseInlineStyleProperty(frame,property2,value))};if(reservation.hidden){const height=this.baseEl?.getBoundingClientRect().height??0;this.openingBlockSize=height||this.openingBlockSize||allocation.getBoundingClientRect().height,set("position","fixed"),reservation.style.blockSize=`${this.openingBlockSize}px`,reservation.hidden=!1}const rect=allocation.getBoundingClientRect();for(const[property2,value]of Object.entries({position:"fixed",top:`${rect.top}px`,left:`${rect.left}px`,right:"auto",bottom:"auto",width:`${rect.width}px`,height:`${rect.height}px`,padding:"0","box-sizing":"border-box","max-inline-size":"none"}))set(property2,value)},this.overlayReturnTarget=null,this.overlayOpener=null,this.floatingDialogPanel=null,this.floatingDialogPreviousRole=null,this.floatingDialogPreviousAriaModal=null,this.drags=new Map,this.dragController=new SeparatorDragController(this,event=>this.onPointerMove(event),event=>this.onPointerUp(event)),this.ownedPanels=[],this.panelOwnership=new Map,this.constraintIssueKey="",this.constraintConfigVersion=0,this.renderConstraintBounds=[],this.initializedSizes=!1,this.measuredInlineSize=Number.POSITIVE_INFINITY,this._effectiveOrientation="horizontal",this.collapseObserverGeneration=0,this.gutterObservedDividers=[],this.gutterObservedContainerSize=0,this.orientationBreakpoints=new OrientationBreakpointController(this,()=>this.updateEffectiveOrientation(this.measuredInlineSize,!0)),this.collapseBreakpoints=new CollapseBreakpointController(this,()=>this.updateCollapseState(this.measuredInlineSize,!0)),this.onSlotChange=()=>{this.updateBrowserDerivedState(()=>this.syncPanelMembership())},this.onBackdropClick=()=>{this.overlayHandle?.dismissBackdrop()},this.onModalLayerClick=event=>{event.target===this.baseEl&&this.overlayHandle?.dismissBackdrop()},this.onPointerDown=(e,index)=>{if(e.button!==0||this.isDividerDisabled(index))return;const divider=e.currentTarget;this.dragController.start(e,divider)&&this.drags.set(e.pointerId,{index,startPos:separatorCoordinate(e,this.effectiveOrientation==="vertical"?"block":"inline"),base:this.baseEl,rtl:this.effectiveOrientation==="horizontal"&&isRtl(this),appliedDelta:0,acceptedResize:!1})},this.onPointerMove=e=>{const drag=this.drags.get(e.pointerId);if(!drag)return;if(this.isDividerDisabled(drag.index)){this.endDragGestures();return}if(this.effectiveOrientation==="horizontal"&&isRtl(this)!==drag.rtl){this.endDragGestures();return}const total=this.effectiveOrientation==="vertical"?drag.base.clientHeight:drag.base.clientWidth;if(!Number.isFinite(total)||total<=0){this.endDragGestures();return}const incremental=separatorDelta(drag.startPos,e,this.effectiveOrientation==="vertical"?"block":"inline",drag.rtl)/total*100-drag.appliedDelta,priorValue=this.sizes[drag.index];if(priorValue===void 0)return;const paired=this.clampPair(this.sizes,drag.index,incremental,total),pairedA=paired[drag.index],pairedB=paired[drag.index+1];if(pairedA===void 0||pairedB===void 0)return;const next=[...this.sizes];next[drag.index]=pairedA,next[drag.index+1]=pairedB,this.requestResize(next,!1)&&(drag.appliedDelta+=pairedA-priorValue,drag.acceptedResize=!0)},this.onPointerUp=e=>{const drag=this.drags.get(e.pointerId);drag&&(this.drags.delete(e.pointerId),e.type==="pointerup"&&drag.acceptedResize&&this.settle(),this.dragController.end(e.pointerId))},this.onDividerKeyDown=(e,index)=>{if(this.isDividerDisabled(index)||e.altKey||e.ctrlKey||e.metaKey||e.isComposing)return;const direction=separatorArrowDirection(e,this.effectiveOrientation==="vertical"?"block":"inline",this.effectiveOrientation==="horizontal"&&isRtl(this));if(e.key==="Home"||e.key==="End"){const{min,max}=this.dividerValueRange(index),current=this.sizes[index];if(current!==void 0){const target=e.key==="Home"?min:max;this.applyDelta(index,target-current,!0)&&e.preventDefault()}}else direction===1?this.applyDelta(index,KEYBOARD_STEP,!0)&&e.preventDefault():direction===-1&&this.applyDelta(index,-KEYBOARD_STEP,!0)&&e.preventDefault()}}static{this.defaultStrings={...super.defaultStrings,resizeDivider:LYRA_DEFAULT_resizeDivider,resizeValuePercent:LYRA_DEFAULT_resizeValuePercent}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["sizes","defaultSizes","panelConstraints"])}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-resize-request","lr-resize","lr-resize-change"])}static{this.properties={collapseState:{reflect:!0,attribute:"collapse-state",noAccessor:!0}}}stopNativeModalGeometry(){this.nativeModalView?.removeEventListener("scroll",this.syncNativeModalGeometry,!0),this.nativeModalView?.removeEventListener("resize",this.syncNativeModalGeometry),this.nativeModalView=void 0,this.nativeModalResizeObserver?.disconnect(),this.nativeModalResizeObserver=void 0;for(const lease of this.floatingGeometry.values())lease.release();this.floatingGeometry.clear(),this.floatingFrame=void 0,this.openingBlockSize=0;const reservation=this.shadowRoot?.querySelector(".allocation-reservation");reservation&&(reservation.hidden=!0,reservation.style.removeProperty("block-size"))}nativeModalLabel(){const panel=this.floatingPanelEl;return panel?panel.hasAttribute("aria-label")?panel.getAttribute("aria-label"):resolveIdReferencesIn(panel.getRootNode(),panel.getAttribute("aria-labelledby")).map(element=>element.textContent?.trim()).filter(Boolean).join(" ")||this.getAttribute("aria-label"):this.getAttribute("aria-label")}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.responsiveObservationEnabled&&this.seedInlineSize(),this.seedFirstRenderState(()=>this.syncPanelMembership(!1)),this.hasUpdated&&this.syncPanelMembership(!1),this.initializedSizes&&this.ensureSizes(),this.responsiveObservationEnabled&&this.armCollapseObserver(),this.hasUpdated&&this.overlayActive&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateFloatingOverlay(),queueMicrotask(()=>{!this.isConnected||!this.overlayActive||(this.syncNativeModalGeometry(),this.modalSurface.show(),this.overlayHandle?.focusInitial())})),this.hasUpdated&&this.syncExternalTriggerA11y()}seedInlineSize(){const hostWidth=this.getBoundingClientRect().width;hostWidth>0&&(this.measuredInlineSize=hostWidth)}disconnectedCallback(){this.modalSurface.disconnect(),this.stopNativeModalGeometry(),super.disconnectedCallback(),this.endDragGestures(),this.resetCollapseObserver(),this.resetGutterObserver(),this.overlayHandle?.suspend(),cancelDeferredFocusReturn(this),this.releaseExternalTriggerA11y(),this.releaseOwnedPanels()}adoptedCallback(){super.adoptedCallback(),cancelDeferredFocusReturn(this),this.releaseExternalTriggerA11y(),this.endDragGestures(),this.resetCollapseObserver(),this.resetGutterObserver(),this.releaseOwnedPanels()}firstUpdated(changed){super.firstUpdated(changed),this.responsiveObservationEnabled&&this.armCollapseObserver()}willUpdate(changed){if(super.willUpdate(changed),!this.ownerDocument&&this.panelCount===0&&(this.panelCount=Math.max(this.sizes.length,this.defaultSizes.length,this.panelConstraints.length)),!this.initializedSizes)this.initializeSizes(),this.initializedSizes=!0;else if(changed.has("sizes")){const previous=changed.get("sizes");this.sizesReconciledForMembership?this.sizesReconciledForMembership=!1:this.validLiveSizes(this.sizes)||(Array.isArray(previous)&&this.validLiveSizes(previous)?this.sizes=[...previous]:(this.sizes=[],this.ensureSizes()))}else this.sizes.length===0&&this.ensureSizes();if((changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.orientationBreakpoints.configure(this.orientationBreakpoint,this.orientationBreakpointBasis),!this.hasUpdated&&this.isConnected&&this.responsiveObservationEnabled&&this.seedInlineSize(),(changed.has("orientation")||changed.has("narrowOrientation")||changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.updateEffectiveOrientation(this.measuredInlineSize,this.hasUpdated&&this.orientationBreakpointBasis==="viewport"),changed.has("collapse")||changed.has("railBreakpoint")||changed.has("floatBreakpoint")||changed.has("collapseBreakpointBasis")){const previousEffective=changed.has("collapse")?this.effectiveCollapseStateFor(changed.get("collapse")??"none"):this.collapseState;changed.has("collapse")&&previousEffective!=="wide"&&this.endDragGestures(),this.collapseBreakpoints.configure(this.railBreakpoint,this.floatBreakpoint,this.collapseBreakpointBasis),this.collapsingIndex!==-1&&!this._forced&&(this._collapseState=this.collapseBreakpoints.classify(this.measuredInlineSize)),this.applyEffectiveCollapseTransition(previousEffective,this.collapseState,this.hasUpdated)}if(changed.has("open")||changed.has("collapseState")||changed.has("collapse")||changed.has("panelCount")){const next=this.collapseState==="floating"&&this.open;next!==this.overlayActive&&(this.overlayActive=next,next?(this.justOpened=!0,this.activateFloatingOverlay()):this.deactivateFloatingOverlay())}this.renderConstraintBounds=this.resolveConstraintBounds(this.getContainerSize()).bounds}get collapseState(){return this.effectiveCollapseStateFor(this.collapse)}set collapseState(next){if(next==="auto"){this.releaseCollapsePin(),this.updateCollapseState(this.currentMeasuredWidth());return}this._forced=!0,this.pinnedBand=this.collapseBreakpoints.classify(this.pinMeasurementWidth()),this.setRequestedCollapseState(next)}expandPane(){this.applyPaneIntent(!0)}collapsePane(){this.applyPaneIntent(!1)}togglePane(){this.applyPaneIntent(!this.paneExpanded)}get paneExpanded(){const state=this.collapseState;return state==="floating"?this.open:state==="wide"}applyPaneIntent(expanded){if(this.collapsingIndex===-1)return;const band=this.collapseBreakpoints.classify(this.pinMeasurementWidth());if(band==="floating"){this.collapseState!=="floating"&&(this.releaseCollapsePin(),this.setRequestedCollapseState("floating")),this.open=expanded;return}const target=expanded?"wide":"rail";if(this.collapseState!==target){if(target===band){this.releaseCollapsePin(),this.setRequestedCollapseState(target);return}this.collapseState=target}}releaseCollapsePin(){this._forced=!1,this.pinnedBand=void 0}pinMeasurementWidth(){const live=this.currentMeasuredWidth();return live>0?live:this.measuredInlineSize}get effectiveOrientation(){return this._effectiveOrientation}get responsiveObservationEnabled(){return this.collapse!=="none"||this.orientationBreakpoints.containerObservationEnabled}updateEffectiveOrientation(width,shouldEmit){const next=this.orientationBreakpoints.isBelow(width)?this.narrowOrientation:this.orientation;next!==this._effectiveOrientation&&(this.endDragGestures(),this._effectiveOrientation=next,this.requestUpdate(),shouldEmit&&this.emit("lr-multi-split-orientation-change",{orientation:next}),this._forced&&this.releasePinOnBreakpoint&&(this.releaseCollapsePin(),this.updateCollapseState(width,this.hasUpdated)))}currentMeasuredWidth(){return this.baseEl?.clientWidth??0}effectiveCollapseStateFor(collapse){return collapse!=="none"&&this.panelCount>=2?this._collapseState:"wide"}applyEffectiveCollapseTransition(previous,next,shouldEmit=!0){if(previous===next)return;this.endDragGestures(),this.requestUpdate("collapseState",previous);const forceClose=previous==="floating"&&next!=="floating"&&this.open,forcedCloseVersion=this.forcedCloseVersion;shouldEmit&&(this.relocateFocusOutOfCollapsingPanel(next),this.decorateOwnedPanels(),this.emit("lr-multi-split-collapse-change",{state:next})),forceClose&&this.forcedCloseVersion===forcedCloseVersion&&this.collapseState!=="floating"&&this.setOpen(!1,{force:!0})}relocateFocusOutOfCollapsingPanel(next){if(next==="wide"||next==="floating"&&this.open)return;const index=this.collapsingIndex;if(index===-1)return;const panel=this.ownedPanels[index];panel&&repairComposedFocus(panel,()=>this.collapseFocusFallbacks(panel))}collapseFocusFallbacks(collapsing){const dividers=[...this.renderRoot.querySelectorAll('[part="divider"]')];return[...new Set([...this.ownedPanels.filter(panel=>panel!==collapsing),...dividers.filter((_,index)=>!this.isDividerDisabled(index)),...dividers])]}setOpen(next,options){if(options?.force){this.open=next,this.forcedCloseVersion+=1,this.emit("lr-toggle",{expanded:next});return}if(this.open===next)return;const collapseState=this.collapseState,open=this.open,mutationVersion=this.toggleProposalMutationVersion;this.toggleProposalDepth+=1;try{if(this.emit("lr-toggle-request",{expanded:next},{cancelable:!0}).defaultPrevented||this.toggleProposalMutationVersion!==mutationVersion||this.collapseState!==collapseState||this.open!==open)return}finally{this.toggleProposalDepth-=1}this.open=next,this.emit("lr-toggle",{expanded:next})}requestUpdate(name,oldValue,options){this.toggleProposalDepth>0&&(name==="open"&&oldValue!==this.open||name==="collapse"&&oldValue!==this.collapse||name==="collapseState"&&oldValue!==this.collapseState)&&(this.toggleProposalMutationVersion+=1),super.requestUpdate(name,oldValue,options)}setRequestedCollapseState(next,shouldEmit=!0){const previousEffective=this.collapseState;if(next===this._collapseState)return;this._collapseState=next;const nextEffective=this.collapseState;this.applyEffectiveCollapseTransition(previousEffective,nextEffective,shouldEmit),previousEffective===nextEffective&&next!==nextEffective&&this.requestUpdate("collapseState",next)}get storageFullKey(){return this.storageKey?`lr-multi-split:${this.storageKey}:panels`:void 0}panelIdsFor(panels){const ids=[],seen=new Set;for(const panel of panels){const panelId=panel.getAttribute("panel-id")??"";if(!panelId||panelId.trim()!==panelId||seen.has(panelId))return null;seen.add(panelId),ids.push(panelId)}return ids}reconcileIdentitySizes(previousIds,previousValues,nextIds){if(previousIds.length!==previousValues.length||nextIds.length===0)return null;const previousSizes=new Map;previousIds.forEach((panelId,index)=>{previousSizes.set(panelId,previousValues[index])});const retainedTotal=nextIds.reduce((total,panelId)=>total+(previousSizes.get(panelId)??0),0),missingCount=nextIds.filter(panelId=>!previousSizes.has(panelId)).length;if(!(retainedTotal>0)){const equal=100/nextIds.length;return nextIds.map(()=>equal)}const newShare=100/nextIds.length,retainedScale=(100-newShare*missingCount)/retainedTotal;return nextIds.map(panelId=>{const previous=previousSizes.get(panelId);return previous===void 0?newShare:previous*retainedScale})}reconcileSizesByPanelId(previousPanels,nextPanels){if(previousPanels.length!==this.sizes.length||nextPanels.length===0)return null;const previousIds=this.panelIdsFor(previousPanels),nextIds=this.panelIdsFor(nextPanels);return!previousIds||!nextIds?null:this.reconcileIdentitySizes(previousIds,this.sizes,nextIds)}validInitialSizes(value){return!Array.isArray(value)||value.length!==this.panelCount||!value.every(size=>Number.isFinite(size)&&size>=this.safeMin)?!1:Math.abs(value.reduce((sum,size)=>sum+size,0)-100)<.01}validLiveSizes(value){if(!Array.isArray(value)||value.length!==this.panelCount)return!1;const floor=this.normalizedDefaultMin();return value.every(size=>Number.isFinite(size)&&size>=floor)?Math.abs(value.reduce((sum,size)=>sum+size,0)-100)<.01:!1}resolveDefaultSizes(){if(this.defaultSizes.length===0)return null;if(!this.defaultSizes.some(entry=>typeof entry=="string")){const numbers=this.defaultSizes;return this.validInitialSizes(numbers)?[...numbers]:null}const containerSize=this.currentMeasuredWidth()||this.getBoundingClientRect().width;if(!(containerSize>0))return null;const resolvedPx=[];for(const entry of this.defaultSizes){if(typeof entry=="number"){if(!Number.isFinite(entry))return null;resolvedPx.push(entry/100*containerSize);continue}const px=resolveCssLength(entry,{host:this,percentBase:containerSize,viewportBasis:this.ownerDocument.defaultView??void 0});if(px==null||!(px>=0))return null;resolvedPx.push(px)}const sum=resolvedPx.reduce((total,size)=>total+size,0);if(!(sum>0))return null;const normalized=resolvedPx.map(size=>size/sum*100);return this.validInitialSizes(normalized)?normalized:null}initializeSizes(){if(this.validInitialSizes(this.sizes)||this.loadPersisted())return;const resolved=this.resolveDefaultSizes();if(resolved){this.sizes=resolved;return}this.sizes=[],this.ensureSizes()}loadPersisted(){const panelIds=this.panelIdsFor(this.ownedPanels);if(!panelIds)return!1;const parsed=readPersistedState(this.storageFullKey,isPersistedPanelLayout);if(!parsed||parsed.panels.length===0)return!1;const persistedIds=[],persistedSizes=[],seen=new Set;for(const panel of parsed.panels){if(seen.has(panel.panelId))return!1;seen.add(panel.panelId),persistedIds.push(panel.panelId),persistedSizes.push(panel.size)}if(Math.abs(persistedSizes.reduce((sum,size)=>sum+size,0)-100)>=.01)return!1;const normalized=this.reconcileIdentitySizes(persistedIds,persistedSizes,panelIds);return normalized&&this.validInitialSizes(normalized)?(this.sizes=normalized,!0):!1}persist(){const panelIds=this.panelIdsFor(this.ownedPanels);if(!panelIds||panelIds.length!==this.sizes.length)return;const layout={version:1,panels:panelIds.map((panelId,index)=>({panelId,size:this.sizes[index]}))};writePersistedState(this.storageFullKey,layout)}ensureSizes(){if(this.panelCount===this.sizes.length)return;if(this.panelCount<=0){this.sizes=[];return}if(this.sizes.length===0){const equal=100/this.panelCount;this.sizes=Array.from({length:this.panelCount},()=>equal);return}const diff=this.panelCount-this.sizes.length;if(diff>0){const newShare=100/this.panelCount,scale=(100-newShare*diff)/100;this.sizes=[...this.sizes.map(s=>s*scale),...Array.from({length:diff},()=>newShare)]}else{const kept=this.sizes.slice(0,this.panelCount),removedTotal=this.sizes.slice(this.panelCount).reduce((sum,s)=>sum+s,0),keptTotal=kept.reduce((sum,s)=>sum+s,0)||1;this.sizes=kept.map(s=>s+s/keptTotal*removedTotal)}}readPanelStyle(panel,property2){return{value:panel.style.getPropertyValue(property2),priority:panel.style.getPropertyPriority(property2)}}samePanelStyle(left,right){return left.value===right.value&&left.priority===right.priority}snapshotPanelOwnership(panel){const styles2=new Map;for(const property2 of OWNED_PANEL_STYLE_PROPERTIES)styles2.set(property2,this.readPanelStyle(panel,property2));return{styles:styles2,appliedStyles:new Map,hidden:panel.hidden,collapseState:panel.getAttribute("data-collapse-state")}}adoptPanelOwnership(panel,snapshot){for(const property2 of OWNED_PANEL_STYLE_PROPERTIES){const current=this.readPanelStyle(panel,property2),applied=snapshot.appliedStyles.get(property2);(applied&&!this.samePanelStyle(current,applied)||!applied&&!this.samePanelStyle(current,snapshot.styles.get(property2)))&&snapshot.styles.set(property2,current)}(snapshot.appliedHidden!==void 0&&panel.hidden!==snapshot.appliedHidden||snapshot.appliedHidden===void 0&&panel.hidden!==snapshot.hidden)&&(snapshot.hidden=panel.hidden);const collapseState=panel.getAttribute("data-collapse-state");(snapshot.appliedCollapseState!==void 0&&collapseState!==snapshot.appliedCollapseState||snapshot.appliedCollapseState===void 0&&collapseState!==snapshot.collapseState)&&(snapshot.collapseState=collapseState)}applyOwnedPanelStyle(panel,snapshot,property2,value){value.value===""?panel.style.removeProperty(property2):panel.style.setProperty(property2,value.value,value.priority),snapshot.appliedStyles.set(property2,this.readPanelStyle(panel,property2))}applyOwnedPanelStyleValue(panel,snapshot,property2,value){this.applyOwnedPanelStyle(panel,snapshot,property2,{value,priority:""})}applyOwnedPanelHidden(panel,snapshot,hidden){panel.hidden=hidden,snapshot.appliedHidden=panel.hidden}applyOwnedPanelCollapseState(panel,snapshot,state){state===null?panel.removeAttribute("data-collapse-state"):panel.setAttribute("data-collapse-state",state),snapshot.appliedCollapseState=panel.getAttribute("data-collapse-state")}restorePanelOwnership(panel,snapshot){this.adoptPanelOwnership(panel,snapshot);for(const property2 of OWNED_PANEL_STYLE_PROPERTIES){const value=snapshot.styles.get(property2);value.value===""?panel.style.removeProperty(property2):panel.style.setProperty(property2,value.value,value.priority)}panel.hidden=snapshot.hidden,snapshot.collapseState===null?panel.removeAttribute("data-collapse-state"):panel.setAttribute("data-collapse-state",snapshot.collapseState)}panelProjectionDiverged(panel,snapshot){for(const property2 of OWNED_PANEL_STYLE_PROPERTIES){const current=this.readPanelStyle(panel,property2),expected=snapshot.appliedStyles.get(property2)??snapshot.styles.get(property2);if(!this.samePanelStyle(current,expected))return!0}if(panel.hidden!==(snapshot.appliedHidden??snapshot.hidden))return!0;const expectedCollapseState=snapshot.appliedCollapseState!==void 0?snapshot.appliedCollapseState:snapshot.collapseState;return panel.getAttribute("data-collapse-state")!==expectedCollapseState}resetPanelOwnershipObserver(){this.panelOwnershipObserver?.disconnect(),this.panelOwnershipObserver=void 0}observeOwnedPanels(){this.resetPanelOwnershipObserver();const MutationObserverConstructor=this.ownerDocument.defaultView?.MutationObserver;if(!MutationObserverConstructor||!this.isConnected||this.ownedPanels.length===0)return;const observer=new MutationObserverConstructor(records=>{records.some(record=>{const panel=record.target,snapshot=this.panelOwnership.get(panel);return snapshot?this.panelProjectionDiverged(panel,snapshot):!1})&&this.requestUpdate()});this.panelOwnershipObserver=observer;for(const panel of this.ownedPanels)observer.observe(panel,{attributes:!0,attributeFilter:["style","hidden","data-collapse-state"]})}samePanelSequence(next){return next.length===this.ownedPanels.length&&next.every((panel,index)=>panel===this.ownedPanels[index])}syncPanelMembership(reconcileSizes=!0){const next=[...this.children].filter(child=>child!==this.nativeModal.helperMount);if(this.samePanelSequence(next))return;const previousPanels=this.ownedPanels,identitySizes=reconcileSizes?this.reconcileSizesByPanelId(previousPanels,next):null,previousEffective=this.collapseState,nextSet=new Set(next);for(const panel of this.ownedPanels){if(nextSet.has(panel))continue;const snapshot=this.panelOwnership.get(panel);snapshot&&this.restorePanelOwnership(panel,snapshot),this.panelOwnership.delete(panel)}for(const panel of next)this.panelOwnership.has(panel)||this.panelOwnership.set(panel,this.snapshotPanelOwnership(panel));const countChanged=next.length!==this.panelCount;this.ownedPanels=next,this.panelCount=next.length,this.collapsingIndex!==-1&&!this._forced&&(this._collapseState=this.collapseBreakpoints.classify(this.currentMeasuredWidth())),this.applyEffectiveCollapseTransition(previousEffective,this.collapseState,this.hasUpdated),identitySizes?(this.sizesReconciledForMembership=!0,this.sizes=identitySizes):countChanged&&reconcileSizes&&(this.sizesReconciledForMembership=!0,this.ensureSizes()),this.observeOwnedPanels(),this.hasUpdated&&this.requestUpdate()}releaseOwnedPanels(){this.resetPanelOwnershipObserver();for(const panel of this.ownedPanels){const snapshot=this.panelOwnership.get(panel);snapshot&&this.restorePanelOwnership(panel,snapshot)}this.ownedPanels=[],this.panelOwnership.clear()}getContainerSize(){return this.baseEl?this.effectiveOrientation==="vertical"?this.baseEl.clientHeight:this.baseEl.clientWidth:0}resetGutterObserver(){this.gutterObserverFrame!==void 0&&(this.gutterObserverDocument?.defaultView?.cancelAnimationFrame(this.gutterObserverFrame),this.gutterObserverFrame=void 0),this.gutterResizeObserver?.disconnect(),this.gutterResizeObserver=void 0,this.gutterObserverDocument=void 0,this.gutterObservedDividers=[],this.baseEl?.style.removeProperty("--_lr-multi-split-gutters")}updateGutterBudget(){const view=this.ownerDocument.defaultView,base=this.baseEl;if(!view||!base)return;const vertical=this.effectiveOrientation==="vertical",value=`${this.gutterObservedDividers.reduce((total,divider)=>{const style=view.getComputedStyle(divider),properties=vertical?["height","padding-top","padding-bottom","border-top-width","border-bottom-width"]:["width","padding-left","padding-right","border-left-width","border-right-width"],boxProperties=style.boxSizing==="border-box"?properties.slice(0,1):properties;return total+boxProperties.reduce((size,property2)=>size+finiteRange(parseFloat(style.getPropertyValue(property2)),0,0),0)},0)}px`;base.style.getPropertyValue("--_lr-multi-split-gutters")!==value&&base.style.setProperty("--_lr-multi-split-gutters",value)}syncGutterObserver(enabled){const base=this.baseEl;if(!enabled||!this.isConnected||!base){this.resetGutterObserver();return}const ownerDocument=this.ownerDocument,dividers=[...base.querySelectorAll('[part="divider"]')];if(this.gutterResizeObserver&&this.gutterObserverDocument===ownerDocument&&dividers.length===this.gutterObservedDividers.length&&dividers.every((divider,index)=>divider===this.gutterObservedDividers[index])){this.updateGutterBudget();return}this.resetGutterObserver(),this.gutterObservedDividers=dividers,this.gutterObserverDocument=ownerDocument,this.gutterObservedContainerSize=this.getContainerSize(),this.updateGutterBudget();const ownerWindow=ownerDocument.defaultView,ResizeObserverConstructor=ownerWindow?.ResizeObserver;if(!ownerWindow||!ResizeObserverConstructor)return;const observer=new ResizeObserverConstructor(()=>{if(this.gutterResizeObserver!==observer||!this.isConnected||this.ownerDocument!==ownerDocument)return;this.updateGutterBudget();const size=this.getContainerSize();size!==this.gutterObservedContainerSize&&(this.gutterObservedContainerSize=size,this.requestUpdate())});this.gutterResizeObserver=observer;const frame=ownerWindow.requestAnimationFrame(()=>{if(!(this.gutterObserverFrame!==frame||this.gutterResizeObserver!==observer||!this.isConnected||this.ownerDocument!==ownerDocument||this.baseEl!==base)){this.gutterObserverFrame=void 0,observer.observe(base,{box:"border-box"});for(const divider of dividers)observer.observe(divider,{box:"border-box"})}});this.gutterObserverFrame=frame}get collapsingIndex(){return this.collapse==="none"||this.panelCount<2?-1:this.collapse==="start"?0:this.panelCount-1}get collapseActive(){return this.collapsingIndex!==-1&&this.collapseState!=="wide"}isDividerDisabled(index){if(!this.collapseActive)return!1;const adjacent=this.collapsingIndex===0?0:this.panelCount-2;return index===adjacent}updateCollapseState(width,shouldEmit=!0){if(this.collapse==="none")return;const classified=this.collapseBreakpoints.classify(width);if(this._forced){if(!this.releasePinOnBreakpoint||classified===this.pinnedBand)return;this.releaseCollapsePin()}this.setRequestedCollapseState(classified,shouldEmit)}armCollapseObserver(){const observedElement=this.baseEl;if(!this.isConnected||!observedElement)return;const ownerDocument=this.ownerDocument;if(this.collapseResizeObserver&&this.collapseObservedElement===observedElement&&this.collapseObserverOwnerDocument===ownerDocument)return;this.resetCollapseObserver();const ResizeObserverConstructor=ownerDocument.defaultView?.ResizeObserver;if(!ResizeObserverConstructor)return;const generation=this.collapseObserverGeneration,observer=new ResizeObserverConstructor(entries=>{if(this.collapseResizeObserver!==observer||this.collapseObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.baseEl!==observedElement)return;const box=entries[0]?.contentBoxSize?.[0],width=box?box.inlineSize:observedElement.getBoundingClientRect().width;this.measuredInlineSize=width,this.updateCollapseState(width),this.updateEffectiveOrientation(width,!0)});this.collapseResizeObserver=observer,this.collapseObservedElement=observedElement,this.collapseObserverOwnerDocument=ownerDocument,observer.observe(observedElement)}resetCollapseObserver(){this.collapseObserverGeneration+=1,this.collapseResizeObserver?.disconnect(),this.collapseResizeObserver=void 0,this.collapseObservedElement=void 0,this.collapseObserverOwnerDocument=void 0}syncCollapseObserver(){if(!this.responsiveObservationEnabled){this.resetCollapseObserver();return}this.armCollapseObserver()}get safeMin(){return finiteRange(this.min,10,0)}normalizedDefaultMin(){if(this.panelCount<=0)return 0;const requested=this.safeMin,available=Math.max(0,100-KEYBOARD_STEP);return Math.min(requested,available/this.panelCount)}resolveConstraintBounds(containerSize){const fallbackMin=this.normalizedDefaultMin(),fallback=Array.from({length:this.panelCount},()=>({min:fallbackMin,max:1/0}));if(this.panelCount<=0)return{bounds:[],usePanelConstraints:!0};const bounds=[];let minimumTotal=0,maximumTotal=0,hasUnboundedMaximum=!1,issueReason;for(let index=0;index<this.panelCount;index++){const constraint=this.panelConstraints[index];let min=this.safeMin,max=1/0,minSet=!1,maxSet=!1;constraint&&(constraint.minPx!=null&&Number.isFinite(constraint.minPx)&&constraint.minPx>=0&&containerSize>0&&(min=constraint.minPx/containerSize*100,minSet=!0),constraint.minPercent!=null&&Number.isFinite(constraint.minPercent)&&constraint.minPercent>=0&&(min=minSet?Math.max(min,constraint.minPercent):constraint.minPercent,minSet=!0),constraint.maxPx!=null&&Number.isFinite(constraint.maxPx)&&constraint.maxPx>=0&&containerSize>0&&(max=constraint.maxPx/containerSize*100,maxSet=!0),constraint.maxPercent!=null&&Number.isFinite(constraint.maxPercent)&&constraint.maxPercent>=0&&(max=maxSet?Math.min(max,constraint.maxPercent):constraint.maxPercent,maxSet=!0),(constraint.minPx!=null&&(!Number.isFinite(constraint.minPx)||constraint.minPx<0)||constraint.maxPx!=null&&(!Number.isFinite(constraint.maxPx)||constraint.maxPx<0)||constraint.minPercent!=null&&(!Number.isFinite(constraint.minPercent)||constraint.minPercent<0)||constraint.maxPercent!=null&&(!Number.isFinite(constraint.maxPercent)||constraint.maxPercent<0))&&(issueReason??="minimum-exceeds-maximum")),min>max&&(issueReason??="minimum-exceeds-maximum"),bounds.push({min,max}),minimumTotal+=min,Number.isFinite(max)?maximumTotal+=max:hasUnboundedMaximum=!0}return issueReason==null&&minimumTotal>100+1e-9&&(issueReason="minimum-total"),issueReason==null&&!hasUnboundedMaximum&&maximumTotal<100-1e-9&&(issueReason="maximum-total"),issueReason==null?{bounds,usePanelConstraints:!0}:{bounds:fallback,usePanelConstraints:!1,issue:{reason:issueReason,panelCount:this.panelCount,minimumTotal,maximumTotal:hasUnboundedMaximum?null:maximumTotal,containerSize}}}hasClampConstraint(constraint){return!!constraint&&(constraint.minPx!=null||constraint.maxPx!=null||constraint.minPercent!=null||constraint.maxPercent!=null)}minSideExpr(constraint){const terms=[];return constraint?.minPx!=null&&Number.isFinite(constraint.minPx)&&constraint.minPx>=0&&terms.push(`${constraint.minPx}px`),constraint?.minPercent!=null&&Number.isFinite(constraint.minPercent)&&constraint.minPercent>=0&&terms.push(`${constraint.minPercent}%`),terms.length===0?`${NO_MIN_PX}px`:terms.length===1?terms[0]:`max(${this.safeMin}%, ${terms.join(", ")})`}maxSideExpr(constraint){const terms=[];return constraint?.maxPx!=null&&Number.isFinite(constraint.maxPx)&&constraint.maxPx>=0&&terms.push(`${constraint.maxPx}px`),constraint?.maxPercent!=null&&Number.isFinite(constraint.maxPercent)&&constraint.maxPercent>=0&&terms.push(`${constraint.maxPercent}%`),terms.length===0?`${NO_MAX_PX}px`:terms.length===1?terms[0]:`min(${terms.join(", ")})`}clampPair(sizes,i,delta,containerSize=0){const next=[...sizes],currentA=next[i],currentB=next[i+1];if(currentA===void 0||currentB===void 0)return next;const pairTotal=currentA+currentB,bounds=this.resolveConstraintBounds(containerSize).bounds,a=bounds[i]??{min:0,max:1/0},b=bounds[i+1]??{min:0,max:1/0},loRaw=Math.max(a.min,pairTotal-b.max),hiRaw=Math.min(a.max,pairTotal-b.min),lo=Math.min(loRaw,pairTotal),hi=Math.max(hiRaw,lo),clampedA=Math.min(Math.max(currentA+delta,lo),hi);return next[i]=clampedA,next[i+1]=pairTotal-clampedA,next}requestResize(next,commit){return next.length===this.sizes.length&&next.every((size,index)=>Math.abs(size-this.sizes[index])<=1e-9)||this.emit("lr-resize-request",{sizes:[...next]},{cancelable:!0}).defaultPrevented?!1:(this.sizes=next,this.emit("lr-resize",{sizes:[...this.sizes]}),commit&&this.settle(),!0)}settle(){this.persist(),this.emit("lr-resize-change",{sizes:[...this.sizes]})}applyDelta(index,delta,commit){const next=this.clampPair(this.sizes,index,delta,this.getContainerSize());return next.length!==this.sizes.length||next.some((size,currentIndex)=>Math.abs(size-this.sizes[currentIndex])>1e-9)?(this.requestResize(next,commit),!0):!1}get floatingPanelEl(){const index=this.collapsingIndex;return index===-1?null:this.ownedPanels[index]??null}activateFloatingOverlay(){this.openingBlockSize=this.baseEl?.getBoundingClientRect().height??0,this.modalSurface.prepare();const opener=deepActiveElement(this.ownerDocument);this.overlayOpener=isHtmlElement(opener)?opener:null;const trigger=this.resolveExternalTrigger();this.overlayReturnTarget=trigger??this.overlayOpener;const panel=this.floatingPanelEl;panel&&(this.floatingDialogPanel=panel,this.floatingDialogPreviousRole=panel.getAttribute("role"),this.floatingDialogPreviousAriaModal=panel.getAttribute("aria-modal"),this.nativeModal.requested||(panel.setAttribute("role","dialog"),panel.setAttribute("aria-modal","true"))),this.overlayHandle=activateOverlay({host:this,panel:()=>this.floatingPanelEl,modalRoot:()=>this.floatingPanelEl,auxiliaryRoots:()=>{const root=this.nativeModal.helperMount;return root?[root]:[]},restoreFocusTo:trigger??void 0,onEscape:()=>this.setOpen(!1),onBackdrop:()=>this.setOpen(!1),lockScroll:!0,suspendWhenUnrendered:!0,deferredReturn:()=>{if(!(this.resolveExternalTrigger()||this.trigger||this.for))return;const panel2=this.floatingDialogPanel;return{candidates:()=>[this.resolveExternalTrigger(),this.overlayReturnTarget,this.overlayOpener],stranded:active=>panel2!==null&&composedContains(panel2,active),isCurrent:()=>!this.overlayActive}}})}deactivateFloatingOverlay(){this.modalSurface.hide(),this.stopNativeModalGeometry(),this.nativeModal.prepare(!1);const trigger=this.resolveExternalTrigger(),panel=this.floatingDialogPanel;trigger&&this.overlayHandle?.updateRestoreFocusTo(trigger),this.overlayHandle?.deactivate(),this.overlayHandle=void 0,this.floatingDialogPanel=null,panel&&(this.floatingDialogPreviousRole===null?panel.removeAttribute("role"):panel.setAttribute("role",this.floatingDialogPreviousRole),this.floatingDialogPreviousAriaModal===null?panel.removeAttribute("aria-modal"):panel.setAttribute("aria-modal",this.floatingDialogPreviousAriaModal))}endDragGestures(){this.drags.clear(),this.dragController.cancelAll()}dividerName(index){let label;try{label=this.dividerLabel?.(index,this.panelCount)}catch{}return typeof label=="string"&&label.trim()?label:this.localize("resizeDivider",void 0,{a:getNumberFormat(this.effectiveLocale).format(index+1),b:getNumberFormat(this.effectiveLocale).format(index+2)})}dividerValueRange(index,bounds=this.resolveConstraintBounds(this.getContainerSize()).bounds){const pairTotal=(this.sizes[index]??0)+(this.sizes[index+1]??0),leading=bounds[index],trailing=bounds[index+1],min=Math.max(leading.min,pairTotal-trailing.max);return{min,max:Math.max(min,Math.min(leading.max,pairTotal-trailing.min))}}updated(changed){super.updated(changed),this.overlayActive&&(this.syncNativeModalGeometry(),this.modalSurface.show()),(changed.has("collapse")||changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.syncCollapseObserver(),this.orientationBreakpoints.active?this.setAttribute("data-effective-orientation",this._effectiveOrientation):this.removeAttribute("data-effective-orientation"),(changed.has("panelConstraints")||changed.has("min"))&&(this.constraintConfigVersion+=1);const constraintResolution=this.resolveConstraintBounds(this.getContainerSize()),issue=constraintResolution.issue,issueKey=issue?`${issue.reason}:${issue.panelCount}:${this.constraintConfigVersion}`:"";issueKey!==this.constraintIssueKey&&(this.constraintIssueKey=issueKey,issue&&this.emit("lr-multi-split-constraints-invalid",issue));const collapsingIndex=this.collapseActive?this.collapsingIndex:-1;this.syncGutterObserver(collapsingIndex===-1&&this.panelConstraints.some(constraint=>finiteRange(constraint?.minPx??0,0,0)>0)),this.decorateOwnedPanels(constraintResolution),this.syncExternalTriggerA11y(),this.justOpened&&(this.justOpened=!1,this.overlayHandle?.focusInitial())}resolveExternalTrigger(){if(this.trigger)return this.trigger;if(!this.for)return null;const found=this.getRootNode().getElementById?.(this.for);return isHtmlElement(found)?found:null}syncExternalTriggerA11y(){const panel=this.ownedPanels[this.collapsingIndex],trigger=panel&&this.panelCount>1?this.resolveExternalTrigger():null;if(!this.isConnected||!panel||!trigger){this.releaseExternalTriggerA11y();return}this.triggerPanel!==panel&&(this.releaseExternalTriggerA11y(),this.triggerPanel=panel),panel.id||(this.generatedTriggerPanelId=nextId("multi-split-panel"),panel.id=this.generatedTriggerPanelId);const contribution={attributes:{"aria-expanded":this.paneExpanded?"true":"false"},controls:[panel]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution)}releaseExternalTriggerA11y(){this.triggerAria?.release(),this.triggerAria=void 0,this.triggerPanel&&this.generatedTriggerPanelId&&this.triggerPanel.id===this.generatedTriggerPanelId&&this.triggerPanel.removeAttribute("id"),this.triggerPanel=void 0,this.generatedTriggerPanelId=void 0}decorateOwnedPanels(constraintResolution=this.resolveConstraintBounds(this.getContainerSize())){const panels=this.ownedPanels;for(const panel of panels){const snapshot=this.panelOwnership.get(panel);snapshot&&this.adoptPanelOwnership(panel,snapshot)}const collapsingIndex=this.collapseActive?this.collapsingIndex:-1,pixelMinimumTotal=constraintResolution.usePanelConstraints?this.panelConstraints.slice(0,this.panelCount).reduce((total,constraint)=>total+finiteRange(constraint?.minPx??0,0,0),0):0,redistributedShare=new Array(panels.length).fill(0);if(collapsingIndex===-1){let freedPercent=0;const growableIndexes=[];let growableTotal=0;for(let i=0;i<panels.length;i++){const percent=this.sizes[i]??0,constraint=constraintResolution.usePanelConstraints?this.panelConstraints[i]:void 0;if(this.hasClampConstraint(constraint)){const bounds=constraintResolution.bounds[i],clamped=bounds?Math.min(Math.max(percent,bounds.min),bounds.max):percent;clamped<percent&&(freedPercent+=percent-clamped)}else growableIndexes.push(i),growableTotal+=percent}if(freedPercent>0&&growableTotal>0)for(const i of growableIndexes)redistributedShare[i]=freedPercent*((this.sizes[i]??0)/growableTotal)}panels.forEach((panel,i)=>{const snapshot=this.panelOwnership.get(panel);if(!snapshot)return;const percent=this.sizes[i]??0,constraint=constraintResolution.usePanelConstraints?this.panelConstraints[i]:void 0,pixelMinimum=finiteRange(constraint?.minPx??0,0,0);if(collapsingIndex===-1&&pixelMinimum>0&&pixelMinimumTotal>0?this.applyOwnedPanelStyleValue(panel,snapshot,"--_lr-multi-split-panel-min",`min(${pixelMinimum}px, max(0px, calc((100% - var(--_lr-multi-split-gutters, 0px)) * ${pixelMinimum/pixelMinimumTotal})))`):this.applyOwnedPanelStyle(panel,snapshot,"--_lr-multi-split-panel-min",snapshot.styles.get("--_lr-multi-split-panel-min")),this.applyOwnedPanelStyle(panel,snapshot,"inline-size",snapshot.styles.get("inline-size")),this.applyOwnedPanelHidden(panel,snapshot,snapshot.hidden),collapsingIndex===i&&this.collapseState==="rail")this.applyOwnedPanelStyleValue(panel,snapshot,"flex",`0 0 ${this.railWidth}`);else if(collapsingIndex===i&&this.collapseState==="floating"&&!this.open)this.applyOwnedPanelStyleValue(panel,snapshot,"flex","none"),this.applyOwnedPanelHidden(panel,snapshot,!0);else if(collapsingIndex===i&&this.collapseState==="floating")this.applyOwnedPanelStyleValue(panel,snapshot,"inline-size",`var(--lr-multi-split-floating-panel-inline-size, ${percent}%)`);else if(collapsingIndex!==-1&&i!==collapsingIndex)this.applyOwnedPanelStyleValue(panel,snapshot,"flex",this.hasClampConstraint(constraint)?`0 1 clamp(${this.minSideExpr(constraint)}, ${percent}%, ${this.maxSideExpr(constraint)})`:`${percent} 1 0%`);else{const adjustedPercent=percent+(redistributedShare[i]??0);this.applyOwnedPanelStyleValue(panel,snapshot,"flex",this.hasClampConstraint(constraint)?`0 1 clamp(${this.minSideExpr(constraint)}, ${percent}%, ${this.maxSideExpr(constraint)})`:`0 1 ${adjustedPercent}%`)}this.applyOwnedPanelStyleValue(panel,snapshot,"order",String(i*2)),collapsingIndex===i?this.applyOwnedPanelCollapseState(panel,snapshot,this.collapseState):this.applyOwnedPanelCollapseState(panel,snapshot,null)}),collapsingIndex!==-1?this.setAttribute("data-collapse-state",this.collapseState):this.removeAttribute("data-collapse-state")}render(){const dividers=[],bounds=this.renderConstraintBounds;for(let i=0;i<this.panelCount-1;i++){const{min:valueMin,max:valueMax}=this.dividerValueRange(i,bounds),disabled=this.isDividerDisabled(i);dividers.push(html`<div
2
2
  part="divider"
3
3
  role="separator"
4
4
  aria-label=${this.dividerName(i)}
@@ -12,9 +12,12 @@ import{__decorate}from"tslib";import{resolveIdReferencesIn}from"../../../interna
12
12
  style=${`order:${i*2+1}`}
13
13
  @pointerdown=${e=>this.onPointerDown(e,i)}
14
14
  @keydown=${e=>this.onDividerKeyDown(e,i)}
15
- ></div>`)}const showBackdrop=this.collapseState==="floating"&&this.open;return this.nativeModal.render(html`<div part="base" @click=${this.onModalLayerClick}>
15
+ ></div>`)}const showBackdrop=this.collapseState==="floating"&&this.open;return html`<div class="allocation">
16
+ <div class="allocation-reservation" aria-hidden="true" inert hidden></div>
17
+ ${this.nativeModal.render(html`<div part="base" @click=${this.onModalLayerClick}>
16
18
  <slot @slotchange=${this.onSlotChange}></slot>
17
19
  ${this.nativeModal.renderHelperSlot()}
18
20
  ${dividers}
19
21
  ${showBackdrop?html`<div part="backdrop" @click=${this.onBackdropClick}></div>`:nothing}
20
- </div>`,{label:this.nativeModalLabel()})}}__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"sizes",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"defaultSizes",void 0),__decorate([property({type:Number})],LyraMultiSplit.prototype,"min",void 0),__decorate([property({reflect:!0})],LyraMultiSplit.prototype,"orientation",void 0),__decorate([property({attribute:"orientation-breakpoint"})],LyraMultiSplit.prototype,"orientationBreakpoint",void 0),__decorate([property({reflect:!0,attribute:"orientation-breakpoint-basis"})],LyraMultiSplit.prototype,"orientationBreakpointBasis",void 0),__decorate([property({reflect:!0,attribute:"narrow-orientation"})],LyraMultiSplit.prototype,"narrowOrientation",void 0),__decorate([property({attribute:"storage-key"})],LyraMultiSplit.prototype,"storageKey",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"panelConstraints",void 0),__decorate([property({reflect:!0})],LyraMultiSplit.prototype,"collapse",void 0),__decorate([property({attribute:"rail-width"})],LyraMultiSplit.prototype,"railWidth",void 0),__decorate([property({attribute:"rail-breakpoint"})],LyraMultiSplit.prototype,"railBreakpoint",void 0),__decorate([property({attribute:"float-breakpoint"})],LyraMultiSplit.prototype,"floatBreakpoint",void 0),__decorate([property({reflect:!0,attribute:"collapse-breakpoint-basis"})],LyraMultiSplit.prototype,"collapseBreakpointBasis",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"release-pin-on-breakpoint"})],LyraMultiSplit.prototype,"releasePinOnBreakpoint",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraMultiSplit.prototype,"open",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"trigger",void 0),__decorate([property()],LyraMultiSplit.prototype,"for",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"dividerLabel",void 0),__decorate([property({type:Number,attribute:"data-lr-panel-count",reflect:!0})],LyraMultiSplit.prototype,"panelCount",void 0),__decorate([query('[part="base"]')],LyraMultiSplit.prototype,"baseEl",void 0);export{LyraMultiSplit};
22
+ </div>`,{label:this.nativeModalLabel()})}
23
+ </div>`}}__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"sizes",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"defaultSizes",void 0),__decorate([property({type:Number})],LyraMultiSplit.prototype,"min",void 0),__decorate([property({reflect:!0})],LyraMultiSplit.prototype,"orientation",void 0),__decorate([property({attribute:"orientation-breakpoint"})],LyraMultiSplit.prototype,"orientationBreakpoint",void 0),__decorate([property({reflect:!0,attribute:"orientation-breakpoint-basis"})],LyraMultiSplit.prototype,"orientationBreakpointBasis",void 0),__decorate([property({reflect:!0,attribute:"narrow-orientation"})],LyraMultiSplit.prototype,"narrowOrientation",void 0),__decorate([property({attribute:"storage-key"})],LyraMultiSplit.prototype,"storageKey",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"panelConstraints",void 0),__decorate([property({reflect:!0})],LyraMultiSplit.prototype,"collapse",void 0),__decorate([property({attribute:"rail-width"})],LyraMultiSplit.prototype,"railWidth",void 0),__decorate([property({attribute:"rail-breakpoint"})],LyraMultiSplit.prototype,"railBreakpoint",void 0),__decorate([property({attribute:"float-breakpoint"})],LyraMultiSplit.prototype,"floatBreakpoint",void 0),__decorate([property({reflect:!0,attribute:"collapse-breakpoint-basis"})],LyraMultiSplit.prototype,"collapseBreakpointBasis",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"release-pin-on-breakpoint"})],LyraMultiSplit.prototype,"releasePinOnBreakpoint",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraMultiSplit.prototype,"open",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"trigger",void 0),__decorate([property()],LyraMultiSplit.prototype,"for",void 0),__decorate([property({attribute:!1})],LyraMultiSplit.prototype,"dividerLabel",void 0),__decorate([property({type:Number,attribute:"data-lr-panel-count",reflect:!0})],LyraMultiSplit.prototype,"panelCount",void 0),__decorate([query('[part="base"]')],LyraMultiSplit.prototype,"baseEl",void 0);export{LyraMultiSplit};
@@ -1 +1 @@
1
- import{focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; block-size: 100%; --_lr-multi-split-overlay-color: var(--lr-color-overlay); --_lr-multi-split-divider-target-size: max( var(--lr-icon-button-size), var(--lr-size-3px) ); --_lr-multi-split-divider-thickness: var(--lr-size-3px); --_lr-multi-split-divider-color: var(--lr-color-border); --_lr-multi-split-divider-hover-color: var(--lr-color-brand); --_lr-multi-split-divider-active-color: color-mix( in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part="base"] { --_lr-multi-split-panel-min: 0; --_lr-multi-split-gutters: 0; display: flex; position: relative; inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; block-size: 100%; } ::slotted(*) { flex: 1 1 0; min-inline-size: var(--_lr-multi-split-panel-min, 0); max-inline-size: 100%; min-block-size: 0; max-block-size: 100%; overflow: auto; overflow-wrap: anywhere; box-sizing: border-box; } ::slotted([hidden]:not([hidden="until-found" i])) { display: none !important; } :host([orientation="vertical"]) [part="base"] { flex-direction: column; } :host([orientation="vertical"]) ::slotted(*), :host([data-effective-orientation="vertical"]) ::slotted(*) { min-inline-size: 0; min-block-size: var(--_lr-multi-split-panel-min, 0); } :host([data-effective-orientation="horizontal"]) ::slotted(*) { min-inline-size: var(--_lr-multi-split-panel-min, 0); min-block-size: 0; } [part="divider"] { position: relative; flex: 0 0 auto; inline-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); min-block-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-block-size: 100%; background: transparent; cursor: col-resize; touch-action: none; } [part="divider"]::before { content: ""; position: absolute; inset-block: 0; inset-inline: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); background: var( --lr-multi-split-divider-color, var(--_lr-multi-split-divider-color) ); pointer-events: none; transition: background-color var(--lr-transition-fast); } :host(:where([orientation="vertical"])) [part="divider"] { inline-size: 100%; min-inline-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-inline-size: 100%; min-block-size: 0; block-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); cursor: row-resize; } :host(:where([orientation="vertical"])) [part="divider"]::before { inset-block: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); inset-inline: 0; } :host([data-effective-orientation="vertical"]) [part="base"] { flex-direction: column; } :host([data-effective-orientation="horizontal"]) [part="base"] { flex-direction: row; } :host(:where([data-effective-orientation="vertical"])) [part="divider"] { inline-size: 100%; min-inline-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-inline-size: 100%; min-block-size: 0; block-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); cursor: row-resize; } :host(:where([data-effective-orientation="vertical"])) [part="divider"]::before { inset-block: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); inset-inline: 0; } :host(:where([data-effective-orientation="horizontal"])) [part="divider"] { inline-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); min-block-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-block-size: 100%; block-size: auto; cursor: col-resize; } :host(:where([data-effective-orientation="horizontal"])) [part="divider"]::before { inset-block: 0; inset-inline: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); } [part="divider"]:hover::before { background: var( --lr-multi-split-divider-hover-color, var(--_lr-multi-split-divider-hover-color) ); } [part="divider"]:active::before { background: var( --lr-multi-split-divider-active-color, var(--_lr-multi-split-divider-active-color) ); } [part="divider"]:focus-visible { ${focusRing} } [part="divider"][aria-disabled="true"] { cursor: default; pointer-events: none; } :host([data-collapse-state="floating"]) [part="divider"][aria-disabled="true"] { flex: 0 0 0; min-inline-size: 0; min-block-size: 0; } :host([data-collapse-state="floating"]) [part="divider"][aria-disabled="true"]::before { content: none; } ::slotted([data-collapse-state="floating"]) { position: absolute; inset-block: var(--lr-multi-split-floating-panel-inset, 0); z-index: var(--lr-layer-content); background: var(--lr-color-surface); border-radius: var(--lr-radius); box-shadow: var(--lr-shadow-l); } :host([collapse="start"]) ::slotted([data-collapse-state="floating"]) { inset-inline-start: var(--lr-multi-split-floating-panel-inset, 0); } :host([collapse="end"]) ::slotted([data-collapse-state="floating"]) { inset-inline-end: var(--lr-multi-split-floating-panel-inset, 0); } [part="backdrop"] { position: absolute; inset: 0; z-index: var(--lr-layer-base); background: var( --lr-multi-split-overlay-color, var(--_lr-multi-split-overlay-color) ); } ::slotted([data-collapse-state="rail"]) { overflow: hidden; } `;export{styles};
1
+ import{focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; block-size: 100%; --_lr-multi-split-overlay-color: var(--lr-color-overlay); --_lr-multi-split-divider-target-size: max( var(--lr-icon-button-size), var(--lr-size-3px) ); --_lr-multi-split-divider-thickness: var(--lr-size-3px); --_lr-multi-split-divider-color: var(--lr-color-border); --_lr-multi-split-divider-hover-color: var(--lr-color-brand); --_lr-multi-split-divider-active-color: color-mix( in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } .allocation { inline-size: 100%; block-size: 100%; min-inline-size: 0; min-block-size: 0; } .allocation-reservation { max-block-size: 100%; pointer-events: none; } .allocation-reservation[hidden] { display: none; } [part="base"] { --_lr-multi-split-panel-min: 0; --_lr-multi-split-gutters: 0; display: flex; position: relative; inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; block-size: 100%; } ::slotted(*) { flex: 1 1 0; min-inline-size: var(--_lr-multi-split-panel-min, 0); max-inline-size: 100%; min-block-size: 0; max-block-size: 100%; overflow: auto; overflow-wrap: anywhere; box-sizing: border-box; } ::slotted([hidden]:not([hidden="until-found" i])) { display: none !important; } :host([orientation="vertical"]) [part="base"] { flex-direction: column; } :host([orientation="vertical"]) ::slotted(*), :host([data-effective-orientation="vertical"]) ::slotted(*) { min-inline-size: 0; min-block-size: var(--_lr-multi-split-panel-min, 0); } :host([data-effective-orientation="horizontal"]) ::slotted(*) { min-inline-size: var(--_lr-multi-split-panel-min, 0); min-block-size: 0; } [part="divider"] { position: relative; flex: 0 0 auto; inline-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); min-block-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-block-size: 100%; background: transparent; cursor: col-resize; touch-action: none; } [part="divider"]::before { content: ""; position: absolute; inset-block: 0; inset-inline: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); background: var( --lr-multi-split-divider-color, var(--_lr-multi-split-divider-color) ); pointer-events: none; transition: background-color var(--lr-transition-fast); } :host(:where([orientation="vertical"])) [part="divider"] { inline-size: 100%; min-inline-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-inline-size: 100%; min-block-size: 0; block-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); cursor: row-resize; } :host(:where([orientation="vertical"])) [part="divider"]::before { inset-block: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); inset-inline: 0; } :host([data-effective-orientation="vertical"]) [part="base"] { flex-direction: column; } :host([data-effective-orientation="horizontal"]) [part="base"] { flex-direction: row; } :host(:where([data-effective-orientation="vertical"])) [part="divider"] { inline-size: 100%; min-inline-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-inline-size: 100%; min-block-size: 0; block-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); cursor: row-resize; } :host(:where([data-effective-orientation="vertical"])) [part="divider"]::before { inset-block: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); inset-inline: 0; } :host(:where([data-effective-orientation="horizontal"])) [part="divider"] { inline-size: var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ); min-block-size: min( 100%, var( --lr-multi-split-divider-target-size, var(--_lr-multi-split-divider-target-size) ) ); max-block-size: 100%; block-size: auto; cursor: col-resize; } :host(:where([data-effective-orientation="horizontal"])) [part="divider"]::before { inset-block: 0; inset-inline: calc( ( 100% - var( --lr-multi-split-divider-thickness, var(--_lr-multi-split-divider-thickness) ) ) / 2 ); } [part="divider"]:hover::before { background: var( --lr-multi-split-divider-hover-color, var(--_lr-multi-split-divider-hover-color) ); } [part="divider"]:active::before { background: var( --lr-multi-split-divider-active-color, var(--_lr-multi-split-divider-active-color) ); } [part="divider"]:focus-visible { ${focusRing} } [part="divider"][aria-disabled="true"] { cursor: default; pointer-events: none; } :host([data-collapse-state="floating"]) [part="divider"][aria-disabled="true"] { flex: 0 0 0; min-inline-size: 0; min-block-size: 0; } :host([data-collapse-state="floating"]) [part="divider"][aria-disabled="true"]::before { content: none; } ::slotted([data-collapse-state="floating"]) { position: absolute; inset-block: var(--lr-multi-split-floating-panel-inset, 0); z-index: var(--lr-layer-content); background: var(--lr-color-surface); border-radius: var(--lr-radius); box-shadow: var(--lr-shadow-l); } :host([collapse="start"]) ::slotted([data-collapse-state="floating"]) { inset-inline-start: var(--lr-multi-split-floating-panel-inset, 0); } :host([collapse="end"]) ::slotted([data-collapse-state="floating"]) { inset-inline-end: var(--lr-multi-split-floating-panel-inset, 0); } [part="backdrop"] { position: absolute; inset: 0; z-index: var(--lr-layer-base); background: var( --lr-multi-split-overlay-color, var(--_lr-multi-split-overlay-color) ); } ::slotted([data-collapse-state="rail"]) { overflow: hidden; } `;export{styles};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{literalSetConverter}from"../../../internal/converters.js";import{resolveCssLength}from"../../../internal/css-length.js";import{setCustomState}from"../../../internal/custom-states.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{menuIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{finiteDuration,finiteRange}from"../../../internal/numbers.js";import{collectFocusableElements}from"../../../internal/overlay-stack.js";import{tag}from"../../../internal/prefix.js";import{bindNavigationMenuItem,navigationMenuItemController,releaseNavigationMenuItem}from"./navigation-menu-owner.js";import{styles}from"./navigation-menu.styles.js";import{LYRA_DEFAULT_menuLabel,LYRA_DEFAULT_navigation}from"../../../internal/default-strings/shared.generated.js";const PANEL_ANCHOR=literalSetConverter(["menu","item"],"menu"),DEFAULT_SHOW_DELAY=200,DEFAULT_HIDE_DELAY=150,DEFAULT_SKIP_DELAY=300,DEFAULT_DISTANCE=6,PANEL_KEY_ORIGIN='a[href], button, [role="link"], [role="button"]',IGNORED_CHILDREN=new Set(["template","script","style"]);function isElementNode(value){return typeof value=="object"&&value!==null&&value.nodeType===1}function isAnchorWithHref(value){return isElementNode(value)&&value.localName==="a"&&value.hasAttribute("href")}class LyraNavigationMenu extends LyraElement{constructor(){super(...arguments),this._expanded=!1,this.expansionWriteGuard=new VetoWriteGuard,this.expansionNotificationSequence=0,this.indicator=!1,this._panelAnchor="menu",this.showDelay=DEFAULT_SHOW_DELAY,this.hideDelay=DEFAULT_HIDE_DELAY,this.skipDelay=DEFAULT_SKIP_DELAY,this.distance=DEFAULT_DISTANCE,this.topLayer=!1,this.collapsedLayout=!1,this.listId=nextId("navigation-menu-list"),this.menuInternals=attachInternalsSafely(this),this.ownedRoles=new WeakSet,this.context={owner:this,layout:()=>this.layout,anchor:item=>this._panelAnchor==="item"?this.controllerFor(item)?.base()??null:this.listElement,distance:()=>finiteRange(this.distance,DEFAULT_DISTANCE,0),topLayer:()=>this.topLayer,activate:item=>this.activateItem(item),willOpen:item=>this.itemWillOpen(item),changed:(item,open,source)=>this.itemChanged(item,open,source),escape:item=>this.itemEscape(item)},this.items=[],this.lastCloseAt=Number.NEGATIVE_INFINITY,this.pressActive=!1,this.observedIndicatorTargets=new Set,this.indicatorQueued=!1,this.onSlotChange=()=>{this.updateBrowserDerivedState(()=>this.bindItems())},this.onPointerOver=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const target=event.composedPath()[0],item=this.itemContaining(target),controller=this.controllerFor(item);if(!item||!controller||!isElementNode(target))return;if(this.openItem===item){this.hideTimer?.item===item&&this.cancelHide();return}const base=controller.base();!base||!composedContains(base,target)||(controller.isTrigger()?this.hoverTrigger(item):this.hoverNonTrigger())},this.onPointerOut=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const item=this.itemContaining(event.composedPath()[0]);if(!item)return;const next=event.relatedTarget;isElementNode(next)&&composedContains(item,next)||(this.showTimer?.item===item&&this.cancelShow(),this.requestHoverClose(item))},this.onDocumentPointerDown=event=>{const open=this.openItem,controller=this.controllerFor(open);if(!open||!controller||this.layout!=="bar"||!controller.isTopmost())return;const path=event.composedPath();if(!path.includes(open)){for(const item of this.items){if(item===open)continue;const other=this.controllerFor(item),base=other?.base();if(other?.isTrigger()&&base&&path.includes(base))return}this.cancelShow(),this.cancelHide(),controller.close("user",{repairFocus:!1})}},this.onPointerDownCapture=event=>{if(event.button!==0||!event.isPrimary)return;this.clearPressTimer(),this.pressActive=!0,this.pressOpenItem=this.openItem;const doc=this.ownerDocument;this.pressDocument!==doc&&(this.stopPressListeners(),doc.addEventListener("pointerup",this.onPressEnd,!0),doc.addEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=doc)},this.onPressEnd=()=>{this.stopPressListeners(),this.clearPressTimer();const view=this.ownerDocument.defaultView;if(!view){this.clearPress();return}const id=view.setTimeout(()=>{this.pressTimer?.id===id&&(this.pressTimer=void 0,this.reevaluatePress())},0);this.pressTimer={id,view}},this.onFocusOut=event=>{const open=this.openItem;if(!open||this.layout!=="bar")return;const target=event.composedPath()[0];if(!isElementNode(target)||!composedContains(open,target))return;const next=event.relatedTarget;!isElementNode(next)||composedContains(open,next)||this.pressActive||(this.cancelShow(),this.cancelHide(),this.controllerFor(open)?.close("user",{repairFocus:!1}))},this.onClickCapture=event=>{if(event.button!==0||event.ctrlKey||event.metaKey||event.shiftKey||event.altKey)return;const path=event.composedPath();if(!this.items.some(item=>{const controller=this.controllerFor(item);if(!controller)return!1;const base=controller.base();if(controller.isLink()&&base&&path.includes(base))return!0;const panel=controller.panel();if(!panel)return!1;const panelIndex=path.indexOf(panel);return panelIndex===-1?!1:path.slice(0,panelIndex).some(isAnchorWithHref)}))return;this.cancelShow(),this.cancelHide();const listHides=this.layout==="stacked"&&this._expanded;this.closeOpenItem("user",listHides?{focusTarget:this.toggleElement}:{}),listHides&&this.setExpanded(!1,"user")},this.onKeyDown=event=>{if(event.defaultPrevented||event.isComposing||event.altKey||event.ctrlKey||event.metaKey)return;if(this.layout==="stacked"){event.key==="Escape"&&this.handleStackedEscape(event);return}const origin=event.composedPath()[0];if(!isElementNode(origin))return;const topLevel=this.items.find(item=>this.controllerFor(item)?.base()===origin);if(topLevel){this.handleBaseKey(event,topLevel);return}const panel=this.controllerFor(this.openItem)?.panel();panel&&composedContains(panel,origin)&&this.handlePanelKey(event,panel,origin)},this.requestingExpansion=!1,this.onToggleClick=()=>{this.setExpanded(!this._expanded,"user")}}static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel,navigation:LYRA_DEFAULT_navigation}}static{this.styles=[LyraElement.styles,styles]}get expanded(){return this._expanded}set expanded(next){markVetoGuardWrite(this.expansionWriteGuard),this.setExpanded(!!next,this.hasUpdated?"programmatic":null)}get panelAnchor(){return this._panelAnchor}set panelAnchor(next){const normalized=PANEL_ANCHOR.normalizeReflected(this,"panel-anchor",next);if(normalized===this._panelAnchor)return;const old=this._panelAnchor;this._panelAnchor=normalized,this.requestUpdate("panelAnchor",old)}get collapsed(){return this.collapsedLayout}get layout(){return this.collapsedLayout?"stacked":"bar"}get listElement(){return this.renderRoot?.querySelector('[part~="list"]')??null}get toggleElement(){return this.renderRoot?.querySelector('[part~="toggle"]')??null}controllerFor(item){return item?navigationMenuItemController(item):void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("pointerover",this.onPointerOver),this.addEventListener("pointerout",this.onPointerOut),this.addEventListener("pointerdown",this.onPointerDownCapture,!0),this.addEventListener("click",this.onClickCapture,!0),this.addEventListener("keydown",this.onKeyDown),this.addEventListener("focusout",this.onFocusOut),this.observeAllocation(),this.hasUpdated&&this.updateBrowserDerivedState(()=>this.bindItems())}disconnectedCallback(){this.removeEventListener("pointerover",this.onPointerOver),this.removeEventListener("pointerout",this.onPointerOut),this.removeEventListener("pointerdown",this.onPointerDownCapture,!0),this.removeEventListener("click",this.onClickCapture,!0),this.removeEventListener("keydown",this.onKeyDown),this.removeEventListener("focusout",this.onFocusOut),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.cancelAllocationFrame(),this.observedIndicatorTargets.clear(),this.stopLightDismiss(),this.cancelShow(),this.cancelHide(),this.clearPress();for(const item of this.items)this.releaseItem(item);this.items=[],super.disconnectedCallback()}close(){this.cancelShow(),this.cancelHide();const listHides=this.collapsedLayout&&this._expanded;this.closeOpenItem("programmatic",listHides?{focusTarget:this.toggleElement}:{}),this.setExpanded(!1,"programmatic")}show(){this.setExpanded(!0,"programmatic")}hide(){this.close()}firstUpdated(changed){super.firstUpdated(changed),queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>this.bindItems())})}willUpdate(changed){super.willUpdate(changed),changed.has("mobileBreakpoint")&&this.hasUpdated&&this.applyAllocation(this.measureContentInlineSize())}updated(changed){super.updated(changed);const pending=this.pendingFocus;this.pendingFocus=void 0,pending==="toggle"?this.toggleElement?.focus({preventScroll:!0}):pending==="first-base"&&this.firstNavigableBase()?.focus({preventScroll:!0});const direction=this.effectiveDirection,directionChanged=this.lastDirection!==void 0&&direction!==this.lastDirection;this.lastDirection=direction,(changed.has("distance")||changed.has("topLayer")||changed.has("panelAnchor")||directionChanged)&&this.controllerFor(this.openItem)?.reposition(),(changed.has("indicator")||changed.has("panelAnchor")||changed.has("collapsedLayout")||directionChanged)&&(this.observeIndicatorTargets(),this.queueIndicatorMeasure())}bindItems(){if(!this.isConnected)return;const slot=this.renderRoot?.querySelector('[part~="list"] > slot'),assigned=slot?slot.assignedElements():[...this.children].filter(child=>!child.hasAttribute("slot")),itemTag=tag("navigation-menu-item"),next=[];for(const child of assigned)child.localName===itemTag?next.push(child):IGNORED_CHILDREN.has(child.localName)||devWarnOnce("lr-navigation-menu:non-item-child",`<${tag("navigation-menu")}> received <${child.localName}> in its default slot, which renders inside its list without a list item role. Only <${itemTag}> children belong there; place header chrome such as a logo, search or actions outside the menu.`);const kept=new Set(next);for(const previous of this.items)kept.has(previous)||this.releaseItem(previous);for(const item of next)bindNavigationMenuItem(item,this.context),item.hasAttribute("role")||(item.setAttribute("role","listitem"),this.ownedRoles.add(item));this.items=next,this.openItem&&(!kept.has(this.openItem)||!this.controllerFor(this.openItem)?.isOpen())&&(this.openItem=void 0);for(const item of next){const controller=this.controllerFor(item);controller?.isOpen()&&(this.openItem?this.openItem!==item&&controller.close(null,{repairFocus:!1,instant:!0}):this.openItem=item)}this.openItem&&this.layout==="bar"?this.startLightDismiss():this.stopLightDismiss(),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}releaseItem(item){releaseNavigationMenuItem(item,this),this.ownedRoles.has(item)&&(item.getAttribute("role")==="listitem"&&item.removeAttribute("role"),this.ownedRoles.delete(item)),this.showTimer?.item===item&&this.cancelShow(),this.hideTimer?.item===item&&this.cancelHide(),this.openItem===item&&(this.openItem=void 0,this.stopLightDismiss())}now(){return this.ownerDocument.defaultView?.performance.now()??Date.now()}isNavigable(item){if(item.hidden||item.inert||item.closest("[inert]")!==null||item.getAttribute("aria-hidden")==="true")return!1;const base=this.controllerFor(item)?.base();return base!=null&&isComposedFocusAvailable(base)}firstNavigableBase(){const item=this.items.find(candidate=>this.isNavigable(candidate));return this.controllerFor(item)?.base()??null}itemContaining(target){if(isElementNode(target))return this.items.find(item=>composedContains(item,target))}focusWithinPanel(item){const active=deepActiveElement(this.ownerDocument);if(!active||!composedContains(item,active))return!1;const base=this.controllerFor(item)?.base();return!(base&&composedContains(base,active))}closeOpenItem(source,options={}){this.controllerFor(this.openItem)?.close(source,options)}activateItem(item){const controller=this.controllerFor(item);if(controller){if(this.cancelShow(),this.cancelHide(),controller.isTrigger()){controller.isOpen()?this.layout==="bar"&&controller.mode()==="hover"?controller.pin():controller.close("user"):controller.open("pinned","user");return}this.closeOpenItem("user"),this.layout==="stacked"&&this.setExpanded(!1,"user")}}itemWillOpen(item){this.showTimer?.item!==item&&this.cancelShow();const current=this.openItem;if(!current||current===item)return;const currentController=this.controllerFor(current);let morph;if(this.layout==="bar"&&this._panelAnchor==="menu"&&!prefersReducedMotion(this)){const panel=currentController?.panel(),from=panel&&!panel.hidden?panel.getBoundingClientRect():void 0;from&&from.width>0&&from.height>0&&(morph={from,direction:this.items.indexOf(item)>this.items.indexOf(current)?"end":"start"})}return currentController?.close("peer",{instant:!0,focusTarget:this.controllerFor(item)?.base()??null}),morph}itemChanged(item,open,source){open?(this.openItem=item,this.hideTimer?.item===item&&this.cancelHide(),this.layout==="bar"&&this.startLightDismiss()):this.openItem===item&&(this.openItem=void 0,this.layout==="bar"&&source!=="peer"&&(this.lastCloseAt=this.now()),this.hideTimer?.item===item&&this.cancelHide(),this.stopLightDismiss()),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}itemEscape(item){this.cancelShow(),this.cancelHide();const within=composedContains(item,deepActiveElement(this.ownerDocument));this.controllerFor(item)?.close("user",{repairFocus:!1,restoreFocus:within})}hoverTrigger(item){this.cancelHide();const open=this.openItem;if(open&&open!==item){if(this.focusWithinPanel(open))return;this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}if(this.showTimer?.item===item)return;const skip=finiteDuration(this.skipDelay,DEFAULT_SKIP_DELAY);if(skip>0&&this.now()-this.lastCloseAt<=skip){this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}this.scheduleShow(item)}hoverNonTrigger(){this.cancelShow();const open=this.openItem;open&&this.requestHoverClose(open)}requestHoverClose(item){this.openItem===item&&(this.controllerFor(item)?.mode()!=="hover"||this.focusWithinPanel(item)||this.scheduleHide(item))}scheduleShow(item){this.cancelShow();const delay=finiteDuration(this.showDelay,DEFAULT_SHOW_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.layout!=="bar"||!this.items.includes(item))return;const open=this.openItem;open&&open!==item&&this.focusWithinPanel(open)||this.controllerFor(item)?.open("hover","user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.showTimer?.id===id&&(this.showTimer=void 0,commit())},delay);this.showTimer={item,id,view}}scheduleHide(item){this.cancelHide();const delay=finiteDuration(this.hideDelay,DEFAULT_HIDE_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.openItem!==item)return;const controller=this.controllerFor(item);controller?.mode()!=="hover"||this.focusWithinPanel(item)||controller.close("user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.hideTimer?.id===id&&(this.hideTimer=void 0,commit())},delay);this.hideTimer={item,id,view}}cancelShow(){const timer=this.showTimer;this.showTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}cancelHide(){const timer=this.hideTimer;this.hideTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}startLightDismiss(){const doc=this.ownerDocument;!this.isConnected||this.lightDismissDocument===doc||(this.stopLightDismiss(),doc.addEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=doc)}stopLightDismiss(){this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=void 0}reevaluatePress(){const pressed=this.pressOpenItem;if(this.pressActive=!1,this.pressOpenItem=void 0,!pressed||pressed!==this.openItem||this.layout!=="bar")return;const controller=this.controllerFor(pressed);if(!controller?.isOpen())return;const doc=this.ownerDocument,active=deepActiveElement(doc);!active||active===doc.body||active===doc.documentElement||composedContains(pressed,active)||controller.close("user",{repairFocus:!1})}stopPressListeners(){this.pressDocument?.removeEventListener("pointerup",this.onPressEnd,!0),this.pressDocument?.removeEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=void 0}clearPressTimer(){const timer=this.pressTimer;this.pressTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}clearPress(){this.stopPressListeners(),this.clearPressTimer(),this.pressActive=!1,this.pressOpenItem=void 0}handleBaseKey(event,item){const rtl=this.effectiveDirection==="rtl";switch(event.key){case"ArrowRight":case"ArrowLeft":{event.preventDefault();const forward=event.key==="ArrowRight"!==rtl;this.focusSibling(item,forward?1:-1);return}case"Home":case"End":{event.preventDefault();const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),target=event.key==="Home"?navigable[0]:navigable.at(-1);this.controllerFor(target)?.base()?.focus();return}case"ArrowDown":{const controller=this.controllerFor(item);if(!controller?.isTrigger()||!controller.isOpen())return;event.preventDefault(),this.enterPanel(controller);return}}}focusSibling(item,step){const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),index=navigable.indexOf(item);index!==-1&&this.controllerFor(navigable[index+step])?.base()?.focus()}async enterPanel(controller){if(await controller.placementReady(),!controller.isOpen())return;const panel=controller.panel();panel&&collectFocusableElements(panel)[0]?.focus()}handlePanelKey(event,panel,origin){if(!["ArrowDown","ArrowUp","Home","End"].includes(event.key)||!origin.matches(PANEL_KEY_ORIGIN))return;event.preventDefault();const focusable=collectFocusableElements(panel),index=focusable.findIndex(candidate=>candidate===origin);let target;event.key==="Home"?target=focusable[0]:event.key==="End"?target=focusable.at(-1):event.key==="ArrowDown"?target=focusable[index+1]:index>0&&(target=focusable[index-1]),target?.focus()}handleStackedEscape(event){const open=this.openItem,active=deepActiveElement(this.ownerDocument);if(open&&active&&composedContains(open,active)){event.preventDefault();const controller=this.controllerFor(open),base=controller?.base();controller?.close("user"),base?.focus();return}this._expanded&&(event.preventDefault(),this.setExpanded(!1,"user"),this.toggleElement?.focus())}setExpanded(next,source){if(next===this._expanded)return;if(source==="user"){if(this.requestingExpansion)return;const previous=this._expanded;this.requestingExpansion=!0;try{let accepted=!1;if(requestThenCommit({requestDetail:{expanded:next,source},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.expansionWriteGuard,commit:()=>{accepted=this._expanded===previous}}),!accepted)return}finally{this.requestingExpansion=!1}}if(!next&&this.collapsedLayout){const list=this.listElement,active=deepActiveElement(this.ownerDocument);list&&active&&composedContains(list,active)&&this.toggleElement?.focus({preventScroll:!0}),this.closeOpenItem(source,{repairFocus:!1})}const old=this._expanded;this._expanded=next;const notificationSequence=++this.expansionNotificationSequence;this.requestUpdate("expanded",old),source!==null&&this.updateComplete.then(()=>{!this.isConnected||this._expanded!==next||this.expansionNotificationSequence!==notificationSequence||this.emit("lr-toggle",{expanded:next,source})})}observeAllocation(){const ResizeObserverConstructor=this.ownerDocument.defaultView?.ResizeObserver;ResizeObserverConstructor&&(this.resizeObserver??=new ResizeObserverConstructor(entries=>this.onResize(entries)),this.resizeObserver.observe(this),this.observedIndicatorTargets.clear(),this.observeIndicatorTargets())}onResize(entries){for(const entry of entries)entry.target===this&&(this.lastInlineSize=entry.contentBoxSize?.[0]?.inlineSize??entry.contentRect.width,this.scheduleAllocation());this.queueIndicatorMeasure()}scheduleAllocation(){if(this.allocationFrame)return;const view=this.ownerDocument.defaultView;if(!view){this.applyAllocation(this.lastInlineSize);return}const id=view.requestAnimationFrame(()=>{this.allocationFrame?.id===id&&(this.allocationFrame=void 0,this.isConnected&&this.applyAllocation(this.lastInlineSize))});this.allocationFrame={id,view}}cancelAllocationFrame(){const frame=this.allocationFrame;this.allocationFrame=void 0,frame&&frame.view.cancelAnimationFrame(frame.id)}measureContentInlineSize(){const view=this.ownerDocument.defaultView;if(!view||!this.isConnected)return this.lastInlineSize;const style=view.getComputedStyle(this),edges=["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"];let width=this.getBoundingClientRect().width;for(const edge of edges)width-=Number.parseFloat(style[edge])||0;return Math.max(0,width)}applyAllocation(width){if(width===void 0||!Number.isFinite(width))return;const breakpoint=resolveCssLength(this.mobileBreakpoint,{host:this}),next=breakpoint!==void 0&&Number.isFinite(breakpoint)&&width<=breakpoint;this.updateBrowserDerivedState(()=>this.setCollapsed(next))}setCollapsed(next){if(next===this.collapsedLayout)return;this.cancelShow(),this.cancelHide();const active=deepActiveElement(this.ownerDocument),open=this.openItem;if(next){const list=this.listElement,listHides=!this._expanded,focusInList=!!(active&&list&&composedContains(list,active));this.controllerFor(open)?.close("programmatic",{instant:!0,repairFocus:!listHides}),listHides&&focusInList&&(this.pendingFocus="toggle"),this.stopLightDismiss()}else{const toggle=this.toggleElement,onToggle=!!(active&&toggle&&composedContains(toggle,active));this.controllerFor(open)?.close("programmatic",{instant:!0}),onToggle&&(this.pendingFocus="first-base")}this.collapsedLayout=next,setCustomState(this.menuInternals,"collapsed",next);for(const item of this.items)item.requestUpdate?.();!next&&this._expanded&&this.setExpanded(!1,"programmatic")}observeIndicatorTargets(){const observer=this.resizeObserver;if(!observer)return;const wanted=new Set;if(this.indicator){const list=this.listElement;list&&wanted.add(list);for(const item of this.items)wanted.add(item)}for(const target of this.observedIndicatorTargets)wanted.has(target)||observer.unobserve(target);for(const target of wanted)this.observedIndicatorTargets.has(target)||observer.observe(target);this.observedIndicatorTargets=wanted}queueIndicatorMeasure(){this.indicatorQueued||!this.indicator||(this.indicatorQueued=!0,queueMicrotask(()=>{const open=this.openItem;Promise.all([this.updateComplete,open?.updateComplete]).then(()=>{this.indicatorQueued=!1,this.measureIndicator()})}))}measureIndicator(){if(!this.indicator||this.collapsedLayout||!this.isConnected)return;const nav=this.renderRoot.querySelector('[part~="base"]'),base=this.controllerFor(this.openItem)?.base(),previous=this.indicatorBox;if(!nav||!base){previous?.visible&&(this.indicatorBox={...previous,visible:!1});return}const navRect=nav.getBoundingClientRect(),trigger=base.getBoundingClientRect(),list=this.listElement,rtl=this.effectiveDirection==="rtl",bottom=this._panelAnchor==="menu"&&list?list.getBoundingClientRect().bottom:trigger.bottom,next={start:rtl?navRect.right-trigger.right:trigger.left-navRect.left,size:trigger.width,top:bottom-navRect.top,visible:!0};previous&&previous.visible===next.visible&&Math.abs(previous.start-next.start)<.5&&Math.abs(previous.size-next.size)<.5&&Math.abs(previous.top-next.top)<.5||(this.indicatorBox=next)}render(){const label=hostAriaLabel(this)??this.label??this.localize("navigation"),collapsed=this.collapsedLayout,box=this.indicatorBox;return html`<nav part="base" aria-label=${label}>
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{literalSetConverter}from"../../../internal/converters.js";import{resolveCssLength}from"../../../internal/css-length.js";import{setCustomState}from"../../../internal/custom-states.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{menuIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{finiteDuration,finiteRange}from"../../../internal/numbers.js";import{collectFocusableElements}from"../../../internal/overlay-stack.js";import{tag}from"../../../internal/prefix.js";import{bindNavigationMenuItem,navigationMenuItemController,releaseNavigationMenuItem}from"./navigation-menu-owner.js";import{styles}from"./navigation-menu.styles.js";import{LYRA_DEFAULT_menuLabel,LYRA_DEFAULT_navigation}from"../../../internal/default-strings/shared.generated.js";const PANEL_ANCHOR=literalSetConverter(["menu","item"],"menu"),DEFAULT_SHOW_DELAY=200,DEFAULT_HIDE_DELAY=150,DEFAULT_SKIP_DELAY=300,DEFAULT_DISTANCE=6,PANEL_KEY_ORIGIN='a[href], button, [role="link"], [role="button"]',IGNORED_CHILDREN=new Set(["template","script","style"]);function isElementNode(value){return typeof value=="object"&&value!==null&&value.nodeType===1}function isAnchorWithHref(value){return isElementNode(value)&&value.localName==="a"&&value.hasAttribute("href")}class LyraNavigationMenu extends LyraElement{constructor(){super(...arguments),this._expanded=!1,this.expansionWriteGuard=new VetoWriteGuard,this.expansionNotificationSequence=0,this.indicator=!1,this._panelAnchor="menu",this.showDelay=DEFAULT_SHOW_DELAY,this.hideDelay=DEFAULT_HIDE_DELAY,this.skipDelay=DEFAULT_SKIP_DELAY,this.distance=DEFAULT_DISTANCE,this.topLayer=!1,this.collapsedLayout=!1,this.listId=nextId("navigation-menu-list"),this.menuInternals=attachInternalsSafely(this),this.ownedRoles=new WeakSet,this.context={owner:this,layout:()=>this.layout,anchor:item=>this._panelAnchor==="item"?this.controllerFor(item)?.base()??null:this.listElement,distance:()=>finiteRange(this.distance,DEFAULT_DISTANCE,0),topLayer:()=>this.topLayer,activate:item=>this.activateItem(item),willOpen:item=>this.itemWillOpen(item),changed:(item,open,source)=>this.itemChanged(item,open,source),escape:item=>this.itemEscape(item)},this.items=[],this.lastCloseAt=Number.NEGATIVE_INFINITY,this.pressActive=!1,this.observedIndicatorTargets=new Set,this.indicatorQueued=!1,this.onSlotChange=()=>{this.updateBrowserDerivedState(()=>this.bindItems())},this.onPointerOver=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const target=event.composedPath()[0],item=this.itemContaining(target),controller=this.controllerFor(item);if(!item||!controller||!isElementNode(target))return;if(this.openItem===item){this.hideTimer?.item===item&&this.cancelHide();return}const base=controller.base();!base||!composedContains(base,target)||(controller.isTrigger()?this.hoverTrigger(item):this.hoverNonTrigger())},this.onPointerOut=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const item=this.itemContaining(event.composedPath()[0]);if(!item)return;const next=event.relatedTarget;isElementNode(next)&&composedContains(item,next)||(this.showTimer?.item===item&&this.cancelShow(),this.requestHoverClose(item))},this.onDocumentPointerDown=event=>{const open=this.openItem,controller=this.controllerFor(open);if(!open||!controller||this.layout!=="bar"||!controller.isTopmost())return;const path=event.composedPath();if(!path.includes(open)){for(const item of this.items){if(item===open)continue;const other=this.controllerFor(item),base=other?.base();if(other?.isTrigger()&&base&&path.includes(base))return}this.cancelShow(),this.cancelHide(),controller.close("user",{repairFocus:!1})}},this.onPointerDownCapture=event=>{if(event.button!==0||!event.isPrimary)return;this.clearPressTimer(),this.pressActive=!0,this.pressOpenItem=this.openItem;const doc=this.ownerDocument;this.pressDocument!==doc&&(this.stopPressListeners(),doc.addEventListener("pointerup",this.onPressEnd,!0),doc.addEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=doc)},this.onPressEnd=()=>{this.stopPressListeners(),this.clearPressTimer();const view=this.ownerDocument.defaultView;if(!view){this.clearPress();return}const id=view.setTimeout(()=>{this.pressTimer?.id===id&&(this.pressTimer=void 0,this.reevaluatePress())},0);this.pressTimer={id,view}},this.onFocusOut=event=>{const open=this.openItem;if(!open||this.layout!=="bar")return;const target=event.composedPath()[0];if(!isElementNode(target)||!composedContains(open,target))return;const next=event.relatedTarget;!isElementNode(next)||composedContains(open,next)||this.pressActive||(this.cancelShow(),this.cancelHide(),this.controllerFor(open)?.close("user",{repairFocus:!1}))},this.onClickCapture=event=>{if(event.button!==0||event.ctrlKey||event.metaKey||event.shiftKey||event.altKey)return;const path=event.composedPath();if(!this.items.some(item=>{const controller=this.controllerFor(item);if(!controller)return!1;const base=controller.base();if(controller.isLink()&&base&&path.includes(base))return!0;const panel=controller.panel();if(!panel)return!1;const panelIndex=path.indexOf(panel);return panelIndex===-1?!1:path.slice(0,panelIndex).some(isAnchorWithHref)}))return;this.cancelShow(),this.cancelHide();const listHides=this.layout==="stacked"&&this._expanded;this.closeOpenItem("user",listHides?{focusTarget:this.toggleElement}:{}),listHides&&this.setExpanded(!1,"user")},this.onKeyDown=event=>{if(event.defaultPrevented||event.isComposing||event.altKey||event.ctrlKey||event.metaKey)return;if(this.layout==="stacked"){event.key==="Escape"&&this.handleStackedEscape(event);return}const origin=event.composedPath()[0];if(!isElementNode(origin))return;const topLevel=this.items.find(item=>this.controllerFor(item)?.base()===origin);if(topLevel){this.handleBaseKey(event,topLevel);return}const panel=this.controllerFor(this.openItem)?.panel();panel&&composedContains(panel,origin)&&this.handlePanelKey(event,panel,origin)},this.requestingExpansion=!1,this.onToggleClick=()=>{this.setExpanded(!this._expanded,"user")}}static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel,navigation:LYRA_DEFAULT_navigation}}static{this.styles=[LyraElement.styles,styles]}get expanded(){return this._expanded}set expanded(next){markVetoGuardWrite(this.expansionWriteGuard),this.setExpanded(!!next,this.hasUpdated?"programmatic":null)}get panelAnchor(){return this._panelAnchor}set panelAnchor(next){const normalized=PANEL_ANCHOR.normalizeReflected(this,"panel-anchor",next);if(normalized===this._panelAnchor)return;const old=this._panelAnchor;this._panelAnchor=normalized,this.requestUpdate("panelAnchor",old)}get collapsed(){return this.collapsedLayout}get layout(){return this.collapsedLayout?"stacked":"bar"}get listElement(){return this.renderRoot?.querySelector('[part~="list"]')??null}get toggleElement(){return this.renderRoot?.querySelector('[part~="toggle"]')??null}controllerFor(item){return item?navigationMenuItemController(item):void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("pointerover",this.onPointerOver),this.addEventListener("pointerout",this.onPointerOut),this.addEventListener("pointerdown",this.onPointerDownCapture,!0),this.addEventListener("click",this.onClickCapture,!0),this.addEventListener("keydown",this.onKeyDown),this.addEventListener("focusout",this.onFocusOut),this.observeAllocation(),this.hasUpdated&&this.updateBrowserDerivedState(()=>this.bindItems())}disconnectedCallback(){this.removeEventListener("pointerover",this.onPointerOver),this.removeEventListener("pointerout",this.onPointerOut),this.removeEventListener("pointerdown",this.onPointerDownCapture,!0),this.removeEventListener("click",this.onClickCapture,!0),this.removeEventListener("keydown",this.onKeyDown),this.removeEventListener("focusout",this.onFocusOut),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.cancelAllocationFrame(),this.observedIndicatorTargets.clear(),this.stopLightDismiss(),this.cancelShow(),this.cancelHide(),this.clearPress();for(const item of this.items)this.releaseItem(item);this.items=[],super.disconnectedCallback()}close(){this.cancelShow(),this.cancelHide();const listHides=this.collapsedLayout&&this._expanded;this.closeOpenItem("programmatic",listHides?{focusTarget:this.toggleElement}:{}),this.setExpanded(!1,"programmatic")}show(){this.setExpanded(!0,"programmatic")}hide(){this.close()}firstUpdated(changed){super.firstUpdated(changed),queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>this.bindItems())})}willUpdate(changed){super.willUpdate(changed),changed.has("mobileBreakpoint")&&this.hasUpdated&&this.applyAllocation(this.measureContentInlineSize())}updated(changed){super.updated(changed);const pending=this.pendingFocus;this.pendingFocus=void 0,pending==="toggle"?this.toggleElement?.focus({preventScroll:!0}):pending==="first-base"&&this.firstNavigableBase()?.focus({preventScroll:!0});const direction=this.effectiveDirection,directionChanged=this.lastDirection!==void 0&&direction!==this.lastDirection;this.lastDirection=direction,(changed.has("distance")||changed.has("topLayer")||changed.has("panelAnchor")||directionChanged)&&this.controllerFor(this.openItem)?.reposition(),(changed.has("indicator")||changed.has("panelAnchor")||changed.has("collapsedLayout")||directionChanged)&&(this.observeIndicatorTargets(),this.queueIndicatorMeasure())}bindItems(){if(!this.isConnected)return;const slot=this.renderRoot?.querySelector('[part~="list"] > slot'),assigned=slot?slot.assignedElements():[...this.children].filter(child=>!child.hasAttribute("slot")),itemTag=tag("navigation-menu-item"),next=[];for(const child of assigned)child.localName===itemTag?next.push(child):IGNORED_CHILDREN.has(child.localName)||devWarnOnce("lr-navigation-menu:non-item-child",`<${tag("navigation-menu")}> received <${child.localName}> in its default slot, which renders inside its list without a list item role. Only <${itemTag}> children belong there; place header chrome such as a logo, search or actions outside the menu.`);const kept=new Set(next);for(const previous of this.items)kept.has(previous)||this.releaseItem(previous);for(const item of next)bindNavigationMenuItem(item,this.context),item.hasAttribute("role")||(item.setAttribute("role","listitem"),this.ownedRoles.add(item));this.items=next,this.openItem&&(!kept.has(this.openItem)||!this.controllerFor(this.openItem)?.isOpen())&&(this.openItem=void 0);for(const item of next){const controller=this.controllerFor(item);controller?.isOpen()&&(this.openItem?this.openItem!==item&&controller.close(null,{repairFocus:!1,instant:!0}):this.openItem=item)}this.openItem&&this.layout==="bar"?this.startLightDismiss():this.stopLightDismiss(),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}releaseItem(item){releaseNavigationMenuItem(item,this),this.ownedRoles.has(item)&&(item.getAttribute("role")==="listitem"&&item.removeAttribute("role"),this.ownedRoles.delete(item)),this.showTimer?.item===item&&this.cancelShow(),this.hideTimer?.item===item&&this.cancelHide(),this.openItem===item&&(this.openItem=void 0,this.stopLightDismiss())}now(){return this.ownerDocument.defaultView?.performance.now()??Date.now()}isNavigable(item){if(item.hidden||item.inert||item.closest("[inert]")!==null||item.getAttribute("aria-hidden")==="true")return!1;const base=this.controllerFor(item)?.base();return base!=null&&isComposedFocusAvailable(base)}firstNavigableBase(){const item=this.items.find(candidate=>this.isNavigable(candidate));return this.controllerFor(item)?.base()??null}itemContaining(target){if(isElementNode(target))return this.items.find(item=>composedContains(item,target))}focusWithinPanel(item){const active=deepActiveElement(this.ownerDocument);if(!active||!composedContains(item,active))return!1;const base=this.controllerFor(item)?.base();return!(base&&composedContains(base,active))}closeOpenItem(source,options={}){this.controllerFor(this.openItem)?.close(source,options)}activateItem(item){const controller=this.controllerFor(item);if(controller){if(this.cancelShow(),this.cancelHide(),controller.isTrigger()){controller.isOpen()?this.layout==="bar"&&controller.mode()==="hover"?controller.pin():controller.close("user"):controller.open("pinned","user");return}this.closeOpenItem("user"),this.layout==="stacked"&&this.setExpanded(!1,"user")}}itemWillOpen(item){this.showTimer?.item!==item&&this.cancelShow();const current=this.openItem;if(!current||current===item)return;const currentController=this.controllerFor(current);let morph;if(this.layout==="bar"&&this._panelAnchor==="menu"&&!prefersReducedMotion(this)){const panel=currentController?.panel(),from=panel&&!panel.hidden?panel.getBoundingClientRect():void 0;from&&from.width>0&&from.height>0&&(morph={from,direction:this.items.indexOf(item)>this.items.indexOf(current)?"end":"start"})}return currentController?.close("peer",{instant:!0,focusTarget:this.controllerFor(item)?.base()??null}),morph}itemChanged(item,open,source){open?(this.openItem=item,this.hideTimer?.item===item&&this.cancelHide(),this.layout==="bar"&&this.startLightDismiss()):this.openItem===item&&(this.openItem=void 0,this.layout==="bar"&&source!=="peer"&&(this.lastCloseAt=this.now()),this.hideTimer?.item===item&&this.cancelHide(),this.stopLightDismiss()),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}itemEscape(item){this.cancelShow(),this.cancelHide();const within=composedContains(item,deepActiveElement(this.ownerDocument));this.controllerFor(item)?.close("user",{repairFocus:!1,restoreFocus:within})}hoverTrigger(item){this.cancelHide();const open=this.openItem;if(open&&open!==item){if(this.focusWithinPanel(open))return;this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}if(this.showTimer?.item===item)return;const skip=finiteDuration(this.skipDelay,DEFAULT_SKIP_DELAY);if(skip>0&&this.now()-this.lastCloseAt<=skip){this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}this.scheduleShow(item)}hoverNonTrigger(){this.cancelShow();const open=this.openItem;open&&this.requestHoverClose(open)}requestHoverClose(item){this.openItem===item&&(this.controllerFor(item)?.mode()!=="hover"||this.focusWithinPanel(item)||this.scheduleHide(item))}scheduleShow(item){this.cancelShow();const delay=finiteDuration(this.showDelay,DEFAULT_SHOW_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.layout!=="bar"||!this.items.includes(item))return;const open=this.openItem;open&&open!==item&&this.focusWithinPanel(open)||this.controllerFor(item)?.open("hover","user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.showTimer?.id===id&&(this.showTimer=void 0,commit())},delay);this.showTimer={item,id,view}}scheduleHide(item){this.cancelHide();const delay=finiteDuration(this.hideDelay,DEFAULT_HIDE_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.openItem!==item)return;const controller=this.controllerFor(item);controller?.mode()!=="hover"||this.focusWithinPanel(item)||controller.close("user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.hideTimer?.id===id&&(this.hideTimer=void 0,commit())},delay);this.hideTimer={item,id,view}}cancelShow(){const timer=this.showTimer;this.showTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}cancelHide(){const timer=this.hideTimer;this.hideTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}startLightDismiss(){const doc=this.ownerDocument;!this.isConnected||this.lightDismissDocument===doc||(this.stopLightDismiss(),doc.addEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=doc)}stopLightDismiss(){this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=void 0}reevaluatePress(){const pressed=this.pressOpenItem;if(this.pressActive=!1,this.pressOpenItem=void 0,!pressed||pressed!==this.openItem||this.layout!=="bar")return;const controller=this.controllerFor(pressed);if(!controller?.isOpen())return;const doc=this.ownerDocument,active=deepActiveElement(doc);!active||active===doc.body||active===doc.documentElement||composedContains(pressed,active)||controller.close("user",{repairFocus:!1})}stopPressListeners(){this.pressDocument?.removeEventListener("pointerup",this.onPressEnd,!0),this.pressDocument?.removeEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=void 0}clearPressTimer(){const timer=this.pressTimer;this.pressTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}clearPress(){this.stopPressListeners(),this.clearPressTimer(),this.pressActive=!1,this.pressOpenItem=void 0}handleBaseKey(event,item){const rtl=this.effectiveDirection==="rtl";switch(event.key){case"ArrowRight":case"ArrowLeft":{event.preventDefault();const forward=event.key==="ArrowRight"!==rtl;this.focusSibling(item,forward?1:-1);return}case"Home":case"End":{event.preventDefault();const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),target=event.key==="Home"?navigable[0]:navigable.at(-1);this.controllerFor(target)?.base()?.focus();return}case"ArrowDown":{const controller=this.controllerFor(item);if(!controller?.isTrigger()||!controller.isOpen())return;event.preventDefault(),this.enterPanel(controller);return}}}focusSibling(item,step){const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),index=navigable.indexOf(item);index!==-1&&this.controllerFor(navigable[index+step])?.base()?.focus()}async enterPanel(controller){if(await controller.placementReady(),!controller.isOpen())return;const panel=controller.panel();panel&&collectFocusableElements(panel)[0]?.focus()}handlePanelKey(event,panel,origin){if(!["ArrowDown","ArrowUp","Home","End"].includes(event.key)||!origin.matches(PANEL_KEY_ORIGIN))return;event.preventDefault();const focusable=collectFocusableElements(panel),index=focusable.findIndex(candidate=>candidate===origin);let target;event.key==="Home"?target=focusable[0]:event.key==="End"?target=focusable.at(-1):event.key==="ArrowDown"?target=focusable[index+1]:index>0&&(target=focusable[index-1]),target?.focus()}handleStackedEscape(event){const open=this.openItem,active=deepActiveElement(this.ownerDocument);if(open&&active&&composedContains(open,active)){event.preventDefault();const controller=this.controllerFor(open),base=controller?.base();controller?.close("user"),base?.focus();return}this._expanded&&(event.preventDefault(),this.setExpanded(!1,"user"),this.toggleElement?.focus())}setExpanded(next,source){if(next===this._expanded)return;if(source==="user"){if(this.requestingExpansion)return;const previous=this._expanded;this.requestingExpansion=!0;try{let accepted=!1;if(requestThenCommit({requestDetail:{expanded:next,source},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.expansionWriteGuard,commit:()=>{accepted=this._expanded===previous}}),!accepted)return}finally{this.requestingExpansion=!1}}if(!next&&this.collapsedLayout){const list=this.listElement,active=deepActiveElement(this.ownerDocument);list&&active&&composedContains(list,active)&&this.toggleElement?.focus({preventScroll:!0}),this.closeOpenItem(source,{repairFocus:!1})}const old=this._expanded;this._expanded=next;const notificationSequence=++this.expansionNotificationSequence;this.requestUpdate("expanded",old),source!==null&&this.updateComplete.then(()=>{!this.isConnected||this._expanded!==next||this.expansionNotificationSequence!==notificationSequence||this.emit("lr-toggle",{expanded:next,source})})}observeAllocation(){const ownerDocument=this.ownerDocument,ResizeObserverConstructor=ownerDocument.defaultView?.ResizeObserver;if(ResizeObserverConstructor){if(!this.resizeObserver){const observer=new ResizeObserverConstructor(entries=>{this.resizeObserver!==observer||!this.isConnected||this.ownerDocument!==ownerDocument||this.onResize(entries)});this.resizeObserver=observer}this.resizeObserver.observe(this),this.observedIndicatorTargets.clear(),this.observeIndicatorTargets()}}onResize(entries){for(const entry of entries)entry.target===this&&(this.lastInlineSize=entry.contentBoxSize?.[0]?.inlineSize??entry.contentRect.width,this.scheduleAllocation());this.queueIndicatorMeasure()}scheduleAllocation(){if(this.allocationFrame)return;const view=this.ownerDocument.defaultView;if(!view){this.applyAllocation(this.lastInlineSize);return}const id=view.requestAnimationFrame(()=>{this.allocationFrame?.id===id&&(this.allocationFrame=void 0,this.isConnected&&this.applyAllocation(this.lastInlineSize))});this.allocationFrame={id,view}}cancelAllocationFrame(){const frame=this.allocationFrame;this.allocationFrame=void 0,frame&&frame.view.cancelAnimationFrame(frame.id)}measureContentInlineSize(){const view=this.ownerDocument.defaultView;if(!view||!this.isConnected)return this.lastInlineSize;const style=view.getComputedStyle(this),edges=["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"];let width=this.getBoundingClientRect().width;for(const edge of edges)width-=Number.parseFloat(style[edge])||0;return Math.max(0,width)}applyAllocation(width){if(width===void 0||!Number.isFinite(width))return;const breakpoint=resolveCssLength(this.mobileBreakpoint,{host:this}),next=breakpoint!==void 0&&Number.isFinite(breakpoint)&&width<=breakpoint;this.updateBrowserDerivedState(()=>this.setCollapsed(next))}setCollapsed(next){if(next===this.collapsedLayout)return;this.cancelShow(),this.cancelHide();const active=deepActiveElement(this.ownerDocument),open=this.openItem;if(next){const list=this.listElement,listHides=!this._expanded,focusInList=!!(active&&list&&composedContains(list,active));this.controllerFor(open)?.close("programmatic",{instant:!0,repairFocus:!listHides}),listHides&&focusInList&&(this.pendingFocus="toggle"),this.stopLightDismiss()}else{const toggle=this.toggleElement,onToggle=!!(active&&toggle&&composedContains(toggle,active));this.controllerFor(open)?.close("programmatic",{instant:!0}),onToggle&&(this.pendingFocus="first-base")}this.collapsedLayout=next,setCustomState(this.menuInternals,"collapsed",next);for(const item of this.items)item.requestUpdate?.();!next&&this._expanded&&this.setExpanded(!1,"programmatic")}observeIndicatorTargets(){const observer=this.resizeObserver;if(!observer)return;const wanted=new Set;if(this.indicator){const list=this.listElement;list&&wanted.add(list);for(const item of this.items)wanted.add(item)}for(const target of this.observedIndicatorTargets)wanted.has(target)||observer.unobserve(target);for(const target of wanted)this.observedIndicatorTargets.has(target)||observer.observe(target);this.observedIndicatorTargets=wanted}queueIndicatorMeasure(){this.indicatorQueued||!this.indicator||(this.indicatorQueued=!0,queueMicrotask(()=>{const open=this.openItem;Promise.all([this.updateComplete,open?.updateComplete]).then(()=>{this.indicatorQueued=!1,this.measureIndicator()})}))}measureIndicator(){if(!this.indicator||this.collapsedLayout||!this.isConnected)return;const nav=this.renderRoot.querySelector('[part~="base"]'),base=this.controllerFor(this.openItem)?.base(),previous=this.indicatorBox;if(!nav||!base){previous?.visible&&(this.indicatorBox={...previous,visible:!1});return}const navRect=nav.getBoundingClientRect(),trigger=base.getBoundingClientRect(),list=this.listElement,rtl=this.effectiveDirection==="rtl",bottom=this._panelAnchor==="menu"&&list?list.getBoundingClientRect().bottom:trigger.bottom,next={start:rtl?navRect.right-trigger.right:trigger.left-navRect.left,size:trigger.width,top:bottom-navRect.top,visible:!0};previous&&previous.visible===next.visible&&Math.abs(previous.start-next.start)<.5&&Math.abs(previous.size-next.size)<.5&&Math.abs(previous.top-next.top)<.5||(this.indicatorBox=next)}render(){const label=hostAriaLabel(this)??this.label??this.localize("navigation"),collapsed=this.collapsedLayout,box=this.indicatorBox;return html`<nav part="base" aria-label=${label}>
2
2
  ${collapsed?html`<button
3
3
  type="button"
4
4
  part="toggle"
@@ -12,6 +12,8 @@ export type PageNavigationPlacement='start'|'end';export interface LyraPageEvent
12
12
  * from its own allocated inline size. A single static navigation subtree participates in the
13
13
  * desktop grid and is promoted in place to a modal mobile drawer, so assigned nodes, component
14
14
  * instances, focus, form state, and scroll state are never cloned or replaced at a breakpoint.
15
+ * The mobile drawer enters the browser top layer, remaining above fixed headers and outside
16
+ * ancestor clipping or transformed containing blocks while the Page host stays in place.
15
17
  *
16
18
  * Each instance owns unique main/drawer/navigation IDs. Its skip link therefore targets its own
17
19
  * main landmark even when several Pages coexist. The default skip and navigation controls are
@@ -145,7 +147,7 @@ mobileBreakpoint:string;
145
147
  /** Logical edge occupied by desktop navigation and the mobile drawer.*/
146
148
  navigationPlacement:PageNavigationPlacement;
147
149
  /** Hides the default mobile toggle. Slotted `data-toggle-nav` controls remain available.*/
148
- disableNavigationToggle:boolean;private accessibleLabel;private readonly mainId;private readonly navigationId;private readonly drawerId;private readonly skipTargetId;private readonly skipLabelId;private fragmentTargetId;private fragmentTabIndex;private resizeObserver?;private readonly allocationFrame;private resizeView?;private overlayHandle?;private readonly nativeModal;private navigationTriggerOwner?;private navigationOpener;private customToggle?;private customToggles;private readonly customToggleOwnership;private mainElement?;private drawerElement?;connectedCallback():void;disconnectedCallback():void;protected firstUpdated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues<this>):void;private observeAllocation;private readonly onWindowResize;private measureAllocation;private applyMeasuredInlineSize;private syncOverlay;private readonly navigationDeferredReturn;private readonly resolveNavigationRestoreTarget;private syncCustomToggle;private releaseCustomToggleA11y;private isUnavailableCustomToggle;private rememberTriggerAndToggle;private readonly onDefaultToggleClick;private readonly onToggleSlotClick;private readonly onPageClick;private readonly onBackdropClick;private readonly onSkipClick;private requestNavOpen;
150
+ disableNavigationToggle:boolean;private accessibleLabel;private readonly mainId;private readonly navigationId;private readonly drawerId;private readonly skipTargetId;private readonly skipLabelId;private fragmentTargetId;private fragmentTabIndex;private resizeObserver?;private allocationMeasured;private readonly allocationFrame;private resizeView?;private overlayHandle?;private readonly nativeModal;private readonly modalSurface;private navigationTriggerOwner?;private navigationOpener;private customToggle?;private customToggles;private readonly customToggleOwnership;private mainElement?;private drawerElement?;connectedCallback():void;disconnectedCallback():void;protected firstUpdated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues<this>):void;private observeAllocation;private readonly onWindowResize;private measureAllocation;private applyMeasuredInlineSize;private syncOverlay;private readonly navigationDeferredReturn;private readonly resolveNavigationRestoreTarget;private syncCustomToggle;private releaseCustomToggleA11y;private isUnavailableCustomToggle;private rememberTriggerAndToggle;private readonly onDefaultToggleClick;private readonly onToggleSlotClick;private readonly onPageClick;private readonly onBackdropClick;private readonly onSkipClick;private requestNavOpen;
149
151
  /** Open mobile navigation. Desktop navigation is already visible, but the state is retained so
150
152
  * an open drawer can move through desktop and back without replacing its content. */
151
153
  showNavigation():void;
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{nextId,resolveAccessibleTrigger}from"../../../internal/a11y.js";import{isAriaTrue}from"../../../internal/accessibility-visibility.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{syncAriaDescribedByElements}from"../../../internal/aria-reflection.js";import{resolveCssLength}from"../../../internal/css-length.js";import{cancelDeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{menuIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{OwnedFrame}from"../../../internal/owned-timer.js";import{finiteRange}from"../../../internal/numbers.js";import{activateOverlay,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{styles}from"./page.styles.js";import{LYRA_DEFAULT_closeNavigation,LYRA_DEFAULT_openNavigation,LYRA_DEFAULT_skipToContent}from"../../../internal/default-strings/layout.generated.js";import{LYRA_DEFAULT_navigation}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_MOBILE_BREAKPOINT="768px";class LyraPage extends LyraElement{constructor(){super(...arguments),this.view="desktop",this.navOpen=!1,this.mobileBreakpoint="768px",this.navigationPlacement="start",this.disableNavigationToggle=!1,this.accessibleLabel=null,this.mainId=nextId("page-main"),this.navigationId=nextId("page-navigation"),this.drawerId=nextId("page-drawer"),this.skipTargetId=nextId("page-skip-target"),this.skipLabelId=nextId("page-skip-label"),this.fragmentTargetId=this.getAttribute("id")||this.skipTargetId,this.fragmentTabIndex=this.getAttribute("tabindex")??"-1",this.allocationFrame=new OwnedFrame(this),this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlayHandle?.isTopmost()&&this.hideNavigation()},onUnexpectedClose:()=>{this.overlayHandle?.isTopmost()&&this.hideNavigation(),this.navOpen&&this.view==="mobile"&&this.nativeModal.show()}}),this.navigationOpener=null,this.customToggles=[],this.customToggleOwnership=new Map,this.onWindowResize=()=>this.measureAllocation(),this.navigationDeferredReturn=()=>{const owner=this.navigationTriggerOwner,opener=owner?null:this.navigationOpener;if(this.navigationOpener=null,!(!owner&&!opener))return{candidates:()=>[owner?.isConnected?resolveAccessibleTrigger(owner):null,opener,this.disableNavigationToggle?null:this.renderRoot.querySelector('[part~="navigation-toggle"]'),this.mainElement],stranded:active=>!!this.drawerElement&&composedContains(this.drawerElement,active),isCurrent:()=>!this.navOpen}},this.resolveNavigationRestoreTarget=()=>{const owner=this.navigationTriggerOwner;if(owner?.isConnected){const accessible=resolveAccessibleTrigger(owner);if(isComposedFocusAvailable(accessible))return accessible}const builtIn=this.disableNavigationToggle?null:this.renderRoot.querySelector('[part~="navigation-toggle"]');return builtIn&&isComposedFocusAvailable(builtIn)?builtIn:this.mainElement&&isComposedFocusAvailable(this.mainElement)?this.mainElement:null},this.onDefaultToggleClick=event=>{this.rememberTriggerAndToggle(event.currentTarget)},this.onToggleSlotClick=event=>{const trigger=event.composedPath().find(candidate=>candidate?.nodeType===1&&candidate.getAttribute("slot")==="navigation-toggle");trigger&&this.customToggles.includes(trigger)&&!this.isUnavailableCustomToggle(trigger)&&this.rememberTriggerAndToggle(trigger)},this.onPageClick=event=>{const path=event.composedPath();if(path.some(candidate=>candidate?.nodeType===1&&candidate.getAttribute("slot")==="navigation-toggle"))return;const trigger=path.find(candidate=>candidate?.nodeType===1&&candidate.hasAttribute("data-toggle-nav"));trigger&&this.rememberTriggerAndToggle(trigger)},this.onBackdropClick=event=>{event.target===event.currentTarget&&this.overlayHandle?.dismissBackdrop()},this.onSkipClick=event=>{event.preventDefault(),this.mainElement?.focus(),this.mainElement?.scrollIntoView({block:"start"})}}static{this.defaultStrings={...super.defaultStrings,closeNavigation:LYRA_DEFAULT_closeNavigation,navigation:LYRA_DEFAULT_navigation,openNavigation:LYRA_DEFAULT_openNavigation,skipToContent:LYRA_DEFAULT_skipToContent}}static{this.knownUnobservedAttributes=["disable-sticky"]}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}connectedCallback(){super.connectedCallback(),this.measureAllocation(),this.observeAllocation(),this.hasUpdated&&this.view==="mobile"&&this.navOpen&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.syncOverlay(),queueMicrotask(()=>{this.nativeModal.show(),this.overlayHandle?.focusInitial()})),this.hasUpdated&&queueMicrotask(()=>this.isConnected&&this.syncCustomToggle())}disconnectedCallback(){this.nativeModal.hide(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.allocationFrame.cancel(),this.resizeView?.removeEventListener("resize",this.onWindowResize),this.resizeView=void 0,this.overlayHandle?.suspend(),cancelDeferredFocusReturn(this),this.releaseCustomToggleA11y(),super.disconnectedCallback()}firstUpdated(changed){super.firstUpdated(changed),this.measureAllocation(),this.observeAllocation()}willUpdate(changed){super.willUpdate(changed),this.view==="mobile"&&this.navOpen&&!this.overlayHandle&&this.nativeModal.prepare(),(this.view!=="mobile"||!this.navOpen)&&(this.nativeModal.hide(),this.nativeModal.prepare(!1)),changed.has("fragmentTargetId")&&!this.fragmentTargetId&&(this.fragmentTargetId=this.skipTargetId),changed.has("fragmentTabIndex")&&this.fragmentTabIndex===null&&(this.fragmentTabIndex="-1")}updated(changed){super.updated(changed),this.view==="mobile"&&this.navOpen&&this.nativeModal.show();const describedBy=this.view==="mobile"&&this.navOpen?this.getAttribute("aria-describedby"):null;for(const dialog of this.renderRoot.querySelectorAll('[part="drawer"], [data-native-modal-carrier]'))syncAriaDescribedByElements(this,dialog,describedBy);changed.has("mobileBreakpoint")&&changed.get("mobileBreakpoint")!==void 0&&this.measureAllocation(),this.overlayHandle!==void 0&&(!this.isConnected||this.view!=="mobile"||!this.navOpen)?(this.syncOverlay(changed),this.syncCustomToggle()):(this.syncCustomToggle(),this.syncOverlay(changed))}observeAllocation(){if(!this.isConnected)return;this.resizeView?.removeEventListener("resize",this.onWindowResize),this.resizeView=void 0;const view=this.ownerDocument.defaultView,ResizeObserverConstructor=view?.ResizeObserver;if(ResizeObserverConstructor){if(!this.resizeObserver){const observer=new ResizeObserverConstructor(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==view||this.resizeObserver!==observer)return;const entry=entries.find(candidate=>candidate.target===this)??entries[0],inlineSize=entry?.contentBoxSize?.[0]?.inlineSize??entry?.contentRect.width;inlineSize!==void 0&&this.allocationFrame.schedule(()=>this.applyMeasuredInlineSize(inlineSize))});this.resizeObserver=observer}this.resizeObserver.observe(this);return}view&&(this.resizeView=view,view.addEventListener("resize",this.onWindowResize))}measureAllocation(){const width=this.getBoundingClientRect().width;width>0&&this.applyMeasuredInlineSize(width)}applyMeasuredInlineSize(width){if(!Number.isFinite(width)||width<0)return;const resolved=resolveCssLength(this.mobileBreakpoint,{host:this}),fallback=resolveCssLength(DEFAULT_MOBILE_BREAKPOINT,{host:this})??768,breakpoint=Math.max(0,resolved!==void 0&&Number.isFinite(resolved)?resolved:fallback),next=width<=breakpoint?"mobile":"desktop";next!==this.view&&(this.view=next)}syncOverlay(changed){if(this.isConnected&&this.view==="mobile"&&this.navOpen){if(this.overlayHandle?.isActive()){this.overlayHandle.resume(),this.navigationTriggerOwner&&this.overlayHandle.updateRestoreFocusTo(this.resolveNavigationRestoreTarget);return}const active=deepActiveElement(this.ownerDocument);this.navigationOpener=active&&typeof active.focus=="function"&&!(this.drawerElement&&composedContains(this.drawerElement,active))?active:null,this.overlayHandle=activateOverlay({host:this,panel:()=>this.drawerElement??null,modalRoot:()=>this.drawerElement??null,onEscape:()=>this.hideNavigation(),onBackdrop:()=>this.hideNavigation(),...this.navigationTriggerOwner?{restoreFocusTo:this.resolveNavigationRestoreTarget}:{},lockScroll:!0,suspendWhenUnrendered:!0,deferredReturn:this.navigationDeferredReturn}),this.overlayHandle.focusInitial();return}if(this.overlayHandle){const restoreFocus=!!(changed?.has("navOpen")&&!this.navOpen);this.overlayHandle.deactivate({restoreFocus}),this.overlayHandle=void 0}this.navOpen||(this.navigationTriggerOwner=void 0)}syncCustomToggle(){const nextToggles=(this.shadowRoot?.querySelector('slot[name="navigation-toggle"]')?.assignedElements({flatten:!0})??[]).filter(candidate=>candidate.nodeType===1&&candidate.getRootNode()!==this.shadowRoot),previous=this.customToggle;this.customToggles=nextToggles,this.customToggle=nextToggles[0];const nextToggleSet=new Set(nextToggles);for(const[host,ownership]of this.customToggleOwnership)nextToggleSet.has(host)||(ownership.accessibleAria?.release(),ownership.hostAria.release(),this.customToggleOwnership.delete(host));const localizedLabel=this.localize(this.navOpen?"closeNavigation":"openNavigation"),drawer=this.drawerElement;for(const host of nextToggles){const accessible=resolveAccessibleTrigger(host);let ownership=this.customToggleOwnership.get(host);ownership?accessible!==ownership.accessible&&(ownership.accessibleAria?.release(),ownership.accessibleAria=void 0,ownership.accessible=accessible,ownership.accessibleAuthoredLabel=accessible.hasAttribute("aria-label")?accessible.getAttribute("aria-label")??"":null):(ownership={accessible,accessibleAuthoredLabel:accessible.hasAttribute("aria-label")?accessible.getAttribute("aria-label")??"":null,hostAria:acquireAriaOwnership(null,{}),hostAuthoredLabel:host.hasAttribute("aria-label")?host.getAttribute("aria-label")??"":null},this.customToggleOwnership.set(host,ownership)),ownership.hostAria.update(host,{attributes:{"aria-haspopup":"dialog","aria-expanded":this.navOpen?"true":"false","aria-label":ownership.hostAuthoredLabel??localizedLabel},controls:drawer?[drawer]:[]});const distinctAccessible=accessible===host?null:accessible,accessibleContribution={attributes:{"aria-haspopup":"dialog","aria-expanded":this.navOpen?"true":"false","aria-label":ownership.accessibleAuthoredLabel??ownership.hostAuthoredLabel??localizedLabel},controls:drawer?[drawer]:[]};ownership.accessibleAria?ownership.accessibleAria.update(distinctAccessible,accessibleContribution):ownership.accessibleAria=acquireAriaOwnership(distinctAccessible,accessibleContribution)}this.navOpen&&this.navigationTriggerOwner&&!nextToggles.includes(this.navigationTriggerOwner)?(this.navigationTriggerOwner=this.customToggle,this.overlayHandle?.updateRestoreFocusTo(this.resolveNavigationRestoreTarget)):this.navOpen&&previous&&this.navigationTriggerOwner===previous&&this.overlayHandle?.updateRestoreFocusTo(this.resolveNavigationRestoreTarget)}releaseCustomToggleA11y(){for(const ownership of this.customToggleOwnership.values())ownership.accessibleAria?.release(),ownership.hostAria.release();this.customToggleOwnership.clear(),this.customToggle=void 0,this.customToggles=[]}isUnavailableCustomToggle(trigger){const accessible=resolveAccessibleTrigger(trigger);return[trigger,accessible].some(candidate=>candidate.hasAttribute("hidden")||candidate.hasAttribute("inert")||candidate.matches(":disabled")||isAriaTrue(candidate.getAttribute("aria-hidden"))||isAriaTrue(candidate.getAttribute("aria-disabled")))}rememberTriggerAndToggle(trigger){this.syncCustomToggle(),this.navOpen||(this.navigationTriggerOwner=trigger),this.toggleNavigation()}requestNavOpen(next){this.navOpen===next||this.emit("lr-nav-toggle-request",{open:next},{cancelable:!0}).defaultPrevented||(this.navOpen=next,this.emit("lr-nav-open-change",{open:next}))}showNavigation(){this.requestNavOpen(!0)}hideNavigation(){this.requestNavOpen(!1)}toggleNavigation(){this.requestNavOpen(!this.navOpen)}visiblePixelsInViewport(element){if(!element)return 0;const rect=element.getBoundingClientRect();if(!Number.isFinite(rect.top)||!Number.isFinite(rect.bottom))return 0;const candidateHeight=element.ownerDocument.defaultView?.innerHeight??element.ownerDocument.documentElement.clientHeight;if(!Number.isFinite(candidateHeight)||candidateHeight<=0)return 0;const viewportHeight=finiteRange(candidateHeight,0,0),visible=Math.min(rect.bottom,viewportHeight)-Math.max(rect.top,0);return finiteRange(visible,0,0,viewportHeight)}render(){const mobile=this.view==="mobile",overlayOpen=mobile&&this.navOpen,navigationLabel=this.accessibleLabel??this.localize("navigation");return html`
1
+ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{nextId,resolveAccessibleTrigger}from"../../../internal/a11y.js";import{isAriaTrue}from"../../../internal/accessibility-visibility.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{syncAriaDescribedByElements}from"../../../internal/aria-reflection.js";import{resolveCssLength}from"../../../internal/css-length.js";import{cancelDeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{menuIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{OwnedFrame}from"../../../internal/owned-timer.js";import{finiteRange}from"../../../internal/numbers.js";import{activateOverlay,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{styles}from"./page.styles.js";import{LYRA_DEFAULT_closeNavigation,LYRA_DEFAULT_openNavigation,LYRA_DEFAULT_skipToContent}from"../../../internal/default-strings/layout.generated.js";import{LYRA_DEFAULT_navigation}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_MOBILE_BREAKPOINT="768px";class LyraPage extends LyraElement{constructor(){super(...arguments),this.view="desktop",this.navOpen=!1,this.mobileBreakpoint="768px",this.navigationPlacement="start",this.disableNavigationToggle=!1,this.accessibleLabel=null,this.mainId=nextId("page-main"),this.navigationId=nextId("page-navigation"),this.drawerId=nextId("page-drawer"),this.skipTargetId=nextId("page-skip-target"),this.skipLabelId=nextId("page-skip-label"),this.fragmentTargetId=this.getAttribute("id")||this.skipTargetId,this.fragmentTabIndex=this.getAttribute("tabindex")??"-1",this.allocationMeasured=!1,this.allocationFrame=new OwnedFrame(this),this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlayHandle?.isTopmost()&&this.hideNavigation()},onUnexpectedClose:()=>{this.overlayHandle?.isTopmost()&&this.hideNavigation(),this.navOpen&&this.view==="mobile"&&this.modalSurface.show()}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal,()=>this.shadowRoot?.querySelector('[part="dialog-wrapper"]')??null),this.navigationOpener=null,this.customToggles=[],this.customToggleOwnership=new Map,this.onWindowResize=()=>this.measureAllocation(),this.navigationDeferredReturn=()=>{const owner=this.navigationTriggerOwner,opener=owner?null:this.navigationOpener;if(this.navigationOpener=null,!(!owner&&!opener))return{candidates:()=>[owner?.isConnected?resolveAccessibleTrigger(owner):null,opener,this.disableNavigationToggle?null:this.renderRoot.querySelector('[part~="navigation-toggle"]'),this.mainElement],stranded:active=>!!this.drawerElement&&composedContains(this.drawerElement,active),isCurrent:()=>!this.navOpen}},this.resolveNavigationRestoreTarget=()=>{const owner=this.navigationTriggerOwner;if(owner?.isConnected){const accessible=resolveAccessibleTrigger(owner);if(isComposedFocusAvailable(accessible))return accessible}const builtIn=this.disableNavigationToggle?null:this.renderRoot.querySelector('[part~="navigation-toggle"]');return builtIn&&isComposedFocusAvailable(builtIn)?builtIn:this.mainElement&&isComposedFocusAvailable(this.mainElement)?this.mainElement:null},this.onDefaultToggleClick=event=>{this.rememberTriggerAndToggle(event.currentTarget)},this.onToggleSlotClick=event=>{const trigger=event.composedPath().find(candidate=>candidate?.nodeType===1&&candidate.getAttribute("slot")==="navigation-toggle");trigger&&this.customToggles.includes(trigger)&&!this.isUnavailableCustomToggle(trigger)&&this.rememberTriggerAndToggle(trigger)},this.onPageClick=event=>{const path=event.composedPath();if(path.some(candidate=>candidate?.nodeType===1&&candidate.getAttribute("slot")==="navigation-toggle"))return;const trigger=path.find(candidate=>candidate?.nodeType===1&&candidate.hasAttribute("data-toggle-nav"));trigger&&this.rememberTriggerAndToggle(trigger)},this.onBackdropClick=event=>{event.target===event.currentTarget&&this.overlayHandle?.dismissBackdrop()},this.onSkipClick=event=>{event.preventDefault(),this.mainElement?.focus(),this.mainElement?.scrollIntoView({block:"start"})}}static{this.defaultStrings={...super.defaultStrings,closeNavigation:LYRA_DEFAULT_closeNavigation,navigation:LYRA_DEFAULT_navigation,openNavigation:LYRA_DEFAULT_openNavigation,skipToContent:LYRA_DEFAULT_skipToContent}}static{this.knownUnobservedAttributes=["disable-sticky"]}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}connectedCallback(){super.connectedCallback(),this.allocationMeasured=!1,this.measureAllocation(),this.observeAllocation(),this.hasUpdated&&this.view==="mobile"&&this.navOpen&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.syncOverlay(),queueMicrotask(()=>{!this.isConnected||this.view!=="mobile"||!this.navOpen||(this.modalSurface.show(),this.overlayHandle?.focusInitial())})),this.hasUpdated&&queueMicrotask(()=>this.isConnected&&this.syncCustomToggle())}disconnectedCallback(){this.modalSurface.disconnect(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.allocationFrame.cancel(),this.resizeView?.removeEventListener("resize",this.onWindowResize),this.resizeView=void 0,this.overlayHandle?.suspend(),cancelDeferredFocusReturn(this),this.releaseCustomToggleA11y(),super.disconnectedCallback()}firstUpdated(changed){super.firstUpdated(changed),this.allocationMeasured||this.measureAllocation()}willUpdate(changed){super.willUpdate(changed),this.view==="mobile"&&this.navOpen&&!this.overlayHandle&&this.modalSurface.prepare(),(this.view!=="mobile"||!this.navOpen)&&(this.modalSurface.hide(),this.nativeModal.prepare(!1)),changed.has("fragmentTargetId")&&!this.fragmentTargetId&&(this.fragmentTargetId=this.skipTargetId),changed.has("fragmentTabIndex")&&this.fragmentTabIndex===null&&(this.fragmentTabIndex="-1")}updated(changed){super.updated(changed),this.view==="mobile"&&this.navOpen&&this.modalSurface.show();const describedBy=this.view==="mobile"&&this.navOpen?this.getAttribute("aria-describedby"):null;for(const dialog of this.renderRoot.querySelectorAll('[part="drawer"], [data-native-modal-carrier]'))syncAriaDescribedByElements(this,dialog,describedBy);changed.has("mobileBreakpoint")&&changed.get("mobileBreakpoint")!==void 0&&this.measureAllocation(),this.overlayHandle!==void 0&&(!this.isConnected||this.view!=="mobile"||!this.navOpen)?(this.syncOverlay(changed),this.syncCustomToggle()):(this.syncCustomToggle(),this.syncOverlay(changed))}observeAllocation(){if(!this.isConnected)return;this.resizeView?.removeEventListener("resize",this.onWindowResize),this.resizeView=void 0;const view=this.ownerDocument.defaultView,ResizeObserverConstructor=view?.ResizeObserver;if(ResizeObserverConstructor){if(!this.resizeObserver){const observer=new ResizeObserverConstructor(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==view||this.resizeObserver!==observer)return;const entry=entries.find(candidate=>candidate.target===this)??entries[0],inlineSize=entry?.contentBoxSize?.[0]?.inlineSize??entry?.contentRect.width;inlineSize!==void 0&&this.allocationFrame.schedule(()=>this.applyMeasuredInlineSize(inlineSize))});this.resizeObserver=observer}this.resizeObserver.observe(this);return}view&&(this.resizeView=view,view.addEventListener("resize",this.onWindowResize))}measureAllocation(){const width=this.getBoundingClientRect().width;width>0&&(this.allocationMeasured=!0,this.applyMeasuredInlineSize(width))}applyMeasuredInlineSize(width){if(!Number.isFinite(width)||width<0)return;const resolved=resolveCssLength(this.mobileBreakpoint,{host:this}),fallback=resolveCssLength(DEFAULT_MOBILE_BREAKPOINT,{host:this})??768,breakpoint=Math.max(0,resolved!==void 0&&Number.isFinite(resolved)?resolved:fallback),next=width<=breakpoint?"mobile":"desktop";next!==this.view&&(this.view=next)}syncOverlay(changed){if(this.isConnected&&this.view==="mobile"&&this.navOpen){if(this.overlayHandle?.isActive()){this.overlayHandle.resume(),this.navigationTriggerOwner&&this.overlayHandle.updateRestoreFocusTo(this.resolveNavigationRestoreTarget);return}const active=deepActiveElement(this.ownerDocument);this.navigationOpener=active&&typeof active.focus=="function"&&!(this.drawerElement&&composedContains(this.drawerElement,active))?active:null,this.overlayHandle=activateOverlay({host:this,panel:()=>this.drawerElement??null,modalRoot:()=>this.drawerElement??null,onEscape:()=>this.hideNavigation(),onBackdrop:()=>this.hideNavigation(),...this.navigationTriggerOwner?{restoreFocusTo:this.resolveNavigationRestoreTarget}:{},lockScroll:!0,suspendWhenUnrendered:!0,deferredReturn:this.navigationDeferredReturn}),this.overlayHandle.focusInitial();return}if(this.overlayHandle){const restoreFocus=!!(changed?.has("navOpen")&&!this.navOpen);this.overlayHandle.deactivate({restoreFocus}),this.overlayHandle=void 0}this.navOpen||(this.navigationTriggerOwner=void 0)}syncCustomToggle(){const nextToggles=(this.shadowRoot?.querySelector('slot[name="navigation-toggle"]')?.assignedElements({flatten:!0})??[]).filter(candidate=>candidate.nodeType===1&&candidate.getRootNode()!==this.shadowRoot),previous=this.customToggle;this.customToggles=nextToggles,this.customToggle=nextToggles[0];const nextToggleSet=new Set(nextToggles);for(const[host,ownership]of this.customToggleOwnership)nextToggleSet.has(host)||(ownership.accessibleAria?.release(),ownership.hostAria.release(),this.customToggleOwnership.delete(host));const localizedLabel=this.localize(this.navOpen?"closeNavigation":"openNavigation"),drawer=this.drawerElement;for(const host of nextToggles){const accessible=resolveAccessibleTrigger(host);let ownership=this.customToggleOwnership.get(host);ownership?accessible!==ownership.accessible&&(ownership.accessibleAria?.release(),ownership.accessibleAria=void 0,ownership.accessible=accessible,ownership.accessibleAuthoredLabel=accessible.hasAttribute("aria-label")?accessible.getAttribute("aria-label")??"":null):(ownership={accessible,accessibleAuthoredLabel:accessible.hasAttribute("aria-label")?accessible.getAttribute("aria-label")??"":null,hostAria:acquireAriaOwnership(null,{}),hostAuthoredLabel:host.hasAttribute("aria-label")?host.getAttribute("aria-label")??"":null},this.customToggleOwnership.set(host,ownership)),ownership.hostAria.update(host,{attributes:{"aria-haspopup":"dialog","aria-expanded":this.navOpen?"true":"false","aria-label":ownership.hostAuthoredLabel??localizedLabel},controls:drawer?[drawer]:[]});const distinctAccessible=accessible===host?null:accessible,accessibleContribution={attributes:{"aria-haspopup":"dialog","aria-expanded":this.navOpen?"true":"false","aria-label":ownership.accessibleAuthoredLabel??ownership.hostAuthoredLabel??localizedLabel},controls:drawer?[drawer]:[]};ownership.accessibleAria?ownership.accessibleAria.update(distinctAccessible,accessibleContribution):ownership.accessibleAria=acquireAriaOwnership(distinctAccessible,accessibleContribution)}this.navOpen&&this.navigationTriggerOwner&&!nextToggles.includes(this.navigationTriggerOwner)?(this.navigationTriggerOwner=this.customToggle,this.overlayHandle?.updateRestoreFocusTo(this.resolveNavigationRestoreTarget)):this.navOpen&&previous&&this.navigationTriggerOwner===previous&&this.overlayHandle?.updateRestoreFocusTo(this.resolveNavigationRestoreTarget)}releaseCustomToggleA11y(){for(const ownership of this.customToggleOwnership.values())ownership.accessibleAria?.release(),ownership.hostAria.release();this.customToggleOwnership.clear(),this.customToggle=void 0,this.customToggles=[]}isUnavailableCustomToggle(trigger){const accessible=resolveAccessibleTrigger(trigger);return[trigger,accessible].some(candidate=>candidate.hasAttribute("hidden")||candidate.hasAttribute("inert")||candidate.matches(":disabled")||isAriaTrue(candidate.getAttribute("aria-hidden"))||isAriaTrue(candidate.getAttribute("aria-disabled")))}rememberTriggerAndToggle(trigger){this.syncCustomToggle(),this.navOpen||(this.navigationTriggerOwner=trigger),this.toggleNavigation()}requestNavOpen(next){this.navOpen===next||this.emit("lr-nav-toggle-request",{open:next},{cancelable:!0}).defaultPrevented||(this.navOpen=next,this.emit("lr-nav-open-change",{open:next}))}showNavigation(){this.requestNavOpen(!0)}hideNavigation(){this.requestNavOpen(!1)}toggleNavigation(){this.requestNavOpen(!this.navOpen)}visiblePixelsInViewport(element){if(!element)return 0;const rect=element.getBoundingClientRect();if(!Number.isFinite(rect.top)||!Number.isFinite(rect.bottom))return 0;const candidateHeight=element.ownerDocument.defaultView?.innerHeight??element.ownerDocument.documentElement.clientHeight;if(!Number.isFinite(candidateHeight)||candidateHeight<=0)return 0;const viewportHeight=finiteRange(candidateHeight,0,0),visible=Math.min(rect.bottom,viewportHeight)-Math.max(rect.top,0);return finiteRange(visible,0,0,viewportHeight)}render(){const mobile=this.view==="mobile",overlayOpen=mobile&&this.navOpen,navigationLabel=this.accessibleLabel??this.localize("navigation");return html`
2
2
  <div part="base page" @click=${this.onPageClick}>
3
3
  <a
4
4
  part="skip-to-content"
@@ -20,8 +20,8 @@ export interface LyraResponsivePanelCloseDetail{reason:LyraResponsivePanelCloseR
20
20
  * `mode="auto"` (the default) updates the
21
21
  * effective presentation without unmounting or re-creating the slotted
22
22
  * content: inline and overlay presentation share the exact same shadow DOM
23
- * structure (only a css class, and the overlay-only `role`/`aria-modal`
24
- * attributes and backdrop element, differ), so lit-html's diffing keeps
23
+ * structure (only a css class, top-layer presentation, overlay-only `role`/`aria-modal`
24
+ * attributes, and backdrop element differ), so lit-html's diffing keeps
25
25
  * `[part="body"]` and its `<slot>` as the same DOM node across the
26
26
  * transition -- scroll position and focus inside the slotted content survive
27
27
  * it for free. When an open inline panel becomes modal, focus already inside
@@ -39,6 +39,8 @@ export interface LyraResponsivePanelCloseDetail{reason:LyraResponsivePanelCloseR
39
39
  * The overlay presentation uses the library's shared overlay coordinator for
40
40
  * focus trapping, Escape/backdrop dismissal, inerting, and stack ordering,
41
41
  * while retaining this component's own responsive rendering and close event.
42
+ * Its surface enters the browser top layer, so sticky headers and ancestor
43
+ * stacking contexts cannot cover it. The host stays in its authored slot.
42
44
  *
43
45
  * Accessible name (overlay presentation only -- the inline presentation has
44
46
  * no dialog semantics to name), in priority order: if the host element itself
@@ -116,9 +118,9 @@ shape:LyraResponsivePanelShape;
116
118
  label:string;
117
119
  /** CSS length compared with this element's allocated inline size in `mode="auto"`.
118
120
  * At or below the breakpoint, the effective presentation is `'overlay'`. */
119
- overlayBreakpoint:string;private accessibleLabel;private belowBreakpoint;private resolvedMode;private readonly slotPresence;private headingText?;private resizeObserver?;private resizeView?;private lastTrigger?;private overlayHandle?;private readonly nativeModal;private headerObserver?;private headerObserverDocument?;private headerObserverGeneration;private ownerRealmGeneration;private overlayChromeActive;private focusOverlayAfterUpdate;private isFirstUpdate;
121
+ overlayBreakpoint:string;private accessibleLabel;private belowBreakpoint;private resolvedMode;private readonly slotPresence;private headingText?;private resizeObserver?;private resizeView?;private lastTrigger?;private overlayHandle?;private readonly nativeModal;private readonly modalSurface;private headerObserver?;private headerObserverDocument?;private headerObserverGeneration;private ownerRealmGeneration;private overlayChromeActive;private focusOverlayAfterUpdate;private isFirstUpdate;
120
122
  /** The currently resolved presentation. Composition/measurement is the sole write authority.*/
121
- get effectiveMode():LyraResponsivePanelEffectiveMode;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private resetOwnerRealmWork;private queueOwnerMicrotask;private activateOverlayChrome;private deactivateOverlayChrome;private observeAllocation;private readonly onWindowResize;private measureAllocation;private applyMeasuredInlineSize;private onHeaderSlotChange;private syncHeaderSlot;private resetHeaderObserver;private detectHeadingText;
123
+ get effectiveMode():LyraResponsivePanelEffectiveMode;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private resetOwnerRealmWork;private queueOwnerMicrotask;private activateOverlayChrome;private deactivateOverlayChrome;private showOverlaySurface;private observeAllocation;private readonly onWindowResize;private measureAllocation;private applyMeasuredInlineSize;private onHeaderSlotChange;private syncHeaderSlot;private resetHeaderObserver;private detectHeadingText;
122
124
  /**
123
125
  * Close the panel. `reason` is forwarded as `lr-close` detail.reason --
124
126
  * built-in overlay triggers pass `'escape'`/`'backdrop'`; a consumer's own