@pagehub/sdk 0.1.5 → 0.1.6

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 (141) hide show
  1. package/README.md +1 -1
  2. package/dist/chrome/viewport/Viewport/hooks/usePageLoadIndicator.d.ts +2 -2
  3. package/dist/chrome/viewport/design-system/hooks/useDesignSystem.d.ts +2 -2
  4. package/dist/chrome/viewport/design-system/hooks/usePaletteState.d.ts +2 -2
  5. package/dist/chunks/ActionEditorPanel-9v50QUwu.js +89 -0
  6. package/dist/chunks/ActionInput-CTt7sOs6.js +929 -0
  7. package/dist/chunks/ActionsAddPicker-BeTPUUor.js +51 -0
  8. package/dist/chunks/ActionsInput-D0h-zLYj.js +174 -0
  9. package/dist/chunks/AnchoredPopover-CckPTxXu.js +2676 -0
  10. package/dist/chunks/AnimationEditorPanel-CXNmsTqV.js +26 -0
  11. package/dist/chunks/AnimationsInput-Djyz0uXG.js +292 -0
  12. package/dist/chunks/AnimationsInputPopover-B2-oNebx.js +71 -0
  13. package/dist/chunks/AnimationsPanel-DungA9qb.js +25 -0
  14. package/dist/chunks/Audio.render-CsR69fZ9.js +22 -0
  15. package/dist/chunks/AudioMainTab-BljM2NMQ.js +70 -0
  16. package/dist/chunks/BackdropEditorPanel-CA2k-6SR.js +26 -0
  17. package/dist/chunks/BackgroundImageInputPopover-vB_217Ig.js +94 -0
  18. package/dist/chunks/BackgroundImagePanel-BvMhF9eU.js +100 -0
  19. package/dist/chunks/BackgroundMainTab-CI4c5DEF.js +10 -0
  20. package/dist/chunks/BundleRowPanel-BcYfyfGQ.js +33 -0
  21. package/dist/chunks/ButtonMainTab-Civy_DoA.js +43 -0
  22. package/dist/chunks/CSSEditorInput-C1ITwAh3.js +73 -0
  23. package/dist/chunks/ClassNameInput-Ce0fGQES.js +720 -0
  24. package/dist/chunks/CodeEditor-axBXmPH8.js +33370 -0
  25. package/dist/chunks/ColorInput-BSfMNt86.js +187 -0
  26. package/dist/chunks/ColorPanel-DOLrT-gS.js +562 -0
  27. package/dist/chunks/ComponentImportExportPanel-DVcnGhGx.js +161 -0
  28. package/dist/chunks/ComponentImportExportPopover-BY1_oxU8.js +26 -0
  29. package/dist/chunks/ConditionEditorPanel-DLbqYaSF.js +43 -0
  30. package/dist/chunks/ConditionsAddPicker-SsHJlc1E.js +54 -0
  31. package/dist/chunks/ConditionsInput-B_5Nge8o.js +474 -0
  32. package/dist/chunks/ContainerMainTab-kkktm1Ns.js +1107 -0
  33. package/dist/chunks/ContainerOverflowSectionPanel-ibKXf-1N.js +120 -0
  34. package/dist/chunks/ContainerOverflowSectionPopover-CRQ9EPsn.js +24 -0
  35. package/dist/chunks/ContainerPaddingOverlay-Cd3xOv-S.js +340 -0
  36. package/dist/chunks/ContainerScrollEffectSection-Dbztqdnr.js +123 -0
  37. package/dist/chunks/ContainerStateSection-DY_gjBJL.js +478 -0
  38. package/dist/chunks/ConversionFields-Bpfl-SGP.js +135 -0
  39. package/dist/chunks/CraftListEditor-_TIy1ogW.js +73 -0
  40. package/dist/chunks/CreateTokenDialog-DNWtWqJd.js +147 -0
  41. package/dist/chunks/Data.render-DTmaqSyz.js +10 -0
  42. package/dist/chunks/DataAttributesPanel-mYhisO_O.js +125 -0
  43. package/dist/chunks/DataMainTab-Batm515E.js +23 -0
  44. package/dist/chunks/DataSourceSectionSlot-BKoO6Vxn.js +10 -0
  45. package/dist/chunks/EditorEmptyLeafHintView-D3E3UN_0.js +78 -0
  46. package/dist/chunks/EffectRowInputPopover-CYhfjFwJ.js +323 -0
  47. package/dist/chunks/EffectsClassInput-Yujuchwy.js +315 -0
  48. package/dist/chunks/Embed.render-BgKpUV8n.js +17 -0
  49. package/dist/chunks/EmbedMainTab-d_-Bnkug.js +225 -0
  50. package/dist/chunks/FilterEditorPanel-CRa0IpLr.js +26 -0
  51. package/dist/chunks/FlexDirectionInput-C5gYjk5W.js +78 -0
  52. package/dist/chunks/FloatingPanel-DJP5Vhua.js +553 -0
  53. package/dist/chunks/FontFamilyInput-CVNnVylt.js +111 -0
  54. package/dist/chunks/Form.render-6GjcmL2u.js +54 -0
  55. package/dist/chunks/FormElement.render-DWrG-2ID.js +36 -0
  56. package/dist/chunks/FormElementMainTab-DSbF3F6e.js +470 -0
  57. package/dist/chunks/FormMainTab-SHny1HxF.js +240 -0
  58. package/dist/chunks/GradientInputPopover-1K6O9jBq.js +103 -0
  59. package/dist/chunks/GradientPanel-DSRQKkaB.js +194 -0
  60. package/dist/chunks/HTMLCodeInput-CCe4Bj5z.js +69 -0
  61. package/dist/chunks/HandlerEditorPanel-DiOXobsl.js +93 -0
  62. package/dist/chunks/HandlersAddPicker-DWTgjKgo.js +101 -0
  63. package/dist/chunks/HandlersInput-p49STTn8.js +132 -0
  64. package/dist/chunks/IconDialogInput-C-81_L2n.js +105 -0
  65. package/dist/chunks/IconInput-D2Gy7Hvf.js +182 -0
  66. package/dist/chunks/IconMainTab-CNrVjDWP.js +26 -0
  67. package/dist/chunks/IconPickerPanel-BjNOlCh6.js +670 -0
  68. package/dist/chunks/ImageMainTab-C4O7RjX0.js +66 -0
  69. package/dist/chunks/ImageSettingsPanel-dvOmGg3C.js +485 -0
  70. package/dist/chunks/LayoutPresetPanel-CNAVAcvw.js +81 -0
  71. package/dist/chunks/LayoutPresetSlot-BqMTdE33.js +16 -0
  72. package/dist/chunks/LinkMainTab-BfFZx0AU.js +13 -0
  73. package/dist/chunks/ListEditor-mD-CmRNE.js +178 -0
  74. package/dist/chunks/Map.render-DFkmncHz.js +82 -0
  75. package/dist/chunks/MapLeaflet-DOfmZ3Pk.js +6588 -0
  76. package/dist/chunks/MapMainTab-CxI7IS1_.js +165 -0
  77. package/dist/chunks/MapPoint.render-0OAfCZTp.js +16 -0
  78. package/dist/chunks/MapPointMainTab-CmLcaSR5.js +60 -0
  79. package/dist/chunks/MediaInput-DHs3D8TJ.js +672 -0
  80. package/dist/chunks/MediaManagerModal-Dc5PK3dn.js +240 -0
  81. package/dist/chunks/MiniPreviewTile-B4zxTj9Y.js +32 -0
  82. package/dist/chunks/ModifierChipList-CwsWklih.js +33 -0
  83. package/dist/chunks/ModifiersAddPicker-D-vSYw7O.js +74 -0
  84. package/dist/chunks/ModifiersPickerPanel-CTefidBx.js +243 -0
  85. package/dist/chunks/NodeAiContextInputPopover-D5bn5o_T.js +66 -0
  86. package/dist/chunks/NodeAiContextPanel-Bx4rcjiM.js +81 -0
  87. package/dist/chunks/NumberSettingsPanel-DASi_l6V.js +56 -0
  88. package/dist/chunks/PageSettingsModal-D6o450IR.js +2678 -0
  89. package/dist/chunks/PatternInputPopover-qMWBv_nl.js +100 -0
  90. package/dist/chunks/PatternPanel-D2fgWDd-.js +352 -0
  91. package/dist/chunks/PeekTargetButton-ClrJX7zh.js +26 -0
  92. package/dist/chunks/PermissionsSection-DwobrV40.js +82 -0
  93. package/dist/chunks/PresetAddChildList-D6a0xdt8.js +35 -0
  94. package/dist/chunks/PropertiesInput-9O39ngbb.js +125 -0
  95. package/dist/chunks/PropertiesPanel-DO0RlalO.js +76 -0
  96. package/dist/chunks/SaveModifierPanel-B6mjKyrT.js +130 -0
  97. package/dist/chunks/ScrollEffectEditorPanel-CllGUhui.js +26 -0
  98. package/dist/chunks/SearchInput-DRUztbM0.js +76 -0
  99. package/dist/chunks/SearchableMenuPopover-DZKVXiEl.js +1251 -0
  100. package/dist/chunks/SlotRenderer-CaLf_2_C.js +38 -0
  101. package/dist/chunks/StateBindingEditorPanel-DKdcG5py.js +101 -0
  102. package/dist/chunks/StateBindingsAddPicker-DxMNAWAD.js +91 -0
  103. package/dist/chunks/StateBindingsInput-iWiqvAVB.js +103 -0
  104. package/dist/chunks/TailwindInput-660FZtyK.js +24 -0
  105. package/dist/chunks/TextEditor-B2O7DlN8.js +22032 -0
  106. package/dist/chunks/TextMainTab-B5udsXsk.js +260 -0
  107. package/dist/chunks/TextStyleEditorPanel-GRNPGzUL.js +381 -0
  108. package/dist/chunks/TextStylePickerPanel-l108SmGQ.js +140 -0
  109. package/dist/chunks/TextareaSettingsPanel-C1rQuF1O.js +50 -0
  110. package/dist/chunks/TokenPicker-Q0LToF_p.js +291 -0
  111. package/dist/chunks/ToolbarDashedButton-DbUxGmDg.js +23 -0
  112. package/dist/chunks/TransformEditorPanel-BGwyznZ6.js +26 -0
  113. package/dist/chunks/TransitionEditorPanel-BSvk58Ow.js +26 -0
  114. package/dist/chunks/TypographyPresetInput-DqnGSgR2.js +296 -0
  115. package/dist/chunks/ValidationPanel-CmA9SfoF.js +56 -0
  116. package/dist/chunks/Video.render-Dg6xvis4.js +21 -0
  117. package/dist/chunks/VideoMainTab-v5UFhUm-.js +174 -0
  118. package/dist/chunks/YouTube.esm-EbHnLU1Z.js +744 -0
  119. package/dist/chunks/dialogAtoms-CeQ2G05l.js +59 -0
  120. package/dist/chunks/extends-hS2Bh-Yp.js +12 -0
  121. package/dist/chunks/formatStorage-C3o2s3dk.js +22 -0
  122. package/dist/chunks/googleFonts-Dj4AntNi.js +323 -0
  123. package/dist/chunks/helpers-Cll72tMn.js +18 -0
  124. package/dist/chunks/index-B-GJd039.js +2875 -0
  125. package/dist/chunks/index-C66dAl3Q.js +32177 -0
  126. package/dist/chunks/index.esm-mqFx3NOs.js +644 -0
  127. package/dist/chunks/popoverOpenRequestAtom-hBS_siXv.js +22 -0
  128. package/dist/chunks/propertyRegistry-CMhVNOgl.js +38 -0
  129. package/dist/chunks/resolveAnchorsViaCraft-Cixm6ZyJ.js +31 -0
  130. package/dist/chunks/toolboxUtils-DjTMslSn.js +370 -0
  131. package/dist/chunks/uiPrimitives-BtohldWg.js +15 -0
  132. package/dist/chunks/use-event-listener-DO3Sk7g0.js +15 -0
  133. package/dist/chunks/useElementPicker-DoNuXNMQ.js +41 -0
  134. package/dist/chunks/useLayoutPreset-wOMV5YnO.js +528 -0
  135. package/dist/chunks/useMediaManager-CmKDbFfw.js +4629 -0
  136. package/dist/chunks/usePopoverAutoOpen-CxIjt0ez.js +25 -0
  137. package/dist/chunks/usePopoverPosition-83Vti7Aw.js +15 -0
  138. package/dist/render/static/index.js +9 -0
  139. package/package.json +22 -13
  140. package/dist/pagehub-viewer.umd.cjs +0 -574
  141. package/dist/pagehub.umd.cjs +0 -1130
