import { watch as k, toRef as g } from "vue";
import { C as o, c as m } from "./forms-BAUgA7Ct.es.js";
const h = '.ui-datepicker{--datepicker-day-color: var(--color-layout-front-1);--datepicker-day-color-hover: var(--color-layer-1);--datepicker-selected-color: var(--color-bg-primary-1);--datepicker-selected-color-hover: var(--color-bg-primary-2);--datepicker-range-color: var(--color-layer-primary-1);--datepicker-range-color-hover: var(--color-layer-primary-2);-webkit-user-select:none;user-select:none;width:auto;padding:0}.ui-datepicker:before,.ui-datepicker:after{display:none}.ui-datepicker-inline{display:inline-block!important}.ui-datepicker:not(.ui-datepicker-inline){border-radius:8px;background:var(--color-layout-front-1);box-shadow:var(--top-shadow);z-index:10000000!important;padding:8px}.ui-datepicker a{text-decoration:none!important}.ui-datepicker option{color:var(--color-text-1);font-size:14px}.ui-datepicker-header{padding:0!important;margin:0 0 18px;display:flex;align-items:center}.ui-datepicker-header>*{display:flex;align-items:center;justify-content:center}.ui-datepicker-title{width:100%!important;height:24px;margin:0!important}.ui-datepicker-month,.ui-datepicker-year{outline:none!important;width:auto!important;border:none;padding:0;margin:0 6px!important;text-align:center;font-size:16px!important}.ui-datepicker-month{color:var(--color-text-1)}.ui-datepicker-year{color:var(--color-text-2)}select.ui-datepicker-month,select.ui-datepicker-year{cursor:pointer}.ui-datepicker-prev,.ui-datepicker-next{cursor:pointer;width:24px!important;height:24px!important;font-size:24px;font-family:Topvisor-2;position:static!important}.ui-datepicker-prev:before{color:var(--color-text-3);content:""}.ui-datepicker-prev-hover:before{color:var(--color-text-1);content:""}.ui-datepicker-next{color:var(--color-text-3);order:1}.ui-datepicker-next-hover{color:var(--color-text-1);order:1}.ui-datepicker-next:before{content:""}.ui-datepicker-prev>*,.ui-datepicker-next>*{display:none!important}.ui-datepicker thead th{width:auto!important;padding:0!important;color:var(--color-text-3);font-size:14px;font-weight:400!important}.ui-datepicker table{margin:0!important;font-size:14px}.ui-datepicker td{color:var(--color-text-1);background:none;padding:0!important}.ui-datepicker td span,.ui-datepicker td a{border-radius:8px;border:none;min-width:32px;height:32px;padding:0;margin:1px;color:var(--color-text-1)!important;line-height:32px;text-align:center;position:relative;display:block}.ui-datepicker td a{background:var(--datepicker-day-color)}.ui-datepicker td a:hover{background:var(--datepicker-day-color-hover)}td.ui-datepicker-today span,td.ui-datepicker-today a{background:none;position:relative}.ui-datepicker td.selected a{background:var(--datepicker-range-color);padding-right:0;padding-left:1px;margin-right:1px;margin-left:0}.ui-datepicker td.selected a:hover{background:var(--datepicker-range-color-hover)}.ui-datepicker td.selected:not(.selected-start):not(:first-child):not(.first-of-month) a{border-top-left-radius:0;border-bottom-left-radius:0;padding-left:1px;margin-left:0}.ui-datepicker td.selected:not(.selected-end):not(:last-child):not(.last-of-month) a{border-top-right-radius:0;border-bottom-right-radius:0;padding-right:1px;margin-right:0}.ui-datepicker td.selected-start a,.ui-datepicker td.selected-end a,.ui-datepicker td.ui-datepicker-current-day a{background:var(--datepicker-selected-color);color:#fff!important}.ui-datepicker td.selected-start a:hover,.ui-datepicker td.selected-end a:hover,.ui-datepicker td.ui-datepicker-current-day a:hover{background:var(--datepicker-selected-color-hover)}.ui-datepicker-day-marks{line-height:normal;position:absolute;right:0;bottom:3px;left:0;display:flex;align-items:center;justify-content:center}.ui-datepicker-day-marks>i{border-radius:50%;border:1px solid #FFF;width:4px;height:4px;margin:0 2px}.ui-datepicker-day-marks-exists{background:var(--color-text-primary)}.ui-datepicker-day-marks-update{background:var(--color-text-negative)}.ui-datepicker-row-break{display:none}';
o.insertStyleToPage(h);
const x = (e) => {
  if (!o.$?.ui?.datepicker) {
    console.info("Для работы datepicker требуется глобальная загрузка jQuery UI Datepicker");
    return;
  }
  return o.$.datepicker.setDefaults({
    dateFormat: o.state.dateFormat.toLowerCase().replace("m", "mm").replace("y", "yy").replace("d", "dd")
  }), o.$(e);
};
function b(e, t) {
  return x(e)?.datepicker(t);
}
let n, l, p, u;
k(g(o.state.dateFormat), () => {
  n = m("2000-01-01"), l = n.match(/\D/)?.[0] ?? "-", p = n.replace(/\D+/g, "").length, u = [];
  for (let e = 0; e < n.length; e++)
    n[e] === l && u.push(e);
}, { immediate: !0 });
function y(e) {
  let t = e.target.selectionEnd, r = e.target.value, i = r.substring(0, t).replace(/\D+/g, ""), a = r.substring(t).replace(/\D+/g, ""), c = i.length + a.length - p;
  if (c > 0) {
    i = i.substring(0, p);
    const d = p - i.length;
    a = a.substring(a.length - d);
  } else c < 0 && (e.inputType === "deleteContentForward" ? i += "0".repeat(-c) : a = "0".repeat(-c) + a);
  t = i.length, r = i + a;
  for (let d = 0; d < u.length; d++) {
    const s = u[d];
    r = r.substring(0, s) + l + r.substring(s), t >= s && t++;
  }
  e.inputType === "deleteContentBackward" && r[t - 1] === l && t--, r !== e.target.value && (e.target.value = r, e.target.selectionStart = t, e.target.selectionEnd = t);
}
export {
  b as connectDatepicker,
  y as oninput
};
//# sourceMappingURL=datepicker-C0jmLfiX.es.js.map
