@vue-js-cron/core
Version:
A renderless Vue.js cron editor.
2,016 lines • 54.7 kB
JavaScript
var ue = Object.defineProperty;
var oe = (a, e, t) => e in a ? ue(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
var d = (a, e, t) => (oe(a, typeof e != "symbol" ? e + "" : e, t), t);
import { ref as k, watch as g, defineComponent as ne, computed as re } from "vue";
var T = /* @__PURE__ */ ((a) => (a.Any = "any", a.Value = "value", a.Range = "range", a.Step = "step", a.RangeStep = "rangeStep", a.Combined = "combined", a.NoSpecific = "noSpecific", a))(T || {}), j = /* @__PURE__ */ ((a) => (a.Prefix = "prefix", a.Suffix = "suffix", a.Text = "text", a))(j || {});
class le {
constructor(e) {
d(this, "field");
d(this, "itemMap");
this.field = e, this.itemMap = this.field.items.reduce(
(t, n) => (t[n.value] = n, t),
{}
);
}
get id() {
return this.field.id;
}
get items() {
return this.field.items;
}
get onChange() {
return this.field.onChange;
}
get segmentFactories() {
return this.field.segmentFactories;
}
get min() {
return this.items[0].value;
}
get max() {
return this.items[this.items.length - 1].value;
}
getItem(e) {
return this.itemMap[e];
}
}
function fe(a, e, t = 1) {
const n = [];
for (let r = a; r <= e; r += t)
n.push(r);
return n;
}
class xe {
constructor(e, t, n = 1) {
d(this, "start");
d(this, "end");
d(this, "step");
return this.start = e, this.end = t, this.step = n, new Proxy(this, {
get: function(r, i) {
const s = typeof i == "string" ? parseInt(i) : i;
return typeof s == "number" && s >= 0 && s <= r.length ? r.start + r.step * s : Reflect.get(r, i);
}
});
}
get length() {
return (this.end - this.start) / this.step + 1;
}
[Symbol.iterator]() {
let e = -1;
return {
next: () => ({ value: this[++e], done: this[e + 1] === void 0 })
};
}
}
function V(a, e, t = (r) => r + "", n = (r) => r + "") {
const r = [];
for (const i of new xe(a, e))
r.push({
text: t(i),
alt: n(i),
value: i
});
return r;
}
function pe(a, e = "crontab") {
const t = (r, i = !1) => new Date(2021, r - 1, 1).toLocaleDateString(a, {
month: i ? "short" : "long"
}), n = (r, i = !1) => new Date(2021, 0, 3 + r).toLocaleDateString(a, {
weekday: i ? "short" : "long"
});
return {
secondItems: V(0, 59, (r) => K(r, 2)),
minuteItems: V(0, 59, (r) => K(r, 2)),
hourItems: V(0, 23, (r) => K(r, 2)),
dayItems: V(1, 31),
monthItems: V(1, 12, t, (r) => t(r, !0)),
dayOfWeekItems: e === "quartz" ? V(
1,
7,
(r) => n(r - 1),
(r) => n(r - 1, !0)
) : V(0, 6, n, (r) => n(r, !0))
};
}
function K(a, e) {
const t = a + "";
return t.length < e ? new Array(e - t.length).fill("0").join("") + a : t;
}
function B(a) {
return a && typeof a == "object" && !Array.isArray(a);
}
function G(a, ...e) {
if (!B(a) || e.length === 0)
return;
const t = e.shift();
if (B(t))
for (const [n, r] of Object.entries(t))
B(r) ? (B(a[n]) || (a[n] = {}), G(a[n], t[n])) : a[n] = t[n];
return e.length > 0 && G(a, ...e), a;
}
function ae(a, ...e) {
if (e.length === 0)
return a;
for (const t of e[0])
if (t in a) {
const n = ae(a[t], ...e.slice(1));
if (n !== void 0)
return n;
}
}
function ce(a) {
for (let e = 1; e < a.length; e++)
if (a[e - 1] + 1 !== a[e])
return !1;
return !0;
}
function de() {
throw new Error("not implemented");
}
function he(a, e, t = !0) {
const n = [];
for (let r = 0; r < a.length; r += e) {
const i = a.slice(r, r + e);
for (; t && i.length < e; )
i.push(null);
n.push(i);
}
return n;
}
class Q {
constructor(e) {
d(this, "field");
d(this, "type", T.NoSpecific);
this.field = e;
}
toCron() {
return "?";
}
toArray() {
return [];
}
get items() {
return {};
}
static fromString(e, t) {
return e !== "?" ? null : new Q(t);
}
}
class M {
constructor(e) {
d(this, "field");
d(this, "type", T.Any);
this.field = e;
}
toCron() {
return "*";
}
toArray() {
return [];
}
get items() {
return {};
}
static fromString(e, t) {
return e !== "*" ? null : new M(t);
}
static fromArray(e, t) {
const { items: n } = t;
if (e.length === 0)
return new M(t);
if (e.length !== n.length)
return null;
for (const r of n)
if (!e.includes(r.value))
return null;
return ce(n.map((r) => r.value)) ? new M(t) : null;
}
}
const N = class N {
constructor(e, t, n) {
d(this, "field");
d(this, "type", T.Range);
d(this, "start");
d(this, "end");
this.field = e, this.start = t, this.end = n;
}
toCron() {
return `${this.start}-${this.end}`;
}
toArray() {
const e = this.start, t = this.end;
return fe(e, t);
}
get items() {
return {
start: this.field.itemMap[this.start],
end: this.field.itemMap[this.end]
};
}
static fromString(e, t) {
if (!N.re.test(e))
return null;
const { min: n, max: r } = t, i = e.split("-"), s = parseInt(i[0]), u = parseInt(i[1]);
return s > u || s < n || u > r ? null : new N(t, s, u);
}
};
d(N, "re", /^\d+-\d+$/);
let $ = N;
function Z(a, e, t) {
const n = [];
for (let r = e; r <= t; r += a)
n.push(r);
return n;
}
const E = class E {
constructor(e, t, n, r) {
d(this, "field");
d(this, "step");
d(this, "start");
d(this, "end");
this.field = e, this.step = t, this.start = n ?? e.min, this.end = r ?? e.max;
}
get type() {
const { min: e, max: t } = this.field;
return this.start !== e || t - this.end >= this.step ? T.RangeStep : T.Step;
}
toCron() {
return this.type == T.RangeStep ? `${this.start}-${this.end}/${this.step}` : `*/${this.step}`;
}
toArray() {
return Z(this.step, this.start, this.end);
}
get items() {
return {
step: this.field.itemMap[this.step],
start: this.field.itemMap[this.start],
end: this.field.itemMap[this.end]
};
}
static fromString(e, t) {
if (!E.re.test(e))
return null;
const [n, r] = e.split("/"), i = parseInt(r);
if (i > t.items.length)
return null;
const s = e.split("-").map((x) => parseInt(x)), u = n == "*" ? t.min : s[0], o = n == "*" ? t.max : s[1];
return Z(i, u, o).length == 0 ? null : new E(t, i, u, o);
}
static fromArray(e, t) {
if (e.length < 3)
return null;
const n = e[1] - e[0];
if (n <= 1)
return null;
for (let r = 2; r < e.length; r++)
if (e[r] - e[r - 1] != n)
return null;
return new E(t, n, e[0], e[e.length - 1]);
}
};
d(E, "re", /^(\*|\d+-\d+)\/\d+$/);
let P = E;
class U {
constructor(e, t) {
d(this, "field");
d(this, "type", T.Value);
d(this, "value");
this.field = e, this.value = t;
}
toCron() {
return `${this.value}`;
}
toArray() {
return [this.value];
}
get items() {
return {
value: this.field.itemMap[this.value]
};
}
static fromString(e, t) {
const { min: n, max: r } = t, i = parseInt(e);
return String(i) === e && i >= n && i <= r ? new U(t, i) : null;
}
static fromArray(e, t) {
const { min: n, max: r } = t;
if (e.length != 1)
return null;
const i = e[0];
return i < n || i > r ? null : i;
}
}
const R = class R {
constructor(e, t = []) {
d(this, "field");
d(this, "segments");
this.field = e, this.segments = t;
}
get type() {
return this.segments.length == 1 ? this.segments[0].type : T.Range;
}
addSegment(e) {
this.segments.push(e);
}
toCron() {
return this.segments.map((e) => e.toCron()).join(",");
}
toArray() {
const e = /* @__PURE__ */ new Set();
for (const t of this.segments)
t.toArray().forEach((n) => e.add(n));
return Array.from(e);
}
get items() {
return de();
}
static fromString(e, t) {
const n = t.segmentFactories ?? R.segmentFactories;
let r = [];
for (const i of e.split(",")) {
if (i === "*") {
r = [new M(t)];
break;
}
let s = null;
for (const u of n)
if (s = u(i, t), s !== null)
break;
if (s === null)
return null;
r.push(s);
}
return new R(t, r);
}
static fromArray(e, t) {
const { min: n, max: r } = t, i = e[0], s = e[e.length - 1];
if (i < n || s > r)
return null;
const u = [];
let o = 0;
for (let x = 0; x < e.length; x++)
(e[x + 1] === void 0 || e[x + 1] - e[x] > 1) && (x === o ? u.push(new U(t, e[o])) : u.push(new $(t, e[o], e[x])), o = x + 1);
return new R(t, u);
}
};
d(R, "segmentFactories", [
M.fromString,
P.fromString,
$.fromString,
U.fromString
]);
let F = R;
function _(a, e) {
return F.fromString(a, e);
}
function me(a, e) {
for (const t of [
M.fromArray,
P.fromArray,
F.fromArray
]) {
const n = t(a, e);
if (n != null)
return n;
}
return null;
}
/*!
* mustache.js - Logic-less {{mustache}} templates with JavaScript
* http://github.com/janl/mustache.js
*/
var ve = Object.prototype.toString, H = Array.isArray || function(e) {
return ve.call(e) === "[object Array]";
};
function X(a) {
return typeof a == "function";
}
function ye(a) {
return H(a) ? "array" : typeof a;
}
function Y(a) {
return a.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
}
function ee(a, e) {
return a != null && typeof a == "object" && e in a;
}
function ge(a, e) {
return a != null && typeof a != "object" && a.hasOwnProperty && a.hasOwnProperty(e);
}
var Se = RegExp.prototype.test;
function we(a, e) {
return Se.call(a, e);
}
var ke = /\S/;
function Ce(a) {
return !we(ke, a);
}
var Oe = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
"/": "/",
"`": "`",
"=": "="
};
function be(a) {
return String(a).replace(/[&<>"'`=\/]/g, function(t) {
return Oe[t];
});
}
var qe = /\s*/, Ae = /\s+/, te = /\s*=/, We = /\s*\}/, Te = /#|\^|\/|>|\{|&|=|!/;
function Me(a, e) {
if (!a)
return [];
var t = !1, n = [], r = [], i = [], s = !1, u = !1, o = "", x = 0;
function h() {
if (s && !u)
for (; i.length; )
delete r[i.pop()];
else
i = [];
s = !1, u = !1;
}
var p, y, W;
function A(b) {
if (typeof b == "string" && (b = b.split(Ae, 2)), !H(b) || b.length !== 2)
throw new Error("Invalid tags: " + b);
p = new RegExp(Y(b[0]) + "\\s*"), y = new RegExp("\\s*" + Y(b[1])), W = new RegExp("\\s*" + Y("}" + b[1]));
}
A(e || q.tags);
for (var l = new z(a), m, f, v, O, I, c; !l.eos(); ) {
if (m = l.pos, v = l.scanUntil(p), v)
for (var S = 0, w = v.length; S < w; ++S)
O = v.charAt(S), Ce(O) ? (i.push(r.length), o += O) : (u = !0, t = !0, o += " "), r.push(["text", O, m, m + 1]), m += 1, O === `
` && (h(), o = "", x = 0, t = !1);
if (!l.scan(p))
break;
if (s = !0, f = l.scan(Te) || "name", l.scan(qe), f === "=" ? (v = l.scanUntil(te), l.scan(te), l.scanUntil(y)) : f === "{" ? (v = l.scanUntil(W), l.scan(We), l.scanUntil(y), f = "&") : v = l.scanUntil(y), !l.scan(y))
throw new Error("Unclosed tag at " + l.pos);
if (f == ">" ? I = [f, v, m, l.pos, o, x, t] : I = [f, v, m, l.pos], x++, r.push(I), f === "#" || f === "^")
n.push(I);
else if (f === "/") {
if (c = n.pop(), !c)
throw new Error('Unopened section "' + v + '" at ' + m);
if (c[1] !== v)
throw new Error('Unclosed section "' + c[1] + '" at ' + m);
} else
f === "name" || f === "{" || f === "&" ? u = !0 : f === "=" && A(v);
}
if (h(), c = n.pop(), c)
throw new Error('Unclosed section "' + c[1] + '" at ' + l.pos);
return Ve(Ie(r));
}
function Ie(a) {
for (var e = [], t, n, r = 0, i = a.length; r < i; ++r)
t = a[r], t && (t[0] === "text" && n && n[0] === "text" ? (n[1] += t[1], n[3] = t[3]) : (e.push(t), n = t));
return e;
}
function Ve(a) {
for (var e = [], t = e, n = [], r, i, s = 0, u = a.length; s < u; ++s)
switch (r = a[s], r[0]) {
case "#":
case "^":
t.push(r), n.push(r), t = r[4] = [];
break;
case "/":
i = n.pop(), i[5] = r[2], t = n.length > 0 ? n[n.length - 1][4] : e;
break;
default:
t.push(r);
}
return e;
}
function z(a) {
this.string = a, this.tail = a, this.pos = 0;
}
z.prototype.eos = function() {
return this.tail === "";
};
z.prototype.scan = function(e) {
var t = this.tail.match(e);
if (!t || t.index !== 0)
return "";
var n = t[0];
return this.tail = this.tail.substring(n.length), this.pos += n.length, n;
};
z.prototype.scanUntil = function(e) {
var t = this.tail.search(e), n;
switch (t) {
case -1:
n = this.tail, this.tail = "";
break;
case 0:
n = "";
break;
default:
n = this.tail.substring(0, t), this.tail = this.tail.substring(t);
}
return this.pos += n.length, n;
};
function D(a, e) {
this.view = a, this.cache = { ".": this.view }, this.parent = e;
}
D.prototype.push = function(e) {
return new D(e, this);
};
D.prototype.lookup = function(e) {
var t = this.cache, n;
if (t.hasOwnProperty(e))
n = t[e];
else {
for (var r = this, i, s, u, o = !1; r; ) {
if (e.indexOf(".") > 0)
for (i = r.view, s = e.split("."), u = 0; i != null && u < s.length; )
u === s.length - 1 && (o = ee(i, s[u]) || ge(i, s[u])), i = i[s[u++]];
else
i = r.view[e], o = ee(r.view, e);
if (o) {
n = i;
break;
}
r = r.parent;
}
t[e] = n;
}
return X(n) && (n = n.call(this.view)), n;
};
function C() {
this.templateCache = {
_cache: {},
set: function(e, t) {
this._cache[e] = t;
},
get: function(e) {
return this._cache[e];
},
clear: function() {
this._cache = {};
}
};
}
C.prototype.clearCache = function() {
typeof this.templateCache < "u" && this.templateCache.clear();
};
C.prototype.parse = function(e, t) {
var n = this.templateCache, r = e + ":" + (t || q.tags).join(":"), i = typeof n < "u", s = i ? n.get(r) : void 0;
return s == null && (s = Me(e, t), i && n.set(r, s)), s;
};
C.prototype.render = function(e, t, n, r) {
var i = this.getConfigTags(r), s = this.parse(e, i), u = t instanceof D ? t : new D(t, void 0);
return this.renderTokens(s, u, n, e, r);
};
C.prototype.renderTokens = function(e, t, n, r, i) {
for (var s = "", u, o, x, h = 0, p = e.length; h < p; ++h)
x = void 0, u = e[h], o = u[0], o === "#" ? x = this.renderSection(u, t, n, r, i) : o === "^" ? x = this.renderInverted(u, t, n, r, i) : o === ">" ? x = this.renderPartial(u, t, n, i) : o === "&" ? x = this.unescapedValue(u, t) : o === "name" ? x = this.escapedValue(u, t, i) : o === "text" && (x = this.rawValue(u)), x !== void 0 && (s += x);
return s;
};
C.prototype.renderSection = function(e, t, n, r, i) {
var s = this, u = "", o = t.lookup(e[1]);
function x(y) {
return s.render(y, t, n, i);
}
if (o) {
if (H(o))
for (var h = 0, p = o.length; h < p; ++h)
u += this.renderTokens(e[4], t.push(o[h]), n, r, i);
else if (typeof o == "object" || typeof o == "string" || typeof o == "number")
u += this.renderTokens(e[4], t.push(o), n, r, i);
else if (X(o)) {
if (typeof r != "string")
throw new Error("Cannot use higher-order sections without the original template");
o = o.call(t.view, r.slice(e[3], e[5]), x), o != null && (u += o);
} else
u += this.renderTokens(e[4], t, n, r, i);
return u;
}
};
C.prototype.renderInverted = function(e, t, n, r, i) {
var s = t.lookup(e[1]);
if (!s || H(s) && s.length === 0)
return this.renderTokens(e[4], t, n, r, i);
};
C.prototype.indentPartial = function(e, t, n) {
for (var r = t.replace(/[^ \t]/g, ""), i = e.split(`
`), s = 0; s < i.length; s++)
i[s].length && (s > 0 || !n) && (i[s] = r + i[s]);
return i.join(`
`);
};
C.prototype.renderPartial = function(e, t, n, r) {
if (n) {
var i = this.getConfigTags(r), s = X(n) ? n(e[1]) : n[e[1]];
if (s != null) {
var u = e[6], o = e[5], x = e[4], h = s;
o == 0 && x && (h = this.indentPartial(s, x, u));
var p = this.parse(h, i);
return this.renderTokens(p, t, n, h, r);
}
}
};
C.prototype.unescapedValue = function(e, t) {
var n = t.lookup(e[1]);
if (n != null)
return n;
};
C.prototype.escapedValue = function(e, t, n) {
var r = this.getConfigEscape(n) || q.escape, i = t.lookup(e[1]);
if (i != null)
return typeof i == "number" && r === q.escape ? String(i) : r(i);
};
C.prototype.rawValue = function(e) {
return e[1];
};
C.prototype.getConfigTags = function(e) {
return H(e) ? e : e && typeof e == "object" ? e.tags : void 0;
};
C.prototype.getConfigEscape = function(e) {
if (e && typeof e == "object" && !H(e))
return e.escape;
};
var q = {
name: "mustache.js",
version: "4.2.0",
tags: ["{{", "}}"],
clearCache: void 0,
escape: void 0,
parse: void 0,
render: void 0,
Scanner: void 0,
Context: void 0,
Writer: void 0,
/**
* Allows a user to override the default caching strategy, by providing an
* object with set, get and clear methods. This can also be used to disable
* the cache by setting it to the literal `undefined`.
*/
set templateCache(a) {
L.templateCache = a;
},
/**
* Gets the default or overridden caching object from the default writer.
*/
get templateCache() {
return L.templateCache;
}
}, L = new C();
q.clearCache = function() {
return L.clearCache();
};
q.parse = function(e, t) {
return L.parse(e, t);
};
q.render = function(e, t, n, r) {
if (typeof e != "string")
throw new TypeError('Invalid template! Template should be a "string" but "' + ye(e) + '" was given as the first argument for mustache#render(template, view, partials)');
return L.render(e, t, n, r);
};
q.escape = be;
q.Scanner = z;
q.Context = D;
q.Writer = C;
const je = {
"*": {
prefix: "每",
suffix: "",
text: "未知",
"*": {
any: { text: "每 {{field.id}}" },
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "每 {{step.value}}" }
},
month: {
"*": { prefix: "的" },
any: { text: "每月" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "的" },
any: { text: "每日" },
value: { text: "{{value.alt}}号" },
range: { text: "{{start.alt}}号-{{end.alt}}号" },
noSpecific: {
text: "无特定日期"
}
},
dayOfWeek: {
"*": { prefix: "的" },
any: { text: "一周的每一天" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
text: "无特定星期几"
}
},
hour: {
"*": { prefix: "的" },
any: { text: "每小时" }
},
minute: {
"*": { prefix: ":" },
any: { text: "每分钟" }
},
second: {
"*": { prefix: ":" },
any: { text: "每秒" }
}
},
minute: {
text: "分"
},
hour: {
text: "小时",
minute: {
"*": {
prefix: ":",
suffix: "分钟"
},
any: { text: "每" }
}
},
day: {
text: "天"
},
week: {
text: "周",
dayOfWeek: {
"*": { prefix: "的" },
any: { text: "每天" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
}
},
month: {
text: "月",
dayOfWeek: {
"*": { prefix: "和" }
},
day: {
"*": { prefix: "的" }
}
},
year: {
text: "年",
dayOfWeek: {
"*": { prefix: "和" }
}
},
//quartz format
"q-second": {
text: "秒"
},
"q-minute": {
text: "分钟",
second: {
"*": {
prefix: ":",
suffix: "秒"
},
any: { text: "每" }
}
},
"q-hour": {
text: "小时",
minute: {
"*": {
prefix: ":"
}
}
}
}, Ee = {
"*": {
prefix: "Hver",
suffix: "",
text: "Ukendt",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "hver {{step.value}}" }
},
month: {
"*": { prefix: "i" },
any: { text: "hver måned" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "og" },
any: { text: "hver dag i måneden" },
value: { text: "{{value.alt}}." },
range: { text: "{{start.alt}}.-{{end.alt}}." },
noSpecific: {
text: "ingen specifik dag"
}
},
dayOfWeek: {
"*": { prefix: "på" },
any: { text: "hver dag i ugen" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
text: "ingen specifik dag i ugen"
}
},
hour: {
"*": { prefix: "klokken" },
any: { text: "hver time" }
},
minute: {
"*": { prefix: ":" },
any: { text: "hvert minut" }
},
second: {
"*": { prefix: ":" },
any: { text: "hvert sekund" }
}
},
second: {
prefix: "Hvert"
},
minute: {
prefix: "Hvert",
text: "Minut"
},
hour: {
text: "Time",
minute: {
"*": {
prefix: "ved",
suffix: "minutter"
},
any: { text: "alle" }
}
},
day: {
text: "Dag"
},
week: {
text: "Uge"
},
month: {
text: "Måned",
dayOfWeek: {
"*": { prefix: "og" }
}
},
year: {
prefix: "Hvert",
text: "År",
dayOfWeek: {
"*": { prefix: "og" }
}
},
// quartz format
"q-second": {
text: "Sekund"
},
"q-minute": {
text: "Minut",
second: {
"*": {
suffix: "sekund(er)"
},
any: { text: "hvert" }
}
},
"q-hour": {
text: "Time",
minute: {
"*": {
prefix: "på"
}
}
}
}, Re = {
"*": {
prefix: "Jede",
suffix: "",
text: "Unknown",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "alle {{step.value}}" }
},
month: {
"*": { prefix: "im" },
any: {
prefix: "in",
text: "jedem Monat"
},
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "den" },
any: {
prefix: "an",
text: "jedem Tag"
},
step: {
prefix: "",
text: "alle {{step.value}} Tage"
},
noSpecific: {
prefix: "an",
text: "keinem bestimmten Tag"
}
},
dayOfWeek: {
"*": { prefix: "am" },
any: {
prefix: "an",
text: "jedem Wochentag"
},
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
prefix: "und",
text: "keinem bestimmten Wochentag"
}
},
hour: {
"*": { prefix: "um" },
any: {
prefix: "zu",
text: "jeder Stunde"
},
step: {
prefix: "",
text: "alle {{step.value}} Stunden"
}
},
minute: {
"*": { prefix: ":" },
any: { text: "jede Minute" },
step: {
prefix: "",
text: "alle {{step.value}} Minuten"
}
},
second: {
"*": { prefix: ":" },
any: { text: "jede Sekunde" },
step: {
prefix: "",
text: "alle {{step.value}} Sekunden"
}
}
},
minute: {
text: "Minute"
},
hour: {
text: "Stunde",
minute: {
"*": {
prefix: "zu",
suffix: "Minute(n)"
},
any: { text: "jeder" }
}
},
day: {
prefix: "Jeden",
text: "Tag"
},
week: {
text: "Woche"
},
month: {
prefix: "Jedes",
text: "Monat"
},
year: {
prefix: "Jedes",
text: "Jahr"
},
//quartz format
"q-second": {
text: "Sekunde"
},
"q-minute": {
text: "Minute",
second: {
"*": {
prefix: "und"
}
}
},
"q-hour": {
text: "Stunde",
minute: {
"*": {
prefix: "und"
}
},
second: {
"*": {
prefix: "und"
}
}
}
}, $e = {
"*": {
prefix: "Every",
suffix: "",
text: "Unknown",
"*": {
any: { text: "every {{field.id}}" },
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "every {{step.value}}" },
rangeStep: { text: "{{start.text}}-{{end.text}}/{{step.value}}" }
},
month: {
"*": { prefix: "in" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
rangeStep: { text: "{{start.alt}}-{{end.alt}}/{{step.value}}" }
},
day: {
"*": { prefix: "on" },
noSpecific: {
text: "no specific day"
}
},
dayOfWeek: {
"*": { prefix: "on" },
any: { text: "every day of the week" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
rangeStep: { text: "{{start.alt}}-{{end.alt}}/{{step.value}}" },
noSpecific: {
text: "no specific day of the week"
}
},
hour: {
"*": { prefix: "at" }
},
minute: {
"*": { prefix: ":" }
},
second: {
"*": { prefix: ":" }
}
},
minute: {
text: "Minute"
},
hour: {
text: "Hour",
minute: {
"*": {
prefix: "at",
suffix: "minute(s)"
},
any: { text: "every" }
}
},
day: {
text: "Day"
},
week: {
text: "Week"
},
month: {
text: "Month",
dayOfWeek: {
"*": { prefix: "and" }
}
},
year: {
text: "Year",
dayOfWeek: {
"*": { prefix: "and" }
}
},
//quartz format
"q-second": {
text: "Second"
},
"q-minute": {
text: "Minute",
second: {
"*": {
prefix: "at",
suffix: "second(s)"
},
any: { text: "every" }
}
},
"q-hour": {
text: "Hour",
minute: {
"*": {
prefix: "at"
}
}
}
}, Pe = {
"*": {
prefix: "todos los",
suffix: "",
text: "Desconocido",
"*": {
any: { text: "todos los {{ field.id }}" },
value: { text: "{{ value.text }}" },
range: { text: "{{ start.text }}-{{ end.text }}" },
step: { text: "todos/as {{ step.value }}" }
},
month: {
"*": { prefix: "en" },
any: { text: "todos los meses" },
value: { text: "{{ value.alt }}" },
range: { text: "{{ start.alt }}-{{ end.alt }}" }
},
day: {
"*": { prefix: "en" },
any: { text: "todos los días" },
value: { text: "los días {{ value.alt }}" }
},
dayOfWeek: {
"*": { prefix: "de" },
any: { text: "todos los días de la semana" },
value: { text: "los {{ value.alt }}" },
range: { text: "{{ start.alt }}-{{ end.alt }}" }
},
hour: {
"*": { prefix: "a" },
any: { text: "todas las horas" },
value: { text: "las {{ value.text }}" }
},
minute: {
"*": { prefix: ":" },
any: { text: "todos los minutos" }
}
},
minute: {
prefix: "todos los",
text: "minutos"
},
hour: {
prefix: "todas las",
text: "horas",
minute: {
"*": {
prefix: "a los",
suffix: "minutos"
},
any: { text: "todos", prefix: "a", suffix: "los minutos" }
}
},
day: {
text: "Días"
},
week: {
text: "Semanas"
},
month: {
text: "Meses",
dayOfWeek: {
"*": { prefix: "y" }
}
},
year: {
text: "años",
dayOfWeek: {
"*": { prefix: "y" }
}
}
}, Ue = {
"*": {
prefix: "Toutes",
suffix: "",
text: "Inconnu",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "tous les {{step.value}}" }
},
month: {
"*": { prefix: "en" },
any: { prefix: "en", text: "tous les mois" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "le" },
any: { prefix: "à", text: "tous les jours" },
step: { prefix: "", text: "tous les {{step.value}} jours" },
noSpecific: { prefix: "à", text: "aucun jour particulier" }
},
dayOfWeek: {
"*": { prefix: "le" },
any: { prefix: "à", text: "tous les jours de la semaine" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "et", text: "aucun jour de la semaine particulier" }
},
hour: {
"*": { prefix: "à" },
any: { prefix: "à", text: "toutes les heures" },
step: { prefix: "", text: "toutes les {{step.value}} heures" }
},
minute: {
"*": { prefix: ":" },
any: { text: "toutes les minutes" },
step: { prefix: "", text: "toutes les {{step.value}} minutes" }
},
second: {
"*": { prefix: ":" },
any: { text: "toutes les secondes" },
step: { prefix: "", text: "toutes les {{step.value}} secondes" }
}
},
minute: { text: "Minute" },
hour: {
text: "Heure",
minute: { "*": { prefix: "à", suffix: "minute(s)" }, any: { text: "toutes" } }
},
day: { prefix: "Tous", text: "Jour" },
week: { text: "Semaine" },
month: { prefix: "Tous", text: "Mois" },
year: { prefix: "Tous", text: "Année" },
//quartz format
"q-second": { text: "Seconde" },
"q-minute": { text: "Minute", second: { "*": { prefix: "et" } } },
"q-hour": { text: "Heure", minute: { "*": { prefix: "et" } }, second: { "*": { prefix: "et" } } }
}, De = {
"*": {
prefix: "בכל",
suffix: "",
text: "לא ידוע",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "כל {{step.value}}" }
},
month: {
"*": { prefix: "ב" },
any: { text: "כל חודש" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "ב" },
any: { text: "כל יום" },
value: { text: "יום {{value.alt}} לחודש" },
noSpecific: {
text: "ללא יום מוגדר"
}
},
dayOfWeek: {
"*": { prefix: "ב" },
any: { text: "כל יום מימות השבוע" },
value: { text: "ימי {{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
text: "ללא יום בשבוע מוגדר"
}
},
hour: {
"*": { prefix: "ב" },
any: { text: "כל שעה" },
value: { text: "שעה {{value.text}}" }
},
minute: {
"*": { prefix: ":" },
any: { text: "כל דקה" }
},
second: {
"*": { prefix: ":" },
any: { text: "כל שניה" }
}
},
minute: {
text: "דקה"
},
hour: {
text: "שעה",
minute: {
"*": {
prefix: "ב",
suffix: "דקות"
},
any: { text: "כל" }
}
},
day: {
text: "יום"
},
week: {
text: "שבוע"
},
month: {
text: "חודש",
dayOfWeek: {
"*": { prefix: "ו" }
}
},
year: {
text: "שנה",
dayOfWeek: {
"*": { prefix: "ו" }
}
},
//quartz format
"q-second": {
text: "שניה"
},
"q-minute": {
text: "דקה",
second: {
"*": {
prefix: "ב",
suffix: "שניות"
},
any: { text: "כל" }
}
},
"q-hour": {
text: "שעה",
minute: {
"*": {
prefix: "ב"
}
}
}
}, He = {
"*": {
prefix: "हर",
suffix: "",
text: "अज्ञात",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "{{step.value}} हर" }
},
month: {
"*": { prefix: "में" },
any: { prefix: "के", text: "हर महीने" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "के" },
any: { prefix: "पर", text: "हर दिन" },
step: { prefix: "", text: "{{step.value}} दिन हर" },
noSpecific: { prefix: "पर", text: "कोई विशेष दिन नहीं" }
},
dayOfWeek: {
"*": { prefix: "पर" },
any: { prefix: "पर", text: "हर सप्ताह" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "और", text: "कोई विशेष सप्ताह नहीं" }
},
hour: {
"*": { prefix: "को" },
any: { prefix: "पर", text: "हर घंटे" },
step: { prefix: "", text: "{{step.value}} घंटे हर" }
},
minute: {
"*": { prefix: ":" },
any: { text: "हर मिनट" },
step: { prefix: "", text: "{{step.value}} मिनट हर" }
},
second: {
"*": { prefix: ":" },
any: { text: "हर सेकंड" },
step: { prefix: "", text: "{{step.value}} सेकंड हर" }
}
},
minute: { text: "मिनट" },
hour: { text: "घंटा", minute: { "*": { prefix: "पर", suffix: "मिनट" }, any: { text: "हर" } } },
day: { prefix: "हर", text: "दिन" },
week: { text: "सप्ताह" },
month: { prefix: "हर", text: "महीना" },
year: { prefix: "हर", text: "साल" },
//quartz format
"q-second": { text: "सेकंड" },
"q-minute": { text: "मिनट", second: { "*": { prefix: "और" } } },
"q-hour": { text: "घंटा", minute: { "*": { prefix: "और" } }, second: { "*": { prefix: "और" } } }
}, Ne = {
"*": {
prefix: "毎",
suffix: "",
text: "不明",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "{{step.value}}ごとに" }
},
month: {
"*": { prefix: "に" },
any: { prefix: "の", text: "毎月" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "の" },
any: { prefix: "に", text: "毎日" },
step: { prefix: "", text: "{{step.value}}日ごとに" },
noSpecific: { prefix: "に", text: "特定の日はなし" }
},
dayOfWeek: {
"*": { prefix: "の" },
any: { prefix: "に", text: "毎週" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "と", text: "特定の曜日はなし" }
},
hour: {
"*": { prefix: "の" },
any: { prefix: "に", text: "毎時" },
step: { prefix: "", text: "{{step.value}}時間ごとに" }
},
minute: {
"*": { prefix: ":" },
any: { text: "毎分" },
step: { prefix: "", text: "{{step.value}}分ごとに" }
},
second: {
"*": { prefix: ":" },
any: { text: "毎秒" },
step: { prefix: "", text: "{{step.value}}秒ごとに" }
}
},
minute: { text: "分" },
hour: { text: "時", minute: { "*": { prefix: "に", suffix: "分" }, any: { text: "毎" } } },
day: { prefix: "毎", text: "日" },
week: { text: "週" },
month: { prefix: "毎", text: "月" },
year: { prefix: "毎", text: "年" },
//quartz format
"q-second": { text: "秒" },
"q-minute": { text: "分", second: { "*": { prefix: "と" } } },
"q-hour": { text: "時", minute: { "*": { prefix: "と" } }, second: { "*": { prefix: "と" } } }
}, Fe = {
"*": {
prefix: "매",
suffix: "",
text: "알 수 없음",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "{{step.value}}마다" }
},
month: {
"*": { prefix: "에" },
any: { prefix: "의", text: "매월" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "의" },
any: { prefix: "에", text: "매일" },
step: { prefix: "", text: "{{step.value}}일마다" },
noSpecific: { prefix: "에", text: "특정한 날 없음" }
},
dayOfWeek: {
"*": { prefix: "의" },
any: { prefix: "에", text: "매주" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "과", text: "특정한 요일 없음" }
},
hour: {
"*": { prefix: "의" },
any: { prefix: "에", text: "매시" },
step: { prefix: "", text: "{{step.value}}시간마다" }
},
minute: {
"*": { prefix: ":" },
any: { text: "매분" },
step: { prefix: "", text: "{{step.value}}분마다" }
},
second: {
"*": { prefix: ":" },
any: { text: "매초" },
step: { prefix: "", text: "{{step.value}}초마다" }
}
},
minute: { text: "분" },
hour: { text: "시", minute: { "*": { prefix: "에", suffix: "분" }, any: { text: "매" } } },
day: { prefix: "매", text: "일" },
week: { text: "주" },
month: { prefix: "매", text: "월" },
year: { prefix: "매", text: "년" },
//quartz format
"q-second": { text: "초" },
"q-minute": { text: "분", second: { "*": { prefix: "와" } } },
"q-hour": { text: "시", minute: { "*": { prefix: "와" } }, second: { "*": { prefix: "와" } } }
}, Le = {
"*": {
prefix: "Todo(a)",
suffix: "",
text: "Desconhecido",
"*": {
any: { text: "todo {{field.id}}" },
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "todo {{step.value}}" }
},
month: {
"*": { prefix: "de" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
any: { text: "todo mês" }
},
day: {
"*": { prefix: "no(s) dia(s)" },
any: { text: "todos" }
},
dayOfWeek: {
"*": { prefix: "de" },
any: { text: "todos dias da semana" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
hour: {
"*": { prefix: "às" },
any: { text: "cada hora" }
},
minute: {
"*": { prefix: ":" },
any: { text: "cada minuto" }
}
},
minute: {
text: "Minuto"
},
hour: {
text: "Hora",
minute: {
"*": {
prefix: "e",
suffix: "minuto(s)"
},
any: { text: "cada" }
}
},
day: {
text: "Dia"
},
week: {
text: "Semana"
},
month: {
text: "Mês",
dayOfWeek: {
"*": { prefix: "e de" }
}
},
year: {
text: "Ano",
dayOfWeek: {
"*": { prefix: "e de" }
}
}
}, ze = {
"*": {
prefix: "Каждый",
suffix: "",
text: "Неизвестно",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "каждый {{step.value}}" }
},
month: {
"*": { prefix: "в" },
any: { prefix: "в", text: "каждом месяце" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "в" },
any: { prefix: "в", text: "каждый день" },
step: { prefix: "", text: "каждые {{step.value}} дня" },
noSpecific: { prefix: "в", text: "нет определенного дня" }
},
dayOfWeek: {
"*": { prefix: "по" },
any: { prefix: "по", text: "каждому дню недели" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "и", text: "нет определенного дня недели" }
},
hour: {
"*": { prefix: "в" },
any: { prefix: "в", text: "каждый час" },
step: { prefix: "", text: "каждые {{step.value}} часа" }
},
minute: {
"*": { prefix: ":" },
any: { text: "каждую минуту" },
step: { prefix: "", text: "каждые {{step.value}} минуты" }
},
second: {
"*": { prefix: ":" },
any: { text: "каждую секунду" },
step: { prefix: "", text: "каждые {{step.value}} секунды" }
}
},
minute: { text: "Минута" },
hour: {
text: "Час",
minute: { "*": { prefix: "в", suffix: "минут(а/ы)" }, any: { text: "каждый" } }
},
day: { prefix: "Каждый", text: "День" },
week: { text: "Неделя" },
month: { prefix: "Каждый", text: "Месяц" },
year: { prefix: "Каждый", text: "Год" },
//quartz format
"q-second": { text: "Секунда" },
"q-minute": { text: "Минута", second: { "*": { prefix: "и" } } },
"q-hour": { text: "Час", minute: { "*": { prefix: "и" } }, second: { "*": { prefix: "и" } } }
}, J = {
empty: {},
en: $e,
de: Re,
pt: Le,
es: Pe,
da: Ee,
zh: je,
he: De,
ru: ze,
fr: Ue,
hi: He,
ja: Ne,
ko: Fe
};
class Be {
constructor(e) {
d(this, "dict");
this.dict = e;
}
/**
* Gets a localization template by traversing the dictionary using provided keys.
* @param keys - Array of keys to traverse through the localization dictionary
* @returns The found template string or empty string if not found
*/
getTemplate(...e) {
const t = e.map((n) => [n, "*"]);
return ae(this.dict, ...t) || "";
}
/**
* Renders a localization template with the provided parameters using Mustache.
* @param periodId - The period identifier (e.g. 'year', 'month')
* @param fieldId - The field identifier (e.g. 'hour', 'minute')
* @param fieldPattern - The pattern type of the field
* @param position - The text position
* @param params - Parameters to be interpolated into the template
* @returns The rendered localization string
*/
render(e, t, n, r, i) {
const s = this.getTemplate(e, t, n, r);
return q.render(s, i || {});
}
}
function Je(a, e) {
const [t] = a.split("-"), n = J[a.toLowerCase()] || J[t.toLowerCase()] || J.en, r = G({}, J.en, n, e || {});
return new Be(r);
}
function Qe(a) {
const { period: e, field: t, initialCron: n = "*", l10n: r } = a, i = k(n), s = k(""), u = k([]), o = k(""), x = k(""), h = k(""), p = (l) => {
const m = l instanceof F ? l.segments : [l];
o.value = m.map((f) => r.render(e.value.id, t.id, f.type, j.Text, {
field: t,
...f.items
})).join(","), x.value = r.getTemplate(e.value.id, t.id, l.type, j.Prefix), h.value = r.getTemplate(e.value.id, t.id, l.type, j.Suffix);
}, y = (l) => {
const m = _(l, t);
m != null ? (u.value = m.toArray(), p(m)) : s.value = `${l} is not a valid cron segment (${t.id})`;
}, W = (l) => {
if (i.value == "?" && l.length == 0)
return;
const m = me(l, t);
m != null ? (i.value = m.toCron(), p(m)) : s.value = `failed to convert ${l} to cron (${t.id})`;
};
y(n);
const A = (l) => {
const m = Array.from(l).sort((f, v) => f > v ? 1 : -1);
u.value = m;
};
return g(i, (l) => {
y(l);
}), g(u, (l) => {
W(l);
}), g(e, () => {
const l = _(i.value, t);
l != null && p(l);
}), {
id: t.id,
items: t.items,
cron: i,
selected: u,
error: s,
select: A,
text: o,
prefix: x,
suffix: h
};
}
function ie(a, e = "*") {
return new Array(a).fill(e).join(" ");
}
function Ke(a) {
return a !== void 0;
}
class Ye {
constructor() {
d(this, "locale", "en");
d(this, "format", "crontab");
}
initialValue(e, t = "*") {
return ie(e, t);
}
fields(e, t) {
const n = e == "quartz" || e == "spring", r = pe(t, e), i = (s) => (u, { segmentMap: o }) => {
if (u.cron.value == "?")
return;
const x = o.get(s);
x && (x.cron.value = "?");
};
return [
...n ? [{ id: "second", items: r.secondItems }] : [],
{ id: "minute", items: r.minuteItems },
{ id: "hour", items: r.hourItems },
{
id: "day",
items: r.dayItems,
onChange: n ? i("dayOfWeek") : void 0,
segmentFactories: n ? [
M.fromString,
Q.fromString,
P.fromString,
$.fromString,
U.fromString
] : void 0
},
{ id: "month", items: r.monthItems },
{
id: "dayOfWeek",
items: r.dayOfWeekItems,
onChange: n ? i("day") : void 0,
segmentFactories: n ? [
M.fromString,
Q.fromString,
P.fromString,
$.fromString,
U.fromString
] : void 0
}
];
}
periods(e) {
const t = e == "quartz" || e == "spring", n = t ? [{ id: "q-second", value: [] }] : [], r = t ? ["second"] : [], i = t ? "q-" : "";
return [
...n,
{ id: i + "minute", value: [...r] },
{ id: i + "hour", value: ["minute", ...r] },
{ id: "day", value: ["hour", "minute", ...r] },
{ id: "week", value: ["dayOfWeek", "hour", "minute", ...r] },
{ id: "month", value: ["day", "dayOfWeek", "hour", "minute", ...r] },
{ id: "year", value: ["month", "day", "dayOfWeek", "hour", "minute", ...r] }
];
}
}
function Ge(a, e, t) {
const n = e.split(" ");
if (n.length !== t.length)
return;
const r = t.filter((i, s) => !["*", "?"].includes(n[s])).map((i) => i.id);
return a.find((i) => {
const s = new Set(i.value);
return r.every((u) => s.has(u));
});
}
function Xe(a) {
const e = new Ye(), t = a.locale ?? e.locale, n = a.format ?? e.format, { customLocale: r, fields: i = e.fields(n, t) } = a, s = a.initialValue ?? e.initialValue(i.length), u = Je(t, r), o = (a.periods ?? e.periods(n)).map((c) => ({
...c,
text: c.text ?? u.getTemplate(c.id, j.Text)
})), x = (a.initialPeriod ? o.find((c) => c.id == a.initialPeriod) : void 0) ?? Ge([...o].reverse(), s, i) ?? o[o.length - 1], h = k(s), p = k(""), y = k(x), W = k(""), A = k(""), l = i.map((c) => Qe({ field: new le(c), l10n: u, period: y })), m = new Map(l.map((c) => [c.id, c])), f = re(() => y.value.value.map((c) => {
const S = m.get(c);
if (Ke(S))
return S;
throw Error("${fieldId} not found");
})), v = (c) => {
if (!c) {
h.value = ie(i.length);
return;
}
const S = c.split(" ");
if (S.length !== i.length) {
p.value = "invalid pattern";
return;
}
for (let w = 0; w < S.length; w++)
l[w].cron.value != S[w] && (l[w].cron.value = S[w]);
p.value = "";
};
v(s);
const O = () => {
h.value = l.map((c) => y.value.value.includes(c.id) || c.cron.value == "?" ? c.cron.value : "*").join(" ");
}, I = () => {
W.value = u.getTemplate(y.value.id, j.Prefix), A.value = u.getTemplate(y.value.id, j.Suffix);
};
return I(), g(h, v), g(y, () => {
O(), I();
}), l.forEach((c, S) => {
g(c.cron, () => {
var w, b;
(b = (w = i[S]).onChange) == null || b.call(w, c, { segmentMap: m }), O();
}), g(c.error, (w) => {
p.value = w;
});
}), {
cron: h,
error: p,
segments: l,
selected: f,
period: {
select: (c) => {
const S = o.map((w) => w.id).indexOf(c);
S != -1 && (y.value = o[S]);
},
selected: y,
items: o,
prefix: W,
suffix: A
}
};
}
function Ze(a, { emit: e }) {
const t = {
...a,
initialValue: a.modelValue,
initialPeriod: a.period
}, n = Xe(t);
return g(
() => a.modelValue,
(r) => {
r && (n.cron.value = r);
}
), g(
() => a.period,
(r) => {
r && n.period.select(r);
}
), g(n.cron, (r) => {
e("update:model-value", r);
}), g(n.period.selected, (r) => {
e("update:period", r.id);
}), g(n.error, (r) => {
e("error", r);
}), n;
}
const _e = () => ({
/**
* The value of the cron expression
*
* @defaultValue crontab: `* * * * *`, quartz: `* * * * * *`
*/
modelValue: {
type: String
},
/**
* The id of a period to select
*
* @defaultValue last entry of `CronCoreProps.periods`
*/
period: {
type: String
},
/**
* The format of the cron expression, either crontab or quartz
*
* @defaultValue `crontab`
*/
format: {
type: String
},
/**
* The locale of the component, such as `en`, `de`, etc.
*
* @defaultValue `en`
*/
locale: {
type: String
},
/** The segments of the cron expression, such as second, minute, hour, etc. */
fields: {
type: Array
},
/** The periods to select, e.g. Every month, day, etc. */
periods: {
type: Array
},
/** The custom locale object, used to override values of the current {@link Localization} */
customLocale: {
type: Object
},
/** Number of columns in the dropdown,
* e.g. the possible values of minute (0-59) will be displayed in a grid with 5 columns
*
* @defaultValue
* ```
* {
* second: 5,
* minute: 5,
* hour: 4,
* day: 4,
* }
* ```
*/
cols: {
type: Object,
default: () => ({
second: 5,
minute: 5,
hour: 4,
day: 4
})
},
/** Disable the cron editor */
disabled: {
type: Boolean,
default: !1
}
}), et = ne({
name: "VueCronCore",
props: _e(),
emits: ["update:model-value", "update:period", "error"],
setup(a, e) {
const { error: t, selected: n, period: r } = Ze(a, e);
return () => {
var s, u;
const i = {
error: t,
fields: n.value.map((o) => ({
id: o.id,
items: o.items,
cron: o.cron.value,
selectedStr: o.text.value,
events: {
"update:model-value": o.select
},
attrs: {
modelValue: o.selected.value
},
prefix: o.prefix.value,
suffix: o.suffix.value
})),
period: {
attrs: {
modelValue: r.selected.value.id
},
events: {
"update:model-value": r.select
},
items: r.items,
prefix: r.prefix.value,
suffix: r.suffix.value
}
};
return (u = (s = e.slots).default) == null ? void 0 : u.call(s, i);
};
}
});
function tt(a) {
const { items: e } = a, t = /* @__PURE__ */ new Set(), n = k(0), r = () => {
n.value = n.value + 1;
}, i = (p) => {
e.indexOf(p) != -1 && (t.add(p), r());
}, s = (p) => t.has(p), u = (p) => {
t.delete(p) && r();
};
return {
values: t,
add: i,
toggle: (p) => {
s(p) ? u(p) : i(p);
},
remove: u,
clear: () => {
t.clear(), r();
},
updated: n,
equals: (p) => {
if (p.length != t.size)
return !1;
for (const y of p)
if (!t.has(y))
return !1;
return !0;
}
};
}
function nt() {
return {
modelValu