@uiwwsw/virtual-keyboard 2.1.0 → 2.2.0

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