@aceshooting/lyra-ui 30.9.0 → 31.0.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 (201) hide show
  1. package/CHANGELOG.md +236 -339
  2. package/dist/ai/adapters/ag-ui.js +1 -1
  3. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
  4. package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
  5. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  6. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
  7. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +1 -1
  8. package/dist/components/charts/chart/box-plot.class.js +2 -2
  9. package/dist/components/charts/chart/chart-sync.js +1 -1
  10. package/dist/components/charts/chart/chart.class.d.ts +1 -1
  11. package/dist/components/charts/chart/chart.class.js +4 -4
  12. package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -1
  13. package/dist/components/charts/chart/lite-chart.class.js +1 -1
  14. package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +9 -4
  15. package/dist/components/conversation/chat-composer/chat-composer.class.js +1 -1
  16. package/dist/components/conversation/chat-composer/chat-composer.styles.js +1 -1
  17. package/dist/components/conversation/chat-message/chat-message.class.d.ts +27 -3
  18. package/dist/components/conversation/chat-message/chat-message.class.js +14 -12
  19. package/dist/components/conversation/chat-message/chat-message.styles.js +1 -1
  20. package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +29 -2
  21. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +2 -2
  22. package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +1 -1
  23. package/dist/components/conversation/code-block/code-block-shared.js +1 -1
  24. package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -1
  25. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  26. package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
  27. package/dist/components/conversation/markdown/markdown-core.class.d.ts +10 -0
  28. package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
  29. package/dist/components/conversation/markdown/markdown-shared.d.ts +7 -2
  30. package/dist/components/conversation/markdown/markdown-shared.js +3 -3
  31. package/dist/components/conversation/markdown/markdown.class.d.ts +10 -0
  32. package/dist/components/conversation/markdown/markdown.class.js +1 -1
  33. package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
  34. package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
  35. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +2 -1
  36. package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +4 -0
  37. package/dist/components/conversation/streaming-text/streaming-text-base.class.js +1 -1
  38. package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +1 -1
  39. package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -0
  40. package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +1 -1
  41. package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
  42. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +17 -3
  43. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +3 -3
  44. package/dist/components/conversation/suggestion-chips/suggestion-chips.d.ts +1 -1
  45. package/dist/components/conversation/suggestion-chips/suggestion-chips.js +1 -1
  46. package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
  47. package/dist/components/conversation/thread-list/thread-list.class.js +2 -2
  48. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  49. package/dist/components/data/data-grid/data-grid.class.d.ts +10 -10
  50. package/dist/components/data/data-grid/data-grid.class.js +1 -1
  51. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  52. package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
  53. package/dist/components/data/heatmap/heatmap.class.d.ts +1 -1
  54. package/dist/components/data/heatmap/heatmap.class.js +1 -1
  55. package/dist/components/data/pagination/pagination.class.js +1 -1
  56. package/dist/components/data/table/table.class.d.ts +31 -2
  57. package/dist/components/data/table/table.class.js +3 -3
  58. package/dist/components/data/table/table.styles.js +1 -1
  59. package/dist/components/data/timeline/timeline-cluster.js +1 -1
  60. package/dist/components/data/timeline/timeline-item.class.d.ts +10 -3
  61. package/dist/components/data/timeline/timeline-item.class.js +16 -12
  62. package/dist/components/data/timeline/timeline-item.styles.js +1 -1
  63. package/dist/components/data/timeline/timeline.class.d.ts +14 -2
  64. package/dist/components/data/timeline/timeline.class.js +9 -5
  65. package/dist/components/data/tree/tree-item.class.js +1 -1
  66. package/dist/components/data/tree/tree.class.d.ts +2 -0
  67. package/dist/components/data/tree/tree.class.js +1 -1
  68. package/dist/components/forms/button/button.class.d.ts +8 -6
  69. package/dist/components/forms/button/button.class.js +2 -2
  70. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  71. package/dist/components/forms/color-picker/color-core.js +1 -1
  72. package/dist/components/forms/date-picker/date-input.class.d.ts +1 -1
  73. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  74. package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -2
  75. package/dist/components/forms/icon-button/icon-button.class.js +2 -2
  76. package/dist/components/forms/input/input-shared.js +2 -2
  77. package/dist/components/forms/input/number-input-locale.js +1 -0
  78. package/dist/components/forms/input/number-input.class.d.ts +19 -2
  79. package/dist/components/forms/input/number-input.class.js +2 -2
  80. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +3 -3
  81. package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
  82. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  83. package/dist/components/layout/details/accordion-item.class.js +1 -1
  84. package/dist/components/layout/menu/menu.class.js +1 -1
  85. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  86. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
  87. package/dist/components/layout/tab-group/tab-group.class.d.ts +8 -1
  88. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  89. package/dist/components/layout/tab-group/tab.class.d.ts +7 -1
  90. package/dist/components/layout/tab-group/tab.class.js +1 -1
  91. package/dist/components/layout/virtual-list/virtual-list.class.d.ts +2 -2
  92. package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
  93. package/dist/components/media/animated-image/animated-image.class.js +1 -1
  94. package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +21 -14
  95. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  96. package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +36 -12
  97. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
  98. package/dist/components/media/drop-zone/drop-zone.class.d.ts +23 -5
  99. package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
  100. package/dist/components/media/drop-zone/drop-zone.styles.js +1 -1
  101. package/dist/components/media/file-icon/file-icon.class.js +1 -1
  102. package/dist/components/media/flag/flag-url-resolver.js +1 -1
  103. package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -2
  104. package/dist/components/media/image-viewer/image-viewer.class.js +1 -1
  105. package/dist/components/media/map/map-owned-features.js +1 -1
  106. package/dist/components/media/map/map-scene-elevated-lines.js +2 -2
  107. package/dist/components/media/map/map-scene-render-controller.js +1 -1
  108. package/dist/components/media/map/map.class.d.ts +5 -5
  109. package/dist/components/media/map/map.class.js +3 -3
  110. package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
  111. package/dist/components/media/video/video.class.d.ts +3 -3
  112. package/dist/components/media/video/video.class.js +3 -1
  113. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  114. package/dist/components/overlays/chip/chip.class.js +1 -1
  115. package/dist/components/overlays/overlay/dropdown.class.js +1 -1
  116. package/dist/components/overlays/overlay/tooltip.class.d.ts +5 -1
  117. package/dist/components/overlays/overlay/tooltip.class.js +3 -3
  118. package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -1
  119. package/dist/components/retrieval/graph/graph-node-renderer.js +1 -1
  120. package/dist/components/retrieval/graph/graph-spatial-controller.js +1 -1
  121. package/dist/components/retrieval/graph/graph.class.d.ts +1 -1
  122. package/dist/components/retrieval/graph/graph.class.js +1 -1
  123. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  124. package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +1 -1
  125. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +3 -3
  126. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
  127. package/dist/components/utility/json-viewer/json-viewer.class.d.ts +16 -1
  128. package/dist/components/utility/json-viewer/json-viewer.class.js +4 -4
  129. package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
  130. package/dist/components/utility/known-date/known-date.class.js +1 -1
  131. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  132. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  133. package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
  134. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
  135. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
  136. package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
  137. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  138. package/dist/components/viewers/include/include.class.js +1 -1
  139. package/dist/components/viewers/model-viewer/model-viewer.class.js +1 -1
  140. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
  141. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
  142. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
  143. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
  144. package/dist/components/viewers/table-viewer-shared.js +4 -4
  145. package/dist/framework-types.d.ts +1 -1
  146. package/dist/internal/anchored-overlay-runtime.js +1 -1
  147. package/dist/internal/catalog-picker.js +1 -1
  148. package/dist/internal/document-tokens.js +2 -2
  149. package/dist/internal/drop-session-controller.js +1 -1
  150. package/dist/internal/engine-3d.js +1 -1
  151. package/dist/internal/icon-only-content.js +1 -1
  152. package/dist/internal/layered-layout.js +1 -1
  153. package/dist/internal/map-custom-layer-controller.js +1 -1
  154. package/dist/internal/media-panorama.js +1 -1
  155. package/dist/internal/package-metadata.js +1 -1
  156. package/dist/internal/safe-url.js +1 -1
  157. package/dist/internal/scoped-definitions.generated.js +1 -1
  158. package/dist/internal/scroll-overflow.js +1 -1
  159. package/dist/internal/source-window-controller.js +1 -1
  160. package/dist/internal/text-quote.js +1 -1
  161. package/dist/internal/viewer-search.js +1 -1
  162. package/dist/lyra.d.ts +1 -1
  163. package/dist/sequence-time-binding.js +1 -1
  164. package/dist/simulation-clock.js +1 -1
  165. package/dist/styles/reservations.css +1 -1
  166. package/dist/styles/reservations.styles.js +1 -1
  167. package/dist/testing/happy-dom-shims.js +1 -1
  168. package/dist/theme/theme.js +1 -1
  169. package/llms/components/lr-attachment-chip.md +27 -12
  170. package/llms/components/lr-attachment-trigger.md +27 -7
  171. package/llms/components/lr-button.md +6 -4
  172. package/llms/components/lr-chat-composer.md +13 -7
  173. package/llms/components/lr-chat-message.md +44 -3
  174. package/llms/components/lr-chat-viewport.md +39 -2
  175. package/llms/components/lr-data-grid.md +2 -0
  176. package/llms/components/lr-dialog.md +10 -0
  177. package/llms/components/lr-drop-zone.md +26 -2
  178. package/llms/components/lr-icon-button.md +2 -1
  179. package/llms/components/lr-json-viewer.md +17 -0
  180. package/llms/components/lr-locale-picker.md +5 -0
  181. package/llms/components/lr-markdown-core.md +2 -1
  182. package/llms/components/lr-markdown.md +20 -4
  183. package/llms/components/lr-menu.md +3 -1
  184. package/llms/components/lr-number-input.md +28 -1
  185. package/llms/components/lr-prompt-input.md +1 -1
  186. package/llms/components/lr-streaming-text-core.md +3 -2
  187. package/llms/components/lr-streaming-text.md +4 -1
  188. package/llms/components/lr-suggestion-chips.md +28 -5
  189. package/llms/components/lr-tab-group.md +13 -1
  190. package/llms/components/lr-tab.md +5 -0
  191. package/llms/components/lr-table.md +25 -4
  192. package/llms/components/lr-timeline-item.md +1 -1
  193. package/llms/components/lr-timeline.md +38 -4
  194. package/llms/components/lr-tooltip.md +3 -1
  195. package/llms/components/lr-tree.md +4 -0
  196. package/llms/components/lr-virtual-list.md +1 -0
  197. package/llms/peers.md +2 -2
  198. package/llms/shared/forms-and-accessibility.md +21 -4
  199. package/llms/shared.md +21 -4
  200. package/package.json +21 -20
  201. package/registrations.json +1 -1
@@ -32,8 +32,9 @@ export type ButtonFormMethod='get'|'post'|'dialog';export interface LyraButtonEv
32
32
  * transient native button rather than this host. With none of those properties set, submission
33
33
  * stays a plain `requestSubmit()` with a `null` submitter.
34
34
  *
35
- * When `href` is set to a safe link URL (`http:`/`https:`/`blob:`/`mailto:`/relative — see
36
- * `safeLinkHref`, or `safeDownloadHref` which drops `mailto:` when `download` is set) the root
35
+ * When `href` is set to a safe link URL (`http:`/`https:`/`blob:`/`mailto:`/`tel:`/`sms:`/relative —
36
+ * see `safeActionLinkHref`, or `safeDownloadHref` which drops `mailto:`, `tel:` and `sms:` when
37
+ * `download` is set) the root
37
38
  * renders as a real `<a part="base" href=…>` instead — for a link styled
38
39
  * as a button (e.g. a CTA). Native navigation is then the anchor's own activation, so the
39
40
  * submit/reset click handler and `type` (submit/reset) have no effect in that mode. When the
@@ -350,10 +351,11 @@ formTarget?:string;
350
351
  loading:boolean;
351
352
  /** When set to a safe link URL, the button's root renders as a real `<a href=…>` instead of a
352
353
  * `<button>` — for a link styled as a button (e.g. a CTA). Unset (the default) renders a plain
353
- * `<button>`, byte-for-byte as before. Only `http:`/`https:`/`blob:`/`mailto:`/relative URLs are
354
- * honored (see `safeLinkHref`); an unsafe/unparseable value falls back to the native `<button>`.
355
- * Setting `download` narrows the allowlist to `safeDownloadHref`'s, which drops `mailto:` — a
356
- * mail handoff names no retrievable bytes, so it cannot be a download target.
354
+ * `<button>`, byte-for-byte as before. Only `http:`/`https:`/`blob:`/`mailto:`/`tel:`/`sms:`/relative
355
+ * URLs are honored (see `safeActionLinkHref`); an unsafe/unparseable value falls back to the
356
+ * native `<button>`. `tel:` and `sms:` hand off to the dialer or messaging app, like `mailto:`
357
+ * to the mail client. Setting `download` narrows the allowlist to `safeDownloadHref`'s, which
358
+ * drops all three — a handoff names no retrievable bytes, so it cannot be a download target.
357
359
  * `type` (submit/reset) has no effect while the anchor renders — an anchor has no submit/reset
358
360
  * concept, and native navigation is its own activation. While the button is disabled the anchor
359
361
  * renders with no `href` (see the class doc comment), so a disabled link button cannot navigate. */