@@ -0,0 +1,1251 @@
1
+ import { jsxs as re, Fragment as Be, jsx as G } from "react/jsx-runtime";
2
+ import * as Oe from "react";
3
+ import W, { useRef as J, useEffect as Ue, useContext as Ie, useMemo as se, createContext as we, useId as be, useState as ae, useCallback as X, Fragment as He, forwardRef as lt, useImperativeHandle as rt } from "react";
4
+ import { ea as $e, a$ as _, eb as Ke, bq as Q, b2 as at, bN as ut, ec as ct, b5 as dt, b6 as qe, ed as ht, ee as pt, ef as fe, b7 as ue, eg as D, eh as Pe, ei as ft, ej as mt, ba as bt, ek as vt, bb as ve, el as gt, bd as ye, be as xt, bc as L, em as St, bM as B, en as Me, eo as Ot, bf as Ge, bg as Xe, bi as ge, bk as Te, bl as xe, bm as Et, bn as yt, bo as Ct, bp as Ae, br as It, bs as wt, bt as Ee, bu as Mt, bv as Tt, ep as Rt, bz as $t, bA as Fe, eq as _e, bC as Pt, er as At, bF as Ft, es as _t, et as kt, eu as zt, ev as Dt, ew as Lt, ex as Nt, ey as Vt, ez as Wt, bH as jt, eA as Bt, bI as Ut, bJ as Ht, eB as Kt, eC as qt, eD as pe, b8 as Gt, eE as Xt, bh as Yt, bj as Jt, bK as ke, dp as Qt, P as Zt, aA as en } from "./index-C66dAl3Q.js";
5
+ import { A as tn } from "./AnchoredPopover-CckPTxXu.js";
6
+ import { flushSync as oe } from "react-dom";
7
+ import { E as nn } from "./use-event-listener-DO3Sk7g0.js";
8
+ function le(t, i, e) {
9
+ let o = e.initialDeps ?? [], n, s = !0;
10
+ function l() {
11
+ var r, u, d;
12
+ let h;
13
+ e.key && ((r = e.debug) != null && r.call(e)) && (h = Date.now());
14
+ const f = t();
15
+ if (!(f.length !== o.length || f.some((c, g) => o[g] !== c)))
16
+ return n;
17
+ o = f;
18
+ let a;
19
+ if (e.key && ((u = e.debug) != null && u.call(e)) && (a = Date.now()), n = i(...f), e.key && ((d = e.debug) != null && d.call(e))) {
20
+ const c = Math.round((Date.now() - h) * 100) / 100, g = Math.round((Date.now() - a) * 100) / 100, x = g / 16, y = (w, C) => {
21
+ for (w = String(w); w.length < C; )
22
+ w = " " + w;
23
+ return w;
24
+ };
25
+ console.info(
26
+ `%c⏱ ${y(g, 5)} /${y(c, 5)} ms`,
27
+ `
28
+ font-size: .6rem;
29
+ font-weight: bold;
30
+ color: hsl(${Math.max(
31
+ 0,
32
+ Math.min(120 - 120 * x, 120)
33
+ )}deg 100% 31%);`,
34
+ e == null ? void 0 : e.key
35
+ );
36
+ }
37
+ return e != null && e.onChange && !(s && e.skipInitialOnChange) && e.onChange(n), s = !1, n;
38
+ }
39
+ return l.updateDeps = (r) => {
40
+ o = r;
41
+ }, l;
42
+ }
43
+ function ze(t, i) {
44
+ if (t === void 0)
45
+ throw new Error("Unexpected undefined");
46
+ return t;
47
+ }
48
+ const on = (t, i) => Math.abs(t - i) < 1.01, sn = (t, i, e) => {
49
+ let o;
50
+ return function(...n) {
51
+ t.clearTimeout(o), o = t.setTimeout(() => i.apply(this, n), e);
52
+ };
53
+ }, De = (t) => {
54
+ const { offsetWidth: i, offsetHeight: e } = t;
55
+ return { width: i, height: e };
56
+ }, ln = (t) => t, rn = (t) => {
57
+ const i = Math.max(t.startIndex - t.overscan, 0), e = Math.min(t.endIndex + t.overscan, t.count - 1), o = [];
58
+ for (let n = i; n <= e; n++)
59
+ o.push(n);
60
+ return o;
61
+ }, an = (t, i) => {
62
+ const e = t.scrollElement;
63
+ if (!e)
64
+ return;
65
+ const o = t.targetWindow;
66
+ if (!o)
67
+ return;
68
+ const n = (l) => {
69
+ const { width: r, height: u } = l;
70
+ i({ width: Math.round(r), height: Math.round(u) });
71
+ };
72
+ if (n(De(e)), !o.ResizeObserver)
73
+ return () => {
74
+ };
75
+ const s = new o.ResizeObserver((l) => {
76
+ const r = () => {
77
+ const u = l[0];
78
+ if (u != null && u.borderBoxSize) {
79
+ const d = u.borderBoxSize[0];
80
+ if (d) {
81
+ n({ width: d.inlineSize, height: d.blockSize });
82
+ return;
83
+ }
84
+ }
85
+ n(De(e));
86
+ };
87
+ t.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
88
+ });
89
+ return s.observe(e, { box: "border-box" }), () => {
90
+ s.unobserve(e);
91
+ };
92
+ }, Le = {
93
+ passive: !0
94
+ }, Ne = typeof window > "u" ? !0 : "onscrollend" in window, un = (t, i) => {
95
+ const e = t.scrollElement;
96
+ if (!e)
97
+ return;
98
+ const o = t.targetWindow;
99
+ if (!o)
100
+ return;
101
+ let n = 0;
102
+ const s = t.options.useScrollendEvent && Ne ? () => {
103
+ } : sn(
104
+ o,
105
+ () => {
106
+ i(n, !1);
107
+ },
108
+ t.options.isScrollingResetDelay
109
+ ), l = (h) => () => {
110
+ const { horizontal: f, isRtl: m } = t.options;
111
+ n = f ? e.scrollLeft * (m && -1 || 1) : e.scrollTop, s(), i(n, h);
112
+ }, r = l(!0), u = l(!1);
113
+ e.addEventListener("scroll", r, Le);
114
+ const d = t.options.useScrollendEvent && Ne;
115
+ return d && e.addEventListener("scrollend", u, Le), () => {
116
+ e.removeEventListener("scroll", r), d && e.removeEventListener("scrollend", u);
117
+ };
118
+ }, cn = (t, i, e) => {
119
+ if (i != null && i.borderBoxSize) {
120
+ const o = i.borderBoxSize[0];
121
+ if (o)
122
+ return Math.round(
123
+ o[e.options.horizontal ? "inlineSize" : "blockSize"]
124
+ );
125
+ }
126
+ return t[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
127
+ }, dn = (t, {
128
+ adjustments: i = 0,
129
+ behavior: e
130
+ }, o) => {
131
+ var n, s;
132
+ const l = t + i;
133
+ (s = (n = o.scrollElement) == null ? void 0 : n.scrollTo) == null || s.call(n, {
134
+ [o.options.horizontal ? "left" : "top"]: l,
135
+ behavior: e
136
+ });
137
+ };
138
+ class hn {
139
+ constructor(i) {
140
+ this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollState = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.now = () => {
141
+ var e, o, n;
142
+ return ((n = (o = (e = this.targetWindow) == null ? void 0 : e.performance) == null ? void 0 : o.now) == null ? void 0 : n.call(o)) ?? Date.now();
143
+ }, this.observer = /* @__PURE__ */ (() => {
144
+ let e = null;
145
+ const o = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((n) => {
146
+ n.forEach((s) => {
147
+ const l = () => {
148
+ const r = s.target, u = this.indexFromElement(r);
149
+ if (!r.isConnected) {
150
+ this.observer.unobserve(r);
151
+ return;
152
+ }
153
+ this.shouldMeasureDuringScroll(u) && this.resizeItem(
154
+ u,
155
+ this.options.measureElement(r, s, this)
156
+ );
157
+ };
158
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
159
+ });
160
+ }));
161
+ return {
162
+ disconnect: () => {
163
+ var n;
164
+ (n = o()) == null || n.disconnect(), e = null;
165
+ },
166
+ observe: (n) => {
167
+ var s;
168
+ return (s = o()) == null ? void 0 : s.observe(n, { box: "border-box" });
169
+ },
170
+ unobserve: (n) => {
171
+ var s;
172
+ return (s = o()) == null ? void 0 : s.unobserve(n);
173
+ }
174
+ };
175
+ })(), this.range = null, this.setOptions = (e) => {
176
+ Object.entries(e).forEach(([o, n]) => {
177
+ typeof n > "u" && delete e[o];
178
+ }), this.options = {
179
+ debug: !1,
180
+ initialOffset: 0,
181
+ overscan: 1,
182
+ paddingStart: 0,
183
+ paddingEnd: 0,
184
+ scrollPaddingStart: 0,
185
+ scrollPaddingEnd: 0,
186
+ horizontal: !1,
187
+ getItemKey: ln,
188
+ rangeExtractor: rn,
189
+ onChange: () => {
190
+ },
191
+ measureElement: cn,
192
+ initialRect: { width: 0, height: 0 },
193
+ scrollMargin: 0,
194
+ gap: 0,
195
+ indexAttribute: "data-index",
196
+ initialMeasurementsCache: [],
197
+ lanes: 1,
198
+ isScrollingResetDelay: 150,
199
+ enabled: !0,
200
+ isRtl: !1,
201
+ useScrollendEvent: !1,
202
+ useAnimationFrameWithResizeObserver: !1,
203
+ laneAssignmentMode: "estimate",
204
+ ...e
205
+ };
206
+ }, this.notify = (e) => {
207
+ var o, n;
208
+ (n = (o = this.options).onChange) == null || n.call(o, this, e);
209
+ }, this.maybeNotify = le(
210
+ () => (this.calculateRange(), [
211
+ this.isScrolling,
212
+ this.range ? this.range.startIndex : null,
213
+ this.range ? this.range.endIndex : null
214
+ ]),
215
+ (e) => {
216
+ this.notify(e);
217
+ },
218
+ {
219
+ key: !1,
220
+ debug: () => this.options.debug,
221
+ initialDeps: [
222
+ this.isScrolling,
223
+ this.range ? this.range.startIndex : null,
224
+ this.range ? this.range.endIndex : null
225
+ ]
226
+ }
227
+ ), this.cleanup = () => {
228
+ this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.rafId != null && this.targetWindow && (this.targetWindow.cancelAnimationFrame(this.rafId), this.rafId = null), this.scrollState = null, this.scrollElement = null, this.targetWindow = null;
229
+ }, this._didMount = () => () => {
230
+ this.cleanup();
231
+ }, this._willUpdate = () => {
232
+ var e;
233
+ const o = this.options.enabled ? this.options.getScrollElement() : null;
234
+ if (this.scrollElement !== o) {
235
+ if (this.cleanup(), !o) {
236
+ this.maybeNotify();
237
+ return;
238
+ }
239
+ this.scrollElement = o, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((n) => {
240
+ this.observer.observe(n);
241
+ }), this.unsubs.push(
242
+ this.options.observeElementRect(this, (n) => {
243
+ this.scrollRect = n, this.maybeNotify();
244
+ })
245
+ ), this.unsubs.push(
246
+ this.options.observeElementOffset(this, (n, s) => {
247
+ this.scrollAdjustments = 0, this.scrollDirection = s ? this.getScrollOffset() < n ? "forward" : "backward" : null, this.scrollOffset = n, this.isScrolling = s, this.scrollState && this.scheduleScrollReconcile(), this.maybeNotify();
248
+ })
249
+ ), this._scrollToOffset(this.getScrollOffset(), {
250
+ adjustments: void 0,
251
+ behavior: void 0
252
+ });
253
+ }
254
+ }, this.rafId = null, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, o) => {
255
+ const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
256
+ for (let l = o - 1; l >= 0; l--) {
257
+ const r = e[l];
258
+ if (n.has(r.lane))
259
+ continue;
260
+ const u = s.get(
261
+ r.lane
262
+ );
263
+ if (u == null || r.end > u.end ? s.set(r.lane, r) : r.end < u.end && n.set(r.lane, !0), n.size === this.options.lanes)
264
+ break;
265
+ }
266
+ return s.size === this.options.lanes ? Array.from(s.values()).sort((l, r) => l.end === r.end ? l.index - r.index : l.end - r.end)[0] : void 0;
267
+ }, this.getMeasurementOptions = le(
268
+ () => [
269
+ this.options.count,
270
+ this.options.paddingStart,
271
+ this.options.scrollMargin,
272
+ this.options.getItemKey,
273
+ this.options.enabled,
274
+ this.options.lanes,
275
+ this.options.laneAssignmentMode
276
+ ],
277
+ (e, o, n, s, l, r, u) => (this.prevLanes !== void 0 && this.prevLanes !== r && (this.lanesChangedFlag = !0), this.prevLanes = r, this.pendingMeasuredCacheIndexes = [], {
278
+ count: e,
279
+ paddingStart: o,
280
+ scrollMargin: n,
281
+ getItemKey: s,
282
+ enabled: l,
283
+ lanes: r,
284
+ laneAssignmentMode: u
285
+ }),
286
+ {
287
+ key: !1
288
+ }
289
+ ), this.getMeasurements = le(
290
+ () => [this.getMeasurementOptions(), this.itemSizeCache],
291
+ ({
292
+ count: e,
293
+ paddingStart: o,
294
+ scrollMargin: n,
295
+ getItemKey: s,
296
+ enabled: l,
297
+ lanes: r,
298
+ laneAssignmentMode: u
299
+ }, d) => {
300
+ if (!l)
301
+ return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
302
+ if (this.laneAssignments.size > e)
303
+ for (const a of this.laneAssignments.keys())
304
+ a >= e && this.laneAssignments.delete(a);
305
+ this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMeasuredCacheIndexes = []), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((a) => {
306
+ this.itemSizeCache.set(a.key, a.size);
307
+ }));
308
+ const h = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
309
+ this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
310
+ const f = this.measurementsCache.slice(0, h), m = new Array(r).fill(
311
+ void 0
312
+ );
313
+ for (let a = 0; a < h; a++) {
314
+ const c = f[a];
315
+ c && (m[c.lane] = a);
316
+ }
317
+ for (let a = h; a < e; a++) {
318
+ const c = s(a), g = this.laneAssignments.get(a);
319
+ let x, y;
320
+ const w = u === "estimate" || d.has(c);
321
+ if (g !== void 0 && this.options.lanes > 1) {
322
+ x = g;
323
+ const b = m[x], A = b !== void 0 ? f[b] : void 0;
324
+ y = A ? A.end + this.options.gap : o + n;
325
+ } else {
326
+ const b = this.options.lanes === 1 ? f[a - 1] : this.getFurthestMeasurement(f, a);
327
+ y = b ? b.end + this.options.gap : o + n, x = b ? b.lane : a % this.options.lanes, this.options.lanes > 1 && w && this.laneAssignments.set(a, x);
328
+ }
329
+ const C = d.get(c), M = typeof C == "number" ? C : this.options.estimateSize(a), T = y + M;
330
+ f[a] = {
331
+ index: a,
332
+ start: y,
333
+ size: M,
334
+ end: T,
335
+ key: c,
336
+ lane: x
337
+ }, m[x] = a;
338
+ }
339
+ return this.measurementsCache = f, f;
340
+ },
341
+ {
342
+ key: !1,
343
+ debug: () => this.options.debug
344
+ }
345
+ ), this.calculateRange = le(
346
+ () => [
347
+ this.getMeasurements(),
348
+ this.getSize(),
349
+ this.getScrollOffset(),
350
+ this.options.lanes
351
+ ],
352
+ (e, o, n, s) => this.range = e.length > 0 && o > 0 ? pn({
353
+ measurements: e,
354
+ outerSize: o,
355
+ scrollOffset: n,
356
+ lanes: s
357
+ }) : null,
358
+ {
359
+ key: !1,
360
+ debug: () => this.options.debug
361
+ }
362
+ ), this.getVirtualIndexes = le(
363
+ () => {
364
+ let e = null, o = null;
365
+ const n = this.calculateRange();
366
+ return n && (e = n.startIndex, o = n.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, o]), [
367
+ this.options.rangeExtractor,
368
+ this.options.overscan,
369
+ this.options.count,
370
+ e,
371
+ o
372
+ ];
373
+ },
374
+ (e, o, n, s, l) => s === null || l === null ? [] : e({
375
+ startIndex: s,
376
+ endIndex: l,
377
+ overscan: o,
378
+ count: n
379
+ }),
380
+ {
381
+ key: !1,
382
+ debug: () => this.options.debug
383
+ }
384
+ ), this.indexFromElement = (e) => {
385
+ const o = this.options.indexAttribute, n = e.getAttribute(o);
386
+ return n ? parseInt(n, 10) : (console.warn(
387
+ `Missing attribute name '${o}={index}' on measured element.`
388
+ ), -1);
389
+ }, this.shouldMeasureDuringScroll = (e) => {
390
+ var o;
391
+ if (!this.scrollState || this.scrollState.behavior !== "smooth")
392
+ return !0;
393
+ const n = this.scrollState.index ?? ((o = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : o.index);
394
+ if (n !== void 0 && this.range) {
395
+ const s = Math.max(
396
+ this.options.overscan,
397
+ Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
398
+ ), l = Math.max(0, n - s), r = Math.min(
399
+ this.options.count - 1,
400
+ n + s
401
+ );
402
+ return e >= l && e <= r;
403
+ }
404
+ return !0;
405
+ }, this.measureElement = (e) => {
406
+ if (!e) {
407
+ this.elementsCache.forEach((l, r) => {
408
+ l.isConnected || (this.observer.unobserve(l), this.elementsCache.delete(r));
409
+ });
410
+ return;
411
+ }
412
+ const o = this.indexFromElement(e), n = this.options.getItemKey(o), s = this.elementsCache.get(n);
413
+ s !== e && (s && this.observer.unobserve(s), this.observer.observe(e), this.elementsCache.set(n, e)), (!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(o) && this.resizeItem(o, this.options.measureElement(e, void 0, this));
414
+ }, this.resizeItem = (e, o) => {
415
+ var n;
416
+ const s = this.measurementsCache[e];
417
+ if (!s) return;
418
+ const l = this.itemSizeCache.get(s.key) ?? s.size, r = o - l;
419
+ r !== 0 && (((n = this.scrollState) == null ? void 0 : n.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(s, r, this) : s.start < this.getScrollOffset() + this.scrollAdjustments) && this._scrollToOffset(this.getScrollOffset(), {
420
+ adjustments: this.scrollAdjustments += r,
421
+ behavior: void 0
422
+ }), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, o)), this.notify(!1));
423
+ }, this.getVirtualItems = le(
424
+ () => [this.getVirtualIndexes(), this.getMeasurements()],
425
+ (e, o) => {
426
+ const n = [];
427
+ for (let s = 0, l = e.length; s < l; s++) {
428
+ const r = e[s], u = o[r];
429
+ n.push(u);
430
+ }
431
+ return n;
432
+ },
433
+ {
434
+ key: !1,
435
+ debug: () => this.options.debug
436
+ }
437
+ ), this.getVirtualItemForOffset = (e) => {
438
+ const o = this.getMeasurements();
439
+ if (o.length !== 0)
440
+ return ze(
441
+ o[Ye(
442
+ 0,
443
+ o.length - 1,
444
+ (n) => ze(o[n]).start,
445
+ e
446
+ )]
447
+ );
448
+ }, this.getMaxScrollOffset = () => {
449
+ if (!this.scrollElement) return 0;
450
+ if ("scrollHeight" in this.scrollElement)
451
+ return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
452
+ {
453
+ const e = this.scrollElement.document.documentElement;
454
+ return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
455
+ }
456
+ }, this.getOffsetForAlignment = (e, o, n = 0) => {
457
+ if (!this.scrollElement) return 0;
458
+ const s = this.getSize(), l = this.getScrollOffset();
459
+ o === "auto" && (o = e >= l + s ? "end" : "start"), o === "center" ? e += (n - s) / 2 : o === "end" && (e -= s);
460
+ const r = this.getMaxScrollOffset();
461
+ return Math.max(Math.min(r, e), 0);
462
+ }, this.getOffsetForIndex = (e, o = "auto") => {
463
+ e = Math.max(0, Math.min(e, this.options.count - 1));
464
+ const n = this.getSize(), s = this.getScrollOffset(), l = this.measurementsCache[e];
465
+ if (!l) return;
466
+ if (o === "auto")
467
+ if (l.end >= s + n - this.options.scrollPaddingEnd)
468
+ o = "end";
469
+ else if (l.start <= s + this.options.scrollPaddingStart)
470
+ o = "start";
471
+ else
472
+ return [s, o];
473
+ if (o === "end" && e === this.options.count - 1)
474
+ return [this.getMaxScrollOffset(), o];
475
+ const r = o === "end" ? l.end + this.options.scrollPaddingEnd : l.start - this.options.scrollPaddingStart;
476
+ return [
477
+ this.getOffsetForAlignment(r, o, l.size),
478
+ o
479
+ ];
480
+ }, this.scrollToOffset = (e, { align: o = "start", behavior: n = "auto" } = {}) => {
481
+ const s = this.getOffsetForAlignment(e, o), l = this.now();
482
+ this.scrollState = {
483
+ index: null,
484
+ align: o,
485
+ behavior: n,
486
+ startedAt: l,
487
+ lastTargetOffset: s,
488
+ stableFrames: 0
489
+ }, this._scrollToOffset(s, { adjustments: void 0, behavior: n }), this.scheduleScrollReconcile();
490
+ }, this.scrollToIndex = (e, {
491
+ align: o = "auto",
492
+ behavior: n = "auto"
493
+ } = {}) => {
494
+ e = Math.max(0, Math.min(e, this.options.count - 1));
495
+ const s = this.getOffsetForIndex(e, o);
496
+ if (!s)
497
+ return;
498
+ const [l, r] = s, u = this.now();
499
+ this.scrollState = {
500
+ index: e,
501
+ align: r,
502
+ behavior: n,
503
+ startedAt: u,
504
+ lastTargetOffset: l,
505
+ stableFrames: 0
506
+ }, this._scrollToOffset(l, { adjustments: void 0, behavior: n }), this.scheduleScrollReconcile();
507
+ }, this.scrollBy = (e, { behavior: o = "auto" } = {}) => {
508
+ const n = this.getScrollOffset() + e, s = this.now();
509
+ this.scrollState = {
510
+ index: null,
511
+ align: "start",
512
+ behavior: o,
513
+ startedAt: s,
514
+ lastTargetOffset: n,
515
+ stableFrames: 0
516
+ }, this._scrollToOffset(n, { adjustments: void 0, behavior: o }), this.scheduleScrollReconcile();
517
+ }, this.getTotalSize = () => {
518
+ var e;
519
+ const o = this.getMeasurements();
520
+ let n;
521
+ if (o.length === 0)
522
+ n = this.options.paddingStart;
523
+ else if (this.options.lanes === 1)
524
+ n = ((e = o[o.length - 1]) == null ? void 0 : e.end) ?? 0;
525
+ else {
526
+ const s = Array(this.options.lanes).fill(null);
527
+ let l = o.length - 1;
528
+ for (; l >= 0 && s.some((r) => r === null); ) {
529
+ const r = o[l];
530
+ s[r.lane] === null && (s[r.lane] = r.end), l--;
531
+ }
532
+ n = Math.max(...s.filter((r) => r !== null));
533
+ }
534
+ return Math.max(
535
+ n - this.options.scrollMargin + this.options.paddingEnd,
536
+ 0
537
+ );
538
+ }, this._scrollToOffset = (e, {
539
+ adjustments: o,
540
+ behavior: n
541
+ }) => {
542
+ this.options.scrollToFn(e, { behavior: n, adjustments: o }, this);
543
+ }, this.measure = () => {
544
+ this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
545
+ }, this.setOptions(i);
546
+ }
547
+ scheduleScrollReconcile() {
548
+ if (!this.targetWindow) {
549
+ this.scrollState = null;
550
+ return;
551
+ }
552
+ this.rafId == null && (this.rafId = this.targetWindow.requestAnimationFrame(() => {
553
+ this.rafId = null, this.reconcileScroll();
554
+ }));
555
+ }
556
+ reconcileScroll() {
557
+ if (!this.scrollState || !this.scrollElement) return;
558
+ if (this.now() - this.scrollState.startedAt > 5e3) {
559
+ this.scrollState = null;
560
+ return;
561
+ }
562
+ const o = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0, n = o ? o[0] : this.scrollState.lastTargetOffset, s = 1, l = n !== this.scrollState.lastTargetOffset;
563
+ if (!l && on(n, this.getScrollOffset())) {
564
+ if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= s) {
565
+ this.scrollState = null;
566
+ return;
567
+ }
568
+ } else
569
+ this.scrollState.stableFrames = 0, l && (this.scrollState.lastTargetOffset = n, this.scrollState.behavior = "auto", this._scrollToOffset(n, {
570
+ adjustments: void 0,
571
+ behavior: "auto"
572
+ }));
573
+ this.scheduleScrollReconcile();
574
+ }
575
+ }
576
+ const Ye = (t, i, e, o) => {
577
+ for (; t <= i; ) {
578
+ const n = (t + i) / 2 | 0, s = e(n);
579
+ if (s < o)
580
+ t = n + 1;
581
+ else if (s > o)
582
+ i = n - 1;
583
+ else
584
+ return n;
585
+ }
586
+ return t > 0 ? t - 1 : 0;
587
+ };
588
+ function pn({
589
+ measurements: t,
590
+ outerSize: i,
591
+ scrollOffset: e,
592
+ lanes: o
593
+ }) {
594
+ const n = t.length - 1, s = (u) => t[u].start;
595
+ if (t.length <= o)
596
+ return {
597
+ startIndex: 0,
598
+ endIndex: n
599
+ };
600
+ let l = Ye(
601
+ 0,
602
+ n,
603
+ s,
604
+ e
605
+ ), r = l;
606
+ if (o === 1)
607
+ for (; r < n && t[r].end < e + i; )
608
+ r++;
609
+ else if (o > 1) {
610
+ const u = Array(o).fill(0);
611
+ for (; r < n && u.some((h) => h < e + i); ) {
612
+ const h = t[r];
613
+ u[h.lane] = h.end, r++;
614
+ }
615
+ const d = Array(o).fill(e + i);
616
+ for (; l >= 0 && d.some((h) => h >= e); ) {
617
+ const h = t[l];
618
+ d[h.lane] = h.start, l--;
619
+ }
620
+ l = Math.max(0, l - l % o), r = Math.min(n, r + (o - 1 - r % o));
621
+ }
622
+ return { startIndex: l, endIndex: r };
623
+ }
624
+ const Ve = typeof document < "u" ? Oe.useLayoutEffect : Oe.useEffect;
625
+ function fn({
626
+ useFlushSync: t = !0,
627
+ ...i
628
+ }) {
629
+ const e = Oe.useReducer(() => ({}), {})[1], o = {
630
+ ...i,
631
+ onChange: (s, l) => {
632
+ var r;
633
+ t && l ? oe(e) : e(), (r = i.onChange) == null || r.call(i, s, l);
634
+ }
635
+ }, [n] = Oe.useState(
636
+ () => new hn(o)
637
+ );
638
+ return n.setOptions(o), Ve(() => n._didMount(), []), Ve(() => n._willUpdate()), n;
639
+ }
640
+ function mn(t) {
641
+ return fn({
642
+ observeElementRect: an,
643
+ observeElementOffset: un,
644
+ scrollToFn: dn,
645
+ ...t
646
+ });
647
+ }
648
+ function Je(t) {
649
+ let i = J({ value: "", selectionStart: null, selectionEnd: null });
650
+ return nn(t, "blur", (e) => {
651
+ let o = e.target;
652
+ $e(o) && (i.current = { value: o.value, selectionStart: o.selectionStart, selectionEnd: o.selectionEnd });
653
+ }), _(() => {
654
+ if (!Ke(t) && $e(t) && t.isConnected) {
655
+ if (t.focus({ preventScroll: !0 }), t.value !== i.current.value) t.setSelectionRange(t.value.length, t.value.length);
656
+ else {
657
+ let { selectionStart: e, selectionEnd: o } = i.current;
658
+ e !== null && o !== null && t.setSelectionRange(e, o);
659
+ }
660
+ i.current = { value: "", selectionStart: null, selectionEnd: null };
661
+ }
662
+ });
663
+ }
664
+ function bn(t, { container: i, accept: e, walk: o }) {
665
+ let n = J(e), s = J(o);
666
+ Ue(() => {
667
+ n.current = e, s.current = o;
668
+ }, [e, o]), Q(() => {
669
+ if (!i || !t) return;
670
+ let l = at(i);
671
+ if (!l) return;
672
+ let r = n.current, u = s.current, d = Object.assign((f) => r(f), { acceptNode: r }), h = l.createTreeWalker(i, NodeFilter.SHOW_ELEMENT, d, !1);
673
+ for (; h.nextNode(); ) u(h.currentNode);
674
+ }, [i, t, n, s]);
675
+ }
676
+ function We(t, i) {
677
+ let e = J([]), o = _(t);
678
+ Ue(() => {
679
+ let n = [...e.current];
680
+ for (let [s, l] of i.entries()) if (e.current[s] !== l) {
681
+ let r = o(i, n);
682
+ return e.current = i, r;
683
+ }
684
+ }, [o, ...i]);
685
+ }
686
+ function vn(t) {
687
+ function i() {
688
+ document.readyState !== "loading" && (t(), document.removeEventListener("DOMContentLoaded", i));
689
+ }
690
+ typeof window < "u" && typeof document < "u" && (document.addEventListener("DOMContentLoaded", i), i());
691
+ }
692
+ let ne = [];
693
+ vn(() => {
694
+ function t(i) {
695
+ if (!ut(i.target) || i.target === document.body || ne[0] === i.target) return;
696
+ let e = i.target;
697
+ e = e.closest(ct), ne.unshift(e ?? i.target), ne = ne.filter((o) => o != null && o.isConnected), ne.splice(10);
698
+ }
699
+ window.addEventListener("click", t, { capture: !0 }), window.addEventListener("mousedown", t, { capture: !0 }), window.addEventListener("focus", t, { capture: !0 }), document.body.addEventListener("click", t, { capture: !0 }), document.body.addEventListener("mousedown", t, { capture: !0 }), document.body.addEventListener("focus", t, { capture: !0 });
700
+ });
701
+ var gn = Object.defineProperty, xn = (t, i, e) => i in t ? gn(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e, je = (t, i, e) => (xn(t, typeof i != "symbol" ? i + "" : i, e), e), v = ((t) => (t[t.Open = 0] = "Open", t[t.Closed = 1] = "Closed", t))(v || {}), q = ((t) => (t[t.Single = 0] = "Single", t[t.Multi = 1] = "Multi", t))(q || {}), Y = ((t) => (t[t.Pointer = 0] = "Pointer", t[t.Focus = 1] = "Focus", t[t.Other = 2] = "Other", t))(Y || {}), Qe = ((t) => (t[t.OpenCombobox = 0] = "OpenCombobox", t[t.CloseCombobox = 1] = "CloseCombobox", t[t.GoToOption = 2] = "GoToOption", t[t.SetTyping = 3] = "SetTyping", t[t.RegisterOption = 4] = "RegisterOption", t[t.UnregisterOption = 5] = "UnregisterOption", t[t.DefaultToFirstOption = 6] = "DefaultToFirstOption", t[t.SetActivationTrigger = 7] = "SetActivationTrigger", t[t.UpdateVirtualConfiguration = 8] = "UpdateVirtualConfiguration", t[t.SetInputElement = 9] = "SetInputElement", t[t.SetButtonElement = 10] = "SetButtonElement", t[t.SetOptionsElement = 11] = "SetOptionsElement", t[t.MarkInputAsMoved = 12] = "MarkInputAsMoved", t))(Qe || {});
702
+ function Ce(t, i = (e) => e) {
703
+ let e = t.activeOptionIndex !== null ? t.options[t.activeOptionIndex] : null, o = i(t.options.slice()), n = o.length > 0 && o[0].dataRef.current.order !== null ? o.sort((l, r) => l.dataRef.current.order - r.dataRef.current.order) : mt(o, (l) => l.dataRef.current.domRef.current), s = e ? n.indexOf(e) : null;
704
+ return s === -1 && (s = null), { options: n, activeOptionIndex: s };
705
+ }
706
+ let Sn = { 1(t) {
707
+ var i;
708
+ if ((i = t.dataRef.current) != null && i.disabled || t.comboboxState === 1) return t;
709
+ let e = t.inputElement ? fe.Tracked(ft(t.inputElement)) : t.inputPositionState;
710
+ return { ...t, activeOptionIndex: null, comboboxState: 1, isTyping: !1, activationTrigger: 2, inputPositionState: e, __demoMode: !1 };
711
+ }, 0(t) {
712
+ var i, e;
713
+ if ((i = t.dataRef.current) != null && i.disabled || t.comboboxState === 0) return t;
714
+ if ((e = t.dataRef.current) != null && e.value) {
715
+ let o = t.dataRef.current.calculateIndex(t.dataRef.current.value);
716
+ if (o !== -1) return { ...t, activeOptionIndex: o, comboboxState: 0, __demoMode: !1, inputPositionState: fe.Idle };
717
+ }
718
+ return { ...t, comboboxState: 0, inputPositionState: fe.Idle, __demoMode: !1 };
719
+ }, 3(t, i) {
720
+ return t.isTyping === i.isTyping ? t : { ...t, isTyping: i.isTyping };
721
+ }, 2(t, i) {
722
+ var e, o, n, s;
723
+ if ((e = t.dataRef.current) != null && e.disabled || t.optionsElement && !((o = t.dataRef.current) != null && o.optionsPropsRef.current.static) && t.comboboxState === 1) return t;
724
+ if (t.virtual) {
725
+ let { options: d, disabled: h } = t.virtual, f = i.focus === D.Specific ? i.idx : Pe(i, { resolveItems: () => d, resolveActiveIndex: () => {
726
+ var a, c;
727
+ return (c = (a = t.activeOptionIndex) != null ? a : d.findIndex((g) => !h(g))) != null ? c : null;
728
+ }, resolveDisabled: h, resolveId() {
729
+ throw new Error("Function not implemented.");
730
+ } }), m = (n = i.trigger) != null ? n : 2;
731
+ return t.activeOptionIndex === f && t.activationTrigger === m ? t : { ...t, activeOptionIndex: f, activationTrigger: m, isTyping: !1, __demoMode: !1 };
732
+ }
733
+ let l = Ce(t);
734
+ if (l.activeOptionIndex === null) {
735
+ let d = l.options.findIndex((h) => !h.dataRef.current.disabled);
736
+ d !== -1 && (l.activeOptionIndex = d);
737
+ }
738
+ let r = i.focus === D.Specific ? i.idx : Pe(i, { resolveItems: () => l.options, resolveActiveIndex: () => l.activeOptionIndex, resolveId: (d) => d.id, resolveDisabled: (d) => d.dataRef.current.disabled }), u = (s = i.trigger) != null ? s : 2;
739
+ return t.activeOptionIndex === r && t.activationTrigger === u ? t : { ...t, ...l, isTyping: !1, activeOptionIndex: r, activationTrigger: u, __demoMode: !1 };
740
+ }, 4: (t, i) => {
741
+ var e, o, n, s;
742
+ if ((e = t.dataRef.current) != null && e.virtual) return { ...t, options: [...t.options, i.payload] };
743
+ let l = i.payload, r = Ce(t, (d) => (d.push(l), d));
744
+ t.activeOptionIndex === null && (n = (o = t.dataRef.current).isSelected) != null && n.call(o, i.payload.dataRef.current.value) && (r.activeOptionIndex = r.options.indexOf(l));
745
+ let u = { ...t, ...r, activationTrigger: 2 };
746
+ return (s = t.dataRef.current) != null && s.__demoMode && t.dataRef.current.value === void 0 && (u.activeOptionIndex = 0), u;
747
+ }, 5: (t, i) => {
748
+ var e;
749
+ if ((e = t.dataRef.current) != null && e.virtual) return { ...t, options: t.options.filter((n) => n.id !== i.id) };
750
+ let o = Ce(t, (n) => {
751
+ let s = n.findIndex((l) => l.id === i.id);
752
+ return s !== -1 && n.splice(s, 1), n;
753
+ });
754
+ return { ...t, ...o, activationTrigger: 2 };
755
+ }, 6: (t, i) => t.defaultToFirstOption === i.value ? t : { ...t, defaultToFirstOption: i.value }, 7: (t, i) => t.activationTrigger === i.trigger ? t : { ...t, activationTrigger: i.trigger }, 8: (t, i) => {
756
+ var e, o;
757
+ if (t.virtual === null) return { ...t, virtual: { options: i.options, disabled: (e = i.disabled) != null ? e : () => !1 } };
758
+ if (t.virtual.options === i.options && t.virtual.disabled === i.disabled) return t;
759
+ let n = t.activeOptionIndex;
760
+ if (t.activeOptionIndex !== null) {
761
+ let s = i.options.indexOf(t.virtual.options[t.activeOptionIndex]);
762
+ s !== -1 ? n = s : n = null;
763
+ }
764
+ return { ...t, activeOptionIndex: n, virtual: { options: i.options, disabled: (o = i.disabled) != null ? o : () => !1 } };
765
+ }, 9: (t, i) => t.inputElement === i.element ? t : { ...t, inputElement: i.element }, 10: (t, i) => t.buttonElement === i.element ? t : { ...t, buttonElement: i.element }, 11: (t, i) => t.optionsElement === i.element ? t : { ...t, optionsElement: i.element }, 12(t) {
766
+ return t.inputPositionState.kind !== "Tracked" ? t : { ...t, inputPositionState: fe.Moved };
767
+ } };
768
+ class Re extends dt {
769
+ constructor(i) {
770
+ super(i), je(this, "actions", { onChange: (e) => {
771
+ let { onChange: o, compare: n, mode: s, value: l } = this.state.dataRef.current;
772
+ return ue(s, { 0: () => o == null ? void 0 : o(e), 1: () => {
773
+ let r = l.slice(), u = r.findIndex((d) => n(d, e));
774
+ return u === -1 ? r.push(e) : r.splice(u, 1), o == null ? void 0 : o(r);
775
+ } });
776
+ }, registerOption: (e, o) => (this.send({ type: 4, payload: { id: e, dataRef: o } }), () => {
777
+ this.state.activeOptionIndex === this.state.dataRef.current.calculateIndex(o.current.value) && this.send({ type: 6, value: !0 }), this.send({ type: 5, id: e });
778
+ }), goToOption: (e, o) => (this.send({ type: 6, value: !1 }), this.send({ type: 2, ...e, trigger: o })), setIsTyping: (e) => {
779
+ this.send({ type: 3, isTyping: e });
780
+ }, closeCombobox: () => {
781
+ var e, o;
782
+ this.send({ type: 1 }), this.send({ type: 6, value: !1 }), (o = (e = this.state.dataRef.current).onClose) == null || o.call(e);
783
+ }, openCombobox: () => {
784
+ this.send({ type: 0 }), this.send({ type: 6, value: !0 });
785
+ }, setActivationTrigger: (e) => {
786
+ this.send({ type: 7, trigger: e });
787
+ }, selectActiveOption: () => {
788
+ let e = this.selectors.activeOptionIndex(this.state);
789
+ if (e !== null) {
790
+ if (this.actions.setIsTyping(!1), this.state.virtual) this.actions.onChange(this.state.virtual.options[e]);
791
+ else {
792
+ let { dataRef: o } = this.state.options[e];
793
+ this.actions.onChange(o.current.value);
794
+ }
795
+ this.actions.goToOption({ focus: D.Specific, idx: e });
796
+ }
797
+ }, setInputElement: (e) => {
798
+ this.send({ type: 9, element: e });
799
+ }, setButtonElement: (e) => {
800
+ this.send({ type: 10, element: e });
801
+ }, setOptionsElement: (e) => {
802
+ this.send({ type: 11, element: e });
803
+ } }), je(this, "selectors", { activeDescendantId: (e) => {
804
+ var o, n;
805
+ let s = this.selectors.activeOptionIndex(e);
806
+ if (s !== null) return e.virtual ? (n = e.options.find((l) => !l.dataRef.current.disabled && e.dataRef.current.compare(l.dataRef.current.value, e.virtual.options[s]))) == null ? void 0 : n.id : (o = e.options[s]) == null ? void 0 : o.id;
807
+ }, activeOptionIndex: (e) => {
808
+ if (e.defaultToFirstOption && e.activeOptionIndex === null && (e.virtual ? e.virtual.options.length > 0 : e.options.length > 0)) {
809
+ if (e.virtual) {
810
+ let { options: n, disabled: s } = e.virtual, l = n.findIndex((r) => {
811
+ var u;
812
+ return !((u = s == null ? void 0 : s(r)) != null && u);
813
+ });
814
+ if (l !== -1) return l;
815
+ }
816
+ let o = e.options.findIndex((n) => !n.dataRef.current.disabled);
817
+ if (o !== -1) return o;
818
+ }
819
+ return e.activeOptionIndex;
820
+ }, activeOption: (e) => {
821
+ var o, n;
822
+ let s = this.selectors.activeOptionIndex(e);
823
+ return s === null ? null : e.virtual ? e.virtual.options[s ?? 0] : (n = (o = e.options[s]) == null ? void 0 : o.dataRef.current.value) != null ? n : null;
824
+ }, isActive: (e, o, n) => {
825
+ var s;
826
+ let l = this.selectors.activeOptionIndex(e);
827
+ return l === null ? !1 : e.virtual ? l === e.dataRef.current.calculateIndex(o) : ((s = e.options[l]) == null ? void 0 : s.id) === n;
828
+ }, shouldScrollIntoView: (e, o, n) => !(e.virtual || e.__demoMode || e.comboboxState !== 0 || e.activationTrigger === 0 || !this.selectors.isActive(e, o, n)), didInputMove(e) {
829
+ return e.inputPositionState.kind === "Moved";
830
+ } });
831
+ {
832
+ let e = this.state.id, o = qe.get(null);
833
+ this.disposables.add(o.on(ht.Push, (n) => {
834
+ !o.selectors.isTop(n, e) && this.state.comboboxState === 0 && this.actions.closeCombobox();
835
+ })), this.on(0, () => o.actions.push(e)), this.on(1, () => o.actions.pop(e));
836
+ }
837
+ this.disposables.group((e) => {
838
+ this.on(1, (o) => {
839
+ o.inputElement && (e.dispose(), e.add(pt(o.inputElement, o.inputPositionState, () => {
840
+ this.send({ type: 12 });
841
+ })));
842
+ });
843
+ });
844
+ }
845
+ static new({ id: i, virtual: e = null, __demoMode: o = !1 }) {
846
+ var n;
847
+ return new Re({ id: i, dataRef: { current: {} }, comboboxState: o ? 0 : 1, isTyping: !1, options: [], virtual: e ? { options: e.options, disabled: (n = e.disabled) != null ? n : () => !1 } : null, activeOptionIndex: null, activationTrigger: 2, inputElement: null, buttonElement: null, optionsElement: null, __demoMode: o, inputPositionState: fe.Idle });
848
+ }
849
+ reduce(i, e) {
850
+ return ue(e.type, Sn, i, e);
851
+ }
852
+ }
853
+ const Ze = we(null);
854
+ function Se(t) {
855
+ let i = Ie(Ze);
856
+ if (i === null) {
857
+ let e = new Error(`<${t} /> is missing a parent <Combobox /> component.`);
858
+ throw Error.captureStackTrace && Error.captureStackTrace(e, et), e;
859
+ }
860
+ return i;
861
+ }
862
+ function et({ id: t, virtual: i = null, __demoMode: e = !1 }) {
863
+ let o = se(() => Re.new({ id: t, virtual: i, __demoMode: e }), []);
864
+ return bt(() => o.dispose()), o;
865
+ }
866
+ let me = we(null);
867
+ me.displayName = "ComboboxDataContext";
868
+ function ce(t) {
869
+ let i = Ie(me);
870
+ if (i === null) {
871
+ let e = new Error(`<${t} /> is missing a parent <Combobox /> component.`);
872
+ throw Error.captureStackTrace && Error.captureStackTrace(e, ce), e;
873
+ }
874
+ return i;
875
+ }
876
+ let tt = we(null);
877
+ function On(t) {
878
+ let i = Se("VirtualProvider"), e = ce("VirtualProvider"), { options: o } = e.virtual, n = L(i, (a) => a.optionsElement), [s, l] = se(() => {
879
+ let a = n;
880
+ if (!a) return [0, 0];
881
+ let c = window.getComputedStyle(a);
882
+ return [parseFloat(c.paddingBlockStart || c.paddingTop), parseFloat(c.paddingBlockEnd || c.paddingBottom)];
883
+ }, [n]), r = mn({ enabled: o.length !== 0, scrollPaddingStart: s, scrollPaddingEnd: l, count: o.length, estimateSize() {
884
+ return 40;
885
+ }, getScrollElement() {
886
+ return i.state.optionsElement;
887
+ }, overscan: 12 }), [u, d] = ae(0);
888
+ Q(() => {
889
+ d((a) => a + 1);
890
+ }, [o]);
891
+ let h = r.getVirtualItems(), f = L(i, (a) => a.activationTrigger === Y.Pointer), m = L(i, i.selectors.activeOptionIndex);
892
+ return h.length === 0 ? null : W.createElement(tt.Provider, { value: r }, W.createElement("div", { style: { position: "relative", width: "100%", height: `${r.getTotalSize()}px` }, ref: (a) => {
893
+ a && (f || m !== null && o.length > m && r.scrollToIndex(m));
894
+ } }, h.map((a) => {
895
+ var c;
896
+ return W.createElement(He, { key: a.key }, W.cloneElement((c = t.children) == null ? void 0 : c.call(t, { ...t.slot, option: o[a.index] }), { key: `${u}-${a.key}`, "data-index": a.index, "aria-setsize": o.length, "aria-posinset": a.index + 1, style: { position: "absolute", top: 0, left: 0, transform: `translateY(${a.start}px)`, overflowAnchor: "none" } }));
897
+ })));
898
+ }
899
+ let En = He;
900
+ function yn(t, i) {
901
+ let e = be(), o = Lt(), { value: n, defaultValue: s, onChange: l, form: r, name: u, by: d, invalid: h = !1, disabled: f = o || !1, onClose: m, __demoMode: a = !1, multiple: c = !1, immediate: g = !1, virtual: x = null, nullable: y, ...w } = t, C = Nt(s), [M = c ? [] : void 0, T] = Vt(n, l, C), b = et({ id: e, virtual: x, __demoMode: a }), A = J({ static: !1, hold: !1 }), R = Wt(d), k = _((I) => x ? d === null ? x.options.indexOf(I) : x.options.findIndex((te) => R(te, I)) : b.state.options.findIndex((te) => R(te.dataRef.current.value, I))), U = X((I) => ue(S.mode, { [q.Multi]: () => M.some((te) => R(te, I)), [q.Single]: () => R(M, I) }), [M]), H = L(b, (I) => I.virtual), E = _(() => m == null ? void 0 : m()), S = se(() => ({ __demoMode: a, immediate: g, optionsPropsRef: A, value: M, defaultValue: C, disabled: f, invalid: h, mode: c ? q.Multi : q.Single, virtual: x ? H : null, onChange: T, isSelected: U, calculateIndex: k, compare: R, onClose: E }), [a, g, A, M, C, f, h, c, x, H, T, U, k, R, E]);
902
+ Q(() => {
903
+ var I;
904
+ x && b.send({ type: Qe.UpdateVirtualConfiguration, options: x.options, disabled: (I = x.disabled) != null ? I : null });
905
+ }, [x, x == null ? void 0 : x.options, x == null ? void 0 : x.disabled]), Q(() => {
906
+ b.state.dataRef.current = S;
907
+ }, [S]);
908
+ let [$, O, j, de] = L(b, (I) => [I.comboboxState, I.buttonElement, I.inputElement, I.optionsElement]), Z = qe.get(null), ie = L(Z, X((I) => Z.selectors.isTop(I, e), [Z, e]));
909
+ jt(ie, [O, j, de], () => b.actions.closeCombobox());
910
+ let ee = L(b, b.selectors.activeOptionIndex), he = L(b, b.selectors.activeOption), p = ge({ open: $ === v.Open, disabled: f, invalid: h, activeIndex: ee, activeOption: he, value: M }), [K, F] = Bt(), N = i === null ? {} : { ref: i }, P = X(() => {
911
+ if (C !== void 0) return T == null ? void 0 : T(C);
912
+ }, [T, C]), V = xe();
913
+ return W.createElement(F, { value: K, props: { htmlFor: j == null ? void 0 : j.id }, slot: { open: $ === v.Open, disabled: f } }, W.createElement(Ut, null, W.createElement(me.Provider, { value: S }, W.createElement(Ze.Provider, { value: b }, W.createElement(Ht, { value: ue($, { [v.Open]: Ee.Open, [v.Closed]: Ee.Closed }) }, u != null && W.createElement(Kt, { disabled: f, data: M != null ? { [u]: M } : {}, form: r, onReset: P }), V({ ourProps: N, theirProps: w, slot: p, defaultTag: En, name: "Combobox" }))))));
914
+ }
915
+ let Cn = "input";
916
+ function In(t, i) {
917
+ var e, o;
918
+ let n = Se("Combobox.Input"), s = ce("Combobox.Input"), l = be(), r = gt(), { id: u = r || `headlessui-combobox-input-${l}`, onChange: d, displayValue: h, disabled: f = s.disabled || !1, autoFocus: m = !1, type: a = "text", ...c } = t, g = J(null), x = ye(g, i, xt(), n.actions.setInputElement), [y, w] = L(n, (p) => [p.comboboxState, p.isTyping]), C = St(), M = _(() => {
919
+ n.actions.onChange(null), n.state.optionsElement && (n.state.optionsElement.scrollTop = 0), n.actions.goToOption({ focus: D.Nothing });
920
+ }), T = se(() => {
921
+ var p;
922
+ return typeof h == "function" && s.value !== void 0 ? (p = h(s.value)) != null ? p : "" : typeof s.value == "string" ? s.value : "";
923
+ }, [s.value, h]);
924
+ We(([p, K], [F, N]) => {
925
+ if (n.state.isTyping) return;
926
+ let P = g.current;
927
+ P && ((N === v.Open && K === v.Closed || p !== F) && (P.value = p), requestAnimationFrame(() => {
928
+ if (n.state.isTyping || !P || Ke(P)) return;
929
+ let { selectionStart: V, selectionEnd: I } = P;
930
+ Math.abs((I ?? 0) - (V ?? 0)) === 0 && V === 0 && P.setSelectionRange(P.value.length, P.value.length);
931
+ }));
932
+ }, [T, y, w]), We(([p], [K]) => {
933
+ if (p === v.Open && K === v.Closed) {
934
+ if (n.state.isTyping) return;
935
+ let F = g.current;
936
+ if (!F) return;
937
+ let N = F.value, { selectionStart: P, selectionEnd: V, selectionDirection: I } = F;
938
+ F.value = "", F.value = N, I !== null ? F.setSelectionRange(P, V, I) : F.setSelectionRange(P, V);
939
+ }
940
+ }, [y]);
941
+ let b = J(!1), A = _(() => {
942
+ b.current = !0;
943
+ }), R = _(() => {
944
+ C.nextFrame(() => {
945
+ b.current = !1;
946
+ });
947
+ }), k = _((p) => {
948
+ switch (n.actions.setIsTyping(!0), p.key) {
949
+ case B.Enter:
950
+ if (n.state.comboboxState !== v.Open || b.current) return;
951
+ if (p.preventDefault(), p.stopPropagation(), n.selectors.activeOptionIndex(n.state) === null) {
952
+ n.actions.closeCombobox();
953
+ return;
954
+ }
955
+ n.actions.selectActiveOption(), s.mode === q.Single && n.actions.closeCombobox();
956
+ break;
957
+ case B.ArrowDown:
958
+ return p.preventDefault(), p.stopPropagation(), ue(n.state.comboboxState, { [v.Open]: () => n.actions.goToOption({ focus: D.Next }), [v.Closed]: () => n.actions.openCombobox() });
959
+ case B.ArrowUp:
960
+ return p.preventDefault(), p.stopPropagation(), ue(n.state.comboboxState, { [v.Open]: () => n.actions.goToOption({ focus: D.Previous }), [v.Closed]: () => {
961
+ oe(() => n.actions.openCombobox()), s.value || n.actions.goToOption({ focus: D.Last });
962
+ } });
963
+ case B.Home:
964
+ if (n.state.comboboxState === v.Closed || p.shiftKey) break;
965
+ return p.preventDefault(), p.stopPropagation(), n.actions.goToOption({ focus: D.First });
966
+ case B.PageUp:
967
+ return p.preventDefault(), p.stopPropagation(), n.actions.goToOption({ focus: D.First });
968
+ case B.End:
969
+ if (n.state.comboboxState === v.Closed || p.shiftKey) break;
970
+ return p.preventDefault(), p.stopPropagation(), n.actions.goToOption({ focus: D.Last });
971
+ case B.PageDown:
972
+ return p.preventDefault(), p.stopPropagation(), n.actions.goToOption({ focus: D.Last });
973
+ case B.Escape:
974
+ return n.state.comboboxState !== v.Open ? void 0 : (p.preventDefault(), n.state.optionsElement && !s.optionsPropsRef.current.static && p.stopPropagation(), s.mode === q.Single && s.value === null && M(), n.actions.closeCombobox());
975
+ case B.Tab:
976
+ if (n.actions.setIsTyping(!1), n.state.comboboxState !== v.Open) return;
977
+ s.mode === q.Single && n.state.activationTrigger !== Y.Focus && n.actions.selectActiveOption(), n.actions.closeCombobox();
978
+ break;
979
+ }
980
+ }), U = _((p) => {
981
+ d == null || d(p), s.mode === q.Single && p.target.value === "" && M(), n.actions.openCombobox();
982
+ }), H = _((p) => {
983
+ var K, F, N;
984
+ let P = (K = p.relatedTarget) != null ? K : ne.find((V) => V !== p.currentTarget);
985
+ if (!((F = n.state.optionsElement) != null && F.contains(P)) && !((N = n.state.buttonElement) != null && N.contains(P)) && n.state.comboboxState === v.Open) return p.preventDefault(), s.mode === q.Single && s.value === null && M(), n.actions.closeCombobox();
986
+ }), E = _((p) => {
987
+ var K, F, N;
988
+ let P = (K = p.relatedTarget) != null ? K : ne.find((V) => V !== p.currentTarget);
989
+ (F = n.state.buttonElement) != null && F.contains(P) || (N = n.state.optionsElement) != null && N.contains(P) || s.disabled || s.immediate && n.state.comboboxState !== v.Open && C.microTask(() => {
990
+ oe(() => n.actions.openCombobox()), n.actions.setActivationTrigger(Y.Focus);
991
+ });
992
+ }), S = Me(), $ = Ot(), { isFocused: O, focusProps: j } = Ge({ autoFocus: m }), { isHovered: de, hoverProps: Z } = Xe({ isDisabled: f }), ie = L(n, (p) => p.optionsElement), ee = ge({ open: y === v.Open, disabled: f, invalid: s.invalid, hover: de, focus: O, autofocus: m }), he = Te({ ref: x, id: u, role: "combobox", type: a, "aria-controls": ie == null ? void 0 : ie.id, "aria-expanded": y === v.Open, "aria-activedescendant": L(n, n.selectors.activeDescendantId), "aria-labelledby": S, "aria-describedby": $, "aria-autocomplete": "list", defaultValue: (o = (e = t.defaultValue) != null ? e : s.defaultValue !== void 0 ? h == null ? void 0 : h(s.defaultValue) : null) != null ? o : s.defaultValue, disabled: f || void 0, autoFocus: m, onCompositionStart: A, onCompositionEnd: R, onKeyDown: k, onChange: U, onFocus: E, onBlur: H }, j, Z);
993
+ return xe()({ ourProps: he, theirProps: c, slot: ee, defaultTag: Cn, name: "Combobox.Input" });
994
+ }
995
+ let wn = "button";
996
+ function Mn(t, i) {
997
+ let e = Se("Combobox.Button"), o = ce("Combobox.Button"), [n, s] = ae(null), l = ye(i, s, e.actions.setButtonElement), r = be(), { id: u = `headlessui-combobox-button-${r}`, disabled: d = o.disabled || !1, autoFocus: h = !1, ...f } = t, [m, a, c] = L(e, (E) => [E.comboboxState, E.inputElement, E.optionsElement]), g = Je(a), x = m === v.Open;
998
+ qt(x, { trigger: n, action: X((E) => {
999
+ if (n != null && n.contains(E.target)) return pe.Ignore;
1000
+ if (a != null && a.contains(E.target)) return pe.Ignore;
1001
+ let S = E.target.closest('[role="option"]:not([data-disabled])');
1002
+ return Gt(S) ? pe.Select(S) : c != null && c.contains(E.target) ? pe.Ignore : pe.Close;
1003
+ }, [n, a, c]), close: e.actions.closeCombobox, select: e.actions.selectActiveOption });
1004
+ let y = _((E) => {
1005
+ switch (E.key) {
1006
+ case B.Space:
1007
+ case B.Enter:
1008
+ E.preventDefault(), E.stopPropagation(), e.state.comboboxState === v.Closed && oe(() => e.actions.openCombobox()), g();
1009
+ return;
1010
+ case B.ArrowDown:
1011
+ E.preventDefault(), E.stopPropagation(), e.state.comboboxState === v.Closed && (oe(() => e.actions.openCombobox()), e.state.dataRef.current.value || e.actions.goToOption({ focus: D.First })), g();
1012
+ return;
1013
+ case B.ArrowUp:
1014
+ E.preventDefault(), E.stopPropagation(), e.state.comboboxState === v.Closed && (oe(() => e.actions.openCombobox()), e.state.dataRef.current.value || e.actions.goToOption({ focus: D.Last })), g();
1015
+ return;
1016
+ case B.Escape:
1017
+ if (e.state.comboboxState !== v.Open) return;
1018
+ E.preventDefault(), e.state.optionsElement && !o.optionsPropsRef.current.static && E.stopPropagation(), oe(() => e.actions.closeCombobox()), g();
1019
+ return;
1020
+ default:
1021
+ return;
1022
+ }
1023
+ }), w = Xt(() => {
1024
+ e.state.comboboxState === v.Open ? e.actions.closeCombobox() : e.actions.openCombobox(), g();
1025
+ }), C = Me([u]), { isFocusVisible: M, focusProps: T } = Ge({ autoFocus: h }), { isHovered: b, hoverProps: A } = Xe({ isDisabled: d }), { pressed: R, pressProps: k } = Yt({ disabled: d }), U = ge({ open: m === v.Open, active: R || m === v.Open, disabled: d, invalid: o.invalid, value: o.value, hover: b, focus: M }), H = Te({ ref: l, id: u, type: Jt(t, n), tabIndex: -1, "aria-haspopup": "listbox", "aria-controls": c == null ? void 0 : c.id, "aria-expanded": m === v.Open, "aria-labelledby": C, disabled: d || void 0, autoFocus: h, onKeyDown: y }, w, T, A, k);
1026
+ return xe()({ ourProps: H, theirProps: f, slot: U, defaultTag: wn, name: "Combobox.Button" });
1027
+ }
1028
+ let Tn = "div", Rn = ke.RenderStrategy | ke.Static;
1029
+ function $n(t, i) {
1030
+ var e, o, n;
1031
+ let s = be(), { id: l = `headlessui-combobox-options-${s}`, hold: r = !1, anchor: u, portal: d = !1, modal: h = !0, transition: f = !1, ...m } = t, a = Se("Combobox.Options"), c = ce("Combobox.Options"), g = Et(u);
1032
+ g && (d = !0);
1033
+ let [x, y] = yt(g), [w, C] = ae(null), M = Ct(), T = ye(i, g ? x : null, a.actions.setOptionsElement, C), [b, A, R, k, U] = L(a, (z) => [z.comboboxState, z.inputElement, z.buttonElement, z.optionsElement, z.activationTrigger]), H = Ae(A || R), E = Ae(k), S = It(), [$, O] = wt(f, w, S !== null ? (S & Ee.Open) === Ee.Open : b === v.Open);
1034
+ Mt($, A, a.actions.closeCombobox);
1035
+ let j = c.__demoMode ? !1 : h && b === v.Open;
1036
+ Tt(j, E);
1037
+ let de = c.__demoMode ? !1 : h && b === v.Open;
1038
+ Rt(de, { allowed: X(() => [A, R, k], [A, R, k]) });
1039
+ let Z = L(a, a.selectors.didInputMove) ? !1 : $;
1040
+ Q(() => {
1041
+ var z;
1042
+ c.optionsPropsRef.current.static = (z = t.static) != null ? z : !1;
1043
+ }, [c.optionsPropsRef, t.static]), Q(() => {
1044
+ c.optionsPropsRef.current.hold = r;
1045
+ }, [c.optionsPropsRef, r]), bn(b === v.Open, { container: k, accept(z) {
1046
+ return z.getAttribute("role") === "option" ? NodeFilter.FILTER_REJECT : z.hasAttribute("role") ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
1047
+ }, walk(z) {
1048
+ z.setAttribute("role", "none");
1049
+ } });
1050
+ let ie = Me([R == null ? void 0 : R.id]), ee = ge({ open: b === v.Open, option: void 0 }), he = _(() => {
1051
+ a.actions.setActivationTrigger(Y.Pointer);
1052
+ }), p = _((z) => {
1053
+ z.preventDefault(), a.actions.setActivationTrigger(Y.Pointer);
1054
+ }), K = Te(g ? M() : {}, { "aria-labelledby": ie, role: "listbox", "aria-multiselectable": c.mode === q.Multi ? !0 : void 0, id: l, ref: T, style: { ...m.style, ...y, "--input-width": Fe($, A, !0).width, "--button-width": Fe($, R, !0).width }, onWheel: U === Y.Pointer ? void 0 : he, onMouseDown: p, ...$t(O) }), F = $ && b === v.Closed && !t.static, N = _e(F, (e = c.virtual) == null ? void 0 : e.options), P = _e(F, c.value), V = X((z) => c.compare(P, z), [c.compare, P]), I = se(() => {
1055
+ if (!c.virtual) return c;
1056
+ if (N === void 0) throw new Error("Missing `options` in virtual mode");
1057
+ return N !== c.virtual.options ? { ...c, virtual: { ...c.virtual, options: N } } : c;
1058
+ }, [c, N, (o = c.virtual) == null ? void 0 : o.options]);
1059
+ c.virtual && Object.assign(m, { children: W.createElement(me.Provider, { value: I }, W.createElement(On, { slot: ee }, m.children)) });
1060
+ let te = xe(), it = se(() => c.mode === q.Multi ? c : { ...c, isSelected: V }, [c, V]);
1061
+ return W.createElement(Pt, { enabled: d ? t.static || $ : !1, ownerDocument: H }, W.createElement(me.Provider, { value: it }, te({ ourProps: K, theirProps: { ...m, children: W.createElement(At, { freeze: F }, typeof m.children == "function" ? (n = m.children) == null ? void 0 : n.call(m, ee) : m.children) }, slot: ee, defaultTag: Tn, features: Rn, visible: Z, name: "Combobox.Options" })));
1062
+ }
1063
+ let Pn = "div";
1064
+ function An(t, i) {
1065
+ var e, o, n;
1066
+ let s = ce("Combobox.Option"), l = Se("Combobox.Option"), r = be(), { id: u = `headlessui-combobox-option-${r}`, value: d, disabled: h = (n = (o = (e = s.virtual) == null ? void 0 : e.disabled) == null ? void 0 : o.call(e, d)) != null ? n : !1, order: f = null, ...m } = t, [a] = L(l, (O) => [O.inputElement]), c = Je(a), g = L(l, X((O) => l.selectors.isActive(O, d, u), [d, u])), x = s.isSelected(d), y = J(null), w = Ft({ disabled: h, value: d, domRef: y, order: f }), C = Ie(tt), M = ye(i, y, C ? C.measureElement : null), T = _(() => {
1067
+ l.actions.setIsTyping(!1), l.actions.onChange(d);
1068
+ });
1069
+ Q(() => l.actions.registerOption(u, w), [w, u]);
1070
+ let b = L(l, X((O) => l.selectors.shouldScrollIntoView(O, d, u), [d, u]));
1071
+ Q(() => {
1072
+ if (b) return _t().requestAnimationFrame(() => {
1073
+ var O, j;
1074
+ (j = (O = y.current) == null ? void 0 : O.scrollIntoView) == null || j.call(O, { block: "nearest" });
1075
+ });
1076
+ }, [b, y]);
1077
+ let A = _((O) => {
1078
+ O.preventDefault(), O.button === kt.Left && (h || (T(), zt() || requestAnimationFrame(() => c()), s.mode === q.Single && l.actions.closeCombobox()));
1079
+ }), R = _(() => {
1080
+ if (h) return l.actions.goToOption({ focus: D.Nothing });
1081
+ let O = s.calculateIndex(d);
1082
+ l.actions.goToOption({ focus: D.Specific, idx: O });
1083
+ }), k = Dt(), U = _((O) => k.update(O)), H = _((O) => {
1084
+ if (!k.wasMoved(O) || h || g && l.state.activationTrigger === Y.Pointer) return;
1085
+ let j = s.calculateIndex(d);
1086
+ l.actions.goToOption({ focus: D.Specific, idx: j }, Y.Pointer);
1087
+ }), E = _((O) => {
1088
+ k.wasMoved(O) && (h || g && (s.optionsPropsRef.current.hold || l.state.activationTrigger === Y.Pointer && l.actions.goToOption({ focus: D.Nothing })));
1089
+ }), S = ge({ active: g, focus: g, selected: x, disabled: h }), $ = { id: u, ref: M, role: "option", tabIndex: h === !0 ? void 0 : -1, "aria-disabled": h === !0 ? !0 : void 0, "aria-selected": x, disabled: void 0, onMouseDown: A, onFocus: R, onPointerEnter: U, onMouseEnter: U, onPointerMove: H, onMouseMove: H, onPointerLeave: E, onMouseLeave: E };
1090
+ return xe()({ ourProps: $, theirProps: m, slot: S, defaultTag: Pn, name: "Combobox.Option" });
1091
+ }
1092
+ let Fn = ve(yn), _n = ve(Mn), nt = ve(In), kn = vt, ot = ve($n), st = ve(An), zn = Object.assign(Fn, { Input: nt, Button: _n, Label: kn, Options: ot, Option: st });
1093
+ const Dn = {
1094
+ "bottom start": "bottom-start",
1095
+ "bottom end": "bottom-end",
1096
+ "top start": "top-start",
1097
+ "top end": "top-end"
1098
+ }, Ln = "text-neutral-content hover:text-base-content hover:bg-base-200 flex size-4 shrink-0 items-center justify-center rounded-md opacity-70 hover:opacity-100 transition-[color,background-color,opacity]";
1099
+ function Nn(t, i) {
1100
+ var o;
1101
+ if (!i) return !0;
1102
+ const e = i.toLowerCase();
1103
+ return !!(t.label.toLowerCase().includes(e) || t.id.toLowerCase().includes(e) || (o = t.keywords) != null && o.some((n) => n.toLowerCase().includes(e)));
1104
+ }
1105
+ function Vn(t) {
1106
+ return /* @__PURE__ */ re(Be, { children: [
1107
+ /* @__PURE__ */ G("span", { className: "min-w-0 flex-1 truncate", children: t.label }),
1108
+ t.hint && /* @__PURE__ */ G("span", { className: "text-neutral-content shrink-0 text-[10px]", children: t.hint })
1109
+ ] });
1110
+ }
1111
+ function Wn({
1112
+ trigger: t,
1113
+ triggerClassName: i = Ln,
1114
+ triggerAriaLabel: e,
1115
+ onTriggerClick: o,
1116
+ items: n,
1117
+ onSelect: s,
1118
+ searchPlaceholder: l = "Type to search...",
1119
+ emptyMessage: r = "Nothing to add",
1120
+ noResultsMessage: u = (y) => `No matches for "${y}"`,
1121
+ anchor: d = "bottom end",
1122
+ panelWidthClass: h = "w-64",
1123
+ filterFn: f = Nn,
1124
+ renderItem: m = Vn,
1125
+ multiSelect: a = !1,
1126
+ onSelectMany: c,
1127
+ applyLabel: g = (y) => `Add${y ? ` (${y})` : ""}`
1128
+ }, x) {
1129
+ const [y, w] = ae(!1), [C, M] = ae(""), [T, b] = ae([]), A = J(null);
1130
+ rt(
1131
+ x,
1132
+ () => ({
1133
+ open: () => w(!0),
1134
+ close: () => w(!1)
1135
+ }),
1136
+ []
1137
+ );
1138
+ const R = X(() => {
1139
+ w(!1), M(""), b([]);
1140
+ }, []), k = X((S) => {
1141
+ b(($) => {
1142
+ const O = $.findIndex((j) => j.id === S.id);
1143
+ return O === -1 ? [...$, S] : [...$.slice(0, O), ...$.slice(O + 1)];
1144
+ });
1145
+ }, []), U = X(() => {
1146
+ T.length && c && c(T), R();
1147
+ }, [T, c, R]), H = X(() => {
1148
+ o == null || o(), w((S) => !S);
1149
+ }, [o]), E = se(
1150
+ () => n.filter((S) => f(S, C)),
1151
+ [n, C, f]
1152
+ );
1153
+ return /* @__PURE__ */ re(Be, { children: [
1154
+ /* @__PURE__ */ G(
1155
+ "button",
1156
+ {
1157
+ ref: A,
1158
+ type: "button",
1159
+ className: i,
1160
+ "aria-label": e,
1161
+ "aria-expanded": y,
1162
+ onClick: H,
1163
+ children: t
1164
+ }
1165
+ ),
1166
+ /* @__PURE__ */ G(
1167
+ tn,
1168
+ {
1169
+ open: y,
1170
+ onOpenChange: w,
1171
+ anchor: A,
1172
+ placement: Dn[d],
1173
+ ignoreOutsideClicks: [A],
1174
+ className: `pagehub-sdk-root border-base-300 bg-base-100 ${h} overflow-hidden rounded-xl border p-1 shadow-xl`,
1175
+ children: /* @__PURE__ */ re(
1176
+ zn,
1177
+ {
1178
+ value: null,
1179
+ onChange: (S) => {
1180
+ if (S) {
1181
+ if (a) {
1182
+ k(S);
1183
+ return;
1184
+ }
1185
+ s(S), R();
1186
+ }
1187
+ },
1188
+ children: [
1189
+ /* @__PURE__ */ re("div", { className: "border-base-300/60 mb-1 flex items-center gap-1.5 border-b px-2 py-1.5", children: [
1190
+ /* @__PURE__ */ G(Qt, { className: "text-neutral-content size-3.5 shrink-0", "aria-hidden": !0 }),
1191
+ /* @__PURE__ */ G(
1192
+ nt,
1193
+ {
1194
+ autoFocus: !0,
1195
+ value: C,
1196
+ onChange: (S) => M(S.target.value),
1197
+ placeholder: l,
1198
+ displayValue: () => C,
1199
+ className: "text-base-content placeholder:text-neutral-content min-w-0 flex-1 bg-transparent text-xs outline-none"
1200
+ }
1201
+ )
1202
+ ] }),
1203
+ /* @__PURE__ */ G(ot, { static: !0, as: "div", className: "scrollbar max-h-60 overflow-y-auto", children: E.length === 0 ? /* @__PURE__ */ G("div", { className: "text-neutral-content px-3 py-4 text-center text-xs italic", children: n.length === 0 ? r : u(C) }) : E.map((S) => {
1204
+ const $ = a && T.some((O) => O.id === S.id);
1205
+ return /* @__PURE__ */ re(
1206
+ st,
1207
+ {
1208
+ value: S,
1209
+ "data-tooltip-id": S.help ? Zt : void 0,
1210
+ "data-tooltip-content": S.help,
1211
+ "data-tooltip-place": "right",
1212
+ className: ({ focus: O }) => `flex w-full cursor-pointer items-center justify-between gap-2 rounded-md px-3 py-1.5 text-left text-xs transition-colors ${O ? "bg-base-200 text-base-content" : "text-base-content"}`,
1213
+ children: [
1214
+ a && /* @__PURE__ */ G(
1215
+ "span",
1216
+ {
1217
+ "aria-hidden": !0,
1218
+ className: `flex size-3.5 shrink-0 items-center justify-center rounded-sm border transition-colors ${$ ? "bg-primary border-primary text-primary-content" : "border-base-300 bg-base-100"}`,
1219
+ children: $ && /* @__PURE__ */ G(en, { className: "size-2.5" })
1220
+ }
1221
+ ),
1222
+ m(S)
1223
+ ]
1224
+ },
1225
+ S.id
1226
+ );
1227
+ }) }),
1228
+ a && /* @__PURE__ */ re("div", { className: "border-base-300/60 mt-1 flex items-center justify-between gap-2 border-t px-2 py-1.5", children: [
1229
+ /* @__PURE__ */ G("span", { className: "text-neutral-content text-[10px]", children: T.length ? `${T.length} selected` : "Pick one or more" }),
1230
+ /* @__PURE__ */ G(
1231
+ "button",
1232
+ {
1233
+ type: "button",
1234
+ onClick: U,
1235
+ disabled: T.length === 0,
1236
+ className: "bg-primary text-primary-content rounded-md px-2.5 py-1 text-xs font-medium transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",
1237
+ children: g(T.length)
1238
+ }
1239
+ )
1240
+ ] })
1241
+ ]
1242
+ }
1243
+ )
1244
+ }
1245
+ )
1246
+ ] });
1247
+ }
1248
+ const Gn = lt(Wn);
1249
+ export {
1250
+ Gn as S
1251
+ };