cronli5 0.3.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1591 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lang/pt/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => index_default
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/core/format.ts
28
+ function pad(n) {
29
+ n = "" + n;
30
+ return n.length < 2 ? "0" + n : n;
31
+ }
32
+ function numeral(n, words, opts) {
33
+ return opts.short ? n : words[n] || n;
34
+ }
35
+ function clockDigits(time, { sep, pad: padHour, lean }) {
36
+ const head = padHour ? pad(time.hour) : "" + time.hour;
37
+ if (lean && !time.minute && !time.second) {
38
+ return head;
39
+ }
40
+ return head + sep + pad(time.minute) + (time.second ? sep + pad(time.second) : "");
41
+ }
42
+
43
+ // src/core/specs.ts
44
+ var weekdayNumbers = {
45
+ SUN: 0,
46
+ MON: 1,
47
+ TUE: 2,
48
+ WED: 3,
49
+ THU: 4,
50
+ FRI: 5,
51
+ SAT: 6
52
+ };
53
+ var maxClockTimes = 6;
54
+
55
+ // src/core/util.ts
56
+ function isNonNegativeInteger(value) {
57
+ const digits = /^\d+$/;
58
+ return digits.test(value);
59
+ }
60
+ function toFieldNumber(token, numberMap) {
61
+ return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
62
+ }
63
+
64
+ // src/core/shapes.ts
65
+ function isOpenStep(field) {
66
+ return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
67
+ }
68
+
69
+ // src/core/cadence.ts
70
+ function arithmeticStep(values) {
71
+ if (values.length < 5) {
72
+ return null;
73
+ }
74
+ const interval = values[1] - values[0];
75
+ if (interval < 2) {
76
+ return null;
77
+ }
78
+ for (let i = 2; i < values.length; i += 1) {
79
+ if (values[i] - values[i - 1] !== interval) {
80
+ return null;
81
+ }
82
+ }
83
+ return { start: values[0], interval, last: values[values.length - 1] };
84
+ }
85
+ function segmentsOf(schedule, field) {
86
+ return schedule.analyses.segments[field] ?? [];
87
+ }
88
+ function stepSegment(schedule, field) {
89
+ return segmentsOf(schedule, field)[0];
90
+ }
91
+ function singleValues(segments) {
92
+ const values = [];
93
+ for (const segment of segments) {
94
+ if (segment.kind !== "single") {
95
+ return null;
96
+ }
97
+ values.push(+segment.value);
98
+ }
99
+ return values;
100
+ }
101
+ function offsetCleanStride(stride) {
102
+ return stride.start < stride.interval && 24 % stride.interval === 0;
103
+ }
104
+ function lastTileOf(start, interval, cycle) {
105
+ return cycle - 1 - (cycle - 1 - start) % interval;
106
+ }
107
+ function renderStride(spec, parts) {
108
+ const { start, interval, last, cycle } = spec;
109
+ const open = cycle % interval === 0 && last === lastTileOf(
110
+ start,
111
+ interval,
112
+ cycle
113
+ );
114
+ if (start === 0 && open) {
115
+ return parts.bare();
116
+ }
117
+ if (start < interval && open) {
118
+ return parts.offset();
119
+ }
120
+ return parts.bounded();
121
+ }
122
+ function hourListStride(values) {
123
+ if (values.length < 2) {
124
+ return null;
125
+ }
126
+ const interval = values[1] - values[0];
127
+ if (interval < 2) {
128
+ return null;
129
+ }
130
+ for (let i = 2; i < values.length; i += 1) {
131
+ if (values[i] - values[i - 1] !== interval) {
132
+ return null;
133
+ }
134
+ }
135
+ if (values[0] !== 0 && values.length < 5) {
136
+ return null;
137
+ }
138
+ return { interval, last: values[values.length - 1], start: values[0] };
139
+ }
140
+
141
+ // src/core/weekday.ts
142
+ function weekdayDisplayKey(value) {
143
+ return value === 0 ? 7 : value;
144
+ }
145
+ function orderWeekdaysForDisplay(segments) {
146
+ const flattened = segments.flatMap(function flat(segment) {
147
+ return segment.kind === "step" ? segment.fires.map(function single(value) {
148
+ return { kind: "single", value: "" + value };
149
+ }) : [segment];
150
+ });
151
+ function key(segment) {
152
+ return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
153
+ }
154
+ return flattened.map(function index(segment, position) {
155
+ return [segment, position];
156
+ }).sort(function byDisplayKey(a, b) {
157
+ return key(a[0]) - key(b[0]) || a[1] - b[1];
158
+ }).map(function unwrap(pair) {
159
+ return pair[0];
160
+ });
161
+ }
162
+
163
+ // src/lang/pt/dialects.ts
164
+ var pt = {
165
+ ampm: false,
166
+ hSuffix: false,
167
+ meridiem: "descriptors",
168
+ sep: ":"
169
+ };
170
+ var dialects = {
171
+ pt,
172
+ // Brazil is the default; named explicitly so it is a recognized choice and
173
+ // has a home if it ever diverges.
174
+ "pt-BR": pt
175
+ };
176
+ function resolveDialect(dialect) {
177
+ if (typeof dialect === "object" && dialect !== null) {
178
+ return { ...dialects.pt, ...dialect };
179
+ }
180
+ return dialects[dialect] || dialects.pt;
181
+ }
182
+
183
+ // src/lang/pt/index.ts
184
+ var numeros = [
185
+ "zero",
186
+ "um",
187
+ "dois",
188
+ "tr\xEAs",
189
+ "quatro",
190
+ "cinco",
191
+ "seis",
192
+ "sete",
193
+ "oito",
194
+ "nove",
195
+ "dez"
196
+ ];
197
+ var monthNames = [
198
+ null,
199
+ "janeiro",
200
+ "fevereiro",
201
+ "mar\xE7o",
202
+ "abril",
203
+ "maio",
204
+ "junho",
205
+ "julho",
206
+ "agosto",
207
+ "setembro",
208
+ "outubro",
209
+ "novembro",
210
+ "dezembro"
211
+ ];
212
+ var weekdayNames = [
213
+ "domingo",
214
+ "segunda-feira",
215
+ "ter\xE7a-feira",
216
+ "quarta-feira",
217
+ "quinta-feira",
218
+ "sexta-feira",
219
+ "s\xE1bado"
220
+ ];
221
+ var weekdayStems = [
222
+ "domingo",
223
+ "segunda",
224
+ "ter\xE7a",
225
+ "quarta",
226
+ "quinta",
227
+ "sexta",
228
+ "s\xE1bado"
229
+ ];
230
+ function weekdayFeminine(number) {
231
+ return number !== 0 && number !== 6;
232
+ }
233
+ var nthWeekdayMasculine = [null, "primeiro", "segundo", "terceiro", "quarto", "quinto"];
234
+ var nthWeekdayFeminine = [null, "primeira", "segunda", "terceira", "quarta", "quinta"];
235
+ function noonMidnightArticle(phrase) {
236
+ if (phrase === "meio-dia") {
237
+ return "o";
238
+ }
239
+ if (phrase === "meia-noite") {
240
+ return "a";
241
+ }
242
+ return null;
243
+ }
244
+ function withA(phrase) {
245
+ const word = noonMidnightArticle(phrase);
246
+ if (word) {
247
+ return (word === "o" ? "ao " : "\xE0 ") + phrase;
248
+ }
249
+ if (phrase.startsWith("as ")) {
250
+ return "\xE0s " + phrase.slice(3);
251
+ }
252
+ if (phrase.startsWith("a ")) {
253
+ return "\xE0 " + phrase.slice(2);
254
+ }
255
+ if (phrase.startsWith("os ")) {
256
+ return "aos " + phrase.slice(3);
257
+ }
258
+ if (phrase.startsWith("o ")) {
259
+ return "ao " + phrase.slice(2);
260
+ }
261
+ return "a " + phrase;
262
+ }
263
+ function withDe(phrase) {
264
+ const word = noonMidnightArticle(phrase);
265
+ if (word) {
266
+ return (word === "o" ? "do " : "da ") + phrase;
267
+ }
268
+ if (phrase.startsWith("as ")) {
269
+ return "das " + phrase.slice(3);
270
+ }
271
+ if (phrase.startsWith("a ")) {
272
+ return "da " + phrase.slice(2);
273
+ }
274
+ if (phrase.startsWith("os ")) {
275
+ return "dos " + phrase.slice(3);
276
+ }
277
+ if (phrase.startsWith("o ")) {
278
+ return "do " + phrase.slice(2);
279
+ }
280
+ return "de " + phrase;
281
+ }
282
+ function hasLeadingArticle(phrase) {
283
+ return noonMidnightArticle(phrase) !== null || phrase.startsWith("a ") || phrase.startsWith("as ") || phrase.startsWith("o ") || phrase.startsWith("os ");
284
+ }
285
+ function withEm(phrase) {
286
+ if (phrase.startsWith("as ")) {
287
+ return "nas " + phrase.slice(3);
288
+ }
289
+ if (phrase.startsWith("a ")) {
290
+ return "na " + phrase.slice(2);
291
+ }
292
+ if (phrase.startsWith("os ")) {
293
+ return "nos " + phrase.slice(3);
294
+ }
295
+ if (phrase.startsWith("o ")) {
296
+ return "no " + phrase.slice(2);
297
+ }
298
+ return "em " + phrase;
299
+ }
300
+ function normalizeOptions(options) {
301
+ options = options || {};
302
+ const style = resolveDialect(options.dialect);
303
+ return {
304
+ // The clock default comes from the dialect (24-hour for pt-BR); an explicit
305
+ // `{ampm}` option overrides it.
306
+ ampm: typeof options.ampm === "boolean" ? options.ampm : style.ampm,
307
+ lenient: !!options.lenient,
308
+ seconds: !!options.seconds,
309
+ short: !!options.short,
310
+ style,
311
+ years: !!options.years
312
+ };
313
+ }
314
+ function describe(schedule, opts) {
315
+ return applyYear(render(schedule, schedule.plan, opts), schedule, opts);
316
+ }
317
+ function render(schedule, plan, opts) {
318
+ const phrase = renderers[plan.kind](schedule, plan, opts);
319
+ if (!isDateWeekdayUnion(schedule)) {
320
+ return phrase;
321
+ }
322
+ const lead = unionMonthLeadFull(schedule);
323
+ return (lead ? lead + " " : "") + phrase + unionSejaSuffix(schedule, opts);
324
+ }
325
+ function renderEverySecond(schedule, plan, opts) {
326
+ return "a cada segundo" + trailingQualifier(schedule, opts);
327
+ }
328
+ function renderStandaloneSeconds(schedule, plan, opts) {
329
+ return secondsLeadClause(schedule, opts) + trailingQualifier(schedule, opts);
330
+ }
331
+ function renderSecondPastMinute(schedule, plan, opts) {
332
+ return "no segundo " + schedule.pattern.second + " de cada minuto" + trailingQualifier(schedule, opts);
333
+ }
334
+ function renderSecondsWithinMinute(schedule, plan, opts) {
335
+ const minuteField = schedule.pattern.minute;
336
+ if (plan.singleSecond) {
337
+ return "no minuto " + minuteField + " e no segundo " + schedule.pattern.second + " de cada hora" + trailingQualifier(schedule, opts);
338
+ }
339
+ return secondsLeadClause(schedule, opts) + ", no minuto " + minuteField + " de cada hora" + trailingQualifier(schedule, opts);
340
+ }
341
+ function secondsListAtClock(schedule, rest, opts) {
342
+ const clockPhrases = rest.times.map(function clock(time) {
343
+ return atTime(timePhrase(time.hour, time.minute, null, opts));
344
+ });
345
+ const grouped = groupClockTimesByArticle(clockPhrases);
346
+ const clockList = degenitive(grouped);
347
+ const stride = strideFromSegments(segmentsOf(schedule, "second"), "segundo", "", opts);
348
+ const secondsPhrase = stride ?? "nos segundos " + joinList(segmentWords(segmentsOf(schedule, "second")));
349
+ const dayFrame = trailingQualifier(schedule, opts);
350
+ return (dayFrame ? dayFrame.trimStart() + ", " : "") + secondsPhrase + " " + clockList;
351
+ }
352
+ function composeHourCadence(schedule, plan, opts) {
353
+ const clockRest = plan.rest.kind === "clockTimes" || plan.rest.kind === "compactClockTimes";
354
+ if (!clockRest || schedule.shapes.minute !== "single") {
355
+ return null;
356
+ }
357
+ const minute = +schedule.pattern.minute;
358
+ return hourCadence(schedule, minute, opts) ?? hourRangeCadence(schedule, minute, opts);
359
+ }
360
+ function isPinnedMinuteSeconds(schedule, plan) {
361
+ return plan.rest.kind === "clockTimes" && (schedule.shapes.second === "wildcard" || schedule.shapes.second === "step");
362
+ }
363
+ function renderComposeSeconds(schedule, plan, opts) {
364
+ const hourCad = composeHourCadence(schedule, plan, opts);
365
+ if (hourCad !== null) {
366
+ return hourCad;
367
+ }
368
+ if (isPinnedMinuteSeconds(schedule, plan)) {
369
+ return pinnedMinuteSeconds(schedule, plan.rest, opts);
370
+ }
371
+ if (plan.rest.kind === "clockTimes" && schedule.shapes.second === "list") {
372
+ return secondsListAtClock(schedule, plan.rest, opts);
373
+ }
374
+ if (plan.rest.kind === "hourRange" && schedule.shapes.second === "step" && schedule.pattern.weekday !== "*") {
375
+ const restNode = plan.rest;
376
+ const window = hourWindow(boundedWindow(restNode), opts);
377
+ const dayFrame = weekdayQualifier(schedule) + monthScope(schedule);
378
+ const cadence = "a cada " + numero(stepSegment(schedule, "second").interval, opts) + " segundos do minuto " + schedule.pattern.minute;
379
+ return dayFrame + ", " + window + ", " + cadence;
380
+ }
381
+ if (isEveryOtherMinuteSeconds(schedule, plan)) {
382
+ const rest = render(schedule, plan.rest, opts).replace(/^a /u, "");
383
+ return secondsLeadClause(schedule, opts) + " de " + rest;
384
+ }
385
+ const restOwnsLead = plan.rest.kind === "compactClockTimes" && schedule.analyses.clockSecond;
386
+ const lead = restOwnsLead ? "" : secondsLeadClause(schedule, opts) + ", ";
387
+ return lead + render(schedule, plan.rest, opts);
388
+ }
389
+ function isEveryOtherMinuteSeconds(schedule, plan) {
390
+ if (plan.rest.kind !== "minuteFrequency" || schedule.shapes.second !== "wildcard" || schedule.shapes.hour !== "wildcard") {
391
+ return false;
392
+ }
393
+ const minuteStep = stepSegment(schedule, "minute");
394
+ return minuteStep.startToken === "*" && minuteStep.interval === 2;
395
+ }
396
+ function pinnedMinuteSeconds(schedule, rest, opts) {
397
+ const dayTrail = trailingDayClause(schedule, opts);
398
+ const trail = dayTrail ? ", " + dayTrail : "";
399
+ if (+rest.times[0].minute === 0 && schedule.shapes.minute === "single") {
400
+ return secondsLeadClause(schedule, opts) + " durante um minuto " + durationHourList(rest.times, opts) + trail;
401
+ }
402
+ return secondsLeadClause(schedule, opts) + " " + explicitClockList(rest.times, opts) + trail;
403
+ }
404
+ function secondsLeadClause(schedule, opts) {
405
+ return secondsClause(schedule, "minuto", opts);
406
+ }
407
+ function secondsClause(schedule, anchor, opts) {
408
+ const secondField = schedule.pattern.second;
409
+ const shape = schedule.shapes.second;
410
+ if (secondField === "*") {
411
+ return "a cada segundo";
412
+ }
413
+ if (shape === "step") {
414
+ return stepCycle60(
415
+ stepSegment(schedule, "second"),
416
+ "segundo",
417
+ anchor,
418
+ opts
419
+ );
420
+ }
421
+ if (shape === "range") {
422
+ const bounds = secondField.split("-");
423
+ return "a cada segundo do " + bounds[0] + " ao " + bounds[1] + " de cada " + anchor;
424
+ }
425
+ if (shape === "single") {
426
+ return "no segundo " + secondField + " de cada " + anchor;
427
+ }
428
+ return strideFromSegments(
429
+ segmentsOf(schedule, "second"),
430
+ "segundo",
431
+ anchor,
432
+ opts
433
+ ) ?? "nos segundos " + joinList(segmentWords(segmentsOf(schedule, "second"))) + " de cada " + anchor;
434
+ }
435
+ function renderEveryMinute(schedule, plan, opts) {
436
+ return "a cada minuto" + trailingQualifier(schedule, opts);
437
+ }
438
+ function renderSingleMinute(schedule, plan, opts) {
439
+ return "no minuto " + schedule.pattern.minute + " de cada hora" + trailingQualifier(schedule, opts);
440
+ }
441
+ function renderRangeOfMinutes(schedule, plan, opts) {
442
+ return minuteRangeLead(schedule.pattern.minute) + " de cada hora" + trailingQualifier(schedule, opts);
443
+ }
444
+ function renderMultipleMinutes(schedule, plan, opts) {
445
+ return minutesList(schedule, opts) + trailingQualifier(schedule, opts);
446
+ }
447
+ function minutesList(schedule, opts) {
448
+ return strideFromSegments(
449
+ segmentsOf(schedule, "minute"),
450
+ "minuto",
451
+ "hora",
452
+ opts
453
+ ) ?? "nos minutos " + joinList(segmentWords(segmentsOf(schedule, "minute"))) + " de cada hora";
454
+ }
455
+ function minuteRangeLead(minuteField) {
456
+ const bounds = minuteField.split("-");
457
+ return "a cada minuto do " + bounds[0] + " ao " + bounds[1];
458
+ }
459
+ function singleHourStep(segments) {
460
+ return segments !== null && segments.length === 1 && segments[0].kind === "step";
461
+ }
462
+ function stepHourSpan(segment, opts) {
463
+ const bounded = segment.startToken.indexOf("-") !== -1;
464
+ const start = segment.startToken === "*" ? 0 : +segment.startToken;
465
+ if (segment.interval === 2 && !bounded && start <= 1) {
466
+ return start === 0 ? "durante as horas pares" : "durante as horas \xEDmpares";
467
+ }
468
+ return "durante as horas " + hourSpanList(segment.fires, opts);
469
+ }
470
+ function hourSpanList(fires, opts) {
471
+ if (!opts.ampm) {
472
+ return "das " + joinList(fires.map(String));
473
+ }
474
+ return joinList(hourPeriodGroups(fires, opts));
475
+ }
476
+ function hourPeriod(hour, opts) {
477
+ return opts.style.meridiem === "english" ? meridiemMark(hour) : dayPeriod(hour, opts);
478
+ }
479
+ function hourPeriodGroups(fires, opts) {
480
+ const groups = [];
481
+ fires.forEach(function place(hour) {
482
+ const period = hour === 0 || hour === 12 ? "" : hourPeriod(hour, opts);
483
+ const last = groups[groups.length - 1];
484
+ if (period !== "" && last && last.period === period) {
485
+ last.hours.push(hour);
486
+ } else {
487
+ groups.push({ hours: [hour], period });
488
+ }
489
+ });
490
+ return groups.map(function phrase(group) {
491
+ if (group.period === "") {
492
+ return fromTime(timePhrase(group.hours[0], 0, null, opts));
493
+ }
494
+ return spanHours(group.hours) + " " + group.period;
495
+ });
496
+ }
497
+ function spanHours(hours) {
498
+ const display = hours.map(function twelve(hour) {
499
+ return hour % 12 || 12;
500
+ });
501
+ if (display.indexOf(1) === -1) {
502
+ return "das " + joinList(display.map(String));
503
+ }
504
+ return joinList(display.map(function article(hour) {
505
+ return withDe((hour === 1 ? "a " : "as ") + hour);
506
+ }));
507
+ }
508
+ function renderMinuteFrequency(schedule, plan, opts) {
509
+ let phrase = stepCycle60(
510
+ stepSegment(schedule, "minute"),
511
+ "minuto",
512
+ "hora",
513
+ opts
514
+ );
515
+ if (plan.hours.kind === "during") {
516
+ const cadence = unevenHourCadence(schedule, opts);
517
+ if (cadence) {
518
+ phrase += ", " + cadence;
519
+ } else {
520
+ phrase += singleHourStep(schedule.analyses.segments.hour) ? ", " + stepHourSpan(stepSegment(schedule, "hour"), opts) : " " + hourSpanFromTimes(schedule, plan.hours.times, opts);
521
+ }
522
+ } else if (plan.hours.kind === "window") {
523
+ phrase += " " + hourWindow(plan.hours, opts);
524
+ } else if (plan.hours.kind === "step") {
525
+ phrase += ", " + stepHourSpan(stepSegment(schedule, "hour"), opts);
526
+ }
527
+ return phrase + trailingQualifier(schedule, opts);
528
+ }
529
+ function renderMinuteSpanInHour(schedule, plan, opts) {
530
+ if (schedule.pattern.minute === "*") {
531
+ return "a cada minuto da hora " + fromTime(timePhrase(plan.hour, 0, null, opts)) + trailingQualifier(schedule, opts);
532
+ }
533
+ return "a cada minuto " + timeRange(
534
+ { hour: plan.hour, minute: plan.span[0] },
535
+ { hour: plan.hour, minute: plan.span[1] },
536
+ opts
537
+ ) + trailingQualifier(schedule, opts);
538
+ }
539
+ function renderMinutesAcrossHours(schedule, plan, opts) {
540
+ const cadence = unevenHourCadence(schedule, opts);
541
+ if (plan.form === "wildcard") {
542
+ if (cadence !== null) {
543
+ return "a cada minuto, " + cadence + trailingQualifier(schedule, opts);
544
+ }
545
+ if (singleHourStep(schedule.analyses.segments.hour)) {
546
+ return "a cada minuto, " + stepHourSpan(stepSegment(schedule, "hour"), opts) + trailingQualifier(schedule, opts);
547
+ }
548
+ return "a cada minuto " + hourSpanFromTimes(schedule, plan.times, opts) + trailingQualifier(schedule, opts);
549
+ }
550
+ const lead = plan.form === "range" ? minuteRangeLead(schedule.pattern.minute) : minutesList(schedule, opts);
551
+ if (cadence !== null) {
552
+ return lead + ", " + cadence + trailingQualifier(schedule, opts);
553
+ }
554
+ return lead + ", " + atHourTimes(schedule, plan.times, opts) + trailingQualifier(schedule, opts);
555
+ }
556
+ function renderMinuteSpanAcrossHourStep(schedule, plan, opts) {
557
+ const segment = stepSegment(schedule, "hour");
558
+ const cadence = unevenHourCadence(schedule, opts);
559
+ if (plan.form === "wildcard") {
560
+ return "a cada minuto, " + stepHourSpan(segment, opts) + trailingQualifier(schedule, opts);
561
+ }
562
+ const lead = plan.form === "list" ? minutesList(schedule, opts) : minuteRangeLead(schedule.pattern.minute);
563
+ return lead + ", " + (cadence ?? stepHours(segment, opts)) + trailingQualifier(schedule, opts);
564
+ }
565
+ function renderEveryHour(schedule, plan, opts) {
566
+ return "a cada hora" + trailingQualifier(schedule, opts);
567
+ }
568
+ function renderHourRange(schedule, plan, opts) {
569
+ const window = hourWindow(boundedWindow(plan), opts);
570
+ if (plan.minuteForm === "wildcard") {
571
+ return "a cada minuto " + window + trailingQualifier(schedule, opts);
572
+ }
573
+ if (plan.minuteForm === "range") {
574
+ return minuteRangeLead(schedule.pattern.minute) + ", " + window + trailingQualifier(schedule, opts);
575
+ }
576
+ if (schedule.pattern.minute === "0") {
577
+ return "a cada hora " + window + trailingQualifier(schedule, opts);
578
+ }
579
+ const lead = schedule.shapes.minute === "single" ? "no minuto " + schedule.pattern.minute + " de cada hora" : minutesList(schedule, opts);
580
+ return lead + ", " + window + trailingQualifier(schedule, opts);
581
+ }
582
+ function renderHourStep(schedule, plan, opts) {
583
+ const cadence = unevenHourCadence(schedule, opts);
584
+ if (cadence !== null) {
585
+ return cadence + trailingQualifier(schedule, opts);
586
+ }
587
+ return stepHours(stepSegment(schedule, "hour"), opts) + trailingQualifier(schedule, opts);
588
+ }
589
+ function boundedWindow(plan) {
590
+ const last = plan.minuteForm === "wildcard" ? plan.boundMinute ?? 0 : 0;
591
+ return { from: plan.from, last, to: plan.to };
592
+ }
593
+ function hourWindow(window, opts) {
594
+ return timeRange(
595
+ { hour: window.from, minute: 0 },
596
+ { hour: window.to, minute: window.last },
597
+ opts
598
+ );
599
+ }
600
+ function isDateWeekdayUnion(schedule) {
601
+ return schedule.pattern.date !== "*" && schedule.pattern.weekday !== "*";
602
+ }
603
+ function unionMonthLeadFull(schedule) {
604
+ if (schedule.pattern.month === "*") {
605
+ return "";
606
+ }
607
+ const lead = monthPhrase(schedule, monthRanged(schedule) ? "de " : "em ");
608
+ const segments = flattenSteps(segmentsOf(schedule, "month"));
609
+ const isEnumeration = !monthRanged(schedule) && segments.length >= 2;
610
+ return isEnumeration ? lead + "," : lead;
611
+ }
612
+ function domArm(schedule, opts) {
613
+ const date = schedule.pattern.date;
614
+ const quartz = quartzDatePhrase(date);
615
+ if (quartz) {
616
+ return hasLeadingArticle(quartz) ? withEm(quartz) : quartz;
617
+ }
618
+ const parity = parityDayPredicate(date);
619
+ if (parity) {
620
+ return "em " + parity;
621
+ }
622
+ if (isOpenStep(date)) {
623
+ return stepDates(date, opts);
624
+ }
625
+ const segments = segmentsOf(schedule, "date");
626
+ if (segments.length === 1 && segments[0].kind === "range") {
627
+ return "do dia " + dayOrdinal(segments[0].bounds[0]) + " ao dia " + segments[0].bounds[1] + " do m\xEAs";
628
+ }
629
+ if (segments.length === 1 && segments[0].kind === "single") {
630
+ return schedule.pattern.month === "*" ? "no dia " + dayOrdinal(segments[0].value) + " de cada m\xEAs" : "no dia " + dayOrdinal(segments[0].value);
631
+ }
632
+ return "nos dias " + joinList(dateWords(segments)) + " do m\xEAs";
633
+ }
634
+ function dowArm(schedule) {
635
+ const quartz = quartzWeekdayPhrase(schedule.pattern.weekday);
636
+ if (quartz) {
637
+ return withEm(quartz);
638
+ }
639
+ const segments = orderWeekdaysForDisplay(segmentsOf(schedule, "weekday"));
640
+ const allSingles = segments.every(function single(segment) {
641
+ return segment.kind === "single";
642
+ });
643
+ if (allSingles && segments.length === 1) {
644
+ return recurringWeekday(segments[0].value);
645
+ }
646
+ if (allSingles) {
647
+ return recurringWeekdayList(segments);
648
+ }
649
+ if (segments.length === 1) {
650
+ return "em qualquer dia " + weekdayRange(segments[0]);
651
+ }
652
+ return mixedWeekdayList(segments);
653
+ }
654
+ function unionSejaSuffix(schedule, opts) {
655
+ return ", seja " + domArm(schedule, opts) + " ou " + dowArm(schedule);
656
+ }
657
+ function renderClockTimes(schedule, plan, opts) {
658
+ if (schedule.shapes.minute === "single") {
659
+ const minute = +schedule.pattern.minute;
660
+ const cadence = hourCadence(schedule, minute, opts) ?? hourRangeCadence(schedule, minute, opts);
661
+ if (cadence !== null) {
662
+ return cadence;
663
+ }
664
+ }
665
+ const phrases = plan.times.map(function clock(time) {
666
+ return atTime(timePhrase(time.hour, time.minute, time.second, opts));
667
+ });
668
+ return leadingQualifier(schedule, opts) + groupClockTimes(phrases);
669
+ }
670
+ function explicitClockList(times, opts) {
671
+ const phrases = times.map(function clock(time) {
672
+ return atTime(explicitTimePhrase(time.hour, time.minute, opts));
673
+ });
674
+ return degenitive(groupClockTimes(phrases));
675
+ }
676
+ function durationHourList(times, opts) {
677
+ const phrases = times.map(function clock(time) {
678
+ return atTime(bareHourPhrase(time.hour, opts));
679
+ });
680
+ return groupClockTimes(phrases);
681
+ }
682
+ function bareHourPhrase(hour, opts) {
683
+ if (opts.ampm) {
684
+ return timePhrase(hour, 0, null, opts);
685
+ }
686
+ if (+hour === 0) {
687
+ return "meia-noite";
688
+ }
689
+ if (+hour === 12) {
690
+ return "meio-dia";
691
+ }
692
+ return (+hour === 1 ? "a " : "as ") + hour;
693
+ }
694
+ function explicitTimePhrase(hour, minute, opts) {
695
+ if (!opts.ampm) {
696
+ const article = +hour === 1 ? "a " : "as ";
697
+ const suffix = opts.style.hSuffix ? " h" : "";
698
+ return article + clockDigits(
699
+ { hour, minute, second: 0 },
700
+ { pad: true, sep: opts.style.sep }
701
+ ) + suffix;
702
+ }
703
+ const display = hour % 12 || 12;
704
+ const time = (display === 1 ? "a " : "as ") + clockDigits({ hour: display, minute, second: 0 }, { sep: opts.style.sep });
705
+ const period = opts.style.meridiem === "english" ? meridiemMark(hour) : dayPeriod(hour, opts);
706
+ return time + " " + period;
707
+ }
708
+ function groupClockTimes(phrases) {
709
+ if (phrases.length < 2) {
710
+ return joinList(phrases);
711
+ }
712
+ return phrases.some(carriesDayPeriod) ? groupClockTimesByDayPeriod(phrases) : groupClockTimesByArticle(phrases);
713
+ }
714
+ function carriesDayPeriod(phrase) {
715
+ return phrase.includes(" da ");
716
+ }
717
+ var periodPhrasePattern = /^(às|à) (.+) (da .+)$/u;
718
+ function groupClockTimesByDayPeriod(phrases) {
719
+ const runs = collectPeriodRuns(phrases);
720
+ const elided = elideSharedSingleValues(runs);
721
+ const rendered = elided.map(renderPeriodRun);
722
+ return joinPeriodClauses(rendered);
723
+ }
724
+ function collectPeriodRuns(phrases) {
725
+ const runs = [];
726
+ phrases.forEach(function place(phrase) {
727
+ const match = periodPhrasePattern.exec(phrase);
728
+ if (!match) {
729
+ runs.push({ kind: "special", text: phrase });
730
+ return;
731
+ }
732
+ const article = match[1] === "\xE0s" ? "as" : "a";
733
+ const value = match[2];
734
+ const period = match[3];
735
+ const last = runs[runs.length - 1];
736
+ if (last && last.kind === "period" && last.period === period) {
737
+ last.values.push({ article, value });
738
+ } else {
739
+ runs.push({ kind: "period", period, values: [{ article, value }] });
740
+ }
741
+ });
742
+ return runs;
743
+ }
744
+ function renderPeriodRun(clause) {
745
+ if (clause.kind === "special") {
746
+ return { text: clause.text, hasInternalE: false };
747
+ }
748
+ const { period, values } = clause;
749
+ if (values.length === 1) {
750
+ const tail = elidedTail(clause);
751
+ return {
752
+ hasInternalE: tail !== "",
753
+ text: withA(values[0].article + " " + values[0].value) + " " + period + tail
754
+ };
755
+ }
756
+ const sharedArticle = values.every(function same(entry) {
757
+ return entry.article === values[0].article;
758
+ });
759
+ const parts = sharedArticle ? values.map(function bare(entry) {
760
+ return entry.value;
761
+ }) : values.map(function articled(entry) {
762
+ return withA(entry.article + " " + entry.value);
763
+ });
764
+ const lead = sharedArticle ? withA(values[0].article + " ") : "";
765
+ return { hasInternalE: true, text: lead + joinList(parts) + " " + period };
766
+ }
767
+ function elideSharedSingleValues(runs) {
768
+ const merged = [];
769
+ let i = 0;
770
+ while (i < runs.length) {
771
+ const run = runs[i];
772
+ const value = loneValue(run);
773
+ let combined = run;
774
+ let j = i + 1;
775
+ if (value !== null) {
776
+ while (j < runs.length && loneValue(runs[j]) === value) {
777
+ combined = appendPeriod(
778
+ combined,
779
+ runs[j].period
780
+ );
781
+ j += 1;
782
+ }
783
+ }
784
+ merged.push(combined);
785
+ i = j;
786
+ }
787
+ return merged;
788
+ }
789
+ function loneValue(clause) {
790
+ return clause.kind === "period" && clause.values.length === 1 ? clause.values[0].value : null;
791
+ }
792
+ function appendPeriod(clause, period) {
793
+ const elided = clause;
794
+ const tailPeriods = (elided.tailPeriods || []).concat(period);
795
+ return { ...clause, tailPeriods };
796
+ }
797
+ function elidedTail(clause) {
798
+ const tail = clause.tailPeriods;
799
+ if (!tail || tail.length === 0) {
800
+ return "";
801
+ }
802
+ return tail.map(function chain(period) {
803
+ return " e " + period;
804
+ }).join("");
805
+ }
806
+ function joinPeriodClauses(clauses) {
807
+ if (clauses.length === 1) {
808
+ return clauses[0].text;
809
+ }
810
+ const last = clauses[clauses.length - 1];
811
+ const lead = clauses.slice(0, -1).map(function text(clause) {
812
+ return clause.text;
813
+ });
814
+ return lead.join(", ") + " e " + last.text;
815
+ }
816
+ function groupClockTimesByArticle(phrases) {
817
+ const singular = "\xE0 ";
818
+ const plural = "\xE0s ";
819
+ const aItems = [];
820
+ const asItems = [];
821
+ for (const phrase of phrases) {
822
+ if (phrase.startsWith(plural)) {
823
+ asItems.push(phrase.slice(plural.length));
824
+ } else if (phrase.startsWith(singular)) {
825
+ aItems.push(phrase.slice(singular.length));
826
+ } else {
827
+ return joinList(phrases);
828
+ }
829
+ }
830
+ if (aItems.length === 0) {
831
+ return plural + joinList(asItems);
832
+ }
833
+ if (asItems.length === 0) {
834
+ return singular + joinList(aItems);
835
+ }
836
+ const aPart = singular + joinList(aItems);
837
+ const asPart = plural + joinList(asItems);
838
+ const doubleE = aItems.length >= 2 || asItems.length === 2;
839
+ const connector = doubleE ? ", " : " e ";
840
+ return aPart + connector + asPart;
841
+ }
842
+ function renderCompactClockTimes(schedule, plan, opts) {
843
+ if (plan.fold) {
844
+ const cadence2 = hourCadence(schedule, plan.minute, opts) ?? hourRangeCadence(schedule, plan.minute, opts);
845
+ if (cadence2 !== null) {
846
+ return cadence2;
847
+ }
848
+ const ranged = segmentsOf(schedule, "hour").some(function range(segment) {
849
+ return segment.kind === "range";
850
+ });
851
+ if (ranged && !schedule.analyses.clockSecond) {
852
+ return "a cada hora " + hourSegmentTimes(
853
+ schedule,
854
+ plan.minute,
855
+ schedule.analyses.clockSecond,
856
+ opts
857
+ ) + trailingQualifier(schedule, opts);
858
+ }
859
+ return leadingQualifier(schedule, opts) + hourSegmentTimes(
860
+ schedule,
861
+ plan.minute,
862
+ schedule.analyses.clockSecond,
863
+ opts
864
+ );
865
+ }
866
+ const cadence = unevenHourCadence(schedule, opts);
867
+ const phrase = cadence ? minutesList(schedule, opts) + ", " + cadence + trailingQualifier(schedule, opts) : minutesList(schedule, opts) + ", " + hourContextTimes(schedule, opts) + trailingQualifier(schedule, opts);
868
+ return schedule.analyses.clockSecond ? secondsLeadClause(schedule, opts) + ", " + phrase : phrase;
869
+ }
870
+ var renderers = {
871
+ clockTimes: renderClockTimes,
872
+ compactClockTimes: renderCompactClockTimes,
873
+ composeSeconds: renderComposeSeconds,
874
+ everyHour: renderEveryHour,
875
+ everyMinute: renderEveryMinute,
876
+ everySecond: renderEverySecond,
877
+ hourRange: renderHourRange,
878
+ hourStep: renderHourStep,
879
+ minuteFrequency: renderMinuteFrequency,
880
+ minuteSpanAcrossHourStep: renderMinuteSpanAcrossHourStep,
881
+ minuteSpanInHour: renderMinuteSpanInHour,
882
+ minutesAcrossHours: renderMinutesAcrossHours,
883
+ multipleMinutes: renderMultipleMinutes,
884
+ rangeOfMinutes: renderRangeOfMinutes,
885
+ secondPastMinute: renderSecondPastMinute,
886
+ secondsWithinMinute: renderSecondsWithinMinute,
887
+ singleMinute: renderSingleMinute,
888
+ standaloneSeconds: renderStandaloneSeconds
889
+ };
890
+ function renderStride2(stride, opts) {
891
+ const { interval, start, last, cycle, unit, anchor } = stride;
892
+ const cadence = "a cada " + numero(interval, opts) + " " + unit + "s";
893
+ const tail = anchor ? " de cada " + anchor : "";
894
+ return renderStride({ start, interval, last, cycle }, {
895
+ bare: () => cadence,
896
+ offset: () => cadence + " a partir do " + unit + " " + start + tail,
897
+ bounded: () => cadence + " do " + unit + " " + start + " ao " + last + tail
898
+ });
899
+ }
900
+ function stepCycle60(segment, unit, anchor, opts) {
901
+ if (segment.startToken.indexOf("-") !== -1) {
902
+ return "nos " + unit + "s " + joinList(wordList(segment.fires)) + " de cada " + anchor;
903
+ }
904
+ const start = segment.startToken === "*" ? 0 : +segment.startToken;
905
+ if (start !== 0 && segment.fires.length <= 3) {
906
+ return "nos " + unit + "s " + joinList(wordList(segment.fires)) + " de cada " + anchor;
907
+ }
908
+ return renderStride2({
909
+ interval: segment.interval,
910
+ start,
911
+ last: segment.fires[segment.fires.length - 1],
912
+ cycle: 60,
913
+ unit,
914
+ anchor
915
+ }, opts);
916
+ }
917
+ function strideFromSegments(segments, unit, anchor, opts) {
918
+ const values = singleValues(segments);
919
+ const step = values && arithmeticStep(values);
920
+ return step ? renderStride2({ ...step, cycle: 60, unit, anchor }, opts) : null;
921
+ }
922
+ function stepHours(segment, opts) {
923
+ if (segment.startToken.indexOf("-") !== -1) {
924
+ return groupClockTimesByArticle(atTimes(segment.fires, opts));
925
+ }
926
+ const start = segment.startToken === "*" ? 0 : +segment.startToken;
927
+ const interval = segment.interval;
928
+ if (start === 0) {
929
+ return "a cada " + numeroF(interval, opts) + " horas";
930
+ }
931
+ if (segment.fires.length <= 3) {
932
+ return groupClockTimesByArticle(atTimes(segment.fires, opts));
933
+ }
934
+ return "a cada " + numeroF(interval, opts) + " horas a partir " + fromTime(timePhrase(start, 0, null, opts));
935
+ }
936
+ function hourStrideCadence(stride, opts) {
937
+ const { start, interval, last } = stride;
938
+ const cadence = "a cada " + numeroF(interval, opts) + " horas";
939
+ return renderStride({ start, interval, last, cycle: 24 }, {
940
+ bare: () => cadence,
941
+ offset: () => cadence + " a partir " + fromTime(timePhrase(start, 0, null, opts)),
942
+ bounded: () => cadence + " " + fromTime(timePhrase(start, 0, null, opts)) + " " + toTime(timePhrase(last, 0, null, opts))
943
+ });
944
+ }
945
+ function unevenHourCadence(schedule, opts) {
946
+ const stride = hourStride(schedule);
947
+ if (!stride || offsetCleanStride(stride)) {
948
+ return null;
949
+ }
950
+ return hourStrideCadence(stride, opts);
951
+ }
952
+ function hourStride(schedule) {
953
+ const segments = segmentsOf(schedule, "hour");
954
+ if (segments.length === 1 && segments[0].kind === "step") {
955
+ const segment = segments[0];
956
+ if (segment.fires.length < 2) {
957
+ return null;
958
+ }
959
+ const start = segment.startToken === "*" ? 0 : +segment.startToken.split("-")[0];
960
+ return { interval: segment.interval, last: segment.fires[segment.fires.length - 1], start };
961
+ }
962
+ const values = singleValues(segments);
963
+ return values && hourListStride(values);
964
+ }
965
+ function subMinuteSecond(schedule) {
966
+ return schedule.pattern.second === "*" || schedule.shapes.second === "step";
967
+ }
968
+ function hourCadenceLead(schedule, minute, opts) {
969
+ if (minute === 0) {
970
+ if (subMinuteSecond(schedule)) {
971
+ return secondsClause(schedule, "minuto", opts) + " durante um minuto";
972
+ }
973
+ return secondsClause(schedule, "hora", opts);
974
+ }
975
+ const minutePhrase = "no minuto " + minute;
976
+ if (schedule.pattern.second === "0") {
977
+ return minutePhrase;
978
+ }
979
+ return secondsClause(schedule, "minuto", opts) + ", " + minutePhrase;
980
+ }
981
+ function hourCadence(schedule, minute, opts) {
982
+ const stride = hourStride(schedule);
983
+ if (!stride) {
984
+ return null;
985
+ }
986
+ const fires = (stride.last - stride.start) / stride.interval + 1;
987
+ if (schedule.pattern.second === "0" && fires <= maxClockTimes && offsetCleanStride(stride)) {
988
+ return null;
989
+ }
990
+ const confinement = minute === 0 && subMinuteSecond(schedule) && cleanStrideSegment(schedule);
991
+ if (confinement) {
992
+ return secondsClause(schedule, "minuto", opts) + " durante um minuto, " + stepHourSpan(confinement, opts) + trailingQualifier(schedule, opts);
993
+ }
994
+ if (minute === 0 && schedule.pattern.second === "0") {
995
+ return hourStrideCadence(stride, opts) + trailingQualifier(schedule, opts);
996
+ }
997
+ return hourCadenceLead(schedule, minute, opts) + ", " + hourStrideCadence(stride, opts) + trailingQualifier(schedule, opts);
998
+ }
999
+ function cleanStrideSegment(schedule) {
1000
+ const segments = segmentsOf(schedule, "hour");
1001
+ const segment = segments.length === 1 && segments[0];
1002
+ if (!segment || segment.kind !== "step" || segment.startToken.indexOf("-") !== -1) {
1003
+ return null;
1004
+ }
1005
+ return segment;
1006
+ }
1007
+ function hasHourWindow(schedule) {
1008
+ return segmentsOf(schedule, "hour").some(function range(segment) {
1009
+ return segment.kind === "range";
1010
+ });
1011
+ }
1012
+ function hourRangeCadence(schedule, minute, opts) {
1013
+ if (minute !== 0 || !hasHourWindow(schedule) || schedule.pattern.second === "0") {
1014
+ return null;
1015
+ }
1016
+ if (subMinuteSecond(schedule)) {
1017
+ return secondsClause(schedule, "minuto", opts) + " durante um minuto, durante as horas " + hourSegmentTimes(schedule, 0, null, opts) + trailingQualifier(schedule, opts);
1018
+ }
1019
+ return hourCadenceLead(schedule, minute, opts) + ", " + hourSegmentTimes(schedule, 0, null, opts) + trailingQualifier(schedule, opts);
1020
+ }
1021
+ function hourContextTimes(schedule, opts) {
1022
+ const segments = segmentsOf(schedule, "hour");
1023
+ const points = [];
1024
+ const hasRange = segments.some(function range(segment) {
1025
+ return segment.kind === "range";
1026
+ });
1027
+ segments.forEach(function collect(segment) {
1028
+ if (segment.kind === "step") {
1029
+ points.push(...segment.fires);
1030
+ } else if (segment.kind === "single") {
1031
+ points.push(+segment.value);
1032
+ }
1033
+ });
1034
+ function isWord(hour) {
1035
+ return !opts.ampm && (hour === 0 || hour === 12);
1036
+ }
1037
+ if (!hasRange && points.every(isWord)) {
1038
+ return joinList(points.map(function each(hour) {
1039
+ return atTime(bareHourPhrase(hour, opts));
1040
+ }));
1041
+ }
1042
+ function wholeHour(hour) {
1043
+ return "da hora " + fromTime(explicitTimePhrase(hour, 0, opts));
1044
+ }
1045
+ const pieces = [];
1046
+ segments.forEach(function place(segment) {
1047
+ if (segment.kind === "range") {
1048
+ pieces.push(timeRange(
1049
+ { hour: +segment.bounds[0], minute: 0 },
1050
+ { hour: +segment.bounds[1], minute: 0 },
1051
+ opts
1052
+ ));
1053
+ } else if (segment.kind === "step") {
1054
+ segment.fires.forEach(function each(hour) {
1055
+ pieces.push(wholeHour(hour));
1056
+ });
1057
+ } else {
1058
+ pieces.push(wholeHour(+segment.value));
1059
+ }
1060
+ });
1061
+ return joinList(pieces);
1062
+ }
1063
+ function atTimes(hours, opts) {
1064
+ return hours.map(function each(hour) {
1065
+ return atTime(timePhrase(hour, 0, null, opts));
1066
+ });
1067
+ }
1068
+ function atHourTimes(schedule, times, opts) {
1069
+ if (times.kind === "fires") {
1070
+ return groupClockTimesByArticle(atTimes(times.fires, opts));
1071
+ }
1072
+ return hourSegmentTimes(schedule, 0, null, opts);
1073
+ }
1074
+ function hourSpanFromTimes(schedule, times, opts) {
1075
+ if (times.kind === "fires" && times.fires.length > 3) {
1076
+ return "durante as horas " + hourSpanList(times.fires, opts);
1077
+ }
1078
+ return hourWindowsFromTimes(schedule, times, opts);
1079
+ }
1080
+ function hourWindowsFromTimes(schedule, times, opts) {
1081
+ if (times.kind === "fires") {
1082
+ return joinList(times.fires.map(function window(hour) {
1083
+ return hourAsWindow(hour, opts);
1084
+ }));
1085
+ }
1086
+ return joinList(segmentsOf(schedule, "hour").map(function window(segment) {
1087
+ if (segment.kind === "range") {
1088
+ return timeRange(
1089
+ { hour: +segment.bounds[0], minute: 0 },
1090
+ { hour: +segment.bounds[1], minute: 59 },
1091
+ opts
1092
+ );
1093
+ }
1094
+ if (segment.kind === "step") {
1095
+ return joinList(segment.fires.map(function each(hour) {
1096
+ return hourAsWindow(hour, opts);
1097
+ }));
1098
+ }
1099
+ return hourAsWindow(+segment.value, opts);
1100
+ }));
1101
+ }
1102
+ function hourSegmentTimes(schedule, minute, second, opts) {
1103
+ const pieces = [];
1104
+ const fromRange = [];
1105
+ segmentsOf(schedule, "hour").forEach(function clock(segment) {
1106
+ if (segment.kind === "step") {
1107
+ segment.fires.forEach(function each(hour) {
1108
+ pieces.push(atTime(timePhrase(hour, minute, second, opts)));
1109
+ fromRange.push(false);
1110
+ });
1111
+ } else if (segment.kind === "range") {
1112
+ pieces.push(timeRange(
1113
+ { hour: +segment.bounds[0], minute, second },
1114
+ { hour: +segment.bounds[1], minute, second },
1115
+ opts
1116
+ ));
1117
+ fromRange.push(true);
1118
+ } else {
1119
+ pieces.push(atTime(timePhrase(+segment.value, minute, second, opts)));
1120
+ fromRange.push(false);
1121
+ }
1122
+ });
1123
+ const lastIdx = pieces.length - 1;
1124
+ const hasRange = fromRange.some(function ranged(r) {
1125
+ return r;
1126
+ });
1127
+ const lastIsPoint = lastIdx >= 1 && !fromRange[lastIdx] && fromRange[lastIdx - 1];
1128
+ if (hasRange && lastIsPoint) {
1129
+ return joinList(pieces.slice(0, lastIdx)) + " e tamb\xE9m " + pieces[lastIdx];
1130
+ }
1131
+ return groupClockTimesByArticle(pieces);
1132
+ }
1133
+ function timeRange(from, to, opts) {
1134
+ const fromPhrase = timePhrase(from.hour, from.minute, from.second, opts);
1135
+ const toPhrase = timePhrase(to.hour, to.minute, to.second, opts);
1136
+ const fromPeriod = dayPeriod(from.hour, opts);
1137
+ const toPeriod = dayPeriod(to.hour, opts);
1138
+ if (fromPeriod && fromPeriod === toPeriod && fromPhrase.endsWith(fromPeriod)) {
1139
+ return fromTime(stripPeriod(fromPhrase, fromPeriod)) + " " + toTime(toPhrase);
1140
+ }
1141
+ return fromTime(fromPhrase) + " " + toTime(toPhrase);
1142
+ }
1143
+ function hourAsWindow(hour, opts) {
1144
+ return timeRange({ hour, minute: 0 }, { hour, minute: 59 }, opts);
1145
+ }
1146
+ function stripPeriod(phrase, period) {
1147
+ return phrase.slice(0, -(period.length + 1));
1148
+ }
1149
+ function atTime(phrase) {
1150
+ return withA(phrase);
1151
+ }
1152
+ function fromTime(phrase) {
1153
+ return withDe(phrase);
1154
+ }
1155
+ function toTime(phrase) {
1156
+ return atTime(phrase);
1157
+ }
1158
+ function degenitive(grouped) {
1159
+ if (grouped.startsWith("\xE0s ")) {
1160
+ return "das " + grouped.slice(3);
1161
+ }
1162
+ if (grouped.startsWith("\xE0 ")) {
1163
+ return "da " + grouped.slice(2);
1164
+ }
1165
+ return grouped;
1166
+ }
1167
+ function timePhrase(hour, minute, second, opts) {
1168
+ const showSeconds = typeof second === "number" && second > 0 ? second : 0;
1169
+ if (!opts.ampm) {
1170
+ const article = +hour === 1 ? "a " : "as ";
1171
+ const suffix = opts.style.hSuffix ? " h" : "";
1172
+ return article + clockDigits(
1173
+ { hour, minute, second: showSeconds },
1174
+ { pad: true, sep: opts.style.sep }
1175
+ ) + suffix;
1176
+ }
1177
+ return twelveHourPhrase(hour, minute, showSeconds, opts);
1178
+ }
1179
+ function twelveHourPhrase(hour, minute, second, opts) {
1180
+ if (+minute === 0 && !second) {
1181
+ if (+hour === 0) {
1182
+ return "meia-noite";
1183
+ }
1184
+ if (+hour === 12) {
1185
+ return "meio-dia";
1186
+ }
1187
+ }
1188
+ const display = hour % 12 || 12;
1189
+ const time = (display === 1 ? "a " : "as ") + clockDigits(
1190
+ { hour: display, minute, second },
1191
+ { lean: true, sep: opts.style.sep }
1192
+ );
1193
+ const period = opts.style.meridiem === "english" ? meridiemMark(hour) : dayPeriod(hour, opts);
1194
+ return time + " " + period;
1195
+ }
1196
+ function meridiemMark(hour) {
1197
+ return +hour < 12 ? "AM" : "PM";
1198
+ }
1199
+ function dayPeriod(hour, opts) {
1200
+ if (!opts.ampm) {
1201
+ return "";
1202
+ }
1203
+ if (+hour === 0 || +hour >= 19) {
1204
+ return "da noite";
1205
+ }
1206
+ if (+hour <= 5) {
1207
+ return "da madrugada";
1208
+ }
1209
+ if (+hour <= 11) {
1210
+ return "da manh\xE3";
1211
+ }
1212
+ return "da tarde";
1213
+ }
1214
+ function leadingQualifier(schedule, opts) {
1215
+ const pattern = schedule.pattern;
1216
+ if (pattern.date !== "*" && pattern.weekday !== "*") {
1217
+ return "";
1218
+ }
1219
+ if (pattern.date !== "*") {
1220
+ return datePhrase(schedule, opts) + " ";
1221
+ }
1222
+ if (pattern.weekday !== "*") {
1223
+ return weekdayLead(schedule) + " ";
1224
+ }
1225
+ if (pattern.month !== "*") {
1226
+ return "todos os dias " + monthPhrase(schedule, "de ") + " ";
1227
+ }
1228
+ return "todos os dias ";
1229
+ }
1230
+ function trailingDayClause(schedule, opts) {
1231
+ const pattern = schedule.pattern;
1232
+ if (pattern.date !== "*" && pattern.weekday !== "*") {
1233
+ return "";
1234
+ }
1235
+ if (pattern.date !== "*") {
1236
+ return datePhrase(schedule, opts);
1237
+ }
1238
+ if (pattern.weekday !== "*") {
1239
+ return weekdayQualifier(schedule) + monthScope(schedule);
1240
+ }
1241
+ if (pattern.month !== "*") {
1242
+ return "todos os dias " + monthPhrase(schedule, "de ");
1243
+ }
1244
+ return "todos os dias";
1245
+ }
1246
+ function trailingQualifier(schedule, opts) {
1247
+ const pattern = schedule.pattern;
1248
+ if (pattern.date !== "*" && pattern.weekday !== "*") {
1249
+ return "";
1250
+ }
1251
+ if (pattern.date !== "*") {
1252
+ return " " + datePhrase(schedule, opts);
1253
+ }
1254
+ if (pattern.weekday !== "*") {
1255
+ return " " + weekdayQualifier(schedule) + monthScope(schedule);
1256
+ }
1257
+ if (pattern.month !== "*") {
1258
+ return " " + monthPhrase(schedule, "em ");
1259
+ }
1260
+ return "";
1261
+ }
1262
+ function weekdayLead(schedule) {
1263
+ const single = singleFeminineWeekday(schedule);
1264
+ if (single !== null && !monthRanged(schedule)) {
1265
+ return everyWeekday(single) + monthScope(schedule);
1266
+ }
1267
+ return weekdayQualifier(schedule) + monthScope(schedule);
1268
+ }
1269
+ function singleFeminineWeekday(schedule) {
1270
+ if (quartzWeekdayPhrase(schedule.pattern.weekday)) {
1271
+ return null;
1272
+ }
1273
+ const segments = segmentsOf(schedule, "weekday");
1274
+ if (segments.length === 1 && segments[0].kind === "single") {
1275
+ const number = canonicalWeekday(segments[0].value);
1276
+ return weekdayFeminine(number) ? number : null;
1277
+ }
1278
+ return null;
1279
+ }
1280
+ function everyWeekday(number) {
1281
+ return "toda " + weekdayNames[number];
1282
+ }
1283
+ function datePhrase(schedule, opts) {
1284
+ const pattern = schedule.pattern;
1285
+ if (quartzDatePhrase(pattern.date) || isOpenStep(pattern.date)) {
1286
+ return dateClause(schedule, "", opts) + monthScope(schedule);
1287
+ }
1288
+ return dateClause(schedule, dateMonthPart(schedule), opts);
1289
+ }
1290
+ function dateClause(schedule, monthPart, opts) {
1291
+ const pattern = schedule.pattern;
1292
+ const quartz = quartzDatePhrase(pattern.date);
1293
+ if (quartz) {
1294
+ return hasLeadingArticle(quartz) ? withEm(quartz) : quartz;
1295
+ }
1296
+ if (isOpenStep(pattern.date)) {
1297
+ return stepDates(pattern.date, opts);
1298
+ }
1299
+ const segments = segmentsOf(schedule, "date");
1300
+ if (segments.length === 1 && segments[0].kind === "range") {
1301
+ return "do dia " + dayOrdinal(segments[0].bounds[0]) + " ao dia " + segments[0].bounds[1] + monthPart + foldedYear(schedule);
1302
+ }
1303
+ if (segments.length === 1 && segments[0].kind === "single") {
1304
+ return "no dia " + dayOrdinal(segments[0].value) + monthPart + foldedYear(schedule);
1305
+ }
1306
+ return "nos dias " + joinList(dateWords(segments)) + monthPart + foldedYear(schedule);
1307
+ }
1308
+ function monthRanged(schedule) {
1309
+ return schedule.pattern.month !== "*" && segmentsOf(schedule, "month").some(function range(segment) {
1310
+ return segment.kind === "range";
1311
+ });
1312
+ }
1313
+ function dateMonthPart(schedule) {
1314
+ if (schedule.pattern.month === "*") {
1315
+ return " de cada m\xEAs";
1316
+ }
1317
+ if (monthRanged(schedule)) {
1318
+ return " de cada m\xEAs, " + monthPhrase(schedule, "de ");
1319
+ }
1320
+ return " " + monthPhrase(schedule, "de ");
1321
+ }
1322
+ function foldedYear(schedule) {
1323
+ const yearField = schedule.pattern.year;
1324
+ if (yearField === "*" || yearField.indexOf("/") !== -1 || yearField.indexOf("-") !== -1 || yearField.indexOf(",") !== -1) {
1325
+ return "";
1326
+ }
1327
+ return " de " + yearField;
1328
+ }
1329
+ function quartzDatePhrase(dateField) {
1330
+ if (dateField === "L") {
1331
+ return "o \xFAltimo dia do m\xEAs";
1332
+ }
1333
+ if (dateField === "LW" || dateField === "WL") {
1334
+ return "o \xFAltimo dia \xFAtil do m\xEAs";
1335
+ }
1336
+ const offset = /^L-(\d{1,2})$/.exec(dateField);
1337
+ if (offset) {
1338
+ return +offset[1] === 1 ? "um dia antes do \xFAltimo dia do m\xEAs" : offset[1] + " dias antes do \xFAltimo dia do m\xEAs";
1339
+ }
1340
+ const nearest = /^(\d{1,2})W$|^W(\d{1,2})$/.exec(dateField);
1341
+ if (nearest) {
1342
+ return "o dia \xFAtil mais pr\xF3ximo ao dia " + (nearest[1] || nearest[2]);
1343
+ }
1344
+ }
1345
+ function quartzWeekdayPhrase(weekdayField) {
1346
+ const parts = weekdayField.split("#");
1347
+ if (parts.length === 2) {
1348
+ const number = canonicalWeekday(parts[0]);
1349
+ const feminine = weekdayFeminine(number);
1350
+ const ordinalWord = (feminine ? nthWeekdayFeminine : nthWeekdayMasculine)[+parts[1]];
1351
+ const article = feminine ? "a " : "o ";
1352
+ if (ordinalCollides(ordinalWord, number)) {
1353
+ return article + parts[1] + (feminine ? "\xAA " : "\xBA ") + weekdayNames[number] + " do m\xEAs";
1354
+ }
1355
+ return article + ordinalWord + " " + weekdayNames[number] + " do m\xEAs";
1356
+ }
1357
+ if (/L$/.test(weekdayField)) {
1358
+ const number = canonicalWeekday(weekdayField.slice(0, -1));
1359
+ const article = weekdayFeminine(number) ? "a \xFAltima " : "o \xFAltimo ";
1360
+ return article + weekdayNames[number] + " do m\xEAs";
1361
+ }
1362
+ }
1363
+ function ordinalCollides(ordinalWord, number) {
1364
+ return ordinalWord === weekdayStems[number];
1365
+ }
1366
+ function weekdayQualifier(schedule) {
1367
+ const quartz = quartzWeekdayPhrase(schedule.pattern.weekday);
1368
+ if (quartz) {
1369
+ return withEm(quartz);
1370
+ }
1371
+ const segments = orderWeekdaysForDisplay(segmentsOf(schedule, "weekday"));
1372
+ const allSingles = segments.every(function single(segment) {
1373
+ return segment.kind === "single";
1374
+ });
1375
+ if (allSingles) {
1376
+ return recurringWeekdayList(segments);
1377
+ }
1378
+ if (segments.length === 1) {
1379
+ return weekdayRange(segments[0]);
1380
+ }
1381
+ return mixedWeekdayList(segments);
1382
+ }
1383
+ function recurringWeekday(token) {
1384
+ const number = canonicalWeekday(token);
1385
+ const article = weekdayFeminine(number) ? "as " : "os ";
1386
+ return withA(article + pluralWeekday(token));
1387
+ }
1388
+ function recurringWeekdayList(segments) {
1389
+ const numbers = segments.map(function num(segment) {
1390
+ return canonicalWeekday(segment.value);
1391
+ });
1392
+ const feminineCount = numbers.filter(weekdayFeminine).length;
1393
+ if (feminineCount === 0) {
1394
+ return withA("os " + joinList(numbers.map(pluralFeira)));
1395
+ }
1396
+ const trailingMasculine = numbers.length - feminineCount === 1 && !weekdayFeminine(numbers[numbers.length - 1]);
1397
+ const head = trailingMasculine ? numbers.slice(0, -1) : numbers;
1398
+ const tail = trailingMasculine ? numbers[numbers.length - 1] : null;
1399
+ if (tail === null) {
1400
+ return withA("as " + joinList(feiraEllipsis(head)));
1401
+ }
1402
+ const feminineList = withA("as " + feiraEllipsis(head).join(", "));
1403
+ return feminineList + " e " + withA("os " + pluralFeira(tail));
1404
+ }
1405
+ function feiraEllipsis(numbers) {
1406
+ let lastFeira = -1;
1407
+ numbers.forEach(function find(number, index) {
1408
+ if (weekdayFeminine(number)) {
1409
+ lastFeira = index;
1410
+ }
1411
+ });
1412
+ return numbers.map(function word(number, index) {
1413
+ if (weekdayFeminine(number)) {
1414
+ return index === lastFeira ? pluralFeira(number) : pluralStem(number);
1415
+ }
1416
+ return pluralFeira(number);
1417
+ });
1418
+ }
1419
+ function mixedWeekdayList(segments) {
1420
+ return joinList(segments.map(function name(segment) {
1421
+ return segment.kind === "range" ? weekdayRange(segment) : recurringWeekday(segment.value);
1422
+ }));
1423
+ }
1424
+ function weekdayRange(segment) {
1425
+ return "de " + weekdayStem(segment.bounds[0]) + " a " + weekdayName(segment.bounds[1]);
1426
+ }
1427
+ function flattenSteps(segments) {
1428
+ return segments.flatMap(function flat(segment) {
1429
+ return segment.kind === "step" ? segment.fires.map(function single(value) {
1430
+ return { kind: "single", value };
1431
+ }) : [segment];
1432
+ });
1433
+ }
1434
+ function monthPhrase(schedule, lead) {
1435
+ const segments = flattenSteps(segmentsOf(schedule, "month"));
1436
+ const ranged = segments.some(function range(segment) {
1437
+ return segment.kind === "range";
1438
+ });
1439
+ if (!ranged) {
1440
+ return lead + joinList(segments.map(function name(segment) {
1441
+ return monthName(segment.value);
1442
+ }));
1443
+ }
1444
+ return joinList(segments.map(function name(segment) {
1445
+ if (segment.kind === "range") {
1446
+ return "de " + monthName(segment.bounds[0]) + " a " + monthName(segment.bounds[1]);
1447
+ }
1448
+ return lead + monthName(segment.value);
1449
+ }));
1450
+ }
1451
+ function monthScope(schedule) {
1452
+ if (schedule.pattern.month === "*") {
1453
+ return "";
1454
+ }
1455
+ return (monthRanged(schedule) ? ", " : " ") + monthPhrase(schedule, "de ");
1456
+ }
1457
+ function parityDayPredicate(dateField) {
1458
+ if (!isOpenStep(dateField)) {
1459
+ return;
1460
+ }
1461
+ const [start, step] = dateField.split("/");
1462
+ if (+step !== 2) {
1463
+ return;
1464
+ }
1465
+ if (start === "*" || start === "1") {
1466
+ return "um dia \xEDmpar do m\xEAs";
1467
+ }
1468
+ if (start === "2") {
1469
+ return "um dia par do m\xEAs";
1470
+ }
1471
+ }
1472
+ function stepDates(dateField, opts) {
1473
+ const parts = dateField.split("/");
1474
+ let phrase = "a cada " + numero(+parts[1], opts) + " dias do m\xEAs";
1475
+ if (parts[0] !== "*" && parts[0] !== "1") {
1476
+ phrase += " a partir do dia " + dayOrdinal(parts[0]);
1477
+ }
1478
+ return phrase;
1479
+ }
1480
+ function applyYear(description, schedule, opts) {
1481
+ const yearField = schedule.pattern.year;
1482
+ if (yearField === "*") {
1483
+ return description;
1484
+ }
1485
+ if (yearField.indexOf("/") !== -1) {
1486
+ return description + " " + stepYears(yearField, opts);
1487
+ }
1488
+ if (foldedYear(schedule) && schedule.pattern.date !== "*") {
1489
+ return description;
1490
+ }
1491
+ if (yearField.indexOf(",") !== -1) {
1492
+ return description + " em " + joinList(yearField.split(","));
1493
+ }
1494
+ return description + " em " + yearField;
1495
+ }
1496
+ function stepYears(yearField, opts) {
1497
+ const parts = yearField.split("/");
1498
+ const interval = +parts[1];
1499
+ if (interval <= 1) {
1500
+ return "todos os anos";
1501
+ }
1502
+ let phrase = "a cada " + numero(interval, opts) + " anos";
1503
+ if (parts[0] !== "*" && parts[0] !== "0") {
1504
+ phrase += " a partir de " + parts[0];
1505
+ }
1506
+ return phrase;
1507
+ }
1508
+ function segmentWords(segments) {
1509
+ return segments.flatMap(function word(segment) {
1510
+ if (segment.kind === "range") {
1511
+ return [segment.bounds[0] + " a " + segment.bounds[1]];
1512
+ }
1513
+ if (segment.kind === "step") {
1514
+ return wordList(segment.fires);
1515
+ }
1516
+ return [segment.value];
1517
+ });
1518
+ }
1519
+ function dateWords(segments) {
1520
+ return segments.flatMap(function word(segment) {
1521
+ if (segment.kind === "range") {
1522
+ return [dayOrdinal(segment.bounds[0]) + " a " + segment.bounds[1]];
1523
+ }
1524
+ if (segment.kind === "step") {
1525
+ return segment.fires.map(function fire(value, index) {
1526
+ return index === 0 ? dayOrdinal(value) : "" + value;
1527
+ });
1528
+ }
1529
+ return [dayOrdinal(segment.value)];
1530
+ });
1531
+ }
1532
+ function dayOrdinal(value) {
1533
+ return +value === 1 ? "1\xBA" : "" + value;
1534
+ }
1535
+ function wordList(fires) {
1536
+ return fires.map(function digit(value) {
1537
+ return "" + value;
1538
+ });
1539
+ }
1540
+ function joinList(items) {
1541
+ if (items.length <= 1) {
1542
+ return items.join("");
1543
+ }
1544
+ if (items.length === 2) {
1545
+ return items[0] + " e " + items[1];
1546
+ }
1547
+ return items.slice(0, -1).join(", ") + " e " + items[items.length - 1];
1548
+ }
1549
+ function numero(n, opts) {
1550
+ return numeral(n, numeros, opts);
1551
+ }
1552
+ function numeroF(n, opts) {
1553
+ const word = numero(n, opts);
1554
+ return word === "dois" ? "duas" : word;
1555
+ }
1556
+ function canonicalWeekday(token) {
1557
+ const number = toFieldNumber("" + token, weekdayNumbers);
1558
+ return number === 7 ? 0 : number;
1559
+ }
1560
+ function weekdayName(token) {
1561
+ return weekdayNames[canonicalWeekday(token)];
1562
+ }
1563
+ function weekdayStem(token) {
1564
+ return weekdayStems[canonicalWeekday(token)];
1565
+ }
1566
+ function pluralWeekday(token) {
1567
+ return pluralFeira(canonicalWeekday(token));
1568
+ }
1569
+ function pluralFeira(number) {
1570
+ if (weekdayFeminine(number)) {
1571
+ return pluralStem(number) + "-feiras";
1572
+ }
1573
+ return weekdayNames[number] + "s";
1574
+ }
1575
+ function pluralStem(number) {
1576
+ return weekdayStems[number] + "s";
1577
+ }
1578
+ function monthName(token) {
1579
+ return monthNames[+token];
1580
+ }
1581
+ var pt2 = {
1582
+ describe,
1583
+ fallback: "um padr\xE3o cron irreconhec\xEDvel",
1584
+ options: normalizeOptions,
1585
+ reboot: "ao iniciar o sistema",
1586
+ // A description ending in a period already carries it, so closing the
1587
+ // sentence must not double it.
1588
+ sentence: (description) => "Se executa " + description + (description.endsWith(".") ? "" : ".")
1589
+ };
1590
+ var index_default = pt2;
1591
+ module.exports = module.exports.default;