@oslokommune/punkt-elements
Version:
Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo
1,696 lines (1,695 loc) • 57.4 kB
JavaScript
import { e as ht } from "./class-map-BpTj9gtz.js";
import { P as dt, E as I, x as k, n as m, a as ft } from "./element-CgEWt74-.js";
import { r as H } from "./state-Bo2bck5_.js";
import "./icon-CC1js8eR.js";
const at = 6048e5, mt = 864e5, V = Symbol.for("constructDateFrom");
function M(t, e) {
return typeof t == "function" ? t(e) : t && typeof t == "object" && V in t ? t[V](e) : t instanceof Date ? new t.constructor(e) : new Date(e);
}
function D(t, e) {
return M(e || t, t);
}
function B(t, e, n) {
const r = D(t, n == null ? void 0 : n.in);
return isNaN(e) ? M(t, NaN) : (e && r.setDate(r.getDate() + e), r);
}
let gt = {};
function L() {
return gt;
}
function _(t, e) {
var c, o, d, g;
const n = L(), r = (e == null ? void 0 : e.weekStartsOn) ?? ((o = (c = e == null ? void 0 : e.locale) == null ? void 0 : c.options) == null ? void 0 : o.weekStartsOn) ?? n.weekStartsOn ?? ((g = (d = n.locale) == null ? void 0 : d.options) == null ? void 0 : g.weekStartsOn) ?? 0, a = D(t, e == null ? void 0 : e.in), s = a.getDay(), i = (s < r ? 7 : 0) + s - r;
return a.setDate(a.getDate() - i), a.setHours(0, 0, 0, 0), a;
}
function q(t, e) {
return _(t, { ...e, weekStartsOn: 1 });
}
function st(t, e) {
const n = D(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = M(n, 0);
a.setFullYear(r + 1, 0, 4), a.setHours(0, 0, 0, 0);
const s = q(a), i = M(n, 0);
i.setFullYear(r, 0, 4), i.setHours(0, 0, 0, 0);
const c = q(i);
return n.getTime() >= s.getTime() ? r + 1 : n.getTime() >= c.getTime() ? r : r - 1;
}
function J(t) {
const e = D(t), n = new Date(
Date.UTC(
e.getFullYear(),
e.getMonth(),
e.getDate(),
e.getHours(),
e.getMinutes(),
e.getSeconds(),
e.getMilliseconds()
)
);
return n.setUTCFullYear(e.getFullYear()), +t - +n;
}
function it(t, ...e) {
const n = M.bind(
null,
e.find((r) => typeof r == "object")
);
return e.map(n);
}
function G(t, e) {
const n = D(t, e == null ? void 0 : e.in);
return n.setHours(0, 0, 0, 0), n;
}
function yt(t, e, n) {
const [r, a] = it(
n == null ? void 0 : n.in,
t,
e
), s = G(r), i = G(a), c = +s - J(s), o = +i - J(i);
return Math.round((c - o) / mt);
}
function pt(t, e) {
const n = st(t, e), r = M(t, 0);
return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), q(r);
}
function wt(t) {
return t instanceof Date || typeof t == "object" && Object.prototype.toString.call(t) === "[object Date]";
}
function bt(t) {
return !(!wt(t) && typeof t != "number" || isNaN(+D(t)));
}
function Dt(t, e) {
const n = D(t, e == null ? void 0 : e.in);
return n.setHours(23, 59, 59, 999), n;
}
function kt(t, e) {
const [n, r] = it(t, e.start, e.end);
return { start: n, end: r };
}
function z(t, e) {
const { start: n, end: r } = kt(e == null ? void 0 : e.in, t);
let a = +n > +r;
const s = a ? +n : +r, i = a ? r : n;
i.setHours(0, 0, 0, 0);
let c = 1;
const o = [];
for (; +i <= s; )
o.push(M(n, i)), i.setDate(i.getDate() + c), i.setHours(0, 0, 0, 0);
return a ? o.reverse() : o;
}
function vt(t, e) {
const n = D(t, e == null ? void 0 : e.in);
return n.setFullYear(n.getFullYear(), 0, 1), n.setHours(0, 0, 0, 0), n;
}
const St = {
lessThanXSeconds: {
one: "less than a second",
other: "less than {{count}} seconds"
},
xSeconds: {
one: "1 second",
other: "{{count}} seconds"
},
halfAMinute: "half a minute",
lessThanXMinutes: {
one: "less than a minute",
other: "less than {{count}} minutes"
},
xMinutes: {
one: "1 minute",
other: "{{count}} minutes"
},
aboutXHours: {
one: "about 1 hour",
other: "about {{count}} hours"
},
xHours: {
one: "1 hour",
other: "{{count}} hours"
},
xDays: {
one: "1 day",
other: "{{count}} days"
},
aboutXWeeks: {
one: "about 1 week",
other: "about {{count}} weeks"
},
xWeeks: {
one: "1 week",
other: "{{count}} weeks"
},
aboutXMonths: {
one: "about 1 month",
other: "about {{count}} months"
},
xMonths: {
one: "1 month",
other: "{{count}} months"
},
aboutXYears: {
one: "about 1 year",
other: "about {{count}} years"
},
xYears: {
one: "1 year",
other: "{{count}} years"
},
overXYears: {
one: "over 1 year",
other: "over {{count}} years"
},
almostXYears: {
one: "almost 1 year",
other: "almost {{count}} years"
}
}, Mt = (t, e, n) => {
let r;
const a = St[t];
return typeof a == "string" ? r = a : e === 1 ? r = a.one : r = a.other.replace("{{count}}", e.toString()), n != null && n.addSuffix ? n.comparison && n.comparison > 0 ? "in " + r : r + " ago" : r;
};
function Q(t) {
return (e = {}) => {
const n = e.width ? String(e.width) : t.defaultWidth;
return t.formats[n] || t.formats[t.defaultWidth];
};
}
const Tt = {
full: "EEEE, MMMM do, y",
long: "MMMM do, y",
medium: "MMM d, y",
short: "MM/dd/yyyy"
}, xt = {
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
}, Ot = {
full: "{{date}} 'at' {{time}}",
long: "{{date}} 'at' {{time}}",
medium: "{{date}}, {{time}}",
short: "{{date}}, {{time}}"
}, Pt = {
date: Q({
formats: Tt,
defaultWidth: "full"
}),
time: Q({
formats: xt,
defaultWidth: "full"
}),
dateTime: Q({
formats: Ot,
defaultWidth: "full"
})
}, Nt = {
lastWeek: "'last' eeee 'at' p",
yesterday: "'yesterday at' p",
today: "'today at' p",
tomorrow: "'tomorrow at' p",
nextWeek: "eeee 'at' p",
other: "P"
}, $t = (t, e, n, r) => Nt[t];
function W(t) {
return (e, n) => {
const r = n != null && n.context ? String(n.context) : "standalone";
let a;
if (r === "formatting" && t.formattingValues) {
const i = t.defaultFormattingWidth || t.defaultWidth, c = n != null && n.width ? String(n.width) : i;
a = t.formattingValues[c] || t.formattingValues[i];
} else {
const i = t.defaultWidth, c = n != null && n.width ? String(n.width) : t.defaultWidth;
a = t.values[c] || t.values[i];
}
const s = t.argumentCallback ? t.argumentCallback(e) : e;
return a[s];
};
}
const Ct = {
narrow: ["B", "A"],
abbreviated: ["BC", "AD"],
wide: ["Before Christ", "Anno Domini"]
}, Et = {
narrow: ["1", "2", "3", "4"],
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
}, Wt = {
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
abbreviated: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
wide: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
}, Yt = {
narrow: ["S", "M", "T", "W", "T", "F", "S"],
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
wide: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
}, Ft = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}
}, At = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
}
}, _t = (t, e) => {
const n = Number(t), r = n % 100;
if (r > 20 || r < 10)
switch (r % 10) {
case 1:
return n + "st";
case 2:
return n + "nd";
case 3:
return n + "rd";
}
return n + "th";
}, Ht = {
ordinalNumber: _t,
era: W({
values: Ct,
defaultWidth: "wide"
}),
quarter: W({
values: Et,
defaultWidth: "wide",
argumentCallback: (t) => t - 1
}),
month: W({
values: Wt,
defaultWidth: "wide"
}),
day: W({
values: Yt,
defaultWidth: "wide"
}),
dayPeriod: W({
values: Ft,
defaultWidth: "wide",
formattingValues: At,
defaultFormattingWidth: "wide"
})
};
function Y(t) {
return (e, n = {}) => {
const r = n.width, a = r && t.matchPatterns[r] || t.matchPatterns[t.defaultMatchWidth], s = e.match(a);
if (!s)
return null;
const i = s[0], c = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], o = Array.isArray(c) ? qt(c, (y) => y.test(i)) : (
// [TODO] -- I challenge you to fix the type
It(c, (y) => y.test(i))
);
let d;
d = t.valueCallback ? t.valueCallback(o) : o, d = n.valueCallback ? (
// [TODO] -- I challenge you to fix the type
n.valueCallback(d)
) : d;
const g = e.slice(i.length);
return { value: d, rest: g };
};
}
function It(t, e) {
for (const n in t)
if (Object.prototype.hasOwnProperty.call(t, n) && e(t[n]))
return n;
}
function qt(t, e) {
for (let n = 0; n < t.length; n++)
if (e(t[n]))
return n;
}
function Lt(t) {
return (e, n = {}) => {
const r = e.match(t.matchPattern);
if (!r) return null;
const a = r[0], s = e.match(t.parsePattern);
if (!s) return null;
let i = t.valueCallback ? t.valueCallback(s[0]) : s[0];
i = n.valueCallback ? n.valueCallback(i) : i;
const c = e.slice(a.length);
return { value: i, rest: c };
};
}
const Rt = /^(\d+)(th|st|nd|rd)?/i, Ut = /\d+/i, Bt = {
narrow: /^(b|a)/i,
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
wide: /^(before christ|before common era|anno domini|common era)/i
}, zt = {
any: [/^b/i, /^(a|c)/i]
}, Qt = {
narrow: /^[1234]/i,
abbreviated: /^q[1234]/i,
wide: /^[1234](th|st|nd|rd)? quarter/i
}, jt = {
any: [/1/i, /2/i, /3/i, /4/i]
}, Gt = {
narrow: /^[jfmasond]/i,
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
}, Xt = {
narrow: [
/^j/i,
/^f/i,
/^m/i,
/^a/i,
/^m/i,
/^j/i,
/^j/i,
/^a/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
],
any: [
/^ja/i,
/^f/i,
/^mar/i,
/^ap/i,
/^may/i,
/^jun/i,
/^jul/i,
/^au/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
]
}, Vt = {
narrow: /^[smtwf]/i,
short: /^(su|mo|tu|we|th|fr|sa)/i,
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
}, Jt = {
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
}, Kt = {
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
}, Zt = {
any: {
am: /^a/i,
pm: /^p/i,
midnight: /^mi/i,
noon: /^no/i,
morning: /morning/i,
afternoon: /afternoon/i,
evening: /evening/i,
night: /night/i
}
}, te = {
ordinalNumber: Lt({
matchPattern: Rt,
parsePattern: Ut,
valueCallback: (t) => parseInt(t, 10)
}),
era: Y({
matchPatterns: Bt,
defaultMatchWidth: "wide",
parsePatterns: zt,
defaultParseWidth: "any"
}),
quarter: Y({
matchPatterns: Qt,
defaultMatchWidth: "wide",
parsePatterns: jt,
defaultParseWidth: "any",
valueCallback: (t) => t + 1
}),
month: Y({
matchPatterns: Gt,
defaultMatchWidth: "wide",
parsePatterns: Xt,
defaultParseWidth: "any"
}),
day: Y({
matchPatterns: Vt,
defaultMatchWidth: "wide",
parsePatterns: Jt,
defaultParseWidth: "any"
}),
dayPeriod: Y({
matchPatterns: Kt,
defaultMatchWidth: "any",
parsePatterns: Zt,
defaultParseWidth: "any"
})
}, ee = {
code: "en-US",
formatDistance: Mt,
formatLong: Pt,
formatRelative: $t,
localize: Ht,
match: te,
options: {
weekStartsOn: 0,
firstWeekContainsDate: 1
}
};
function ne(t, e) {
const n = D(t, e == null ? void 0 : e.in);
return yt(n, vt(n)) + 1;
}
function re(t, e) {
const n = D(t, e == null ? void 0 : e.in), r = +q(n) - +pt(n);
return Math.round(r / at) + 1;
}
function ot(t, e) {
var g, y, f, T;
const n = D(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = L(), s = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((y = (g = e == null ? void 0 : e.locale) == null ? void 0 : g.options) == null ? void 0 : y.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((T = (f = a.locale) == null ? void 0 : f.options) == null ? void 0 : T.firstWeekContainsDate) ?? 1, i = M((e == null ? void 0 : e.in) || t, 0);
i.setFullYear(r + 1, 0, s), i.setHours(0, 0, 0, 0);
const c = _(i, e), o = M((e == null ? void 0 : e.in) || t, 0);
o.setFullYear(r, 0, s), o.setHours(0, 0, 0, 0);
const d = _(o, e);
return +n >= +c ? r + 1 : +n >= +d ? r : r - 1;
}
function ae(t, e) {
var c, o, d, g;
const n = L(), r = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((o = (c = e == null ? void 0 : e.locale) == null ? void 0 : c.options) == null ? void 0 : o.firstWeekContainsDate) ?? n.firstWeekContainsDate ?? ((g = (d = n.locale) == null ? void 0 : d.options) == null ? void 0 : g.firstWeekContainsDate) ?? 1, a = ot(t, e), s = M((e == null ? void 0 : e.in) || t, 0);
return s.setFullYear(a, 0, r), s.setHours(0, 0, 0, 0), _(s, e);
}
function ct(t, e) {
const n = D(t, e == null ? void 0 : e.in), r = +_(n, e) - +ae(n, e);
return Math.round(r / at) + 1;
}
function u(t, e) {
const n = t < 0 ? "-" : "", r = Math.abs(t).toString().padStart(e, "0");
return n + r;
}
const x = {
// Year
y(t, e) {
const n = t.getFullYear(), r = n > 0 ? n : 1 - n;
return u(e === "yy" ? r % 100 : r, e.length);
},
// Month
M(t, e) {
const n = t.getMonth();
return e === "M" ? String(n + 1) : u(n + 1, 2);
},
// Day of the month
d(t, e) {
return u(t.getDate(), e.length);
},
// AM or PM
a(t, e) {
const n = t.getHours() / 12 >= 1 ? "pm" : "am";
switch (e) {
case "a":
case "aa":
return n.toUpperCase();
case "aaa":
return n;
case "aaaaa":
return n[0];
case "aaaa":
default:
return n === "am" ? "a.m." : "p.m.";
}
},
// Hour [1-12]
h(t, e) {
return u(t.getHours() % 12 || 12, e.length);
},
// Hour [0-23]
H(t, e) {
return u(t.getHours(), e.length);
},
// Minute
m(t, e) {
return u(t.getMinutes(), e.length);
},
// Second
s(t, e) {
return u(t.getSeconds(), e.length);
},
// Fraction of second
S(t, e) {
const n = e.length, r = t.getMilliseconds(), a = Math.trunc(
r * Math.pow(10, n - 3)
);
return u(a, e.length);
}
}, C = {
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}, K = {
// Era
G: function(t, e, n) {
const r = t.getFullYear() > 0 ? 1 : 0;
switch (e) {
case "G":
case "GG":
case "GGG":
return n.era(r, { width: "abbreviated" });
case "GGGGG":
return n.era(r, { width: "narrow" });
case "GGGG":
default:
return n.era(r, { width: "wide" });
}
},
// Year
y: function(t, e, n) {
if (e === "yo") {
const r = t.getFullYear(), a = r > 0 ? r : 1 - r;
return n.ordinalNumber(a, { unit: "year" });
}
return x.y(t, e);
},
// Local week-numbering year
Y: function(t, e, n, r) {
const a = ot(t, r), s = a > 0 ? a : 1 - a;
if (e === "YY") {
const i = s % 100;
return u(i, 2);
}
return e === "Yo" ? n.ordinalNumber(s, { unit: "year" }) : u(s, e.length);
},
// ISO week-numbering year
R: function(t, e) {
const n = st(t);
return u(n, e.length);
},
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: function(t, e) {
const n = t.getFullYear();
return u(n, e.length);
},
// Quarter
Q: function(t, e, n) {
const r = Math.ceil((t.getMonth() + 1) / 3);
switch (e) {
case "Q":
return String(r);
case "QQ":
return u(r, 2);
case "Qo":
return n.ordinalNumber(r, { unit: "quarter" });
case "QQQ":
return n.quarter(r, {
width: "abbreviated",
context: "formatting"
});
case "QQQQQ":
return n.quarter(r, {
width: "narrow",
context: "formatting"
});
case "QQQQ":
default:
return n.quarter(r, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone quarter
q: function(t, e, n) {
const r = Math.ceil((t.getMonth() + 1) / 3);
switch (e) {
case "q":
return String(r);
case "qq":
return u(r, 2);
case "qo":
return n.ordinalNumber(r, { unit: "quarter" });
case "qqq":
return n.quarter(r, {
width: "abbreviated",
context: "standalone"
});
case "qqqqq":
return n.quarter(r, {
width: "narrow",
context: "standalone"
});
case "qqqq":
default:
return n.quarter(r, {
width: "wide",
context: "standalone"
});
}
},
// Month
M: function(t, e, n) {
const r = t.getMonth();
switch (e) {
case "M":
case "MM":
return x.M(t, e);
case "Mo":
return n.ordinalNumber(r + 1, { unit: "month" });
case "MMM":
return n.month(r, {
width: "abbreviated",
context: "formatting"
});
case "MMMMM":
return n.month(r, {
width: "narrow",
context: "formatting"
});
case "MMMM":
default:
return n.month(r, { width: "wide", context: "formatting" });
}
},
// Stand-alone month
L: function(t, e, n) {
const r = t.getMonth();
switch (e) {
case "L":
return String(r + 1);
case "LL":
return u(r + 1, 2);
case "Lo":
return n.ordinalNumber(r + 1, { unit: "month" });
case "LLL":
return n.month(r, {
width: "abbreviated",
context: "standalone"
});
case "LLLLL":
return n.month(r, {
width: "narrow",
context: "standalone"
});
case "LLLL":
default:
return n.month(r, { width: "wide", context: "standalone" });
}
},
// Local week of year
w: function(t, e, n, r) {
const a = ct(t, r);
return e === "wo" ? n.ordinalNumber(a, { unit: "week" }) : u(a, e.length);
},
// ISO week of year
I: function(t, e, n) {
const r = re(t);
return e === "Io" ? n.ordinalNumber(r, { unit: "week" }) : u(r, e.length);
},
// Day of the month
d: function(t, e, n) {
return e === "do" ? n.ordinalNumber(t.getDate(), { unit: "date" }) : x.d(t, e);
},
// Day of year
D: function(t, e, n) {
const r = ne(t);
return e === "Do" ? n.ordinalNumber(r, { unit: "dayOfYear" }) : u(r, e.length);
},
// Day of week
E: function(t, e, n) {
const r = t.getDay();
switch (e) {
case "E":
case "EE":
case "EEE":
return n.day(r, {
width: "abbreviated",
context: "formatting"
});
case "EEEEE":
return n.day(r, {
width: "narrow",
context: "formatting"
});
case "EEEEEE":
return n.day(r, {
width: "short",
context: "formatting"
});
case "EEEE":
default:
return n.day(r, {
width: "wide",
context: "formatting"
});
}
},
// Local day of week
e: function(t, e, n, r) {
const a = t.getDay(), s = (a - r.weekStartsOn + 8) % 7 || 7;
switch (e) {
case "e":
return String(s);
case "ee":
return u(s, 2);
case "eo":
return n.ordinalNumber(s, { unit: "day" });
case "eee":
return n.day(a, {
width: "abbreviated",
context: "formatting"
});
case "eeeee":
return n.day(a, {
width: "narrow",
context: "formatting"
});
case "eeeeee":
return n.day(a, {
width: "short",
context: "formatting"
});
case "eeee":
default:
return n.day(a, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone local day of week
c: function(t, e, n, r) {
const a = t.getDay(), s = (a - r.weekStartsOn + 8) % 7 || 7;
switch (e) {
case "c":
return String(s);
case "cc":
return u(s, e.length);
case "co":
return n.ordinalNumber(s, { unit: "day" });
case "ccc":
return n.day(a, {
width: "abbreviated",
context: "standalone"
});
case "ccccc":
return n.day(a, {
width: "narrow",
context: "standalone"
});
case "cccccc":
return n.day(a, {
width: "short",
context: "standalone"
});
case "cccc":
default:
return n.day(a, {
width: "wide",
context: "standalone"
});
}
},
// ISO day of week
i: function(t, e, n) {
const r = t.getDay(), a = r === 0 ? 7 : r;
switch (e) {
case "i":
return String(a);
case "ii":
return u(a, e.length);
case "io":
return n.ordinalNumber(a, { unit: "day" });
case "iii":
return n.day(r, {
width: "abbreviated",
context: "formatting"
});
case "iiiii":
return n.day(r, {
width: "narrow",
context: "formatting"
});
case "iiiiii":
return n.day(r, {
width: "short",
context: "formatting"
});
case "iiii":
default:
return n.day(r, {
width: "wide",
context: "formatting"
});
}
},
// AM or PM
a: function(t, e, n) {
const a = t.getHours() / 12 >= 1 ? "pm" : "am";
switch (e) {
case "a":
case "aa":
return n.dayPeriod(a, {
width: "abbreviated",
context: "formatting"
});
case "aaa":
return n.dayPeriod(a, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "aaaaa":
return n.dayPeriod(a, {
width: "narrow",
context: "formatting"
});
case "aaaa":
default:
return n.dayPeriod(a, {
width: "wide",
context: "formatting"
});
}
},
// AM, PM, midnight, noon
b: function(t, e, n) {
const r = t.getHours();
let a;
switch (r === 12 ? a = C.noon : r === 0 ? a = C.midnight : a = r / 12 >= 1 ? "pm" : "am", e) {
case "b":
case "bb":
return n.dayPeriod(a, {
width: "abbreviated",
context: "formatting"
});
case "bbb":
return n.dayPeriod(a, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "bbbbb":
return n.dayPeriod(a, {
width: "narrow",
context: "formatting"
});
case "bbbb":
default:
return n.dayPeriod(a, {
width: "wide",
context: "formatting"
});
}
},
// in the morning, in the afternoon, in the evening, at night
B: function(t, e, n) {
const r = t.getHours();
let a;
switch (r >= 17 ? a = C.evening : r >= 12 ? a = C.afternoon : r >= 4 ? a = C.morning : a = C.night, e) {
case "B":
case "BB":
case "BBB":
return n.dayPeriod(a, {
width: "abbreviated",
context: "formatting"
});
case "BBBBB":
return n.dayPeriod(a, {
width: "narrow",
context: "formatting"
});
case "BBBB":
default:
return n.dayPeriod(a, {
width: "wide",
context: "formatting"
});
}
},
// Hour [1-12]
h: function(t, e, n) {
if (e === "ho") {
let r = t.getHours() % 12;
return r === 0 && (r = 12), n.ordinalNumber(r, { unit: "hour" });
}
return x.h(t, e);
},
// Hour [0-23]
H: function(t, e, n) {
return e === "Ho" ? n.ordinalNumber(t.getHours(), { unit: "hour" }) : x.H(t, e);
},
// Hour [0-11]
K: function(t, e, n) {
const r = t.getHours() % 12;
return e === "Ko" ? n.ordinalNumber(r, { unit: "hour" }) : u(r, e.length);
},
// Hour [1-24]
k: function(t, e, n) {
let r = t.getHours();
return r === 0 && (r = 24), e === "ko" ? n.ordinalNumber(r, { unit: "hour" }) : u(r, e.length);
},
// Minute
m: function(t, e, n) {
return e === "mo" ? n.ordinalNumber(t.getMinutes(), { unit: "minute" }) : x.m(t, e);
},
// Second
s: function(t, e, n) {
return e === "so" ? n.ordinalNumber(t.getSeconds(), { unit: "second" }) : x.s(t, e);
},
// Fraction of second
S: function(t, e) {
return x.S(t, e);
},
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: function(t, e, n) {
const r = t.getTimezoneOffset();
if (r === 0)
return "Z";
switch (e) {
case "X":
return tt(r);
case "XXXX":
case "XX":
return N(r);
case "XXXXX":
case "XXX":
default:
return N(r, ":");
}
},
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: function(t, e, n) {
const r = t.getTimezoneOffset();
switch (e) {
case "x":
return tt(r);
case "xxxx":
case "xx":
return N(r);
case "xxxxx":
case "xxx":
default:
return N(r, ":");
}
},
// Timezone (GMT)
O: function(t, e, n) {
const r = t.getTimezoneOffset();
switch (e) {
case "O":
case "OO":
case "OOO":
return "GMT" + Z(r, ":");
case "OOOO":
default:
return "GMT" + N(r, ":");
}
},
// Timezone (specific non-location)
z: function(t, e, n) {
const r = t.getTimezoneOffset();
switch (e) {
case "z":
case "zz":
case "zzz":
return "GMT" + Z(r, ":");
case "zzzz":
default:
return "GMT" + N(r, ":");
}
},
// Seconds timestamp
t: function(t, e, n) {
const r = Math.trunc(+t / 1e3);
return u(r, e.length);
},
// Milliseconds timestamp
T: function(t, e, n) {
return u(+t, e.length);
}
};
function Z(t, e = "") {
const n = t > 0 ? "-" : "+", r = Math.abs(t), a = Math.trunc(r / 60), s = r % 60;
return s === 0 ? n + String(a) : n + String(a) + e + u(s, 2);
}
function tt(t, e) {
return t % 60 === 0 ? (t > 0 ? "-" : "+") + u(Math.abs(t) / 60, 2) : N(t, e);
}
function N(t, e = "") {
const n = t > 0 ? "-" : "+", r = Math.abs(t), a = u(Math.trunc(r / 60), 2), s = u(r % 60, 2);
return n + a + e + s;
}
const et = (t, e) => {
switch (t) {
case "P":
return e.date({ width: "short" });
case "PP":
return e.date({ width: "medium" });
case "PPP":
return e.date({ width: "long" });
case "PPPP":
default:
return e.date({ width: "full" });
}
}, ut = (t, e) => {
switch (t) {
case "p":
return e.time({ width: "short" });
case "pp":
return e.time({ width: "medium" });
case "ppp":
return e.time({ width: "long" });
case "pppp":
default:
return e.time({ width: "full" });
}
}, se = (t, e) => {
const n = t.match(/(P+)(p+)?/) || [], r = n[1], a = n[2];
if (!a)
return et(t, e);
let s;
switch (r) {
case "P":
s = e.dateTime({ width: "short" });
break;
case "PP":
s = e.dateTime({ width: "medium" });
break;
case "PPP":
s = e.dateTime({ width: "long" });
break;
case "PPPP":
default:
s = e.dateTime({ width: "full" });
break;
}
return s.replace("{{date}}", et(r, e)).replace("{{time}}", ut(a, e));
}, ie = {
p: ut,
P: se
}, oe = /^D+$/, ce = /^Y+$/, ue = ["D", "DD", "YY", "YYYY"];
function le(t) {
return oe.test(t);
}
function he(t) {
return ce.test(t);
}
function de(t, e, n) {
const r = fe(t, e, n);
if (console.warn(r), ue.includes(t)) throw new RangeError(r);
}
function fe(t, e, n) {
const r = t[0] === "Y" ? "years" : "days of the month";
return `Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}
const me = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, ge = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, ye = /^'([^]*?)'?$/, pe = /''/g, we = /[a-zA-Z]/;
function be(t, e, n) {
var g, y, f, T;
const r = L(), a = r.locale ?? ee, s = r.firstWeekContainsDate ?? ((y = (g = r.locale) == null ? void 0 : g.options) == null ? void 0 : y.firstWeekContainsDate) ?? 1, i = r.weekStartsOn ?? ((T = (f = r.locale) == null ? void 0 : f.options) == null ? void 0 : T.weekStartsOn) ?? 0, c = D(t, n == null ? void 0 : n.in);
if (!bt(c))
throw new RangeError("Invalid time value");
let o = e.match(ge).map((p) => {
const b = p[0];
if (b === "p" || b === "P") {
const U = ie[b];
return U(p, a.formatLong);
}
return p;
}).join("").match(me).map((p) => {
if (p === "''")
return { isToken: !1, value: "'" };
const b = p[0];
if (b === "'")
return { isToken: !1, value: De(p) };
if (K[b])
return { isToken: !0, value: p };
if (b.match(we))
throw new RangeError(
"Format string contains an unescaped latin alphabet character `" + b + "`"
);
return { isToken: !1, value: p };
});
a.localize.preprocessor && (o = a.localize.preprocessor(c, o));
const d = {
firstWeekContainsDate: s,
weekStartsOn: i,
locale: a
};
return o.map((p) => {
if (!p.isToken) return p.value;
const b = p.value;
(he(b) || le(b)) && de(b, e, String(t));
const U = K[b[0]];
return U(c, b, a.localize, d);
}).join("");
}
function De(t) {
const e = t.match(ye);
return e ? e[1].replace(pe, "'") : t;
}
function ke(t, e) {
const n = D(t, e == null ? void 0 : e.in).getDay();
return n === 0 ? 7 : n;
}
const j = {}, F = {};
function A(t, e) {
try {
const r = (j[t] || (j[t] = new Intl.DateTimeFormat("en-GB", {
timeZone: t,
hour: "numeric",
timeZoneName: "longOffset"
}).format))(e).split("GMT")[1] || "";
return r in F ? F[r] : nt(r, r.split(":"));
} catch {
if (t in F) return F[t];
const n = t == null ? void 0 : t.match(ve);
return n ? nt(t, n.slice(1)) : NaN;
}
}
const ve = /([+-]\d\d):?(\d\d)?/;
function nt(t, e) {
const n = +e[0], r = +(e[1] || 0);
return F[t] = n > 0 ? n * 60 + r : n * 60 - r;
}
class S extends Date {
//#region static
constructor(...e) {
super(), e.length > 1 && typeof e[e.length - 1] == "string" && (this.timeZone = e.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(A(this.timeZone, this)) ? this.setTime(NaN) : e.length ? typeof e[0] == "number" && (e.length === 1 || e.length === 2 && typeof e[1] != "number") ? this.setTime(e[0]) : typeof e[0] == "string" ? this.setTime(+new Date(e[0])) : e[0] instanceof Date ? this.setTime(+e[0]) : (this.setTime(+new Date(...e)), lt(this), X(this)) : this.setTime(Date.now());
}
static tz(e, ...n) {
return n.length ? new S(...n, e) : new S(Date.now(), e);
}
//#endregion
//#region time zone
withTimeZone(e) {
return new S(+this, e);
}
getTimezoneOffset() {
return -A(this.timeZone, this);
}
//#endregion
//#region time
setTime(e) {
return Date.prototype.setTime.apply(this, arguments), X(this), +this;
}
//#endregion
//#region date-fns integration
[Symbol.for("constructDateFrom")](e) {
return new S(+new Date(e), this.timeZone);
}
//#endregion
}
const rt = /^(get|set)(?!UTC)/;
Object.getOwnPropertyNames(Date.prototype).forEach((t) => {
if (!rt.test(t)) return;
const e = t.replace(rt, "$1UTC");
S.prototype[e] && (t.startsWith("get") ? S.prototype[t] = function() {
return this.internal[e]();
} : (S.prototype[t] = function() {
return Date.prototype[e].apply(this.internal, arguments), Se(this), +this;
}, S.prototype[e] = function() {
return Date.prototype[e].apply(this, arguments), X(this), +this;
}));
});
function X(t) {
t.internal.setTime(+t), t.internal.setUTCMinutes(t.internal.getUTCMinutes() - t.getTimezoneOffset());
}
function Se(t) {
Date.prototype.setFullYear.call(t, t.internal.getUTCFullYear(), t.internal.getUTCMonth(), t.internal.getUTCDate()), Date.prototype.setHours.call(t, t.internal.getUTCHours(), t.internal.getUTCMinutes(), t.internal.getUTCSeconds(), t.internal.getUTCMilliseconds()), lt(t);
}
function lt(t) {
const e = A(t.timeZone, t), n = /* @__PURE__ */ new Date(+t);
n.setUTCHours(n.getUTCHours() - 1);
const r = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset(), a = -(/* @__PURE__ */ new Date(+n)).getTimezoneOffset(), s = r - a, i = Date.prototype.getHours.apply(t) !== t.internal.getUTCHours();
s && i && t.internal.setUTCMinutes(t.internal.getUTCMinutes() + s);
const c = r - e;
c && Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + c);
const o = A(t.timeZone, t), g = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset() - o, y = o !== e, f = g - c;
if (y && f) {
Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + f);
const T = A(t.timeZone, t), p = o - T;
p && (t.internal.setUTCMinutes(t.internal.getUTCMinutes() + p), Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + p));
}
}
class E extends S {
//#region static
static tz(e, ...n) {
return n.length ? new E(...n, e) : new E(Date.now(), e);
}
//#endregion
//#region representation
toISOString() {
const [e, n, r] = this.tzComponents(), a = `${e}${n}:${r}`;
return this.internal.toISOString().slice(0, -1) + a;
}
toString() {
return `${this.toDateString()} ${this.toTimeString()}`;
}
toDateString() {
const [e, n, r, a] = this.internal.toUTCString().split(" ");
return `${e == null ? void 0 : e.slice(0, -1)} ${r} ${n} ${a}`;
}
toTimeString() {
const e = this.internal.toUTCString().split(" ")[4], [n, r, a] = this.tzComponents();
return `${e} GMT${n}${r}${a} (${Me(this.timeZone, this)})`;
}
toLocaleString(e, n) {
return Date.prototype.toLocaleString.call(this, e, {
...n,
timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
});
}
toLocaleDateString(e, n) {
return Date.prototype.toLocaleDateString.call(this, e, {
...n,
timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
});
}
toLocaleTimeString(e, n) {
return Date.prototype.toLocaleTimeString.call(this, e, {
...n,
timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
});
}
//#endregion
//#region private
tzComponents() {
const e = this.getTimezoneOffset(), n = e > 0 ? "-" : "+", r = String(Math.floor(Math.abs(e) / 60)).padStart(2, "0"), a = String(Math.abs(e) % 60).padStart(2, "0");
return [n, r, a];
}
//#endregion
withTimeZone(e) {
return new E(+this, e);
}
//#region date-fns integration
[Symbol.for("constructDateFrom")](e) {
return new E(+new Date(e), this.timeZone);
}
//#endregion
}
function Me(t, e) {
return new Intl.DateTimeFormat("en-GB", {
timeZone: t,
timeZoneName: "long"
}).format(e).slice(12);
}
window.pktTz = window.pktTz === void 0 ? "Europe/Oslo" : window.pktTz;
const Te = (t = window.pktTz) => {
const e = new E((/* @__PURE__ */ new Date()).toISOString(), t);
return e.setHours(0, 0, 0, 0), isNaN(e.getTime()) ? /* @__PURE__ */ new Date() : new Date(e.getFullYear(), e.getMonth(), e.getDate());
};
function $(t) {
if (!t || t === "") return /* @__PURE__ */ new Date();
if (/^\d{4}-\d{2}-\d{2}$/.test(t)) {
const [e, n, r] = t.split("-").map(Number);
return new Date(e, n - 1, r);
}
if (/^\d{4}-\d{2}$/.test(t)) {
const [e, n] = t.split("-").map(Number);
return new Date(e, n - 1, 1);
}
return /^\d{4}$/.test(t) ? new Date(Number(t), 0, 1) : new Date(t);
}
const w = (t) => {
if (!t || isNaN(t.getTime())) return "";
const e = t.getFullYear(), n = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0");
return `${e}-${n}-${r}`;
}, _e = (t) => {
if (!t)
return null;
const e = $(t);
return isNaN(e.getTime()) ? null : e;
}, He = (t, e) => {
const n = v(t);
return isNaN(n.getTime()) ? "" : be(n, e);
}, v = (t = "", e) => {
const n = typeof t == "string" ? $(t) : t;
return !n || isNaN(n.getTime()) ? /* @__PURE__ */ new Date() : e ? e === "end" ? Dt(n) : G(n) : n;
}, O = (t, e, n = 1) => {
if (typeof t != "number" || typeof e != "number" || typeof n != "number" || isNaN(t) || isNaN(e) || isNaN(n))
return /* @__PURE__ */ new Date();
const r = new Date(t, e, n);
return isNaN(r.getTime()) ? /* @__PURE__ */ new Date() : r;
}, xe = (t) => !t || isNaN(t.getTime()) ? "" : new Intl.DateTimeFormat("no", { dateStyle: "full", timeZone: window.pktTz }).format(t), Oe = (t) => {
if (Array.isArray(t)) return t;
if (typeof t == "string") return t.split(",");
}, Pe = (t) => t ? $(t) : null, Ne = (t) => {
if (typeof t == "string")
return t.split(",").map((e) => $(e));
if (Array.isArray(t))
return t.map((e) => $(e));
}, R = {
csvToArray: Oe,
stringToDate: Pe,
stringsToDate: Ne
}, $e = {
earliest: {
default: null
},
latest: {
default: null
},
weeknumbers: {
default: !1
},
withcontrols: {
default: !1
},
multiple: {
default: !1
},
maxMultiple: {
default: 4
},
range: {
default: !1
}
}, P = {
props: $e
};
var Ce = Object.defineProperty, Ee = Object.getOwnPropertyDescriptor, h = (t, e, n, r) => {
for (var a = r > 1 ? void 0 : r ? Ee(e, n) : e, s = t.length - 1, i; s >= 0; s--)
(i = t[s]) && (a = (r ? i(e, n, a) : i(a)) || a);
return r && a && Ce(e, n, a), a;
};
let l = class extends dt {
constructor() {
super(...arguments), this.multiple = P.props.multiple.default, this.maxMultiple = P.props.maxMultiple.default, this.range = P.props.range.default, this.weeknumbers = P.props.weeknumbers.default, this.withcontrols = P.props.withcontrols.default, this.selected = [], this.earliest = P.props.earliest.default, this.latest = P.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.dayStrings = this.strings.dates.daysShort, this.dayStringsLong = this.strings.dates.days, this.monthStrings = this.strings.dates.months, this.weekString = this.strings.dates.week, this.prevMonthString = this.strings.dates.prevMonth, this.nextMonthString = this.strings.dates.nextMonth, this._selected = [], this.year = 0, this.month = 0, this.week = 0, this.rangeHovered = null, this.inRange = {}, this.focusedDate = null, this.selectableDates = [], this.currentmonthtouched = !1, this.tabIndexSet = 0;
}
/**
* Runs on mount, used to set up various values and whatever you need to run
*/
connectedCallback() {
super.connectedCallback();
}
disconnectedCallback() {
this.removeEventListener("keydown", this.handleKeydown), super.disconnectedCallback();
}
attributeChangedCallback(t, e, n) {
t === "selected" && n && this.convertSelected(), super.attributeChangedCallback(t, e, n);
}
updated(t) {
super.updated(t), t.has("selected") && this.convertSelected();
}
firstUpdated(t) {
this.addEventListener("keydown", this.handleKeydown);
}
convertSelected() {
if (typeof this.selected == "string" && (this.selected = this.selected.split(",")), this.selected.length === 1 && this.selected[0] === "" && (this.selected = []), this._selected = this.selected.map((t) => $(t)), this.range && this.selected.length === 2) {
const t = z({
start: this._selected[0],
end: this._selected[1]
});
if (this.inRange = {}, Array.isArray(t) && t.length) {
const e = {};
for (let n = 0; n < t.length; n++)
e[w(t[n])] = this.isInRange(t[n]);
this.inRange = e;
}
}
this.setCurrentMonth();
}
setCurrentMonth() {
if (this.currentmonth === null && !this.currentmonthtouched) {
this.currentmonthtouched = !0;
return;
}
if (this.selected.length && this.selected[0] !== "") {
const t = $(this.selected[this.selected.length - 1]);
this.currentmonth = isNaN(t.getTime()) ? /* @__PURE__ */ new Date() : t;
} else this.currentmonth === null && (this.currentmonth = /* @__PURE__ */ new Date());
(!this.currentmonth || isNaN(this.currentmonth.getTime())) && (this.currentmonth = /* @__PURE__ */ new Date()), this.year = this.currentmonth.getFullYear(), this.month = this.currentmonth.getMonth();
}
handleKeydown(t) {
switch (t.key) {
case "ArrowLeft":
this.handleArrowKey(t, -1);
break;
case "ArrowRight":
this.handleArrowKey(t, 1);
break;
case "ArrowUp":
this.handleArrowKey(t, -7);
break;
case "ArrowDown":
this.handleArrowKey(t, 7);
break;
}
}
handleArrowKey(t, e) {
var a, s, i;
if (((a = t.target) == null ? void 0 : a.nodeName) === "INPUT" || ((s = t.target) == null ? void 0 : s.nodeName) === "SELECT" || ((i = t.target) == null ? void 0 : i.nodeName) === "BUTTON") return;
t.preventDefault(), this.focusedDate || this.focusOnCurrentDate();
const n = this.focusedDate ? v(this.focusedDate) : O(this.year, this.month, 1);
let r = B(n, e);
if (r) {
let c = this.querySelector(`div[data-date="${w(r)}"]`);
if (c instanceof HTMLDivElement) {
if (c.dataset.disabled) {
r = B(r, e);
let o = this.querySelector(`div[data-date="${w(r)}"]`);
for (; o && o instanceof HTMLDivElement && o.dataset.disabled; )
r = B(r, e), o = this.querySelector(`div[data-date="${w(r)}"]`);
c = o;
}
c instanceof HTMLDivElement && !c.dataset.disabled && (this.focusedDate = w(r), c.focus());
}
}
}
/**
* Component functionality and render
*/
render() {
return k`
<div
class="pkt-calendar ${this.weeknumbers ? "pkt-cal-weeknumbers" : I}"
@focusout=${this.closeEvent}
@keydown=${(t) => {
t.key === "Escape" && (t.preventDefault(), this.close());
}}
>
<nav class="pkt-cal-month-nav">
<div>
<button
type="button"
@click=${this.isPrevMonthAllowed() && this.prevMonth}
@keydown=${(t) => {
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.isNextMonthAllowed() && this.prevMonth());
}}
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isPrevMonthAllowed() ? "" : "pkt-hide"}"
.data-disabled=${this.isPrevMonthAllowed() ? I : "disabled"}
?aria-disabled=${!this.isPrevMonthAllowed()}
tabindex=${this.isPrevMonthAllowed() ? "0" : "-1"}
>
<pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
<span class="pkt-btn__text">${this.prevMonthString}</span>
</button>
</div>
${this.renderMonthNav()}
<div>
<button
type="button"
@click=${this.isNextMonthAllowed() && this.nextMonth}
@keydown=${(t) => {
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.isNextMonthAllowed() && this.nextMonth());
}}
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isNextMonthAllowed() ? "" : "pkt-hide"}"
.data-disabled=${this.isNextMonthAllowed() ? I : "disabled"}
?aria-disabled=${!this.isNextMonthAllowed()}
tabindex=${this.isNextMonthAllowed() ? "0" : "-1"}
>
<pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
<span class="pkt-btn__text">${this.nextMonthString}</span>
</button>
</div>
</nav>
<table
class="pkt-cal-days pkt-txt-12-medium"
role="grid"
?aria-multiselectable=${this.range || this.multiple}
>
<thead>
${this.renderDayNames()}
</thead>
<tbody>
${this.renderCalendarBody()}
</tbody>
</table>
</div>
`;
}
renderDayNames() {
const t = [];
this.weeknumbers && t.push(k`<th><div>${this.weekString}</div></th>`);
for (let e = 0; e < this.dayStrings.length; e++)
t.push(
k`<th><div aria-label="${this.dayStringsLong[e]}">${this.dayStrings[e]}</div></th>`
);
return k`<tr class="pkt-cal-week-row">
${t}
</tr>`;
}
renderMonthNav() {
let t = [];
return this.withcontrols ? t.push(
k`<div class="pkt-cal-month-picker">
<label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
<select
aria-label="${this.strings.dates.month}"
class="pkt-input pkt-input-compact"
id="${this.id}-monthnav"
@change=${(e) => {
e.stopImmediatePropagation(), this.changeMonth(this.year, e.target.value);
}}
>
${this.monthStrings.map(
(e, n) => k`<option value=${n} ?selected=${this.month === n}>${e}</option>`
)}
</select>
<label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
<input
aria-label="${this.strings.dates.year}"
class="pkt-input pkt-cal-input-year pkt-input-compact"
id="${this.id}-yearnav"
type="number"
size="4"
placeholder="0000"
@change=${(e) => {
e.stopImmediatePropagation(), this.changeMonth(e.target.value, this.month);
}}
.value=${this.year}
/>
</div> `
) : t.push(
k`<div class="pkt-txt-16-medium" aria-live="polite">
${this.monthStrings[this.month]} ${this.year}
</div>`
), t;
}
renderDayView(t, e, n) {
var y;
const r = O(this.year, this.month, t), a = w(r), s = a === w(e), i = this.selected.includes(a), c = xe(r), o = this.isExcluded(n, r) || !i && this.multiple && this.maxMultiple > 0 && this.selected.length >= this.maxMultiple, d = this.focusedDate ? this.focusedDate === a && !o ? "0" : "-1" : !o && this.tabIndexSet === 0 || this.tabIndexSet === t ? "0" : "-1";
d === "0" && (this.tabIndexSet = t), this.selectableDates.push({ currentDateISO: a, isDisabled: o, tabindex: d });
const g = {
"pkt-cal-today": s,
"pkt-cal-selected": i,
"pkt-cal-in-range": this.inRange[a],
"pkt-cal-excluded": this.isExcluded(n, r),
"pkt-cal-in-range-first": this.range && (this.selected.length === 2 || this.rangeHovered !== null) && a === this.selected[0],
"pkt-cal-in-range-last": this.range && this.selected.length === 2 && a === this.selected[1],
"pkt-cal-range-hover": this.rangeHovered !== null && a === w(this.rangeHovered)
};
return k`<td class=${ht(g)}>
<div
?aria-selected=${i}
role="gridcell"
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
@mouseover=${() => this.range && !this.isExcluded(n, r) && this.handleRangeHover(r)}
@focus=${() => {
this.range && !this.isExcluded(n, r) && this.handleRangeHover(r), this.focusedDate = a;
}}
aria-label="${c}"
tabindex=${(y = this.selectableDates.find((f) => f.currentDateISO === a)) == null ? void 0 : y.tabindex}
data-disabled=${o ? "disabled" : I}
data-date=${a}
@keydown=${(f) => {
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), this.handleDateSelect(r));
}}
@click=${(f) => {
o || (f.preventDefault(), this.handleDateSelect(r));
}}
>
<span class="pkt-btn__text pkt-txt-14-light">${t}</span>
</div>
</td>`;
}
renderCalendarBody() {
const t = Te(), e = O(this.year, this.month, 1), n = O(this.year, this.month + 1, 0), r = (e.getDay() + 6) % 7, a = n.getDate(), s = Math.ceil((a + r) / 7), c = O(this.year, this.month, 0).getDate();
let o = 1;
this.week = ct(O(this.year, this.month, 1));
const d = [];
for (let g = 0; g < s; g++) {
const y = [];
this.weeknumbers && y.push(k`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
for (let f = 1; f < 8; f++)
if (g === 0 && f < r + 1) {