@@ -1,4 +1,4 @@
1
- var _a;import{__decorate}from"tslib";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{FORM_CONTROL_LABEL_FACTORY,LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{installFormControlInternalsCapture}from"../../../internal/form-control-labels.js";import{chevronIcon,spinnerIcon}from"../../../internal/icons.js";import{hasIconOnlyDefaultContent,IconOnlyLabelObserver}from"../../../internal/icon-only-content.js";import{safeDownloadHref,safeLinkHref}from"../../../internal/safe-url.js";import{syncAriaControlsElements}from"../../../internal/aria-reflection.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{sizes}from"../../../internal/sizes.styles.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{getFormOwner,setFormOwner}from"../../../internal/direct-form-associated.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState}from"../../../internal/custom-states.js";import{literalSetConverter,omittedEmptyStringConverter}from"../../../internal/converters.js";import{resolveGuardedRel}from"../../../internal/link-rel.js";import{currentValidityValidator}from"../form-validator.js";import{findDefaultButton,isImplicitSubmission,submitFormImplicitly}from"../../../internal/submit-on-enter.js";import{createButtonExternalLabelController}from"./button-external-label.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";installFormControlInternalsCapture();const BUTTON_TYPE=literalSetConverter(["button","submit","reset"],"button"),IMPLICIT_SUBMIT_INPUT=/^(text|search|url|tel|email|password|date|month|week|time|datetime-local|number)$/;class LyraButton extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","loading","href","value")]}static{this.styles=[LyraElement.styles,sizes,variants,styles]}static{this.formAssociated=!0}static{this[_a]=createButtonExternalLabelController}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},customError:{attribute:"custom-error",reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.requestUpdate("disabled",old),this.updateValidity(),this.syncButtonStates()}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get effectiveDisabled(){return this._disabled||this._fieldsetDisabled}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}constructor(){super(),this._fieldsetDisabled=!1,this._disabled=!1,this._name="",this._value="",this._required=!1,this._variant="neutral",this._type="button",this.injectedHostTabIndex=!1,this.implicitForm=null,this.localDescriptionIds="",this.customValidityMessage="",this.reflectingCustomError=!1,this.accessibleLabel=null,this.triggerHasPopup=null,this.triggerKeyShortcuts=null,this.triggerExpanded=null,this.triggerPressed=null,this.pressed=null,this.triggerCurrent=null,this.triggerControls=null,this.triggerDescribedBy=null,this.appearance="accent",this.size="m",this.pill=!1,this.circle=!1,this.outline=!1,this.withCaret=!1,this.withStart=!1,this.withEnd=!1,this.wrap=!1,this.formNoValidate=!1,this.loading=!1,this.hasStartSlot=!1,this.hasEndSlot=!1,this.isIconButton=!1,this.iconOnlyObserver=new IconOnlyLabelObserver(this,()=>this.labelEl,()=>this.isIconButton,next=>{this.isIconButton=next,this.syncButtonStates()}),this.onFormKeyDown=event=>{const field=event.target,form=this.implicitForm;!form||!isImplicitSubmission(event)||!(field instanceof HTMLInputElement)||!IMPLICIT_SUBMIT_INPUT.test(field.type)||field.form!==form||this.baseEl?.localName==="a"||findDefaultButton(form)!==this||(event.preventDefault(),submitFormImplicitly(form))},this.onClick=event=>{if(this.type!=="submit"&&this.type!=="reset")return;const ownerWindow=this.ownerDocument.defaultView;let settled=!1;const finish=()=>{settled||(settled=!0,ownerWindow?.removeEventListener("click",finishAtWindow),!(event.defaultPrevented||this.effectiveDisabled||this.loading)&&this.runClickDefaultAction())},finishAtWindow=candidate=>{candidate===event&&finish()};ownerWindow?.addEventListener("click",finishAtWindow),queueMicrotask(finish)},this.onFocusChange=event=>{relayNativeEvent(this,event)},this.onAdornmentSlotChange=()=>{this.syncAdornmentSlots()},this.onDefaultSlotChange=()=>{this.isIconButton=hasIconOnlyDefaultContent(this),this.syncButtonStates()},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),customError:()=>this.customValidityMessage}),this.internals=this.validityController.formInternals,this.updateValidity(),this.syncButtonStates()}get variant(){return this._variant}set variant(next){next==="primary"?this._variant="brand":next==="default"||next==="text"?this._variant="neutral":this._variant=next,next==="text"&&(this.appearance="plain")}get caret(){return this.withCaret}set caret(next){this.withCaret=!!next}get type(){return this._type}set type(next){const old=this._type;this._type=BUTTON_TYPE.normalize(typeof next=="string"?next.toLowerCase():next),this.requestUpdate("type",old)}get value(){return this._value}set value(next){this._value=next??"",this.updateValidity()}get required(){return this._required}set required(next){this._required=!!next,this.updateValidity()}get resolvedRel(){return resolveGuardedRel(this.rel,this.target)}click(){this.effectiveDisabled||this.loading||this.baseEl?.click()}focus(options){!this.effectiveDisabled&&!this.loading&&this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}[(_a=FORM_CONTROL_LABEL_FACTORY,VALIDITY_ANCHOR)](){return this.baseEl??null}checkValidity(){return this.validityController.checkValidity()}reportValidity(){return this.validityController.syncConstraints(),this.internals.reportValidity()}setCustomValidity(message){const old=this.customValidityMessage||null,next=message??"";if(this.customValidityMessage=next,this.validityController.setCustomValidity(this.isValidationBarred?"":next),!this.reflectingCustomError){this.reflectingCustomError=!0;try{next?this.setAttribute("custom-error",next):this.removeAttribute("custom-error")}finally{this.reflectingCustomError=!1}}this.requestUpdate("customError",old)}resetValidity(){this.customValidityMessage="",this.validityController.setCustomValidity(""),this.updateValidity()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?state2:""}syncImplicitSubmission(form=this.getForm()){const next=this.type==="submit"&&this.isConnected?form:null;next!==this.implicitForm&&(this.implicitForm?.removeEventListener("keydown",this.onFormKeyDown),this.implicitForm=next,next?.addEventListener("keydown",this.onFormKeyDown))}formAssociatedCallback(form){this.syncImplicitSubmission(form)}runClickDefaultAction(){if(this.type==="submit"){const form=this.getForm();if(!form)return;this.hasSubmitterOverrides?this.submitAsNamedSubmitter(form):form.requestSubmit()}else this.type==="reset"&&this.getForm()?.reset()}get hasSubmitterOverrides(){return!!(this.name||this.value||this.formNoValidate)||this.formAction!==void 0||this.formEnctype!==void 0||this.formMethod!==void 0||this.formTarget!==void 0}submitAsNamedSubmitter(form){const submitter=this.ownerDocument.createElement("button");submitter.type="submit",submitter.hidden=!0,submitter.tabIndex=-1,this.name&&(submitter.name=this.name,submitter.value=this.value),this.formAction!==void 0&&submitter.setAttribute("formaction",this.formAction),this.formEnctype!==void 0&&submitter.setAttribute("formenctype",this.formEnctype),this.formMethod!==void 0&&submitter.setAttribute("formmethod",this.formMethod),this.formNoValidate&&(submitter.formNoValidate=!0),this.formTarget!==void 0&&submitter.setAttribute("formtarget",this.formTarget),this.parentElement&&this.closest("form")===form?this.insertAdjacentElement("afterend",submitter):form.append(submitter);try{form.requestSubmit(submitter)}finally{submitter.remove()}}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.updateValidity(),this.syncButtonStates(),this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements(),this.syncImplicitSubmission(),this.updateValidity(),this.syncButtonStates(),this.hasUpdated&&this.iconOnlyObserver.arm()}disconnectedCallback(){this.releaseExternalDescription(),this.syncImplicitSubmission(null),this.iconOnlyObserver.disarm(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed);const focusedControl=shadowFocusTarget(this);changed.has("loading")&&this.loading&&focusedControl!==null&&focusedControl===this.baseEl&&(this.hasAttribute("tabindex")||(this.tabIndex=-1,this.injectedHostTabIndex=!0),HTMLElement.prototype.focus.call(this,{preventScroll:!0})),this.hasUpdated||this.seedFirstRenderState(()=>{this.syncAdornmentSlots(),this.isIconButton=hasIconOnlyDefaultContent(this)})}syncAdornmentSlots(){const collection=this.children,children=collection?Array.from(collection):[];this.hasStartSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="start"||slot==="prefix"}),this.hasEndSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="end"||slot==="suffix"})}get labelGrows(){return this.withCaret||this.hasEndSlot||this.withEnd}updated(changed){if(super.updated(changed),changed.has("type")&&this.syncImplicitSubmission(),changed.has("loading")&&!this.loading&&this.injectedHostTabIndex){const parked=this.ownerDocument.activeElement===this&&!shadowFocusTarget(this);this.removeAttribute("tabindex"),this.injectedHostTabIndex=!1,parked&&this.baseEl?.focus({preventScroll:!0})}syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),this.iconOnlyObserver.arm(),this.updateValidity(),this.syncButtonStates()}updateValidity(){if(this.validityController){if(this.isValidationBarred){this.validityController.setCustomValidity(""),this.validityController.setValidity({});return}this.required&&!this.value?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.validityController.setCustomValidity(this.customValidityMessage)}}get isValidationBarred(){return this.effectiveDisabled||this.loading||this.baseEl?.localName==="a"}syncButtonStates(){this.internals&&(setCustomState(this.internals,"disabled",this.effectiveDisabled||this.loading),setCustomState(this.internals,"icon-button",this.isIconButton),setCustomState(this.internals,"link",this.baseEl?.localName==="a"),setCustomState(this.internals,"loading",this.loading))}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}render(){const pressed=this.pressed==="mixed"?"mixed":typeof this.pressed=="boolean"?String(this.pressed):["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,content=html`
1
+ var _a;import{__decorate}from"tslib";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{FORM_CONTROL_LABEL_FACTORY,LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{installFormControlInternalsCapture}from"../../../internal/form-control-labels.js";import{chevronIcon,spinnerIcon}from"../../../internal/icons.js";import{hasIconOnlyDefaultContent,IconOnlyLabelObserver}from"../../../internal/icon-only-content.js";import{safeActionLinkHref,safeDownloadHref}from"../../../internal/safe-url.js";import{syncAriaControlsElements}from"../../../internal/aria-reflection.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{sizes}from"../../../internal/sizes.styles.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{getFormOwner,setFormOwner}from"../../../internal/direct-form-associated.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState}from"../../../internal/custom-states.js";import{literalSetConverter,omittedEmptyStringConverter}from"../../../internal/converters.js";import{resolveGuardedRel}from"../../../internal/link-rel.js";import{currentValidityValidator}from"../form-validator.js";import{findDefaultButton,isImplicitSubmission,submitFormImplicitly}from"../../../internal/submit-on-enter.js";import{createButtonExternalLabelController}from"./button-external-label.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";installFormControlInternalsCapture();const BUTTON_TYPE=literalSetConverter(["button","submit","reset"],"button"),IMPLICIT_SUBMIT_INPUT=/^(text|search|url|tel|email|password|date|month|week|time|datetime-local|number)$/;class LyraButton extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","loading","href","value")]}static{this.styles=[LyraElement.styles,sizes,variants,styles]}static{this.formAssociated=!0}static{this[_a]=createButtonExternalLabelController}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},customError:{attribute:"custom-error",reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.requestUpdate("disabled",old),this.updateValidity(),this.syncButtonStates()}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get effectiveDisabled(){return this._disabled||this._fieldsetDisabled}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}constructor(){super(),this._fieldsetDisabled=!1,this._disabled=!1,this._name="",this._value="",this._required=!1,this._variant="neutral",this._type="button",this.injectedHostTabIndex=!1,this.implicitForm=null,this.localDescriptionIds="",this.customValidityMessage="",this.reflectingCustomError=!1,this.accessibleLabel=null,this.triggerHasPopup=null,this.triggerKeyShortcuts=null,this.triggerExpanded=null,this.triggerPressed=null,this.pressed=null,this.triggerCurrent=null,this.triggerControls=null,this.triggerDescribedBy=null,this.appearance="accent",this.size="m",this.pill=!1,this.circle=!1,this.outline=!1,this.withCaret=!1,this.withStart=!1,this.withEnd=!1,this.wrap=!1,this.formNoValidate=!1,this.loading=!1,this.hasStartSlot=!1,this.hasEndSlot=!1,this.isIconButton=!1,this.iconOnlyObserver=new IconOnlyLabelObserver(this,()=>this.labelEl,()=>this.isIconButton,next=>{this.isIconButton=next,this.syncButtonStates()}),this.onFormKeyDown=event=>{const field=event.target,form=this.implicitForm;!form||!isImplicitSubmission(event)||!(field instanceof HTMLInputElement)||!IMPLICIT_SUBMIT_INPUT.test(field.type)||field.form!==form||this.baseEl?.localName==="a"||findDefaultButton(form)!==this||(event.preventDefault(),submitFormImplicitly(form))},this.onClick=event=>{if(this.type!=="submit"&&this.type!=="reset")return;const ownerWindow=this.ownerDocument.defaultView;let settled=!1;const finish=()=>{settled||(settled=!0,ownerWindow?.removeEventListener("click",finishAtWindow),!(event.defaultPrevented||this.effectiveDisabled||this.loading)&&this.runClickDefaultAction())},finishAtWindow=candidate=>{candidate===event&&finish()};ownerWindow?.addEventListener("click",finishAtWindow),queueMicrotask(finish)},this.onFocusChange=event=>{relayNativeEvent(this,event)},this.onAdornmentSlotChange=()=>{this.syncAdornmentSlots()},this.onDefaultSlotChange=()=>{this.isIconButton=hasIconOnlyDefaultContent(this),this.syncButtonStates()},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),customError:()=>this.customValidityMessage}),this.internals=this.validityController.formInternals,this.updateValidity(),this.syncButtonStates()}get variant(){return this._variant}set variant(next){next==="primary"?this._variant="brand":next==="default"||next==="text"?this._variant="neutral":this._variant=next,next==="text"&&(this.appearance="plain")}get caret(){return this.withCaret}set caret(next){this.withCaret=!!next}get type(){return this._type}set type(next){const old=this._type;this._type=BUTTON_TYPE.normalize(typeof next=="string"?next.toLowerCase():next),this.requestUpdate("type",old)}get value(){return this._value}set value(next){this._value=next??"",this.updateValidity()}get required(){return this._required}set required(next){this._required=!!next,this.updateValidity()}get resolvedRel(){return resolveGuardedRel(this.rel,this.target)}click(){this.effectiveDisabled||this.loading||this.baseEl?.click()}focus(options){!this.effectiveDisabled&&!this.loading&&this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}[(_a=FORM_CONTROL_LABEL_FACTORY,VALIDITY_ANCHOR)](){return this.baseEl??null}checkValidity(){return this.validityController.checkValidity()}reportValidity(){return this.validityController.syncConstraints(),this.internals.reportValidity()}setCustomValidity(message){const old=this.customValidityMessage||null,next=message??"";if(this.customValidityMessage=next,this.validityController.setCustomValidity(this.isValidationBarred?"":next),!this.reflectingCustomError){this.reflectingCustomError=!0;try{next?this.setAttribute("custom-error",next):this.removeAttribute("custom-error")}finally{this.reflectingCustomError=!1}}this.requestUpdate("customError",old)}resetValidity(){this.customValidityMessage="",this.validityController.setCustomValidity(""),this.updateValidity()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?state2:""}syncImplicitSubmission(form=this.getForm()){const next=this.type==="submit"&&this.isConnected?form:null;next!==this.implicitForm&&(this.implicitForm?.removeEventListener("keydown",this.onFormKeyDown),this.implicitForm=next,next?.addEventListener("keydown",this.onFormKeyDown))}formAssociatedCallback(form){this.syncImplicitSubmission(form)}runClickDefaultAction(){if(this.type==="submit"){const form=this.getForm();if(!form)return;this.hasSubmitterOverrides?this.submitAsNamedSubmitter(form):form.requestSubmit()}else this.type==="reset"&&this.getForm()?.reset()}get hasSubmitterOverrides(){return!!(this.name||this.value||this.formNoValidate)||this.formAction!==void 0||this.formEnctype!==void 0||this.formMethod!==void 0||this.formTarget!==void 0}submitAsNamedSubmitter(form){const submitter=this.ownerDocument.createElement("button");submitter.type="submit",submitter.hidden=!0,submitter.tabIndex=-1,this.name&&(submitter.name=this.name,submitter.value=this.value),this.formAction!==void 0&&submitter.setAttribute("formaction",this.formAction),this.formEnctype!==void 0&&submitter.setAttribute("formenctype",this.formEnctype),this.formMethod!==void 0&&submitter.setAttribute("formmethod",this.formMethod),this.formNoValidate&&(submitter.formNoValidate=!0),this.formTarget!==void 0&&submitter.setAttribute("formtarget",this.formTarget),this.parentElement&&this.closest("form")===form?this.insertAdjacentElement("afterend",submitter):form.append(submitter);try{form.requestSubmit(submitter)}finally{submitter.remove()}}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.updateValidity(),this.syncButtonStates(),this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements(),this.syncImplicitSubmission(),this.updateValidity(),this.syncButtonStates(),this.hasUpdated&&this.iconOnlyObserver.arm()}disconnectedCallback(){this.releaseExternalDescription(),this.syncImplicitSubmission(null),this.iconOnlyObserver.disarm(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed);const focusedControl=shadowFocusTarget(this);changed.has("loading")&&this.loading&&focusedControl!==null&&focusedControl===this.baseEl&&(this.hasAttribute("tabindex")||(this.tabIndex=-1,this.injectedHostTabIndex=!0),HTMLElement.prototype.focus.call(this,{preventScroll:!0})),this.hasUpdated||this.seedFirstRenderState(()=>{this.syncAdornmentSlots(),this.isIconButton=hasIconOnlyDefaultContent(this)})}syncAdornmentSlots(){const collection=this.children,children=collection?Array.from(collection):[];this.hasStartSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="start"||slot==="prefix"}),this.hasEndSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="end"||slot==="suffix"})}get labelGrows(){return this.withCaret||this.hasEndSlot||this.withEnd}updated(changed){if(super.updated(changed),changed.has("type")&&this.syncImplicitSubmission(),changed.has("loading")&&!this.loading&&this.injectedHostTabIndex){const parked=this.ownerDocument.activeElement===this&&!shadowFocusTarget(this);this.removeAttribute("tabindex"),this.injectedHostTabIndex=!1,parked&&this.baseEl?.focus({preventScroll:!0})}syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),this.iconOnlyObserver.arm(),this.updateValidity(),this.syncButtonStates()}updateValidity(){if(this.validityController){if(this.isValidationBarred){this.validityController.setCustomValidity(""),this.validityController.setValidity({});return}this.required&&!this.value?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.validityController.setCustomValidity(this.customValidityMessage)}}get isValidationBarred(){return this.effectiveDisabled||this.loading||this.baseEl?.localName==="a"}syncButtonStates(){this.internals&&(setCustomState(this.internals,"disabled",this.effectiveDisabled||this.loading),setCustomState(this.internals,"icon-button",this.isIconButton),setCustomState(this.internals,"link",this.baseEl?.localName==="a"),setCustomState(this.internals,"loading",this.loading))}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}render(){const pressed=this.pressed==="mixed"?"mixed":typeof this.pressed=="boolean"?String(this.pressed):["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,content=html`
2
2
  <span
3
3
  part="start prefix"
4
4
  ?hidden=${!(this.hasStartSlot||this.withStart)}
@@ -15,7 +15,7 @@ var _a;import{__decorate}from"tslib";import{FormControlController,reflectFormNam
15
15
  </span>
16
16
  ${this.withCaret?html`<span part="caret" aria-hidden="true">${chevronIcon()}</span>`:nothing}
17
17
  ${this.loading?html`<span part="spinner" aria-hidden="true">${spinnerIcon()}</span>`:""}
18
- `,hasDownload=this.download!==void 0,href=hasDownload?safeDownloadHref(this.href):safeLinkHref(this.href);if(href){const disabled=this.effectiveDisabled||this.loading;return html`<a
18
+ `,hasDownload=this.download!==void 0,href=hasDownload?safeDownloadHref(this.href):safeActionLinkHref(this.href);if(href){const disabled=this.effectiveDisabled||this.loading;return html`<a
19
19
  part="base button"
20
20
  ?data-icon-button=${this.isIconButton}
21
21
  ?data-grow-label=${this.labelGrows}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{acquireAriaDescription,acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./checkbox-group.styles.js";import{createStringArrayFormDataState,getFormOwner,isBarredFromValidation,readStringArrayFormDataState,setFormOwner}from"../../../internal/form-associated.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{LYRA_DEFAULT_checkboxGroupRequired}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();const DUPLICATE_VALUE_WARNING_KEY="lyra-checkbox-group-duplicate-child-values",DUPLICATE_VALUE_WARNING="<lr-checkbox-group>: duplicate child values make submitted FormData ambiguous; give each child a distinct value.";class LyraCheckboxGroup extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,checkboxGroupRequired:LYRA_DEFAULT_checkboxGroupRequired,fieldRequired:LYRA_DEFAULT_fieldRequired}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-checkbox-group-toggle-request"])}static{this.identityEventDetailProperties=Object.freeze({"lr-checkbox-group-toggle-request":Object.freeze(["option"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},size:{reflect:!0},orientation:{reflect:!0},value:{attribute:!1,noAccessor:!0}}}get hasLabelSlot(){return this.slotPresence.has("label")}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.sync(),this.requestUpdate("name",old)}get value(){return Object.freeze([...this._value])}set value(next){markVetoGuardWrite(this.toggleGuard);const requested=Array.isArray(next)?next.filter(entry=>typeof entry=="string"):[];if(this.boxes.length===0){this.pendingValues=requested;return}this.pendingValues=void 0,this.applyValues(requested)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.sync(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.propagateDisabled(),this.sync(),this.requestUpdate("disabled",old)}constructor(){super(),this.orientation="vertical",this.label="",this.hint="",this.withLabel=!1,this.withHint=!1,this.errorText="",this.accessibleLabel="",this.hasInteracted=!1,this.slotPresence=new SlotPresenceController(this),this.labelId=nextId("checkbox-group-label"),this.hintId=nextId("checkbox-group-hint"),this.errorId=nextId("checkbox-group-error"),this.requiredDescriptionId=nextId("checkbox-group-required"),this._fieldsetDisabled=!1,this._name="",this._required=!1,this._disabled=!1,this._value=[],this.childObserverGeneration=0,this.childControllers=new Map,this.toggleGuard=new VetoWriteGuard,this.authoredChildSizes=new Map,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.reflectValidityStates())},this.syncQueued=!1,this.suppressCheckboxSync=!1,this.onChildEvent=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),event.type!=="change"||this.effectiveDisabled))return;this.hasInteracted=!0,this.sync();const value=this.value,detail=()=>Object.freeze({value:Object.freeze([...value])});emitValueEvents(this,"input",detail(),detail2=>this.emit("lr-input",detail2)),emitValueEvents(this,"change",detail(),detail2=>this.emit("lr-change",detail2))},this.onChildToggleRequest=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),this.effectiveDisabled))return;const option=event.target,proposed=event.detail.checked;let allowed=!1;requestThenCommit({requestDetail:{value:this.projectedValue(option,proposed),previousValue:this.value,option},emitRequest:(detail,init)=>this.emit("lr-checkbox-group-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{allowed=!0}}),allowed||event.preventDefault()},this.onChildMutations=records=>{if(records.some(record=>record.type==="childList"||record.attributeName==="slot")){this.onSlotChange();return}for(const record of records){if(record.attributeName!=="size"||!this.isOwnedCheckbox(record.target))continue;const box=record.target;this.size!==void 0&&box.size!==this.size&&this.authoredChildSizes.set(box,box.size)}records.some(record=>record.attributeName==="size"&&this.isOwnedCheckbox(record.target))&&this.propagateSize(),records.some(record=>this.isOwnedCheckbox(record.target))&&this.sync()},this.onSlotChange=()=>{this.cachedBoxes=void 0,this.reconcileChildControllers(),!this.applyPendingRestore()&&!this.applyPendingValues()&&this.sync(),this.propagateDisabled(),this.propagateSize()},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals}checkboxGroupOwner(element){const group=element.closest(tag("checkbox-group"));if(!group)return null;let topLevelChild=element;for(;topLevelChild.parentElement&&topLevelChild.parentElement!==group;)topLevelChild=topLevelChild.parentElement;if(topLevelChild.parentElement!==group)return null;const slot=topLevelChild.getAttribute("slot");return slot==="label"||slot==="hint"||slot==="error"?null:group}ownsCheckbox(element){return element.localName===tag("checkbox")&&this.checkboxGroupOwner(element)===this}get boxes(){const querySelectorAll=this.querySelectorAll;return typeof querySelectorAll!="function"?[]:Array.from(querySelectorAll.call(this,"lr-checkbox")).filter(box=>this.ownsCheckbox(box))}syncBoxes(){return this.cachedBoxes||(this.cachedBoxes=this.boxes,queueMicrotask(()=>{this.cachedBoxes=void 0})),this.cachedBoxes}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}propagateDisabled(){const effective=this.effectiveDisabled;this.boxes.forEach(box=>box.setGroupDisabled?.(effective))}propagateSize(){for(const box of this.boxes)if(this.authoredChildSizes.has(box)||this.authoredChildSizes.set(box,box.size),this.size===void 0||this.size===null){const authored=this.authoredChildSizes.get(box);authored!==void 0&&box.size!==authored&&(box.size=authored),this.authoredChildSizes.delete(box)}else box.size!==this.size&&(box.size=this.size)}sync(){const next=[],seen=new Set;for(const box of this.syncBoxes()){const value=box.value??box.getAttribute("value")??"on";seen.has(value)&&devWarnOnce(DUPLICATE_VALUE_WARNING_KEY,DUPLICATE_VALUE_WARNING),seen.add(value),box.checked&&next.push(value)}const old=this._value;this._value=next,this.requestUpdate("value",old);const data=new FormData;this.name&&next.forEach(value=>data.append(this.name,value)),this.internals.setFormValue(this.name?data:null,createStringArrayFormDataState(this.name,next)),!this.barredFromValidation&&this.required&&next.length===0?this.validityController.setValidity({valueMissing:!0},this.localize("checkboxGroupRequired")):this.validityController.setValidity({}),this.reflectValidityStates()}scheduleSync(){this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.isConnected&&this.sync()}))}notifyCheckboxStateChange(checkbox){this.suppressCheckboxSync||this.isConnected&&this.ownsCheckbox(checkbox)&&this.sync()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}reflectValidityStates(){const barred=this.barredFromValidation;this.toggleAttribute("data-invalid",!barred&&this.hasInteracted&&!this.internals.validity.valid),syncValidityStates(this.internals,{required:this.required,hasInteracted:this.hasInteracted,barred})}isOwnedCheckbox(target){return target?.nodeType===1&&this.ownsCheckbox(target)}projectedValue(option,proposed){return Object.freeze(this.boxes.filter(box=>box===option?proposed:box.checked).map(box=>box.value??"on"))}reconcileChildControllers(){const current=new Set(this.boxes);for(const[box,controller]of this.childControllers){if(current.has(box))continue;box.removeController(controller),this.childControllers.delete(box);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize),this.authoredChildSizes.delete(box);const nextOwner=this.checkboxGroupOwner(box);(!nextOwner||nextOwner===this)&&box.setGroupDisabled?.(!1)}for(const box of current){if(this.childControllers.has(box)||typeof box.addController!="function")continue;const controller={hostUpdated:()=>{this.isConnected&&this.ownsCheckbox(box)&&this.scheduleSync()}};box.addController(controller),this.childControllers.set(box,controller)}}applyValues(values){const remaining=new Map;for(const value of values)remaining.set(value,(remaining.get(value)??0)+1);this.suppressCheckboxSync=!0;try{for(const box of this.boxes){const value=box.value??"on",count=remaining.get(value)??0;box.checked=count>0,count>0&&remaining.set(value,count-1)}}finally{this.suppressCheckboxSync=!1}this.sync()}applyPendingRestore(){if(this.pendingRestoreValues===void 0||this.boxes.length===0)return!1;const values=this.pendingRestoreValues;return this.pendingRestoreValues=void 0,this.hasInteracted=!1,this.applyValues(values),!0}applyPendingValues(){if(this.pendingValues===void 0||this.boxes.length===0)return!1;const values=this.pendingValues;return this.pendingValues=void 0,this.applyValues(values),!0}connectedCallback(){super.connectedCallback(),this.cachedBoxes=void 0,this.addEventListener("input",this.onChildEvent,{capture:!0}),this.addEventListener("lr-input",this.onChildEvent,{capture:!0}),this.addEventListener("change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.hasUpdated?this.onSlotChange():(this.reconcileChildControllers(),!this.applyPendingRestore()&&!this.applyPendingValues()&&this.sync(),this.propagateDisabled(),this.propagateSize()),this.armChildObserver(),this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}armChildObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.childObserver&&this.childObserverDocument===ownerDocument)return;this.resetChildObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.childObserverGeneration,observer=new MutationObserverCtor(records=>{this.childObserver!==observer||this.childObserverDocument!==ownerDocument||this.childObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onChildMutations(records)});this.childObserver=observer,this.childObserverDocument=ownerDocument,observer.observe(this,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["checked","value","disabled","size","slot"]})}disconnectedCallback(){this.releaseExternalDescription(),this.releaseRequiredDescription(),this.cachedBoxes=void 0,this.removeEventListener("input",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-input",this.onChildEvent,{capture:!0}),this.removeEventListener("change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.resetChildObserver();for(const[box,controller]of this.childControllers){box.removeController(controller),box.setGroupDisabled?.(!1);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize)}this.childControllers.clear(),this.authoredChildSizes.clear(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.releaseRequiredDescription(),this.resetChildObserver(),this.isConnected&&this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}resetChildObserver(){this.childObserverGeneration+=1,this.childObserver?.disconnect(),this.childObserver=void 0,this.childObserverDocument=void 0}firstUpdated(changed){super.firstUpdated(changed),this.addEventListener("blur",event=>{const blurredControl=event.target;(typeof blurredControl?.matches=="function"?blurredControl.matches(":disabled"):this.effectiveDisabled)||(this.hasInteracted=!0),this.sync()},!0)}updated(changed){super.updated(changed),changed.has("size")&&this.propagateSize(),this.syncRequiredDescription(),this.syncExternalDescription()}syncExternalDescription(){const target=this.renderRoot.querySelector("fieldset");if(!target){this.releaseExternalDescription();return}if(!this.externalDescriptionLease){this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby");return}this.externalDescriptionLease.update(target)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}syncRequiredDescription(){const target=this.renderRoot.querySelector("fieldset"),description=this.renderRoot.querySelector(`#${this.requiredDescriptionId}`);if(!this.required||!target||!description){this.releaseRequiredDescription();return}if(this.requiredDescriptionTarget!==target){this.releaseRequiredDescription(),this.requiredDescriptionTarget=target,this.requiredDescriptionLease=acquireAriaDescription(target,[description]);return}this.requiredDescriptionLease?.update([description])}releaseRequiredDescription(){this.requiredDescriptionLease?.release(),this.requiredDescriptionLease=void 0,this.requiredDescriptionTarget=void 0}[VALIDITY_ANCHOR](){const first=this.firstEnabledBox();return resolveValidityAnchor(first)??first??null}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}checkValidity(){return this.validityController.checkValidity()}reportValidity(){return this.validityController.syncConstraints(),this.hasInteracted=!0,this.reflectValidityStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.reflectValidityStates(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}firstEnabledBox(){return this.boxes.find(box=>!box.effectiveDisabled&&!box.matches(":disabled"))}focus(options){this.liveDisabled||this.firstEnabledBox()?.focus(options)}blur(){this.boxes.find(box=>box.matches(":focus-within"))?.blur()}click(){this.liveDisabled||this.firstEnabledBox()?.click()}formResetCallback(){this.suppressCheckboxSync=!0;try{this.boxes.forEach(box=>box.resetFromGroup())}finally{this.suppressCheckboxSync=!1}this.hasInteracted=!1,this.sync()}formStateRestoreCallback(state2,_mode){this.pendingRestoreValues=readStringArrayFormDataState(state2),this.applyPendingRestore()}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.propagateDisabled(),this.sync(),this.requestUpdate())}render(){const hasLabel=this.hasLabelSlot||!!this.label||this.withLabel,hasHint=this.hasHintSlot||!!this.hint||this.withHint,hasError=this.hasErrorSlot||!!this.errorText,described=[hasHint?this.hintId:"",hasError?this.errorId:""].filter(Boolean).join(" ")||nothing,invalid=hasError||this.hasInteracted&&!this.internals.validity.valid;return html`<fieldset
1
+ import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{acquireAriaDescription,acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./checkbox-group.styles.js";import{createStringArrayFormDataState,getFormOwner,isBarredFromValidation,readStringArrayFormDataState,setFormOwner}from"../../../internal/form-associated.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{LYRA_DEFAULT_checkboxGroupRequired}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();const DUPLICATE_VALUE_WARNING_KEY="lyra-checkbox-group-duplicate-child-values",DUPLICATE_VALUE_WARNING="<lr-checkbox-group>: duplicate child values make submitted FormData ambiguous; give each child a distinct value.";class LyraCheckboxGroup extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,checkboxGroupRequired:LYRA_DEFAULT_checkboxGroupRequired,fieldRequired:LYRA_DEFAULT_fieldRequired}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-checkbox-group-toggle-request"])}static{this.identityEventDetailProperties=Object.freeze({"lr-checkbox-group-toggle-request":Object.freeze(["option"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},size:{reflect:!0},orientation:{reflect:!0},value:{attribute:!1,noAccessor:!0}}}get hasLabelSlot(){return this.slotPresence.has("label")}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.sync(),this.requestUpdate("name",old)}get value(){return Object.freeze([...this._value])}set value(next){markVetoGuardWrite(this.toggleGuard);const requested=Array.isArray(next)?next.filter(entry=>typeof entry=="string"):[];if(this.boxes.length===0){this.pendingValues=requested;return}this.pendingValues=void 0,this.applyValues(requested)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.sync(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.propagateDisabled(),this.sync(),this.requestUpdate("disabled",old)}constructor(){super(),this.orientation="vertical",this.label="",this.hint="",this.withLabel=!1,this.withHint=!1,this.errorText="",this.accessibleLabel="",this.hasInteracted=!1,this.slotPresence=new SlotPresenceController(this),this.labelId=nextId("checkbox-group-label"),this.hintId=nextId("checkbox-group-hint"),this.errorId=nextId("checkbox-group-error"),this.requiredDescriptionId=nextId("checkbox-group-required"),this._fieldsetDisabled=!1,this._name="",this._required=!1,this._disabled=!1,this._value=[],this.childObserverGeneration=0,this.childControllers=new Map,this.toggleGuard=new VetoWriteGuard,this.authoredChildSizes=new Map,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.reflectValidityStates())},this.syncQueued=!1,this.suppressCheckboxSync=!1,this.onChildEvent=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),event.type!=="change"||this.effectiveDisabled))return;this.hasInteracted=!0,this.sync();const value=this.value,detail=()=>Object.freeze({value:Object.freeze([...value])});emitValueEvents(this,"input",detail(),detail2=>this.emit("lr-input",detail2)),emitValueEvents(this,"change",detail(),detail2=>this.emit("lr-change",detail2))},this.onChildToggleRequest=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),this.effectiveDisabled))return;const option=event.target,proposed=event.detail.checked;let allowed=!1;requestThenCommit({requestDetail:{value:this.projectedValue(option,proposed),previousValue:this.value,option},emitRequest:(detail,init)=>this.emit("lr-checkbox-group-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{allowed=!0}}),allowed||event.preventDefault()},this.onChildMutations=records=>{if(records.some(record=>record.type==="childList"||record.attributeName==="slot")){this.onSlotChange();return}for(const record of records){if(record.attributeName!=="size"||!this.isOwnedCheckbox(record.target))continue;const box=record.target;this.size!==void 0&&box.size!==this.size&&this.authoredChildSizes.set(box,box.size)}records.some(record=>record.attributeName==="size"&&this.isOwnedCheckbox(record.target))&&this.propagateSize(),records.some(record=>this.isOwnedCheckbox(record.target))&&this.sync()},this.onSlotChange=()=>{this.cachedBoxes=void 0,this.reconcileChildControllers(),!this.applyPendingRestore()&&!this.applyPendingValues()&&this.sync(),this.propagateDisabled(),this.propagateSize()},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals}checkboxGroupOwner(element){const group=element.closest(tag("checkbox-group"));if(!group)return null;let topLevelChild=element;for(;topLevelChild.parentElement&&topLevelChild.parentElement!==group;)topLevelChild=topLevelChild.parentElement;if(topLevelChild.parentElement!==group)return null;const slot=topLevelChild.getAttribute("slot");return slot==="label"||slot==="hint"||slot==="error"?null:group}ownsCheckbox(element){return element.localName===tag("checkbox")&&this.checkboxGroupOwner(element)===this}get boxes(){const querySelectorAll=this.querySelectorAll;return typeof querySelectorAll!="function"?[]:Array.from(querySelectorAll.call(this,"lr-checkbox")).filter(box=>this.ownsCheckbox(box))}syncBoxes(){return this.cachedBoxes||(this.cachedBoxes=this.boxes,queueMicrotask(()=>{this.cachedBoxes=void 0})),this.cachedBoxes}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}propagateDisabled(){const effective=this.effectiveDisabled;this.boxes.forEach(box=>box.setGroupDisabled?.(effective))}propagateSize(){for(const box of this.boxes)if(this.authoredChildSizes.has(box)||this.authoredChildSizes.set(box,box.size),this.size===void 0||this.size===null){const authored=this.authoredChildSizes.get(box);authored!==void 0&&box.size!==authored&&(box.size=authored),this.authoredChildSizes.delete(box)}else box.size!==this.size&&(box.size=this.size)}sync(){const next=[],seen=new Set;for(const box of this.syncBoxes()){const value=box.value??box.getAttribute("value")??"on";seen.has(value)&&devWarnOnce(DUPLICATE_VALUE_WARNING_KEY,DUPLICATE_VALUE_WARNING),seen.add(value),box.checked&&next.push(value)}const old=this._value;this._value=next,this.requestUpdate("value",old);const data=new FormData;this.name&&next.forEach(value=>data.append(this.name,value)),this.internals.setFormValue(this.name?data:null,createStringArrayFormDataState(this.name,next)),!this.barredFromValidation&&this.required&&next.length===0?this.validityController.setValidity({valueMissing:!0},this.localize("checkboxGroupRequired")):this.validityController.setValidity({}),this.reflectValidityStates()}scheduleSync(){this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.isConnected&&this.sync()}))}notifyCheckboxStateChange(checkbox){this.suppressCheckboxSync||this.isConnected&&this.ownsCheckbox(checkbox)&&this.sync()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}reflectValidityStates(){const barred=this.barredFromValidation;this.toggleAttribute("data-invalid",!barred&&this.hasInteracted&&!this.internals.validity.valid),syncValidityStates(this.internals,{required:this.required,hasInteracted:this.hasInteracted,barred})}isOwnedCheckbox(target){return target?.nodeType===1&&this.ownsCheckbox(target)}projectedValue(option,proposed){return Object.freeze(this.boxes.filter(box=>box===option?proposed:box.checked).map(box=>box.value??"on"))}reconcileChildControllers(){const current=new Set(this.boxes);for(const[box,controller]of this.childControllers){if(current.has(box))continue;box.removeController(controller),this.childControllers.delete(box);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize),this.authoredChildSizes.delete(box);const nextOwner=this.checkboxGroupOwner(box);(!nextOwner||nextOwner===this)&&box.setGroupDisabled?.(!1)}for(const box of current){if(this.childControllers.has(box)||typeof box.addController!="function")continue;const controller={hostUpdated:()=>{this.isConnected&&this.ownsCheckbox(box)&&this.scheduleSync()}};box.addController(controller),this.childControllers.set(box,controller)}}applyValues(values){const remaining=new Map;for(const value of values)remaining.set(value,(remaining.get(value)??0)+1);this.suppressCheckboxSync=!0;try{for(const box of this.boxes){const value=box.value??"on",count=remaining.get(value)??0;box.checked=count>0,count>0&&remaining.set(value,count-1)}}finally{this.suppressCheckboxSync=!1}this.sync()}applyPendingRestore(){if(this.pendingRestoreValues===void 0||this.boxes.length===0)return!1;const values=this.pendingRestoreValues;return this.pendingRestoreValues=void 0,this.hasInteracted=!1,this.applyValues(values),!0}applyPendingValues(){if(this.pendingValues===void 0||this.boxes.length===0)return!1;const values=this.pendingValues;return this.pendingValues=void 0,this.applyValues(values),!0}connectedCallback(){super.connectedCallback(),this.cachedBoxes=void 0,this.addEventListener("input",this.onChildEvent,{capture:!0}),this.addEventListener("lr-input",this.onChildEvent,{capture:!0}),this.addEventListener("change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.hasUpdated?this.onSlotChange():(this.reconcileChildControllers(),!this.applyPendingRestore()&&!this.applyPendingValues()&&this.sync(),this.propagateDisabled(),this.propagateSize()),this.armChildObserver(),this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}armChildObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.childObserver&&this.childObserverDocument===ownerDocument)return;this.resetChildObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.childObserverGeneration,observer=new MutationObserverCtor(records=>{this.childObserver!==observer||this.childObserverDocument!==ownerDocument||this.childObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onChildMutations(records)});this.childObserver=observer,this.childObserverDocument=ownerDocument,observer.observe(this,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["checked","value","disabled","size","slot"]})}disconnectedCallback(){this.releaseExternalDescription(),this.releaseRequiredDescription(),this.cachedBoxes=void 0,this.removeEventListener("input",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-input",this.onChildEvent,{capture:!0}),this.removeEventListener("change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.resetChildObserver();for(const[box,controller]of this.childControllers){box.removeController(controller),box.setGroupDisabled?.(!1);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize)}this.childControllers.clear(),this.authoredChildSizes.clear(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.releaseRequiredDescription(),this.resetChildObserver(),this.isConnected&&this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}resetChildObserver(){this.childObserverGeneration+=1,this.childObserver?.disconnect(),this.childObserver=void 0,this.childObserverDocument=void 0}firstUpdated(changed){super.firstUpdated(changed),this.addEventListener("blur",event=>{const blurredControl=event.target;(typeof blurredControl?.matches=="function"?blurredControl.matches(":disabled"):this.effectiveDisabled)||(this.hasInteracted=!0),this.sync()},!0)}updated(changed){super.updated(changed),changed.has("size")&&this.propagateSize(),this.syncRequiredDescription(),this.syncExternalDescription()}syncExternalDescription(){const target=this.isConnected?this.renderRoot.querySelector("fieldset"):null;if(!target){this.releaseExternalDescription();return}if(!this.externalDescriptionLease){this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby");return}this.externalDescriptionLease.update(target)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}syncRequiredDescription(){const target=this.isConnected?this.renderRoot.querySelector("fieldset"):null,description=this.renderRoot.querySelector(`#${this.requiredDescriptionId}`);if(!this.required||!target||!description){this.releaseRequiredDescription();return}if(this.requiredDescriptionTarget!==target){this.releaseRequiredDescription(),this.requiredDescriptionTarget=target,this.requiredDescriptionLease=acquireAriaDescription(target,[description]);return}this.requiredDescriptionLease?.update([description])}releaseRequiredDescription(){this.requiredDescriptionLease?.release(),this.requiredDescriptionLease=void 0,this.requiredDescriptionTarget=void 0}[VALIDITY_ANCHOR](){const first=this.firstEnabledBox();return resolveValidityAnchor(first)??first??null}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}checkValidity(){return this.validityController.checkValidity()}reportValidity(){return this.validityController.syncConstraints(),this.hasInteracted=!0,this.reflectValidityStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.reflectValidityStates(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}firstEnabledBox(){return this.boxes.find(box=>!box.effectiveDisabled&&!box.matches(":disabled"))}focus(options){this.liveDisabled||this.firstEnabledBox()?.focus(options)}blur(){this.boxes.find(box=>box.matches(":focus-within"))?.blur()}click(){this.liveDisabled||this.firstEnabledBox()?.click()}formResetCallback(){this.suppressCheckboxSync=!0;try{this.boxes.forEach(box=>box.resetFromGroup())}finally{this.suppressCheckboxSync=!1}this.hasInteracted=!1,this.sync()}formStateRestoreCallback(state2,_mode){this.pendingRestoreValues=readStringArrayFormDataState(state2),this.applyPendingRestore()}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.propagateDisabled(),this.sync(),this.requestUpdate())}render(){const hasLabel=this.hasLabelSlot||!!this.label||this.withLabel,hasHint=this.hasHintSlot||!!this.hint||this.withHint,hasError=this.hasErrorSlot||!!this.errorText,described=[hasHint?this.hintId:"",hasError?this.errorId:""].filter(Boolean).join(" ")||nothing,invalid=hasError||this.hasInteracted&&!this.internals.validity.valid;return html`<fieldset
2
2
  part="form-control"
3
3
  ?disabled=${this.effectiveDisabled}
4
4
  aria-label=${hostAriaLabel(this)??nothing}
@@ -1 +1 @@
1
- import{finiteRange}from"../../../internal/numbers.js";const CSS_WIDE_KEYWORDS=/^(?:inherit|initial|unset|revert|revert-layer|currentcolor)$/i,HEX_PATTERN=/^#([0-9a-f]+)$/i,FUNCTION_PATTERN=/^([a-z]+)\(([^()]*)\)$/i,NUMBER_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(%?)$/,ANGLE_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(deg|grad|rad|turn)?$/i,clamp=(value,min,max)=>finiteRange(value,min,min,max);function normalizeHue(hue){if(!Number.isFinite(hue))return 0;if(hue===360)return 360;const wrapped=hue%360;return wrapped<0?wrapped+360:wrapped}function hsva(h,s,v,a=1){return{h:normalizeHue(h),s:clamp(s,0,100),v:clamp(v,0,100),a:clamp(a,0,1)}}function hsvToRgb(h,s,v){const sector=normalizeHue(h)/60,saturation=clamp(s,0,100)/100,value=clamp(v,0,100)/100,chroma=value*saturation,secondary=chroma*(1-Math.abs(sector%2-1)),base=value-chroma;let r=0,g=0,b=0;return sector<1?[r,g,b]=[chroma,secondary,0]:sector<2?[r,g,b]=[secondary,chroma,0]:sector<3?[r,g,b]=[0,chroma,secondary]:sector<4?[r,g,b]=[0,secondary,chroma]:sector<5?[r,g,b]=[secondary,0,chroma]:[r,g,b]=[chroma,0,secondary],{r:(r+base)*255,g:(g+base)*255,b:(b+base)*255}}function rgbToHsv(r,g,b){const red=clamp(r,0,255)/255,green=clamp(g,0,255)/255,blue=clamp(b,0,255)/255,max=Math.max(red,green,blue),min=Math.min(red,green,blue),chroma=max-min;let hue=0;return chroma!==0&&(max===red?hue=60*((green-blue)/chroma%6):max===green?hue=60*((blue-red)/chroma+2):hue=60*((red-green)/chroma+4)),{h:normalizeHue(hue),s:max===0?0:chroma/max*100,v:max*100}}function hsvToHsl(h,s,v){const value=clamp(v,0,100)/100,saturation=clamp(s,0,100)/100,lightness=value*(1-saturation/2),denominator=Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:denominator===0?0:(value-lightness)/denominator*100,l:lightness*100}}function hslToHsv(h,s,l){const lightness=clamp(l,0,100)/100,saturation=clamp(s,0,100)/100,value=lightness+saturation*Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:value===0?0:2*(1-lightness/value)*100,v:value*100}}function parseNumber(text,percentBase){if(text===void 0)return null;const match=NUMBER_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);return Number.isFinite(raw)?match[2]==="%"?raw/100*percentBase:raw:null}function parseAngle(text){if(text===void 0)return null;const match=ANGLE_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);if(!Number.isFinite(raw))return null;switch((match[2]??"deg").toLowerCase()){case"grad":return raw*360/400;case"rad":return raw*180/Math.PI;case"turn":return raw*360;default:return raw}}function splitArguments(body){const[head="",tail]=body.split("/"),channels=head.split(/[,\s]+/).map(entry=>entry.trim()).filter(Boolean);return tail!==void 0?{channels,alpha:tail.trim()}:channels.length===4?{channels:channels.slice(0,3),alpha:channels[3]}:{channels}}function parseHex(text){const match=HEX_PATTERN.exec(text);if(!match)return null;const digits=match[1],short=digits.length===3||digits.length===4,long=digits.length===6||digits.length===8;if(!short&&!long)return null;const size=short?1:2,channel=index=>{const slice=digits.slice(index*size,index*size+size);return Number.parseInt(short?slice+slice:slice,16)},hasAlpha=digits.length===4||digits.length===8,{h,s,v}=rgbToHsv(channel(0),channel(1),channel(2));return hsva(h,s,v,hasAlpha?channel(3)/255:1)}const float32=Math.fround,BROWSER_ROUNDING_EPSILON=float32(1e-7),BYTE_MARGIN=1e-9;function browserHslBytes(hue,saturation,lightness){const h=float32(normalizeHue(hue)),s=float32(clamp(saturation,0,100)/100),l=float32(clamp(lightness,0,100)/100),channel=offset=>{let value=l;if(s!==0){const k=float32(offset+float32(h/30))%12,a=float32(s*Math.min(l,float32(1-l))),t=Math.max(-1,Math.min(float32(k-3),float32(9-k),1));value=float32(l-float32(a*t))}return Math.round(clamp(float32(float32(value+BROWSER_ROUNDING_EPSILON)*255),0,255))};return[channel(0),channel(8),channel(4)]}function settleOnBytes(color,bytes){const{r,g,b}=hsvToRgb(color.h,color.s,color.v),channels=[r,g,b];if(channels.every((channel,index)=>Math.round(channel)===bytes[index]))return color;const[red=0,green=0,blue=0]=channels.map((channel,index)=>{const byte=bytes[index]??0;return clamp(channel,byte-.5+BYTE_MARGIN,byte+.5-BYTE_MARGIN)}),settled=rgbToHsv(red,green,blue),keepHue=settled.s===0||settled.h===0&&color.h===360;return hsva(keepHue?color.h:settled.h,settled.s,settled.v,color.a)}function parseFunctional(text){const match=FUNCTION_PATTERN.exec(text);if(!match)return null;const name=match[1].toLowerCase(),{channels,alpha}=splitArguments(match[2]??"");if(channels.length!==3)return null;const alphaValue=alpha===void 0?1:parseNumber(alpha,1);if(alphaValue===null)return null;if(name==="rgb"||name==="rgba"){const r=parseNumber(channels[0],255),g=parseNumber(channels[1],255),b=parseNumber(channels[2],255);if(r===null||g===null||b===null)return null;const converted=rgbToHsv(r,g,b);return hsva(converted.h,converted.s,converted.v,alphaValue)}if(name==="hsl"||name==="hsla"||name==="hsv"||name==="hsva"){const h=parseAngle(channels[0]),second=parseNumber(channels[1],100),third=parseNumber(channels[2],100);if(h===null||second===null||third===null)return null;if(name.startsWith("hsv"))return hsva(h,second,third,alphaValue);const converted=hslToHsv(h,second,third);return settleOnBytes(hsva(converted.h,converted.s,converted.v,alphaValue),browserHslBytes(h,second,third))}return null}function parseViaCssom(text){if(typeof document>"u"||CSS_WIDE_KEYWORDS.test(text))return null;const cached=cssomCache.get(text);if(cached!==void 0)return cached;const resolved=resolveViaCssom(text);return cssomCache.size>=CSSOM_CACHE_LIMIT&&cssomCache.clear(),cssomCache.set(text,resolved),resolved}const CSSOM_CACHE_LIMIT=64,cssomCache=new Map;function resolveViaCssom(text){const probe=document.createElement("span");if(probe.style.color=text,probe.style.color==="")return null;probe.style.position="absolute",probe.style.visibility="hidden",probe.style.pointerEvents="none",document.body.append(probe);const computed=getComputedStyle(probe).color;probe.remove();const serialized=computed.trim(),functional=parseFunctional(serialized);if(functional)return functional;const canvas=document.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=serialized,context.fillRect(0,0,1,1);const[red=0,green=0,blue=0,alpha=0]=context.getImageData(0,0,1,1).data,converted=rgbToHsv(red,green,blue);return hsva(converted.h,converted.s,converted.v,alpha/255)}function parseColor(input){const text=(input??"").trim();return text===""?null:parseHex(text)??parseFunctional(text)??parseViaCssom(text)}const hexByte=channel=>Math.round(clamp(channel,0,255)).toString(16).padStart(2,"0"),round=value=>String(Math.round(value)),alphaText=alpha=>clamp(alpha,0,1).toFixed(2);function formatColor(color,format,uppercase=!1){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);let text;switch(format){case"hex":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}`;break;case"hexa":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}${hexByte(color.a*255)}`;break;case"rgb":text=`rgb(${round(r)}, ${round(g)}, ${round(b)})`;break;case"rgba":text=`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`;break;case"hsv":text=`hsv(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%)`;break;case"hsva":text=`hsva(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%, ${alphaText(color.a)})`;break;default:{const hsl=hsvToHsl(color.h,color.s,color.v);text=format==="hsla"?`hsla(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%, ${alphaText(color.a)})`:`hsl(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%)`;break}}return uppercase?text.toUpperCase():text}function withAlphaFormat(format,includeAlpha){return includeAlpha?`${format}a`:format}function cssColor(color){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);return`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`}function sameColor(left,right){return formatColor(left,"hexa")===formatColor(right,"hexa")}export{cssColor,formatColor,hslToHsv,hsvToHsl,hsvToRgb,hsva,parseColor,rgbToHsv,sameColor,withAlphaFormat};
1
+ import{finiteRange}from"../../../internal/numbers.js";const CSS_WIDE_KEYWORDS=/^(?:inherit|initial|unset|revert|revert-layer|currentcolor)$/i,HEX_PATTERN=/^#([0-9a-f]+)$/i,FUNCTION_PATTERN=/^([a-z]+)\(([^()]*)\)$/i,NUMBER_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(%?)$/,ANGLE_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(deg|grad|rad|turn)?$/i,clamp=(value,min,max)=>finiteRange(value,min,min,max);function normalizeHue(hue){if(!Number.isFinite(hue))return 0;if(hue===360)return 360;const wrapped=hue%360;return wrapped<0?wrapped+360:wrapped}function hsva(h,s,v,a=1){return{h:normalizeHue(h),s:clamp(s,0,100),v:clamp(v,0,100),a:clamp(a,0,1)}}function hsvToRgb(h,s,v){const sector=normalizeHue(h)/60,saturation=clamp(s,0,100)/100,value=clamp(v,0,100)/100,chroma=value*saturation,secondary=chroma*(1-Math.abs(sector%2-1)),base=value-chroma;let r=0,g=0,b=0;return sector<1?[r,g,b]=[chroma,secondary,0]:sector<2?[r,g,b]=[secondary,chroma,0]:sector<3?[r,g,b]=[0,chroma,secondary]:sector<4?[r,g,b]=[0,secondary,chroma]:sector<5?[r,g,b]=[secondary,0,chroma]:[r,g,b]=[chroma,0,secondary],{r:(r+base)*255,g:(g+base)*255,b:(b+base)*255}}function rgbToHsv(r,g,b){const red=clamp(r,0,255)/255,green=clamp(g,0,255)/255,blue=clamp(b,0,255)/255,max=Math.max(red,green,blue),min=Math.min(red,green,blue),chroma=max-min;let hue=0;return chroma!==0&&(max===red?hue=60*((green-blue)/chroma%6):max===green?hue=60*((blue-red)/chroma+2):hue=60*((red-green)/chroma+4)),{h:normalizeHue(hue),s:max===0?0:chroma/max*100,v:max*100}}function hsvToHsl(h,s,v){const value=clamp(v,0,100)/100,saturation=clamp(s,0,100)/100,lightness=value*(1-saturation/2),denominator=Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:denominator===0?0:(value-lightness)/denominator*100,l:lightness*100}}function hslToHsv(h,s,l){const lightness=clamp(l,0,100)/100,saturation=clamp(s,0,100)/100,value=lightness+saturation*Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:value===0?0:2*(1-lightness/value)*100,v:value*100}}function parseNumber(text,percentBase){if(text===void 0)return null;const match=NUMBER_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);return Number.isFinite(raw)?match[2]==="%"?clamp(raw,0,100)/100*percentBase:raw:null}function parseAngle(text){if(text===void 0)return null;const match=ANGLE_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);if(!Number.isFinite(raw))return null;switch((match[2]??"deg").toLowerCase()){case"grad":return raw*360/400;case"rad":return raw*180/Math.PI;case"turn":return raw*360;default:return raw}}function splitArguments(body){const[head="",tail]=body.split("/"),channels=head.split(/[,\s]+/).map(entry=>entry.trim()).filter(Boolean);return tail!==void 0?{channels,alpha:tail.trim()}:channels.length===4?{channels:channels.slice(0,3),alpha:channels[3]}:{channels}}function parseHex(text){const match=HEX_PATTERN.exec(text);if(!match)return null;const digits=match[1],short=digits.length===3||digits.length===4,long=digits.length===6||digits.length===8;if(!short&&!long)return null;const size=short?1:2,channel=index=>{const slice=digits.slice(index*size,index*size+size);return Number.parseInt(short?slice+slice:slice,16)},hasAlpha=digits.length===4||digits.length===8,{h,s,v}=rgbToHsv(channel(0),channel(1),channel(2));return hsva(h,s,v,hasAlpha?channel(3)/255:1)}const float32=Math.fround,BROWSER_ROUNDING_EPSILON=float32(1e-7),BYTE_MARGIN=1e-9;function browserHslBytes(hue,saturation,lightness){const h=float32(normalizeHue(hue)),s=float32(clamp(saturation,0,100)/100),l=float32(clamp(lightness,0,100)/100),channel=offset=>{let value=l;if(s!==0){const k=float32(offset+float32(h/30))%12,a=float32(s*Math.min(l,float32(1-l))),t=Math.max(-1,Math.min(float32(k-3),float32(9-k),1));value=float32(l-float32(a*t))}return Math.round(clamp(float32(float32(value+BROWSER_ROUNDING_EPSILON)*255),0,255))};return[channel(0),channel(8),channel(4)]}function settleOnBytes(color,bytes){const{r,g,b}=hsvToRgb(color.h,color.s,color.v),channels=[r,g,b];if(channels.every((channel,index)=>Math.round(channel)===bytes[index]))return color;const[red=0,green=0,blue=0]=channels.map((channel,index)=>{const byte=bytes[index]??0;return clamp(channel,byte-.5+BYTE_MARGIN,byte+.5-BYTE_MARGIN)}),settled=rgbToHsv(red,green,blue),keepHue=settled.s===0||settled.h===0&&color.h===360;return hsva(keepHue?color.h:settled.h,settled.s,settled.v,color.a)}function parseFunctional(text){const match=FUNCTION_PATTERN.exec(text);if(!match)return null;const name=match[1].toLowerCase(),{channels,alpha}=splitArguments(match[2]??"");if(channels.length!==3)return null;const alphaValue=alpha===void 0?1:parseNumber(alpha,1);if(alphaValue===null)return null;if(name==="rgb"||name==="rgba"){const r=parseNumber(channels[0],255),g=parseNumber(channels[1],255),b=parseNumber(channels[2],255);if(r===null||g===null||b===null)return null;const converted=rgbToHsv(r,g,b);return hsva(converted.h,converted.s,converted.v,alphaValue)}if(name==="hsl"||name==="hsla"||name==="hsv"||name==="hsva"){const h=parseAngle(channels[0]),second=parseNumber(channels[1],100),third=parseNumber(channels[2],100);if(h===null||second===null||third===null)return null;if(name.startsWith("hsv"))return hsva(h,second,third,alphaValue);const converted=hslToHsv(h,second,third);return settleOnBytes(hsva(converted.h,converted.s,converted.v,alphaValue),browserHslBytes(h,second,third))}return null}function parseViaCssom(text){if(typeof document>"u"||CSS_WIDE_KEYWORDS.test(text))return null;const cached=cssomCache.get(text);if(cached!==void 0)return cached;const resolved=resolveViaCssom(text);return cssomCache.size>=CSSOM_CACHE_LIMIT&&cssomCache.clear(),cssomCache.set(text,resolved),resolved}const CSSOM_CACHE_LIMIT=64,cssomCache=new Map;function resolveViaCssom(text){const probe=document.createElement("span");if(probe.style.color=text,probe.style.color==="")return null;probe.style.position="absolute",probe.style.visibility="hidden",probe.style.pointerEvents="none",document.body.append(probe);const computed=getComputedStyle(probe).color;probe.remove();const serialized=computed.trim(),functional=parseFunctional(serialized);if(functional)return functional;const canvas=document.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=serialized,context.fillRect(0,0,1,1);const[red=0,green=0,blue=0,alpha=0]=context.getImageData(0,0,1,1).data,converted=rgbToHsv(red,green,blue);return hsva(converted.h,converted.s,converted.v,alpha/255)}function parseColor(input){const text=(input??"").trim();return text===""?null:parseHex(text)??parseFunctional(text)??parseViaCssom(text)}const hexByte=channel=>Math.round(clamp(channel,0,255)).toString(16).padStart(2,"0"),round=value=>String(Math.round(value)),alphaText=alpha=>clamp(alpha,0,1).toFixed(2);function formatColor(color,format,uppercase=!1){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);let text;switch(format){case"hex":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}`;break;case"hexa":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}${hexByte(color.a*255)}`;break;case"rgb":text=`rgb(${round(r)}, ${round(g)}, ${round(b)})`;break;case"rgba":text=`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`;break;case"hsv":text=`hsv(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%)`;break;case"hsva":text=`hsva(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%, ${alphaText(color.a)})`;break;default:{const hsl=hsvToHsl(color.h,color.s,color.v);text=format==="hsla"?`hsla(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%, ${alphaText(color.a)})`:`hsl(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%)`;break}}return uppercase?text.toUpperCase():text}function withAlphaFormat(format,includeAlpha){return includeAlpha?`${format}a`:format}function cssColor(color){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);return`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`}function sameColor(left,right){return formatColor(left,"hexa")===formatColor(right,"hexa")}export{cssColor,formatColor,hslToHsv,hsvToHsl,hsvToRgb,hsva,parseColor,rgbToHsv,sameColor,withAlphaFormat};
@@ -274,7 +274,7 @@ resetValidity():void;private setTypedBadInput;private parseStrictISO;private nor
274
274
  /** Open the calendar popover, unless the cancelable `lr-show` request is vetoed.*/
275
275
  show():Promise<void>;
276
276
  /** Close the calendar popover, unless the cancelable `lr-hide` request is vetoed.*/
277
- hide(restoreFocus?:boolean):Promise<void>;private forceClose;private onDocPointer;private reconnectOpenPopup;private settleTransition;connectedCallback():void;private daySlotNames;private observeDaySlots;private onClearClick;
277
+ hide(restoreFocus?:boolean):Promise<void>;private forceClose;private onDocPointer;private reconnectOpenPopup;private watchPopupPlacement;private settleTransition;connectedCallback():void;private daySlotNames;private observeDaySlots;private onClearClick;
278
278
  /** Clear the value (`input`, `change`, `lr-clear`); inert while blank, disabled or readonly.*/
279
279
  clear():void;private syncInteractionListeners;private syncValidatorAttributeObserver;private disconnectValidatorAttributeObserver;private syncCustomStates;disconnectedCallback():void;adoptedCallback():void;private syncExternalDescription;protected updated(changed:PropertyValues):void;private commitTypedValue;private applyTypedText;private onInputChange;private commitInputChange;private onInput;private numericDate;private parseOneDate;private parseSingleText;private localizedRangeSeparator;private parseRangeText;private onInputKey;private onInputBlur;private onInputFocus;
280
280
  /** Activate the internal date text input unless the form control is effectively disabled.*/
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{nativeAutocorrectAttribute,setNativeRangeText}from"../../../internal/native-text-control.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{observeReactivePropertyWrites}from"../../../internal/reactive-property-writes.js";import{html,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{FormAssociated,isBarredFromValidation}from"../../../internal/form-associated.js";import{SET_ANCHORED_VALIDITY,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{deferredPlaceReady as place,waitForDeferredPlacement}from"../../../internal/anchored-overlay-runtime.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{PopupController,emitPopupEvent}from"../../../internal/popup-controller.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{nextId}from"../../../internal/a11y.js";import{closeIcon,calendarIcon,chevronIcon}from"../../../internal/icons.js";import{activateNonmodalOverlay,composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{setCustomState}from"../../../internal/custom-states.js";import{finiteCount,finiteNumber}from"../../../internal/numbers.js";import{isDateObject}from"../../../internal/dom-guards.js";import{localeDateOrder,normalizeLocaleDigits,stripBidiFormattingMarks}from"../../../internal/locale-date.js";import{dateTimeFormat,parseISO,formatISO,localDate,utcDate,normalizeCalendarMonths,normalizeWeekdayFormat}from"./calendar-core.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./date-input.styles.js";import{inclusiveDayCount,parseDisabledWeekdays,projectDisabledDateKeys}from"./date-picker.class.js";import"./date-picker.class.js";import{autocorrectConverter,literalSetConverter,normalizeAutocorrect,spellcheckFromAttributeConverter as spellcheckConverter}from"../../../internal/converters.js";import{isImplicitSubmission,submitOnEnter}from"../../../internal/submit-on-enter.js";import{dispatchNativeEvent,dispatchNativeInputEvent,relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_chooseDate,LYRA_DEFAULT_dateInputFutureDisabled,LYRA_DEFAULT_dateInputPastDisabled,LYRA_DEFAULT_openCalendar}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_date,LYRA_DEFAULT_dateInputInvalid,LYRA_DEFAULT_dateInputMaxMessage,LYRA_DEFAULT_dateInputMinMessage,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";const DASH_CLASS="[-\\u2010-\\u2015\\u2212~\\u301c\\uff5e]",DASH_LIKE=new RegExp(DASH_CLASS,"u");function literalPattern(literal){const visible=Array.from(literal.replace(/\s+/gu,""));return visible.length?`\\s*${visible.map(char=>DASH_LIKE.test(char)?DASH_CLASS:char.replace(/[.*+?^${}()|[\]\\/]/gu,"\\$&")).join("\\s*")}\\s*`:literal?"\\s+":""}function compileDatePattern(parts){const fields=[],pieces=[];for(const part of parts)part.type==="day"||part.type==="month"||part.type==="year"?(fields.push([part.source==="startRange"?1:part.source==="endRange"?2:0,part.type]),pieces.push("(\\d{1,4})")):pieces.push(literalPattern(stripBidiFormattingMarks(part.value)));for(const owner of[1,2])for(const type of["day","month","year"])if(fields.filter(([o,t])=>t===type&&(o===0||o===owner)).length!==1)return null;const first=pieces.indexOf("(\\d{1,4})"),last=pieces.lastIndexOf("(\\d{1,4})"),optional=source2=>source2?`(?:${source2})?`:"",source=optional(pieces.slice(0,first).join(""))+pieces.slice(first,last+1).join("")+optional(pieces.slice(last+1).join(""));return{regex:new RegExp(`^\\s*${source}\\s*$`,"iu"),fields}}function localeDatePatterns(locale){const formatter=dateTimeFormat(locale,{year:"numeric",month:"numeric",day:"numeric"});let letters="";const compile=parts=>{for(const part of parts)part.type==="literal"&&(letters+=(part.value.match(/\p{L}/gu)??[]).join(""));return compileDatePattern(parts)};let single=null;try{single=compile(formatter.formatToParts(localDate(2026,0,2)))}catch{}const ranges=[];for(const[from,to]of[[localDate(2026,0,2),localDate(2026,0,3)],[localDate(2026,0,2),localDate(2026,1,3)],[localDate(2025,0,2),localDate(2026,1,3)]])try{const pattern=compile(formatter.formatRangeToParts(from,to));pattern&&ranges.push(pattern)}catch{}return{single,ranges,letters:letters.toLowerCase()}}function dateFromFields({day,month,year}){if(!day||!month||!year)return null;const fullYear=year.length<=2?2e3+Number(year):Number(year);return parseISO(`${String(fullYear).padStart(4,"0")}-${String(Number(month)).padStart(2,"0")}-${String(Number(day)).padStart(2,"0")}`)}function matchDatePattern(pattern,text){const match=pattern?.regex.exec(text);if(!pattern||!match)return null;const start={},end={};pattern.fields.forEach(([owner,type],index)=>{owner!==2&&(start[type]=match[index+1]),owner!==1&&(end[type]=match[index+1])});const from=dateFromFields(start),to=dateFromFields(end);return from&&to?[from,to]:null}function hasForeignLetters(text,letters){return(text.match(/\p{L}/gu)??[]).some(letter=>!letters.includes(letter.toLowerCase()))}function normalizeLocalizedDateText(raw,locale){return normalizeLocaleDigits(raw,locale).trim()}const monthsConverter={fromAttribute:normalizeCalendarMonths,toAttribute:normalizeCalendarMonths},weekdayFormatConverter={fromAttribute:normalizeWeekdayFormat,toAttribute:normalizeWeekdayFormat},APPEARANCE=literalSetConverter(["accent","filled","outlined","filled-outlined","plain"],"outlined"),placements=new Set(["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"]);function normalizeDateInputPlacement(value){return typeof value=="string"&&placements.has(value)?value:"bottom-start"}const placementConverter={fromAttribute:normalizeDateInputPlacement,toAttribute:normalizeDateInputPlacement};function normalizeDateInputPageBy(value){return value==="single"?"single":"months"}const pageByConverter={fromAttribute:normalizeDateInputPageBy,toAttribute:normalizeDateInputPageBy},VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]);function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}class LyraDateInputBase extends LyraElement{}class LyraDateInput extends FormAssociated(LyraDateInputBase){static{this.defaultStrings={...super.defaultStrings,chooseDate:LYRA_DEFAULT_chooseDate,clear:LYRA_DEFAULT_clear,date:LYRA_DEFAULT_date,dateInputFutureDisabled:LYRA_DEFAULT_dateInputFutureDisabled,dateInputInvalid:LYRA_DEFAULT_dateInputInvalid,dateInputMaxMessage:LYRA_DEFAULT_dateInputMaxMessage,dateInputMinMessage:LYRA_DEFAULT_dateInputMinMessage,dateInputPastDisabled:LYRA_DEFAULT_dateInputPastDisabled,fieldRequired:LYRA_DEFAULT_fieldRequired,openCalendar:LYRA_DEFAULT_openCalendar}}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.properties={mode:{reflect:!0,noAccessor:!0},min:{reflect:!0,noAccessor:!0},max:{reflect:!0,noAccessor:!0},readonly:{type:Boolean,reflect:!0,noAccessor:!0},disablePast:{type:Boolean,attribute:"disable-past",reflect:!0,noAccessor:!0},disableFuture:{type:Boolean,attribute:"disable-future",reflect:!0,noAccessor:!0}}}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!this.readonly&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=normalizeAutocorrect(next),this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get appliedPreset(){return this._appliedPreset}static get observedAttributes(){const attributes=super.observedAttributes;return observeReactivePropertyWrites(this.prototype,["clearLabel","openLabel","dialogLabel"],(instance,name,value)=>{const authored=value!=null;let ownershipChanged=!1;switch(name){case"clearLabel":if(instance.clearLabelAuthored===void 0)return;ownershipChanged=authored!==instance.clearLabelAuthored,instance.clearLabelAuthored=authored;break;case"openLabel":if(instance.openLabelAuthored===void 0)return;ownershipChanged=authored!==instance.openLabelAuthored,instance.openLabelAuthored=authored;break;case"dialogLabel":if(instance.dialogLabelAuthored===void 0)return;ownershipChanged=authored!==instance.dialogLabelAuthored,instance.dialogLabelAuthored=authored;break}ownershipChanged&&instance.requestUpdate()}),attributes}constructor(){super(),this._appearance="outlined",this.clearable=!1,this.withClear=!1,this.withHint=!1,this.withLabel=!1,this.size="m",this.pill=!1,this.label="",this.labelDisplay="visible",this.hint="",this.errorText="",this.placeholder="",this.spellcheck=!0,this.autocapitalize="",this.autocorrectValue=!0,this.autocomplete="",this.inputMode="",this.enterKeyHint="",this.accessibleLabel=null,this.locale="",this.months=1,this.firstDayOfWeek="auto",this.weekdayFormat="short",this.presets=Object.freeze([]),this.withOutsideDays=!1,this.withWeekNumbers=!1,this.disabledDates="",this.disabledDaysOfWeek="",this.minRange=0,this.maxRange=0,this.pageBy="months",this.today="",this.distance=0,this.placement="bottom-start",this.assumeInteractionOn=["input"],this.validators=[],this.clearLabel="",this.clearLabelAuthored=!1,this.openLabel="",this.openLabelAuthored=!1,this.dialogLabel="Choose date",this.dialogLabelAuthored=!1,this.enterCommittedText=null,this.committingTypedText=!1,this.forcingClose=!1,this.inputRelayedSinceCommit=!1,this.popupController=new PopupController({host:this,popup:()=>this.renderRoot.querySelector('[part="popup"]'),emit:(name,cancelable)=>emitPopupEvent(this,name,cancelable),onPointer:event=>this.onDocPointer(event)}),this.restorePopupFocusOnClose=!1,this.popupHidden=!0,this.popupPositioned=!1,this.interactionListeners=new Map,this.renderedDaySlots="",this.localDescriptionIds="",this.inputId=nextId("date-input"),this.popupId=nextId("date-popup"),this.touched=!1,this.slotPresence=new SlotPresenceController(this),this.validityRevision=0,this._mode="single",this._min="",this._max="",this._open=!1,this._readonly=!1,this._disablePast=!1,this._disableFuture=!1,this.typedBadInput=!1,this.now=()=>new Date,this.onVisibilityChange=()=>{this.ownerDocument.visibilityState==="visible"&&(this.updateValidity(),this.validityRevision++)},this.onDocPointer=e=>{e.composedPath().includes(this)||this.hide(!1)},this.onClearClick=()=>{this.clear(),this.inputElement?.focus()},this.onInputChange=e=>{e.stopPropagation(),!this.liveDisabled&&this.commitInputChange(e.target.value,e)},this.onInput=event=>{if(event.stopPropagation(),this.liveDisabled)return;this.enterCommittedText=null,this.inputRelayedSinceCommit=!0;const value=this.value;relayNativeEvent(this,event),this.emit("lr-input",{value})},this.onInputKey=e=>{if(e.altKey&&e.key==="ArrowDown"){e.preventDefault(),this.show();return}if(this.liveDisabled||this.readonly||!isImplicitSubmission(e))return;const input=this.inputElement;if(input&&input.value!==this.displayText){const raw=input.value;if(this.applyTypedText(raw)){const value=this.value;this.inputRelayedSinceCommit||(dispatchNativeInputEvent(this,{inputType:"insertReplacementText"}),this.emit("lr-input",{value})),this.inputRelayedSinceCommit=!1,dispatchNativeEvent(this,"change"),this.emit("lr-change",{value})}else this.inputRelayedSinceCommit=!1;this.enterCommittedText=raw}submitOnEnter(this,e)},this.onInputBlur=event=>{!this.liveDisabled&&this.inputRelayedSinceCommit&&this.inputElement&&this.commitInputChange(this.inputElement.value),this.liveDisabled||(this.touched=!0),relayNativeEvent(this,event)},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}relayNativeEvent(this,event)},this.onPickerInput=e=>{if(e.stopPropagation(),this.liveDisabled)return;const picker=e.target;this.value=picker.value,this._appliedPreset=picker.appliedPreset,this.inputRelayedSinceCommit=!1;const value=this.value;relayNativeEvent(this,e),this.emit("lr-input",{value})},this.onPickerChange=e=>{if(e.stopPropagation(),this.liveDisabled)return;const picker=e.target;this.value=picker.value,this._appliedPreset=picker.appliedPreset;const value=this.value;relayNativeEvent(this,e),this.emit("lr-change",{value}),this.hide(!0)},new GlassScrollLayer(this,'[part="popup"]',()=>this.open),this.addEventListener("invalid",()=>{this.touched=!0})}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}get hasLabelSlot(){return this.slotPresence.has("label")}get hasStartSlot(){return this.slotPresence.has("start")}get hasEndSlot(){return this.slotPresence.has("end")}get mode(){return this._mode}set mode(next){const old=this._mode;this._mode=next==="range"?"range":"single",this.internals.setFormValue(this.isIncompleteRangeValue(this.value)?"":this.value),this.updateValidity(),this.syncCustomStates(),this.requestUpdate("mode",old)}get min(){return this._min}set min(next){const old=this._min;this._min=next??"",this.updateValidity(),this.requestUpdate("min",old)}get max(){return this._max}set max(next){const old=this._max;this._max=next??"",this.updateValidity(),this.requestUpdate("max",old)}get readonly(){return this._readonly}set readonly(next){const old=this._readonly;this._readonly=!!next,this.toggleAttribute("readonly",this._readonly),this._readonly&&this.forceClose(),this.updateValidity(),this.requestUpdate("readonly",old)}get disabled(){return super.disabled}set disabled(next){super.disabled=next,next&&this.forceClose(),this.syncCustomStates()}get disablePast(){return this._disablePast}set disablePast(next){const old=this._disablePast;this._disablePast=!!next,this.updateValidity(),this.requestUpdate("disablePast",old)}get disableFuture(){return this._disableFuture}set disableFuture(next){const old=this._disableFuture;this._disableFuture=!!next,this.updateValidity(),this.requestUpdate("disableFuture",old)}get input(){return this.inputElement}get selectionStart(){return this.inputElement?.selectionStart??null}set selectionStart(value){this.inputElement&&(this.inputElement.selectionStart=value??0)}get selectionEnd(){return this.inputElement?.selectionEnd??null}set selectionEnd(value){this.inputElement&&(this.inputElement.selectionEnd=value??0)}get selectionDirection(){return this.inputElement?.selectionDirection??null}set selectionDirection(value){this.inputElement&&(this.inputElement.selectionDirection=value??"none")}get value(){return super.value}set value(next){this.setTypedBadInput(!1);const old=super.value,normalized=this.normalizeCommittedValue(next??"");super.value=normalized,this.internals.setFormValue(this.isIncompleteRangeValue(normalized)?"":normalized),this.syncCustomStates(),normalized!==old&&this.valueReplaced()}valueReplaced(){this.enterCommittedText=null,this.committingTypedText||(this.inputRelayedSinceCommit=!1,this.inputElement&&(this.inputElement.value=this.displayText))}get valueAsDate(){return this.mode==="single"?this.parseStrictISO(this.value):null}set valueAsDate(next){this.value=isDateObject(next)&&Number.isFinite(next.getTime())?formatISO(next):""}get valueAsLocalDate(){return this.valueAsDate}set valueAsLocalDate(next){this.valueAsDate=next}get valueAsUTCDate(){const local=this.valueAsDate;return local?utcDate(local.getFullYear(),local.getMonth(),local.getDate()):null}set valueAsUTCDate(next){this.valueAsDate=isDateObject(next)?localDate(next.getUTCFullYear(),next.getUTCMonth(),next.getUTCDate()):null}get valueAsRange(){if(this.mode!=="range")return{from:null,to:null};const[from="",to=""]=this.value.split("/");return{from:this.parseStrictISO(from),to:this.parseStrictISO(to)}}set valueAsRange(next){let from=isDateObject(next?.from)&&Number.isFinite(next.from.getTime())?next.from:null,to=isDateObject(next?.to)&&Number.isFinite(next.to.getTime())?next.to:null;from&&to&&to<from&&([from,to]=[to,from]),this.value=from?to?`${formatISO(from)}/${formatISO(to)}`:formatISO(from):""}get validationTarget(){return this.validationTargetOverride??this.inputElement}set validationTarget(next){const old=this.validationTarget;this.validationTargetOverride=next??void 0,this.requestUpdate("validationTarget",old)}[VALIDITY_ANCHOR](){return this.validationTarget}resetValidity(){this.setCustomValidity(""),this.updateValidity()}setTypedBadInput(next){const old=this.typedBadInput;this.typedBadInput=next,old!==next&&this.requestUpdate("typedBadInput",old)}parseStrictISO(value){return/^\d{4}-\d{2}-\d{2}$/.test(value)?parseISO(value):null}normalizeCommittedValue(value){if(value==="")return"";const parts=value.split("/");if(parts.length!==1&&parts.length!==2)return"";const dates=parts.map(part=>this.parseStrictISO(part));return dates.some(date=>date===null)?"":parts.length===2&&dates[0]>dates[1]?`${parts[1]}/${parts[0]}`:value}isIncompleteRangeValue(value){return this.mode==="range"&&value!==""&&!value.includes("/")}valueDates(value){const parts=value.split("/"),expectedParts=this.mode==="range"&&parts.length===2?2:1;if(parts.length!==expectedParts)return null;const dates=parts.map(part=>this.parseStrictISO(part));return dates.some(date=>date===null)?null:dates}get disabledDateKeys(){const source=this.disabledDates;return(!this.disabledDateKeysCache||this.disabledDateKeysCache[0]!==source)&&(this.disabledDateKeysCache=[source,new Set(projectDisabledDateKeys(source))]),this.disabledDateKeysCache[1]}validatorResult(){for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("dateInputInvalid")}}result=typeof validator=="function"?validator(this.value,this):validator?.validate(this.value,this)}catch{return{flags:{customError:!0},message:this.localize("dateInputInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("dateInputInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("dateInputInvalid")}}}return{}}updateValidity(){if(isBarredFromValidation(this,this.internals)){this[SET_ANCHORED_VALIDITY]({});return}const flags={};let underflowMessage="",overflowMessage="";const incompleteRange=this.isIncompleteRangeValue(this.value);if(this.required&&(this.value===""||incompleteRange)&&(flags.valueMissing=!0),this.typedBadInput&&(flags.badInput=!0),this.value!==""){const dates=this.valueDates(this.value);if(!dates)flags.badInput=!0;else{const min=this.parseStrictISO(this.min),max=this.parseStrictISO(this.max),now=this.parseStrictISO(this.today)??this.now(),today=localDate(now.getFullYear(),now.getMonth(),now.getDate());min!==null&&dates.some(date=>date<min)&&(flags.rangeUnderflow=!0,underflowMessage=this.localize("dateInputMinMessage",void 0,{min:this.displayDate(min)})),this.disablePast&&dates.some(date=>date<today)&&(flags.rangeUnderflow=!0,underflowMessage||=this.localize("dateInputPastDisabled")),max!==null&&dates.some(date=>date>max)&&(flags.rangeOverflow=!0,overflowMessage=this.localize("dateInputMaxMessage",void 0,{max:this.displayDate(max)})),this.disableFuture&&dates.some(date=>date>today)&&(flags.rangeOverflow=!0,overflowMessage||=this.localize("dateInputFutureDisabled"));const disabledDates=this.disabledDateKeys,disabledWeekdays=parseDisabledWeekdays(this.disabledDaysOfWeek);let configuredDisabled=dates.some(date=>disabledDates.has(formatISO(date))||disabledWeekdays.has(date.getDay()));if(!configuredDisabled&&this.isDateDisabled)try{configuredDisabled=dates.some(date=>!!this.isDateDisabled?.(new Date(date.getTime())))}catch{configuredDisabled=!1}if(configuredDisabled&&(flags.customError=!0),this.mode==="range"&&dates.length===2){const length=inclusiveDayCount(dates[0],dates[1]),minimum=finiteCount(this.minRange,0),maximum=finiteCount(this.maxRange,0);minimum>0&&length<minimum&&(flags.rangeUnderflow=!0,underflowMessage||=this.localize("dateInputInvalid")),maximum>0&&length>maximum&&(flags.rangeOverflow=!0,overflowMessage||=this.localize("dateInputInvalid"))}}}const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags);let message="";configured.message?message=configured.message:flags.badInput||flags.customError?message=this.localize("dateInputInvalid"):flags.rangeUnderflow?message=underflowMessage:flags.rangeOverflow?message=overflowMessage:flags.valueMissing&&(message=this.localize("fieldRequired")),this[SET_ANCHORED_VALIDITY](flags,message)}checkValidity(){return this.updateValidity(),super.checkValidity()}reportValidity(){return this.updateValidity(),super.reportValidity()}bindVisibilityListener(){if(!this.isConnected)return;const ownerDocument=this.ownerDocument;if(this.visibilityListenerDocument===ownerDocument&&this.visibilityListener)return;this.unbindVisibilityListener();const listener=()=>{this.visibilityListener!==listener||this.visibilityListenerDocument!==ownerDocument||!this.isConnected||this.ownerDocument!==ownerDocument||this.onVisibilityChange()};this.visibilityListenerDocument=ownerDocument,this.visibilityListener=listener,ownerDocument.addEventListener("visibilitychange",listener)}unbindVisibilityListener(){this.visibilityListenerDocument&&this.visibilityListener&&this.visibilityListenerDocument.removeEventListener("visibilitychange",this.visibilityListener),this.visibilityListenerDocument=void 0,this.visibilityListener=void 0}displayDate(date){return dateTimeFormat(this.effectiveLocale,{year:"numeric",month:"numeric",day:"numeric"}).format(date)}get displayText(){const parts=this.value.split("/"),from=parseISO(parts[0]),to=parseISO(parts[1]??"");if(!from)return"";const formatter=dateTimeFormat(this.effectiveLocale,{year:"numeric",month:"numeric",day:"numeric"}),fmt=d=>formatter.format(d);if(this.mode!=="range"||!to)return fmt(from);try{return formatter.formatRange(from,to)}catch{return`${fmt(from)} – ${fmt(to)}`}}willUpdate(changed){super.willUpdate(changed),changed.has("open")&&(this.open&&this.isConnected?this.popupController.bindPointer():this.popupController.unbindPointer(),this.popupPositioned=!1),this.open&&(this.popupHidden=!1)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}show(){if(this.open||this.liveDisabled||this.readonly||this.emit("lr-show",null,{cancelable:!0}).defaultPrevented)return Promise.resolve();const settled=this.popupController.wait(!0);return this.open=!0,this.settleTransition("lr-after-show"),settled}hide(restoreFocus=!1){if(!this.open||this.emit("lr-hide",null,{cancelable:!this.forcingClose}).defaultPrevented)return Promise.resolve();const settled=this.popupController.wait(!1);return this.restorePopupFocusOnClose||=restoreFocus,this.open=!1,this.settleTransition("lr-after-hide"),settled}forceClose(){this.forcingClose=!0;try{this.hide()}finally{this.forcingClose=!1}}reconnectOpenPopup(){if(!this.isConnected||!this.open)return;this.popupController.bindPointer(),this.cleanupFn?.();const anchor=this.renderRoot.querySelector('[part="input-wrapper"]'),popup=this.renderRoot.querySelector('[part="popup"]');if(!(!anchor||!popup)){this.cleanupFn=place(anchor,popup,{placement:normalizeDateInputPlacement(this.placement),offset:finiteNumber(this.distance,0),strategy:resolveEffectivePositioningStrategy(this,void 0,"fixed")});{const operation=this.cleanupFn;operation.ready.then(positioned=>{positioned&&this.cleanupFn===operation&&this.open&&this.isConnected&&(this.popupPositioned=!0)})}this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="popup"]'),onEscape:()=>{this.hide(!0)}})}}settleTransition(event){return this.popupController.settle(event,{waitForPosition:async stale=>{const positioned=await waitForDeferredPlacement(()=>this.cleanupFn);return stale()||!this.open?!1:positioned?!0:(this.popupController.release("lr-after-show"),this.open=!1,!1)},conceal:()=>{this.popupHidden=!0}})}connectedCallback(){super.connectedCallback(),this.observeDaySlots(),this.syncExternalDescription(),this.bindVisibilityListener(),this.syncInteractionListeners(),this.syncValidatorAttributeObserver(),this.syncCustomStates(),this.hasUpdated&&this.open&&queueMicrotask(()=>this.reconnectOpenPopup())}daySlotNames(){return[...new Set(Array.from(this.children??[]).map(child=>child.getAttribute("slot")??"").filter(name=>/^day-\d{4}-\d{2}-\d{2}$/.test(name)))]}observeDaySlots(){const Observer=this.ownerDocument.defaultView?.MutationObserver;this.daySlotObserver||!Observer||(this.daySlotObserver=new Observer(()=>{this.daySlotNames().join(" ")!==this.renderedDaySlots&&this.requestUpdate()}),this.daySlotObserver.observe(this,{childList:!0,subtree:!0,attributeFilter:["slot"]}))}clear(){!this.value||this.liveDisabled||this.readonly||(this.touched=!0,this._appliedPreset=void 0,this.value="",this.inputRelayedSinceCommit=!1,dispatchNativeInputEvent(this,{inputType:"deleteContentBackward"}),this.emit("lr-input",{value:""}),dispatchNativeEvent(this,"change"),this.emit("lr-change",{value:""}),this.emit("lr-clear"))}syncInteractionListeners(){const requested=new Set((Array.isArray(this.assumeInteractionOn)?this.assumeInteractionOn:[]).filter(name=>typeof name=="string"&&name.length>0));for(const[name,listener]of this.interactionListeners)requested.has(name)||(this.removeEventListener(name,listener),this.interactionListeners.delete(name));for(const name of requested){if(this.interactionListeners.has(name))continue;const listener=()=>{this.touched=!0,this.syncCustomStates()};this.addEventListener(name,listener),this.interactionListeners.set(name,listener)}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}syncCustomStates(){setCustomState(this.internals,"blank",this.value===""),setCustomState(this.internals,"disabled",this.effectiveDisabled),setCustomState(this.internals,"open",this.open),setCustomState(this.internals,"range",this.mode==="range")}disconnectedCallback(){this.popupHidden=!0,this.daySlotObserver?.disconnect(),this.daySlotObserver=void 0,this.externalDescription?.release(),this.externalDescription=void 0,this.popupController.cancel(),this.cleanupFn?.(),this.cleanupFn=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindVisibilityListener(),this.popupController.unbindPointer(),this.disconnectValidatorAttributeObserver(),this.restorePopupFocusOnClose=!1;for(const[name,listener]of this.interactionListeners)this.removeEventListener(name,listener);this.interactionListeners.clear(),this.enterCommittedText=null,this.inputRelayedSinceCommit=!1,this.open=!1,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.externalDescription?.release(),this.externalDescription=void 0,this.syncExternalDescription(),this.cleanupFn?.(),this.cleanupFn=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindVisibilityListener(),this.popupController.unbindPointer(),this.disconnectValidatorAttributeObserver()}syncExternalDescription(){if(!this.isConnected)return;const input=this.renderRoot?.querySelector("input")??null;this.externalDescription?this.externalDescription.update(input):this.externalDescription=acquireNativeControlDescription(this,input,()=>this.localDescriptionIds)}updated(changed){if(super.updated(changed),this.syncExternalDescription(),(changed.has("disabledDates")||changed.has("disabledDaysOfWeek")||changed.has("isDateDisabled")||changed.has("minRange")||changed.has("maxRange")||changed.has("today")||changed.has("validators"))&&this.updateValidity(),(changed.has("open")||this.open&&(changed.has("placement")||changed.has("distance")))&&(this.cleanupFn?.(),this.cleanupFn=void 0,this.open&&this.isConnected)){const anchor=this.renderRoot.querySelector('[part="input-wrapper"]'),popup=this.renderRoot.querySelector('[part="popup"]');if(anchor&&popup){this.cleanupFn=place(anchor,popup,{placement:normalizeDateInputPlacement(this.placement),offset:finiteNumber(this.distance,0),strategy:resolveEffectivePositioningStrategy(this,void 0,"fixed")});const operation=this.cleanupFn;operation.ready.then(positioned=>{positioned&&this.cleanupFn===operation&&this.open&&this.isConnected&&(this.popupPositioned=!0)})}}if(changed.has("open")){if(this.open&&this.isConnected)this.renderRoot.querySelector('[part="popup"]')&&(this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="popup"]'),onEscape:()=>{this.hide(!0)}}));else if(!this.open){const popup=this.renderRoot.querySelector('[part="popup"]'),focusWasInsidePopup=popup!==null&&composedContains(popup,deepActiveElement(this.ownerDocument));this.overlayHandle?.deactivate({restoreFocus:this.restorePopupFocusOnClose||focusWasInsidePopup}),this.overlayHandle=void 0,this.restorePopupFocusOnClose=!1}}changed.has("assumeInteractionOn")&&this.syncInteractionListeners(),changed.has("validators")&&this.syncValidatorAttributeObserver(),this.syncCustomStates(),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("mode")||changed.has("min")||changed.has("max")||changed.has("readonly")||changed.has("disablePast")||changed.has("disableFuture")||changed.has("disabledDates")||changed.has("disabledDaysOfWeek")||changed.has("minRange")||changed.has("maxRange")||changed.has("validators")||changed.has("typedBadInput")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid)}commitTypedValue(next){this.committingTypedText=!0;try{this.value=next}finally{this.committingTypedText=!1}}applyTypedText(raw){this.enterCommittedText=null;const trimmed=raw.trim();if(!trimmed)return this.value!==""&&(this._appliedPreset=void 0),this.commitTypedValue(""),!0;const parsed=this.mode==="range"?this.parseRangeText(trimmed):this.parseSingleText(trimmed);return parsed?(parsed!==this.value&&(this._appliedPreset=void 0),this.commitTypedValue(parsed),!0):(this.inputElement&&(this.inputElement.value=this.displayText),this.setTypedBadInput(!0),this.updateValidity(),!1)}commitInputChange(raw,source){if(this.enterCommittedText!==null&&(raw===this.enterCommittedText||raw===this.displayText))return;if(this.enterCommittedText=null,this.applyTypedText(raw)){const value=this.value;this.inputRelayedSinceCommit||(dispatchNativeInputEvent(this,{inputType:"insertReplacementText"}),this.emit("lr-input",{value})),this.inputRelayedSinceCommit=!1,source?relayNativeEvent(this,source):dispatchNativeEvent(this,"change"),this.emit("lr-change",{value})}else this.inputRelayedSinceCommit=!1}numericDate(groups){if(groups.length!==3)return null;const order=groups[0].length===4?["year","month","day"]:localeDateOrder(this.effectiveLocale,"gregory"),fields={};return order.forEach((type,index)=>{fields[type]=groups[index]}),dateFromFields(fields)}parseOneDate(raw){const text=normalizeLocalizedDateText(raw,this.effectiveLocale),patterns=localeDatePatterns(this.effectiveLocale),own=matchDatePattern(patterns.single,text);if(own)return own[0];if(/^\d{4}-\d{2}-\d{2}$/.test(text))return parseISO(text);const groups=text.match(/\d+/g)??[];if(!hasForeignLetters(text,patterns.letters))return this.numericDate(groups);if(groups.length===3)return null;const timestamp=Date.parse(text);return Number.isNaN(timestamp)?null:new Date(timestamp)}parseSingleText(raw){const parsed=this.parseOneDate(raw);return parsed?formatISO(parsed):null}localizedRangeSeparator(){const formatter=dateTimeFormat(this.effectiveLocale,{year:"numeric",month:"numeric",day:"numeric"});try{const parts=formatter.formatRangeToParts(localDate(2026,0,2),localDate(2026,0,3)),firstEnd=parts.findIndex(part=>part.source==="endRange");let lastStart=-1;for(let index=0;index<firstEnd;index++)parts[index]?.source==="startRange"&&(lastStart=index);const separator=parts.slice(lastStart+1,firstEnd).map(part=>part.value).join("");return normalizeLocalizedDateText(separator,this.effectiveLocale)||"–"}catch{return"–"}}parseRangeText(raw){if(raw=normalizeLocalizedDateText(raw,this.effectiveLocale),raw===normalizeLocalizedDateText(this.displayText,this.effectiveLocale)&&this.value.includes("/"))return this.normalizeCommittedValue(this.value);if(/^\d{4}-\d{2}-\d{2}\/\d{4}-\d{2}-\d{2}$/.test(raw)){const[a,b]=raw.split("/"),from2=parseISO(a),to2=parseISO(b);return!from2||!to2?null:from2<=to2?raw:`${b}/${a}`}const patterns=localeDatePatterns(this.effectiveLocale);let pair=null;for(const pattern of[...patterns.ranges,patterns.single])pair??=matchDatePattern(pattern,raw);if(!pair){const groups=raw.match(/\d+/g)??[];if(hasForeignLetters(raw,patterns.letters)){const separator=this.localizedRangeSeparator(),idx=raw.indexOf(separator);if(idx===-1)return null;const from2=this.parseOneDate(raw.slice(0,idx).trim()),to2=this.parseOneDate(raw.slice(idx+separator.length).trim());pair=from2&&to2?[from2,to2]:null}else{if(groups.length!==6)return null;const from2=this.numericDate(groups.slice(0,3)),to2=this.numericDate(groups.slice(3));pair=from2&&to2?[from2,to2]:null}}if(!pair)return null;const[from,to]=pair[0]<=pair[1]?pair:[pair[1],pair[0]],start=formatISO(from),end=formatISO(to);return start&&end?`${start}/${end}`:null}click(){this.liveDisabled||this.inputElement?.click()}focus(options){this.liveDisabled||this.inputElement?.focus(options)}blur(){this.inputElement?.blur()}select(){this.inputElement?.select()}setSelectionRange(start,end,direction){this.inputElement?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputElement;input&&(setNativeRangeText(input,replacement,start,end,selectMode),this.applyTypedText(input.value))}formStateRestoreCallback(state2,_mode){this.value=typeof state2=="string"?state2:""}formResetCallback(){super.formResetCallback(),this.valueReplaced(),this.touched=!1,this._appliedPreset=void 0}formDisabledCallback(disabled){super.formDisabledCallback(disabled),disabled&&this.forceClose(),this.syncCustomStates()}render(){const hasValue=this.value.length>0,hasHint=this.withHint||this.hasHintSlot||(this.hint??"").length>0,hasError=this.hasErrorSlot||(this.errorText??"").length>0,hasLabel=this.withLabel||this.hasLabelSlot||(this.label??"").length>0,invalid=hasError||this.touched&&!this.internals.validity.valid,describedBy=this.localDescriptionIds=[hasError?"date-input-error":"",hasHint?"date-input-hint":""].filter(Boolean).join(" "),dynamicDaySlots=this.daySlotNames();return this.renderedDaySlots=dynamicDaySlots.join(" "),html`
1
+ import{__decorate}from"tslib";import{nativeAutocorrectAttribute,setNativeRangeText}from"../../../internal/native-text-control.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{observeReactivePropertyWrites}from"../../../internal/reactive-property-writes.js";import{html,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{FormAssociated,isBarredFromValidation}from"../../../internal/form-associated.js";import{SET_ANCHORED_VALIDITY,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{deferredPlaceReady as place,waitForDeferredPlacement}from"../../../internal/anchored-overlay-runtime.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{PopupController,emitPopupEvent}from"../../../internal/popup-controller.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{nextId}from"../../../internal/a11y.js";import{closeIcon,calendarIcon,chevronIcon}from"../../../internal/icons.js";import{activateNonmodalOverlay,composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{setCustomState}from"../../../internal/custom-states.js";import{finiteCount,finiteNumber}from"../../../internal/numbers.js";import{isDateObject}from"../../../internal/dom-guards.js";import{localeDateOrder,normalizeLocaleDigits,stripBidiFormattingMarks}from"../../../internal/locale-date.js";import{dateTimeFormat,parseISO,formatISO,localDate,utcDate,normalizeCalendarMonths,normalizeWeekdayFormat}from"./calendar-core.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./date-input.styles.js";import{inclusiveDayCount,parseDisabledWeekdays,projectDisabledDateKeys}from"./date-picker.class.js";import"./date-picker.class.js";import{autocorrectConverter,literalSetConverter,normalizeAutocorrect,spellcheckFromAttributeConverter as spellcheckConverter}from"../../../internal/converters.js";import{isImplicitSubmission,submitOnEnter}from"../../../internal/submit-on-enter.js";import{dispatchNativeEvent,dispatchNativeInputEvent,relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_chooseDate,LYRA_DEFAULT_dateInputFutureDisabled,LYRA_DEFAULT_dateInputPastDisabled,LYRA_DEFAULT_openCalendar}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_date,LYRA_DEFAULT_dateInputInvalid,LYRA_DEFAULT_dateInputMaxMessage,LYRA_DEFAULT_dateInputMinMessage,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";const DASH_CLASS="[-\\u2010-\\u2015\\u2212~\\u301c\\uff5e]",DASH_LIKE=new RegExp(DASH_CLASS,"u");function literalPattern(literal){const visible=Array.from(literal.replace(/\s+/gu,""));return visible.length?`\\s*${visible.map(char=>DASH_LIKE.test(char)?DASH_CLASS:char.replace(/[.*+?^${}()|[\]\\/]/gu,"\\$&")).join("\\s*")}\\s*`:literal?"\\s+":""}function compileDatePattern(parts){const fields=[],pieces=[];for(const part of parts)part.type==="day"||part.type==="month"||part.type==="year"?(fields.push([part.source==="startRange"?1:part.source==="endRange"?2:0,part.type]),pieces.push("(\\d{1,4})")):pieces.push(literalPattern(stripBidiFormattingMarks(part.value)));for(const owner of[1,2])for(const type of["day","month","year"])if(fields.filter(([o,t])=>t===type&&(o===0||o===owner)).length!==1)return null;const first=pieces.indexOf("(\\d{1,4})"),last=pieces.lastIndexOf("(\\d{1,4})"),optional=source2=>source2?`(?:${source2})?`:"",source=optional(pieces.slice(0,first).join(""))+pieces.slice(first,last+1).join("")+optional(pieces.slice(last+1).join(""));return{regex:new RegExp(`^\\s*${source}\\s*$`,"iu"),fields}}function localeDatePatterns(locale){const formatter=dateTimeFormat(locale,{year:"numeric",month:"numeric",day:"numeric"});let letters="";const compile=parts=>{for(const part of parts)part.type==="literal"&&(letters+=(part.value.match(/\p{L}/gu)??[]).join(""));return compileDatePattern(parts)};let single=null;try{single=compile(formatter.formatToParts(localDate(2026,0,2)))}catch{}const ranges=[];for(const[from,to]of[[localDate(2026,0,2),localDate(2026,0,3)],[localDate(2026,0,2),localDate(2026,1,3)],[localDate(2025,0,2),localDate(2026,1,3)]])try{const pattern=compile(formatter.formatRangeToParts(from,to));pattern&&ranges.push(pattern)}catch{}return{single,ranges,letters:letters.toLowerCase()}}function dateFromFields({day,month,year}){if(!day||!month||!year)return null;const fullYear=year.length<=2?2e3+Number(year):Number(year);return parseISO(`${String(fullYear).padStart(4,"0")}-${String(Number(month)).padStart(2,"0")}-${String(Number(day)).padStart(2,"0")}`)}function matchDatePattern(pattern,text){const match=pattern?.regex.exec(text);if(!pattern||!match)return null;const start={},end={};pattern.fields.forEach(([owner,type],index)=>{owner!==2&&(start[type]=match[index+1]),owner!==1&&(end[type]=match[index+1])});const from=dateFromFields(start),to=dateFromFields(end);return from&&to?[from,to]:null}function hasForeignLetters(text,letters){return(text.match(/\p{L}/gu)??[]).some(letter=>!letters.includes(letter.toLowerCase()))}function normalizeLocalizedDateText(raw,locale){return normalizeLocaleDigits(raw,locale).trim()}const monthsConverter={fromAttribute:normalizeCalendarMonths,toAttribute:normalizeCalendarMonths},weekdayFormatConverter={fromAttribute:normalizeWeekdayFormat,toAttribute:normalizeWeekdayFormat},APPEARANCE=literalSetConverter(["accent","filled","outlined","filled-outlined","plain"],"outlined"),placements=new Set(["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"]);function normalizeDateInputPlacement(value){return typeof value=="string"&&placements.has(value)?value:"bottom-start"}const placementConverter={fromAttribute:normalizeDateInputPlacement,toAttribute:normalizeDateInputPlacement};function normalizeDateInputPageBy(value){return value==="single"?"single":"months"}const pageByConverter={fromAttribute:normalizeDateInputPageBy,toAttribute:normalizeDateInputPageBy},VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]);function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}class LyraDateInputBase extends LyraElement{}class LyraDateInput extends FormAssociated(LyraDateInputBase){static{this.defaultStrings={...super.defaultStrings,chooseDate:LYRA_DEFAULT_chooseDate,clear:LYRA_DEFAULT_clear,date:LYRA_DEFAULT_date,dateInputFutureDisabled:LYRA_DEFAULT_dateInputFutureDisabled,dateInputInvalid:LYRA_DEFAULT_dateInputInvalid,dateInputMaxMessage:LYRA_DEFAULT_dateInputMaxMessage,dateInputMinMessage:LYRA_DEFAULT_dateInputMinMessage,dateInputPastDisabled:LYRA_DEFAULT_dateInputPastDisabled,fieldRequired:LYRA_DEFAULT_fieldRequired,openCalendar:LYRA_DEFAULT_openCalendar}}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.properties={mode:{reflect:!0,noAccessor:!0},min:{reflect:!0,noAccessor:!0},max:{reflect:!0,noAccessor:!0},readonly:{type:Boolean,reflect:!0,noAccessor:!0},disablePast:{type:Boolean,attribute:"disable-past",reflect:!0,noAccessor:!0},disableFuture:{type:Boolean,attribute:"disable-future",reflect:!0,noAccessor:!0}}}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!this.readonly&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=normalizeAutocorrect(next),this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get appliedPreset(){return this._appliedPreset}static get observedAttributes(){const attributes=super.observedAttributes;return observeReactivePropertyWrites(this.prototype,["clearLabel","openLabel","dialogLabel"],(instance,name,value)=>{const authored=value!=null;let ownershipChanged=!1;switch(name){case"clearLabel":if(instance.clearLabelAuthored===void 0)return;ownershipChanged=authored!==instance.clearLabelAuthored,instance.clearLabelAuthored=authored;break;case"openLabel":if(instance.openLabelAuthored===void 0)return;ownershipChanged=authored!==instance.openLabelAuthored,instance.openLabelAuthored=authored;break;case"dialogLabel":if(instance.dialogLabelAuthored===void 0)return;ownershipChanged=authored!==instance.dialogLabelAuthored,instance.dialogLabelAuthored=authored;break}ownershipChanged&&instance.requestUpdate()}),attributes}constructor(){super(),this._appearance="outlined",this.clearable=!1,this.withClear=!1,this.withHint=!1,this.withLabel=!1,this.size="m",this.pill=!1,this.label="",this.labelDisplay="visible",this.hint="",this.errorText="",this.placeholder="",this.spellcheck=!0,this.autocapitalize="",this.autocorrectValue=!0,this.autocomplete="",this.inputMode="",this.enterKeyHint="",this.accessibleLabel=null,this.locale="",this.months=1,this.firstDayOfWeek="auto",this.weekdayFormat="short",this.presets=Object.freeze([]),this.withOutsideDays=!1,this.withWeekNumbers=!1,this.disabledDates="",this.disabledDaysOfWeek="",this.minRange=0,this.maxRange=0,this.pageBy="months",this.today="",this.distance=0,this.placement="bottom-start",this.assumeInteractionOn=["input"],this.validators=[],this.clearLabel="",this.clearLabelAuthored=!1,this.openLabel="",this.openLabelAuthored=!1,this.dialogLabel="Choose date",this.dialogLabelAuthored=!1,this.enterCommittedText=null,this.committingTypedText=!1,this.forcingClose=!1,this.inputRelayedSinceCommit=!1,this.popupController=new PopupController({host:this,popup:()=>this.renderRoot.querySelector('[part="popup"]'),emit:(name,cancelable)=>emitPopupEvent(this,name,cancelable),onPointer:event=>this.onDocPointer(event)}),this.restorePopupFocusOnClose=!1,this.popupHidden=!0,this.popupPositioned=!1,this.interactionListeners=new Map,this.renderedDaySlots="",this.localDescriptionIds="",this.inputId=nextId("date-input"),this.popupId=nextId("date-popup"),this.touched=!1,this.slotPresence=new SlotPresenceController(this),this.validityRevision=0,this._mode="single",this._min="",this._max="",this._open=!1,this._readonly=!1,this._disablePast=!1,this._disableFuture=!1,this.typedBadInput=!1,this.now=()=>new Date,this.onVisibilityChange=()=>{this.ownerDocument.visibilityState==="visible"&&(this.updateValidity(),this.validityRevision++)},this.onDocPointer=e=>{e.composedPath().includes(this)||this.hide(!1)},this.onClearClick=()=>{this.clear(),this.inputElement?.focus()},this.onInputChange=e=>{e.stopPropagation(),!this.liveDisabled&&this.commitInputChange(e.target.value,e)},this.onInput=event=>{if(event.stopPropagation(),this.liveDisabled)return;this.enterCommittedText=null,this.inputRelayedSinceCommit=!0;const value=this.value;relayNativeEvent(this,event),this.emit("lr-input",{value})},this.onInputKey=e=>{if(e.altKey&&e.key==="ArrowDown"){e.preventDefault(),this.show();return}if(this.liveDisabled||this.readonly||!isImplicitSubmission(e))return;const input=this.inputElement;if(input&&input.value!==this.displayText){const raw=input.value;if(this.applyTypedText(raw)){const value=this.value;this.inputRelayedSinceCommit||(dispatchNativeInputEvent(this,{inputType:"insertReplacementText"}),this.emit("lr-input",{value})),this.inputRelayedSinceCommit=!1,dispatchNativeEvent(this,"change"),this.emit("lr-change",{value})}else this.inputRelayedSinceCommit=!1;this.enterCommittedText=raw}submitOnEnter(this,e)},this.onInputBlur=event=>{!this.liveDisabled&&this.inputRelayedSinceCommit&&this.inputElement&&this.commitInputChange(this.inputElement.value),this.liveDisabled||(this.touched=!0),relayNativeEvent(this,event)},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}relayNativeEvent(this,event)},this.onPickerInput=e=>{if(e.stopPropagation(),this.liveDisabled)return;const picker=e.target;this.value=picker.value,this._appliedPreset=picker.appliedPreset,this.inputRelayedSinceCommit=!1;const value=this.value;relayNativeEvent(this,e),this.emit("lr-input",{value})},this.onPickerChange=e=>{if(e.stopPropagation(),this.liveDisabled)return;const picker=e.target;this.value=picker.value,this._appliedPreset=picker.appliedPreset;const value=this.value;relayNativeEvent(this,e),this.emit("lr-change",{value}),this.hide(!0)},new GlassScrollLayer(this,'[part="popup"]',()=>this.open),this.addEventListener("invalid",()=>{this.touched=!0})}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}get hasLabelSlot(){return this.slotPresence.has("label")}get hasStartSlot(){return this.slotPresence.has("start")}get hasEndSlot(){return this.slotPresence.has("end")}get mode(){return this._mode}set mode(next){const old=this._mode;this._mode=next==="range"?"range":"single",this.internals.setFormValue(this.isIncompleteRangeValue(this.value)?"":this.value),this.updateValidity(),this.syncCustomStates(),this.requestUpdate("mode",old)}get min(){return this._min}set min(next){const old=this._min;this._min=next??"",this.updateValidity(),this.requestUpdate("min",old)}get max(){return this._max}set max(next){const old=this._max;this._max=next??"",this.updateValidity(),this.requestUpdate("max",old)}get readonly(){return this._readonly}set readonly(next){const old=this._readonly;this._readonly=!!next,this.toggleAttribute("readonly",this._readonly),this._readonly&&this.forceClose(),this.updateValidity(),this.requestUpdate("readonly",old)}get disabled(){return super.disabled}set disabled(next){super.disabled=next,next&&this.forceClose(),this.syncCustomStates()}get disablePast(){return this._disablePast}set disablePast(next){const old=this._disablePast;this._disablePast=!!next,this.updateValidity(),this.requestUpdate("disablePast",old)}get disableFuture(){return this._disableFuture}set disableFuture(next){const old=this._disableFuture;this._disableFuture=!!next,this.updateValidity(),this.requestUpdate("disableFuture",old)}get input(){return this.inputElement}get selectionStart(){return this.inputElement?.selectionStart??null}set selectionStart(value){this.inputElement&&(this.inputElement.selectionStart=value??0)}get selectionEnd(){return this.inputElement?.selectionEnd??null}set selectionEnd(value){this.inputElement&&(this.inputElement.selectionEnd=value??0)}get selectionDirection(){return this.inputElement?.selectionDirection??null}set selectionDirection(value){this.inputElement&&(this.inputElement.selectionDirection=value??"none")}get value(){return super.value}set value(next){this.setTypedBadInput(!1);const old=super.value,normalized=this.normalizeCommittedValue(next??"");super.value=normalized,this.internals.setFormValue(this.isIncompleteRangeValue(normalized)?"":normalized),this.syncCustomStates(),normalized!==old&&this.valueReplaced()}valueReplaced(){this.enterCommittedText=null,this.committingTypedText||(this.inputRelayedSinceCommit=!1,this.inputElement&&(this.inputElement.value=this.displayText))}get valueAsDate(){return this.mode==="single"?this.parseStrictISO(this.value):null}set valueAsDate(next){this.value=isDateObject(next)&&Number.isFinite(next.getTime())?formatISO(next):""}get valueAsLocalDate(){return this.valueAsDate}set valueAsLocalDate(next){this.valueAsDate=next}get valueAsUTCDate(){const local=this.valueAsDate;return local?utcDate(local.getFullYear(),local.getMonth(),local.getDate()):null}set valueAsUTCDate(next){this.valueAsDate=isDateObject(next)?localDate(next.getUTCFullYear(),next.getUTCMonth(),next.getUTCDate()):null}get valueAsRange(){if(this.mode!=="range")return{from:null,to:null};const[from="",to=""]=this.value.split("/");return{from:this.parseStrictISO(from),to:this.parseStrictISO(to)}}set valueAsRange(next){let from=isDateObject(next?.from)&&Number.isFinite(next.from.getTime())?next.from:null,to=isDateObject(next?.to)&&Number.isFinite(next.to.getTime())?next.to:null;from&&to&&to<from&&([from,to]=[to,from]),this.value=from?to?`${formatISO(from)}/${formatISO(to)}`:formatISO(from):""}get validationTarget(){return this.validationTargetOverride??this.inputElement}set validationTarget(next){const old=this.validationTarget;this.validationTargetOverride=next??void 0,this.requestUpdate("validationTarget",old)}[VALIDITY_ANCHOR](){return this.validationTarget}resetValidity(){this.setCustomValidity(""),this.updateValidity()}setTypedBadInput(next){const old=this.typedBadInput;this.typedBadInput=next,old!==next&&this.requestUpdate("typedBadInput",old)}parseStrictISO(value){return/^\d{4}-\d{2}-\d{2}$/.test(value)?parseISO(value):null}normalizeCommittedValue(value){if(value==="")return"";const parts=value.split("/");if(parts.length!==1&&parts.length!==2)return"";const dates=parts.map(part=>this.parseStrictISO(part));return dates.some(date=>date===null)?"":parts.length===2&&dates[0]>dates[1]?`${parts[1]}/${parts[0]}`:value}isIncompleteRangeValue(value){return this.mode==="range"&&value!==""&&!value.includes("/")}valueDates(value){const parts=value.split("/"),expectedParts=this.mode==="range"&&parts.length===2?2:1;if(parts.length!==expectedParts)return null;const dates=parts.map(part=>this.parseStrictISO(part));return dates.some(date=>date===null)?null:dates}get disabledDateKeys(){const source=this.disabledDates;return(!this.disabledDateKeysCache||this.disabledDateKeysCache[0]!==source)&&(this.disabledDateKeysCache=[source,new Set(projectDisabledDateKeys(source))]),this.disabledDateKeysCache[1]}validatorResult(){for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("dateInputInvalid")}}result=typeof validator=="function"?validator(this.value,this):validator?.validate(this.value,this)}catch{return{flags:{customError:!0},message:this.localize("dateInputInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("dateInputInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("dateInputInvalid")}}}return{}}updateValidity(){if(isBarredFromValidation(this,this.internals)){this[SET_ANCHORED_VALIDITY]({});return}const flags={};let underflowMessage="",overflowMessage="";const incompleteRange=this.isIncompleteRangeValue(this.value);if(this.required&&(this.value===""||incompleteRange)&&(flags.valueMissing=!0),this.typedBadInput&&(flags.badInput=!0),this.value!==""){const dates=this.valueDates(this.value);if(!dates)flags.badInput=!0;else{const min=this.parseStrictISO(this.min),max=this.parseStrictISO(this.max),now=this.parseStrictISO(this.today)??this.now(),today=localDate(now.getFullYear(),now.getMonth(),now.getDate());min!==null&&dates.some(date=>date<min)&&(flags.rangeUnderflow=!0,underflowMessage=this.localize("dateInputMinMessage",void 0,{min:this.displayDate(min)})),this.disablePast&&dates.some(date=>date<today)&&(flags.rangeUnderflow=!0,underflowMessage||=this.localize("dateInputPastDisabled")),max!==null&&dates.some(date=>date>max)&&(flags.rangeOverflow=!0,overflowMessage=this.localize("dateInputMaxMessage",void 0,{max:this.displayDate(max)})),this.disableFuture&&dates.some(date=>date>today)&&(flags.rangeOverflow=!0,overflowMessage||=this.localize("dateInputFutureDisabled"));const disabledDates=this.disabledDateKeys,disabledWeekdays=parseDisabledWeekdays(this.disabledDaysOfWeek);let configuredDisabled=dates.some(date=>disabledDates.has(formatISO(date))||disabledWeekdays.has(date.getDay()));if(!configuredDisabled&&this.isDateDisabled)try{configuredDisabled=dates.some(date=>!!this.isDateDisabled?.(new Date(date.getTime())))}catch{configuredDisabled=!1}if(configuredDisabled&&(flags.customError=!0),this.mode==="range"&&dates.length===2){const length=inclusiveDayCount(dates[0],dates[1]),minimum=finiteCount(this.minRange,0),maximum=finiteCount(this.maxRange,0);minimum>0&&length<minimum&&(flags.rangeUnderflow=!0,underflowMessage||=this.localize("dateInputInvalid")),maximum>0&&length>maximum&&(flags.rangeOverflow=!0,overflowMessage||=this.localize("dateInputInvalid"))}}}const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags);let message="";configured.message?message=configured.message:flags.badInput||flags.customError?message=this.localize("dateInputInvalid"):flags.rangeUnderflow?message=underflowMessage:flags.rangeOverflow?message=overflowMessage:flags.valueMissing&&(message=this.localize("fieldRequired")),this[SET_ANCHORED_VALIDITY](flags,message)}checkValidity(){return this.updateValidity(),super.checkValidity()}reportValidity(){return this.updateValidity(),super.reportValidity()}bindVisibilityListener(){if(!this.isConnected)return;const ownerDocument=this.ownerDocument;if(this.visibilityListenerDocument===ownerDocument&&this.visibilityListener)return;this.unbindVisibilityListener();const listener=()=>{this.visibilityListener!==listener||this.visibilityListenerDocument!==ownerDocument||!this.isConnected||this.ownerDocument!==ownerDocument||this.onVisibilityChange()};this.visibilityListenerDocument=ownerDocument,this.visibilityListener=listener,ownerDocument.addEventListener("visibilitychange",listener)}unbindVisibilityListener(){this.visibilityListenerDocument&&this.visibilityListener&&this.visibilityListenerDocument.removeEventListener("visibilitychange",this.visibilityListener),this.visibilityListenerDocument=void 0,this.visibilityListener=void 0}displayDate(date){return dateTimeFormat(this.effectiveLocale,{year:"numeric",month:"numeric",day:"numeric"}).format(date)}get displayText(){const parts=this.value.split("/"),from=parseISO(parts[0]),to=parseISO(parts[1]??"");if(!from)return"";const formatter=dateTimeFormat(this.effectiveLocale,{year:"numeric",month:"numeric",day:"numeric"}),fmt=d=>formatter.format(d);if(this.mode!=="range"||!to)return fmt(from);try{return formatter.formatRange(from,to)}catch{return`${fmt(from)} – ${fmt(to)}`}}willUpdate(changed){super.willUpdate(changed),changed.has("open")&&(this.open&&this.isConnected?this.popupController.bindPointer():this.popupController.unbindPointer(),this.popupPositioned=!1),this.open&&(this.popupHidden=!1)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}show(){if(this.open||this.liveDisabled||this.readonly||this.emit("lr-show",null,{cancelable:!0}).defaultPrevented)return Promise.resolve();const settled=this.popupController.wait(!0);return this.open=!0,this.settleTransition("lr-after-show"),settled}hide(restoreFocus=!1){if(!this.open||this.emit("lr-hide",null,{cancelable:!this.forcingClose}).defaultPrevented)return Promise.resolve();const settled=this.popupController.wait(!1);return this.restorePopupFocusOnClose||=restoreFocus,this.open=!1,this.settleTransition("lr-after-hide"),settled}forceClose(){this.forcingClose=!0;try{this.hide()}finally{this.forcingClose=!1}}reconnectOpenPopup(){if(!this.isConnected||!this.open)return;this.popupController.bindPointer(),this.cleanupFn?.();const anchor=this.renderRoot.querySelector('[part="input-wrapper"]'),popup=this.renderRoot.querySelector('[part="popup"]');!anchor||!popup||(this.cleanupFn=place(anchor,popup,{placement:normalizeDateInputPlacement(this.placement),offset:finiteNumber(this.distance,0),strategy:resolveEffectivePositioningStrategy(this,void 0,"fixed")}),this.watchPopupPlacement(this.cleanupFn),this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="popup"]'),onEscape:()=>{this.hide(!0)}}))}watchPopupPlacement(operation){operation.ready.then(positioned=>{this.cleanupFn!==operation||!this.open||!this.isConnected||(this.popupPositioned=positioned,positioned||(this.popupController.release("lr-after-show"),this.open=!1,this.popupHidden=!0))})}settleTransition(event){return this.popupController.settle(event,{waitForPosition:async stale=>{const positioned=await waitForDeferredPlacement(()=>this.cleanupFn);return stale()||!this.open?!1:positioned},conceal:()=>{this.popupHidden=!0}})}connectedCallback(){super.connectedCallback(),this.observeDaySlots(),this.syncExternalDescription(),this.bindVisibilityListener(),this.syncInteractionListeners(),this.syncValidatorAttributeObserver(),this.syncCustomStates(),this.hasUpdated&&this.open&&queueMicrotask(()=>this.reconnectOpenPopup())}daySlotNames(){return[...new Set(Array.from(this.children??[]).map(child=>child.getAttribute("slot")??"").filter(name=>/^day-\d{4}-\d{2}-\d{2}$/.test(name)))]}observeDaySlots(){const Observer=this.ownerDocument.defaultView?.MutationObserver;this.daySlotObserver||!Observer||(this.daySlotObserver=new Observer(()=>{this.daySlotNames().join(" ")!==this.renderedDaySlots&&this.requestUpdate()}),this.daySlotObserver.observe(this,{childList:!0,subtree:!0,attributeFilter:["slot"]}))}clear(){!this.value||this.liveDisabled||this.readonly||(this.touched=!0,this._appliedPreset=void 0,this.value="",this.inputRelayedSinceCommit=!1,dispatchNativeInputEvent(this,{inputType:"deleteContentBackward"}),this.emit("lr-input",{value:""}),dispatchNativeEvent(this,"change"),this.emit("lr-change",{value:""}),this.emit("lr-clear"))}syncInteractionListeners(){const requested=new Set((Array.isArray(this.assumeInteractionOn)?this.assumeInteractionOn:[]).filter(name=>typeof name=="string"&&name.length>0));for(const[name,listener]of this.interactionListeners)requested.has(name)||(this.removeEventListener(name,listener),this.interactionListeners.delete(name));for(const name of requested){if(this.interactionListeners.has(name))continue;const listener=()=>{this.touched=!0,this.syncCustomStates()};this.addEventListener(name,listener),this.interactionListeners.set(name,listener)}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}syncCustomStates(){setCustomState(this.internals,"blank",this.value===""),setCustomState(this.internals,"disabled",this.effectiveDisabled),setCustomState(this.internals,"open",this.open),setCustomState(this.internals,"range",this.mode==="range")}disconnectedCallback(){this.popupHidden=!0,this.daySlotObserver?.disconnect(),this.daySlotObserver=void 0,this.externalDescription?.release(),this.externalDescription=void 0,this.popupController.cancel(),this.cleanupFn?.(),this.cleanupFn=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindVisibilityListener(),this.popupController.unbindPointer(),this.disconnectValidatorAttributeObserver(),this.restorePopupFocusOnClose=!1;for(const[name,listener]of this.interactionListeners)this.removeEventListener(name,listener);this.interactionListeners.clear(),this.enterCommittedText=null,this.inputRelayedSinceCommit=!1,this.open=!1,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.externalDescription?.release(),this.externalDescription=void 0,this.syncExternalDescription(),this.cleanupFn?.(),this.cleanupFn=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindVisibilityListener(),this.popupController.unbindPointer(),this.disconnectValidatorAttributeObserver()}syncExternalDescription(){if(!this.isConnected)return;const input=this.renderRoot?.querySelector("input")??null;this.externalDescription?this.externalDescription.update(input):this.externalDescription=acquireNativeControlDescription(this,input,()=>this.localDescriptionIds)}updated(changed){if(super.updated(changed),this.syncExternalDescription(),(changed.has("disabledDates")||changed.has("disabledDaysOfWeek")||changed.has("isDateDisabled")||changed.has("minRange")||changed.has("maxRange")||changed.has("today")||changed.has("validators"))&&this.updateValidity(),(changed.has("open")||this.open&&(changed.has("placement")||changed.has("distance")))&&(this.cleanupFn?.(),this.cleanupFn=void 0,this.open&&this.isConnected)){const anchor=this.renderRoot.querySelector('[part="input-wrapper"]'),popup=this.renderRoot.querySelector('[part="popup"]');anchor&&popup&&(this.cleanupFn=place(anchor,popup,{placement:normalizeDateInputPlacement(this.placement),offset:finiteNumber(this.distance,0),strategy:resolveEffectivePositioningStrategy(this,void 0,"fixed")}),this.watchPopupPlacement(this.cleanupFn))}if(changed.has("open")){if(this.open&&this.isConnected)this.renderRoot.querySelector('[part="popup"]')&&(this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="popup"]'),onEscape:()=>{this.hide(!0)}}));else if(!this.open){const popup=this.renderRoot.querySelector('[part="popup"]'),focusWasInsidePopup=popup!==null&&composedContains(popup,deepActiveElement(this.ownerDocument));this.overlayHandle?.deactivate({restoreFocus:this.restorePopupFocusOnClose||focusWasInsidePopup}),this.overlayHandle=void 0,this.restorePopupFocusOnClose=!1}}changed.has("assumeInteractionOn")&&this.syncInteractionListeners(),changed.has("validators")&&this.syncValidatorAttributeObserver(),this.syncCustomStates(),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("mode")||changed.has("min")||changed.has("max")||changed.has("readonly")||changed.has("disablePast")||changed.has("disableFuture")||changed.has("disabledDates")||changed.has("disabledDaysOfWeek")||changed.has("minRange")||changed.has("maxRange")||changed.has("validators")||changed.has("typedBadInput")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid)}commitTypedValue(next){this.committingTypedText=!0;try{this.value=next}finally{this.committingTypedText=!1}}applyTypedText(raw){this.enterCommittedText=null;const trimmed=raw.trim();if(!trimmed)return this.value!==""&&(this._appliedPreset=void 0),this.commitTypedValue(""),!0;const parsed=this.mode==="range"?this.parseRangeText(trimmed):this.parseSingleText(trimmed);return parsed?(parsed!==this.value&&(this._appliedPreset=void 0),this.commitTypedValue(parsed),!0):(this.inputElement&&(this.inputElement.value=this.displayText),this.setTypedBadInput(!0),this.updateValidity(),!1)}commitInputChange(raw,source){if(this.enterCommittedText!==null&&(raw===this.enterCommittedText||raw===this.displayText))return;if(this.enterCommittedText=null,this.applyTypedText(raw)){const value=this.value;this.inputRelayedSinceCommit||(dispatchNativeInputEvent(this,{inputType:"insertReplacementText"}),this.emit("lr-input",{value})),this.inputRelayedSinceCommit=!1,source?relayNativeEvent(this,source):dispatchNativeEvent(this,"change"),this.emit("lr-change",{value})}else this.inputRelayedSinceCommit=!1}numericDate(groups){if(groups.length!==3)return null;const order=groups[0].length===4?["year","month","day"]:localeDateOrder(this.effectiveLocale,"gregory"),fields={};return order.forEach((type,index)=>{fields[type]=groups[index]}),dateFromFields(fields)}parseOneDate(raw){const text=normalizeLocalizedDateText(raw,this.effectiveLocale),patterns=localeDatePatterns(this.effectiveLocale),own=matchDatePattern(patterns.single,text);if(own)return own[0];if(/^\d{4}-\d{2}-\d{2}$/.test(text))return parseISO(text);const groups=text.match(/\d+/g)??[];if(!hasForeignLetters(text,patterns.letters))return this.numericDate(groups);if(groups.length===3)return null;const timestamp=Date.parse(text);return Number.isNaN(timestamp)?null:new Date(timestamp)}parseSingleText(raw){const parsed=this.parseOneDate(raw);return parsed?formatISO(parsed):null}localizedRangeSeparator(){const formatter=dateTimeFormat(this.effectiveLocale,{year:"numeric",month:"numeric",day:"numeric"});try{const parts=formatter.formatRangeToParts(localDate(2026,0,2),localDate(2026,0,3)),firstEnd=parts.findIndex(part=>part.source==="endRange");let lastStart=-1;for(let index=0;index<firstEnd;index++)parts[index]?.source==="startRange"&&(lastStart=index);const separator=parts.slice(lastStart+1,firstEnd).map(part=>part.value).join("");return normalizeLocalizedDateText(separator,this.effectiveLocale)||"–"}catch{return"–"}}parseRangeText(raw){if(raw=normalizeLocalizedDateText(raw,this.effectiveLocale),raw===normalizeLocalizedDateText(this.displayText,this.effectiveLocale)&&this.value.includes("/"))return this.normalizeCommittedValue(this.value);if(/^\d{4}-\d{2}-\d{2}\/\d{4}-\d{2}-\d{2}$/.test(raw)){const[a,b]=raw.split("/"),from2=parseISO(a),to2=parseISO(b);return!from2||!to2?null:from2<=to2?raw:`${b}/${a}`}const patterns=localeDatePatterns(this.effectiveLocale);let pair=null;for(const pattern of[...patterns.ranges,patterns.single])pair??=matchDatePattern(pattern,raw);if(!pair){const groups=raw.match(/\d+/g)??[];if(hasForeignLetters(raw,patterns.letters)){const separator=this.localizedRangeSeparator(),idx=raw.indexOf(separator);if(idx===-1)return null;const from2=this.parseOneDate(raw.slice(0,idx).trim()),to2=this.parseOneDate(raw.slice(idx+separator.length).trim());pair=from2&&to2?[from2,to2]:null}else{if(groups.length!==6)return null;const from2=this.numericDate(groups.slice(0,3)),to2=this.numericDate(groups.slice(3));pair=from2&&to2?[from2,to2]:null}}if(!pair)return null;const[from,to]=pair[0]<=pair[1]?pair:[pair[1],pair[0]],start=formatISO(from),end=formatISO(to);return start&&end?`${start}/${end}`:null}click(){this.liveDisabled||this.inputElement?.click()}focus(options){this.liveDisabled||this.inputElement?.focus(options)}blur(){this.inputElement?.blur()}select(){this.inputElement?.select()}setSelectionRange(start,end,direction){this.inputElement?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputElement;input&&(setNativeRangeText(input,replacement,start,end,selectMode),this.applyTypedText(input.value))}formStateRestoreCallback(state2,_mode){this.value=typeof state2=="string"?state2:""}formResetCallback(){super.formResetCallback(),this.valueReplaced(),this.touched=!1,this._appliedPreset=void 0}formDisabledCallback(disabled){super.formDisabledCallback(disabled),disabled&&this.forceClose(),this.syncCustomStates()}render(){const hasValue=this.value.length>0,hasHint=this.withHint||this.hasHintSlot||(this.hint??"").length>0,hasError=this.hasErrorSlot||(this.errorText??"").length>0,hasLabel=this.withLabel||this.hasLabelSlot||(this.label??"").length>0,invalid=hasError||this.touched&&!this.internals.validity.valid,describedBy=this.localDescriptionIds=[hasError?"date-input-error":"",hasHint?"date-input-hint":""].filter(Boolean).join(" "),dynamicDaySlots=this.daySlotNames();return this.renderedDaySlots=dynamicDaySlots.join(" "),html`
2
2
  <div part="date-input">
3
3
  <div part="base">
4
4
  <div part="form-control">
@@ -46,7 +46,8 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from
46
46
  * renders no glyph unless a matching library is registered, including through
47
47
  * `registerIconLibrary('default', { resolver })`.
48
48
  *
49
- * A safe `href` switches the interactive root to a native anchor. `rel` is independently
49
+ * A safe `href` (`http:`/`https:`/`blob:`/`mailto:`/`tel:`/`sms:`/relative, see
50
+ * `safeActionLinkHref`) switches the interactive root to a native anchor. `rel` is independently
50
51
  * settable (no default); `opener` is always stripped and any `target` force-adds the
51
52
  * non-removable `noopener noreferrer` guard. `download` narrows URL validation to downloadable
52
53
  * schemes. A disabled link keeps the anchor anatomy but removes `href`, so it cannot navigate.
@@ -156,7 +157,8 @@ get name():string;set name(next:string|undefined);
156
157
  library?:string;
157
158
  /** Remote SVG URL forwarded to the nested `<lr-icon>` and handled by its guarded loader.*/
158
159
  src?:string;accessibleLabel:string;private triggerHasPopup;private triggerKeyShortcuts;private triggerExpanded;private triggerControls;private triggerDescribedBy;private triggerPressed;private triggerCurrent;label:string;
159
- /** Safe link URL. When valid, the native root is an anchor rather than a button.*/
160
+ /** Safe link URL (`http:`/`https:`/`blob:`/`mailto:`/`tel:`/`sms:`/relative). When valid, the
161
+ * native root is an anchor rather than a button; `download` drops the three handoff schemes. */
160
162
  href?:string;
161
163
  /** Native anchor target. A non-empty target always derives a safe `rel`.*/
162
164
  target?:string;
@@ -1,8 +1,8 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{syncAriaControlsElements,acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{styles}from"./icon-button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{resolveGuardedRel}from"../../../internal/link-rel.js";import{safeDownloadHref,safeLinkHref}from"../../../internal/safe-url.js";import{isUnsafeSvgCloneAttribute,isUnsafeSvgCloneElement}from"../../../internal/safe-svg.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{LYRA_DEFAULT_iconButtonLabel}from"../../../internal/default-strings/forms.generated.js";const BARE_SVG_GEOMETRY_TAGS=new Set(["path","circle","rect","line","polygon","polyline","ellipse","g","use"]),SVG_NAMESPACE="http://www.w3.org/2000/svg";function needsSvgNamespaceFallback(node){return BARE_SVG_GEOMETRY_TAGS.has(node.localName)&&node.namespaceURI!==SVG_NAMESPACE}function cloneToSvgNamespace(node){if(node.localName.includes("-")||isUnsafeSvgCloneElement(node.localName))return null;const copy=node.ownerDocument.createElementNS(SVG_NAMESPACE,node.localName);for(const attribute of node.attributes)isUnsafeSvgCloneAttribute(attribute.name,attribute.value,node.localName)||copy.setAttribute(attribute.name==="xlink:href"?"href":attribute.name,attribute.value);for(const child of node.childNodes)if(child.nodeType===3)copy.append(child.cloneNode(!0));else if(child.nodeType===1){const childCopy=cloneToSvgNamespace(child);childCopy&&copy.append(childCopy)}return copy}function namesControl(nodes){for(const node of nodes){if(node.nodeType===3){if(node.textContent?.trim())return!0;continue}const el=node;if(!(el.nodeType!==1||el.hasAttribute("hidden")||el.getAttribute("aria-hidden")==="true")&&(el.getAttribute("aria-label")?.trim()||el.getAttribute("alt")?.trim()||namesControl((el.shadowRoot??el).childNodes)))return!0}return!1}class LyraIconButton extends LyraElement{constructor(){super(...arguments),this._disabled=!1,this.toolbarAction=this.createToolbarAction(),this.icon="",this.accessibleLabel="",this.triggerHasPopup=null,this.triggerKeyShortcuts=null,this.triggerExpanded=null,this.triggerControls=null,this.triggerDescribedBy=null,this.triggerPressed=null,this.triggerCurrent=null,this.label="",this.hasBareGeometry=!1,this.contentNamed=!1,this.onFocus=event=>{relayNativeEvent(this,event)},this.onBlur=event=>{relayNativeEvent(this,event)},this.onSlotChange=e=>{this.onSlotChangeFromSlot(e.target)}}static{this.defaultStrings={...super.defaultStrings,iconButtonLabel:LYRA_DEFAULT_iconButtonLabel}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this._disabled}get name(){return this.icon}set name(next){this.icon=next??""}get resolvedRel(){return resolveGuardedRel(this.rel,this.target)}get control(){return this.baseEl??null}click(){this.effectiveDisabled||this.baseEl?.click()}focus(options){this.effectiveDisabled||this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}onSlotChangeFromSlot(slot){const assigned=slot.assignedNodes({flatten:!0});this.hasBareGeometry=assigned.some(node=>node.nodeType===1&&needsSvgNamespaceFallback(node)),this.contentNamed=namesControl(assigned)}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements()}firstUpdated(changed){super.firstUpdated(changed);const slot=this.slotEl;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.onSlotChangeFromSlot(s))})}disconnectedCallback(){this.toolbarAction.releaseTabIndex?.(),this.releaseExternalDescription(),super.disconnectedCallback()}adoptedCallback(){this.toolbarAction.releaseTabIndex?.(),super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed),this.seedFirstRenderState(()=>{this.contentNamed=namesControl(this.childNodes)})}updated(changed){super.updated(changed),this.syncFallbackGeometry(),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements()}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby"),this.externalLabelLease?this.externalLabelLease.update(target):this.externalLabelLease=acquireResolvedAriaRelationship(this,target,"aria-labelledby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0,this.externalLabelLease?.release(),this.externalLabelLease=void 0}getToolbarActions(){return[this.toolbarAction]}createToolbarAction(){const host=this;let leasedTrigger,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const target=leasedTrigger;target&&target.getAttribute("tabindex")===lastManagedTabIndex&&(authoredTabIndex===null?target.removeAttribute("tabindex"):target.setAttribute("tabindex",authoredTabIndex)),leasedTrigger=void 0,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return{id:"icon-button",get disabled(){return host.effectiveDisabled||!host.baseEl},focus(options){host.focus(options)},setTabIndex(tabIndex){const trigger=host.baseEl;if(!trigger){releaseTabIndex();return}if(leasedTrigger!==trigger&&(releaseTabIndex(),leasedTrigger=trigger,authoredTabIndex=trigger.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&trigger.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}trigger.tabIndex=tabIndex,lastManagedTabIndex=trigger.getAttribute("tabindex")},releaseTabIndex,matchesEventPath(path){const control=host.baseEl;return path.includes(host)||control!=null&&path.includes(control)}}}syncFallbackGeometry(){const svgEl=this.fallbackSvgEl;if(!svgEl)return;svgEl.replaceChildren();const assigned=this.slotEl?.assignedElements({flatten:!0})??[];for(const el of assigned){if(!needsSvgNamespaceFallback(el))continue;const copy=cloneToSvgNamespace(el);copy&&svgEl.append(copy)}}render(){const pressed=["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,label=hostAriaLabel(this)??(this.label||(this.contentNamed?nothing:this.localize("iconButtonLabel"))),content=html`${this.icon||this.src?html`<lr-icon
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{syncAriaControlsElements,acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{styles}from"./icon-button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{resolveGuardedRel}from"../../../internal/link-rel.js";import{safeActionLinkHref,safeDownloadHref}from"../../../internal/safe-url.js";import{isUnsafeSvgCloneAttribute,isUnsafeSvgCloneElement}from"../../../internal/safe-svg.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{LYRA_DEFAULT_iconButtonLabel}from"../../../internal/default-strings/forms.generated.js";const BARE_SVG_GEOMETRY_TAGS=new Set(["path","circle","rect","line","polygon","polyline","ellipse","g","use"]),SVG_NAMESPACE="http://www.w3.org/2000/svg";function needsSvgNamespaceFallback(node){return BARE_SVG_GEOMETRY_TAGS.has(node.localName)&&node.namespaceURI!==SVG_NAMESPACE}function cloneToSvgNamespace(node){if(node.localName.includes("-")||isUnsafeSvgCloneElement(node.localName))return null;const copy=node.ownerDocument.createElementNS(SVG_NAMESPACE,node.localName);for(const attribute of node.attributes)isUnsafeSvgCloneAttribute(attribute.name,attribute.value,node.localName)||copy.setAttribute(attribute.name==="xlink:href"?"href":attribute.name,attribute.value);for(const child of node.childNodes)if(child.nodeType===3)copy.append(child.cloneNode(!0));else if(child.nodeType===1){const childCopy=cloneToSvgNamespace(child);childCopy&&copy.append(childCopy)}return copy}function namesControl(nodes){for(const node of nodes){if(node.nodeType===3){if(node.textContent?.trim())return!0;continue}const el=node;if(!(el.nodeType!==1||el.hasAttribute("hidden")||el.getAttribute("aria-hidden")==="true")&&(el.getAttribute("aria-label")?.trim()||el.getAttribute("alt")?.trim()||namesControl((el.shadowRoot??el).childNodes)))return!0}return!1}class LyraIconButton extends LyraElement{constructor(){super(...arguments),this._disabled=!1,this.toolbarAction=this.createToolbarAction(),this.icon="",this.accessibleLabel="",this.triggerHasPopup=null,this.triggerKeyShortcuts=null,this.triggerExpanded=null,this.triggerControls=null,this.triggerDescribedBy=null,this.triggerPressed=null,this.triggerCurrent=null,this.label="",this.hasBareGeometry=!1,this.contentNamed=!1,this.onFocus=event=>{relayNativeEvent(this,event)},this.onBlur=event=>{relayNativeEvent(this,event)},this.onSlotChange=e=>{this.onSlotChangeFromSlot(e.target)}}static{this.defaultStrings={...super.defaultStrings,iconButtonLabel:LYRA_DEFAULT_iconButtonLabel}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this._disabled}get name(){return this.icon}set name(next){this.icon=next??""}get resolvedRel(){return resolveGuardedRel(this.rel,this.target)}get control(){return this.baseEl??null}click(){this.effectiveDisabled||this.baseEl?.click()}focus(options){this.effectiveDisabled||this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}onSlotChangeFromSlot(slot){const assigned=slot.assignedNodes({flatten:!0});this.hasBareGeometry=assigned.some(node=>node.nodeType===1&&needsSvgNamespaceFallback(node)),this.contentNamed=namesControl(assigned)}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements()}firstUpdated(changed){super.firstUpdated(changed);const slot=this.slotEl;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.onSlotChangeFromSlot(s))})}disconnectedCallback(){this.toolbarAction.releaseTabIndex?.(),this.releaseExternalDescription(),super.disconnectedCallback()}adoptedCallback(){this.toolbarAction.releaseTabIndex?.(),super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed),this.seedFirstRenderState(()=>{this.contentNamed=namesControl(this.childNodes)})}updated(changed){super.updated(changed),this.syncFallbackGeometry(),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements()}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby"),this.externalLabelLease?this.externalLabelLease.update(target):this.externalLabelLease=acquireResolvedAriaRelationship(this,target,"aria-labelledby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0,this.externalLabelLease?.release(),this.externalLabelLease=void 0}getToolbarActions(){return[this.toolbarAction]}createToolbarAction(){const host=this;let leasedTrigger,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const target=leasedTrigger;target&&target.getAttribute("tabindex")===lastManagedTabIndex&&(authoredTabIndex===null?target.removeAttribute("tabindex"):target.setAttribute("tabindex",authoredTabIndex)),leasedTrigger=void 0,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return{id:"icon-button",get disabled(){return host.effectiveDisabled||!host.baseEl},focus(options){host.focus(options)},setTabIndex(tabIndex){const trigger=host.baseEl;if(!trigger){releaseTabIndex();return}if(leasedTrigger!==trigger&&(releaseTabIndex(),leasedTrigger=trigger,authoredTabIndex=trigger.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&trigger.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}trigger.tabIndex=tabIndex,lastManagedTabIndex=trigger.getAttribute("tabindex")},releaseTabIndex,matchesEventPath(path){const control=host.baseEl;return path.includes(host)||control!=null&&path.includes(control)}}}syncFallbackGeometry(){const svgEl=this.fallbackSvgEl;if(!svgEl)return;svgEl.replaceChildren();const assigned=this.slotEl?.assignedElements({flatten:!0})??[];for(const el of assigned){if(!needsSvgNamespaceFallback(el))continue;const copy=cloneToSvgNamespace(el);copy&&svgEl.append(copy)}}render(){const pressed=["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,label=hostAriaLabel(this)??(this.label||(this.contentNamed?nothing:this.localize("iconButtonLabel"))),content=html`${this.icon||this.src?html`<lr-icon
2
2
  name=${this.icon||nothing}
3
3
  library=${this.library||nothing}
4
4
  src=${this.src||nothing}
5
- ></lr-icon>`:nothing}${this.hasBareGeometry?html`<svg part="fallback" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"></svg>`:nothing}<slot @slotchange=${this.onSlotChange}></slot>`,hasDownload=this.download!==void 0,href=hasDownload?safeDownloadHref(this.href):safeLinkHref(this.href);if(href){const disabled=this.effectiveDisabled;return html`<a
5
+ ></lr-icon>`:nothing}${this.hasBareGeometry?html`<svg part="fallback" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"></svg>`:nothing}<slot @slotchange=${this.onSlotChange}></slot>`,hasDownload=this.download!==void 0,href=hasDownload?safeDownloadHref(this.href):safeActionLinkHref(this.href);if(href){const disabled=this.effectiveDisabled;return html`<a
6
6
  part="base button"
7
7
  href=${disabled?nothing:href}
8
8
  target=${this.target||nothing}