@uiwwsw/virtual-keyboard 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,46 +1,46 @@
1
1
  "use client";
2
- import { jsxs as q, jsx as C, Fragment as ze } from "react/jsx-runtime";
3
- import { useContext as qe, createContext as Ze, forwardRef as We, useId as Be, useRef as P, useState as R, useMemo as Ke, useCallback as k, useEffect as V, useImperativeHandle as _e, createElement as Je } from "react";
4
- import { convertQwertyToHangul as Re, assemble as Ge, removeLastCharacter as Qe } from "es-hangul";
5
- import { createPortal as ke } from "react-dom";
6
- class Oe {
2
+ import { jsxs as Y, jsx as L, Fragment as Pe } from "react/jsx-runtime";
3
+ import { useContext as tt, createContext as nt, forwardRef as rt, useId as qe, useRef as T, useState as $, useMemo as Fe, useCallback as E, useEffect as K, useImperativeHandle as ot, useLayoutEffect as at, createElement as ct } from "react";
4
+ import { convertQwertyToHangul as Ye, assemble as it, removeLastCharacter as lt } from "es-hangul";
5
+ import { createPortal as Ie } from "react-dom";
6
+ class ut {
7
7
  past = [];
8
8
  future = [];
9
- record(r, n) {
10
- r.value !== n.value && (r.composing && n.composing && this.past.length || (this.past.push({ ...r, composing: !1 }), this.past.length > 100 && this.past.shift()), this.future = []);
9
+ record(n, r) {
10
+ n.value !== r.value && (n.composing && r.composing && this.past.length || (this.past.push({ ...n, composing: !1 }), this.past.length > 100 && this.past.shift()), this.future = []);
11
11
  }
12
- undo(r) {
13
- const n = this.past.pop();
14
- return n ? (this.future.push({ ...r, composing: !1 }), n) : r;
12
+ undo(n) {
13
+ const r = this.past.pop();
14
+ return r ? (this.future.push({ ...n, composing: !1 }), r) : n;
15
15
  }
16
- redo(r) {
17
- const n = this.future.pop();
18
- return n ? (this.past.push({ ...r, composing: !1 }), n) : r;
16
+ redo(n) {
17
+ const r = this.future.pop();
18
+ return r ? (this.past.push({ ...n, composing: !1 }), r) : n;
19
19
  }
20
20
  clear() {
21
21
  this.past = [], this.future = [];
22
22
  }
23
23
  }
24
- const He = Ze(null);
25
- function Fe() {
26
- const e = qe(He);
24
+ const Ze = nt(null);
25
+ function _e() {
26
+ const e = tt(Ze);
27
27
  if (!e)
28
28
  throw new Error(
29
29
  "VirtualInput must be used within a <VirtualInputProvider>."
30
30
  );
31
31
  return e;
32
32
  }
33
- function fe(e) {
33
+ function we(e) {
34
34
  return /^[\u1100-\u11FF\u3130-\u318F\uAC00-\uD7AF]$/.test(e);
35
35
  }
36
- function et(e, r) {
36
+ function st(e, n) {
37
37
  if (e.key === "HangulMode") return { handled: !0, toggleHangulMode: !0 };
38
38
  if (e.ctrlKey || e.metaKey || e.altKey || [...e.key].length !== 1 || /[\r\n\t]/.test(e.key))
39
39
  return { handled: !1 };
40
- const n = r && /^[A-Za-z]$/.test(e.key) ? Re(e.key) : e.key;
41
- return { handled: !0, text: n, composing: fe(n) };
40
+ const r = n && /^[A-Za-z]$/.test(e.key) ? Ye(e.key) : e.key;
41
+ return { handled: !0, text: r, composing: we(r) };
42
42
  }
43
- const G = [
43
+ const ee = [
44
44
  [
45
45
  {
46
46
  label: "q",
@@ -211,7 +211,7 @@ const G = [
211
211
  width: 1.25
212
212
  }
213
213
  ]
214
- ], tt = [
214
+ ], dt = [
215
215
  [
216
216
  {
217
217
  label: "1",
@@ -280,7 +280,7 @@ const G = [
280
280
  type: "action"
281
281
  }
282
282
  ]
283
- ], rt = [
283
+ ], ft = [
284
284
  [
285
285
  {
286
286
  label: "1",
@@ -363,7 +363,7 @@ const G = [
363
363
  }
364
364
  ]
365
365
  ];
366
- function de(e) {
366
+ function ge(e) {
367
367
  switch (e) {
368
368
  case "hangul":
369
369
  return !0;
@@ -376,34 +376,34 @@ function de(e) {
376
376
  return null;
377
377
  }
378
378
  }
379
- const se = () => !0, nt = {
379
+ const he = () => !0, pt = {
380
380
  text: {
381
381
  mode: "text",
382
- layout: G,
383
- filterKey: se,
382
+ layout: ee,
383
+ filterKey: he,
384
384
  sanitizeValue: (e) => e.replace(/[\r\n\t]+/g, " ")
385
385
  },
386
386
  number: {
387
387
  mode: "number",
388
- layout: tt,
388
+ layout: dt,
389
389
  filterKey: (e) => /^[0-9.]+$/.test(e),
390
390
  sanitizeValue: (e) => e.replace(/[^0-9.]/g, "")
391
391
  },
392
392
  tel: {
393
393
  mode: "tel",
394
- layout: rt,
394
+ layout: ft,
395
395
  filterKey: (e) => /^[0-9*#+]+$/.test(e),
396
396
  sanitizeValue: (e) => e.replace(/[^0-9*#+]/g, "")
397
397
  },
398
398
  hangul: {
399
399
  mode: "hangul",
400
- layout: G,
401
- filterKey: se,
400
+ layout: ee,
401
+ filterKey: he,
402
402
  sanitizeValue: (e) => e.replace(/[A-Za-z]/g, "")
403
403
  },
404
404
  alpha: {
405
405
  mode: "alpha",
406
- layout: G,
406
+ layout: ee,
407
407
  filterKey: (e) => /^[A-Za-z]+$/.test(e),
408
408
  sanitizeValue: (e) => e.replace(/[^A-Za-z]/g, "")
409
409
  },
@@ -411,270 +411,362 @@ const se = () => !0, nt = {
411
411
  mode: "alphanumeric",
412
412
  layout: [
413
413
  Array.from("1234567890", (e) => ({ value: e })),
414
- ...G
414
+ ...ee
415
415
  ],
416
416
  filterKey: (e) => /^[A-Za-z0-9]+$/.test(e),
417
417
  sanitizeValue: (e) => e.replace(/[^A-Za-z0-9]/g, "")
418
418
  },
419
419
  custom: {
420
420
  mode: "custom",
421
- layout: G,
422
- filterKey: se,
421
+ layout: ee,
422
+ filterKey: he,
423
423
  sanitizeValue: (e) => e.replace(/[\r\n\t]+/g, " ")
424
424
  }
425
425
  };
426
- function ye(e) {
427
- const r = e?.mode ?? "text", n = nt[r];
426
+ function Le(e) {
427
+ const n = e?.mode ?? "text", r = pt[n];
428
428
  return {
429
- mode: r,
430
- layout: e?.layout ?? n.layout ?? G,
431
- filterKey: e?.filterKey ?? n.filterKey ?? se,
432
- sanitizeValue: e?.sanitizeValue ?? n.sanitizeValue ?? ((o) => o)
429
+ mode: n,
430
+ layout: e?.layout ?? r.layout ?? ee,
431
+ filterKey: e?.filterKey ?? r.filterKey ?? he,
432
+ sanitizeValue: e?.sanitizeValue ?? r.sanitizeValue ?? ((a) => a)
433
433
  };
434
434
  }
435
- const ot = new Intl.Segmenter(void 0, { granularity: "grapheme" }), at = new Intl.Segmenter(void 0, { granularity: "word" });
436
- function it(e, r) {
437
- const n = Math.max(0, Math.min(r, e.length - 1));
438
- for (const o of at.segment(e))
439
- if (n < o.index + o.segment.length)
440
- return [o.index, o.index + o.segment.length];
435
+ const ht = new Intl.Segmenter(void 0, { granularity: "grapheme" }), gt = new Intl.Segmenter(void 0, { granularity: "word" });
436
+ function mt(e, n) {
437
+ const r = Math.max(0, Math.min(n, e.length - 1));
438
+ for (const a of gt.segment(e))
439
+ if (r < a.index + a.segment.length)
440
+ return [a.index, a.index + a.segment.length];
441
441
  return [0, 0];
442
442
  }
443
- const Ee = (e) => Array.from(ot.segment(e));
444
- function ue(e, r) {
443
+ const me = (e) => Array.from(ht.segment(e));
444
+ function oe(e, n) {
445
445
  return [
446
- ...Ee(e).map((o) => o.index),
446
+ ...me(e).map((a) => a.index),
447
447
  e.length
448
- ].filter((o) => o <= Math.max(0, r)).at(-1) ?? 0;
448
+ ].filter((a) => a <= Math.max(0, n)).at(-1) ?? 0;
449
449
  }
450
- function be(e, r, n) {
451
- const o = [
452
- ...Ee(e).map((i) => i.index),
450
+ function Ce(e, n, r) {
451
+ const a = [
452
+ ...me(e).map((i) => i.index),
453
453
  e.length
454
454
  ];
455
- return n < 0 ? o.filter((i) => i < r).at(-1) ?? 0 : o.find((i) => i > r) ?? e.length;
455
+ return r < 0 ? a.filter((i) => i < n).at(-1) ?? 0 : a.find((i) => i > n) ?? e.length;
456
456
  }
457
- const te = ({ anchor: e, caret: r }) => [Math.min(e, r), Math.max(e, r)];
458
- function lt(e, r, n = !1, o) {
459
- const [i, c] = te(e);
460
- let h = e.value.slice(0, i), v = r;
461
- i === c && e.composing && n && fe(h.at(-1) ?? "") && (v = Ge([h.at(-1), r]), h = h.slice(0, -1));
462
- const d = h + v + e.value.slice(c);
463
- if (o !== void 0 && d.length > o) return e;
464
- const L = h.length + v.length;
465
- return { value: d, caret: L, anchor: L, composing: n };
457
+ const te = ({ anchor: e, caret: n }) => [Math.min(e, n), Math.max(e, n)];
458
+ function wt(e, n, r = !1, a) {
459
+ const [i, s] = te(e);
460
+ let m = e.value.slice(0, i), v = n;
461
+ i === s && e.composing && r && we(m.at(-1) ?? "") && (v = it([m.at(-1), n]), m = m.slice(0, -1));
462
+ const d = m + v + e.value.slice(s);
463
+ if (a !== void 0 && d.length > a) return e;
464
+ const k = m.length + v.length;
465
+ return { value: d, caret: k, anchor: k, composing: r };
466
466
  }
467
- function me(e, r) {
468
- let [n, o] = te(e);
469
- if (n === o) {
470
- if (r < 0 && e.composing && fe(e.value[n - 1] ?? "")) {
471
- const i = e.value.slice(0, n - 1) + Qe(e.value[n - 1]);
467
+ function ke(e, n) {
468
+ let [r, a] = te(e);
469
+ if (r === a) {
470
+ if (n < 0 && e.composing && we(e.value[r - 1] ?? "")) {
471
+ const i = e.value.slice(0, r - 1) + lt(e.value[r - 1]);
472
472
  return {
473
- value: i + e.value.slice(o),
473
+ value: i + e.value.slice(a),
474
474
  anchor: i.length,
475
475
  caret: i.length,
476
476
  composing: !0
477
477
  };
478
478
  }
479
- r < 0 ? n = be(e.value, n, -1) : o = be(e.value, o, 1);
479
+ n < 0 ? r = Ce(e.value, r, -1) : a = Ce(e.value, a, 1);
480
480
  }
481
481
  return {
482
- value: e.value.slice(0, n) + e.value.slice(o),
483
- caret: n,
484
- anchor: n,
482
+ value: e.value.slice(0, r) + e.value.slice(a),
483
+ caret: r,
484
+ anchor: r,
485
485
  composing: !1
486
486
  };
487
487
  }
488
- function Ve(e, r, n = !1) {
489
- const [o, i] = te(e), c = r === "home" ? 0 : r === "end" ? e.value.length : !n && o !== i ? r < 0 ? o : i : be(e.value, e.caret, r);
488
+ function je(e, n, r = !1) {
489
+ const [a, i] = te(e), s = n === "home" ? 0 : n === "end" ? e.value.length : !r && a !== i ? n < 0 ? a : i : Ce(e.value, e.caret, n);
490
490
  return {
491
491
  ...e,
492
- caret: c,
493
- anchor: n ? e.anchor : c,
492
+ caret: s,
493
+ anchor: r ? e.anchor : s,
494
494
  composing: !1
495
495
  };
496
496
  }
497
- const kt = We(
497
+ function Ae(e) {
498
+ const n = e.ownerDocument.getSelection();
499
+ if (!n?.anchorNode || !n.focusNode || !e.contains(n.anchorNode) || !e.contains(n.focusNode))
500
+ return null;
501
+ const r = (i, s) => s >= 0 && s <= (i.nodeType === Node.TEXT_NODE ? i.textContent?.length ?? 0 : i.childNodes.length);
502
+ if (!r(n.anchorNode, n.anchorOffset) || !r(n.focusNode, n.focusOffset))
503
+ return null;
504
+ const a = (i, s) => {
505
+ const m = e.ownerDocument.createRange();
506
+ return m.selectNodeContents(e), m.setEnd(i, s), m.toString().length;
507
+ };
508
+ return {
509
+ anchor: a(n.anchorNode, n.anchorOffset),
510
+ caret: a(n.focusNode, n.focusOffset)
511
+ };
512
+ }
513
+ function vt(e, n, r) {
514
+ const a = e.ownerDocument.getSelection();
515
+ if (!a) return;
516
+ const i = Ae(e);
517
+ if (i?.anchor === n && i.caret === r) return;
518
+ const s = (p) => {
519
+ const l = e.ownerDocument.createTreeWalker(
520
+ e,
521
+ NodeFilter.SHOW_TEXT
522
+ );
523
+ let u = l.nextNode(), P = p;
524
+ for (; u; ) {
525
+ const w = u.textContent?.length ?? 0;
526
+ if (P <= w) return [u, P];
527
+ P -= w, u = l.nextNode();
528
+ }
529
+ return [e, e.childNodes.length];
530
+ }, [m, v] = s(n), [d, k] = s(r);
531
+ a.setBaseAndExtent(m, v, d, k);
532
+ }
533
+ const Xe = typeof window > "u" ? K : at, Dt = rt(
498
534
  function({
499
- value: r,
500
- defaultValue: n = "",
501
- placeholder: o,
535
+ value: n,
536
+ defaultValue: r = "",
537
+ placeholder: a,
502
538
  onChange: i,
503
- onValueChange: c,
504
- onClipboardError: h,
539
+ onValueChange: s,
540
+ onClipboardError: m,
505
541
  mode: v = "text",
506
542
  layout: d,
507
- filterKey: L,
508
- sanitizeValue: f,
543
+ filterKey: k,
544
+ sanitizeValue: p,
509
545
  disabled: l = !1,
510
546
  readOnly: u = !1,
511
- maxLength: I,
547
+ maxLength: P,
512
548
  ...w
513
- }, Q) {
514
- const H = Be(), {
515
- focusId: re,
516
- onFocus: X,
517
- onBlur: D,
549
+ }, _) {
550
+ const B = qe(), {
551
+ focusId: ae,
552
+ onFocus: Z,
553
+ onBlur: F,
518
554
  defaultLayout: O,
519
- inputRef: Z,
520
- hangulMode: ne,
521
- theme: p,
522
- toggleKorean: S,
523
- enterSelectionMode: g
524
- } = Fe(), y = P(null), z = P(null), [A, j] = R(() => ({
525
- value: r ?? n,
526
- caret: (r ?? n).length,
527
- anchor: (r ?? n).length,
555
+ inputRef: X,
556
+ hangulMode: ce,
557
+ theme: ie,
558
+ toggleKorean: h,
559
+ setEditingStatus: b
560
+ } = _e(), g = T(null), A = T(null), I = T(null), U = T(!1), [C, J] = $(() => ({
561
+ value: n ?? r,
562
+ caret: (n ?? r).length,
563
+ anchor: (n ?? r).length,
528
564
  composing: !1
529
- })), T = r ?? A.value, s = P(A), m = P(0), U = P(new Oe()), W = P(!1), F = re === H, _ = P(F);
530
- _.current = F;
531
- const ae = r !== void 0 && r !== A.value;
532
- ae && U.current.clear(), s.current = {
533
- ...A,
534
- value: T,
535
- caret: ue(T, A.caret),
536
- anchor: ue(T, A.anchor),
537
- composing: ae ? !1 : A.composing
565
+ })), M = n ?? C.value, c = T(C), W = T(0), ne = T(new ut()), G = T(!1), V = ae === B, Q = T(V);
566
+ Q.current = V;
567
+ const le = n !== void 0 && n !== C.value;
568
+ le && ne.current.clear(), c.current = {
569
+ ...C,
570
+ value: M,
571
+ caret: oe(M, C.caret),
572
+ anchor: oe(M, C.anchor),
573
+ composing: le ? !1 : C.composing
538
574
  };
539
- const N = Ke(
540
- () => ye({
575
+ const j = Fe(
576
+ () => Le({
541
577
  mode: v,
542
578
  layout: d ?? (v === "text" || v === "custom" ? O : void 0),
543
- filterKey: L,
544
- sanitizeValue: f
579
+ filterKey: k,
580
+ sanitizeValue: p
545
581
  }),
546
- [v, d, O, L, f]
547
- ), [b, K] = R(""), Y = P(
582
+ [v, d, O, k, p]
583
+ ), [y, D] = $(""), q = T(
548
584
  void 0
549
- ), B = P(null), M = k(() => {
550
- clearTimeout(Y.current), B.current = null;
585
+ ), R = T(null), z = E(() => {
586
+ clearTimeout(q.current), R.current = null;
551
587
  }, []);
552
- V(() => {
553
- (l || u) && M();
554
- }, [l, u, M]), V(() => {
555
- const t = (a) => {
556
- B.current && B.current.id !== a.pointerId && M();
588
+ K(() => {
589
+ (l || u) && z();
590
+ }, [l, u, z]), K(() => {
591
+ const t = (o) => {
592
+ R.current && R.current.id !== o.pointerId && z();
557
593
  };
558
- return window.addEventListener("blur", M), window.addEventListener("scroll", M, !0), window.addEventListener("pointerdown", t, !0), document.addEventListener("visibilitychange", M), () => {
559
- M(), window.removeEventListener("blur", M), window.removeEventListener("scroll", M, !0), window.removeEventListener("pointerdown", t, !0), document.removeEventListener("visibilitychange", M);
594
+ return window.addEventListener("blur", z), window.addEventListener("scroll", z, !0), window.addEventListener("pointerdown", t, !0), document.addEventListener("visibilitychange", z), () => {
595
+ z(), window.removeEventListener("blur", z), window.removeEventListener("scroll", z, !0), window.removeEventListener("pointerdown", t, !0), document.removeEventListener("visibilitychange", z);
560
596
  };
561
- }, [M]);
562
- const x = k(
563
- (t, a = !0) => {
564
- const E = s.current.value;
565
- if (a && U.current.record(s.current, t), s.current = t, m.current++, j(t), t.value !== E) {
566
- c?.(t.value);
567
- const $ = { value: t.value };
597
+ }, [z]);
598
+ const S = E(
599
+ (t, o = !0, f = !1) => {
600
+ const x = c.current.value;
601
+ if (o && ne.current.record(c.current, t), U.current = !f, c.current = t, W.current++, D(""), J(t), t.value !== x) {
602
+ s?.(t.value);
603
+ const N = { value: t.value };
568
604
  i?.({
569
- target: $,
570
- currentTarget: $
605
+ target: N,
606
+ currentTarget: N
571
607
  });
572
608
  }
573
609
  },
574
- [i, c]
575
- ), ee = k(
576
- (t, a = !1) => {
610
+ [i, s]
611
+ ), H = E(() => {
612
+ const t = A.current;
613
+ if (!t || l || U.current || t.textContent !== c.current.value)
614
+ return null;
615
+ const o = Ae(t);
616
+ if (!o) return null;
617
+ const f = oe(c.current.value, o.anchor), x = oe(c.current.value, o.caret);
618
+ return (f !== c.current.anchor || x !== c.current.caret || f !== o.anchor || x !== o.caret) && S(
619
+ { ...c.current, anchor: f, caret: x, composing: !1 },
620
+ !1,
621
+ f === o.anchor && x === o.caret
622
+ ), { anchor: f, caret: x };
623
+ }, [l, S]);
624
+ K(() => {
625
+ const t = () => {
626
+ const o = H();
627
+ o && o.anchor !== o.caret && (clearTimeout(q.current), R.current && (R.current.held = !0), !u && g.current && !Q.current && (g.current.focus({ preventScroll: !0 }), Z(B, g.current, j)));
628
+ };
629
+ return document.addEventListener("selectionchange", t), () => document.removeEventListener("selectionchange", t);
630
+ }, [H, u, Z, B, j]), Xe(() => {
631
+ (V || document.activeElement === g.current) && !l && A.current && (U.current || le) && vt(
632
+ A.current,
633
+ c.current.anchor,
634
+ c.current.caret
635
+ ), U.current = !1;
636
+ }), K(() => {
637
+ if (!V) return;
638
+ const [t, o] = te(c.current);
639
+ b({
640
+ selectionLength: me(M.slice(t, o)).length,
641
+ hasValue: !!M,
642
+ message: y
643
+ });
644
+ }, [
645
+ M,
646
+ C.anchor,
647
+ C.caret,
648
+ y,
649
+ V,
650
+ b
651
+ ]);
652
+ const re = E(
653
+ (t, o = !1) => {
577
654
  if (l || u) return;
578
- const E = N.sanitizeValue(t).replace(/[\r\n\t]+/g, " ");
579
- E && x(lt(s.current, E, a, I));
655
+ H();
656
+ const f = j.sanitizeValue(t).replace(/[\r\n\t]+/g, " ");
657
+ f && S(wt(c.current, f, o, P));
580
658
  },
581
- [l, u, N, I, x]
582
- ), pe = k(() => {
583
- !l && !u && x(U.current.undo(s.current), !1);
584
- }, [l, u, x]), he = k(() => {
585
- !l && !u && x(U.current.redo(s.current), !1);
586
- }, [l, u, x]), Le = k(
587
- () => x({
588
- ...s.current,
589
- caret: s.current.value.length,
659
+ [l, u, j, P, S, H]
660
+ ), ve = E(() => {
661
+ !l && !u && S(ne.current.undo(c.current), !1);
662
+ }, [l, u, S]), ye = E(() => {
663
+ !l && !u && S(ne.current.redo(c.current), !1);
664
+ }, [l, u, S]), De = E(
665
+ () => S({
666
+ ...c.current,
667
+ caret: c.current.value.length,
590
668
  anchor: 0,
591
669
  composing: !1
592
670
  }),
593
- [x]
594
- ), Se = k(
595
- (t, a = !1) => x(Ve(s.current, t === "left" ? -1 : 1, a)),
596
- [x]
597
- ), Ne = (t) => {
671
+ [S]
672
+ ), Ke = E(
673
+ (t, o = !1) => {
674
+ H(), S(je(c.current, t === "left" ? -1 : 1, o));
675
+ },
676
+ [S, H]
677
+ ), Ge = (t) => {
598
678
  if (w.onKeyDown?.(t), t.defaultPrevented || l) return;
599
- const a = t.key;
600
- if (a === "Escape") {
601
- t.preventDefault(), x({ ...s.current, composing: !1 }), D(!0), y.current?.blur();
679
+ H();
680
+ const o = t.key;
681
+ if (o === "Escape") {
682
+ t.preventDefault(), S({ ...c.current, composing: !1 }), F(!0), g.current?.blur();
602
683
  return;
603
684
  }
604
- if (a === "HangulMode") {
605
- t.preventDefault(), x({ ...s.current, composing: !1 }), S();
685
+ if (o === "HangulMode") {
686
+ t.preventDefault(), S({ ...c.current, composing: !1 }), h();
606
687
  return;
607
688
  }
608
- const E = t.ctrlKey || t.metaKey;
609
- if (E && ["z", "y"].includes(a.toLowerCase())) {
610
- t.preventDefault(), a.toLowerCase() === "y" || t.shiftKey ? he() : pe();
689
+ const f = t.ctrlKey || t.metaKey;
690
+ if (f && ["z", "y"].includes(o.toLowerCase())) {
691
+ t.preventDefault(), o.toLowerCase() === "y" || t.shiftKey ? ye() : ve();
611
692
  return;
612
693
  }
613
- if (E && a.toLowerCase() === "a") {
614
- t.preventDefault(), x({
615
- ...s.current,
616
- caret: s.current.value.length,
694
+ if (f && o.toLowerCase() === "a") {
695
+ t.preventDefault(), S({
696
+ ...c.current,
697
+ caret: c.current.value.length,
617
698
  anchor: 0,
618
699
  composing: !1
619
700
  });
620
701
  return;
621
702
  }
622
- const $ = a === "Home" || a === "ArrowUp" || E && a === "ArrowLeft" ? "home" : a === "End" || a === "ArrowDown" || E && a === "ArrowRight" ? "end" : a === "ArrowLeft" ? -1 : a === "ArrowRight" ? 1 : null;
623
- if ($ !== null) {
624
- t.preventDefault(), x(Ve(s.current, $, t.shiftKey));
703
+ const x = o === "Home" || o === "ArrowUp" || f && o === "ArrowLeft" ? "home" : o === "End" || o === "ArrowDown" || f && o === "ArrowRight" ? "end" : o === "ArrowLeft" ? -1 : o === "ArrowRight" ? 1 : null;
704
+ if (x !== null) {
705
+ t.preventDefault(), S(je(c.current, x, t.shiftKey));
625
706
  return;
626
707
  }
627
- if (a === "Tab" || a === "Enter") {
628
- x({ ...s.current, composing: !1 });
708
+ if (o === "Tab" || o === "Enter") {
709
+ S({ ...c.current, composing: !1 });
629
710
  return;
630
711
  }
631
712
  if (u) return;
632
- if (a === "Backspace" || a === "Delete") {
633
- t.preventDefault(), x(me(s.current, a === "Backspace" ? -1 : 1));
713
+ if (o === "Backspace" || o === "Delete") {
714
+ t.preventDefault(), S(ke(c.current, o === "Backspace" ? -1 : 1));
634
715
  return;
635
716
  }
636
- const J = et(
717
+ const N = st(
637
718
  t,
638
- de(N.mode) ?? ne
719
+ ge(j.mode) ?? ce
639
720
  );
640
- J.handled && J.text && (t.preventDefault(), N.filterKey(J.text) && ee(J.text, J.composing));
641
- }, ie = k(
721
+ N.handled && N.text && (t.preventDefault(), j.filterKey(N.text) && re(N.text, N.composing));
722
+ }, de = E(
642
723
  (t) => {
643
- const a = t instanceof Error ? t : new Error(String(t));
644
- W.current && (K(
645
- "클립보드에 접근할 수 없습니다. 키보드의 복사·붙여넣기 단축키를 사용해 주세요."
646
- ), h?.(a));
724
+ const o = t instanceof Error ? t : new Error(String(t));
725
+ G.current && (D(
726
+ "클립보드에 접근할 수 없습니다. 선택한 글자를 길게 눌러 기본 복사 메뉴를 사용해 주세요."
727
+ ), m?.(o));
647
728
  },
648
- [h]
649
- ), le = k(async () => {
650
- const [t, a] = te(s.current);
651
- t !== a && (await navigator.clipboard.writeText(
652
- s.current.value.slice(t, a)
653
- ), W.current && K("선택한 내용을 복사했습니다."));
654
- }, []), Ae = k(async () => {
729
+ [m]
730
+ ), fe = E(async () => {
731
+ H();
732
+ const [t, o] = te(c.current);
733
+ if (t === o) return;
734
+ const f = c.current.value.slice(t, o);
735
+ try {
736
+ if (!navigator.clipboard?.writeText)
737
+ throw new Error("Clipboard API unavailable");
738
+ await navigator.clipboard.writeText(f);
739
+ } catch (x) {
740
+ if (!A.current || document.getSelection()?.toString() !== f || !document.execCommand?.("copy"))
741
+ throw x;
742
+ }
743
+ G.current && D("복사했어요");
744
+ }, [H]), Ve = E(async () => {
655
745
  if (l || u) return;
656
- const t = s.current, a = m.current;
657
- t.anchor !== t.caret && (await le(), W.current && _.current && m.current === a && s.current.value === t.value && x(me(t, -1)));
658
- }, [l, u, le, x]), Pe = k(async () => {
746
+ H();
747
+ const t = c.current, o = W.current;
748
+ t.anchor !== t.caret && (await fe(), G.current && Q.current && W.current === o && c.current.value === t.value && S(ke(t, -1)));
749
+ }, [l, u, fe, S, H]), ze = E(async () => {
659
750
  if (l || u) return;
660
- const t = m.current, a = s.current.value, E = await navigator.clipboard.readText();
661
- W.current && _.current && m.current === t && s.current.value === a && ee(E);
662
- }, [l, u, ee]), oe = Ke(
751
+ H();
752
+ const t = W.current, o = c.current.value, f = await navigator.clipboard.readText();
753
+ G.current && Q.current && W.current === t && c.current.value === o && re(f);
754
+ }, [l, u, re, H]), ue = Fe(
663
755
  () => ({
664
756
  focus: (t) => {
665
- l || y.current?.focus(t);
757
+ l || g.current?.focus(t);
666
758
  },
667
759
  blur: () => {
668
- y.current?.blur(), _.current && D(!0);
760
+ g.current?.blur(), Q.current && F(!0);
669
761
  },
670
- getValue: () => s.current.value,
671
- setSelectionRange: (t, a) => x({
672
- ...s.current,
673
- anchor: ue(s.current.value, t),
674
- caret: ue(s.current.value, a),
762
+ getValue: () => c.current.value,
763
+ setSelectionRange: (t, o) => S({
764
+ ...c.current,
765
+ anchor: oe(c.current.value, t),
766
+ caret: oe(c.current.value, o),
675
767
  composing: !1
676
768
  }),
677
- handleKeyDown: (t) => y.current?.dispatchEvent(
769
+ handleKeyDown: (t) => g.current?.dispatchEvent(
678
770
  new KeyboardEvent("keydown", {
679
771
  key: t.key,
680
772
  shiftKey: t.shiftKey,
@@ -686,108 +778,125 @@ const kt = We(
686
778
  cancelable: !0
687
779
  })
688
780
  ),
689
- insertText: (t, a) => {
690
- N.filterKey(t) && ee(t, a);
781
+ insertText: (t, o) => {
782
+ j.filterKey(t) && re(t, o);
691
783
  },
692
- scrollIntoView: () => y.current?.scrollIntoView({ block: "nearest", inline: "nearest" }),
693
- moveCaret: Se,
694
- undo: pe,
695
- redo: he,
696
- selectAll: Le,
697
- copySelection: () => le().catch(ie),
698
- pasteClipboard: () => Pe().catch(ie),
699
- cutSelection: () => Ae().catch(ie)
784
+ scrollIntoView: () => g.current?.scrollIntoView({ block: "nearest", inline: "nearest" }),
785
+ moveCaret: Ke,
786
+ undo: ve,
787
+ redo: ye,
788
+ selectAll: De,
789
+ copySelection: () => fe().catch(de),
790
+ pasteClipboard: () => ze().catch(de),
791
+ cutSelection: () => Ve().catch(de)
700
792
  }),
701
793
  [
702
- N,
703
- ee,
704
- Se,
705
- le,
706
- Pe,
707
- Ae,
708
- ie,
709
- pe,
710
- he,
711
- Le,
794
+ j,
795
+ re,
796
+ Ke,
797
+ fe,
798
+ ze,
799
+ Ve,
800
+ de,
801
+ ve,
802
+ ye,
803
+ De,
712
804
  l,
713
- D,
714
- x
805
+ F,
806
+ S
715
807
  ]
716
808
  );
717
- _e(Q, () => oe, [oe]), V(() => {
718
- F || j(
809
+ ot(_, () => ue, [ue]), K(() => {
810
+ V || J(
719
811
  (t) => t.composing ? { ...t, composing: !1 } : t
720
812
  );
721
- }, [F]), V(() => {
722
- if (!(!F || l || u))
723
- return Z.current = oe, () => {
724
- Z.current === oe && (Z.current = null);
813
+ }, [V]), K(() => {
814
+ if (!(!V || l || u))
815
+ return X.current = ue, () => {
816
+ X.current === ue && (X.current = null);
725
817
  };
726
- }, [F, l, u, oe, Z]), V(() => {
727
- F && y.current && (l || u ? D(!0) : X(H, y.current, N));
728
- }, [F, l, u, H, N, X, D]), V(() => (W.current = !0, () => {
729
- W.current = !1, clearTimeout(Y.current), _.current && D(!0);
730
- }), [D]), V(() => {
731
- if (!F || !y.current || !z.current) return;
732
- const t = y.current.getBoundingClientRect(), a = z.current.getBoundingClientRect();
733
- a.right > t.right - 12 ? y.current.scrollLeft += a.right - t.right + 12 : a.left < t.left + 12 && (y.current.scrollLeft -= t.left + 12 - a.left);
734
- }, [T, A.caret, F]);
735
- const Me = (t, a) => {
736
- if (a ? w.onCut?.(t) : w.onCopy?.(t), t.defaultPrevented || l || a && u) return;
737
- const [E, $] = te(s.current);
738
- E !== $ && (t.preventDefault(), t.clipboardData.setData(
818
+ }, [V, l, u, ue, X]), K(() => {
819
+ V && g.current && (l || u ? F(!0) : Z(B, g.current, j));
820
+ }, [V, l, u, B, j, Z, F]), K(() => (G.current = !0, () => {
821
+ G.current = !1, clearTimeout(q.current), Q.current && F(!0);
822
+ }), [F]), Xe(() => {
823
+ if (!g.current || !A.current || !I.current)
824
+ return;
825
+ const t = () => {
826
+ const f = g.current, x = A.current, N = f.getBoundingClientRect(), $e = x.querySelector(
827
+ `[data-char-index="${c.current.caret}"]`
828
+ ), pe = ($e ?? x).getBoundingClientRect(), se = $e || !c.current.value ? pe.left : pe.right;
829
+ Object.assign(I.current.style, {
830
+ left: `${se - N.left + f.scrollLeft - f.clientLeft}px`,
831
+ top: `${pe.top - N.top + f.scrollTop - f.clientTop}px`,
832
+ height: `${pe.height}px`
833
+ }), !(!V || c.current.anchor !== c.current.caret) && (se > N.right - 12 ? f.scrollLeft += se - N.right + 12 : se < N.left + 12 && (f.scrollLeft -= N.left + 12 - se));
834
+ };
835
+ t();
836
+ const o = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
837
+ return o?.observe(g.current), () => o?.disconnect();
838
+ }, [M, C.caret, C.anchor, V]);
839
+ const Ne = (t, o) => {
840
+ if (o ? w.onCut?.(t) : w.onCopy?.(t), t.defaultPrevented || l || o && u) return;
841
+ const f = document.getSelection();
842
+ if (f && !f.isCollapsed && A.current && !Ae(A.current))
843
+ return;
844
+ H();
845
+ const [x, N] = te(c.current);
846
+ x !== N && (t.preventDefault(), t.clipboardData.setData(
739
847
  "text/plain",
740
- s.current.value.slice(E, $)
741
- ), a && x(me(s.current, -1)));
742
- }, ce = (t, a = !0) => {
743
- for (const E of y.current?.querySelectorAll(
848
+ c.current.value.slice(x, N)
849
+ ), o ? S(ke(c.current, -1)) : D("복사했어요"));
850
+ }, be = (t, o = !0) => {
851
+ for (const f of g.current?.querySelectorAll(
744
852
  "[data-char-index]"
745
853
  ) ?? []) {
746
- const $ = E.getBoundingClientRect();
747
- if (t < $.left + $.width * (a ? 0.5 : 1))
748
- return Number(E.dataset.charIndex);
854
+ const x = f.getBoundingClientRect();
855
+ if (t < x.left + x.width * (o ? 0.5 : 1))
856
+ return Number(f.dataset.charIndex);
749
857
  }
750
- return s.current.value.length;
751
- }, ge = () => {
752
- y.current?.focus({ preventScroll: !0 }), !u && y.current && X(H, y.current, N);
753
- }, Xe = (t) => {
858
+ return c.current.value.length;
859
+ }, xe = () => {
860
+ g.current?.focus({ preventScroll: !0 }), !u && g.current && Z(B, g.current, j);
861
+ }, Be = (t) => {
862
+ const [o, f] = mt(
863
+ c.current.value,
864
+ be(t, !1)
865
+ );
866
+ xe(), S({ ...c.current, anchor: o, caret: f, composing: !1 });
867
+ }, Qe = (t) => {
754
868
  if (w.onPointerDown?.(t), t.defaultPrevented || l || t.button !== 0) return;
755
- const a = t.pointerType === "mouse";
756
- if (a || t.preventDefault(), B.current || t.isPrimary === !1) {
757
- M();
869
+ const o = t.pointerType === "mouse";
870
+ if (R.current || t.isPrimary === !1) {
871
+ z();
758
872
  return;
759
873
  }
760
- const E = ce(t.clientX), $ = t.shiftKey ? s.current.anchor : E;
761
- B.current = {
874
+ const f = be(t.clientX), x = t.shiftKey ? c.current.anchor : f;
875
+ R.current = {
762
876
  id: t.pointerId,
763
877
  x: t.clientX,
764
878
  y: t.clientY,
765
- anchor: $,
766
- mouse: a,
879
+ anchor: x,
880
+ mouse: o,
767
881
  held: !1
768
- }, clearTimeout(Y.current), a ? (ge(), x({ ...s.current, caret: E, anchor: $, composing: !1 }), y.current?.setPointerCapture?.(t.pointerId)) : u || (Y.current = setTimeout(() => {
769
- if (!B.current) return;
770
- B.current.held = !0;
771
- const [J, Ye] = it(
772
- s.current.value,
773
- ce(B.current.x, !1)
774
- );
775
- ge(), x({ ...s.current, anchor: J, caret: Ye, composing: !1 }), g();
776
- }, 550));
777
- }, [Ce, Ie] = te(s.current), Ue = Ee(T), Te = /* @__PURE__ */ C(
882
+ }, clearTimeout(q.current), o ? xe() : q.current = setTimeout(() => {
883
+ R.current && (R.current.held = !0, Be(R.current.x));
884
+ }, 550);
885
+ }, [Re, He] = te(c.current), Oe = me(M), et = /* @__PURE__ */ L(
778
886
  "span",
779
887
  {
780
- ref: z,
888
+ ref: I,
781
889
  "aria-hidden": "true",
782
890
  className: "vk-caret",
783
891
  style: {
784
- display: "inline-block",
892
+ display: V && !u && !l && Re === He ? "block" : "none",
785
893
  width: 0,
786
894
  height: "1.1em",
787
- verticalAlign: "-0.15em",
788
- position: "relative"
895
+ position: "absolute",
896
+ pointerEvents: "none",
897
+ userSelect: "none"
789
898
  },
790
- children: F && !u && !l && Ce === Ie && /* @__PURE__ */ C(
899
+ children: V && !u && !l && Re === He && /* @__PURE__ */ L(
791
900
  "span",
792
901
  {
793
902
  style: {
@@ -799,23 +908,24 @@ const kt = We(
799
908
  )
800
909
  }
801
910
  );
802
- return /* @__PURE__ */ q(
911
+ return /* @__PURE__ */ Y(
803
912
  "div",
804
913
  {
805
914
  ...w,
806
- ref: y,
807
- id: w.id ?? H,
915
+ ref: g,
916
+ id: w.id ?? B,
808
917
  role: "textbox",
809
918
  tabIndex: l ? -1 : w.tabIndex ?? 0,
810
919
  "aria-disabled": l || void 0,
811
920
  "aria-readonly": u || void 0,
812
921
  "aria-multiline": "false",
813
- "aria-placeholder": o,
922
+ "aria-placeholder": a,
814
923
  "data-virtual-input": "true",
815
- "data-focused": F || void 0,
816
- "data-value": T,
924
+ "data-focused": V || void 0,
925
+ "data-value": M,
817
926
  style: {
818
927
  display: "block",
928
+ position: "relative",
819
929
  boxSizing: "border-box",
820
930
  minHeight: "2.75em",
821
931
  padding: "0.65em 0.8em",
@@ -827,87 +937,82 @@ const kt = We(
827
937
  overflowX: "auto",
828
938
  scrollbarWidth: "none",
829
939
  cursor: l ? "not-allowed" : "text",
830
- userSelect: "none",
831
- WebkitUserSelect: "none",
832
- WebkitTouchCallout: "none",
940
+ userSelect: l ? "none" : "text",
941
+ WebkitUserSelect: l ? "none" : "text",
942
+ WebkitTouchCallout: "default",
833
943
  touchAction: "manipulation",
834
944
  opacity: l ? 0.5 : 1,
835
945
  outlineOffset: 3,
836
946
  ...w.style
837
947
  },
838
948
  onFocus: (t) => {
839
- w.onFocus?.(t), !t.defaultPrevented && !l && !u && X(H, t.currentTarget, N);
949
+ w.onFocus?.(t), !t.defaultPrevented && !l && !u && Z(B, t.currentTarget, j);
840
950
  },
841
951
  onBlur: (t) => {
842
- w.onBlur?.(t), M(), t.defaultPrevented || D(t);
952
+ w.onBlur?.(t), z(), t.defaultPrevented || F(t);
843
953
  },
844
- onKeyDown: Ne,
845
- onCopy: (t) => Me(t, !1),
846
- onCut: (t) => Me(t, !0),
954
+ onKeyDown: Ge,
955
+ onCopy: (t) => Ne(t, !1),
956
+ onCut: (t) => Ne(t, !0),
847
957
  onPaste: (t) => {
848
- w.onPaste?.(t), !t.defaultPrevented && !l && !u && (t.preventDefault(), ee(t.clipboardData.getData("text/plain")));
958
+ w.onPaste?.(t), !t.defaultPrevented && !l && !u && (t.preventDefault(), re(t.clipboardData.getData("text/plain")));
959
+ },
960
+ onPointerDown: Qe,
961
+ onDoubleClick: (t) => {
962
+ w.onDoubleClick?.(t), !(t.defaultPrevented || l || t.button !== 0) && (t.preventDefault(), Be(t.clientX));
849
963
  },
850
- onPointerDown: Xe,
851
964
  onPointerMove: (t) => {
852
965
  if (w.onPointerMove?.(t), t.defaultPrevented) {
853
- M();
966
+ z();
854
967
  return;
855
968
  }
856
- !B.current || B.current.id !== t.pointerId || Math.hypot(
857
- t.clientX - B.current.x,
858
- t.clientY - B.current.y
859
- ) > 8 && (clearTimeout(Y.current), B.current.mouse ? x({
860
- ...s.current,
861
- caret: ce(t.clientX),
862
- anchor: B.current.anchor,
863
- composing: !1
864
- }) : M());
969
+ !R.current || R.current.id !== t.pointerId || Math.hypot(
970
+ t.clientX - R.current.x,
971
+ t.clientY - R.current.y
972
+ ) > 8 && (clearTimeout(q.current), R.current.mouse || z());
865
973
  },
866
974
  onPointerUp: (t) => {
867
975
  w.onPointerUp?.(t);
868
- const a = B.current;
869
- if (!t.defaultPrevented && a?.id === t.pointerId && !a.mouse && !a.held && Math.hypot(t.clientX - a.x, t.clientY - a.y) <= 8) {
870
- const E = ce(t.clientX);
871
- ge(), x({
872
- ...s.current,
873
- caret: E,
874
- anchor: E,
875
- composing: !1
876
- });
976
+ const o = R.current;
977
+ if (!t.defaultPrevented && o?.id === t.pointerId && !o.held && Math.hypot(t.clientX - o.x, t.clientY - o.y) <= 8) {
978
+ const f = H();
979
+ if (!f || !o.mouse && f.anchor === f.caret) {
980
+ const x = be(t.clientX);
981
+ xe(), S({
982
+ ...c.current,
983
+ caret: x,
984
+ anchor: t.shiftKey ? o.anchor : x,
985
+ composing: !1
986
+ });
987
+ }
877
988
  }
878
- M();
989
+ z();
879
990
  },
880
991
  onPointerCancel: (t) => {
881
- w.onPointerCancel?.(t), M();
992
+ w.onPointerCancel?.(t), z();
882
993
  },
883
994
  onLostPointerCapture: (t) => {
884
- w.onLostPointerCapture?.(t), B.current?.id === t.pointerId && M();
995
+ w.onLostPointerCapture?.(t), R.current?.id === t.pointerId && z();
885
996
  },
886
997
  onContextMenu: (t) => {
887
- w.onContextMenu?.(t), t.defaultPrevented || t.preventDefault();
998
+ w.onContextMenu?.(t), t.defaultPrevented || H();
888
999
  },
889
1000
  children: [
890
- Ue.map(({ segment: t, index: a }) => /* @__PURE__ */ q("span", { children: [
891
- a === s.current.caret && Te,
892
- /* @__PURE__ */ C(
893
- "span",
894
- {
895
- "data-char-index": a,
896
- style: a >= Ce && a < Ie ? { background: "#bfdbfe", color: "#0f172a" } : void 0,
897
- children: t
898
- }
899
- )
900
- ] }, a)),
901
- s.current.caret === T.length && Te,
902
- !T && /* @__PURE__ */ C(
1001
+ /* @__PURE__ */ L("span", { ref: A, "data-input-text": "true", children: Oe.map(({ segment: t, index: o }) => /* @__PURE__ */ L("span", { "data-char-index": o, children: t }, o)) }),
1002
+ et,
1003
+ !M && /* @__PURE__ */ L(
903
1004
  "span",
904
1005
  {
905
1006
  "aria-hidden": "true",
906
- style: { color: p === "dark" ? "#a6b7a9" : "#58665d" },
907
- children: o || " "
1007
+ style: {
1008
+ color: ie === "dark" ? "#a6b7a9" : "#58665d",
1009
+ userSelect: "none",
1010
+ WebkitUserSelect: "none"
1011
+ },
1012
+ children: a || " "
908
1013
  }
909
1014
  ),
910
- /* @__PURE__ */ C(
1015
+ /* @__PURE__ */ L(
911
1016
  "span",
912
1017
  {
913
1018
  role: "status",
@@ -917,16 +1022,18 @@ const kt = We(
917
1022
  height: 1,
918
1023
  overflow: "hidden",
919
1024
  clipPath: "inset(50%)",
920
- whiteSpace: "nowrap"
1025
+ whiteSpace: "nowrap",
1026
+ userSelect: "none",
1027
+ WebkitUserSelect: "none"
921
1028
  },
922
- children: b
1029
+ children: y
923
1030
  }
924
1031
  )
925
1032
  ]
926
1033
  }
927
1034
  );
928
1035
  }
929
- ), ct = [
1036
+ ), yt = [
930
1037
  [
931
1038
  {
932
1039
  value: "1"
@@ -1043,97 +1150,97 @@ const kt = We(
1043
1150
  }
1044
1151
  ]
1045
1152
  ];
1046
- function ut({
1153
+ function bt({
1047
1154
  tagName: e,
1048
- css: r,
1049
- children: n,
1050
- hostRef: o,
1155
+ css: n,
1156
+ children: r,
1157
+ hostRef: a,
1051
1158
  ...i
1052
1159
  }) {
1053
- const [c, h] = R(null), v = k(
1160
+ const [s, m] = $(null), v = E(
1054
1161
  (d) => {
1055
- o && (o.current = d), d && h(d.shadowRoot ?? d.attachShadow({ mode: "open" }));
1162
+ a && (a.current = d), d && m(d.shadowRoot ?? d.attachShadow({ mode: "open" }));
1056
1163
  },
1057
- [o]
1164
+ [a]
1058
1165
  );
1059
- return Je(
1166
+ return ct(
1060
1167
  e,
1061
1168
  { ...i, ref: v },
1062
- c && ke(
1063
- /* @__PURE__ */ q(ze, { children: [
1064
- r && /* @__PURE__ */ C("style", { children: r }),
1065
- n
1169
+ s && Ie(
1170
+ /* @__PURE__ */ Y(Pe, { children: [
1171
+ n && /* @__PURE__ */ L("style", { children: n }),
1172
+ r
1066
1173
  ] }),
1067
- c
1174
+ s
1068
1175
  )
1069
1176
  );
1070
1177
  }
1071
- function De(e, r, n) {
1178
+ function Ue(e, n, r) {
1072
1179
  if (e.type === "action") return e.value === `
1073
1180
  ` ? "Enter" : e.value;
1074
1181
  if (!/^[a-zA-Z]$/.test(e.value)) return e.value;
1075
- const o = n ? e.value.toUpperCase() : e.value;
1076
- return r ? Re(o) : o;
1182
+ const a = r ? e.value.toUpperCase() : e.value;
1183
+ return n ? Ye(a) : a;
1077
1184
  }
1078
- function xe(e, { disabled: r = !1, repeat: n = !1 } = {}) {
1079
- const o = P(e);
1080
- o.current = e;
1081
- const i = P(void 0), c = P(null), [h, v] = R(!1), d = k(() => {
1082
- clearTimeout(i.current), c.current = null, v(!1);
1185
+ function Me(e, { disabled: n = !1, repeat: r = !1 } = {}) {
1186
+ const a = T(e);
1187
+ a.current = e;
1188
+ const i = T(void 0), s = T(null), [m, v] = $(!1), d = E(() => {
1189
+ clearTimeout(i.current), s.current = null, v(!1);
1083
1190
  }, []);
1084
- V(() => (window.addEventListener("blur", d), document.addEventListener("visibilitychange", d), () => {
1191
+ K(() => (window.addEventListener("blur", d), document.addEventListener("visibilitychange", d), () => {
1085
1192
  d(), window.removeEventListener("blur", d), document.removeEventListener("visibilitychange", d);
1086
- }), [d]), V(() => {
1087
- r && d();
1088
- }, [r, d]);
1089
- const L = (f) => {
1090
- const l = c.current?.bounds;
1091
- return !!l && f.clientX >= l.left && f.clientX <= l.right && f.clientY >= l.top && f.clientY <= l.bottom;
1193
+ }), [d]), K(() => {
1194
+ n && d();
1195
+ }, [n, d]);
1196
+ const k = (p) => {
1197
+ const l = s.current?.bounds;
1198
+ return !!l && p.clientX >= l.left && p.clientX <= l.right && p.clientY >= l.top && p.clientY <= l.bottom;
1092
1199
  };
1093
1200
  return {
1094
- "data-pressed": h || void 0,
1095
- onPointerDown: (f) => {
1096
- if (!(r || f.button !== 0 || c.current)) {
1097
- f.preventDefault(), c.current = {
1098
- id: f.pointerId,
1099
- bounds: f.currentTarget.getBoundingClientRect(),
1201
+ "data-pressed": m || void 0,
1202
+ onPointerDown: (p) => {
1203
+ if (!(n || p.button !== 0 || s.current)) {
1204
+ p.preventDefault(), s.current = {
1205
+ id: p.pointerId,
1206
+ bounds: p.currentTarget.getBoundingClientRect(),
1100
1207
  repeated: !1
1101
1208
  }, v(!0);
1102
1209
  try {
1103
- f.currentTarget.setPointerCapture?.(f.pointerId);
1210
+ p.currentTarget.setPointerCapture?.(p.pointerId);
1104
1211
  } catch {
1105
1212
  }
1106
- if (n) {
1213
+ if (r) {
1107
1214
  const l = () => {
1108
- c.current && (c.current.repeated = !0, o.current(), i.current = setTimeout(l, 65));
1215
+ s.current && (s.current.repeated = !0, a.current(), i.current = setTimeout(l, 65));
1109
1216
  };
1110
1217
  i.current = setTimeout(l, 450);
1111
1218
  }
1112
1219
  }
1113
1220
  },
1114
- onPointerMove: (f) => {
1115
- c.current?.id === f.pointerId && !L(f) && d();
1221
+ onPointerMove: (p) => {
1222
+ s.current?.id === p.pointerId && !k(p) && d();
1116
1223
  },
1117
- onPointerUp: (f) => {
1118
- if (c.current?.id !== f.pointerId) return;
1119
- const l = !r && L(f) && !c.current.repeated;
1120
- d(), l && o.current();
1224
+ onPointerUp: (p) => {
1225
+ if (s.current?.id !== p.pointerId) return;
1226
+ const l = !n && k(p) && !s.current.repeated;
1227
+ d(), l && a.current();
1121
1228
  },
1122
- onPointerCancel: (f) => {
1123
- c.current?.id === f.pointerId && d();
1229
+ onPointerCancel: (p) => {
1230
+ s.current?.id === p.pointerId && d();
1124
1231
  },
1125
- onLostPointerCapture: (f) => {
1126
- c.current?.id === f.pointerId && d();
1232
+ onLostPointerCapture: (p) => {
1233
+ s.current?.id === p.pointerId && d();
1127
1234
  },
1128
- onPointerLeave: (f) => {
1129
- c.current?.id === f.pointerId && !L(f) && d();
1235
+ onPointerLeave: (p) => {
1236
+ s.current?.id === p.pointerId && !k(p) && d();
1130
1237
  },
1131
- onClick: (f) => {
1132
- !r && f.detail === 0 && !c.current && o.current();
1238
+ onClick: (p) => {
1239
+ !n && p.detail === 0 && !s.current && a.current();
1133
1240
  }
1134
1241
  };
1135
1242
  }
1136
- const $e = {
1243
+ const Te = {
1137
1244
  Shift: "Shift",
1138
1245
  HangulMode: "한영 전환",
1139
1246
  Backspace: "지우기",
@@ -1152,31 +1259,51 @@ const $e = {
1152
1259
  Redo: "다시 실행",
1153
1260
  SelectAll: "전체 선택"
1154
1261
  };
1155
- function st({
1262
+ function We({
1156
1263
  cell: e,
1157
- label: r,
1158
- value: n,
1159
- active: o,
1264
+ label: n,
1265
+ value: r,
1266
+ active: a,
1160
1267
  disabled: i,
1161
- dispatch: c
1268
+ dispatch: s
1162
1269
  }) {
1163
- const h = xe(c, {
1270
+ const m = Me(s, {
1164
1271
  disabled: i,
1165
- repeat: ["Backspace", "Delete", "ArrowLeft", "ArrowRight"].includes(n)
1166
- }), v = e.type === "action" && n === "HangulMode";
1167
- return /* @__PURE__ */ C(
1272
+ repeat: ["Backspace", "Delete", "ArrowLeft", "ArrowRight"].includes(r)
1273
+ }), v = e.type === "action" && r === "HangulMode", d = e.type === "action" && (r === "Backspace" && (!e.label || e.label === "⌫") || r === "Delete" && (!e.label || e.label === "⌦"));
1274
+ return /* @__PURE__ */ L(
1168
1275
  "button",
1169
1276
  {
1170
1277
  type: "button",
1171
1278
  disabled: i,
1172
- "aria-label": $e[n] ?? r,
1173
- "aria-pressed": o,
1279
+ "aria-label": Te[r] ?? n,
1280
+ "aria-pressed": a,
1174
1281
  className: v ? "key action language" : e.type === "action" ? "key action" : "key",
1175
- title: v ? i ? `${o ? "한국어" : "영어"} 전용` : `${o ? "영어" : "한국어"}로 전환` : void 0,
1282
+ title: v ? i ? `${a ? "한국어" : "영어"} 전용` : `${a ? "영어" : "한국어"}로 전환` : void 0,
1176
1283
  style: { flex: e.width && e.width > 0 ? e.width : 1 },
1177
- ...h,
1178
- children: v && !e.label ? /* @__PURE__ */ q("span", { className: "language-label", "aria-hidden": "true", children: [
1179
- /* @__PURE__ */ q(
1284
+ ...m,
1285
+ children: d ? /* @__PURE__ */ Y(
1286
+ "svg",
1287
+ {
1288
+ "data-key-icon": r === "Backspace" ? "backspace" : "delete",
1289
+ "aria-hidden": "true",
1290
+ width: "24",
1291
+ height: "24",
1292
+ viewBox: "0 0 24 24",
1293
+ fill: "none",
1294
+ stroke: "currentColor",
1295
+ strokeWidth: "1.7",
1296
+ strokeLinecap: "round",
1297
+ strokeLinejoin: "round",
1298
+ focusable: "false",
1299
+ style: r === "Delete" ? { transform: "scaleX(-1)" } : void 0,
1300
+ children: [
1301
+ /* @__PURE__ */ L("path", { d: "M9 5H20a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 20 19H9l-7-7 7-7Z" }),
1302
+ /* @__PURE__ */ L("path", { d: "m12 9 6 6m0-6-6 6" })
1303
+ ]
1304
+ }
1305
+ ) : v && !e.label ? /* @__PURE__ */ Y("span", { className: "language-label", "aria-hidden": "true", children: [
1306
+ /* @__PURE__ */ Y(
1180
1307
  "svg",
1181
1308
  {
1182
1309
  width: "19",
@@ -1189,72 +1316,73 @@ function st({
1189
1316
  strokeLinejoin: "round",
1190
1317
  focusable: "false",
1191
1318
  children: [
1192
- /* @__PURE__ */ C("circle", { cx: "12", cy: "12", r: "9" }),
1193
- /* @__PURE__ */ C("ellipse", { cx: "12", cy: "12", rx: "4", ry: "9" }),
1194
- /* @__PURE__ */ C("path", { d: "M3 12h18" })
1319
+ /* @__PURE__ */ L("circle", { cx: "12", cy: "12", r: "9" }),
1320
+ /* @__PURE__ */ L("ellipse", { cx: "12", cy: "12", rx: "4", ry: "9" }),
1321
+ /* @__PURE__ */ L("path", { d: "M3 12h18" })
1195
1322
  ]
1196
1323
  }
1197
1324
  ),
1198
- /* @__PURE__ */ C("span", { children: o ? "한" : "EN" })
1199
- ] }) : r
1325
+ /* @__PURE__ */ L("span", { children: a ? "한" : "EN" })
1326
+ ] }) : n
1200
1327
  }
1201
1328
  );
1202
1329
  }
1203
- function dt({
1330
+ function xt({
1204
1331
  layout: e,
1205
- viewport: r,
1206
- onHeightChange: n
1332
+ viewport: n,
1333
+ onHeightChange: r
1207
1334
  }) {
1208
- const o = Fe(), {
1335
+ const a = _e(), {
1209
1336
  inputRef: i,
1210
- hangulMode: c,
1211
- shift: h,
1337
+ hangulMode: s,
1338
+ shift: m,
1212
1339
  shiftLocked: v,
1213
1340
  theme: d,
1214
- selectionMode: L,
1215
- selectionAdjusting: f,
1341
+ selectionMode: k,
1342
+ selectionAdjusting: p,
1216
1343
  activeInputPolicy: l,
1217
- onBlur: u
1218
- } = o, I = P(null), [w, Q] = R(!1), H = xe(() => Q((p) => !p)), re = xe(() => u(!0)), X = ["text", "hangul", "custom"].includes(
1344
+ editingStatus: u,
1345
+ onBlur: P
1346
+ } = a, w = T(null), [_, B] = $(!1), ae = Me(() => B((h) => !h)), Z = Me(() => P(!0)), F = ["text", "hangul", "custom"].includes(
1219
1347
  l.mode
1220
- ), D = w && X && !L ? ct : e;
1221
- V(() => {
1222
- if (!I.current) return;
1223
- const p = () => {
1224
- const g = I.current?.getBoundingClientRect().height ?? 0;
1225
- n(g);
1348
+ ), O = _ && F && !k ? yt : e;
1349
+ K(() => {
1350
+ if (!w.current) return;
1351
+ const h = () => {
1352
+ const g = w.current?.getBoundingClientRect().height ?? 0;
1353
+ r(g);
1226
1354
  };
1227
- p();
1228
- const S = new ResizeObserver(p);
1229
- return S.observe(I.current), () => S.disconnect();
1230
- }, [n]), V(() => {
1231
- let p = null;
1232
- const S = /* @__PURE__ */ new Set(), g = (m) => m.composedPath().some(
1233
- (U) => U === I.current || U instanceof Element && U.hasAttribute("data-virtual-input")
1234
- ), y = (m) => {
1235
- S.add(m.pointerId), p = S.size !== 1 || m.button !== 0 || g(m) ? null : { x: m.clientX, y: m.clientY, id: m.pointerId };
1236
- }, z = (m) => {
1237
- p && p.id === m.pointerId && Math.hypot(m.clientX - p.x, m.clientY - p.y) < 10 && !g(m) && u(!0), p = null, S.delete(m.pointerId);
1238
- }, A = (m) => {
1239
- p?.id === m.pointerId && Math.hypot(m.clientX - p.x, m.clientY - p.y) >= 10 && (p = null);
1240
- }, j = () => {
1241
- p = null;
1242
- }, T = (m) => {
1243
- j(), S.delete(m.pointerId);
1244
- }, s = () => {
1245
- j(), S.clear();
1355
+ h();
1356
+ const b = new ResizeObserver(h);
1357
+ return b.observe(w.current), () => b.disconnect();
1358
+ }, [r]), K(() => {
1359
+ let h = null;
1360
+ const b = /* @__PURE__ */ new Set(), g = (c) => c.composedPath().some(
1361
+ (W) => W === w.current || W instanceof Element && W.hasAttribute("data-virtual-input")
1362
+ ), A = (c) => {
1363
+ b.add(c.pointerId), h = b.size !== 1 || c.button !== 0 || g(c) ? null : { x: c.clientX, y: c.clientY, id: c.pointerId };
1364
+ }, I = (c) => {
1365
+ h && h.id === c.pointerId && Math.hypot(c.clientX - h.x, c.clientY - h.y) < 10 && !g(c) && P(!0), h = null, b.delete(c.pointerId);
1366
+ }, U = (c) => {
1367
+ h?.id === c.pointerId && Math.hypot(c.clientX - h.x, c.clientY - h.y) >= 10 && (h = null);
1368
+ }, C = () => {
1369
+ h = null;
1370
+ }, J = (c) => {
1371
+ C(), b.delete(c.pointerId);
1372
+ }, M = () => {
1373
+ C(), b.clear();
1246
1374
  };
1247
- return window.addEventListener("pointerdown", y, !0), window.addEventListener("pointermove", A, !0), window.addEventListener("pointerup", z, !0), window.addEventListener("pointercancel", T, !0), window.addEventListener("scroll", j, !0), window.addEventListener("blur", s), document.addEventListener("visibilitychange", s), () => {
1248
- window.removeEventListener("pointerdown", y, !0), window.removeEventListener("pointermove", A, !0), window.removeEventListener("pointerup", z, !0), window.removeEventListener("pointercancel", T, !0), window.removeEventListener("scroll", j, !0), window.removeEventListener("blur", s), document.removeEventListener("visibilitychange", s);
1375
+ return window.addEventListener("pointerdown", A, !0), window.addEventListener("pointermove", U, !0), window.addEventListener("pointerup", I, !0), window.addEventListener("pointercancel", J, !0), window.addEventListener("scroll", C, !0), window.addEventListener("blur", M), document.addEventListener("visibilitychange", M), () => {
1376
+ window.removeEventListener("pointerdown", A, !0), window.removeEventListener("pointermove", U, !0), window.removeEventListener("pointerup", I, !0), window.removeEventListener("pointercancel", J, !0), window.removeEventListener("scroll", C, !0), window.removeEventListener("blur", M), document.removeEventListener("visibilitychange", M);
1249
1377
  };
1250
- }, [u]);
1251
- const O = (p) => {
1252
- const S = De(p, c, h);
1253
- if (p.type !== "action") {
1254
- i.current?.insertText(S, fe(S)), o.consumeShift();
1378
+ }, [P]);
1379
+ const X = (h) => {
1380
+ const b = Ue(h, s, m);
1381
+ if (h.type !== "action") {
1382
+ i.current?.insertText(b, we(b)), a.consumeShift();
1255
1383
  return;
1256
1384
  }
1257
- switch (S) {
1385
+ switch (b) {
1258
1386
  case "Undo":
1259
1387
  i.current?.undo();
1260
1388
  break;
@@ -1265,21 +1393,21 @@ function dt({
1265
1393
  i.current?.selectAll();
1266
1394
  break;
1267
1395
  case "Shift":
1268
- o.toggleShift();
1396
+ a.toggleShift();
1269
1397
  break;
1270
1398
  case "HangulMode":
1271
1399
  i.current?.handleKeyDown(
1272
- new KeyboardEvent("keydown", { key: S })
1400
+ new KeyboardEvent("keydown", { key: b })
1273
1401
  );
1274
1402
  break;
1275
1403
  case "EnterSelectionMode":
1276
- Q(!1), o.enterSelectionMode();
1404
+ B(!1), a.enterSelectionMode();
1277
1405
  break;
1278
1406
  case "ExitSelectionMode":
1279
- o.exitSelectionMode();
1407
+ a.exitSelectionMode();
1280
1408
  break;
1281
1409
  case "ToggleSelectionAdjust":
1282
- o.toggleSelectionAdjust();
1410
+ a.toggleSelectionAdjust();
1283
1411
  break;
1284
1412
  case "Copy":
1285
1413
  i.current?.copySelection();
@@ -1291,26 +1419,26 @@ function dt({
1291
1419
  i.current?.cutSelection();
1292
1420
  break;
1293
1421
  case "ArrowLeft":
1294
- i.current?.moveCaret("left", f);
1422
+ i.current?.moveCaret("left", p);
1295
1423
  break;
1296
1424
  case "ArrowRight":
1297
- i.current?.moveCaret("right", f);
1425
+ i.current?.moveCaret("right", p);
1298
1426
  break;
1299
1427
  default:
1300
- S === " " ? i.current?.insertText(" ") : i.current?.handleKeyDown(
1301
- new KeyboardEvent("keydown", { key: S })
1428
+ b === " " ? i.current?.insertText(" ") : i.current?.handleKeyDown(
1429
+ new KeyboardEvent("keydown", { key: b })
1302
1430
  );
1303
1431
  }
1304
- }, Z = de(l.mode) !== null, ne = {
1432
+ }, ce = ge(l.mode) !== null, ie = {
1305
1433
  position: "fixed",
1306
1434
  zIndex: 9999,
1307
1435
  boxSizing: "border-box",
1308
1436
  display: "block",
1309
- width: Math.min(r.width || 760, 760),
1310
- left: r.offsetLeft + r.width / 2,
1311
- transform: r.height ? "translate(-50%, -100%)" : "translateX(-50%)",
1312
- ...r.height ? { top: r.offsetTop + r.height } : { bottom: 0 },
1313
- maxHeight: r.height ? r.height * 0.65 : "65dvh",
1437
+ width: Math.min(n.width || 760, 760),
1438
+ left: n.offsetLeft + n.width / 2,
1439
+ transform: n.height ? "translate(-50%, -100%)" : "translateX(-50%)",
1440
+ ...n.height ? { top: n.offsetTop + n.height } : { bottom: 0 },
1441
+ maxHeight: n.height ? n.height * 0.65 : "65dvh",
1314
1442
  overflowY: "auto",
1315
1443
  colorScheme: d,
1316
1444
  background: d === "dark" ? "#18201f" : "#e9eeeb",
@@ -1322,23 +1450,23 @@ function dt({
1322
1450
  userSelect: "none",
1323
1451
  WebkitUserSelect: "none"
1324
1452
  };
1325
- return ke(
1326
- /* @__PURE__ */ C(
1327
- ut,
1453
+ return Ie(
1454
+ /* @__PURE__ */ L(
1455
+ bt,
1328
1456
  {
1329
1457
  tagName: "virtual-keypad",
1330
- hostRef: I,
1458
+ hostRef: w,
1331
1459
  "data-virtual-keypad": "true",
1332
- style: ne,
1333
- onPointerDown: (p) => {
1334
- p.button === 0 && p.preventDefault();
1460
+ style: ie,
1461
+ onPointerDown: (h) => {
1462
+ h.button === 0 && h.preventDefault();
1335
1463
  },
1336
- onMouseDown: (p) => {
1337
- p.button === 0 && p.preventDefault();
1464
+ onMouseDown: (h) => {
1465
+ h.button === 0 && h.preventDefault();
1338
1466
  },
1339
- onBlur: o.onBlur,
1340
- onKeyDown: (p) => {
1341
- p.key === "Escape" && (p.preventDefault(), u(!0));
1467
+ onBlur: a.onBlur,
1468
+ onKeyDown: (h) => {
1469
+ h.key === "Escape" && (h.preventDefault(), P(!0));
1342
1470
  },
1343
1471
  css: `
1344
1472
  * {
@@ -1356,6 +1484,8 @@ function dt({
1356
1484
  justify-content: space-between;
1357
1485
  padding: 0 6px 8px;
1358
1486
  font-size: 12px;
1487
+ min-height: 52px;
1488
+ gap: 5px;
1359
1489
  }
1360
1490
  .toolbar span {
1361
1491
  opacity: 0.75;
@@ -1377,6 +1507,9 @@ function dt({
1377
1507
  margin-top: 7px;
1378
1508
  }
1379
1509
  .key {
1510
+ display: inline-flex;
1511
+ align-items: center;
1512
+ justify-content: center;
1380
1513
  min-width: 0;
1381
1514
  min-height: 44px;
1382
1515
  border: 0;
@@ -1394,6 +1527,26 @@ function dt({
1394
1527
  background: ${d === "dark" ? "#414e46" : "#d7e1db"};
1395
1528
  font-size: 14px;
1396
1529
  }
1530
+ .selection-count {
1531
+ min-width: 48px;
1532
+ white-space: nowrap;
1533
+ font-size: 11px;
1534
+ }
1535
+ .selection-actions {
1536
+ display: flex;
1537
+ flex: 1;
1538
+ gap: 5px;
1539
+ }
1540
+ .selection-actions .key {
1541
+ font-size: 12px;
1542
+ box-shadow: none;
1543
+ white-space: nowrap;
1544
+ }
1545
+ .feedback {
1546
+ margin: 0 6px 6px;
1547
+ font-size: 12px;
1548
+ line-height: 1.5;
1549
+ }
1397
1550
  .key[aria-pressed="true"]:not(.language) {
1398
1551
  background: #246447;
1399
1552
  color: #fff;
@@ -1443,109 +1596,137 @@ function dt({
1443
1596
  }
1444
1597
  }
1445
1598
  `,
1446
- children: /* @__PURE__ */ q("section", { className: "keyboard", role: "group", "aria-label": "가상 키보드", children: [
1447
- /* @__PURE__ */ q("div", { className: "toolbar", children: [
1448
- /* @__PURE__ */ q("span", { children: [
1449
- L ? "텍스트 편집" : w && X ? "숫자 · 기호" : l.mode === "number" ? "숫자" : l.mode === "tel" ? "전화번호" : c ? "한국어 · 두벌식" : "English",
1599
+ children: /* @__PURE__ */ Y("section", { className: "keyboard", role: "group", "aria-label": "가상 키보드", children: [
1600
+ /* @__PURE__ */ Y("div", { className: "toolbar", children: [
1601
+ u.selectionLength > 0 && !k ? /* @__PURE__ */ Y(Pe, { children: [
1602
+ /* @__PURE__ */ L(
1603
+ "span",
1604
+ {
1605
+ className: "selection-count",
1606
+ title: u.message || void 0,
1607
+ children: u.message === "복사했어요" ? "복사했어요" : `${u.selectionLength}자 선택`
1608
+ }
1609
+ ),
1610
+ /* @__PURE__ */ L(
1611
+ "div",
1612
+ {
1613
+ className: "selection-actions",
1614
+ role: "group",
1615
+ "aria-label": "선택한 텍스트 편집",
1616
+ children: ["Copy", "Cut", "SelectAll"].map((h) => /* @__PURE__ */ L(
1617
+ We,
1618
+ {
1619
+ cell: { value: h, type: "action" },
1620
+ value: h,
1621
+ label: Te[h],
1622
+ dispatch: () => X({ value: h, type: "action" })
1623
+ },
1624
+ h
1625
+ ))
1626
+ }
1627
+ )
1628
+ ] }) : /* @__PURE__ */ Y("span", { children: [
1629
+ k ? u.message === "복사했어요" ? "복사했어요" : "텍스트 편집" : _ && F ? "숫자 · 기호" : l.mode === "number" ? "숫자" : l.mode === "tel" ? "전화번호" : s ? "한국어 · 두벌식" : "English",
1450
1630
  v ? " · Shift 고정" : ""
1451
1631
  ] }),
1452
- X && !L && /* @__PURE__ */ C(
1632
+ F && !k && !u.selectionLength && /* @__PURE__ */ L(
1453
1633
  "button",
1454
1634
  {
1455
1635
  type: "button",
1456
1636
  className: "close",
1457
1637
  "aria-label": "숫자·기호 전환",
1458
- "aria-pressed": w,
1459
- ...H,
1460
- children: w ? "가 / ABC" : "123 / #+="
1638
+ "aria-pressed": _,
1639
+ ...ae,
1640
+ children: _ ? "가 / ABC" : "123 / #+="
1461
1641
  }
1462
1642
  ),
1463
- /* @__PURE__ */ C(
1643
+ /* @__PURE__ */ L(
1464
1644
  "button",
1465
1645
  {
1466
1646
  type: "button",
1467
1647
  className: "close",
1468
- ...re,
1648
+ ...Z,
1469
1649
  "aria-label": "키보드 닫기",
1470
1650
  children: "닫기 ↓"
1471
1651
  }
1472
1652
  )
1473
1653
  ] }),
1474
- D.map((p, S) => /* @__PURE__ */ C("div", { className: "row", children: p.map((g, y) => {
1475
- const z = De(g, c, h), A = g.type === "action" ? g.label ?? $e[z] ?? z : /^[A-Za-z]$/.test(g.value) ? z : g.label ?? z, j = g.value === "Shift" ? h : g.value === "HangulMode" ? c : g.value === "ToggleSelectionAdjust" ? f : void 0;
1476
- return /* @__PURE__ */ C(
1477
- st,
1654
+ u.message && u.message !== "복사했어요" && /* @__PURE__ */ L("p", { className: "feedback", children: u.message }),
1655
+ O.map((h, b) => /* @__PURE__ */ L("div", { className: "row", children: h.map((g, A) => {
1656
+ const I = Ue(g, s, m), U = g.type === "action" ? g.label ?? Te[I] ?? I : /^[A-Za-z]$/.test(g.value) ? I : g.label ?? I, C = g.value === "Shift" ? m : g.value === "HangulMode" ? s : g.value === "ToggleSelectionAdjust" ? p : void 0;
1657
+ return /* @__PURE__ */ L(
1658
+ We,
1478
1659
  {
1479
1660
  cell: g,
1480
- label: A,
1481
- value: z,
1482
- active: j,
1483
- disabled: g.value === "HangulMode" && Z || (g.type !== "action" || z === " ") && !l.filterKey(z),
1484
- dispatch: () => O(g)
1661
+ label: U,
1662
+ value: I,
1663
+ active: C,
1664
+ disabled: g.value === "HangulMode" && ce || ["Copy", "Cut"].includes(I) && !u.selectionLength || I === "SelectAll" && !u.hasValue || (g.type !== "action" || I === " ") && !l.filterKey(I),
1665
+ dispatch: () => X(g)
1485
1666
  },
1486
- `${S}-${y}-${g.value}`
1667
+ `${b}-${A}-${g.value}`
1487
1668
  );
1488
- }) }, S))
1669
+ }) }, b))
1489
1670
  ] })
1490
1671
  }
1491
1672
  ),
1492
1673
  document.body
1493
1674
  );
1494
1675
  }
1495
- const ve = "virtual-keyboard:storage";
1496
- function ft(e, r) {
1497
- const n = P(r), [o, i] = R(r), c = P(o), h = k(
1498
- () => n.current instanceof Function ? n.current() : n.current,
1676
+ const Se = "virtual-keyboard:storage";
1677
+ function kt(e, n) {
1678
+ const r = T(n), [a, i] = $(n), s = T(a), m = E(
1679
+ () => r.current instanceof Function ? r.current() : r.current,
1499
1680
  []
1500
1681
  );
1501
- V(() => {
1682
+ K(() => {
1502
1683
  const d = (u) => {
1503
1684
  try {
1504
- const I = u === null ? h() : JSON.parse(u);
1505
- return typeof I == typeof h() ? I : h();
1685
+ const P = u === null ? m() : JSON.parse(u);
1686
+ return typeof P == typeof m() ? P : m();
1506
1687
  } catch {
1507
- return h();
1688
+ return m();
1508
1689
  }
1509
- }, L = (u) => {
1510
- c.current = d(u), i(c.current);
1690
+ }, k = (u) => {
1691
+ s.current = d(u), i(s.current);
1511
1692
  };
1512
1693
  try {
1513
- L(window.localStorage.getItem(e));
1694
+ k(window.localStorage.getItem(e));
1514
1695
  } catch {
1515
1696
  }
1516
- const f = (u) => {
1697
+ const p = (u) => {
1517
1698
  try {
1518
1699
  if (u.storageArea && u.storageArea !== window.localStorage)
1519
1700
  return;
1520
1701
  } catch {
1521
1702
  return;
1522
1703
  }
1523
- (u.key === e || u.key === null) && L(u.newValue);
1704
+ (u.key === e || u.key === null) && k(u.newValue);
1524
1705
  }, l = (u) => {
1525
- const I = u.detail;
1526
- I.key === e && L(I.raw);
1706
+ const P = u.detail;
1707
+ P.key === e && k(P.raw);
1527
1708
  };
1528
- return window.addEventListener("storage", f), window.addEventListener(ve, l), () => {
1529
- window.removeEventListener("storage", f), window.removeEventListener(ve, l);
1709
+ return window.addEventListener("storage", p), window.addEventListener(Se, l), () => {
1710
+ window.removeEventListener("storage", p), window.removeEventListener(Se, l);
1530
1711
  };
1531
- }, [e, h]);
1532
- const v = k(
1712
+ }, [e, m]);
1713
+ const v = E(
1533
1714
  (d) => {
1534
- c.current = d instanceof Function ? d(c.current) : d, i(c.current), window.dispatchEvent(
1535
- new CustomEvent(ve, {
1536
- detail: { key: e, raw: JSON.stringify(c.current) }
1715
+ s.current = d instanceof Function ? d(s.current) : d, i(s.current), window.dispatchEvent(
1716
+ new CustomEvent(Se, {
1717
+ detail: { key: e, raw: JSON.stringify(s.current) }
1537
1718
  })
1538
1719
  );
1539
1720
  try {
1540
- window.localStorage.setItem(e, JSON.stringify(c.current));
1721
+ window.localStorage.setItem(e, JSON.stringify(s.current));
1541
1722
  } catch {
1542
1723
  }
1543
1724
  },
1544
1725
  [e]
1545
1726
  );
1546
- return [o, v];
1727
+ return [a, v];
1547
1728
  }
1548
- const pt = [
1729
+ const St = [
1549
1730
  [
1550
1731
  {
1551
1732
  label: "전체 선택",
@@ -1625,7 +1806,7 @@ const pt = [
1625
1806
  type: "action"
1626
1807
  }
1627
1808
  ]
1628
- ], ht = () => typeof window > "u" ? { width: 0, height: 0, scale: 1, offsetLeft: 0, offsetTop: 0 } : typeof window < "u" && window.visualViewport ? {
1809
+ ], Et = () => typeof window > "u" ? { width: 0, height: 0, scale: 1, offsetLeft: 0, offsetTop: 0 } : typeof window < "u" && window.visualViewport ? {
1629
1810
  width: window.visualViewport.width,
1630
1811
  height: window.visualViewport.height,
1631
1812
  scale: window.visualViewport.scale,
@@ -1637,185 +1818,191 @@ const pt = [
1637
1818
  scale: 1,
1638
1819
  offsetLeft: 0,
1639
1820
  offsetTop: 0
1640
- }, gt = (e, r) => e.width === r.width && e.height === r.height && e.scale === r.scale && e.offsetLeft === r.offsetLeft && e.offsetTop === r.offsetTop, mt = () => {
1641
- const [e, r] = R(() => ({
1821
+ }, Lt = (e, n) => e.width === n.width && e.height === n.height && e.scale === n.scale && e.offsetLeft === n.offsetLeft && e.offsetTop === n.offsetTop, Ct = () => {
1822
+ const [e, n] = $(() => ({
1642
1823
  width: 0,
1643
1824
  height: 0,
1644
1825
  scale: 1,
1645
1826
  offsetLeft: 0,
1646
1827
  offsetTop: 0
1647
1828
  }));
1648
- return V(() => {
1829
+ return K(() => {
1649
1830
  if (typeof window > "u") return;
1650
- let n = null;
1651
- const o = () => {
1652
- const c = ht();
1653
- r(
1654
- (h) => gt(h, c) ? h : c
1831
+ let r = null;
1832
+ const a = () => {
1833
+ const s = Et();
1834
+ n(
1835
+ (m) => Lt(m, s) ? m : s
1655
1836
  );
1656
1837
  };
1657
- o();
1838
+ a();
1658
1839
  const i = () => {
1659
- n !== null && cancelAnimationFrame(n), n = requestAnimationFrame(o);
1840
+ r !== null && cancelAnimationFrame(r), r = requestAnimationFrame(a);
1660
1841
  };
1661
1842
  return window.visualViewport ? (window.visualViewport.addEventListener("resize", i, {
1662
1843
  passive: !0
1663
1844
  }), window.visualViewport.addEventListener("scroll", i, {
1664
1845
  passive: !0
1665
1846
  })) : window.addEventListener("resize", i, { passive: !0 }), () => {
1666
- n !== null && cancelAnimationFrame(n), window.visualViewport ? (window.visualViewport.removeEventListener("resize", i), window.visualViewport.removeEventListener("scroll", i)) : window.removeEventListener("resize", i);
1847
+ r !== null && cancelAnimationFrame(r), window.visualViewport ? (window.visualViewport.removeEventListener("resize", i), window.visualViewport.removeEventListener("scroll", i)) : window.removeEventListener("resize", i);
1667
1848
  };
1668
1849
  }, []), e;
1669
1850
  };
1670
- function vt() {
1671
- const [e, r] = R("light");
1672
- return V(() => {
1851
+ function At() {
1852
+ const [e, n] = $("light");
1853
+ return K(() => {
1673
1854
  if (typeof window > "u" || !window.matchMedia) return;
1674
- const n = window.matchMedia("(prefers-color-scheme: dark)");
1675
- r(n.matches ? "dark" : "light");
1676
- const o = (i) => {
1677
- r(i.matches ? "dark" : "light");
1855
+ const r = window.matchMedia("(prefers-color-scheme: dark)");
1856
+ n(r.matches ? "dark" : "light");
1857
+ const a = (i) => {
1858
+ n(i.matches ? "dark" : "light");
1678
1859
  };
1679
- return n.addEventListener("change", o), () => n.removeEventListener("change", o);
1860
+ return r.addEventListener("change", a), () => r.removeEventListener("change", a);
1680
1861
  }, []), e;
1681
1862
  }
1682
- function je(e) {
1863
+ function Je(e) {
1683
1864
  return e !== void 0 ? /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1684
1865
  e
1685
- ) : typeof navigator > "u" ? !1 : je(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1 || typeof window < "u" && !!window.matchMedia?.("(pointer: coarse)").matches;
1866
+ ) : typeof navigator > "u" ? !1 : Je(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1 || typeof window < "u" && !!window.matchMedia?.("(pointer: coarse)").matches;
1686
1867
  }
1687
- const we = "virtual-keyboard:focus-change";
1688
- function Et({
1868
+ const Ee = "virtual-keyboard:focus-change";
1869
+ function Kt({
1689
1870
  children: e,
1690
- layout: r = G,
1691
- defaultHangulMode: n = !0,
1692
- theme: o,
1871
+ layout: n = ee,
1872
+ defaultHangulMode: r = !0,
1873
+ theme: a,
1693
1874
  keyboardVisibility: i = "auto"
1694
1875
  }) {
1695
- const c = Be(), h = P(null), v = P(null), d = P(
1876
+ const s = qe(), m = T(null), v = T(null), d = T(
1696
1877
  void 0
1697
- ), [L, f] = R(), [l, u] = R(0), [I, w] = R(!1), [Q, H] = R(!1), [re, X] = ft(
1878
+ ), [k, p] = $(), [l, u] = $(0), [P, w] = $(!1), [_, B] = $(!1), [ae, Z] = $({
1879
+ selectionLength: 0,
1880
+ hasValue: !1,
1881
+ message: ""
1882
+ }), [F, O] = kt(
1698
1883
  "virtual-keyboard-hangul-mode",
1699
- n
1700
- ), [D, O] = R(
1701
- () => ye({ layout: r })
1702
- ), [Z, ne] = R(!1), [p, S] = R(0), g = mt(), y = vt(), z = de(D.mode) ?? re, A = !!L && (i === "always" || i === "auto" && Z), j = P(A);
1703
- j.current = A, V(() => {
1704
- const b = () => ne(je());
1705
- b();
1706
- const K = window.matchMedia?.("(pointer: coarse)");
1707
- return K?.addEventListener("change", b), () => K?.removeEventListener("change", b);
1884
+ r
1885
+ ), [X, ce] = $(
1886
+ () => Le({ layout: n })
1887
+ ), [ie, h] = $(!1), [b, g] = $(0), A = Ct(), I = At(), U = ge(X.mode) ?? F, C = !!k && (i === "always" || i === "auto" && ie), J = T(C);
1888
+ J.current = C, K(() => {
1889
+ const y = () => h(Je());
1890
+ y();
1891
+ const D = window.matchMedia?.("(pointer: coarse)");
1892
+ return D?.addEventListener("change", y), () => D?.removeEventListener("change", y);
1708
1893
  }, []);
1709
- const T = k(() => {
1710
- clearTimeout(d.current), v.current = null, h.current = null, f(void 0), u(0), w(!1), H(!1);
1894
+ const M = E(() => {
1895
+ clearTimeout(d.current), v.current = null, m.current = null, p(void 0), u(0), w(!1), B(!1);
1711
1896
  }, []);
1712
- V(() => {
1713
- const b = (K) => {
1714
- K.detail !== c && T();
1897
+ K(() => {
1898
+ const y = (D) => {
1899
+ D.detail !== s && M();
1715
1900
  };
1716
- return window.addEventListener(we, b), () => {
1717
- window.removeEventListener(we, b), clearTimeout(d.current);
1901
+ return window.addEventListener(Ee, y), () => {
1902
+ window.removeEventListener(Ee, y), clearTimeout(d.current);
1718
1903
  };
1719
- }, [c, T]);
1720
- const s = k(
1721
- (b, K, Y) => {
1722
- clearTimeout(d.current), v.current !== K && (u(0), w(!1), H(!1)), v.current = K, O(ye(Y)), f(b), window.dispatchEvent(
1723
- new CustomEvent(we, { detail: c })
1904
+ }, [s, M]);
1905
+ const c = E(
1906
+ (y, D, q) => {
1907
+ clearTimeout(d.current), v.current !== D && (u(0), w(!1), B(!1)), v.current = D, ce(Le(q)), p(y), window.dispatchEvent(
1908
+ new CustomEvent(Ee, { detail: s })
1724
1909
  );
1725
1910
  },
1726
- [c]
1727
- ), m = k(
1728
- (b) => {
1729
- if (b === !0) {
1730
- T();
1911
+ [s]
1912
+ ), W = E(
1913
+ (y) => {
1914
+ if (y === !0) {
1915
+ M();
1731
1916
  return;
1732
1917
  }
1733
- const K = typeof b == "object" ? b.relatedTarget : null;
1734
- K?.closest?.("[data-virtual-input], [data-virtual-keypad]") || !K && j.current || (clearTimeout(d.current), d.current = setTimeout(T, 0));
1918
+ const D = typeof y == "object" ? y.relatedTarget : null;
1919
+ D?.closest?.("[data-virtual-input], [data-virtual-keypad]") || !D && J.current || (clearTimeout(d.current), d.current = setTimeout(M, 0));
1735
1920
  },
1736
- [T]
1921
+ [M]
1737
1922
  );
1738
- V(() => {
1739
- if (!A || !p || g.scale !== 1) return;
1740
- const b = requestAnimationFrame(() => {
1741
- const K = v.current?.getBoundingClientRect();
1742
- if (!K) return;
1743
- const Y = g.offsetTop + g.height - p - 16;
1744
- K.bottom > Y && window.scrollBy({ top: K.bottom - Y, behavior: "instant" });
1923
+ K(() => {
1924
+ if (!C || !b || A.scale !== 1) return;
1925
+ const y = requestAnimationFrame(() => {
1926
+ const D = v.current?.getBoundingClientRect();
1927
+ if (!D) return;
1928
+ const q = A.offsetTop + A.height - b - 16;
1929
+ D.bottom > q && window.scrollBy({ top: D.bottom - q, behavior: "instant" });
1745
1930
  });
1746
- return () => cancelAnimationFrame(b);
1931
+ return () => cancelAnimationFrame(y);
1747
1932
  }, [
1748
- L,
1749
- A,
1750
- p,
1751
- g.height,
1752
- g.offsetTop,
1753
- g.scale
1933
+ k,
1934
+ C,
1935
+ b,
1936
+ A.height,
1937
+ A.offsetTop,
1938
+ A.scale
1754
1939
  ]);
1755
- const U = k(() => {
1756
- de(D.mode) === null && X((b) => !b);
1757
- }, [D.mode, X]), W = k(
1758
- () => u((b) => (b + 1) % 3),
1940
+ const ne = E(() => {
1941
+ ge(X.mode) === null && O((y) => !y);
1942
+ }, [X.mode, O]), G = E(
1943
+ () => u((y) => (y + 1) % 3),
1759
1944
  []
1760
- ), F = k(
1761
- () => u((b) => b === 1 ? 0 : b),
1945
+ ), V = E(
1946
+ () => u((y) => y === 1 ? 0 : y),
1762
1947
  []
1763
- ), _ = k(() => {
1764
- w(!0), H(!1);
1765
- }, []), ae = k(() => {
1766
- w(!1), H(!1);
1767
- }, []), N = k(
1768
- () => H((b) => !b),
1948
+ ), Q = E(() => {
1949
+ w(!0), B(!1);
1950
+ }, []), le = E(() => {
1951
+ w(!1), B(!1);
1952
+ }, []), j = E(
1953
+ () => B((y) => !y),
1769
1954
  []
1770
1955
  );
1771
- return /* @__PURE__ */ q(
1772
- He.Provider,
1956
+ return /* @__PURE__ */ Y(
1957
+ Ze.Provider,
1773
1958
  {
1774
1959
  value: {
1775
- inputRef: h,
1776
- focusId: L,
1777
- onFocus: s,
1778
- onBlur: m,
1779
- defaultLayout: r,
1780
- hangulMode: z,
1960
+ inputRef: m,
1961
+ focusId: k,
1962
+ onFocus: c,
1963
+ onBlur: W,
1964
+ defaultLayout: n,
1965
+ hangulMode: U,
1781
1966
  shift: l > 0,
1782
1967
  shiftLocked: l === 2,
1783
- theme: o ?? y,
1784
- toggleKorean: U,
1785
- toggleShift: W,
1786
- consumeShift: F,
1787
- selectionMode: I,
1788
- selectionAdjusting: Q,
1789
- enterSelectionMode: _,
1790
- exitSelectionMode: ae,
1791
- toggleSelectionAdjust: N,
1792
- activeInputPolicy: D
1968
+ theme: a ?? I,
1969
+ toggleKorean: ne,
1970
+ toggleShift: G,
1971
+ consumeShift: V,
1972
+ selectionMode: P,
1973
+ selectionAdjusting: _,
1974
+ enterSelectionMode: Q,
1975
+ exitSelectionMode: le,
1976
+ toggleSelectionAdjust: j,
1977
+ activeInputPolicy: X,
1978
+ editingStatus: ae,
1979
+ setEditingStatus: Z
1793
1980
  },
1794
1981
  children: [
1795
1982
  e,
1796
- A && /* @__PURE__ */ q(ze, { children: [
1797
- ke(
1798
- /* @__PURE__ */ C(
1983
+ C && /* @__PURE__ */ Y(Pe, { children: [
1984
+ Ie(
1985
+ /* @__PURE__ */ L(
1799
1986
  "div",
1800
1987
  {
1801
1988
  "aria-hidden": "true",
1802
1989
  style: {
1803
- height: p,
1990
+ height: b,
1804
1991
  pointerEvents: "none",
1805
- background: (o ?? y) === "dark" ? "#121c17" : "#f7f8f4"
1992
+ background: (a ?? I) === "dark" ? "#121c17" : "#f7f8f4"
1806
1993
  }
1807
1994
  }
1808
1995
  ),
1809
1996
  document.body
1810
1997
  ),
1811
- /* @__PURE__ */ C(
1812
- dt,
1998
+ /* @__PURE__ */ L(
1999
+ xt,
1813
2000
  {
1814
- layout: I ? pt : D.layout,
1815
- viewport: g,
1816
- onHeightChange: S
2001
+ layout: P ? St : X.layout,
2002
+ viewport: A,
2003
+ onHeightChange: g
1817
2004
  },
1818
- L
2005
+ k
1819
2006
  )
1820
2007
  ] })
1821
2008
  ]
@@ -1823,6 +2010,6 @@ function Et({
1823
2010
  );
1824
2011
  }
1825
2012
  export {
1826
- kt as VirtualInput,
1827
- Et as VirtualInputProvider
2013
+ Dt as VirtualInput,
2014
+ Kt as VirtualInputProvider
1828
2015
  };