@shiodome47/sekisho 0.0.0-stage → 0.2.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/course.ts"],"sourcesContent":["/**\n * コースを作る・直す(画面なし)。自分のコースを作る画面と、管理者がコースを作る画面の両方で使う。\n * どの関数も元のコースは変えず、新しいコースを返す。直すたびに revision(設計の版)が 1 つ上がる。\n */\nimport type { CheckItem, Course, Gate, Route } from './types'\n\nconst newId = () => crypto.randomUUID()\n\n/** 新しいコース(関所は空) */\nexport function newCourse(\n input: { title: string; description?: string; route?: Route; origin?: Course['origin']; color?: string },\n now: Date,\n): Course {\n const at = now.toISOString()\n return {\n id: newId(),\n title: input.title.trim(),\n ...(input.description?.trim() ? { description: input.description.trim() } : {}),\n origin: input.origin ?? 'own',\n route: input.route ?? 'free',\n ...(input.color ? { color: input.color } : {}),\n gates: [],\n revision: 1,\n createdAt: at,\n updatedAt: at,\n }\n}\n\n/** 新しい関所(項目は空) */\nexport function newGate(input: { title: string; description?: string }): Gate {\n return {\n id: newId(),\n title: input.title.trim(),\n ...(input.description?.trim() ? { description: input.description.trim() } : {}),\n items: [],\n }\n}\n\n/** 新しいチェック項目 */\nexport function newItem(input: { title: string; target?: CheckItem['target']; count?: number; note?: string }): CheckItem {\n return {\n id: newId(),\n title: input.title.trim(),\n ...(input.note?.trim() ? { note: input.note.trim() } : {}),\n ...(input.target ? { target: input.target } : {}),\n ...(input.count && input.count > 1 ? { count: Math.floor(input.count) } : {}),\n }\n}\n\n/** 直したコース(版を上げ、直した日時を入れる) */\nfunction touch(course: Course, gates: Gate[], now: Date, patch: Partial<Course> = {}): Course {\n return { ...course, ...patch, gates, revision: course.revision + 1, updatedAt: now.toISOString() }\n}\n\n/** 並びの中で 1 つを動かす(toIndex は動かしたあとの位置) */\nfunction moveIn<T>(list: T[], from: number, toIndex: number): T[] {\n const out = list.slice()\n const [x] = out.splice(from, 1)\n out.splice(Math.max(0, Math.min(out.length, toIndex)), 0, x)\n return out\n}\n\n/** コースの名前・説明・回り方・色・ご褒美を直す */\nexport function updateCourse(\n course: Course,\n patch: Partial<Pick<Course, 'title' | 'description' | 'route' | 'color' | 'reward'>>,\n now: Date,\n): Course {\n return touch(course, course.gates, now, patch)\n}\n\n/** 関所を足す(index が無ければ最後に) */\nexport function addGate(course: Course, gate: Gate, now: Date, index?: number): Course {\n const gates = course.gates.slice()\n gates.splice(index ?? gates.length, 0, gate)\n return touch(course, gates, now)\n}\n\n/** 関所の名前・説明・スタンプ・ご褒美を直す */\nexport function updateGate(\n course: Course,\n gateId: string,\n patch: Partial<Pick<Gate, 'title' | 'description' | 'stamp' | 'reward' | 'points'>>,\n now: Date,\n): Course {\n return touch(course, course.gates.map((g) => (g.id === gateId ? { ...g, ...patch } : g)), now)\n}\n\n/** 関所を消す(中の項目ごと) */\nexport function removeGate(course: Course, gateId: string, now: Date): Course {\n return touch(course, course.gates.filter((g) => g.id !== gateId), now)\n}\n\n/** 関所の並びを変える */\nexport function moveGate(course: Course, gateId: string, toIndex: number, now: Date): Course {\n const from = course.gates.findIndex((g) => g.id === gateId)\n if (from < 0) return course\n return touch(course, moveIn(course.gates, from, toIndex), now)\n}\n\n/** 関所にチェック項目を足す(index が無ければ最後に) */\nexport function addItem(course: Course, gateId: string, item: CheckItem, now: Date, index?: number): Course {\n return touch(\n course,\n course.gates.map((g) => {\n if (g.id !== gateId) return g\n const items = g.items.slice()\n items.splice(index ?? items.length, 0, item)\n return { ...g, items }\n }),\n now,\n )\n}\n\n/** チェック項目を直す */\nexport function updateItem(\n course: Course,\n itemId: string,\n patch: Partial<Pick<CheckItem, 'title' | 'note' | 'target' | 'count'>>,\n now: Date,\n): Course {\n return touch(\n course,\n course.gates.map((g) => ({ ...g, items: g.items.map((i) => (i.id === itemId ? { ...i, ...patch } : i)) })),\n now,\n )\n}\n\n/** チェック項目を消す */\nexport function removeItem(course: Course, itemId: string, now: Date): Course {\n return touch(course, course.gates.map((g) => ({ ...g, items: g.items.filter((i) => i.id !== itemId) })), now)\n}\n\n/** チェック項目を動かす(同じ関所の中でも、ほかの関所へも) */\nexport function moveItem(course: Course, itemId: string, toGateId: string, toIndex: number, now: Date): Course {\n const item = course.gates.flatMap((g) => g.items).find((i) => i.id === itemId)\n if (!item || !course.gates.some((g) => g.id === toGateId)) return course\n const gates = course.gates.map((g) => {\n const items = g.items.filter((i) => i.id !== itemId)\n if (g.id === toGateId) items.splice(Math.max(0, Math.min(items.length, toIndex)), 0, item)\n return { ...g, items }\n })\n return touch(course, gates, now)\n}\n\n/**\n * 複製して自分のコースにする(与えられたコースを、自分用に直したいとき)。\n * 新しい id になるので、進み具合は引き継がない\n */\nexport function duplicateCourse(course: Course, now: Date, title?: string): Course {\n const at = now.toISOString()\n return {\n ...structuredClone(course),\n id: newId(),\n title: (title ?? course.title).trim(),\n origin: 'own',\n revision: 1,\n createdAt: at,\n updatedAt: at,\n }\n}\n"],"mappings":";;;AAMA,IAAM,QAAQ,MAAM,OAAO,WAAW;AAG/B,SAAS,UACd,OACA,KACQ;AACR,QAAM,KAAK,IAAI,YAAY;AAC3B,SAAO;AAAA,IACL,IAAI,MAAM;AAAA,IACV,OAAO,MAAM,MAAM,KAAK;AAAA,IACxB,GAAI,MAAM,aAAa,KAAK,IAAI,EAAE,aAAa,MAAM,YAAY,KAAK,EAAE,IAAI,CAAC;AAAA,IAC7E,QAAQ,MAAM,UAAU;AAAA,IACxB,OAAO,MAAM,SAAS;AAAA,IACtB,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,IAC5C,OAAO,CAAC;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;AAGO,SAAS,QAAQ,OAAsD;AAC5E,SAAO;AAAA,IACL,IAAI,MAAM;AAAA,IACV,OAAO,MAAM,MAAM,KAAK;AAAA,IACxB,GAAI,MAAM,aAAa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B,QAAgB,UAAkB,SAAiB,KAAmB;AAC7G,QAAM,OAAO,OAAO,MAAM,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM;AAC7E,MAAI,CAAC,QAAQ,CAAC,OAAO,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,QAAQ,EAAG,QAAO;AAClE,QAAM,QAAQ,OAAO,MAAM,IAAI,CAAC,MAAM;AACpC,UAAM,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,OAAO,MAAM;AACnD,QAAI,EAAE,OAAO,SAAU,OAAM,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,MAAM,QAAQ,OAAO,CAAC,GAAG,GAAG,IAAI;AACzF,WAAO,EAAE,GAAG,GAAG,MAAM;AAAA,EACvB,CAAC;AACD,SAAO,MAAM,QAAQ,OAAO,GAAG;AACjC;AAMO,SAAS,gBAAgB,QAAgB,KAAW,OAAwB;AACjF,QAAM,KAAK,IAAI,YAAY;AAC3B,SAAO;AAAA,IACL,GAAG,gBAAgB,MAAM;AAAA,IACzB,IAAI,MAAM;AAAA,IACV,QAAQ,SAAS,OAAO,OAAO,KAAK;AAAA,IACpC,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;","names":[]}
@@ -0,0 +1,222 @@
1
+ 'use client'
2
+
3
+ // src/ui/connectors.ts
4
+ function stampOf(gate, courseColor) {
5
+ const text = gate.stamp?.text?.trim() || [...gate.title.trim()][0] || "\u95A2";
6
+ return { text: [...text].slice(0, 2).join(""), color: gate.stamp?.color || courseColor || DEFAULT_STAMP_COLOR };
7
+ }
8
+ var DEFAULT_STAMP_COLOR = "#d9480f";
9
+
10
+ // src/ui/labels.ts
11
+ var JA_LABELS = {
12
+ courses: "\u30B3\u30FC\u30B9",
13
+ noCourses: "\u307E\u3060\u30B3\u30FC\u30B9\u304C\u3042\u308A\u307E\u305B\u3093",
14
+ given: "\u914D\u3089\u308C\u305F\u30B3\u30FC\u30B9",
15
+ own: "\u81EA\u5206\u306E\u30B3\u30FC\u30B9",
16
+ back: "\u3082\u3069\u308B",
17
+ createCourse: "\u30B3\u30FC\u30B9\u3092\u4F5C\u308B",
18
+ importCourses: "\u30B3\u30FC\u30B9\u3092\u8AAD\u307F\u8FBC\u3080",
19
+ importDone: (n) => `${n} \u500B\u306E\u30B3\u30FC\u30B9\u3092\u5165\u308C\u307E\u3057\u305F`,
20
+ importNothing: "\u65B0\u3057\u3044\u30B3\u30FC\u30B9\u306F\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F",
21
+ editCourse: "\u76F4\u3059",
22
+ duplicateCourse: "\u8907\u88FD\u3057\u3066\u81EA\u5206\u306E\u30B3\u30FC\u30B9\u306B\u3059\u308B",
23
+ exportCourse: "\u66F8\u304D\u51FA\u3059\uFF08\u914D\u308B\u7528\uFF09",
24
+ deleteCourse: "\u30B3\u30FC\u30B9\u3092\u6D88\u3059",
25
+ deleteConfirm: (title) => `\u300C${title}\u300D\u3092\u6D88\u3057\u307E\u3059\u304B\uFF1F \u9032\u307F\u5177\u5408\u3068\u30B9\u30BF\u30F3\u30D7\u3082\u6D88\u3048\u307E\u3059`,
26
+ passport: "\u901A\u884C\u624B\u5F62",
27
+ routeFree: "\u3069\u3053\u304B\u3089\u3067\u3082",
28
+ routeOrdered: "\u9806\u756A",
29
+ clearedOf: (cleared, total) => `${cleared} / ${total} \u95A2\u6240`,
30
+ locked: "\u307E\u3060\u958B\u3044\u3066\u3044\u307E\u305B\u3093",
31
+ cleared: "\u30AF\u30EA\u30A2",
32
+ courseCleared: "\u30B3\u30FC\u30B9\u5236\u8987",
33
+ check: (title) => `\u300C${title}\u300D\u3092\u6E08\u307F\u306B\u3059\u308B`,
34
+ uncheck: (title) => `\u300C${title}\u300D\u3092\u5916\u3059`,
35
+ plusOne: (title) => `\u300C${title}\u300D\u3092 1 \u56DE\u9032\u3081\u308B`,
36
+ minusOne: (title) => `\u300C${title}\u300D\u3092 1 \u56DE\u623B\u3059`,
37
+ open: (title) => `\u300C${title}\u300D\u3092\u958B\u304F`,
38
+ gateClear: "\u95A2\u6240\u30AF\u30EA\u30A2\uFF01",
39
+ courseClear: "\u5168\u95A2\u6240 \u5236\u8987\uFF01",
40
+ next: "\u3064\u304E\u3078",
41
+ close: "\u3068\u3058\u308B",
42
+ secretMessage: "\u3072\u307F\u3064\u306E\u4E00\u8A00",
43
+ emptyGate: "\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093",
44
+ // 周回
45
+ lapNumber: (n) => `${n} \u5468\u76EE`,
46
+ laps: "\u5468\u56DE\u306E\u8A18\u9332",
47
+ lapDate: (iso) => new Date(iso).toLocaleDateString("ja-JP"),
48
+ nextLap: "\u3082\u3046\u4E00\u5468\u3059\u308B",
49
+ nextLapHint: "\u4ECA\u306E\u5468\u3092\u8A18\u9332\u3057\u3066\u3001\u30C1\u30A7\u30C3\u30AF\u3068\u30B9\u30BF\u30F3\u30D7\u3092\u7A7A\u306B\u3057\u307E\u3059",
50
+ nextLapConfirm: (n) => `${n} \u5468\u76EE\u3092\u8A18\u9332\u3057\u3066\u3001\u30C1\u30A7\u30C3\u30AF\u3068\u30B9\u30BF\u30F3\u30D7\u3092\u7A7A\u306B\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`,
51
+ restartCourse: "\u306F\u3058\u3081\u304B\u3089\u3084\u308A\u76F4\u3059",
52
+ restartConfirm: "\u30C1\u30A7\u30C3\u30AF\u30FB\u30B9\u30BF\u30F3\u30D7\u30FB\u5468\u56DE\u306E\u8A18\u9332\u3092\u5168\u90E8\u6D88\u3057\u3066\u3001\u306F\u3058\u3081\u304B\u3089\u3084\u308A\u76F4\u3057\u307E\u3059\u304B\uFF1F\uFF08\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\uFF09",
53
+ // 作る画面
54
+ courseTitle: "\u30B3\u30FC\u30B9\u306E\u540D\u524D",
55
+ courseDescription: "\u8AAC\u660E\uFF08\u306A\u304F\u3066\u3082\u3088\u3044\uFF09",
56
+ route: "\u56DE\u308A\u65B9",
57
+ gateTitle: "\u95A2\u6240\u306E\u540D\u524D",
58
+ gateNumber: (n) => `\u7B2C ${n} \u306E\u95A2\u6240`,
59
+ stampText: "\u30B9\u30BF\u30F3\u30D7\u306E\u5B57",
60
+ addGate: "\u95A2\u6240\u3092\u8DB3\u3059",
61
+ newGateTitle: (n) => `\u7B2C ${n} \u306E\u95A2\u6240`,
62
+ removeGate: "\u3053\u306E\u95A2\u6240\u3092\u6D88\u3059",
63
+ removeGateConfirm: (title) => `\u95A2\u6240\u300C${title}\u300D\u3092\u6D88\u3057\u307E\u3059\u304B\uFF1F`,
64
+ moveGate: (title) => `\u95A2\u6240\u300C${title}\u300D\u3092\u52D5\u304B\u3059`,
65
+ itemTitle: "\u9805\u76EE\u306E\u6587",
66
+ itemCount: "\u56DE\u6570",
67
+ addItem: "\u9805\u76EE\u3092\u8DB3\u3059",
68
+ addItemPlaceholder: "\u4F8B: \u300C\u3042\u308A\u304C\u3068\u3046\u300D\u3092 10 \u56DE\u304F\u308A\u8FD4\u3059",
69
+ pickTarget: "\u52D5\u753B\u30FB\u533A\u9593\u304B\u3089\u8DB3\u3059",
70
+ moveUp: (title) => `\u300C${title}\u300D\u3092\u4E0A\u3078`,
71
+ moveDown: (title) => `\u300C${title}\u300D\u3092\u4E0B\u3078`,
72
+ removeItem: (title) => `\u300C${title}\u300D\u3092\u6D88\u3059`,
73
+ rewardMessage: "\u3054\u8912\u7F8E: \u3072\u307F\u3064\u306E\u4E00\u8A00\uFF08\u306A\u304F\u3066\u3082\u3088\u3044\uFF09",
74
+ rewardOther: (type) => `\u3054\u8912\u7F8E: ${type}`,
75
+ removeReward: "\u3054\u8912\u7F8E\u3092\u5916\u3059",
76
+ save: "\u4FDD\u5B58",
77
+ cancel: "\u3084\u3081\u308B",
78
+ untitled: "\u540D\u524D\u306E\u306A\u3044\u30B3\u30FC\u30B9"
79
+ };
80
+ var EN_LABELS = {
81
+ courses: "Courses",
82
+ noCourses: "No courses yet",
83
+ given: "Assigned",
84
+ own: "My course",
85
+ back: "Back",
86
+ createCourse: "New course",
87
+ importCourses: "Import courses",
88
+ importDone: (n) => `Added ${n} course${n === 1 ? "" : "s"}`,
89
+ importNothing: "No new courses",
90
+ editCourse: "Edit",
91
+ duplicateCourse: "Make my own copy",
92
+ exportCourse: "Export (to share)",
93
+ deleteCourse: "Delete course",
94
+ deleteConfirm: (title) => `Delete "${title}"? Progress and stamps will be lost.`,
95
+ passport: "Passport",
96
+ routeFree: "Any order",
97
+ routeOrdered: "In order",
98
+ clearedOf: (cleared, total) => `${cleared} / ${total} gates`,
99
+ locked: "Locked",
100
+ cleared: "Cleared",
101
+ courseCleared: "Completed",
102
+ check: (title) => `Mark "${title}" done`,
103
+ uncheck: (title) => `Uncheck "${title}"`,
104
+ plusOne: (title) => `Add one to "${title}"`,
105
+ minusOne: (title) => `Remove one from "${title}"`,
106
+ open: (title) => `Open "${title}"`,
107
+ gateClear: "Gate cleared!",
108
+ courseClear: "All gates cleared!",
109
+ next: "Next",
110
+ close: "Close",
111
+ secretMessage: "Secret message",
112
+ emptyGate: "No items",
113
+ lapNumber: (n) => `Round ${n}`,
114
+ laps: "Past rounds",
115
+ lapDate: (iso) => new Date(iso).toLocaleDateString("en-US"),
116
+ nextLap: "Start next round",
117
+ nextLapHint: "Saves this round and clears the checks and stamps",
118
+ nextLapConfirm: (n) => `Save round ${n} and clear the checks and stamps?`,
119
+ restartCourse: "Start over",
120
+ restartConfirm: "Delete all checks, stamps and past rounds, and start over? This cannot be undone.",
121
+ courseTitle: "Course name",
122
+ courseDescription: "Description (optional)",
123
+ route: "Route",
124
+ gateTitle: "Gate name",
125
+ gateNumber: (n) => `Gate ${n}`,
126
+ stampText: "Stamp text",
127
+ addGate: "Add a gate",
128
+ newGateTitle: (n) => `Gate ${n}`,
129
+ removeGate: "Delete this gate",
130
+ removeGateConfirm: (title) => `Delete gate "${title}"?`,
131
+ moveGate: (title) => `Move gate "${title}"`,
132
+ itemTitle: "Item text",
133
+ itemCount: "Times",
134
+ addItem: "Add item",
135
+ addItemPlaceholder: 'e.g. Repeat "thank you" 10 times',
136
+ pickTarget: "Add from videos",
137
+ moveUp: (title) => `Move "${title}" up`,
138
+ moveDown: (title) => `Move "${title}" down`,
139
+ removeItem: (title) => `Delete "${title}"`,
140
+ rewardMessage: "Reward: secret message (optional)",
141
+ rewardOther: (type) => `Reward: ${type}`,
142
+ removeReward: "Remove reward",
143
+ save: "Save",
144
+ cancel: "Cancel",
145
+ untitled: "Untitled course"
146
+ };
147
+
148
+ // src/ui/Stamp.tsx
149
+ import { useEffect, useState } from "react";
150
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
151
+ function Stamp({
152
+ text,
153
+ color,
154
+ state = "pressed",
155
+ size = 56,
156
+ tilt = -8,
157
+ label
158
+ }) {
159
+ const chars = [...text].slice(0, 2);
160
+ if (state !== "pressed") {
161
+ return /* @__PURE__ */ jsx("span", { className: "sk-stamp sk-stamp--empty", style: { width: size, height: size }, role: "img", "aria-label": label, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 100 100", width: size, height: size, "aria-hidden": "true", children: [
162
+ /* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r: "44", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeDasharray: "7 7" }),
163
+ state === "locked" ? /* @__PURE__ */ jsxs("g", { fill: "currentColor", children: [
164
+ /* @__PURE__ */ jsx("rect", { x: "36", y: "48", width: "28", height: "22", rx: "3" }),
165
+ /* @__PURE__ */ jsx("path", { d: "M41 48v-7a9 9 0 0 1 18 0v7", fill: "none", stroke: "currentColor", strokeWidth: "5" })
166
+ ] }) : null
167
+ ] }) });
168
+ }
169
+ const vertical = chars.length === 2;
170
+ return /* @__PURE__ */ jsx("span", { className: "sk-stamp", style: { width: size, height: size, transform: `rotate(${tilt}deg)` }, role: "img", "aria-label": label, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 100 100", width: size, height: size, "aria-hidden": "true", children: [
171
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("filter", { id: "sk-ink", x: "-10%", y: "-10%", width: "120%", height: "120%", children: [
172
+ /* @__PURE__ */ jsx("feTurbulence", { type: "fractalNoise", baseFrequency: "1.1", numOctaves: "1", seed: "3", result: "n" }),
173
+ /* @__PURE__ */ jsx("feColorMatrix", { in: "n", type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.9 1.25", result: "mask" }),
174
+ /* @__PURE__ */ jsx("feComposite", { in: "SourceGraphic", in2: "mask", operator: "in" })
175
+ ] }) }),
176
+ /* @__PURE__ */ jsxs("g", { filter: "url(#sk-ink)", fill: "none", stroke: color, children: [
177
+ /* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r: "45", strokeWidth: "6" }),
178
+ /* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r: "37", strokeWidth: "2" }),
179
+ /* @__PURE__ */ jsx(
180
+ "text",
181
+ {
182
+ x: "50",
183
+ y: vertical ? 47 : 52,
184
+ fill: color,
185
+ stroke: "none",
186
+ textAnchor: "middle",
187
+ dominantBaseline: "central",
188
+ fontSize: vertical ? 30 : 44,
189
+ fontWeight: "700",
190
+ fontFamily: "'Hiragino Mincho ProN','Yu Mincho','Noto Serif JP',serif",
191
+ children: vertical ? /* @__PURE__ */ jsxs(Fragment, { children: [
192
+ /* @__PURE__ */ jsx("tspan", { x: "50", dy: "-12", children: chars[0] }),
193
+ /* @__PURE__ */ jsx("tspan", { x: "50", dy: "30", children: chars[1] })
194
+ ] }) : chars[0]
195
+ }
196
+ )
197
+ ] })
198
+ ] }) });
199
+ }
200
+ function useReducedMotion(force) {
201
+ const query = "(prefers-reduced-motion: reduce)";
202
+ const read = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(query).matches;
203
+ const [os, setOs] = useState(read);
204
+ useEffect(() => {
205
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
206
+ const m = window.matchMedia(query);
207
+ const on = () => setOs(m.matches);
208
+ m.addEventListener?.("change", on);
209
+ return () => m.removeEventListener?.("change", on);
210
+ }, []);
211
+ return force ?? os;
212
+ }
213
+
214
+ export {
215
+ stampOf,
216
+ DEFAULT_STAMP_COLOR,
217
+ JA_LABELS,
218
+ EN_LABELS,
219
+ Stamp,
220
+ useReducedMotion
221
+ };
222
+ //# sourceMappingURL=chunk-PO4XY43G.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/connectors.ts","../src/ui/labels.ts","../src/ui/Stamp.tsx"],"sourcesContent":["/**\n * アプリとのつなぎ(コネクタ・窓口)の形。\n * 部品はチェック項目の中身もご褒美の中身も知らない。アプリがこれを渡して、表示・開く・演出を受け持つ。\n */\nimport type { ReactNode } from 'react'\nimport type { CheckItem, ClearEvent, Gate, RewardRef, TargetRef } from '../core/types'\nimport type { Labels } from './labels'\n\n/** チェック項目の中身(動画・区間など)の窓口 */\nexport interface TargetAdapter {\n /** 「動画・区間を選ぶ」を押したとき。アプリが自分の画面で選ばせ、選んだものを返す(やめたら null) */\n pick?: () => Promise<{ target: TargetRef; title: string } | null>\n /** 項目の横に出す小さな印(▶ 動画、🔁 区間 など) */\n renderBadge?: (target: TargetRef, item: CheckItem) => ReactNode\n /** 項目を押したとき、その中身を開く(手話アプリなら、動画や区間に飛ぶ)。無ければ押せない */\n open?: (target: TargetRef, item: CheckItem) => void\n /** 開けるか(消した動画など、開けないものは false)。無ければ開ける */\n canOpen?: (target: TargetRef) => boolean\n}\n\n/** ご褒美のコネクタに渡すもの */\nexport interface RewardRenderProps {\n reward: RewardRef\n event: ClearEvent\n /** 呼ぶと次へ進む(閉じる) */\n done: () => void\n /** 演出を減らす(動きを止める)とき true */\n reducedMotion: boolean\n /** 音を出さないとき true */\n muted: boolean\n labels: Labels\n}\n\n/**\n * ご褒美のコネクタ。type が同じご褒美(gate.reward・course.reward)を出す。\n * アプリが <Sekisho rewards={[...]} /> で渡す。部品に入っているもの(message)と同じ type なら、こちらが使われる\n */\nexport interface RewardConnector {\n type: string\n render: (props: RewardRenderProps) => ReactNode\n}\n\n/** スタンプ(クリアの演出)を差し替えるときに渡すもの */\nexport interface StampRenderProps {\n event: ClearEvent\n /** スタンプの文字・色(gate.stamp ・コースの色から決めたもの) */\n stamp: { text: string; color: string }\n done: () => void\n reducedMotion: boolean\n muted: boolean\n labels: Labels\n}\n\n/** 関所のスタンプの文字と色(無ければ名前の 1 文字目・コースの色・朱色) */\nexport function stampOf(gate: Pick<Gate, 'title' | 'stamp'>, courseColor?: string): { text: string; color: string } {\n const text = gate.stamp?.text?.trim() || [...gate.title.trim()][0] || '関'\n return { text: [...text].slice(0, 2).join(''), color: gate.stamp?.color || courseColor || DEFAULT_STAMP_COLOR }\n}\n\nexport const DEFAULT_STAMP_COLOR = '#d9480f'\n","/** 画面の文言。labels で一部だけ差し替えられる。英語は EN_LABELS */\nexport const JA_LABELS = {\n courses: 'コース',\n noCourses: 'まだコースがありません',\n given: '配られたコース',\n own: '自分のコース',\n back: 'もどる',\n createCourse: 'コースを作る',\n importCourses: 'コースを読み込む',\n importDone: (n: number) => `${n} 個のコースを入れました`,\n importNothing: '新しいコースはありませんでした',\n editCourse: '直す',\n duplicateCourse: '複製して自分のコースにする',\n exportCourse: '書き出す(配る用)',\n deleteCourse: 'コースを消す',\n deleteConfirm: (title: string) => `「${title}」を消しますか? 進み具合とスタンプも消えます`,\n passport: '通行手形',\n routeFree: 'どこからでも',\n routeOrdered: '順番',\n clearedOf: (cleared: number, total: number) => `${cleared} / ${total} 関所`,\n locked: 'まだ開いていません',\n cleared: 'クリア',\n courseCleared: 'コース制覇',\n check: (title: string) => `「${title}」を済みにする`,\n uncheck: (title: string) => `「${title}」を外す`,\n plusOne: (title: string) => `「${title}」を 1 回進める`,\n minusOne: (title: string) => `「${title}」を 1 回戻す`,\n open: (title: string) => `「${title}」を開く`,\n gateClear: '関所クリア!',\n courseClear: '全関所 制覇!',\n next: 'つぎへ',\n close: 'とじる',\n secretMessage: 'ひみつの一言',\n emptyGate: '項目がありません',\n // 周回\n lapNumber: (n: number) => `${n} 周目`,\n laps: '周回の記録',\n lapDate: (iso: string) => new Date(iso).toLocaleDateString('ja-JP'),\n nextLap: 'もう一周する',\n nextLapHint: '今の周を記録して、チェックとスタンプを空にします',\n nextLapConfirm: (n: number) => `${n} 周目を記録して、チェックとスタンプを空にします。よろしいですか?`,\n restartCourse: 'はじめからやり直す',\n restartConfirm: 'チェック・スタンプ・周回の記録を全部消して、はじめからやり直しますか?(取り消せません)',\n // 作る画面\n courseTitle: 'コースの名前',\n courseDescription: '説明(なくてもよい)',\n route: '回り方',\n gateTitle: '関所の名前',\n gateNumber: (n: number) => `第 ${n} の関所`,\n stampText: 'スタンプの字',\n addGate: '関所を足す',\n newGateTitle: (n: number) => `第 ${n} の関所`,\n removeGate: 'この関所を消す',\n removeGateConfirm: (title: string) => `関所「${title}」を消しますか?`,\n moveGate: (title: string) => `関所「${title}」を動かす`,\n itemTitle: '項目の文',\n itemCount: '回数',\n addItem: '項目を足す',\n addItemPlaceholder: '例: 「ありがとう」を 10 回くり返す',\n pickTarget: '動画・区間から足す',\n moveUp: (title: string) => `「${title}」を上へ`,\n moveDown: (title: string) => `「${title}」を下へ`,\n removeItem: (title: string) => `「${title}」を消す`,\n rewardMessage: 'ご褒美: ひみつの一言(なくてもよい)',\n rewardOther: (type: string) => `ご褒美: ${type}`,\n removeReward: 'ご褒美を外す',\n save: '保存',\n cancel: 'やめる',\n untitled: '名前のないコース',\n}\n\nexport type Labels = typeof JA_LABELS\n\nexport const EN_LABELS: Labels = {\n courses: 'Courses',\n noCourses: 'No courses yet',\n given: 'Assigned',\n own: 'My course',\n back: 'Back',\n createCourse: 'New course',\n importCourses: 'Import courses',\n importDone: (n) => `Added ${n} course${n === 1 ? '' : 's'}`,\n importNothing: 'No new courses',\n editCourse: 'Edit',\n duplicateCourse: 'Make my own copy',\n exportCourse: 'Export (to share)',\n deleteCourse: 'Delete course',\n deleteConfirm: (title) => `Delete \"${title}\"? Progress and stamps will be lost.`,\n passport: 'Passport',\n routeFree: 'Any order',\n routeOrdered: 'In order',\n clearedOf: (cleared, total) => `${cleared} / ${total} gates`,\n locked: 'Locked',\n cleared: 'Cleared',\n courseCleared: 'Completed',\n check: (title) => `Mark \"${title}\" done`,\n uncheck: (title) => `Uncheck \"${title}\"`,\n plusOne: (title) => `Add one to \"${title}\"`,\n minusOne: (title) => `Remove one from \"${title}\"`,\n open: (title) => `Open \"${title}\"`,\n gateClear: 'Gate cleared!',\n courseClear: 'All gates cleared!',\n next: 'Next',\n close: 'Close',\n secretMessage: 'Secret message',\n emptyGate: 'No items',\n lapNumber: (n) => `Round ${n}`,\n laps: 'Past rounds',\n lapDate: (iso) => new Date(iso).toLocaleDateString('en-US'),\n nextLap: 'Start next round',\n nextLapHint: 'Saves this round and clears the checks and stamps',\n nextLapConfirm: (n) => `Save round ${n} and clear the checks and stamps?`,\n restartCourse: 'Start over',\n restartConfirm: 'Delete all checks, stamps and past rounds, and start over? This cannot be undone.',\n courseTitle: 'Course name',\n courseDescription: 'Description (optional)',\n route: 'Route',\n gateTitle: 'Gate name',\n gateNumber: (n) => `Gate ${n}`,\n stampText: 'Stamp text',\n addGate: 'Add a gate',\n newGateTitle: (n) => `Gate ${n}`,\n removeGate: 'Delete this gate',\n removeGateConfirm: (title) => `Delete gate \"${title}\"?`,\n moveGate: (title) => `Move gate \"${title}\"`,\n itemTitle: 'Item text',\n itemCount: 'Times',\n addItem: 'Add item',\n addItemPlaceholder: 'e.g. Repeat \"thank you\" 10 times',\n pickTarget: 'Add from videos',\n moveUp: (title) => `Move \"${title}\" up`,\n moveDown: (title) => `Move \"${title}\" down`,\n removeItem: (title) => `Delete \"${title}\"`,\n rewardMessage: 'Reward: secret message (optional)',\n rewardOther: (type) => `Reward: ${type}`,\n removeReward: 'Remove reward',\n save: 'Save',\n cancel: 'Cancel',\n untitled: 'Untitled course',\n}\n","import { useEffect, useState } from 'react'\n\n/**\n * 丸い印(スタンプ)。押した印・まだの印(点線の丸)・鍵のかかった印。\n * 色は朱肉のように、少しかすれた二重の丸で描く\n */\nexport function Stamp({\n text,\n color,\n state = 'pressed',\n size = 56,\n tilt = -8,\n label,\n}: {\n text: string\n color: string\n state?: 'pressed' | 'empty' | 'locked'\n size?: number\n /** 傾き(度)。押した印だけ */\n tilt?: number\n /** 読み上げ用の名前 */\n label?: string\n}) {\n const chars = [...text].slice(0, 2)\n if (state !== 'pressed') {\n return (\n <span className=\"sk-stamp sk-stamp--empty\" style={{ width: size, height: size }} role=\"img\" aria-label={label}>\n <svg viewBox=\"0 0 100 100\" width={size} height={size} aria-hidden=\"true\">\n <circle cx=\"50\" cy=\"50\" r=\"44\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeDasharray=\"7 7\" />\n {state === 'locked' ? (\n <g fill=\"currentColor\">\n <rect x=\"36\" y=\"48\" width=\"28\" height=\"22\" rx=\"3\" />\n <path d=\"M41 48v-7a9 9 0 0 1 18 0v7\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"5\" />\n </g>\n ) : null}\n </svg>\n </span>\n )\n }\n const vertical = chars.length === 2\n return (\n <span className=\"sk-stamp\" style={{ width: size, height: size, transform: `rotate(${tilt}deg)` }} role=\"img\" aria-label={label}>\n <svg viewBox=\"0 0 100 100\" width={size} height={size} aria-hidden=\"true\">\n <defs>\n {/* 朱肉のかすれ */}\n <filter id=\"sk-ink\" x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feTurbulence type=\"fractalNoise\" baseFrequency=\"1.1\" numOctaves=\"1\" seed=\"3\" result=\"n\" />\n <feColorMatrix in=\"n\" type=\"matrix\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.9 1.25\" result=\"mask\" />\n <feComposite in=\"SourceGraphic\" in2=\"mask\" operator=\"in\" />\n </filter>\n </defs>\n <g filter=\"url(#sk-ink)\" fill=\"none\" stroke={color}>\n <circle cx=\"50\" cy=\"50\" r=\"45\" strokeWidth=\"6\" />\n <circle cx=\"50\" cy=\"50\" r=\"37\" strokeWidth=\"2\" />\n <text\n x=\"50\"\n y={vertical ? 47 : 52}\n fill={color}\n stroke=\"none\"\n textAnchor=\"middle\"\n dominantBaseline=\"central\"\n fontSize={vertical ? 30 : 44}\n fontWeight=\"700\"\n fontFamily=\"'Hiragino Mincho ProN','Yu Mincho','Noto Serif JP',serif\"\n >\n {vertical ? (\n <>\n <tspan x=\"50\" dy=\"-12\">\n {chars[0]}\n </tspan>\n <tspan x=\"50\" dy=\"30\">\n {chars[1]}\n </tspan>\n </>\n ) : (\n chars[0]\n )}\n </text>\n </g>\n </svg>\n </span>\n )\n}\n\n/** 端末の「視差効果を減らす」(prefers-reduced-motion)に合わせる。force を渡せば、それに従う */\nexport function useReducedMotion(force?: boolean): boolean {\n const query = '(prefers-reduced-motion: reduce)'\n const read = () => typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia(query).matches\n const [os, setOs] = useState(read)\n useEffect(() => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return\n const m = window.matchMedia(query)\n const on = () => setOs(m.matches)\n m.addEventListener?.('change', on)\n return () => m.removeEventListener?.('change', on)\n }, [])\n return force ?? os\n}\n"],"mappings":";;;AAsDO,SAAS,QAAQ,MAAqC,aAAuD;AAClH,QAAM,OAAO,KAAK,OAAO,MAAM,KAAK,KAAK,CAAC,GAAG,KAAK,MAAM,KAAK,CAAC,EAAE,CAAC,KAAK;AACtE,SAAO,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,KAAK,OAAO,SAAS,eAAe,oBAAoB;AAChH;AAEO,IAAM,sBAAsB;;;AC1D5B,IAAM,YAAY;AAAA,EACvB,SAAS;AAAA,EACT,WAAW;AAAA,EACX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A,MAC/C;AAAA,QAAC;AAAA;AAAA,UACC,GAAE;AAAA,UACF,GAAG,WAAW,KAAK;AAAA,UACnB,MAAM;AAAA,UACN,QAAO;AAAA,UACP,YAAW;AAAA,UACX,kBAAiB;AAAA,UACjB,UAAU,WAAW,KAAK;AAAA,UAC1B,YAAW;AAAA,UACX,YAAW;AAAA,UAEV,qBACC,iCACE;AAAA,gCAAC,WAAM,GAAE,MAAK,IAAG,OACd,gBAAM,CAAC,GACV;AAAA,YACA,oBAAC,WAAM,GAAE,MAAK,IAAG,MACd,gBAAM,CAAC,GACV;AAAA,aACF,IAEA,MAAM,CAAC;AAAA;AAAA,MAEX;AAAA,OACF;AAAA,KACF,GACF;AAEJ;AAGO,SAAS,iBAAiB,OAA0B;AACzD,QAAM,QAAQ;AACd,QAAM,OAAO,MAAM,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,cAAc,OAAO,WAAW,KAAK,EAAE;AACxH,QAAM,CAAC,IAAI,KAAK,IAAI,SAAS,IAAI;AACjC,YAAU,MAAM;AACd,QAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,WAAY;AAC9E,UAAM,IAAI,OAAO,WAAW,KAAK;AACjC,UAAM,KAAK,MAAM,MAAM,EAAE,OAAO;AAChC,MAAE,mBAAmB,UAAU,EAAE;AACjC,WAAO,MAAM,EAAE,sBAAsB,UAAU,EAAE;AAAA,EACnD,GAAG,CAAC,CAAC;AACL,SAAO,SAAS;AAClB;","names":[]}
@@ -0,0 +1,202 @@
1
+ import { d as Course, G as Gate, b as CheckItem, L as Lap, S as SekishoData, a as Changes, I as ItemProgress, A as Activity, T as TargetRef, e as Route } from '../types-73liizfJ.js';
2
+ export { c as Clear, C as ClearEvent, R as RewardRef } from '../types-73liizfJ.js';
3
+
4
+ /**
5
+ * 進み具合の計算(画面なし)。
6
+ * 関数はデータを書き換えず、変更(Changes)を返す。保存はアプリがして、applyChanges で手元にも当てる。
7
+ *
8
+ * 周回: 進み具合とクリアの記録は「何周目のものか」(round)を持ち、今の周のものだけを数える。
9
+ * 「もう一周する」(nextLap)で周回の記録(Lap)を残して次の周へ、「はじめからやり直す」(restartCourse)で 1 周目に戻る。
10
+ */
11
+
12
+ /** 進み具合の id */
13
+ declare const progressId: (courseId: string, itemId: string) => string;
14
+ /** クリアの記録の id。gateId が無ければコースを全部クリアした記録 */
15
+ declare const clearId: (courseId: string, gateId?: string) => string;
16
+ /** 周回の記録の id */
17
+ declare const lapId: (courseId: string, round: number) => string;
18
+ /** 項目の回数(無ければ 1。1 より小さい・数でないものも 1) */
19
+ declare function itemGoal(item: Pick<CheckItem, 'count'>): number;
20
+ interface ItemView {
21
+ item: CheckItem;
22
+ /** 今の回数 */
23
+ done: number;
24
+ /** 回数(無ければ 1) */
25
+ goal: number;
26
+ complete: boolean;
27
+ }
28
+ interface GateView {
29
+ gate: Gate;
30
+ index: number;
31
+ items: ItemView[];
32
+ /** 済んだ項目の数 */
33
+ done: number;
34
+ /** 項目の数 */
35
+ total: number;
36
+ /** 今、項目が全部済んでいるか */
37
+ complete: boolean;
38
+ /** この周でクリアの記録があるか(一度クリアしたら、項目を外しても true のまま) */
39
+ cleared: boolean;
40
+ clearedAt?: string;
41
+ /** 開いているか(順番のコースでは、前の関所をクリアすると開く) */
42
+ open: boolean;
43
+ }
44
+ interface CourseView {
45
+ course: Course;
46
+ gates: GateView[];
47
+ /** この周でクリアした関所の数 */
48
+ cleared: number;
49
+ /** 関所の数 */
50
+ total: number;
51
+ /** この周でコースを全部クリアした記録があるか */
52
+ complete: boolean;
53
+ clearedAt?: string;
54
+ /** 何周目か(画面に出す番号。はじめからやり直すと 1 に戻る) */
55
+ lap: number;
56
+ /** これまでの周回の記録(古い順。隠したものは入れない) */
57
+ laps: Lap[];
58
+ /** この周で、何か進めたか(チェック・回数・クリアのどれか) */
59
+ started: boolean;
60
+ }
61
+ /** 今が何周目か(画面に出す番号) */
62
+ declare function currentLap(data: Pick<SekishoData, 'laps'>, courseId: string): number;
63
+ /** 関所が開いているか */
64
+ declare function isGateOpen(data: Pick<SekishoData, 'clears'> & Partial<SekishoData>, course: Course, gateId: string): boolean;
65
+ /** コースの進み具合(関所ごと・項目ごと・何周目か)。画面はこれを描く */
66
+ declare function viewCourse(data: SekishoData, course: Course): CourseView;
67
+ /** 1 つ進める(「+1」。回数の無い項目なら済みにする) */
68
+ declare function addOne(data: SekishoData, courseId: string, itemId: string, now: Date): Changes;
69
+ /** 1 つ戻す(まちがえたとき) */
70
+ declare function removeOne(data: SekishoData, courseId: string, itemId: string, now: Date): Changes;
71
+ /** 済みにする(回数のある項目は、まとめて回数まで) */
72
+ declare function checkItem(data: SekishoData, courseId: string, itemId: string, now: Date): Changes;
73
+ /** 外す(回数は 0 に戻る。関所のクリアの記録は残る) */
74
+ declare function uncheckItem(data: SekishoData, courseId: string, itemId: string, now: Date): Changes;
75
+ /** 済んでいれば外し、まだなら済みにする(チェック欄を押したとき) */
76
+ declare function toggleItem(data: SekishoData, courseId: string, itemId: string, now: Date): Changes;
77
+ /** target が同じか(type と id が同じ。ほかの項目は見ない) */
78
+ declare function sameTarget(a: TargetRef | undefined, b: TargetRef | undefined): boolean;
79
+ /**
80
+ * 自動のチェック。アプリが「これをした」と知らせると、target が同じチェック項目を、
81
+ * 入っているコース全部で amount ずつ進める(回数の無い項目は済みにする)。
82
+ * 数えるのは知らせを受けたときだけなので、コースを入れる前の練習はさかのぼらない
83
+ */
84
+ declare function report(data: SekishoData, activity: Activity, now: Date): Changes;
85
+ /**
86
+ * クリアの記録を整える。コースが新しい版になって項目が減ったときなど、
87
+ * 進み具合は変わらないのに関所が全部済んだ状態になったら、ここでクリアにする。
88
+ * courseIds を渡すと、そのコースだけを見る
89
+ */
90
+ declare function settleClears(data: SekishoData, now: Date, courseIds?: string[]): Changes;
91
+ /**
92
+ * もう一周する: 今の周を周回の記録に残し、チェックとスタンプを空にして次の周へ進む。
93
+ * 次の周でも、関所をクリアするとスタンプと演出がまた出る
94
+ */
95
+ declare function nextLap(data: SekishoData, courseId: string, now: Date): Changes;
96
+ /**
97
+ * はじめからやり直す: チェック・スタンプ・周回の記録を全部消して、1 周目に戻る(画面の番号)。
98
+ * 中の周の番号は進める(ほかの端末から古い周の記録が届いても、今の周に混ざらないように)
99
+ */
100
+ declare function restartCourse(data: SekishoData, courseId: string, now: Date): Changes;
101
+ /** コースを消す(進み具合・クリアの記録・周回の記録も一緒に) */
102
+ declare function deleteCourse(data: SekishoData, courseId: string): Changes;
103
+ /** 変更を手元のデータに当てる(新しいデータを返す。元は変えない) */
104
+ declare function applyChanges<T extends SekishoData>(data: T, changes: Changes): T;
105
+ /**
106
+ * 同期・追記で、ほかの端末の進み具合を受け取ったとき、書き直すものを返す。
107
+ * 手元に無いもの・手元より新しい(updatedAt が後の)ものだけ。
108
+ * クリアの記録は消えないので、手元に無い id のものを足すだけでよい
109
+ */
110
+ declare function newerProgress(local: ItemProgress[], incoming: ItemProgress[]): ItemProgress[];
111
+
112
+ /**
113
+ * コースを作る・直す(画面なし)。自分のコースを作る画面と、管理者がコースを作る画面の両方で使う。
114
+ * どの関数も元のコースは変えず、新しいコースを返す。直すたびに revision(設計の版)が 1 つ上がる。
115
+ */
116
+
117
+ /** 新しいコース(関所は空) */
118
+ declare function newCourse(input: {
119
+ title: string;
120
+ description?: string;
121
+ route?: Route;
122
+ origin?: Course['origin'];
123
+ color?: string;
124
+ }, now: Date): Course;
125
+ /** 新しい関所(項目は空) */
126
+ declare function newGate(input: {
127
+ title: string;
128
+ description?: string;
129
+ }): Gate;
130
+ /** 新しいチェック項目 */
131
+ declare function newItem(input: {
132
+ title: string;
133
+ target?: CheckItem['target'];
134
+ count?: number;
135
+ note?: string;
136
+ }): CheckItem;
137
+ /** コースの名前・説明・回り方・色・ご褒美を直す */
138
+ declare function updateCourse(course: Course, patch: Partial<Pick<Course, 'title' | 'description' | 'route' | 'color' | 'reward'>>, now: Date): Course;
139
+ /** 関所を足す(index が無ければ最後に) */
140
+ declare function addGate(course: Course, gate: Gate, now: Date, index?: number): Course;
141
+ /** 関所の名前・説明・スタンプ・ご褒美を直す */
142
+ declare function updateGate(course: Course, gateId: string, patch: Partial<Pick<Gate, 'title' | 'description' | 'stamp' | 'reward' | 'points'>>, now: Date): Course;
143
+ /** 関所を消す(中の項目ごと) */
144
+ declare function removeGate(course: Course, gateId: string, now: Date): Course;
145
+ /** 関所の並びを変える */
146
+ declare function moveGate(course: Course, gateId: string, toIndex: number, now: Date): Course;
147
+ /** 関所にチェック項目を足す(index が無ければ最後に) */
148
+ declare function addItem(course: Course, gateId: string, item: CheckItem, now: Date, index?: number): Course;
149
+ /** チェック項目を直す */
150
+ declare function updateItem(course: Course, itemId: string, patch: Partial<Pick<CheckItem, 'title' | 'note' | 'target' | 'count'>>, now: Date): Course;
151
+ /** チェック項目を消す */
152
+ declare function removeItem(course: Course, itemId: string, now: Date): Course;
153
+ /** チェック項目を動かす(同じ関所の中でも、ほかの関所へも) */
154
+ declare function moveItem(course: Course, itemId: string, toGateId: string, toIndex: number, now: Date): Course;
155
+ /**
156
+ * 複製して自分のコースにする(与えられたコースを、自分用に直したいとき)。
157
+ * 新しい id になるので、進み具合は引き継がない
158
+ */
159
+ declare function duplicateCourse(course: Course, now: Date, title?: string): Course;
160
+
161
+ /** コースのファイルの形 */
162
+ interface SekishoFile {
163
+ format: 'sekisho-courses';
164
+ version: 1;
165
+ courses: Course[];
166
+ }
167
+ /**
168
+ * コースを書き出す(配る用)。
169
+ * 受け取った人のところでは与えられたコースになるように、origin は 'given' にする
170
+ */
171
+ declare function exportCourses(courses: Course[]): SekishoFile;
172
+ /** 1 つのコースの形を確かめる。使えなければ null(errors にわけを足す) */
173
+ declare function readCourse(v: unknown, now: Date, errors?: string[]): Course | null;
174
+ /**
175
+ * コースの JSON を読む。コースのファイル(SekishoFile)・コースの並び・コース 1 つ、のどれでもよい。
176
+ * 形の合わないところは飛ばして、わけを errors に入れる
177
+ */
178
+ declare function parseCourses(input: unknown, now: Date): {
179
+ courses: Course[];
180
+ errors: string[];
181
+ };
182
+ interface ImportResult {
183
+ changes: Changes;
184
+ /** 新しく入れたコース */
185
+ added: Course[];
186
+ /** 新しい版にしたコース */
187
+ updated: Course[];
188
+ /** 入れなかったコース(同じか古い版・同じ id の自分のコース) */
189
+ skipped: Course[];
190
+ }
191
+ /**
192
+ * 配られたコースを取り込む(パックを取り込んだときなど)。
193
+ * - この端末に無いコースは足す
194
+ * - あるコースは、配られたほうが新しい版(revision が大きい。同じなら updatedAt が後)のときだけ置きかえる。
195
+ * 進み具合はチェック項目の id で結びつくので残る。一度クリアした関所はクリアのまま
196
+ * - 同じ id の自分のコースは置きかえない
197
+ * 取り込んだコースは与えられたコース(origin: 'given')になる
198
+ */
199
+ declare function importCourses(data: SekishoData, incoming: Course[], now: Date): ImportResult;
200
+
201
+ export { Activity, Changes, CheckItem, Course, Gate, ItemProgress, Lap, Route, SekishoData, TargetRef, addGate, addItem, addOne, applyChanges, checkItem, clearId, currentLap, deleteCourse, duplicateCourse, exportCourses, importCourses, isGateOpen, itemGoal, lapId, moveGate, moveItem, newCourse, newGate, newItem, newerProgress, nextLap, parseCourses, progressId, readCourse, removeGate, removeItem, removeOne, report, restartCourse, sameTarget, settleClears, toggleItem, uncheckItem, updateCourse, updateGate, updateItem, viewCourse };
202
+ export type { CourseView, GateView, ImportResult, ItemView, SekishoFile };
@@ -0,0 +1,82 @@
1
+ 'use client'
2
+ import {
3
+ addOne,
4
+ applyChanges,
5
+ checkItem,
6
+ clearId,
7
+ currentLap,
8
+ deleteCourse,
9
+ exportCourses,
10
+ importCourses,
11
+ isGateOpen,
12
+ itemGoal,
13
+ lapId,
14
+ newerProgress,
15
+ nextLap,
16
+ parseCourses,
17
+ progressId,
18
+ readCourse,
19
+ removeOne,
20
+ report,
21
+ restartCourse,
22
+ sameTarget,
23
+ settleClears,
24
+ toggleItem,
25
+ uncheckItem,
26
+ viewCourse
27
+ } from "../chunk-7YUKMUSF.js";
28
+ import {
29
+ addGate,
30
+ addItem,
31
+ duplicateCourse,
32
+ moveGate,
33
+ moveItem,
34
+ newCourse,
35
+ newGate,
36
+ newItem,
37
+ removeGate,
38
+ removeItem,
39
+ updateCourse,
40
+ updateGate,
41
+ updateItem
42
+ } from "../chunk-IQYSUTRQ.js";
43
+ export {
44
+ addGate,
45
+ addItem,
46
+ addOne,
47
+ applyChanges,
48
+ checkItem,
49
+ clearId,
50
+ currentLap,
51
+ deleteCourse,
52
+ duplicateCourse,
53
+ exportCourses,
54
+ importCourses,
55
+ isGateOpen,
56
+ itemGoal,
57
+ lapId,
58
+ moveGate,
59
+ moveItem,
60
+ newCourse,
61
+ newGate,
62
+ newItem,
63
+ newerProgress,
64
+ nextLap,
65
+ parseCourses,
66
+ progressId,
67
+ readCourse,
68
+ removeGate,
69
+ removeItem,
70
+ removeOne,
71
+ report,
72
+ restartCourse,
73
+ sameTarget,
74
+ settleClears,
75
+ toggleItem,
76
+ uncheckItem,
77
+ updateCourse,
78
+ updateGate,
79
+ updateItem,
80
+ viewCourse
81
+ };
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { C as CourseEditorProps } from '../Sekisho-BgZdhYqq.js';
3
+ import '../types-73liizfJ.js';
4
+
5
+ /**
6
+ * コースを作る・直す画面。自分のコースにも、管理者が配るコースにも使う。
7
+ * 関所はカードにして段組みで並べ、ドラッグで動かす(linkshelf の <CardBoard>)。
8
+ * 保存するまでは、手元の下書きだけを変える
9
+ */
10
+ declare function CourseEditor({ course, onSave, onCancel, targets, labels: labelsPatch }: CourseEditorProps): react.JSX.Element;
11
+
12
+ export { CourseEditor, CourseEditorProps };