@shiodome47/planner 0.3.0 → 0.3.1

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/dist/core.js CHANGED
@@ -204,115 +204,123 @@ function oe(e) {
204
204
  return e.period === "year" && !!x(e.yearDay) && !x(e.yearDay).day;
205
205
  }
206
206
  // src/core/logic.ts
207
- var T = {
207
+ var se = {
208
208
  today: 0,
209
209
  week: 1,
210
210
  month: 2,
211
211
  year: 3,
212
212
  life: 4
213
213
  };
214
- function E(e, t) {
214
+ function T(e, t) {
215
215
  if (e === "today") return n(t);
216
216
  if (e === "tomorrow") return n(u(t, 1));
217
217
  if (e === "nextweek") return s("week", u(t, 7));
218
218
  if (e === "week") return s("week", t);
219
219
  if (e === "month") return s("month", t);
220
220
  }
221
- function se(e, t) {
221
+ function ce(e, t) {
222
222
  if (e === "today") return n(t);
223
223
  if (e === "week") return s("week", t);
224
224
  if (e === "month") return s("month", t);
225
225
  }
226
- function D(e, t) {
226
+ function E(e, t) {
227
227
  if (!(e.parentId || e.habitId) || !e.placedFor) return !1;
228
- let n = se(e.horizon, t);
228
+ let n = ce(e.horizon, t);
229
229
  return n !== void 0 && e.placedFor < n;
230
230
  }
231
- function O(e, t) {
232
- return j(e) ? k(e.due, t) : !M(e) && e.horizon === "week" && !!e.placedFor && e.placedFor > s("week", t);
231
+ function D(e, t) {
232
+ return A(e) ? O(e.due, t) : !j(e) && e.horizon === "week" && !!e.placedFor && e.placedFor > s("week", t);
233
233
  }
234
- function k(e, t) {
234
+ function O(e, t) {
235
235
  let r = u(i(t), 7);
236
236
  return e >= n(r) && e <= n(u(r, 6));
237
237
  }
238
- function A(e, t) {
239
- return j(e) ? h(e.due, t) === 1 : e.horizon === "today" && !!e.placedFor && e.placedFor > n(t);
238
+ function k(e, t) {
239
+ return A(e) ? h(e.due, t) === 1 : e.horizon === "today" && !!e.placedFor && e.placedFor > n(t);
240
240
  }
241
- function j(e) {
241
+ function A(e) {
242
242
  return !!e.due && !e.parentId && !e.habitId;
243
243
  }
244
- function M(e) {
244
+ function j(e) {
245
245
  return !!e.projectId && !e.parentId;
246
246
  }
247
- function N(e, t) {
247
+ function M(e, t) {
248
248
  let r = h(e, t);
249
249
  return r === null ? "life" : r <= 1 ? "today" : e <= n(u(i(t), 13)) ? "week" : r <= 92 ? "month" : r <= 366 ? "year" : "life";
250
250
  }
251
- function P(e, t) {
252
- return j(e) ? N(e.due, t) : M(e) ? "pool" : e.horizon;
251
+ function N(e, t) {
252
+ return A(e) ? M(e.due, t) : j(e) ? "pool" : e.horizon;
253
253
  }
254
- function ce(e, t) {
254
+ function le(e, t) {
255
255
  if (!e.doneAt) return !0;
256
- let n = P(e, t);
256
+ let n = N(e, t);
257
257
  return n === "pool" || d(c[n], e.doneAt, t);
258
258
  }
259
- function F(e, t) {
260
- return !D(e, t) && ce(e, t);
259
+ function P(e, t) {
260
+ return !E(e, t) && le(e, t);
261
261
  }
262
- function I(e, t, n) {
263
- return t.find((t) => t.parentId === e.id && !D(t, n));
262
+ function F(e, t, n) {
263
+ return t.find((t) => t.parentId === e.id && !E(t, n));
264
264
  }
265
- function L(t) {
265
+ function I(t) {
266
266
  if (t === "pool") return [...e];
267
267
  if (t === "today") return [];
268
- let n = T[t];
269
- return e.filter((e) => T[e] < n).flatMap((e) => e === "today" ? ["today", "tomorrow"] : e === "week" ? ["week", "nextweek"] : [e]);
268
+ let n = se[t];
269
+ return e.filter((e) => se[e] < n).flatMap((e) => e === "today" ? ["today", "tomorrow"] : e === "week" ? ["week", "nextweek"] : [e]);
270
270
  }
271
- function le(e) {
272
- return L(e).filter((e) => e !== "tomorrow" && e !== "nextweek").at(-1);
271
+ function ue(e) {
272
+ return I(e).filter((e) => e !== "tomorrow" && e !== "nextweek").at(-1);
273
273
  }
274
- function R(e) {
274
+ function de(e) {
275
+ let n = new Set(e), r = {}, i = [];
276
+ for (let e of t) n.has(e) ? (i.length && (r[e] = i), i = []) : i.push(e);
277
+ return {
278
+ before: r,
279
+ after: n.size ? i : []
280
+ };
281
+ }
282
+ function L(e) {
275
283
  let n = [];
276
- for (let r of t) e.filter((e) => e.priority === r).sort(z).forEach((e, t) => n.push({
284
+ for (let r of t) e.filter((e) => e.priority === r).sort(R).forEach((e, t) => n.push({
277
285
  task: e,
278
286
  label: `${r}${t + 1}`
279
287
  }));
280
288
  return n;
281
289
  }
282
- function z(e, t) {
290
+ function R(e, t) {
283
291
  return e.order - t.order || e.createdAt.localeCompare(t.createdAt);
284
292
  }
285
- function ue(t, n) {
293
+ function fe(t, n) {
286
294
  let r = new Map(t.projects.map((e) => [e.id, e])), i = new Map(t.tasks.map((e) => [e.id, e])), a = new Map(t.habits.map((e) => [e.id, e])), o = (e) => {
287
295
  let t = a.get(e);
288
296
  return t ? _(t.period) : void 0;
289
297
  }, s = (e, a) => {
290
- let s = I(e, t.tasks, n), c = e.parentId ? i.get(e.parentId) : void 0;
298
+ let s = F(e, t.tasks, n), c = e.parentId ? i.get(e.parentId) : void 0;
291
299
  return {
292
300
  task: e,
293
- horizon: P(e, n),
301
+ horizon: N(e, n),
294
302
  label: a,
295
303
  done: !!e.doneAt,
296
304
  faded: !!s && !e.doneAt,
297
- placedTo: s ? A(s, n) ? "tomorrow" : O(s, n) ? "nextweek" : s.horizon : void 0,
298
- from: c ? P(c, n) : e.habitId ? o(e.habitId) : void 0,
305
+ placedTo: s ? k(s, n) ? "tomorrow" : D(s, n) ? "nextweek" : s.horizon : void 0,
306
+ from: c ? N(c, n) : e.habitId ? o(e.habitId) : void 0,
299
307
  project: e.projectId ? r.get(e.projectId) : void 0
300
308
  };
301
309
  };
302
310
  return e.map((e) => {
303
- let i = t.tasks.filter((t) => P(t, n) === e && F(t, n)), a = e === "today" ? i.filter((e) => !A(e, n)) : e === "week" ? i.filter((e) => !O(e, n)) : i, o = e === "today" ? i.filter((e) => A(e, n)) : [], c = e === "week" ? i.filter((e) => O(e, n)) : [], u = l[e], f = (e, i, a) => {
304
- let o = d(e.period, e.checkedAt, n), s = X(e, t.tasks, n);
311
+ let i = t.tasks.filter((t) => N(t, n) === e && P(t, n)), a = e === "today" ? i.filter((e) => !k(e, n)) : e === "week" ? i.filter((e) => !D(e, n)) : i, o = e === "today" ? i.filter((e) => k(e, n)) : [], c = e === "week" ? i.filter((e) => D(e, n)) : [], u = l[e], f = (e, i, a) => {
312
+ let o = d(e.period, e.checkedAt, n), s = Y(e, t.tasks, n);
305
313
  return {
306
314
  habit: e,
307
315
  checked: o,
308
316
  project: e.projectId ? r.get(e.projectId) : void 0,
309
317
  faded: !!s && !o && !i,
310
- placedTo: s && !i ? A(s, n) ? "tomorrow" : O(s, n) ? "nextweek" : s.horizon : void 0,
318
+ placedTo: s && !i ? k(s, n) ? "tomorrow" : D(s, n) ? "nextweek" : s.horizon : void 0,
311
319
  auto: i,
312
320
  dueDay: a ?? C(e, n)
313
321
  };
314
- }, p = t.habits.filter((e) => !e.endedAt), m = u ? p.filter((e) => e.period === u).sort(z).map((e) => f(e, !1)) : [], h = [];
315
- for (let t of p.filter((e) => e.period !== u).sort(z)) {
322
+ }, p = t.habits.filter((e) => !e.endedAt), m = u ? p.filter((e) => e.period === u).sort(R).map((e) => f(e, !1)) : [], h = [];
323
+ for (let t of p.filter((e) => e.period !== u).sort(R)) {
316
324
  let r = w(t, e, n);
317
325
  r && h.push(f(t, !0, r));
318
326
  }
@@ -320,45 +328,45 @@ function ue(t, n) {
320
328
  horizon: e,
321
329
  habitPeriod: u,
322
330
  habits: [...m, ...h],
323
- tasks: R(a).map(({ task: e, label: t }) => s(e, t)),
324
- tomorrow: R(o).map(({ task: e, label: t }) => s(e, t)),
325
- nextWeek: R(c).map(({ task: e, label: t }) => s(e, t)),
326
- ended: u ? K(t.habits.filter((e) => e.period === u)) : []
331
+ tasks: L(a).map(({ task: e, label: t }) => s(e, t)),
332
+ tomorrow: L(o).map(({ task: e, label: t }) => s(e, t)),
333
+ nextWeek: L(c).map(({ task: e, label: t }) => s(e, t)),
334
+ ended: u ? G(t.habits.filter((e) => e.period === u)) : []
327
335
  };
328
336
  });
329
337
  }
330
- var B = (e) => e.toISOString();
331
- function V(e, t, n) {
338
+ var z = (e) => e.toISOString();
339
+ function B(e, t, n) {
332
340
  let r = e.filter((e) => e.horizon === t && e.priority === n);
333
341
  return r.length === 0 ? 0 : Math.max(...r.map((e) => e.order)) + 1;
334
342
  }
335
- function H(e, t, n) {
336
- let r = B(n);
343
+ function V(e, t, n) {
344
+ let r = z(n);
337
345
  return {
338
346
  id: crypto.randomUUID(),
339
347
  title: t.title,
340
348
  horizon: t.horizon,
341
349
  priority: t.priority,
342
- order: V(e.tasks, t.horizon, t.priority),
343
- ...t.tomorrow ? { placedFor: E("tomorrow", n) } : {},
344
- ...t.nextWeek ? { placedFor: E("nextweek", n) } : {},
350
+ order: B(e.tasks, t.horizon, t.priority),
351
+ ...t.tomorrow ? { placedFor: T("tomorrow", n) } : {},
352
+ ...t.nextWeek ? { placedFor: T("nextweek", n) } : {},
345
353
  ...t.projectId ? { projectId: t.projectId } : {},
346
354
  ...t.due ? { due: t.due } : {},
347
355
  createdAt: r,
348
356
  updatedAt: r
349
357
  };
350
358
  }
351
- function de(e, t, n, r) {
352
- let i = B(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = I(t, e.tasks, r), s = o && !o.doneAt ? U(e.tasks, o.id, r).concat(o.id) : [];
359
+ function pe(e, t, n, r) {
360
+ let i = z(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = F(t, e.tasks, r), s = o && !o.doneAt ? H(e.tasks, o.id, r).concat(o.id) : [];
353
361
  return {
354
362
  tasks: [{
355
363
  id: crypto.randomUUID(),
356
364
  title: t.title,
357
365
  horizon: a,
358
366
  priority: t.priority,
359
- order: V(e.tasks, a, t.priority),
367
+ order: B(e.tasks, a, t.priority),
360
368
  parentId: t.id,
361
- ...E(n, r) ? { placedFor: E(n, r) } : {},
369
+ ...T(n, r) ? { placedFor: T(n, r) } : {},
362
370
  ...t.projectId ? { projectId: t.projectId } : {},
363
371
  ...t.due ? { due: t.due } : {},
364
372
  ...t.note ? { note: t.note } : {},
@@ -368,28 +376,28 @@ function de(e, t, n, r) {
368
376
  deleteTaskIds: s
369
377
  };
370
378
  }
371
- function fe(e, t, n) {
372
- return { deleteTaskIds: [t.id, ...U(e.tasks, t.id, n)] };
379
+ function me(e, t, n) {
380
+ return { deleteTaskIds: [t.id, ...H(e.tasks, t.id, n)] };
373
381
  }
374
- function pe(e, t, n, r) {
382
+ function he(e, t, n, r) {
375
383
  if (t.horizon === n) return {};
376
384
  let { placedFor: i, ...a } = t;
377
385
  return { tasks: [{
378
386
  ...a,
379
387
  horizon: n,
380
- order: V(e.tasks, n, t.priority),
381
- updatedAt: B(r)
388
+ order: B(e.tasks, n, t.priority),
389
+ updatedAt: z(r)
382
390
  }] };
383
391
  }
384
- function U(e, t, n) {
392
+ function H(e, t, n) {
385
393
  let r = [];
386
- for (let i of e) i.parentId === t && !D(i, n) && r.push(i.id, ...U(e, i.id, n));
394
+ for (let i of e) i.parentId === t && !E(i, n) && r.push(i.id, ...H(e, i.id, n));
387
395
  return r;
388
396
  }
389
- function W(e, t, n) {
390
- let r = new Map(e.tasks.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set([t.id, ...U(e.tasks, t.id, n)]);
397
+ function U(e, t, n) {
398
+ let r = new Map(e.tasks.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set([t.id, ...H(e.tasks, t.id, n)]);
391
399
  for (let e = t.parentId ? r.get(t.parentId) : void 0; e; e = e.parentId ? r.get(e.parentId) : void 0) i.add(e.id);
392
- let a = B(n), o = !t.doneAt, s = [...i].map((e) => r.get(e)).filter((e) => !!e).map((e) => {
400
+ let a = z(n), o = !t.doneAt, s = [...i].map((e) => r.get(e)).filter((e) => !!e).map((e) => {
393
401
  let { doneAt: t, ...n } = e;
394
402
  return o ? {
395
403
  ...n,
@@ -402,13 +410,13 @@ function W(e, t, n) {
402
410
  }), c = t.habitId ? e.habits.find((e) => e.id === t.habitId) : void 0;
403
411
  return c && d(c.period, c.checkedAt, n) !== o ? {
404
412
  tasks: s,
405
- habits: [G(c, n)]
413
+ habits: [W(c, n)]
406
414
  } : { tasks: s };
407
415
  }
408
- function me(e, t, n, r) {
409
- let i = e.tasks.filter((e) => e.horizon === t.horizon && e.priority === t.priority && F(e, r) && A(e, r) === A(t, r)).sort(z), a = i.findIndex((e) => e.id === t.id), o = a + n;
416
+ function ge(e, t, n, r) {
417
+ let i = e.tasks.filter((e) => e.horizon === t.horizon && e.priority === t.priority && P(e, r) && k(e, r) === k(t, r)).sort(R), a = i.findIndex((e) => e.id === t.id), o = a + n;
410
418
  if (a < 0 || o < 0 || o >= i.length) return {};
411
- let s = B(r), c = [...i];
419
+ let s = z(r), c = [...i];
412
420
  [c[a], c[o]] = [c[o], c[a]];
413
421
  let l = new Map(i.map((e) => [e.id, e.order]));
414
422
  return { tasks: c.map((e, t) => ({
@@ -417,19 +425,19 @@ function me(e, t, n, r) {
417
425
  updatedAt: s
418
426
  })).filter((e) => l.get(e.id) !== e.order) };
419
427
  }
420
- function he(e, t, n, r) {
428
+ function _e(e, t, n, r) {
421
429
  return t.priority === n ? {} : { tasks: [{
422
430
  ...t,
423
431
  priority: n,
424
- order: V(e.tasks, t.horizon, n),
425
- updatedAt: B(r)
432
+ order: B(e.tasks, t.horizon, n),
433
+ updatedAt: z(r)
426
434
  }] };
427
435
  }
428
- function ge(e, t, n) {
429
- return { deleteTaskIds: [t.id, ...U(e.tasks, t.id, n)] };
436
+ function ve(e, t, n) {
437
+ return { deleteTaskIds: [t.id, ...H(e.tasks, t.id, n)] };
430
438
  }
431
- function _e(e, t, n) {
432
- let r = e.habits.filter((e) => e.period === t.period), i = B(n);
439
+ function ye(e, t, n) {
440
+ let r = e.habits.filter((e) => e.period === t.period), i = z(n);
433
441
  return {
434
442
  id: crypto.randomUUID(),
435
443
  title: t.title,
@@ -440,8 +448,8 @@ function _e(e, t, n) {
440
448
  updatedAt: i
441
449
  };
442
450
  }
443
- function G(e, t) {
444
- let { checkedAt: r, ...i } = e, a = B(t), o = e.history ?? [];
451
+ function W(e, t) {
452
+ let { checkedAt: r, ...i } = e, a = z(t), o = e.history ?? [];
445
453
  if (d(e.period, e.checkedAt, t)) {
446
454
  let t = n(new Date(e.checkedAt));
447
455
  return {
@@ -458,26 +466,26 @@ function G(e, t) {
458
466
  updatedAt: a
459
467
  };
460
468
  }
461
- var ve = 800;
462
- function K(e) {
469
+ var be = 800;
470
+ function G(e) {
463
471
  return e.filter((e) => e.endedAt).sort((e, t) => t.endedAt.localeCompare(e.endedAt));
464
472
  }
465
- function ye(e, t, n, r, i) {
466
- let a = B(i), { endNote: o, ...s } = t, c = r.trim(), l = {
473
+ function xe(e, t, n, r, i) {
474
+ let a = z(i), { endNote: o, ...s } = t, c = r.trim(), l = {
467
475
  ...s,
468
476
  endedAt: t.endedAt ?? a,
469
477
  endedAs: n,
470
478
  ...c ? { endNote: c } : {},
471
479
  updatedAt: a
472
- }, u = t.endedAt ? [] : e.tasks.filter((e) => e.habitId === t.id && !e.doneAt && !D(e, i));
480
+ }, u = t.endedAt ? [] : e.tasks.filter((e) => e.habitId === t.id && !e.doneAt && !E(e, i));
473
481
  return {
474
482
  habits: [l],
475
483
  ...u.length ? { deleteTaskIds: u.map((e) => e.id) } : {}
476
484
  };
477
485
  }
478
- function be(e, t, r) {
486
+ function Se(e, t, r) {
479
487
  if (!t.endedAt) return {};
480
- let i = B(r), { endedAt: a, endedAs: o, endNote: s, breaks: c, ...l } = t, u = n(new Date(a)) === n(r), d = {
488
+ let i = z(r), { endedAt: a, endedAs: o, endNote: s, breaks: c, ...l } = t, u = n(new Date(a)) === n(r), d = {
481
489
  endedAt: a,
482
490
  endedAs: o ?? "paused",
483
491
  ...s ? { endNote: s } : {},
@@ -490,8 +498,8 @@ function be(e, t, r) {
490
498
  updatedAt: i
491
499
  }] };
492
500
  }
493
- function xe(e, t, n) {
494
- let r = B(n), i = e.projects.filter((e) => e.parentId === t.parentId);
501
+ function Ce(e, t, n) {
502
+ let r = z(n), i = e.projects.filter((e) => e.parentId === t.parentId);
495
503
  return {
496
504
  id: crypto.randomUUID(),
497
505
  name: t.name,
@@ -502,56 +510,56 @@ function xe(e, t, n) {
502
510
  updatedAt: r
503
511
  };
504
512
  }
505
- function q(e, t) {
513
+ function K(e, t) {
506
514
  return e.projects.filter((e) => e.parentId === t).sort((e, t) => e.order - t.order);
507
515
  }
508
- function Se(e) {
516
+ function we(e) {
509
517
  let t = new Set(e.projects.map((e) => e.id));
510
518
  return e.projects.filter((e) => !e.parentId || !t.has(e.parentId)).sort((e, t) => e.order - t.order);
511
519
  }
512
- function Ce(e, t) {
513
- let n = /* @__PURE__ */ new Set([t.id, ...q(e, t.id).map((e) => e.id)]);
520
+ function Te(e, t) {
521
+ let n = /* @__PURE__ */ new Set([t.id, ...K(e, t.id).map((e) => e.id)]);
514
522
  return {
515
523
  deleteProjectIds: [...n],
516
524
  deleteTaskIds: e.tasks.filter((e) => e.projectId && n.has(e.projectId)).map((e) => e.id),
517
525
  deleteHabitIds: e.habits.filter((e) => e.projectId && n.has(e.projectId)).map((e) => e.id)
518
526
  };
519
527
  }
520
- function we(e, t, n, r) {
521
- if (n === t.parentId || n === t.id || n && q(e, t.id).length > 0) return {};
528
+ function Ee(e, t, n, r) {
529
+ if (n === t.parentId || n === t.id || n && K(e, t.id).length > 0) return {};
522
530
  let i = e.projects.filter((e) => e.parentId === n && e.id !== t.id), { parentId: a, ...o } = t;
523
531
  return { projects: [{
524
532
  ...o,
525
533
  ...n ? { parentId: n } : {},
526
534
  order: i.length === 0 ? 0 : Math.max(...i.map((e) => e.order)) + 1,
527
- updatedAt: B(r)
535
+ updatedAt: z(r)
528
536
  }] };
529
537
  }
530
- function J(e, t = [], n = []) {
538
+ function q(e, t = [], n = []) {
531
539
  let r = new Set(n), i = new Map(t.map((e) => [e.id, e])), a = e.filter((e) => !r.has(e.id)).map((e) => i.get(e.id) ?? e), o = t.filter((t) => !e.some((e) => e.id === t.id) && !r.has(t.id));
532
540
  return [...a, ...o];
533
541
  }
534
- function Te(e, t) {
542
+ function De(e, t) {
535
543
  return {
536
544
  ...e,
537
- tasks: J(e.tasks, t.tasks, t.deleteTaskIds),
538
- habits: J(e.habits, t.habits, t.deleteHabitIds),
539
- projects: J(e.projects, t.projects, t.deleteProjectIds)
545
+ tasks: q(e.tasks, t.tasks, t.deleteTaskIds),
546
+ habits: q(e.habits, t.habits, t.deleteHabitIds),
547
+ projects: q(e.projects, t.projects, t.deleteProjectIds)
540
548
  };
541
549
  }
542
- function Y(e, t, n) {
550
+ function J(e, t, n) {
543
551
  let r = [...e], [i] = r.splice(t, 1);
544
552
  return r.splice(n, 0, i), r;
545
553
  }
546
- function Ee(e, n, r, i, a) {
554
+ function Oe(e, n, r, i, a) {
547
555
  let o = n.indexOf(r), s = n.indexOf(i);
548
556
  if (o < 0 || s < 0 || o === s) return {};
549
557
  let c = new Map(e.tasks.map((e) => [e.id, e])), l = c.get(i), u = c.get(r);
550
558
  if (!l || !u) return {};
551
- let d = l.priority, f = Y(n, o, s).map((e) => c.get(e)).filter((e) => !!e).map((e) => e.id === r ? {
559
+ let d = l.priority, f = J(n, o, s).map((e) => c.get(e)).filter((e) => !!e).map((e) => e.id === r ? {
552
560
  ...e,
553
561
  priority: d
554
- } : e), p = B(a), m = [];
562
+ } : e), p = z(a), m = [];
555
563
  for (let e of t) f.filter((t) => t.priority === e).forEach((e, t) => {
556
564
  let n = c.get(e.id);
557
565
  (n.order !== t || n.priority !== e.priority) && m.push({
@@ -562,11 +570,11 @@ function Ee(e, n, r, i, a) {
562
570
  });
563
571
  return { tasks: m };
564
572
  }
565
- function De(e, t, n, r, i) {
573
+ function ke(e, t, n, r, i) {
566
574
  let a = t.indexOf(n), o = t.indexOf(r);
567
575
  if (a < 0 || o < 0 || a === o) return {};
568
- let s = new Map(e.habits.map((e) => [e.id, e])), c = B(i);
569
- return { habits: Y(t, a, o).map((e, t) => ({
576
+ let s = new Map(e.habits.map((e) => [e.id, e])), c = z(i);
577
+ return { habits: J(t, a, o).map((e, t) => ({
570
578
  habit: s.get(e),
571
579
  order: t
572
580
  })).filter((e) => !!e.habit && e.habit.order !== e.order).map(({ habit: e, order: t }) => ({
@@ -575,11 +583,11 @@ function De(e, t, n, r, i) {
575
583
  updatedAt: c
576
584
  })) };
577
585
  }
578
- function Oe(e, t, n, r) {
586
+ function Ae(e, t, n, r) {
579
587
  let i = e.projects.find((e) => e.id === t), a = [...e.projects].filter((e) => e.parentId === i?.parentId).sort((e, t) => e.order - t.order).map((e) => e.id), o = a.indexOf(t), s = a.indexOf(n);
580
588
  if (o < 0 || s < 0 || o === s) return {};
581
- let c = new Map(e.projects.map((e) => [e.id, e])), l = B(r);
582
- return { projects: Y(a, o, s).map((e, t) => ({
589
+ let c = new Map(e.projects.map((e) => [e.id, e])), l = z(r);
590
+ return { projects: J(a, o, s).map((e, t) => ({
583
591
  project: c.get(e),
584
592
  order: t
585
593
  })).filter(({ project: e, order: t }) => e.order !== t).map(({ project: e, order: t }) => ({
@@ -588,23 +596,23 @@ function Oe(e, t, n, r) {
588
596
  updatedAt: l
589
597
  })) };
590
598
  }
591
- function X(e, t, n) {
592
- return t.find((t) => t.habitId === e.id && !D(t, n));
599
+ function Y(e, t, n) {
600
+ return t.find((t) => t.habitId === e.id && !E(t, n));
593
601
  }
594
- function ke(e) {
595
- return L(_(e.period));
602
+ function je(e) {
603
+ return I(_(e.period));
596
604
  }
597
- function Ae(e, t, n, r) {
598
- let i = B(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = X(t, e.tasks, r);
605
+ function Me(e, t, n, r) {
606
+ let i = z(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = Y(t, e.tasks, r);
599
607
  return {
600
608
  tasks: [{
601
609
  id: crypto.randomUUID(),
602
610
  title: t.title,
603
611
  horizon: a,
604
612
  priority: "C",
605
- order: V(e.tasks, a, "C"),
613
+ order: B(e.tasks, a, "C"),
606
614
  habitId: t.id,
607
- ...E(n, r) ? { placedFor: E(n, r) } : {},
615
+ ...T(n, r) ? { placedFor: T(n, r) } : {},
608
616
  ...t.projectId ? { projectId: t.projectId } : {},
609
617
  ...t.note ? { note: t.note } : {},
610
618
  createdAt: i,
@@ -613,10 +621,10 @@ function Ae(e, t, n, r) {
613
621
  deleteTaskIds: o && !o.doneAt ? [o.id] : []
614
622
  };
615
623
  }
616
- function je(e, t, n) {
617
- let r = G(t, n), i = d(r.period, r.checkedAt, n), a = X(t, e.tasks, n);
624
+ function Ne(e, t, n) {
625
+ let r = W(t, n), i = d(r.period, r.checkedAt, n), a = Y(t, e.tasks, n);
618
626
  if (!a || !!a.doneAt === i) return { habits: [r] };
619
- let o = B(n), { doneAt: s, ...c } = a;
627
+ let o = z(n), { doneAt: s, ...c } = a;
620
628
  return {
621
629
  habits: [r],
622
630
  tasks: [i ? {
@@ -629,8 +637,8 @@ function je(e, t, n) {
629
637
  }]
630
638
  };
631
639
  }
632
- function Me(e, t, n) {
633
- let r = H(e, {
640
+ function Pe(e, t, n) {
641
+ let r = V(e, {
634
642
  title: t.title,
635
643
  horizon: _(t.period),
636
644
  priority: "C",
@@ -644,10 +652,10 @@ function Me(e, t, n) {
644
652
  deleteHabitIds: [t.id]
645
653
  };
646
654
  }
647
- function Ne(e, t) {
655
+ function Fe(e, t) {
648
656
  if (e.day) return b(e.day, t);
649
657
  }
650
- function Pe(e, t) {
658
+ function Ie(e, t) {
651
659
  let { due: n, ...r } = e, i = (/* @__PURE__ */ new Date()).toISOString();
652
660
  return { tasks: [t ? {
653
661
  ...r,
@@ -658,7 +666,7 @@ function Pe(e, t) {
658
666
  updatedAt: i
659
667
  }] };
660
668
  }
661
- function Fe(e, t) {
669
+ function Le(e, t) {
662
670
  let { day: n, ...r } = e;
663
671
  return {
664
672
  ...r,
@@ -666,8 +674,8 @@ function Fe(e, t) {
666
674
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
667
675
  };
668
676
  }
669
- function Ie(e, t, r) {
670
- let i = n(t), a = e.history ?? [], o = B(r), c = s(e.period, t) === s(e.period, r);
677
+ function Re(e, t, r) {
678
+ let i = n(t), a = e.history ?? [], o = z(r), c = s(e.period, t) === s(e.period, r);
671
679
  if (a.includes(i)) {
672
680
  let { checkedAt: t, ...r } = e, s = a.filter((e) => e !== i);
673
681
  return {
@@ -679,17 +687,17 @@ function Ie(e, t, r) {
679
687
  let l = [...a, i].sort().slice(-800), u = i === n(r) ? r : new Date(t.getFullYear(), t.getMonth(), t.getDate(), 12), f = c && !d(e.period, e.checkedAt, r);
680
688
  return {
681
689
  ...e,
682
- ...f ? { checkedAt: B(u) } : {},
690
+ ...f ? { checkedAt: z(u) } : {},
683
691
  history: l,
684
692
  updatedAt: o
685
693
  };
686
694
  }
687
- function Le(e, t, r, i) {
688
- return W(e, t, n(r) === n(i) ? i : new Date(r.getFullYear(), r.getMonth(), r.getDate(), 12));
695
+ function ze(e, t, r, i) {
696
+ return U(e, t, n(r) === n(i) ? i : new Date(r.getFullYear(), r.getMonth(), r.getDate(), 12));
689
697
  }
690
- function Re(e, t) {
691
- let r = B(t), i = n(u(t, 1));
692
- return j(e) ? { tasks: [{
698
+ function Be(e, t) {
699
+ let r = z(t), i = n(u(t, 1));
700
+ return A(e) ? { tasks: [{
693
701
  ...e,
694
702
  due: i,
695
703
  updatedAt: r
@@ -700,9 +708,9 @@ function Re(e, t) {
700
708
  updatedAt: r
701
709
  }] };
702
710
  }
703
- function ze(e, t) {
704
- let r = B(t);
705
- if (j(e)) return { tasks: [{
711
+ function Ve(e, t) {
712
+ let r = z(t);
713
+ if (A(e)) return { tasks: [{
706
714
  ...e,
707
715
  due: n(t),
708
716
  updatedAt: r
@@ -719,22 +727,22 @@ function ze(e, t) {
719
727
  updatedAt: r
720
728
  }] };
721
729
  }
722
- function Be(e, t) {
723
- let n = e.tasks.filter((e) => M(e) && e.projectId === t), r = n.filter((e) => !e.doneAt), i = (e) => e.goalOrder ?? (e.due ? 2 ** 53 - 1 : -(2 ** 53 - 1)), a = [...r].sort((e, t) => i(e) - i(t) || e.createdAt.localeCompare(t.createdAt)), o = r.filter((e) => e.due).sort((e, t) => t.due.localeCompare(e.due) || e.createdAt.localeCompare(t.createdAt)), s = 0;
730
+ function He(e, t) {
731
+ let n = e.tasks.filter((e) => j(e) && e.projectId === t), r = n.filter((e) => !e.doneAt), i = (e) => e.goalOrder ?? (e.due ? 2 ** 53 - 1 : -(2 ** 53 - 1)), a = [...r].sort((e, t) => i(e) - i(t) || e.createdAt.localeCompare(t.createdAt)), o = r.filter((e) => e.due).sort((e, t) => t.due.localeCompare(e.due) || e.createdAt.localeCompare(t.createdAt)), s = 0;
724
732
  return {
725
733
  open: a.map((e) => e.due ? o[s++] : e),
726
734
  done: n.filter((e) => e.doneAt).sort((e, t) => (t.due ?? "").localeCompare(e.due ?? "") || e.createdAt.localeCompare(t.createdAt))
727
735
  };
728
736
  }
729
- function Ve(e, t) {
730
- let n = e.tasks.filter((e) => e.projectId === t && e.goalOrder !== void 0).map((e) => e.goalOrder), r = e.tasks.filter((e) => M(e) && e.projectId === t).length;
737
+ function Ue(e, t) {
738
+ let n = e.tasks.filter((e) => e.projectId === t && e.goalOrder !== void 0).map((e) => e.goalOrder), r = e.tasks.filter((e) => j(e) && e.projectId === t).length;
731
739
  return Math.max(r, ...n.map((e) => e + 1));
732
740
  }
733
- function He(e, t, n, r, i) {
741
+ function We(e, t, n, r, i) {
734
742
  let a = t.indexOf(n), o = t.indexOf(r);
735
743
  if (a < 0 || o < 0 || a === o) return {};
736
- let s = new Map(e.tasks.map((e) => [e.id, e])), c = B(i);
737
- return { tasks: Y(t, a, o).map((e, t) => ({
744
+ let s = new Map(e.tasks.map((e) => [e.id, e])), c = z(i);
745
+ return { tasks: J(t, a, o).map((e, t) => ({
738
746
  task: s.get(e),
739
747
  goalOrder: t
740
748
  })).filter((e) => !!e.task && e.task.goalOrder !== e.goalOrder).map(({ task: e, goalOrder: t }) => ({
@@ -744,22 +752,22 @@ function He(e, t, n, r, i) {
744
752
  })) };
745
753
  }
746
754
  // src/core/labels.ts
747
- var Z = {
755
+ var Ge = {
748
756
  today: "今日",
749
757
  week: "今週",
750
758
  month: "数か月",
751
759
  year: "今年",
752
760
  life: "一生"
753
- }, Ue = {
761
+ }, Ke = {
754
762
  today: "Action",
755
763
  week: "Week",
756
764
  month: "Month",
757
765
  year: "Year",
758
766
  life: "⭐"
759
- }, We = {
760
- ...Z,
767
+ }, qe = {
768
+ ...Ge,
761
769
  pool: "未定(置き場)"
762
- }, Ge = {
770
+ }, Je = {
763
771
  today: "今日やる",
764
772
  tomorrow: "明日やる",
765
773
  nextweek: "来週やる",
@@ -767,7 +775,7 @@ var Z = {
767
775
  month: "数か月以内にやる",
768
776
  year: "今年やる",
769
777
  life: "一生のうちに"
770
- }, Ke = {
778
+ }, Ye = {
771
779
  today: "今日",
772
780
  tomorrow: "明日",
773
781
  nextweek: "来週",
@@ -775,25 +783,25 @@ var Z = {
775
783
  month: "数か月",
776
784
  year: "今年",
777
785
  life: "一生"
778
- }, qe = {
786
+ }, Xe = {
779
787
  A: "重要・緊急",
780
788
  B: "重要",
781
789
  C: "通常",
782
790
  D: "低",
783
791
  P: "Private"
784
- }, Je = {
792
+ }, Ze = {
785
793
  day: "毎日",
786
794
  week: "毎週",
787
795
  month: "毎月",
788
796
  year: "毎年"
789
797
  };
790
798
  // src/core/review.ts
791
- function Q(e) {
799
+ function X(e) {
792
800
  let t = new Set(e.history ?? []);
793
801
  return e.checkedAt && t.add(n(new Date(e.checkedAt))), t;
794
802
  }
795
- function Ye(e, t) {
796
- let r = Q(e);
803
+ function Qe(e, t) {
804
+ let r = X(e);
797
805
  if (e.period === "day") return r.has(n(t));
798
806
  let i = s(e.period, t);
799
807
  for (let t of r) {
@@ -802,33 +810,33 @@ function Ye(e, t) {
802
810
  }
803
811
  return !1;
804
812
  }
805
- function $(e) {
813
+ function Z(e) {
806
814
  if (!e) return;
807
815
  let t = new Date(e);
808
816
  return Number.isNaN(t.getTime()) ? void 0 : n(t);
809
817
  }
810
- function Xe(e, t) {
811
- let n = $(e.createdAt) ?? "", r = e.history ?? [], i = [...t].sort()[0];
818
+ function Q(e, t) {
819
+ let n = Z(e.createdAt) ?? "", r = e.history ?? [], i = [...t].sort()[0];
812
820
  return r.length >= 800 && r[0] > n ? r[0] : i && i < n ? i : n;
813
821
  }
814
- function Ze(e, t, n, r) {
822
+ function $(e, t, n, r) {
815
823
  if (t.has(n)) return !0;
816
824
  if (n < r) return !1;
817
- let i = $(e.endedAt);
825
+ let i = Z(e.endedAt);
818
826
  return i && n >= i ? !1 : !(e.breaks ?? []).some((e) => {
819
- let t = $(e.endedAt), r = $(e.resumedAt);
827
+ let t = Z(e.endedAt), r = Z(e.resumedAt);
820
828
  return !!t && !!r && n >= t && n < r;
821
829
  });
822
830
  }
823
- function Qe(e, t) {
824
- let r = Q(e);
825
- return Ze(e, r, n(t), Xe(e, r));
826
- }
827
831
  function $e(e, t) {
828
- let r = Q(e), i = Xe(e, r), a = e.endedAt ? new Date(e.endedAt) : void 0, o = a && !Number.isNaN(a.getTime()) ? a : void 0, c = o ?? t, l = n(c), [d, f, p] = (i || l).split("-").map(Number), m = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
832
+ let r = X(e);
833
+ return $(e, r, n(t), Q(e, r));
834
+ }
835
+ function et(e, t) {
836
+ let r = X(e), i = Q(e, r), a = e.endedAt ? new Date(e.endedAt) : void 0, o = a && !Number.isNaN(a.getTime()) ? a : void 0, c = o ?? t, l = n(c), [d, f, p] = (i || l).split("-").map(Number), m = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
829
837
  for (let t = new Date(d, f - 1, p); n(t) <= l; t = u(t, 1)) {
830
838
  let a = n(t);
831
- if (!Ze(e, r, a, i)) continue;
839
+ if (!$(e, r, a, i)) continue;
832
840
  let o = s(e.period, t);
833
841
  m.add(o), r.has(a) && h.add(o);
834
842
  }
@@ -840,21 +848,21 @@ function $e(e, t) {
840
848
  total: m.size
841
849
  };
842
850
  }
843
- function et(e, t) {
851
+ function tt(e, t) {
844
852
  if (e.period !== "day") return 0;
845
- let r = Q(e), i = r.has(n(t)) ? t : u(t, -1), a = 0;
853
+ let r = X(e), i = r.has(n(t)) ? t : u(t, -1), a = 0;
846
854
  for (; r.has(n(i));) a++, i = u(i, -1);
847
855
  return a;
848
856
  }
849
- function tt(e, t, r) {
857
+ function nt(e, t, r) {
850
858
  let i = n(t), a = new Map(e.projects.map((e) => [e.id, e])), o = new Set(e.tasks.filter((e) => e.parentId && e.doneAt).map((e) => e.parentId));
851
859
  return e.tasks.filter((e) => e.doneAt && n(new Date(e.doneAt)) === i && !o.has(e.id)).sort((e, t) => e.doneAt.localeCompare(t.doneAt)).map((e) => ({
852
860
  task: e,
853
- horizon: P(e, r),
861
+ horizon: N(e, r),
854
862
  project: e.projectId ? a.get(e.projectId) : void 0
855
863
  }));
856
864
  }
857
- function nt(e, t) {
865
+ function rt(e, t) {
858
866
  return Array.from({ length: t }, (n, r) => u(e, r - t + 1));
859
867
  }
860
- export { ve as HABIT_HISTORY_LIMIT, e as HORIZONS, l as HORIZON_HABIT_PERIOD, Z as HORIZON_NAME, We as HORIZON_OPTION, c as HORIZON_PERIOD, Ue as HORIZON_SUB, Je as PERIOD_NAME, Ke as PLACED_MARK, Ge as PLACE_LABEL, t as PRIORITIES, qe as PRIORITY_NAME, I as activeChild, X as activeHabitChild, u as addDays, Te as applyChanges, w as autoDue, ze as bringToToday, ue as buildColumns, q as childProjects, n as dayKey, v as dayLabel, h as daysUntil, tt as doneOn, m as dueLabel, ee as dueLabelWeekday, P as effectiveHorizon, ye as endHabit, K as endedHabits, Le as finishOnDay, j as followsDue, k as goalDueNextWeek, Qe as habitActiveOn, Q as habitDays, Ye as habitDoneOn, ke as habitPlaceTargets, $e as habitRecord, Me as habitToTask, S as hasWhen, N as horizonForDue, d as inSamePeriod, D as isExpired, O as isForNextWeek, A as isForTomorrow, oe as isMonthOnly, M as isProjectGoal, F as isVisible, nt as lastDays, J as mergeById, b as monthDayDate, a as monthKey, Ne as monthlyDueDate, we as moveProject, me as moveStep, pe as moveTo, _e as newHabit, xe as newProject, H as newTask, Ve as nextGoalOrder, R as numbered, y as parseNthWeekday, x as parseYearDay, _ as periodHorizon, s as periodKey, p as periodLabel, de as placeDown, Ae as placeHabitDown, L as placeTargets, E as placedForKey, Re as postponeToTomorrow, Be as projectGoals, le as quickTarget, Ce as removeProject, ge as removeTask, He as reorderGoals, De as reorderHabits, Oe as reorderProjects, Ee as reorderTasks, be as resumeHabit, fe as returnUp, Pe as setDue, he as setPriority, te as shortDueLabel, et as streak, W as toggleDone, G as toggleHabit, je as toggleHabitAll, Ie as toggleHabitOnDay, Se as topProjects, r as weekKey, i as weekStart, C as whenDate, re as whenLabel, Fe as withDay, ae as withWhen, o as yearKey };
868
+ export { be as HABIT_HISTORY_LIMIT, e as HORIZONS, l as HORIZON_HABIT_PERIOD, Ge as HORIZON_NAME, qe as HORIZON_OPTION, c as HORIZON_PERIOD, Ke as HORIZON_SUB, Ze as PERIOD_NAME, Ye as PLACED_MARK, Je as PLACE_LABEL, t as PRIORITIES, Xe as PRIORITY_NAME, F as activeChild, Y as activeHabitChild, u as addDays, De as applyChanges, w as autoDue, Ve as bringToToday, fe as buildColumns, K as childProjects, n as dayKey, v as dayLabel, h as daysUntil, nt as doneOn, m as dueLabel, ee as dueLabelWeekday, N as effectiveHorizon, de as emptyPriorityGaps, xe as endHabit, G as endedHabits, ze as finishOnDay, A as followsDue, O as goalDueNextWeek, $e as habitActiveOn, X as habitDays, Qe as habitDoneOn, je as habitPlaceTargets, et as habitRecord, Pe as habitToTask, S as hasWhen, M as horizonForDue, d as inSamePeriod, E as isExpired, D as isForNextWeek, k as isForTomorrow, oe as isMonthOnly, j as isProjectGoal, P as isVisible, rt as lastDays, q as mergeById, b as monthDayDate, a as monthKey, Fe as monthlyDueDate, Ee as moveProject, ge as moveStep, he as moveTo, ye as newHabit, Ce as newProject, V as newTask, Ue as nextGoalOrder, L as numbered, y as parseNthWeekday, x as parseYearDay, _ as periodHorizon, s as periodKey, p as periodLabel, pe as placeDown, Me as placeHabitDown, I as placeTargets, T as placedForKey, Be as postponeToTomorrow, He as projectGoals, ue as quickTarget, Te as removeProject, ve as removeTask, We as reorderGoals, ke as reorderHabits, Ae as reorderProjects, Oe as reorderTasks, Se as resumeHabit, me as returnUp, Ie as setDue, _e as setPriority, te as shortDueLabel, tt as streak, U as toggleDone, W as toggleHabit, Ne as toggleHabitAll, Re as toggleHabitOnDay, we as topProjects, r as weekKey, i as weekStart, C as whenDate, re as whenLabel, Le as withDay, ae as withWhen, o as yearKey };