@yoast/ai-insights-client 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1432 +0,0 @@
1
- import { r as h, G as We, U as Y, H as qe, I as S, J as Q, K as W, N as Ue, Q as he, R as x, V as Ke, W as Ge, X as He, Y as Je, Z as Qe, $ as Z, a0 as te, a1 as Xe, a2 as ne, a3 as ye, a4 as Ye, a5 as Ze, a6 as le, a7 as et, a8 as ve, a9 as tt, aa as nt, ab as Oe, ac as P, ad as Ce, ae as ot, af as L, ag as Se, ah as at, ai as Re, aj as it, l as rt, u as _e, _ as X, c as me, ak as lt, al as st, am as ut, B as ct, an as dt, P as O, ao as pt, a as ft, ap as mt, n as ht, aq as vt, j as E, v as Ee, ar as bt, m as pe, as as Ie, z as gt, at as xt, p as yt } from "./index-B56vBhjW.js";
2
- import { P as Ot } from "./PaperActions-CJVyQXH2.js";
3
- function H(t, l, n) {
4
- let e = n.initialDeps ?? [], o;
5
- function i() {
6
- var a, s, p, u;
7
- let d;
8
- n.key && ((a = n.debug) != null && a.call(n)) && (d = Date.now());
9
- const v = t();
10
- if (!(v.length !== e.length || v.some((m, y) => e[y] !== m)))
11
- return o;
12
- e = v;
13
- let r;
14
- if (n.key && ((s = n.debug) != null && s.call(n)) && (r = Date.now()), o = l(...v), n.key && ((p = n.debug) != null && p.call(n))) {
15
- const m = Math.round((Date.now() - d) * 100) / 100, y = Math.round((Date.now() - r) * 100) / 100, C = y / 16, g = (I, w) => {
16
- for (I = String(I); I.length < w; )
17
- I = " " + I;
18
- return I;
19
- };
20
- console.info(
21
- `%c⏱ ${g(y, 5)} /${g(m, 5)} ms`,
22
- `
23
- font-size: .6rem;
24
- font-weight: bold;
25
- color: hsl(${Math.max(
26
- 0,
27
- Math.min(120 - 120 * C, 120)
28
- )}deg 100% 31%);`,
29
- n?.key
30
- );
31
- }
32
- return (u = n?.onChange) == null || u.call(n, o), o;
33
- }
34
- return i.updateDeps = (a) => {
35
- e = a;
36
- }, i;
37
- }
38
- function Te(t, l) {
39
- if (t === void 0)
40
- throw new Error("Unexpected undefined");
41
- return t;
42
- }
43
- const Ct = (t, l) => Math.abs(t - l) < 1.01, St = (t, l, n) => {
44
- let e;
45
- return function(...o) {
46
- t.clearTimeout(e), e = t.setTimeout(() => l.apply(this, o), n);
47
- };
48
- }, we = (t) => {
49
- const { offsetWidth: l, offsetHeight: n } = t;
50
- return { width: l, height: n };
51
- }, Rt = (t) => t, Et = (t) => {
52
- const l = Math.max(t.startIndex - t.overscan, 0), n = Math.min(t.endIndex + t.overscan, t.count - 1), e = [];
53
- for (let o = l; o <= n; o++)
54
- e.push(o);
55
- return e;
56
- }, It = (t, l) => {
57
- const n = t.scrollElement;
58
- if (!n)
59
- return;
60
- const e = t.targetWindow;
61
- if (!e)
62
- return;
63
- const o = (a) => {
64
- const { width: s, height: p } = a;
65
- l({ width: Math.round(s), height: Math.round(p) });
66
- };
67
- if (o(we(n)), !e.ResizeObserver)
68
- return () => {
69
- };
70
- const i = new e.ResizeObserver((a) => {
71
- const s = () => {
72
- const p = a[0];
73
- if (p?.borderBoxSize) {
74
- const u = p.borderBoxSize[0];
75
- if (u) {
76
- o({ width: u.inlineSize, height: u.blockSize });
77
- return;
78
- }
79
- }
80
- o(we(n));
81
- };
82
- t.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(s) : s();
83
- });
84
- return i.observe(n, { box: "border-box" }), () => {
85
- i.unobserve(n);
86
- };
87
- }, Me = {
88
- passive: !0
89
- }, Ae = typeof window > "u" ? !0 : "onscrollend" in window, Tt = (t, l) => {
90
- const n = t.scrollElement;
91
- if (!n)
92
- return;
93
- const e = t.targetWindow;
94
- if (!e)
95
- return;
96
- let o = 0;
97
- const i = t.options.useScrollendEvent && Ae ? () => {
98
- } : St(
99
- e,
100
- () => {
101
- l(o, !1);
102
- },
103
- t.options.isScrollingResetDelay
104
- ), a = (d) => () => {
105
- const { horizontal: v, isRtl: c } = t.options;
106
- o = v ? n.scrollLeft * (c && -1 || 1) : n.scrollTop, i(), l(o, d);
107
- }, s = a(!0), p = a(!1);
108
- p(), n.addEventListener("scroll", s, Me);
109
- const u = t.options.useScrollendEvent && Ae;
110
- return u && n.addEventListener("scrollend", p, Me), () => {
111
- n.removeEventListener("scroll", s), u && n.removeEventListener("scrollend", p);
112
- };
113
- }, wt = (t, l, n) => {
114
- if (l?.borderBoxSize) {
115
- const e = l.borderBoxSize[0];
116
- if (e)
117
- return Math.round(
118
- e[n.options.horizontal ? "inlineSize" : "blockSize"]
119
- );
120
- }
121
- return t[n.options.horizontal ? "offsetWidth" : "offsetHeight"];
122
- }, Mt = (t, {
123
- adjustments: l = 0,
124
- behavior: n
125
- }, e) => {
126
- var o, i;
127
- const a = t + l;
128
- (i = (o = e.scrollElement) == null ? void 0 : o.scrollTo) == null || i.call(o, {
129
- [e.options.horizontal ? "left" : "top"]: a,
130
- behavior: n
131
- });
132
- };
133
- class At {
134
- constructor(l) {
135
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
136
- let n = null;
137
- const e = () => n || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : n = new this.targetWindow.ResizeObserver((o) => {
138
- o.forEach((i) => {
139
- const a = () => {
140
- this._measureElement(i.target, i);
141
- };
142
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(a) : a();
143
- });
144
- }));
145
- return {
146
- disconnect: () => {
147
- var o;
148
- (o = e()) == null || o.disconnect(), n = null;
149
- },
150
- observe: (o) => {
151
- var i;
152
- return (i = e()) == null ? void 0 : i.observe(o, { box: "border-box" });
153
- },
154
- unobserve: (o) => {
155
- var i;
156
- return (i = e()) == null ? void 0 : i.unobserve(o);
157
- }
158
- };
159
- })(), this.range = null, this.setOptions = (n) => {
160
- Object.entries(n).forEach(([e, o]) => {
161
- typeof o > "u" && delete n[e];
162
- }), this.options = {
163
- debug: !1,
164
- initialOffset: 0,
165
- overscan: 1,
166
- paddingStart: 0,
167
- paddingEnd: 0,
168
- scrollPaddingStart: 0,
169
- scrollPaddingEnd: 0,
170
- horizontal: !1,
171
- getItemKey: Rt,
172
- rangeExtractor: Et,
173
- onChange: () => {
174
- },
175
- measureElement: wt,
176
- initialRect: { width: 0, height: 0 },
177
- scrollMargin: 0,
178
- gap: 0,
179
- indexAttribute: "data-index",
180
- initialMeasurementsCache: [],
181
- lanes: 1,
182
- isScrollingResetDelay: 150,
183
- enabled: !0,
184
- isRtl: !1,
185
- useScrollendEvent: !1,
186
- useAnimationFrameWithResizeObserver: !1,
187
- ...n
188
- };
189
- }, this.notify = (n) => {
190
- var e, o;
191
- (o = (e = this.options).onChange) == null || o.call(e, this, n);
192
- }, this.maybeNotify = H(
193
- () => (this.calculateRange(), [
194
- this.isScrolling,
195
- this.range ? this.range.startIndex : null,
196
- this.range ? this.range.endIndex : null
197
- ]),
198
- (n) => {
199
- this.notify(n);
200
- },
201
- {
202
- key: process.env.NODE_ENV !== "production" && "maybeNotify",
203
- debug: () => this.options.debug,
204
- initialDeps: [
205
- this.isScrolling,
206
- this.range ? this.range.startIndex : null,
207
- this.range ? this.range.endIndex : null
208
- ]
209
- }
210
- ), this.cleanup = () => {
211
- this.unsubs.filter(Boolean).forEach((n) => n()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
212
- }, this._didMount = () => () => {
213
- this.cleanup();
214
- }, this._willUpdate = () => {
215
- var n;
216
- const e = this.options.enabled ? this.options.getScrollElement() : null;
217
- if (this.scrollElement !== e) {
218
- if (this.cleanup(), !e) {
219
- this.maybeNotify();
220
- return;
221
- }
222
- this.scrollElement = e, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((n = this.scrollElement) == null ? void 0 : n.window) ?? null, this.elementsCache.forEach((o) => {
223
- this.observer.observe(o);
224
- }), this._scrollToOffset(this.getScrollOffset(), {
225
- adjustments: void 0,
226
- behavior: void 0
227
- }), this.unsubs.push(
228
- this.options.observeElementRect(this, (o) => {
229
- this.scrollRect = o, this.maybeNotify();
230
- })
231
- ), this.unsubs.push(
232
- this.options.observeElementOffset(this, (o, i) => {
233
- this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o, this.isScrolling = i, this.maybeNotify();
234
- })
235
- );
236
- }
237
- }, 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 = (n, e) => {
238
- const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
239
- for (let a = e - 1; a >= 0; a--) {
240
- const s = n[a];
241
- if (o.has(s.lane))
242
- continue;
243
- const p = i.get(
244
- s.lane
245
- );
246
- if (p == null || s.end > p.end ? i.set(s.lane, s) : s.end < p.end && o.set(s.lane, !0), o.size === this.options.lanes)
247
- break;
248
- }
249
- return i.size === this.options.lanes ? Array.from(i.values()).sort((a, s) => a.end === s.end ? a.index - s.index : a.end - s.end)[0] : void 0;
250
- }, this.getMeasurementOptions = H(
251
- () => [
252
- this.options.count,
253
- this.options.paddingStart,
254
- this.options.scrollMargin,
255
- this.options.getItemKey,
256
- this.options.enabled
257
- ],
258
- (n, e, o, i, a) => (this.pendingMeasuredCacheIndexes = [], {
259
- count: n,
260
- paddingStart: e,
261
- scrollMargin: o,
262
- getItemKey: i,
263
- enabled: a
264
- }),
265
- {
266
- key: !1
267
- }
268
- ), this.getMeasurements = H(
269
- () => [this.getMeasurementOptions(), this.itemSizeCache],
270
- ({ count: n, paddingStart: e, scrollMargin: o, getItemKey: i, enabled: a }, s) => {
271
- if (!a)
272
- return this.measurementsCache = [], this.itemSizeCache.clear(), [];
273
- this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((d) => {
274
- this.itemSizeCache.set(d.key, d.size);
275
- }));
276
- const p = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
277
- this.pendingMeasuredCacheIndexes = [];
278
- const u = this.measurementsCache.slice(0, p);
279
- for (let d = p; d < n; d++) {
280
- const v = i(d), c = this.options.lanes === 1 ? u[d - 1] : this.getFurthestMeasurement(u, d), r = c ? c.end + this.options.gap : e + o, m = s.get(v), y = typeof m == "number" ? m : this.options.estimateSize(d), C = r + y, g = c ? c.lane : d % this.options.lanes;
281
- u[d] = {
282
- index: d,
283
- start: r,
284
- size: y,
285
- end: C,
286
- key: v,
287
- lane: g
288
- };
289
- }
290
- return this.measurementsCache = u, u;
291
- },
292
- {
293
- key: process.env.NODE_ENV !== "production" && "getMeasurements",
294
- debug: () => this.options.debug
295
- }
296
- ), this.calculateRange = H(
297
- () => [
298
- this.getMeasurements(),
299
- this.getSize(),
300
- this.getScrollOffset(),
301
- this.options.lanes
302
- ],
303
- (n, e, o, i) => this.range = n.length > 0 && e > 0 ? Pt({
304
- measurements: n,
305
- outerSize: e,
306
- scrollOffset: o,
307
- lanes: i
308
- }) : null,
309
- {
310
- key: process.env.NODE_ENV !== "production" && "calculateRange",
311
- debug: () => this.options.debug
312
- }
313
- ), this.getVirtualIndexes = H(
314
- () => {
315
- let n = null, e = null;
316
- const o = this.calculateRange();
317
- return o && (n = o.startIndex, e = o.endIndex), this.maybeNotify.updateDeps([this.isScrolling, n, e]), [
318
- this.options.rangeExtractor,
319
- this.options.overscan,
320
- this.options.count,
321
- n,
322
- e
323
- ];
324
- },
325
- (n, e, o, i, a) => i === null || a === null ? [] : n({
326
- startIndex: i,
327
- endIndex: a,
328
- overscan: e,
329
- count: o
330
- }),
331
- {
332
- key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
333
- debug: () => this.options.debug
334
- }
335
- ), this.indexFromElement = (n) => {
336
- const e = this.options.indexAttribute, o = n.getAttribute(e);
337
- return o ? parseInt(o, 10) : (console.warn(
338
- `Missing attribute name '${e}={index}' on measured element.`
339
- ), -1);
340
- }, this._measureElement = (n, e) => {
341
- const o = this.indexFromElement(n), i = this.measurementsCache[o];
342
- if (!i)
343
- return;
344
- const a = i.key, s = this.elementsCache.get(a);
345
- s !== n && (s && this.observer.unobserve(s), this.observer.observe(n), this.elementsCache.set(a, n)), n.isConnected && this.resizeItem(o, this.options.measureElement(n, e, this));
346
- }, this.resizeItem = (n, e) => {
347
- const o = this.measurementsCache[n];
348
- if (!o)
349
- return;
350
- const i = this.itemSizeCache.get(o.key) ?? o.size, a = e - i;
351
- a !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(o, a, this) : o.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", a), this._scrollToOffset(this.getScrollOffset(), {
352
- adjustments: this.scrollAdjustments += a,
353
- behavior: void 0
354
- })), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, e)), this.notify(!1));
355
- }, this.measureElement = (n) => {
356
- if (!n) {
357
- this.elementsCache.forEach((e, o) => {
358
- e.isConnected || (this.observer.unobserve(e), this.elementsCache.delete(o));
359
- });
360
- return;
361
- }
362
- this._measureElement(n, void 0);
363
- }, this.getVirtualItems = H(
364
- () => [this.getVirtualIndexes(), this.getMeasurements()],
365
- (n, e) => {
366
- const o = [];
367
- for (let i = 0, a = n.length; i < a; i++) {
368
- const s = n[i], p = e[s];
369
- o.push(p);
370
- }
371
- return o;
372
- },
373
- {
374
- key: process.env.NODE_ENV !== "production" && "getVirtualItems",
375
- debug: () => this.options.debug
376
- }
377
- ), this.getVirtualItemForOffset = (n) => {
378
- const e = this.getMeasurements();
379
- if (e.length !== 0)
380
- return Te(
381
- e[Ne(
382
- 0,
383
- e.length - 1,
384
- (o) => Te(e[o]).start,
385
- n
386
- )]
387
- );
388
- }, this.getOffsetForAlignment = (n, e, o = 0) => {
389
- const i = this.getSize(), a = this.getScrollOffset();
390
- e === "auto" && (e = n >= a + i ? "end" : "start"), e === "center" ? n += (o - i) / 2 : e === "end" && (n -= i);
391
- const s = this.getTotalSize() + this.options.scrollMargin - i;
392
- return Math.max(Math.min(s, n), 0);
393
- }, this.getOffsetForIndex = (n, e = "auto") => {
394
- n = Math.max(0, Math.min(n, this.options.count - 1));
395
- const o = this.measurementsCache[n];
396
- if (!o)
397
- return;
398
- const i = this.getSize(), a = this.getScrollOffset();
399
- if (e === "auto")
400
- if (o.end >= a + i - this.options.scrollPaddingEnd)
401
- e = "end";
402
- else if (o.start <= a + this.options.scrollPaddingStart)
403
- e = "start";
404
- else
405
- return [a, e];
406
- const s = e === "end" ? o.end + this.options.scrollPaddingEnd : o.start - this.options.scrollPaddingStart;
407
- return [
408
- this.getOffsetForAlignment(s, e, o.size),
409
- e
410
- ];
411
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (n, { align: e = "start", behavior: o } = {}) => {
412
- o === "smooth" && this.isDynamicMode() && console.warn(
413
- "The `smooth` scroll behavior is not fully supported with dynamic size."
414
- ), this._scrollToOffset(this.getOffsetForAlignment(n, e), {
415
- adjustments: void 0,
416
- behavior: o
417
- });
418
- }, this.scrollToIndex = (n, { align: e = "auto", behavior: o } = {}) => {
419
- o === "smooth" && this.isDynamicMode() && console.warn(
420
- "The `smooth` scroll behavior is not fully supported with dynamic size."
421
- ), n = Math.max(0, Math.min(n, this.options.count - 1));
422
- let i = 0;
423
- const a = 10, s = (u) => {
424
- if (!this.targetWindow) return;
425
- const d = this.getOffsetForIndex(n, u);
426
- if (!d) {
427
- console.warn("Failed to get offset for index:", n);
428
- return;
429
- }
430
- const [v, c] = d;
431
- this._scrollToOffset(v, { adjustments: void 0, behavior: o }), this.targetWindow.requestAnimationFrame(() => {
432
- const r = this.getScrollOffset(), m = this.getOffsetForIndex(n, c);
433
- if (!m) {
434
- console.warn("Failed to get offset for index:", n);
435
- return;
436
- }
437
- Ct(m[0], r) || p(c);
438
- });
439
- }, p = (u) => {
440
- this.targetWindow && (i++, i < a ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, a), this.targetWindow.requestAnimationFrame(() => s(u))) : console.warn(
441
- `Failed to scroll to index ${n} after ${a} attempts.`
442
- ));
443
- };
444
- s(e);
445
- }, this.scrollBy = (n, { behavior: e } = {}) => {
446
- e === "smooth" && this.isDynamicMode() && console.warn(
447
- "The `smooth` scroll behavior is not fully supported with dynamic size."
448
- ), this._scrollToOffset(this.getScrollOffset() + n, {
449
- adjustments: void 0,
450
- behavior: e
451
- });
452
- }, this.getTotalSize = () => {
453
- var n;
454
- const e = this.getMeasurements();
455
- let o;
456
- if (e.length === 0)
457
- o = this.options.paddingStart;
458
- else if (this.options.lanes === 1)
459
- o = ((n = e[e.length - 1]) == null ? void 0 : n.end) ?? 0;
460
- else {
461
- const i = Array(this.options.lanes).fill(null);
462
- let a = e.length - 1;
463
- for (; a >= 0 && i.some((s) => s === null); ) {
464
- const s = e[a];
465
- i[s.lane] === null && (i[s.lane] = s.end), a--;
466
- }
467
- o = Math.max(...i.filter((s) => s !== null));
468
- }
469
- return Math.max(
470
- o - this.options.scrollMargin + this.options.paddingEnd,
471
- 0
472
- );
473
- }, this._scrollToOffset = (n, {
474
- adjustments: e,
475
- behavior: o
476
- }) => {
477
- this.options.scrollToFn(n, { behavior: o, adjustments: e }, this);
478
- }, this.measure = () => {
479
- this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
480
- }, this.setOptions(l);
481
- }
482
- }
483
- const Ne = (t, l, n, e) => {
484
- for (; t <= l; ) {
485
- const o = (t + l) / 2 | 0, i = n(o);
486
- if (i < e)
487
- t = o + 1;
488
- else if (i > e)
489
- l = o - 1;
490
- else
491
- return o;
492
- }
493
- return t > 0 ? t - 1 : 0;
494
- };
495
- function Pt({
496
- measurements: t,
497
- outerSize: l,
498
- scrollOffset: n,
499
- lanes: e
500
- }) {
501
- const o = t.length - 1, i = (p) => t[p].start;
502
- if (t.length <= e)
503
- return {
504
- startIndex: 0,
505
- endIndex: o
506
- };
507
- let a = Ne(
508
- 0,
509
- o,
510
- i,
511
- n
512
- ), s = a;
513
- if (e === 1)
514
- for (; s < o && t[s].end < n + l; )
515
- s++;
516
- else if (e > 1) {
517
- const p = Array(e).fill(0);
518
- for (; s < o && p.some((d) => d < n + l); ) {
519
- const d = t[s];
520
- p[d.lane] = d.end, s++;
521
- }
522
- const u = Array(e).fill(n + l);
523
- for (; a >= 0 && u.some((d) => d >= n); ) {
524
- const d = t[a];
525
- u[d.lane] = d.start, a--;
526
- }
527
- a = Math.max(0, a - a % e), s = Math.min(o, s + (e - 1 - s % e));
528
- }
529
- return { startIndex: a, endIndex: s };
530
- }
531
- const Pe = typeof document < "u" ? h.useLayoutEffect : h.useEffect;
532
- function Ft(t) {
533
- const l = h.useReducer(() => ({}), {})[1], n = {
534
- ...t,
535
- onChange: (o, i) => {
536
- var a;
537
- i ? We.flushSync(l) : l(), (a = t.onChange) == null || a.call(t, o, i);
538
- }
539
- }, [e] = h.useState(
540
- () => new At(n)
541
- );
542
- return e.setOptions(n), Pe(() => e._didMount(), []), Pe(() => e._willUpdate()), e;
543
- }
544
- function _t(t) {
545
- return Ft({
546
- observeElementRect: It,
547
- observeElementOffset: Tt,
548
- scrollToFn: Mt,
549
- ...t
550
- });
551
- }
552
- var Nt = ((t) => (t[t.Open = 0] = "Open", t[t.Closed = 1] = "Closed", t))(Nt || {}), Dt = ((t) => (t[t.Single = 0] = "Single", t[t.Multi = 1] = "Multi", t))(Dt || {}), zt = ((t) => (t[t.Pointer = 0] = "Pointer", t[t.Focus = 1] = "Focus", t[t.Other = 2] = "Other", t))(zt || {}), kt = ((t) => (t[t.OpenCombobox = 0] = "OpenCombobox", t[t.CloseCombobox = 1] = "CloseCombobox", t[t.GoToOption = 2] = "GoToOption", t[t.RegisterOption = 3] = "RegisterOption", t[t.UnregisterOption = 4] = "UnregisterOption", t[t.RegisterLabel = 5] = "RegisterLabel", t[t.SetActivationTrigger = 6] = "SetActivationTrigger", t[t.UpdateVirtualOptions = 7] = "UpdateVirtualOptions", t))(kt || {});
553
- function fe(t, l = (n) => n) {
554
- let n = t.activeOptionIndex !== null ? t.options[t.activeOptionIndex] : null, e = l(t.options.slice()), o = e.length > 0 && e[0].dataRef.current.order !== null ? e.sort((a, s) => a.dataRef.current.order - s.dataRef.current.order) : ot(e, (a) => a.dataRef.current.domRef.current), i = n ? o.indexOf(n) : null;
555
- return i === -1 && (i = null), { options: o, activeOptionIndex: i };
556
- }
557
- let $t = { 1(t) {
558
- var l;
559
- return (l = t.dataRef.current) != null && l.disabled || t.comboboxState === 1 ? t : { ...t, activeOptionIndex: null, comboboxState: 1 };
560
- }, 0(t) {
561
- var l, n;
562
- if ((l = t.dataRef.current) != null && l.disabled || t.comboboxState === 0) return t;
563
- if ((n = t.dataRef.current) != null && n.value) {
564
- let e = t.dataRef.current.calculateIndex(t.dataRef.current.value);
565
- if (e !== -1) return { ...t, activeOptionIndex: e, comboboxState: 0 };
566
- }
567
- return { ...t, comboboxState: 0 };
568
- }, 2(t, l) {
569
- var n, e, o, i, a;
570
- if ((n = t.dataRef.current) != null && n.disabled || (e = t.dataRef.current) != null && e.optionsRef.current && !((o = t.dataRef.current) != null && o.optionsPropsRef.current.static) && t.comboboxState === 1) return t;
571
- if (t.virtual) {
572
- let d = l.focus === P.Specific ? l.idx : Ce(l, { resolveItems: () => t.virtual.options, resolveActiveIndex: () => {
573
- var c, r;
574
- return (r = (c = t.activeOptionIndex) != null ? c : t.virtual.options.findIndex((m) => !t.virtual.disabled(m))) != null ? r : null;
575
- }, resolveDisabled: t.virtual.disabled, resolveId() {
576
- throw new Error("Function not implemented.");
577
- } }), v = (i = l.trigger) != null ? i : 2;
578
- return t.activeOptionIndex === d && t.activationTrigger === v ? t : { ...t, activeOptionIndex: d, activationTrigger: v };
579
- }
580
- let s = fe(t);
581
- if (s.activeOptionIndex === null) {
582
- let d = s.options.findIndex((v) => !v.dataRef.current.disabled);
583
- d !== -1 && (s.activeOptionIndex = d);
584
- }
585
- let p = l.focus === P.Specific ? l.idx : Ce(l, { resolveItems: () => s.options, resolveActiveIndex: () => s.activeOptionIndex, resolveId: (d) => d.id, resolveDisabled: (d) => d.dataRef.current.disabled }), u = (a = l.trigger) != null ? a : 2;
586
- return t.activeOptionIndex === p && t.activationTrigger === u ? t : { ...t, ...s, activeOptionIndex: p, activationTrigger: u };
587
- }, 3: (t, l) => {
588
- var n, e, o;
589
- if ((n = t.dataRef.current) != null && n.virtual) return { ...t, options: [...t.options, l.payload] };
590
- let i = l.payload, a = fe(t, (p) => (p.push(i), p));
591
- t.activeOptionIndex === null && (e = t.dataRef.current) != null && e.isSelected(l.payload.dataRef.current.value) && (a.activeOptionIndex = a.options.indexOf(i));
592
- let s = { ...t, ...a, activationTrigger: 2 };
593
- return (o = t.dataRef.current) != null && o.__demoMode && t.dataRef.current.value === void 0 && (s.activeOptionIndex = 0), s;
594
- }, 4: (t, l) => {
595
- var n;
596
- if ((n = t.dataRef.current) != null && n.virtual) return { ...t, options: t.options.filter((o) => o.id !== l.id) };
597
- let e = fe(t, (o) => {
598
- let i = o.findIndex((a) => a.id === l.id);
599
- return i !== -1 && o.splice(i, 1), o;
600
- });
601
- return { ...t, ...e, activationTrigger: 2 };
602
- }, 5: (t, l) => t.labelId === l.id ? t : { ...t, labelId: l.id }, 6: (t, l) => t.activationTrigger === l.trigger ? t : { ...t, activationTrigger: l.trigger }, 7: (t, l) => {
603
- var n;
604
- if (((n = t.virtual) == null ? void 0 : n.options) === l.options) return t;
605
- let e = t.activeOptionIndex;
606
- if (t.activeOptionIndex !== null) {
607
- let o = l.options.indexOf(t.virtual.options[t.activeOptionIndex]);
608
- o !== -1 ? e = o : e = null;
609
- }
610
- return { ...t, activeOptionIndex: e, virtual: Object.assign({}, t.virtual, { options: l.options }) };
611
- } }, be = h.createContext(null);
612
- be.displayName = "ComboboxActionsContext";
613
- function oe(t) {
614
- let l = h.useContext(be);
615
- if (l === null) {
616
- let n = new Error(`<${t} /> is missing a parent <Combobox /> component.`);
617
- throw Error.captureStackTrace && Error.captureStackTrace(n, oe), n;
618
- }
619
- return l;
620
- }
621
- let De = h.createContext(null);
622
- function Lt(t) {
623
- var l;
624
- let n = K("VirtualProvider"), [e, o] = h.useMemo(() => {
625
- let p = n.optionsRef.current;
626
- if (!p) return [0, 0];
627
- let u = window.getComputedStyle(p);
628
- return [parseFloat(u.paddingBlockStart || u.paddingTop), parseFloat(u.paddingBlockEnd || u.paddingBottom)];
629
- }, [n.optionsRef.current]), i = _t({ scrollPaddingStart: e, scrollPaddingEnd: o, count: n.virtual.options.length, estimateSize() {
630
- return 40;
631
- }, getScrollElement() {
632
- var p;
633
- return (p = n.optionsRef.current) != null ? p : null;
634
- }, overscan: 12 }), [a, s] = h.useState(0);
635
- return W(() => {
636
- s((p) => p + 1);
637
- }, [(l = n.virtual) == null ? void 0 : l.options]), x.createElement(De.Provider, { value: i }, x.createElement("div", { style: { position: "relative", width: "100%", height: `${i.getTotalSize()}px` }, ref: (p) => {
638
- if (p) {
639
- if (typeof process < "u" && process.env.JEST_WORKER_ID !== void 0 || n.activationTrigger === 0) return;
640
- n.activeOptionIndex !== null && n.virtual.options.length > n.activeOptionIndex && i.scrollToIndex(n.activeOptionIndex);
641
- }
642
- } }, i.getVirtualItems().map((p) => {
643
- var u;
644
- return x.createElement(h.Fragment, { key: p.key }, x.cloneElement((u = t.children) == null ? void 0 : u.call(t, { option: n.virtual.options[p.index], open: n.comboboxState === 0 }), { key: `${a}-${p.key}`, "data-index": p.index, "aria-setsize": n.virtual.options.length, "aria-posinset": p.index + 1, style: { position: "absolute", top: 0, left: 0, transform: `translateY(${p.start}px)`, overflowAnchor: "none" } }));
645
- })));
646
- }
647
- let ge = h.createContext(null);
648
- ge.displayName = "ComboboxDataContext";
649
- function K(t) {
650
- let l = h.useContext(ge);
651
- if (l === null) {
652
- let n = new Error(`<${t} /> is missing a parent <Combobox /> component.`);
653
- throw Error.captureStackTrace && Error.captureStackTrace(n, K), n;
654
- }
655
- return l;
656
- }
657
- function jt(t, l) {
658
- return Q(l.type, $t, t, l);
659
- }
660
- let Bt = h.Fragment;
661
- function Vt(t, l) {
662
- let { value: n, defaultValue: e, onChange: o, form: i, name: a, by: s = null, disabled: p = !1, __demoMode: u = !1, nullable: d = !1, multiple: v = !1, immediate: c = !1, virtual: r = null, ...m } = t, y = !1, C = null, [g = v ? [] : void 0, I] = qe(n, o, e), [w, _] = h.useReducer(jt, { dataRef: h.createRef(), comboboxState: u ? 0 : 1, options: [], virtual: null, activeOptionIndex: null, activationTrigger: 2, labelId: null }), N = h.useRef(!1), V = h.useRef({ static: !1, hold: !1 }), q = h.useRef(null), G = h.useRef(null), ee = h.useRef(null), M = h.useRef(null), T = S(typeof s == "string" ? (b, R) => {
663
- let z = s;
664
- return b?.[z] === R?.[z];
665
- } : s ?? ((b, R) => b === R)), k = S((b) => w.options.findIndex((R) => T(R.dataRef.current.value, b))), se = h.useCallback((b) => Q(f.mode, { 1: () => g.some((R) => T(R, b)), 0: () => T(g, b) }), [g]), ue = S((b) => w.activeOptionIndex === k(b)), f = h.useMemo(() => ({ ...w, immediate: y, optionsPropsRef: V, labelRef: q, inputRef: G, buttonRef: ee, optionsRef: M, value: g, defaultValue: e, disabled: p, mode: v ? 1 : 0, virtual: w.virtual, get activeOptionIndex() {
666
- if (N.current && w.activeOptionIndex === null && w.options.length > 0) {
667
- let b = w.options.findIndex((R) => !R.dataRef.current.disabled);
668
- if (b !== -1) return b;
669
- }
670
- return w.activeOptionIndex;
671
- }, calculateIndex: k, compare: T, isSelected: se, isActive: ue, nullable: d, __demoMode: u }), [g, e, p, v, d, u, w, C]);
672
- W(() => {
673
- }, [C, void 0]), W(() => {
674
- w.dataRef.current = f;
675
- }, [f]), Ue([f.buttonRef, f.inputRef, f.optionsRef], () => de.closeCombobox(), f.comboboxState === 0);
676
- let D = h.useMemo(() => {
677
- var b, R, z;
678
- return { open: f.comboboxState === 0, disabled: p, activeIndex: f.activeOptionIndex, activeOption: f.activeOptionIndex === null ? null : f.virtual ? f.virtual.options[(b = f.activeOptionIndex) != null ? b : 0] : (z = (R = f.options[f.activeOptionIndex]) == null ? void 0 : R.dataRef.current.value) != null ? z : null, value: g };
679
- }, [f, p, g]), F = S(() => {
680
- if (f.activeOptionIndex !== null) {
681
- if (f.virtual) ce(f.virtual.options[f.activeOptionIndex]);
682
- else {
683
- let { dataRef: b } = f.options[f.activeOptionIndex];
684
- ce(b.current.value);
685
- }
686
- de.goToOption(P.Specific, f.activeOptionIndex);
687
- }
688
- }), j = S(() => {
689
- _({ type: 0 }), N.current = !0;
690
- }), A = S(() => {
691
- _({ type: 1 }), N.current = !1;
692
- }), $ = S((b, R, z) => (N.current = !1, b === P.Specific ? _({ type: 2, focus: P.Specific, idx: R, trigger: z }) : _({ type: 2, focus: b, trigger: z }))), U = S((b, R) => (_({ type: 3, payload: { id: b, dataRef: R } }), () => {
693
- f.isActive(R.current.value) && (N.current = !0), _({ type: 4, id: b });
694
- })), Le = S((b) => (_({ type: 5, id: b }), () => _({ type: 5, id: null }))), ce = S((b) => Q(f.mode, { 0() {
695
- return I?.(b);
696
- }, 1() {
697
- let R = f.value.slice(), z = R.findIndex((ie) => T(ie, b));
698
- return z === -1 ? R.push(b) : R.splice(z, 1), I?.(R);
699
- } })), je = S((b) => {
700
- _({ type: 6, trigger: b });
701
- }), de = h.useMemo(() => ({ onChange: ce, registerOption: U, registerLabel: Le, goToOption: $, closeCombobox: A, openCombobox: j, setActivationTrigger: je, selectActiveOption: F }), []), Be = l === null ? {} : { ref: l }, ae = h.useRef(null), Ve = he();
702
- return h.useEffect(() => {
703
- ae.current && e !== void 0 && Ve.addEventListener(ae.current, "reset", () => {
704
- I?.(e);
705
- });
706
- }, [ae, I]), x.createElement(be.Provider, { value: de }, x.createElement(ge.Provider, { value: f }, x.createElement(Ke, { value: Q(f.comboboxState, { 0: le.Open, 1: le.Closed }) }, a != null && g != null && Ge({ [a]: g }).map(([b, R], z) => x.createElement(He, { features: Qe.Hidden, ref: z === 0 ? (ie) => {
707
- var xe;
708
- ae.current = (xe = ie?.closest("form")) != null ? xe : null;
709
- } : void 0, ...Je({ key: b, as: "input", type: "hidden", hidden: !0, readOnly: !0, form: i, disabled: p, name: b, value: R }) })), Z({ ourProps: Be, theirProps: m, slot: D, defaultTag: Bt, name: "Combobox" }))));
710
- }
711
- let Wt = "input";
712
- function qt(t, l) {
713
- var n, e, o, i, a;
714
- let s = te(), { id: p = `headlessui-combobox-input-${s}`, onChange: u, displayValue: d, type: v = "text", ...c } = t, r = K("Combobox.Input"), m = oe("Combobox.Input"), y = ne(r.inputRef, l), C = nt(r.inputRef), g = h.useRef(!1), I = he(), w = S(() => {
715
- m.onChange(null), r.optionsRef.current && (r.optionsRef.current.scrollTop = 0), m.goToOption(P.Nothing);
716
- }), _ = function() {
717
- var f;
718
- return typeof d == "function" && r.value !== void 0 ? (f = d(r.value)) != null ? f : "" : typeof r.value == "string" ? r.value : "";
719
- }();
720
- Oe(([f, D], [F, j]) => {
721
- if (g.current) return;
722
- let A = r.inputRef.current;
723
- A && ((j === 0 && D === 1 || f !== F) && (A.value = f), requestAnimationFrame(() => {
724
- if (g.current || !A || C?.activeElement !== A) return;
725
- let { selectionStart: $, selectionEnd: U } = A;
726
- Math.abs((U ?? 0) - ($ ?? 0)) === 0 && $ === 0 && A.setSelectionRange(A.value.length, A.value.length);
727
- }));
728
- }, [_, r.comboboxState, C]), Oe(([f], [D]) => {
729
- if (f === 0 && D === 1) {
730
- if (g.current) return;
731
- let F = r.inputRef.current;
732
- if (!F) return;
733
- let j = F.value, { selectionStart: A, selectionEnd: $, selectionDirection: U } = F;
734
- F.value = "", F.value = j, U !== null ? F.setSelectionRange(A, $, U) : F.setSelectionRange(A, $);
735
- }
736
- }, [r.comboboxState]);
737
- let N = h.useRef(!1), V = S(() => {
738
- N.current = !0;
739
- }), q = S(() => {
740
- I.nextFrame(() => {
741
- N.current = !1;
742
- });
743
- }), G = S((f) => {
744
- switch (g.current = !0, f.key) {
745
- case L.Enter:
746
- if (g.current = !1, r.comboboxState !== 0 || N.current) return;
747
- if (f.preventDefault(), f.stopPropagation(), r.activeOptionIndex === null) {
748
- m.closeCombobox();
749
- return;
750
- }
751
- m.selectActiveOption(), r.mode === 0 && m.closeCombobox();
752
- break;
753
- case L.ArrowDown:
754
- return g.current = !1, f.preventDefault(), f.stopPropagation(), Q(r.comboboxState, { 0: () => m.goToOption(P.Next), 1: () => m.openCombobox() });
755
- case L.ArrowUp:
756
- return g.current = !1, f.preventDefault(), f.stopPropagation(), Q(r.comboboxState, { 0: () => m.goToOption(P.Previous), 1: () => {
757
- m.openCombobox(), I.nextFrame(() => {
758
- r.value || m.goToOption(P.Last);
759
- });
760
- } });
761
- case L.Home:
762
- if (f.shiftKey) break;
763
- return g.current = !1, f.preventDefault(), f.stopPropagation(), m.goToOption(P.First);
764
- case L.PageUp:
765
- return g.current = !1, f.preventDefault(), f.stopPropagation(), m.goToOption(P.First);
766
- case L.End:
767
- if (f.shiftKey) break;
768
- return g.current = !1, f.preventDefault(), f.stopPropagation(), m.goToOption(P.Last);
769
- case L.PageDown:
770
- return g.current = !1, f.preventDefault(), f.stopPropagation(), m.goToOption(P.Last);
771
- case L.Escape:
772
- return g.current = !1, r.comboboxState !== 0 ? void 0 : (f.preventDefault(), r.optionsRef.current && !r.optionsPropsRef.current.static && f.stopPropagation(), r.nullable && r.mode === 0 && r.value === null && w(), m.closeCombobox());
773
- case L.Tab:
774
- if (g.current = !1, r.comboboxState !== 0) return;
775
- r.mode === 0 && r.activationTrigger !== 1 && m.selectActiveOption(), m.closeCombobox();
776
- break;
777
- }
778
- }), ee = S((f) => {
779
- u?.(f), r.nullable && r.mode === 0 && f.target.value === "" && w(), m.openCombobox();
780
- }), M = S((f) => {
781
- var D, F, j;
782
- let A = (D = f.relatedTarget) != null ? D : Se.find(($) => $ !== f.currentTarget);
783
- if (g.current = !1, !((F = r.optionsRef.current) != null && F.contains(A)) && !((j = r.buttonRef.current) != null && j.contains(A)) && r.comboboxState === 0) return f.preventDefault(), r.mode === 0 && (r.nullable && r.value === null ? w() : r.activationTrigger !== 1 && m.selectActiveOption()), m.closeCombobox();
784
- }), T = S((f) => {
785
- var D, F, j;
786
- let A = (D = f.relatedTarget) != null ? D : Se.find(($) => $ !== f.currentTarget);
787
- (F = r.buttonRef.current) != null && F.contains(A) || (j = r.optionsRef.current) != null && j.contains(A) || r.disabled || r.immediate && r.comboboxState !== 0 && (m.openCombobox(), I.nextFrame(() => {
788
- m.setActivationTrigger(1);
789
- }));
790
- }), k = ve(() => {
791
- if (r.labelId) return [r.labelId].join(" ");
792
- }, [r.labelId]), se = h.useMemo(() => ({ open: r.comboboxState === 0, disabled: r.disabled }), [r]), ue = { ref: y, id: p, role: "combobox", type: v, "aria-controls": (n = r.optionsRef.current) == null ? void 0 : n.id, "aria-expanded": r.comboboxState === 0, "aria-activedescendant": r.activeOptionIndex === null ? void 0 : r.virtual ? (e = r.options.find((f) => {
793
- var D;
794
- return !((D = r.virtual) != null && D.disabled(f.dataRef.current.value)) && r.compare(f.dataRef.current.value, r.virtual.options[r.activeOptionIndex]);
795
- })) == null ? void 0 : e.id : (o = r.options[r.activeOptionIndex]) == null ? void 0 : o.id, "aria-labelledby": k, "aria-autocomplete": "list", defaultValue: (a = (i = t.defaultValue) != null ? i : r.defaultValue !== void 0 ? d?.(r.defaultValue) : null) != null ? a : r.defaultValue, disabled: r.disabled, onCompositionStart: V, onCompositionEnd: q, onKeyDown: G, onChange: ee, onFocus: T, onBlur: M };
796
- return Z({ ourProps: ue, theirProps: c, slot: se, defaultTag: Wt, name: "Combobox.Input" });
797
- }
798
- let Ut = "button";
799
- function Kt(t, l) {
800
- var n;
801
- let e = K("Combobox.Button"), o = oe("Combobox.Button"), i = ne(e.buttonRef, l), a = te(), { id: s = `headlessui-combobox-button-${a}`, ...p } = t, u = he(), d = S((y) => {
802
- switch (y.key) {
803
- case L.ArrowDown:
804
- return y.preventDefault(), y.stopPropagation(), e.comboboxState === 1 && o.openCombobox(), u.nextFrame(() => {
805
- var C;
806
- return (C = e.inputRef.current) == null ? void 0 : C.focus({ preventScroll: !0 });
807
- });
808
- case L.ArrowUp:
809
- return y.preventDefault(), y.stopPropagation(), e.comboboxState === 1 && (o.openCombobox(), u.nextFrame(() => {
810
- e.value || o.goToOption(P.Last);
811
- })), u.nextFrame(() => {
812
- var C;
813
- return (C = e.inputRef.current) == null ? void 0 : C.focus({ preventScroll: !0 });
814
- });
815
- case L.Escape:
816
- return e.comboboxState !== 0 ? void 0 : (y.preventDefault(), e.optionsRef.current && !e.optionsPropsRef.current.static && y.stopPropagation(), o.closeCombobox(), u.nextFrame(() => {
817
- var C;
818
- return (C = e.inputRef.current) == null ? void 0 : C.focus({ preventScroll: !0 });
819
- }));
820
- default:
821
- return;
822
- }
823
- }), v = S((y) => {
824
- if (at(y.currentTarget)) return y.preventDefault();
825
- e.comboboxState === 0 ? o.closeCombobox() : (y.preventDefault(), o.openCombobox()), u.nextFrame(() => {
826
- var C;
827
- return (C = e.inputRef.current) == null ? void 0 : C.focus({ preventScroll: !0 });
828
- });
829
- }), c = ve(() => {
830
- if (e.labelId) return [e.labelId, s].join(" ");
831
- }, [e.labelId, s]), r = h.useMemo(() => ({ open: e.comboboxState === 0, disabled: e.disabled, value: e.value }), [e]), m = { ref: i, id: s, type: tt(t, e.buttonRef), tabIndex: -1, "aria-haspopup": "listbox", "aria-controls": (n = e.optionsRef.current) == null ? void 0 : n.id, "aria-expanded": e.comboboxState === 0, "aria-labelledby": c, disabled: e.disabled, onClick: v, onKeyDown: d };
832
- return Z({ ourProps: m, theirProps: p, slot: r, defaultTag: Ut, name: "Combobox.Button" });
833
- }
834
- let Gt = "label";
835
- function Ht(t, l) {
836
- let n = te(), { id: e = `headlessui-combobox-label-${n}`, ...o } = t, i = K("Combobox.Label"), a = oe("Combobox.Label"), s = ne(i.labelRef, l);
837
- W(() => a.registerLabel(e), [e]);
838
- let p = S(() => {
839
- var d;
840
- return (d = i.inputRef.current) == null ? void 0 : d.focus({ preventScroll: !0 });
841
- }), u = h.useMemo(() => ({ open: i.comboboxState === 0, disabled: i.disabled }), [i]);
842
- return Z({ ourProps: { ref: s, id: e, onClick: p }, theirProps: o, slot: u, defaultTag: Gt, name: "Combobox.Label" });
843
- }
844
- let Jt = "ul", Qt = Re.RenderStrategy | Re.Static;
845
- function Xt(t, l) {
846
- let n = te(), { id: e = `headlessui-combobox-options-${n}`, hold: o = !1, ...i } = t, a = K("Combobox.Options"), s = ne(a.optionsRef, l), p = Ze(), u = p !== null ? (p & le.Open) === le.Open : a.comboboxState === 0;
847
- W(() => {
848
- var r;
849
- a.optionsPropsRef.current.static = (r = t.static) != null ? r : !1;
850
- }, [a.optionsPropsRef, t.static]), W(() => {
851
- a.optionsPropsRef.current.hold = o;
852
- }, [a.optionsPropsRef, o]), et({ container: a.optionsRef.current, enabled: a.comboboxState === 0, accept(r) {
853
- return r.getAttribute("role") === "option" ? NodeFilter.FILTER_REJECT : r.hasAttribute("role") ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
854
- }, walk(r) {
855
- r.setAttribute("role", "none");
856
- } });
857
- let d = ve(() => {
858
- var r, m;
859
- return (m = a.labelId) != null ? m : (r = a.buttonRef.current) == null ? void 0 : r.id;
860
- }, [a.labelId, a.buttonRef.current]), v = h.useMemo(() => ({ open: a.comboboxState === 0, option: void 0 }), [a]), c = { "aria-labelledby": d, role: "listbox", "aria-multiselectable": a.mode === 1 ? !0 : void 0, id: e, ref: s };
861
- return a.virtual && a.comboboxState === 0 && Object.assign(i, { children: x.createElement(Lt, null, i.children) }), Z({ ourProps: c, theirProps: i, slot: v, defaultTag: Jt, features: Qt, visible: u, name: "Combobox.Options" });
862
- }
863
- let Yt = "li";
864
- function Zt(t, l) {
865
- var n;
866
- let e = te(), { id: o = `headlessui-combobox-option-${e}`, disabled: i = !1, value: a, order: s = null, ...p } = t, u = K("Combobox.Option"), d = oe("Combobox.Option"), v = u.virtual ? u.activeOptionIndex === u.calculateIndex(a) : u.activeOptionIndex === null ? !1 : ((n = u.options[u.activeOptionIndex]) == null ? void 0 : n.id) === o, c = u.isSelected(a), r = h.useRef(null), m = Xe({ disabled: i, value: a, domRef: r, order: s }), y = h.useContext(De), C = ne(l, r, y ? y.measureElement : null), g = S(() => d.onChange(a));
867
- W(() => d.registerOption(o, m), [m, o]);
868
- let I = h.useRef(!(u.virtual || u.__demoMode));
869
- W(() => {
870
- if (!u.virtual || !u.__demoMode) return;
871
- let M = ye();
872
- return M.requestAnimationFrame(() => {
873
- I.current = !0;
874
- }), M.dispose;
875
- }, [u.virtual, u.__demoMode]), W(() => {
876
- if (!I.current || u.comboboxState !== 0 || !v || u.activationTrigger === 0) return;
877
- let M = ye();
878
- return M.requestAnimationFrame(() => {
879
- var T, k;
880
- (k = (T = r.current) == null ? void 0 : T.scrollIntoView) == null || k.call(T, { block: "nearest" });
881
- }), M.dispose;
882
- }, [r, v, u.comboboxState, u.activationTrigger, u.activeOptionIndex]);
883
- let w = S((M) => {
884
- var T;
885
- if (i || (T = u.virtual) != null && T.disabled(a)) return M.preventDefault();
886
- g(), it() || requestAnimationFrame(() => {
887
- var k;
888
- return (k = u.inputRef.current) == null ? void 0 : k.focus({ preventScroll: !0 });
889
- }), u.mode === 0 && requestAnimationFrame(() => d.closeCombobox());
890
- }), _ = S(() => {
891
- var M;
892
- if (i || (M = u.virtual) != null && M.disabled(a)) return d.goToOption(P.Nothing);
893
- let T = u.calculateIndex(a);
894
- d.goToOption(P.Specific, T);
895
- }), N = Ye(), V = S((M) => N.update(M)), q = S((M) => {
896
- var T;
897
- if (!N.wasMoved(M) || i || (T = u.virtual) != null && T.disabled(a) || v) return;
898
- let k = u.calculateIndex(a);
899
- d.goToOption(P.Specific, k, 0);
900
- }), G = S((M) => {
901
- var T;
902
- N.wasMoved(M) && (i || (T = u.virtual) != null && T.disabled(a) || v && (u.optionsPropsRef.current.hold || d.goToOption(P.Nothing)));
903
- }), ee = h.useMemo(() => ({ active: v, selected: c, disabled: i }), [v, c, i]);
904
- return Z({ ourProps: { id: o, ref: C, role: "option", tabIndex: i === !0 ? void 0 : -1, "aria-disabled": i === !0 ? !0 : void 0, "aria-selected": c, disabled: void 0, onClick: w, onFocus: _, onPointerEnter: V, onMouseEnter: V, onPointerMove: q, onMouseMove: q, onPointerLeave: G, onMouseLeave: G }, theirProps: p, slot: ee, defaultTag: Yt, name: "Combobox.Option" });
905
- }
906
- let en = Y(Vt), tn = Y(Kt), nn = Y(qt), on = Y(Ht), an = Y(Xt), rn = Y(Zt), J = Object.assign(en, { Input: nn, Button: tn, Label: on, Options: an, Option: rn });
907
- const ze = /* @__PURE__ */ h.forwardRef((t, l) => /* @__PURE__ */ x.createElement(J.Button, X({
908
- as: "div",
909
- ref: l
910
- }, t)));
911
- ze.displayName = "AutocompleteButton";
912
- const ke = ({
913
- children: t,
914
- value: l
915
- }) => {
916
- const n = _e(), e = h.useCallback(({
917
- active: o,
918
- selected: i
919
- }) => me("yst-autocomplete__option", i && "yst-autocomplete__option--selected", o && !i && "yst-autocomplete__option--active"), []);
920
- return /* @__PURE__ */ x.createElement(J.Option, {
921
- className: e,
922
- value: l
923
- }, ({
924
- selected: o
925
- }) => /* @__PURE__ */ x.createElement(x.Fragment, null, /* @__PURE__ */ x.createElement("span", {
926
- className: me("yst-autocomplete__option-label", o && "yst-font-semibold")
927
- }, t), o && /* @__PURE__ */ x.createElement(pt, X({
928
- className: "yst-autocomplete__option-check"
929
- }, n))));
930
- }, ln = {
931
- children: O.node,
932
- value: O.oneOfType([O.string, O.number, O.bool]).isRequired
933
- };
934
- ke.propTypes = ln;
935
- const $e = ({
936
- onClear: t,
937
- svgAriaProps: l,
938
- screenReaderText: n
939
- }) => {
940
- const e = h.useCallback((o) => {
941
- o.preventDefault(), t(null);
942
- }, [t]);
943
- return /* @__PURE__ */ x.createElement(ct, {
944
- variant: "tertiary",
945
- className: "yst-autocomplete__clear-action",
946
- onClick: e
947
- }, /* @__PURE__ */ x.createElement("span", {
948
- className: "yst-sr-only"
949
- }, n), /* @__PURE__ */ x.createElement(dt, X({
950
- className: "yst-autocomplete__action-icon"
951
- }, l)));
952
- };
953
- $e.propTypes = {
954
- onClear: O.func.isRequired,
955
- svgAriaProps: O.object.isRequired,
956
- screenReaderText: O.string.isRequired
957
- };
958
- const B = /* @__PURE__ */ h.forwardRef(({
959
- id: t,
960
- value: l,
961
- children: n,
962
- selectedLabel: e,
963
- label: o,
964
- labelProps: i,
965
- labelSuffix: a,
966
- onChange: s,
967
- onQueryChange: p,
968
- onClear: u,
969
- validation: d,
970
- placeholder: v,
971
- className: c,
972
- buttonProps: r,
973
- clearButtonScreenReaderText: m,
974
- nullable: y,
975
- disabled: C,
976
- ...g
977
- }, I) => {
978
- const w = h.useCallback(rt.constant(e), [e]), _ = _e(), N = y && e, V = !(d != null && d.message), q = N || V;
979
- return /* @__PURE__ */ x.createElement(J, X({
980
- ref: I,
981
- as: "div",
982
- value: l,
983
- onChange: s,
984
- className: me("yst-autocomplete", C && "yst-autocomplete--disabled", c),
985
- disabled: C
986
- }, g), o && /* @__PURE__ */ x.createElement("div", {
987
- className: "yst-flex yst-items-center yst-mb-2"
988
- }, /* @__PURE__ */ x.createElement(J.Label, i, o), a), /* @__PURE__ */ x.createElement("div", {
989
- className: "yst-relative"
990
- }, /* @__PURE__ */ x.createElement(lt, X({
991
- as: ze,
992
- "data-id": t,
993
- validation: d,
994
- className: "yst-autocomplete__button"
995
- }, r), /* @__PURE__ */ x.createElement(J.Input, {
996
- className: "yst-autocomplete__input",
997
- autoComplete: "off",
998
- placeholder: v,
999
- displayValue: w,
1000
- onChange: p
1001
- }), q && /* @__PURE__ */ x.createElement("div", {
1002
- className: "yst-autocomplete__action-container"
1003
- }, N && /* @__PURE__ */ x.createElement(x.Fragment, null, /* @__PURE__ */ x.createElement($e, {
1004
- onClear: u || s,
1005
- svgAriaProps: _,
1006
- screenReaderText: m
1007
- }), /* @__PURE__ */ x.createElement("hr", {
1008
- className: "yst-autocomplete__action-separator"
1009
- })), V && /* @__PURE__ */ x.createElement(st, X({
1010
- className: "yst-autocomplete__action-icon yst-pointer-events-none"
1011
- }, _)))), /* @__PURE__ */ x.createElement(ut, {
1012
- as: h.Fragment,
1013
- enter: "yst-transition yst-duration-100 yst-ease-out",
1014
- enterFrom: "yst-transform yst-scale-95 yst-opacity-0",
1015
- enterTo: "yst-transform yst-scale-100 yst-opacity-100",
1016
- leave: "yst-transition yst-duration-75 yst-ease-out",
1017
- leaveFrom: "yst-transform yst-scale-100 yst-opacity-100",
1018
- leaveTo: "yst-transform yst-scale-95 yst-opacity-0"
1019
- }, /* @__PURE__ */ x.createElement(J.Options, {
1020
- className: "yst-autocomplete__options"
1021
- }, n))));
1022
- }), sn = {
1023
- id: O.string.isRequired,
1024
- value: O.oneOfType([O.string, O.number, O.bool]),
1025
- children: O.node,
1026
- selectedLabel: O.string,
1027
- label: O.string,
1028
- labelProps: O.object,
1029
- labelSuffix: O.node,
1030
- onChange: O.func.isRequired,
1031
- onQueryChange: O.func.isRequired,
1032
- validation: O.shape({
1033
- variant: O.string,
1034
- message: O.node
1035
- }),
1036
- placeholder: O.string,
1037
- className: O.string,
1038
- buttonProps: O.object,
1039
- clearButtonScreenReaderText: O.string,
1040
- nullable: O.bool,
1041
- onClear: O.func,
1042
- disabled: O.bool
1043
- };
1044
- B.displayName = "Autocomplete";
1045
- B.propTypes = sn;
1046
- B.defaultProps = {
1047
- children: null,
1048
- value: null,
1049
- selectedLabel: "",
1050
- label: "",
1051
- labelProps: {},
1052
- labelSuffix: null,
1053
- validation: {},
1054
- placeholder: "",
1055
- className: "",
1056
- buttonProps: {},
1057
- clearButtonScreenReaderText: "Clear",
1058
- nullable: !1,
1059
- onClear: null,
1060
- disabled: !1
1061
- };
1062
- B.Option = ke;
1063
- B.Option.displayName = "Autocomplete.Option";
1064
- const un = [{
1065
- value: "US",
1066
- label: "United States"
1067
- }, {
1068
- value: "GB",
1069
- label: "United Kingdom"
1070
- }, {
1071
- value: "CA",
1072
- label: "Canada"
1073
- }, {
1074
- value: "AU",
1075
- label: "Australia"
1076
- }, {
1077
- value: "DE",
1078
- label: "Germany"
1079
- }, {
1080
- value: "FR",
1081
- label: "France"
1082
- }, {
1083
- value: "NL",
1084
- label: "Netherlands"
1085
- }], cn = [{
1086
- value: "AR",
1087
- label: "Argentina"
1088
- }, {
1089
- value: "BE",
1090
- label: "Belgium"
1091
- }, {
1092
- value: "BR",
1093
- label: "Brazil"
1094
- }, {
1095
- value: "CN",
1096
- label: "China"
1097
- }, {
1098
- value: "EG",
1099
- label: "Egypt"
1100
- }, {
1101
- value: "ID",
1102
- label: "Indonesia"
1103
- }, {
1104
- value: "IE",
1105
- label: "Ireland"
1106
- }, {
1107
- value: "IL",
1108
- label: "Israel"
1109
- }, {
1110
- value: "IN",
1111
- label: "India"
1112
- }, {
1113
- value: "IT",
1114
- label: "Italy"
1115
- }, {
1116
- value: "JP",
1117
- label: "Japan"
1118
- }, {
1119
- value: "KR",
1120
- label: "South Korea"
1121
- }, {
1122
- value: "MX",
1123
- label: "Mexico"
1124
- }, {
1125
- value: "NG",
1126
- label: "Nigeria"
1127
- }, {
1128
- value: "PL",
1129
- label: "Poland"
1130
- }, {
1131
- value: "RU",
1132
- label: "Russia"
1133
- }, {
1134
- value: "SA",
1135
- label: "Saudi Arabia"
1136
- }, {
1137
- value: "SE",
1138
- label: "Sweden"
1139
- }, {
1140
- value: "ES",
1141
- label: "Spain"
1142
- }, {
1143
- value: "TH",
1144
- label: "Thailand"
1145
- }, {
1146
- value: "TR",
1147
- label: "Turkey"
1148
- }, {
1149
- value: "TW",
1150
- label: "Taiwan"
1151
- }, {
1152
- value: "ZA",
1153
- label: "South Africa"
1154
- }], re = [...un, ...cn, {
1155
- value: "OTHER",
1156
- label: "Other"
1157
- }], dn = [{
1158
- value: "en",
1159
- label: "English"
1160
- }, {
1161
- value: "es",
1162
- label: "Spanish"
1163
- }, {
1164
- value: "fr",
1165
- label: "French"
1166
- }, {
1167
- value: "de",
1168
- label: "German"
1169
- }, {
1170
- value: "zh",
1171
- label: "Chinese (Mandarin)"
1172
- }, {
1173
- value: "ja",
1174
- label: "Japanese"
1175
- }], pn = [{
1176
- value: "ar",
1177
- label: "Arabic"
1178
- }, {
1179
- value: "da",
1180
- label: "Danish"
1181
- }, {
1182
- value: "nl",
1183
- label: "Dutch"
1184
- }, {
1185
- value: "fi",
1186
- label: "Finnish"
1187
- }, {
1188
- value: "hi",
1189
- label: "Hindi"
1190
- }, {
1191
- value: "it",
1192
- label: "Italian"
1193
- }, {
1194
- value: "ko",
1195
- label: "Korean"
1196
- }, {
1197
- value: "no",
1198
- label: "Norwegian"
1199
- }, {
1200
- value: "pl",
1201
- label: "Polish"
1202
- }, {
1203
- value: "pt",
1204
- label: "Portuguese"
1205
- }, {
1206
- value: "ru",
1207
- label: "Russian"
1208
- }, {
1209
- value: "sv",
1210
- label: "Swedish"
1211
- }, {
1212
- value: "th",
1213
- label: "Thai"
1214
- }, {
1215
- value: "tr",
1216
- label: "Turkish"
1217
- }], fn = [
1218
- ...dn,
1219
- // separator,
1220
- ...pn
1221
- ], Fe = [
1222
- // Technology & Software
1223
- "Software",
1224
- "SaaS",
1225
- "Mobile Apps",
1226
- "Web Development",
1227
- "Cybersecurity",
1228
- "AI/Machine Learning",
1229
- "Cloud Computing",
1230
- "Data Analytics",
1231
- "IT Services",
1232
- "Gaming",
1233
- // E-commerce & Retail
1234
- "E-commerce",
1235
- "Online Retail",
1236
- "Fashion Retail",
1237
- "Electronics Retail",
1238
- "Home Goods",
1239
- "Sporting Goods",
1240
- "Jewelry",
1241
- "Beauty Products",
1242
- "Automotive Parts",
1243
- "Books & Media",
1244
- // Professional Services
1245
- "Consulting",
1246
- "Legal Services",
1247
- "Accounting",
1248
- "Marketing Agency",
1249
- "Public Relations",
1250
- "HR Services",
1251
- "Business Coaching",
1252
- "Financial Advisory",
1253
- "Real Estate",
1254
- "Insurance",
1255
- // Healthcare & Wellness
1256
- "Healthcare",
1257
- "Dental",
1258
- "Mental Health",
1259
- "Fitness",
1260
- "Spa & Wellness",
1261
- "Nutrition",
1262
- "Medical Device",
1263
- "Pharmacy",
1264
- "Veterinary",
1265
- "Alternative Medicine",
1266
- // Creative & Media
1267
- "Photography",
1268
- "Graphic Design",
1269
- "Video Production",
1270
- "Marketing",
1271
- "Advertising",
1272
- "Content Creation",
1273
- "Music",
1274
- "Art & Design",
1275
- "Entertainment",
1276
- "Publishing",
1277
- // Food & Beverage
1278
- "Restaurant",
1279
- "Cafe",
1280
- "Food Delivery",
1281
- "Catering",
1282
- "Bakery",
1283
- "Brewery",
1284
- "Wine",
1285
- "Food Production",
1286
- "Grocery",
1287
- "Food Truck",
1288
- // Education & Training
1289
- "Education",
1290
- "Online Learning",
1291
- "Training",
1292
- "Coaching",
1293
- "Tutoring",
1294
- "Language Learning",
1295
- "Professional Development",
1296
- "Childcare",
1297
- "University",
1298
- "Certification",
1299
- // Manufacturing & Industrial
1300
- "Manufacturing",
1301
- "Construction",
1302
- "Engineering",
1303
- "Automotive",
1304
- "Aerospace",
1305
- "Chemical",
1306
- "Textile",
1307
- "Furniture",
1308
- "Packaging",
1309
- "Industrial Equipment",
1310
- // Travel & Hospitality
1311
- "Travel",
1312
- "Hotel",
1313
- "Tourism",
1314
- "Event Planning",
1315
- "Transportation",
1316
- "Airline",
1317
- "Cruise",
1318
- "Car Rental",
1319
- "Vacation Rental",
1320
- "Adventure Tours",
1321
- // Non-Profit & Government
1322
- "Non-Profit",
1323
- "Charity",
1324
- "Government",
1325
- "Religious Organization",
1326
- "Community Service",
1327
- "Environmental",
1328
- "Political",
1329
- "Social Services",
1330
- "Foundation",
1331
- "Advocacy"
1332
- ], vn = () => {
1333
- const t = ft(), l = mt(), n = ht(), [e, o] = h.useState({
1334
- name: "",
1335
- url: "",
1336
- industry: "",
1337
- language: "en",
1338
- isLocal: !1,
1339
- country: "",
1340
- region: ""
1341
- }), [i, a] = h.useState(Fe), {
1342
- mutate: s,
1343
- isPending: p,
1344
- error: u
1345
- } = vt({
1346
- mutation: {
1347
- onSuccess: (c) => {
1348
- console.log("Brand created successfully", c.data.id), n.invalidateQueries({
1349
- queryKey: [xt(), yt()]
1350
- }), l.setBrandId(c.data.id), c?.status && c.status >= 200 && c.status < 300 && c?.data?.id && (l.setBrandId(c.data.id), t("/setup/queries"));
1351
- },
1352
- onError: (c) => {
1353
- console.log("Error creating brand:", c);
1354
- }
1355
- }
1356
- }), d = (c, r) => {
1357
- o((m) => ({
1358
- ...m,
1359
- [c]: r
1360
- }));
1361
- }, v = (c) => {
1362
- c.preventDefault();
1363
- let r = e.url;
1364
- r && !/^https?:\/\//i.test(r) && (r = `https://${r}`), s({
1365
- data: {
1366
- name: e.name,
1367
- url: r,
1368
- industry: e.industry,
1369
- focusLanguage: e.language,
1370
- isLocalFocus: e.isLocal,
1371
- country: e.country,
1372
- regionOrCity: e.region
1373
- }
1374
- });
1375
- };
1376
- return /* @__PURE__ */ E.jsxs("form", { onSubmit: v, children: [
1377
- /* @__PURE__ */ E.jsxs("div", { className: "yst-space-y-4", children: [
1378
- /* @__PURE__ */ E.jsx(Ee, { size: "2", children: "Brand info" }),
1379
- u && /* @__PURE__ */ E.jsx(bt, { variant: "error", title: "Error", isVisible: !!u, children: /* @__PURE__ */ E.jsx("ul", { children: u?.response?.data?.error ? Object.entries(u.response.data.error).flatMap(([c, r]) => Array.isArray(r) ? r.map((m, y) => /* @__PURE__ */ E.jsx("li", { children: m }, `${c}-${y}`)) : null) : "There was an error creating the brand." }) }),
1380
- /* @__PURE__ */ E.jsx(
1381
- pe,
1382
- {
1383
- id: "name",
1384
- label: "Brand name",
1385
- value: e.name,
1386
- onChange: (c) => d("name", c.target.value)
1387
- }
1388
- ),
1389
- /* @__PURE__ */ E.jsx(pe, { id: "url", label: "Website URL (optional)", placeholder: "Example: https://yourwebsite.com", value: e.url, onChange: (c) => d("url", c.target.value) }),
1390
- /* @__PURE__ */ E.jsxs(B, { className: "yst-max-w-sm", clearButtonScreenReaderText: "Clear selection", id: "industry", label: "Industry", labelProps: {
1391
- className: "yst-text-slate-800 yst-font-medium"
1392
- }, nullable: !0, onChange: (c) => d("industry", c), onQueryChange: (c) => {
1393
- a([c.target.value, ...Fe.filter(
1394
- // includes any matching the user input
1395
- (r) => r.toLowerCase().includes(c.target.value.toLowerCase())
1396
- )]);
1397
- }, placeholder: "Select or type your industry...", selectedLabel: e.industry, value: e.industry, children: [
1398
- !i.find((c) => c === e.industry) && e.industry && /* @__PURE__ */ E.jsx(B.Option, { value: e.industry, children: e.industry }),
1399
- i.map((c) => /* @__PURE__ */ E.jsx(B.Option, { value: c, children: c }, c))
1400
- ] }),
1401
- /* @__PURE__ */ E.jsxs("div", { className: "yst-space-y-2", children: [
1402
- /* @__PURE__ */ E.jsx(Ie, { className: "yst-max-w-sm", id: "language-select", label: "Target language", value: e.language, onChange: (c) => d("language", c), options: fn.map((c) => ({
1403
- label: c.label,
1404
- value: c.value
1405
- })) }),
1406
- /* @__PURE__ */ E.jsx("p", { children: "The main language your brand uses to communicate or create content." })
1407
- ] })
1408
- ] }),
1409
- /* @__PURE__ */ E.jsx(gt, {}),
1410
- /* @__PURE__ */ E.jsxs("div", { className: "yst-space-y-4", children: [
1411
- /* @__PURE__ */ E.jsx(Ee, { size: "2", children: "Location info" }),
1412
- /* @__PURE__ */ E.jsx("p", { children: "You can specify a location to help focus the analysis." }),
1413
- /* @__PURE__ */ E.jsx(Ie, { className: "yst-max-w-sm", id: "language-select", label: "Target country (optional)", value: e.country, placeholder: "Select...", onChange: (c) => d("country", c), options: [{
1414
- label: "Select...",
1415
- value: "none"
1416
- }, ...re].map((c) => ({
1417
- label: c.label,
1418
- value: c.value
1419
- })) }),
1420
- /* @__PURE__ */ E.jsxs(B, { className: "yst-hidden yst-max-w-sm", clearButtonScreenReaderText: "Clear selection", id: "country", label: "Which country do you operate in?", nullable: !0, onChange: (c) => d("country", c), onQueryChange: (c) => d("country", c.target.value), placeholder: "Select or type your country...", selectedLabel: re.find((c) => c.value === e.country)?.label || e.country, value: e.country, children: [
1421
- !re.find((c) => c.value === e.country) && e.country && /* @__PURE__ */ E.jsx(B.Option, { value: e.country, children: e.country }),
1422
- re.map((c) => /* @__PURE__ */ E.jsx(B.Option, { value: c.value, children: c.label }, c.value))
1423
- ] }),
1424
- e.country && /* @__PURE__ */ E.jsx(pe, { id: "region", label: "Target city, state, or region (optional)", value: e.region, onChange: (c) => d("region", c.target.value), description: `Enter a city, state, or region to narrow down the analysis. For
1425
- example: California, Bavaria, or Paris.` })
1426
- ] }),
1427
- /* @__PURE__ */ E.jsx(Ot, { sparkCost: 1, onBack: () => t(-1), buttonText: "Generate queries", isButtonDisabled: p, isLoading: p })
1428
- ] });
1429
- };
1430
- export {
1431
- vn as default
1432
- };