assignment-user-matcher 1.16.0 → 1.22.0
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.
- package/README.md +312 -20
- package/dist/escalation/policy.d.ts +11 -0
- package/dist/escalation/policy.d.ts.map +1 -1
- package/dist/escalation/policy.js +22 -1
- package/dist/forecasting/backtest.d.ts +52 -0
- package/dist/forecasting/backtest.d.ts.map +1 -0
- package/dist/forecasting/backtest.js +195 -0
- package/dist/forecasting/calendar.d.ts +44 -0
- package/dist/forecasting/calendar.d.ts.map +1 -0
- package/dist/forecasting/calendar.js +85 -0
- package/dist/forecasting/cover.d.ts +69 -0
- package/dist/forecasting/cover.d.ts.map +1 -0
- package/dist/forecasting/cover.js +103 -0
- package/dist/forecasting/days.d.ts +17 -0
- package/dist/forecasting/days.d.ts.map +1 -0
- package/dist/forecasting/days.js +35 -0
- package/dist/forecasting/distributions.d.ts +31 -0
- package/dist/forecasting/distributions.d.ts.map +1 -0
- package/dist/forecasting/distributions.js +154 -0
- package/dist/forecasting/effects.d.ts +88 -0
- package/dist/forecasting/effects.d.ts.map +1 -0
- package/dist/forecasting/effects.js +303 -0
- package/dist/forecasting/erlang.d.ts +31 -0
- package/dist/forecasting/erlang.d.ts.map +1 -0
- package/dist/forecasting/erlang.js +86 -0
- package/dist/forecasting/forecast.d.ts +7 -0
- package/dist/forecasting/forecast.d.ts.map +1 -0
- package/dist/forecasting/forecast.js +221 -0
- package/dist/forecasting/index.d.ts +18 -0
- package/dist/forecasting/index.d.ts.map +1 -0
- package/dist/forecasting/index.js +54 -0
- package/dist/forecasting/model.d.ts +145 -0
- package/dist/forecasting/model.d.ts.map +1 -0
- package/dist/forecasting/model.js +583 -0
- package/dist/forecasting/nowcast.d.ts +26 -0
- package/dist/forecasting/nowcast.d.ts.map +1 -0
- package/dist/forecasting/nowcast.js +92 -0
- package/dist/forecasting/simulation.d.ts +91 -0
- package/dist/forecasting/simulation.d.ts.map +1 -0
- package/dist/forecasting/simulation.js +478 -0
- package/dist/forecasting/spikes.d.ts +6 -0
- package/dist/forecasting/spikes.d.ts.map +1 -0
- package/dist/forecasting/spikes.js +73 -0
- package/dist/forecasting/staffing.d.ts +64 -0
- package/dist/forecasting/staffing.d.ts.map +1 -0
- package/dist/forecasting/staffing.js +765 -0
- package/dist/forecasting/stats.d.ts +11 -0
- package/dist/forecasting/stats.d.ts.map +1 -0
- package/dist/forecasting/stats.js +45 -0
- package/dist/forecasting/types.d.ts +299 -0
- package/dist/forecasting/types.d.ts.map +1 -0
- package/dist/forecasting/types.js +8 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/learning/auto-weights.d.ts +1 -5
- package/dist/learning/auto-weights.d.ts.map +1 -1
- package/dist/learning/auto-weights.js +0 -3
- package/dist/lua/book-slot.lua +84 -0
- package/dist/lua/claim-queued.lua +47 -0
- package/dist/managers/DecisionTraceManager.d.ts +15 -0
- package/dist/managers/DecisionTraceManager.d.ts.map +1 -1
- package/dist/managers/DecisionTraceManager.js +117 -11
- package/dist/managers/LearningManager.d.ts +12 -0
- package/dist/managers/LearningManager.d.ts.map +1 -1
- package/dist/managers/LearningManager.js +21 -7
- package/dist/managers/ReliabilityManager.d.ts +1 -2
- package/dist/managers/ReliabilityManager.d.ts.map +1 -1
- package/dist/managers/ReliabilityManager.js +1 -1
- package/dist/managers/TelemetryManager.d.ts.map +1 -1
- package/dist/managers/TelemetryManager.js +9 -3
- package/dist/managers/WorkflowManager.d.ts.map +1 -1
- package/dist/managers/WorkflowManager.js +3 -4
- package/dist/matcher.class.d.ts +319 -4
- package/dist/matcher.class.d.ts.map +1 -1
- package/dist/matcher.class.js +1428 -102
- package/dist/queries/lane-stats.d.ts +51 -0
- package/dist/queries/lane-stats.d.ts.map +1 -0
- package/dist/queries/lane-stats.js +78 -0
- package/dist/schedule/recurrence.d.ts +11 -0
- package/dist/schedule/recurrence.d.ts.map +1 -1
- package/dist/schedule/recurrence.js +19 -2
- package/dist/schedule/slot.d.ts +60 -0
- package/dist/schedule/slot.d.ts.map +1 -0
- package/dist/schedule/slot.js +86 -0
- package/dist/scheduling/constraints/availability.d.ts +2 -14
- package/dist/scheduling/constraints/availability.d.ts.map +1 -1
- package/dist/scheduling/constraints/availability.js +14 -15
- package/dist/scheduling/constraints/consecutive.d.ts +10 -0
- package/dist/scheduling/constraints/consecutive.d.ts.map +1 -1
- package/dist/scheduling/constraints/consecutive.js +64 -1
- package/dist/scheduling/constraints/contract.d.ts.map +1 -1
- package/dist/scheduling/constraints/contract.js +12 -3
- package/dist/scheduling/constraints/employee-scope.d.ts.map +1 -1
- package/dist/scheduling/constraints/employee-scope.js +10 -2
- package/dist/scheduling/constraints/group-composition.js +2 -2
- package/dist/scheduling/constraints/min-staffing.d.ts.map +1 -1
- package/dist/scheduling/constraints/min-staffing.js +51 -8
- package/dist/scheduling/constraints/rolling-hours.d.ts.map +1 -1
- package/dist/scheduling/constraints/rolling-hours.js +29 -4
- package/dist/scheduling/constraints/support.d.ts +4 -8
- package/dist/scheduling/constraints/support.d.ts.map +1 -1
- package/dist/scheduling/constraints/support.js +23 -2
- package/dist/scheduling/constraints/weekly-rest.d.ts +28 -0
- package/dist/scheduling/constraints/weekly-rest.d.ts.map +1 -1
- package/dist/scheduling/constraints/weekly-rest.js +108 -21
- package/dist/scheduling/engine/construction.d.ts.map +1 -1
- package/dist/scheduling/engine/construction.js +56 -7
- package/dist/scheduling/engine/objective.d.ts +0 -1
- package/dist/scheduling/engine/objective.d.ts.map +1 -1
- package/dist/scheduling/engine/objective.js +65 -6
- package/dist/scheduling/engine/search.d.ts +4 -0
- package/dist/scheduling/engine/search.d.ts.map +1 -1
- package/dist/scheduling/engine/search.js +2 -1
- package/dist/scheduling/engine/state.d.ts +14 -0
- package/dist/scheduling/engine/state.d.ts.map +1 -1
- package/dist/scheduling/engine/state.js +7 -0
- package/dist/scheduling/engine/timeline.d.ts +23 -1
- package/dist/scheduling/engine/timeline.d.ts.map +1 -1
- package/dist/scheduling/engine/timeline.js +85 -27
- package/dist/scheduling/engine/verdicts.d.ts +40 -1
- package/dist/scheduling/engine/verdicts.d.ts.map +1 -1
- package/dist/scheduling/engine/verdicts.js +177 -17
- package/dist/scheduling/index.d.ts +3 -2
- package/dist/scheduling/index.d.ts.map +1 -1
- package/dist/scheduling/index.js +7 -1
- package/dist/scheduling/model.d.ts +8 -4
- package/dist/scheduling/model.d.ts.map +1 -1
- package/dist/scheduling/model.js +239 -23
- package/dist/scheduling/operations.d.ts +174 -2
- package/dist/scheduling/operations.d.ts.map +1 -1
- package/dist/scheduling/operations.js +558 -21
- package/dist/scheduling/preference-report.d.ts +15 -0
- package/dist/scheduling/preference-report.d.ts.map +1 -0
- package/dist/scheduling/preference-report.js +111 -0
- package/dist/scheduling/preferences.d.ts +30 -0
- package/dist/scheduling/preferences.d.ts.map +1 -0
- package/dist/scheduling/preferences.js +85 -0
- package/dist/scheduling/resilience.d.ts +46 -0
- package/dist/scheduling/resilience.d.ts.map +1 -0
- package/dist/scheduling/resilience.js +45 -0
- package/dist/scheduling/scheduler.class.d.ts +12 -1
- package/dist/scheduling/scheduler.class.d.ts.map +1 -1
- package/dist/scheduling/scheduler.class.js +28 -4
- package/dist/scheduling/sites.d.ts +1 -1
- package/dist/scheduling/sites.d.ts.map +1 -1
- package/dist/scheduling/sites.js +34 -1
- package/dist/scheduling/time.d.ts +28 -6
- package/dist/scheduling/time.d.ts.map +1 -1
- package/dist/scheduling/time.js +59 -17
- package/dist/scheduling/types.d.ts +247 -7
- package/dist/scheduling/types.d.ts.map +1 -1
- package/dist/scoring/fair-arbitration.d.ts.map +1 -1
- package/dist/scoring/fair-arbitration.js +2 -1
- package/dist/tracing/decision-trace.d.ts +5 -0
- package/dist/tracing/decision-trace.d.ts.map +1 -1
- package/dist/tracing/decision-trace.js +3 -0
- package/dist/types/matcher.d.ts +369 -2
- package/dist/types/matcher.d.ts.map +1 -1
- package/dist/updates/assignment-update.d.ts +93 -0
- package/dist/updates/assignment-update.d.ts.map +1 -0
- package/dist/updates/assignment-update.js +91 -0
- package/dist/utils/keys.d.ts +10 -0
- package/dist/utils/keys.d.ts.map +1 -1
- package/dist/utils/keys.js +43 -0
- package/package.json +25 -3
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
*/
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.score = exports.scoreLex = exports.softBreaches = exports.breachTotals = exports.minHoursShortfalls = exports.hoursVariance = exports.unfilledSlots = exports.tagShortage = exports.slotShortage = exports.isBetter = exports.compareScores = exports.DEFAULT_SOFT_WEIGHT = exports.MIN_HOURS_WEIGHT = exports.TAG_SHORTFALL_WEIGHT = exports.UNFILLED_WEIGHT = void 0;
|
|
30
|
+
const support_1 = require("../constraints/support");
|
|
31
|
+
const verdicts_1 = require("./verdicts");
|
|
30
32
|
const fairness_1 = require("../constraints/fairness");
|
|
31
33
|
const availability_1 = require("../constraints/availability");
|
|
32
34
|
const contract_hours_1 = require("../contract-hours");
|
|
@@ -63,14 +65,31 @@ function tagShortage(ctx, state, instanceId) {
|
|
|
63
65
|
return 0;
|
|
64
66
|
const assigned = state.assignments.get(instanceId);
|
|
65
67
|
let short = 0;
|
|
66
|
-
for (const [tag,
|
|
68
|
+
for (const [tag, requirement] of Object.entries(inst.tagRequirements)) {
|
|
67
69
|
let have = 0;
|
|
68
70
|
if (assigned) {
|
|
71
|
+
for (const employeeId of assigned) {
|
|
72
|
+
const holds = requirement.level === undefined
|
|
73
|
+
? ctx.holdsTagOn(employeeId, tag, inst.date)
|
|
74
|
+
: ctx.holdsTagAt(employeeId, tag, inst.date, requirement.level);
|
|
75
|
+
if (holds)
|
|
76
|
+
have++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
short += Math.max(0, requirement.min - have);
|
|
80
|
+
}
|
|
81
|
+
// A ratio's shortfall is measured against the team that is actually on, so
|
|
82
|
+
// it moves as the shift fills — which is what lets the search close it by
|
|
83
|
+
// adding the right person rather than by adding anybody.
|
|
84
|
+
const size = assigned?.size ?? 0;
|
|
85
|
+
if (size > 0) {
|
|
86
|
+
for (const [tag, ratio] of Object.entries(inst.tagRatios)) {
|
|
87
|
+
let have = 0;
|
|
69
88
|
for (const employeeId of assigned)
|
|
70
|
-
if (ctx.
|
|
89
|
+
if (ctx.holdsTagOn(employeeId, tag, inst.date))
|
|
71
90
|
have++;
|
|
91
|
+
short += Math.max(0, Math.ceil(ratio * size) - have);
|
|
72
92
|
}
|
|
73
|
-
short += Math.max(0, needed - have);
|
|
74
93
|
}
|
|
75
94
|
return short;
|
|
76
95
|
}
|
|
@@ -116,10 +135,20 @@ function breachTotals(ctx, state) {
|
|
|
116
135
|
const scored = ctx.constraints.filter((c) => c.id !== 'min-staffing' && c.id !== 'fairness');
|
|
117
136
|
if (scored.length === 0)
|
|
118
137
|
return totals;
|
|
138
|
+
// The search scores the whole roster after every move, and most people's
|
|
139
|
+
// schedules did not move. Where every rule is a built-in and the state
|
|
140
|
+
// counts mutations per person, a pair's person-scoped deltas are reused
|
|
141
|
+
// until that person changes; crew-reading rules are always asked. The
|
|
142
|
+
// sums below run over the same pairs and rules in the same order either
|
|
143
|
+
// way, so the totals are the same numbers to the last bit.
|
|
144
|
+
const memo = deltaMemoFor(ctx, state, scored);
|
|
119
145
|
for (const [instanceId, employees] of state.assignments) {
|
|
120
146
|
for (const employeeId of employees) {
|
|
121
|
-
|
|
122
|
-
|
|
147
|
+
const pair = { employeeId, shiftInstanceId: instanceId };
|
|
148
|
+
const cached = memo?.lookup(pair);
|
|
149
|
+
for (let i = 0; i < scored.length; i++) {
|
|
150
|
+
const c = scored[i];
|
|
151
|
+
const d = cached && !memo.crew[i] ? cached[i] : c.delta(state, pair);
|
|
123
152
|
if (d > 0)
|
|
124
153
|
totals[c.hardness] += d * (c.weight ?? exports.DEFAULT_SOFT_WEIGHT);
|
|
125
154
|
}
|
|
@@ -128,7 +157,37 @@ function breachTotals(ctx, state) {
|
|
|
128
157
|
return totals;
|
|
129
158
|
}
|
|
130
159
|
exports.breachTotals = breachTotals;
|
|
131
|
-
|
|
160
|
+
const memos = new WeakMap();
|
|
161
|
+
function deltaMemoFor(ctx, state, scored) {
|
|
162
|
+
const versions = state.personVersion;
|
|
163
|
+
if (!versions || state.ctx !== ctx || !ctx.constraints.every((c) => support_1.builtInConstraints.has(c)))
|
|
164
|
+
return undefined;
|
|
165
|
+
const existing = memos.get(state);
|
|
166
|
+
if (existing && existing.scored.length === scored.length && existing.scored.every((c, i) => c === scored[i])) {
|
|
167
|
+
return existing.memo;
|
|
168
|
+
}
|
|
169
|
+
const crew = scored.map((c) => (0, verdicts_1.readsCrew)(c));
|
|
170
|
+
const byInstance = new Map();
|
|
171
|
+
const memo = {
|
|
172
|
+
crew,
|
|
173
|
+
lookup(pair) {
|
|
174
|
+
const person = versions.get(ctx.personIdOf.get(pair.employeeId) ?? pair.employeeId) ?? 0;
|
|
175
|
+
let byEmployee = byInstance.get(pair.shiftInstanceId);
|
|
176
|
+
if (!byEmployee) {
|
|
177
|
+
byEmployee = new Map();
|
|
178
|
+
byInstance.set(pair.shiftInstanceId, byEmployee);
|
|
179
|
+
}
|
|
180
|
+
const hit = byEmployee.get(pair.employeeId);
|
|
181
|
+
if (hit && hit.person === person)
|
|
182
|
+
return hit.deltas;
|
|
183
|
+
const deltas = scored.map((c, i) => (crew[i] ? 0 : c.delta(state, pair)));
|
|
184
|
+
byEmployee.set(pair.employeeId, { person, deltas });
|
|
185
|
+
return deltas;
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
memos.set(state, { scored, memo });
|
|
189
|
+
return memo;
|
|
190
|
+
}
|
|
132
191
|
function softBreaches(ctx, state) {
|
|
133
192
|
return breachTotals(ctx, state).soft;
|
|
134
193
|
}
|
|
@@ -36,6 +36,10 @@ export interface SearchOptions {
|
|
|
36
36
|
historyLength?: number;
|
|
37
37
|
/** Called whenever a new best is found, for anytime reporting. */
|
|
38
38
|
onImprovement?: (state: InternalState, score: LexScore) => void;
|
|
39
|
+
/** After every round, with the best state so far and the variants judged. */
|
|
40
|
+
onRound?: (best: InternalState, evaluatedVariants: number) => void;
|
|
41
|
+
/** Asked before every round; `true` ends the search with the best so far. */
|
|
42
|
+
shouldStop?: () => boolean;
|
|
39
43
|
}
|
|
40
44
|
export interface SearchOutcome {
|
|
41
45
|
best: InternalState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/scheduling/engine/search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAgE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAG9E,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/scheduling/engine/search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAgE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAG9E,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChE,6EAA6E;IAC7E,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAiCD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EAAE,aAAa,EACtB,gBAAgB,EAAE,MAAM,aAAa,GACtC,aAAa,CA6Ef"}
|
|
@@ -71,7 +71,7 @@ function improveWithLns(ctx, state, propagation, options, createEmptyState) {
|
|
|
71
71
|
const historyLength = Math.max(1, options.historyLength ?? DEFAULT_HISTORY_LENGTH);
|
|
72
72
|
const history = new Array(historyLength).fill(workingScore);
|
|
73
73
|
let iteration = 0;
|
|
74
|
-
while (now() < deadline && iteration < (options.maxIterations ?? Infinity)) {
|
|
74
|
+
while (now() < deadline && iteration < (options.maxIterations ?? Infinity) && !options.shouldStop?.()) {
|
|
75
75
|
const total = (0, state_1.assignedPairs)(working).length;
|
|
76
76
|
if (total === 0)
|
|
77
77
|
break;
|
|
@@ -121,6 +121,7 @@ function improveWithLns(ctx, state, propagation, options, createEmptyState) {
|
|
|
121
121
|
}
|
|
122
122
|
history[iteration % historyLength] = workingScore;
|
|
123
123
|
iteration++;
|
|
124
|
+
options.onRound?.(best, evaluatedVariants);
|
|
124
125
|
}
|
|
125
126
|
return { best, evaluatedVariants };
|
|
126
127
|
}
|
|
@@ -9,6 +9,20 @@ import type { ModelContext, SearchState } from '../types';
|
|
|
9
9
|
export interface InternalState extends SearchState {
|
|
10
10
|
/** Per-pair selection reasons recorded by construction/repair, surfaced in the result. */
|
|
11
11
|
reasons: Map<string, string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* A mutation counter per person, bumped by every `assign`/`unassign` of any
|
|
14
|
+
* of their records: it moves exactly when their timeline, shifts or hours do.
|
|
15
|
+
*/
|
|
16
|
+
personVersion: Map<string, number>;
|
|
17
|
+
/**
|
|
18
|
+
* The person-scoped half of `hardCompliant`'s answer, by instance then
|
|
19
|
+
* employee, with the person counter it was computed at. The crew-reading
|
|
20
|
+
* rules are cheap and asked live.
|
|
21
|
+
*/
|
|
22
|
+
hardCache: Map<string, Map<string, {
|
|
23
|
+
person: number;
|
|
24
|
+
ok: boolean;
|
|
25
|
+
}>>;
|
|
12
26
|
}
|
|
13
27
|
export declare function createState(ctx: ModelContext): InternalState;
|
|
14
28
|
export declare function pairKey(employeeId: string, instanceId: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/scheduling/engine/state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG1D,MAAM,WAAW,aAAc,SAAQ,WAAW;IAC9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,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAQrG"}
|
|
@@ -28,6 +28,8 @@ function createState(ctx) {
|
|
|
28
28
|
// boundary from the very first evaluation.
|
|
29
29
|
timelines: new timeline_1.TimelineIndex(ctx.history),
|
|
30
30
|
reasons: new Map(),
|
|
31
|
+
personVersion: new Map(),
|
|
32
|
+
hardCache: new Map(),
|
|
31
33
|
isAssigned(employeeId, instanceId) {
|
|
32
34
|
return assignments.get(instanceId)?.has(employeeId) ?? false;
|
|
33
35
|
},
|
|
@@ -52,6 +54,7 @@ function assign(state, employeeId, instanceId, reasons) {
|
|
|
52
54
|
// classification can put below the elapsed span.
|
|
53
55
|
state.minutesByEmployee.set(employeeId, (state.minutesByEmployee.get(employeeId) ?? 0) + inst.workingMinutes);
|
|
54
56
|
const personId = state.ctx.personIdOf.get(employeeId) ?? employeeId;
|
|
57
|
+
touch(state, personId);
|
|
55
58
|
state.timelines.add(personId, {
|
|
56
59
|
id: timelineEntryId(employeeId, instanceId),
|
|
57
60
|
start: inst.startMinute,
|
|
@@ -73,10 +76,14 @@ function unassign(state, employeeId, instanceId) {
|
|
|
73
76
|
state.byEmployee.get(employeeId)?.delete(instanceId);
|
|
74
77
|
state.minutesByEmployee.set(employeeId, (state.minutesByEmployee.get(employeeId) ?? 0) - inst.workingMinutes);
|
|
75
78
|
const personId = state.ctx.personIdOf.get(employeeId) ?? employeeId;
|
|
79
|
+
touch(state, personId);
|
|
76
80
|
state.timelines.remove(personId, timelineEntryId(employeeId, instanceId));
|
|
77
81
|
state.reasons.delete(pairKey(employeeId, instanceId));
|
|
78
82
|
}
|
|
79
83
|
exports.unassign = unassign;
|
|
84
|
+
function touch(state, personId) {
|
|
85
|
+
state.personVersion.set(personId, (state.personVersion.get(personId) ?? 0) + 1);
|
|
86
|
+
}
|
|
80
87
|
/**
|
|
81
88
|
* Timeline entries are keyed by employee *and* instance, not by instance alone:
|
|
82
89
|
* two contracts of the same person share a timeline, so an instance id on its
|
|
@@ -73,6 +73,8 @@ export declare class PersonTimeline {
|
|
|
73
73
|
* to save a walk over a few dozen items.
|
|
74
74
|
*/
|
|
75
75
|
workingMinutesIn(window: MinuteRange): number;
|
|
76
|
+
/** `workingMinutesIn` without the window object, for the probes below; assumes a clean index. */
|
|
77
|
+
private workingMinutesBetween;
|
|
76
78
|
/**
|
|
77
79
|
* Worst case of "working minutes in any window of `windowMinutes`" that
|
|
78
80
|
* overlaps `bounds` — the quantity a rolling average such as "≤48h in any
|
|
@@ -98,8 +100,12 @@ export declare class PersonTimeline {
|
|
|
98
100
|
* window over `bounds`, plus the bounds themselves. Sliding a window until
|
|
99
101
|
* its edge meets a boundary never reduces the extreme being sought, so this
|
|
100
102
|
* finite set contains the answer.
|
|
103
|
+
*
|
|
104
|
+
* Visited rather than collected: both callers take a max or a min, which a
|
|
105
|
+
* repeated edge cannot change, and these probes run for every candidate the
|
|
106
|
+
* search judges, so the set and array they used to build were pure garbage.
|
|
101
107
|
*/
|
|
102
|
-
private
|
|
108
|
+
private forEachCandidateWindowStart;
|
|
103
109
|
/** Entries intersecting `window`, in order. */
|
|
104
110
|
entriesIn(window: MinuteRange): TimelineEntry[];
|
|
105
111
|
/**
|
|
@@ -128,6 +134,8 @@ export declare class PersonTimeline {
|
|
|
128
134
|
* window has 7 days of rest, and a weekly-rest rule must see that.
|
|
129
135
|
*/
|
|
130
136
|
longestRestIn(window: MinuteRange): number;
|
|
137
|
+
/** `longestRestIn` without the window object or the intersecting-entries array; assumes a clean index. */
|
|
138
|
+
private longestRestBetween;
|
|
131
139
|
/**
|
|
132
140
|
* Smallest gap between `range` and any existing entry, ignoring `excludeId`.
|
|
133
141
|
* Returns `Infinity` when the timeline is otherwise empty, and 0 when
|
|
@@ -148,6 +156,20 @@ export declare class PersonTimeline {
|
|
|
148
156
|
* a day so the caller's clock owns DST, not this structure.
|
|
149
157
|
*/
|
|
150
158
|
longestConsecutiveDays(dayIndexOf: (minute: number) => number): number;
|
|
159
|
+
/**
|
|
160
|
+
* The longest run of consecutive weekends any entry falls in.
|
|
161
|
+
*
|
|
162
|
+
* "Every second weekend off" is the most commonly negotiated scheduling
|
|
163
|
+
* term in Europe and the one shape a *count* cannot express: three weekends
|
|
164
|
+
* each is satisfied exactly as well by three in a row as by alternating
|
|
165
|
+
* ones, and the arrangement is the thing people agreed to.
|
|
166
|
+
*
|
|
167
|
+
* Weekends are keyed by the week they belong to, so a Saturday and the
|
|
168
|
+
* Sunday after it are one weekend rather than two — otherwise working an
|
|
169
|
+
* ordinary weekend would breach "every second", which is the opposite of
|
|
170
|
+
* what it asks. A Sunday belongs to the week whose Saturday preceded it.
|
|
171
|
+
*/
|
|
172
|
+
longestConsecutiveWeekends(weekendKeyOf: (minute: number) => number | null): number;
|
|
151
173
|
/**
|
|
152
174
|
* First index that may overlap a window starting at `windowStart`.
|
|
153
175
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../../src/scheduling/engine/timeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../../src/scheduling/engine/timeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,gDAAgD;AAChD,MAAM,WAAW,aAAc,SAAQ,WAAW;IAC9C,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAC;IACX,wFAAwF;IACxF,cAAc,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;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C,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAY5D,4DAA4D;IAC5D,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,GAAG,MAAM;IAKnF;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,GAAG,MAAM;IAehE;;;;OAIG;IACH,sBAAsB,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM;IAiBtE;;;;;;;;;;;;OAYG;IACH,0BAA0B,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,MAAM;IAoBnF;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,OAAO;CAWlB;AAED;;;;;;GAMG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;gBAElD,OAAO,GAAE,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,CAAa;IAM7D,yDAAyD;IACzD,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc;IASrC,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAIjD,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAIlD,SAAS,IAAI,MAAM,EAAE;CAGxB"}
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
*/
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.TimelineIndex = exports.PersonTimeline = void 0;
|
|
31
|
-
const time_1 = require("../time");
|
|
32
31
|
/**
|
|
33
32
|
* One person's ordered, non-overlapping-by-construction spans, with prefix sums
|
|
34
33
|
* for O(log n) window queries.
|
|
@@ -90,15 +89,19 @@ class PersonTimeline {
|
|
|
90
89
|
*/
|
|
91
90
|
workingMinutesIn(window) {
|
|
92
91
|
this.ensureClean();
|
|
93
|
-
|
|
92
|
+
return this.workingMinutesBetween(window.start, window.end);
|
|
93
|
+
}
|
|
94
|
+
/** `workingMinutesIn` without the window object, for the probes below; assumes a clean index. */
|
|
95
|
+
workingMinutesBetween(start, end) {
|
|
96
|
+
if (end <= start || this.entries.length === 0)
|
|
94
97
|
return 0;
|
|
95
|
-
const first = this.firstOverlapping(
|
|
98
|
+
const first = this.firstOverlapping(start);
|
|
96
99
|
let total = 0;
|
|
97
100
|
for (let i = first; i < this.entries.length; i++) {
|
|
98
101
|
const entry = this.entries[i];
|
|
99
|
-
if (entry.start >=
|
|
102
|
+
if (entry.start >= end)
|
|
100
103
|
break;
|
|
101
|
-
total +=
|
|
104
|
+
total += proratedWorkingMinutesBetween(entry, start, end);
|
|
102
105
|
}
|
|
103
106
|
return total;
|
|
104
107
|
}
|
|
@@ -118,11 +121,12 @@ class PersonTimeline {
|
|
|
118
121
|
if (windowMinutes <= 0)
|
|
119
122
|
return 0;
|
|
120
123
|
let worst = 0;
|
|
121
|
-
|
|
122
|
-
const total = this.
|
|
124
|
+
const probe = (start) => {
|
|
125
|
+
const total = this.workingMinutesBetween(start, start + windowMinutes);
|
|
123
126
|
if (total > worst)
|
|
124
127
|
worst = total;
|
|
125
|
-
}
|
|
128
|
+
};
|
|
129
|
+
this.forEachCandidateWindowStart(windowMinutes, bounds, probe);
|
|
126
130
|
return worst;
|
|
127
131
|
}
|
|
128
132
|
/**
|
|
@@ -137,11 +141,12 @@ class PersonTimeline {
|
|
|
137
141
|
if (windowMinutes <= 0)
|
|
138
142
|
return Infinity;
|
|
139
143
|
let worst = Infinity;
|
|
140
|
-
|
|
141
|
-
const rest = this.
|
|
144
|
+
const probe = (start) => {
|
|
145
|
+
const rest = this.longestRestBetween(start, start + windowMinutes);
|
|
142
146
|
if (rest < worst)
|
|
143
147
|
worst = rest;
|
|
144
|
-
}
|
|
148
|
+
};
|
|
149
|
+
this.forEachCandidateWindowStart(windowMinutes, bounds, probe);
|
|
145
150
|
return worst;
|
|
146
151
|
}
|
|
147
152
|
/**
|
|
@@ -149,16 +154,25 @@ class PersonTimeline {
|
|
|
149
154
|
* window over `bounds`, plus the bounds themselves. Sliding a window until
|
|
150
155
|
* its edge meets a boundary never reduces the extreme being sought, so this
|
|
151
156
|
* finite set contains the answer.
|
|
157
|
+
*
|
|
158
|
+
* Visited rather than collected: both callers take a max or a min, which a
|
|
159
|
+
* repeated edge cannot change, and these probes run for every candidate the
|
|
160
|
+
* search judges, so the set and array they used to build were pure garbage.
|
|
152
161
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
162
|
+
forEachCandidateWindowStart(windowMinutes, bounds, visit) {
|
|
163
|
+
visit(bounds.start);
|
|
164
|
+
visit(bounds.end - windowMinutes);
|
|
165
|
+
const lowest = bounds.start - windowMinutes;
|
|
166
|
+
const highest = bounds.end + windowMinutes;
|
|
155
167
|
for (const entry of this.entries) {
|
|
156
|
-
|
|
168
|
+
// Sorted by start, so nothing after this can qualify either.
|
|
169
|
+
if (entry.start > highest)
|
|
170
|
+
break;
|
|
171
|
+
if (entry.end < lowest)
|
|
157
172
|
continue;
|
|
158
|
-
|
|
159
|
-
|
|
173
|
+
visit(entry.start);
|
|
174
|
+
visit(entry.end - windowMinutes);
|
|
160
175
|
}
|
|
161
|
-
return [...starts];
|
|
162
176
|
}
|
|
163
177
|
/** Entries intersecting `window`, in order. */
|
|
164
178
|
entriesIn(window) {
|
|
@@ -225,20 +239,31 @@ class PersonTimeline {
|
|
|
225
239
|
* window has 7 days of rest, and a weekly-rest rule must see that.
|
|
226
240
|
*/
|
|
227
241
|
longestRestIn(window) {
|
|
228
|
-
|
|
242
|
+
this.ensureClean();
|
|
243
|
+
return this.longestRestBetween(window.start, window.end);
|
|
244
|
+
}
|
|
245
|
+
/** `longestRestIn` without the window object or the intersecting-entries array; assumes a clean index. */
|
|
246
|
+
longestRestBetween(start, end) {
|
|
247
|
+
if (end <= start)
|
|
229
248
|
return 0;
|
|
230
|
-
const busy = this.entriesIn(window);
|
|
231
|
-
if (busy.length === 0)
|
|
232
|
-
return window.end - window.start;
|
|
233
249
|
let longest = 0;
|
|
234
|
-
let cursor =
|
|
235
|
-
|
|
250
|
+
let cursor = start;
|
|
251
|
+
let any = false;
|
|
252
|
+
for (let i = this.firstOverlapping(start); i < this.entries.length; i++) {
|
|
253
|
+
const entry = this.entries[i];
|
|
254
|
+
if (entry.start >= end)
|
|
255
|
+
break;
|
|
256
|
+
if (entry.end <= start)
|
|
257
|
+
continue;
|
|
258
|
+
any = true;
|
|
236
259
|
if (entry.start > cursor)
|
|
237
260
|
longest = Math.max(longest, entry.start - cursor);
|
|
238
261
|
cursor = Math.max(cursor, entry.end);
|
|
239
262
|
}
|
|
240
|
-
if (
|
|
241
|
-
|
|
263
|
+
if (!any)
|
|
264
|
+
return end - start;
|
|
265
|
+
if (end > cursor)
|
|
266
|
+
longest = Math.max(longest, end - cursor);
|
|
242
267
|
return longest;
|
|
243
268
|
}
|
|
244
269
|
/**
|
|
@@ -309,6 +334,39 @@ class PersonTimeline {
|
|
|
309
334
|
}
|
|
310
335
|
return longest;
|
|
311
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* The longest run of consecutive weekends any entry falls in.
|
|
339
|
+
*
|
|
340
|
+
* "Every second weekend off" is the most commonly negotiated scheduling
|
|
341
|
+
* term in Europe and the one shape a *count* cannot express: three weekends
|
|
342
|
+
* each is satisfied exactly as well by three in a row as by alternating
|
|
343
|
+
* ones, and the arrangement is the thing people agreed to.
|
|
344
|
+
*
|
|
345
|
+
* Weekends are keyed by the week they belong to, so a Saturday and the
|
|
346
|
+
* Sunday after it are one weekend rather than two — otherwise working an
|
|
347
|
+
* ordinary weekend would breach "every second", which is the opposite of
|
|
348
|
+
* what it asks. A Sunday belongs to the week whose Saturday preceded it.
|
|
349
|
+
*/
|
|
350
|
+
longestConsecutiveWeekends(weekendKeyOf) {
|
|
351
|
+
this.ensureClean();
|
|
352
|
+
const weekends = new Set();
|
|
353
|
+
for (const entry of this.entries) {
|
|
354
|
+
const key = weekendKeyOf(entry.start);
|
|
355
|
+
if (key !== null)
|
|
356
|
+
weekends.add(key);
|
|
357
|
+
}
|
|
358
|
+
const sorted = [...weekends].sort((a, b) => a - b);
|
|
359
|
+
let longest = 0;
|
|
360
|
+
let current = 0;
|
|
361
|
+
let previous;
|
|
362
|
+
for (const weekend of sorted) {
|
|
363
|
+
current = previous !== undefined && weekend === previous + 1 ? current + 1 : 1;
|
|
364
|
+
if (current > longest)
|
|
365
|
+
longest = current;
|
|
366
|
+
previous = weekend;
|
|
367
|
+
}
|
|
368
|
+
return longest;
|
|
369
|
+
}
|
|
312
370
|
/**
|
|
313
371
|
* First index that may overlap a window starting at `windowStart`.
|
|
314
372
|
*
|
|
@@ -405,11 +463,11 @@ function lowerBound(entries, start) {
|
|
|
405
463
|
* at a fraction, or only for actual call-outs), so a partial overlap is scaled
|
|
406
464
|
* by the same fraction rather than clipped to elapsed time.
|
|
407
465
|
*/
|
|
408
|
-
function
|
|
466
|
+
function proratedWorkingMinutesBetween(entry, start, end) {
|
|
409
467
|
const span = entry.end - entry.start;
|
|
410
468
|
if (span <= 0)
|
|
411
469
|
return 0;
|
|
412
|
-
const inside = (0,
|
|
470
|
+
const inside = Math.max(0, Math.min(entry.end, end) - Math.max(entry.start, start));
|
|
413
471
|
if (inside === span)
|
|
414
472
|
return entry.workingMinutes;
|
|
415
473
|
return (entry.workingMinutes * inside) / span;
|
|
@@ -8,11 +8,50 @@
|
|
|
8
8
|
* Two judgement paths always drift, and the one that drifts is the one nobody
|
|
9
9
|
* is reading at the time.
|
|
10
10
|
*/
|
|
11
|
-
import type { AssignmentPair, ConstraintViolation, RuleVerdict, SearchState } from '../types';
|
|
11
|
+
import type { AssignmentPair, ConstraintViolation, ModelContext, RuleVerdict, SchedulingConstraint, SearchState } from '../types';
|
|
12
12
|
/** Every rule's verdict on one pair, in registry order. */
|
|
13
13
|
export declare function verdictsFor(state: SearchState, pair: AssignmentPair): RuleVerdict[];
|
|
14
14
|
/** Breaches attributable to individual assignments in the committed roster. */
|
|
15
15
|
export declare function collectPairViolations(state: SearchState): ConstraintViolation[];
|
|
16
|
+
/** Every committed pair with every rule's verdict on it, in assignment order. */
|
|
17
|
+
export declare function collectPairVerdicts(state: SearchState): Array<{
|
|
18
|
+
pair: AssignmentPair;
|
|
19
|
+
verdicts: RuleVerdict[];
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* The failing verdicts of `collectPairVerdicts`, as violations. Split out so a
|
|
23
|
+
* caller that reports the verdicts too (`checkCompliance`) judges each pair
|
|
24
|
+
* once rather than twice — the verdicts are the expensive part.
|
|
25
|
+
*/
|
|
26
|
+
export declare function pairViolationsFrom(pairVerdicts: Array<{
|
|
27
|
+
pair: AssignmentPair;
|
|
28
|
+
verdicts: RuleVerdict[];
|
|
29
|
+
}>): ConstraintViolation[];
|
|
30
|
+
/** Whether any hard rule's `delta` objects to the pair — `hardCompliant`'s question, short-circuited. */
|
|
31
|
+
export declare function anyHardDelta(ctx: ModelContext, state: SearchState, pair: AssignmentPair): boolean;
|
|
32
|
+
/** Whether a built-in rule's per-pair judgement reads who else is on the shift. */
|
|
33
|
+
export declare function readsCrew(c: SchedulingConstraint): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* `anyHardDelta` over one half of the hard rules: those that read the crew of
|
|
36
|
+
* the instance, or those that read only the person. The two halves together
|
|
37
|
+
* are exactly `anyHardDelta`; splitting them lets a caller remember the
|
|
38
|
+
* person half for as long as the person's schedule stands still.
|
|
39
|
+
*/
|
|
40
|
+
export declare function anyHardDeltaIn(ctx: ModelContext, state: SearchState, pair: AssignmentPair, half: 'person' | 'crew'): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the pair is blocked: some verdict fails at hard severity, or some
|
|
43
|
+
* hard rule's `delta` objects. Equal to checking `verdictsFor(...).some(hard
|
|
44
|
+
* failure) || anyHardDelta(...)`, but stops at the first objection and reads a
|
|
45
|
+
* rule's verdict once where its delta is known to mirror it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function hardBlocked(state: SearchState, pair: AssignmentPair): boolean;
|
|
16
48
|
/** Breaches only a whole-roster view can see: coverage, quotas, team fairness. */
|
|
17
49
|
export declare function collectAggregateViolations(state: SearchState): ConstraintViolation[];
|
|
50
|
+
/**
|
|
51
|
+
* `anyHardDelta` for a pair whose `verdictsFor` is already in hand. A rule
|
|
52
|
+
* without a verdict had its verdict synthesised from its delta, and a
|
|
53
|
+
* `fromVerdict` rule's delta mirrors its verdict, so only a rule with its own
|
|
54
|
+
* independent delta is asked again.
|
|
55
|
+
*/
|
|
56
|
+
export declare function anyHardDeltaGiven(state: SearchState, pair: AssignmentPair, verdicts: RuleVerdict[]): boolean;
|
|
18
57
|
//# sourceMappingURL=verdicts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verdicts.d.ts","sourceRoot":"","sources":["../../../src/scheduling/engine/verdicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"verdicts.d.ts","sourceRoot":"","sources":["../../../src/scheduling/engine/verdicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGlI,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,GAAG,WAAW,EAAE,CAoBnF;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WA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