import { X as S, cV as j, w as y, Y as a, S as q, O as v, ex as I, bI as F, Z as T, bQ as z, N as J, U as W, a6 as o, F as t, ey as _, ah as $, al as G, bV as H, G as x, a7 as d, a8 as u, af as h, bJ as Q, a9 as X, aa as Y, ac as V, bL as Z, ez as A } from "./603b75d9.js";
import { ButtonCompWrapper as K, Button100 as ee, buttonRefMethods as te } from "./26dac75c.js";
import ne, { useState as s, useEffect as ae, useRef as oe, Suspense as se, useContext as m } from "react";
import "react-dom";
const ie = S.div`
  color: #f5222d;
  height: 100px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
`, re = S.div`
  video,
  .ant-skeleton {
    height: 400px;
    max-height: 70vh;
    position: relative;
    object-fit: cover;
    background-color: #000;
  }
  .ant-skeleton {
    h3,
    li {
      background-color: transparent;
    }
  }
`, le = S(A)`
  top: 10vh;
  .react-draggable {
    max-width: 100%;
    width: 500px;
  }
`, ce = ne.lazy(() => import("./29f81326.js").then((f) => f.i)), de = function() {
  const f = {
    data: j("data"),
    text: y(q, a("scanner.text")),
    continuous: v,
    uniqueData: y(v, !0),
    maskClosable: y(v, !0),
    onEvent: I,
    disabled: F,
    style: T(z, "style"),
    viewRef: J
  };
  return new W(f, (e) => {
    const [r, g] = s(!1), [k, C] = s(""), [p, D] = s({
      facingMode: "environment"
    }), [B, R] = s([]), [P, M] = s(!1), [E, b] = s(!1);
    ae(() => {
      !r && E && e.onEvent("success");
    }, [E, r]);
    const i = oe([]), L = (n, l) => {
      if (l)
        if (e.continuous) {
          i.current = [...i.current, l.text];
          const w = e.uniqueData ? [...new Set(i.current)] : i.current;
          e.data.onChange(w), e.onEvent("success");
        } else
          e.data.onChange([l.text]), g(!1), b(!0);
      else
        b(!1);
    }, N = (n) => {
      typeof n == "string" ? C(n) : n.message === "getUserMedia is not implemented in this browser" ? C(a("scanner.errTip")) : C(n.message), b(!1);
    }, O = () => {
      navigator.mediaDevices.enumerateDevices().then((n) => {
        const w = n.filter((c) => c.kind === "videoinput").map((c, U) => ({
          label: c.label || a("scanner.camera", {
            index: U + 1
          }),
          key: c.deviceId
        }));
        R(w);
      });
    };
    return /* @__PURE__ */ o(K, {
      $disabled: e.disabled,
      children: [/* @__PURE__ */ t(ee, {
        ref: e.viewRef,
        $buttonStyle: e.style,
        disabled: e.disabled,
        onClick: () => {
          e.onEvent("click"), g(!0), i.current = [];
        },
        children: /* @__PURE__ */ t("span", {
          children: e.text
        })
      }), /* @__PURE__ */ t(le, {
        showOkButton: !1,
        showCancelButton: !1,
        open: r,
        maskClosable: e.maskClosable,
        destroyOnClose: !0,
        onCancel: () => {
          g(!1), e.onEvent("close");
        },
        children: k ? /* @__PURE__ */ t(ie, {
          children: k
        }) : r && /* @__PURE__ */ o(re, {
          children: [/* @__PURE__ */ t(se, {
            fallback: /* @__PURE__ */ t(_, {}),
            children: /* @__PURE__ */ t(ce, {
              delay: 1e3,
              onUpdate: L,
              onError: N,
              videoConstraints: p
            }, JSON.stringify(p))
          }), /* @__PURE__ */ t("div", {
            style: {
              height: "42px"
            },
            onClick: () => {
              M(!1);
            },
            children: /* @__PURE__ */ t($, {
              placement: "bottomRight",
              trigger: ["click"],
              open: P,
              onOpenChange: (n) => M(n),
              dropdownRender: () => /* @__PURE__ */ t(G, {
                items: B,
                onClick: (n) => D({
                  ...p,
                  deviceId: n.key
                })
              }),
              children: /* @__PURE__ */ t(H, {
                style: {
                  float: "right",
                  marginTop: "10px"
                },
                onClick: (n) => {
                  n.stopPropagation(), O();
                },
                children: a("scanner.changeCamera")
              })
            })
          })]
        })
      })]
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ o(x, {
    children: [/* @__PURE__ */ t(d, {
      name: u.basic,
      children: e.text.propertyView({
        label: a("text")
      })
    }), (m(h).editorModeStatus === "logic" || m(h).editorModeStatus === "both") && /* @__PURE__ */ o(x, {
      children: [/* @__PURE__ */ o(d, {
        name: u.interaction,
        children: [e.onEvent.getPropertyView(), Q(e), X(e)]
      }), /* @__PURE__ */ o(d, {
        name: u.advanced,
        children: [e.continuous.propertyView({
          label: a("scanner.continuous")
        }), e.continuous.getView() && e.uniqueData.propertyView({
          label: a("scanner.uniqueData")
        }), e.maskClosable.propertyView({
          label: a("scanner.maskClosable")
        })]
      })]
    }), (m(h).editorModeStatus === "layout" || m(h).editorModeStatus === "both") && /* @__PURE__ */ t(x, {
      children: /* @__PURE__ */ t(d, {
        name: u.style,
        children: e.style.getPropertyView()
      })
    })]
  })).setExposeMethodConfigs(te).build();
}(), ge = Y(de, [new V("data", a("data")), new V("text", a("button.textDesc")), ...Z]);
export {
  ge as ScannerComp
};
