@calenderjs/calendar 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/index.cjs CHANGED
@@ -2,762 +2,14 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const wsxCore = require("@wsxjs/wsx-core");
4
4
  const eventDsl = require("@calenderjs/event-dsl");
5
+ const dateTime = require("@calenderjs/date-time");
6
+ const eventRuntime = require("@calenderjs/event-runtime");
5
7
  const core = require("@calenderjs/core");
6
- const l = /^(\d{4})-(\d{2})-(\d{2})$/;
7
- function i(t) {
8
- if (t instanceof Date) {
9
- if (isNaN(t.getTime()))
10
- throw new Error(`Invalid date: ${t}`);
11
- return t;
12
- }
13
- if (typeof t == "string") {
14
- const e = l.exec(t);
15
- if (e) {
16
- const r = Number(e[1]), o = Number(e[2]), s = Number(e[3]);
17
- return new Date(r, o - 1, s);
18
- }
19
- const n = new Date(t);
20
- if (isNaN(n.getTime()))
21
- throw new Error(`Invalid date: ${t}`);
22
- return n;
23
- }
24
- throw new Error(
25
- `Invalid date type: expected Date or string, got ${typeof t}`
26
- );
27
- }
28
- function m(t) {
29
- const e = i(t);
30
- return new Date(e.getFullYear(), e.getMonth(), 1);
31
- }
32
- function h(t) {
33
- const e = i(t);
34
- return new Date(e.getFullYear(), e.getMonth() + 1, 0);
35
- }
36
- function d(t, e = 1) {
37
- const n = i(t), r = n.getDay();
38
- let o;
39
- e === 0 ? o = n.getDate() - r : o = n.getDate() - r + (r === 0 ? -6 : 1);
40
- const s = new Date(n);
41
- return s.setDate(o), s.setHours(0, 0, 0, 0), s;
42
- }
43
- function w(t, e = 1) {
44
- const n = d(t, e), r = new Date(n);
45
- return r.setDate(r.getDate() + 6), r.setHours(0, 0, 0, 0), r;
46
- }
47
- function S(t, e = 1) {
48
- const n = d(t, e), r = [];
49
- for (let o = 0; o < 7; o++) {
50
- const s = new Date(n);
51
- s.setDate(s.getDate() + o), s.setHours(0, 0, 0, 0), r.push(s);
52
- }
53
- return r;
54
- }
55
- function p(t, e = 1) {
56
- const n = m(t), r = h(t), o = d(n, e), s = w(r, e), c = [], a = new Date(o);
57
- for (; a <= s; ) {
58
- const u = new Date(a);
59
- u.setHours(0, 0, 0, 0), c.push(u), a.setDate(a.getDate() + 1);
60
- }
61
- return c;
62
- }
63
- function y(t, e) {
64
- const n = i(t), r = i(e);
65
- return n.getFullYear() === r.getFullYear() && n.getMonth() === r.getMonth() && n.getDate() === r.getDate();
66
- }
67
- function $(t, e) {
68
- const n = i(t), r = i(e);
69
- return n.getFullYear() === r.getFullYear() && n.getMonth() === r.getMonth();
70
- }
71
- function x() {
72
- return Array.from({ length: 24 }, (t, e) => e);
73
- }
74
- function D(t) {
75
- if (t instanceof Date) {
76
- if (isNaN(t.getTime()))
77
- throw new Error(`Invalid date: ${t}`);
78
- return t;
79
- }
80
- if (typeof t == "string") {
81
- const e = new Date(t);
82
- if (isNaN(e.getTime()))
83
- throw new Error(`Invalid date: ${t}`);
84
- return e;
85
- }
86
- throw new Error(
87
- `Invalid date type: expected Date or string, got ${typeof t}`
88
- );
89
- }
90
- function b$1(t) {
91
- const e = D(t), n = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), o = String(e.getDate()).padStart(2, "0");
92
- return `${n}-${r}-${o}`;
93
- }
94
- function W(t) {
95
- const e = D(t), n = String(e.getHours()).padStart(2, "0"), r = String(e.getMinutes()).padStart(2, "0");
96
- return `${n}:${r}`;
97
- }
98
8
  const styles$3 = '/* Calendar Component Styles - Google Calendar Inspired */\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n font-family: var(\n --calender-font-family,\n "Google Sans",\n Roboto,\n Arial,\n sans-serif\n );\n font-size: var(--calender-font-size, 14px);\n color: var(--calender-text-color, #202124);\n background: var(--calender-bg-color, #fff);\n}\n\n.calendar {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--calender-bg-color, #fff);\n}\n\n/* Toolbar Styles */\n.calendar-toolbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--calender-toolbar-padding, 8px 16px);\n border-bottom: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n min-height: var(--calender-toolbar-min-height, 48px);\n}\n\n.calendar-toolbar-left {\n display: flex;\n align-items: center;\n gap: var(--calender-toolbar-gap, 8px);\n}\n\n.calendar-toolbar-right {\n display: flex;\n align-items: center;\n gap: var(--calender-toolbar-gap, 8px);\n}\n\n.calendar-nav-button {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--calender-nav-button-size, 40px);\n height: var(--calender-nav-button-size, 40px);\n border: none;\n background: transparent;\n border-radius: 50%;\n cursor: pointer;\n color: var(--calender-text-secondary-color, #5f6368);\n transition: background-color var(--calender-transition-duration, 0.2s);\n}\n\n.calendar-nav-button:hover {\n background-color: var(--calender-hover-bg-color, #f1f3f4);\n}\n\n.calendar-nav-button:active {\n background-color: var(--calender-active-bg-color, #e8eaed);\n}\n\n.calendar-nav-button svg {\n width: var(--calender-icon-size, 24px);\n height: var(--calender-icon-size, 24px);\n fill: currentColor;\n}\n\n.calendar-today-button {\n padding: var(--calender-button-padding, 8px 16px);\n border: 1px solid var(--calender-border-color, #dadce0);\n border-radius: var(--calender-border-radius, 4px);\n background: var(--calender-bg-color, #fff);\n color: var(--calender-text-color, #202124);\n font-size: var(--calender-font-size, 14px);\n font-weight: var(--calender-button-font-weight, 500);\n cursor: pointer;\n transition:\n background-color var(--calender-transition-duration, 0.2s),\n border-color var(--calender-transition-duration, 0.2s);\n}\n\n.calendar-today-button:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n border-color: var(--calender-border-hover-color, #c4c7c5);\n}\n\n.calendar-today-button:active {\n background-color: var(--calender-active-bg-color, #f1f3f4);\n}\n\n.calendar-toolbar-date {\n font-size: var(--calender-toolbar-date-font-size, 22px);\n font-weight: var(--calender-toolbar-date-font-weight, 400);\n color: var(--calender-text-color, #202124);\n margin-left: var(--calender-toolbar-gap, 8px);\n min-width: var(--calender-toolbar-date-min-width, 200px);\n}\n\n.calendar-view-buttons {\n display: flex;\n gap: 0;\n border: 1px solid var(--calender-border-color, #dadce0);\n border-radius: var(--calender-border-radius, 4px);\n overflow: hidden;\n}\n\n.calendar-view-button {\n padding: var(--calender-button-padding, 8px 16px);\n border: none;\n background: var(--calender-bg-color, #fff);\n color: var(--calender-text-secondary-color, #5f6368);\n font-size: var(--calender-font-size, 14px);\n font-weight: var(--calender-button-font-weight, 500);\n cursor: pointer;\n transition:\n background-color var(--calender-transition-duration, 0.2s),\n color var(--calender-transition-duration, 0.2s);\n border-right: 1px solid var(--calender-border-color, #dadce0);\n}\n\n.calendar-view-button:last-child {\n border-right: none;\n}\n\n.calendar-view-button:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.calendar-view-button.active {\n background-color: var(--calender-primary-color, #1a73e8);\n color: var(--calender-primary-text-color, #fff);\n}\n\n.calendar-view-button.active:hover {\n background-color: var(--calender-primary-hover-color, #1765cc);\n}\n';
99
- class b {
100
- constructor(t) {
101
- this.dataModel = t;
102
- }
103
- /**
104
- * 获取 Data Model(只读)
105
- */
106
- getDataModel() {
107
- return this.dataModel;
108
- }
109
- /**
110
- * 验证事件
111
- *
112
- * **验证流程**:
113
- * 1. DSL 文本定义验证规则(在 `validate:` 部分)
114
- * 2. DSL 解析器将验证规则解析为 AST(`this.ast.validate: ValidationRule[]`)
115
- * 3. 运行时**使用** AST 中的验证规则,**验证** Event 数据模型的数据
116
- * - 使用:`this.ast.validate`(AST 中的验证规则)
117
- * - 验证:`event: Event`(Event 数据模型的数据,来自 @calenderjs/event-model)
118
- *
119
- * **验证内容**(基于 DSL 中定义的验证规则,业务规则,需要运行时数据):
120
- * 1. **Between 规则**:字段值在范围内
121
- * - DSL:`attendees.count between 1 and 50`
122
- * - 验证:`event.data.attendees.length` 是否在 1-50 之间
123
- *
124
- * 2. **Comparison 规则**:比较表达式
125
- * - DSL:`startTime.hour >= 9`、`duration < 2 hours`
126
- * - 验证:字段值与常量或表达式的比较
127
- *
128
- * 3. **NoConflict 规则**:检查时间冲突
129
- * - DSL:`no conflict with other events`
130
- * - 验证:事件时间是否与其他事件冲突(需要 context.events)
131
- *
132
- * 4. **Conflict 规则**:检查是否有冲突(与 NoConflict 相反)
133
- * - DSL:`conflict with other events`
134
- * - 验证:事件时间是否与其他事件冲突
135
- *
136
- * 5. **When 规则**:条件满足时执行子规则
137
- * - DSL:`when priority is high: attendees.count >= 5`
138
- * - 验证:条件满足时执行子规则验证
139
- *
140
- * **重要**:
141
- * - 运行时**使用** AST 中的验证规则(`this.ast.validate`)
142
- * - 运行时**验证** Event 数据模型的数据(`event: Event`,来自 @calenderjs/event-model)
143
- * - 这些验证需要运行时数据(event.data.attendees.length)
144
- * - 这些验证需要上下文信息(context.events, context.now, context.user)
145
- * - 这些验证无法在编译时验证(数据是动态的)
146
- * - 这些验证无法通过 JSON Schema 验证(JSON Schema 只能验证结构)
147
- *
148
- * @param event 要验证的 Event 对象(来自 @calenderjs/event-model,Event 数据模型)
149
- * @param context 验证上下文(包含 events, now, user 等信息)
150
- * @returns 验证结果
151
- */
152
- validate(t, i2) {
153
- const s = [], e = this.validateBaseTimeRules(t, i2);
154
- e.length > 0 && s.push(...e);
155
- const n = this.dataModel.validationRules || [];
156
- for (const r of n) {
157
- const a = this.evaluateValidationRule(r, t, i2);
158
- a.valid || s.push(...a.errors || []);
159
- }
160
- return {
161
- valid: s.length === 0,
162
- errors: s.length > 0 ? s : void 0
163
- };
164
- }
165
- /**
166
- * 验证基础时间规则(自动应用)
167
- *
168
- * 这些规则基于 constraints 中的约束值自动验证
169
- */
170
- validateBaseTimeRules(t, i2) {
171
- const s = [], e = this.dataModel.constraints || [], n = (u) => e.find((d2) => d2.name === u)?.value, r = t.startTime instanceof Date ? t.startTime : new Date(t.startTime), a = t.endTime instanceof Date ? t.endTime : new Date(t.endTime);
172
- r >= a && s.push("开始时间必须早于结束时间");
173
- const o = n("minDuration");
174
- if (o) {
175
- const u = this.durationToMinutes(o), l2 = this.getFieldValue(
176
- { type: "FieldAccess", path: ["duration"] },
177
- t,
178
- i2
179
- );
180
- l2 !== void 0 && l2 < u && s.push(`持续时间必须至少 ${this.formatDuration(u)}`);
181
- }
182
- const c = n("maxDuration");
183
- if (c) {
184
- const u = this.durationToMinutes(c), l2 = this.getFieldValue(
185
- { type: "FieldAccess", path: ["duration"] },
186
- t,
187
- i2
188
- );
189
- l2 !== void 0 && l2 > u && s.push(`持续时间不能超过 ${this.formatDuration(u)}`);
190
- }
191
- const f = n("timePrecision");
192
- if (f) {
193
- const u = this.durationToMinutes(f);
194
- r.getUTCMinutes() % u !== 0 && s.push(`开始时间的分钟数必须是 ${u} 的倍数`), a.getUTCMinutes() % u !== 0 && s.push(`结束时间的分钟数必须是 ${u} 的倍数`);
195
- }
196
- const T = n("minAdvanceTime");
197
- if (T && i2.now) {
198
- const u = this.durationToMinutes(T), l2 = i2.now instanceof Date ? i2.now : new Date(i2.now), d2 = new Date(l2.getTime() + u * 60 * 1e3);
199
- r < d2 && s.push(
200
- `开始时间必须至少提前 ${this.formatDuration(u)} 创建`
201
- );
202
- }
203
- const D2 = n("maxAdvanceTime");
204
- if (D2 && i2.now) {
205
- const u = this.durationToMinutes(D2), l2 = i2.now instanceof Date ? i2.now : new Date(i2.now), d2 = new Date(l2.getTime() + u * 60 * 1e3);
206
- r > d2 && s.push(
207
- `开始时间不能超过 ${this.formatDuration(u)} 后创建`
208
- );
209
- }
210
- const m2 = n("timeZone");
211
- m2 && t.timeZone && t.timeZone !== m2 && s.push(`事件时区必须是 ${m2}`);
212
- const h2 = n("allowedTimeZones");
213
- if (h2 && Array.isArray(h2) && t.timeZone && (h2.includes(t.timeZone) || s.push(`事件时区必须是以下之一: ${h2.join(", ")}`)), t.allDay === true) {
214
- const u = r.getUTCHours(), l2 = r.getUTCMinutes(), d2 = r.getUTCSeconds(), w2 = r.getUTCMilliseconds();
215
- (u !== 0 || l2 !== 0 || d2 !== 0 || w2 !== 0) && s.push("全天事件的开始时间应该是当天的 00:00:00");
216
- const p2 = a.getUTCHours(), g = a.getUTCMinutes(), y2 = a.getUTCSeconds(), V = a.getUTCMilliseconds();
217
- if (!(p2 === 23 && g === 59 && y2 === 59 || p2 === 0 && g === 0 && y2 === 0 && V === 0)) {
218
- const C = r.toISOString().split("T")[0];
219
- a.toISOString().split("T")[0] !== C && p2 === 0 && g === 0 && y2 === 0 && V === 0 || s.push(
220
- "全天事件的结束时间应该是当天的 23:59:59 或次日的 00:00:00"
221
- );
222
- }
223
- } else if (n("allowCrossDay") === false) {
224
- const l2 = r.toISOString().split("T")[0], d2 = a.toISOString().split("T")[0];
225
- l2 !== d2 && s.push("不允许跨天事件");
226
- }
227
- const M = n("maxCrossDayDuration");
228
- if (M) {
229
- const u = this.durationToDays(M), l2 = new Date(r.toISOString().split("T")[0]), d2 = new Date(a.toISOString().split("T")[0]);
230
- Math.ceil(
231
- (d2.getTime() - l2.getTime()) / (1e3 * 60 * 60 * 24)
232
- ) > u && s.push(`跨天时长不能超过 ${u} 天`);
233
- }
234
- const v = this.validateRecurringRules(t, i2);
235
- return v.length > 0 && s.push(...v), s;
236
- }
237
- /**
238
- * 验证重复事件规则
239
- */
240
- validateRecurringRules(t, i2) {
241
- const s = [];
242
- if (!t.recurring)
243
- return s;
244
- const e = t.recurring, n = t.startTime instanceof Date ? t.startTime : new Date(t.startTime);
245
- if (!e.endDate && (!e.count || e.count <= 0) && s.push("重复事件必须设置 endDate 或 count > 0"), e.endDate && (e.endDate instanceof Date ? e.endDate : new Date(e.endDate)) <= n && s.push("重复事件的结束日期必须晚于开始时间"), e.frequency === "weekly")
246
- if (!e.daysOfWeek || !Array.isArray(e.daysOfWeek) || e.daysOfWeek.length === 0)
247
- s.push("weekly 频率的重复事件必须设置 daysOfWeek");
248
- else {
249
- const r = e.daysOfWeek.filter(
250
- (a) => a < 0 || a > 6
251
- );
252
- r.length > 0 && s.push(
253
- `daysOfWeek 值必须在 0-6 之间(0=周日,6=周六),无效值: ${r.join(
254
- ", "
255
- )}`
256
- );
257
- }
258
- if (e.frequency === "monthly" && (e.dayOfMonth === void 0 || e.dayOfMonth === null ? s.push("monthly 频率的重复事件必须设置 dayOfMonth") : (e.dayOfMonth < 1 || e.dayOfMonth > 31) && s.push("dayOfMonth 必须在 1-31 之间")), e.frequency === "yearly" && e.dayOfMonth !== void 0 && e.dayOfMonth !== null && (e.dayOfMonth < 1 || e.dayOfMonth > 31) && s.push("dayOfMonth 必须在 1-31 之间"), (e.interval === void 0 || e.interval <= 0) && s.push("重复事件的 interval 必须大于 0"), e.count !== void 0 && e.count <= 0 && s.push("重复事件的 count 必须大于 0"), e.excludeDates && Array.isArray(e.excludeDates)) {
259
- const r = e.excludeDates.filter((a) => {
260
- const o = a instanceof Date ? a : new Date(a);
261
- return isNaN(o.getTime());
262
- });
263
- r.length > 0 && s.push(
264
- `excludeDates 包含无效的日期格式: ${r.length} 个`
265
- );
266
- }
267
- return s;
268
- }
269
- /**
270
- * 将 Duration 转换为分钟数
271
- */
272
- durationToMinutes(t) {
273
- if (typeof t == "number")
274
- return t;
275
- if (t?.type === "Duration") {
276
- const i2 = t.value;
277
- switch (t.unit) {
278
- case "minutes":
279
- return i2;
280
- case "hours":
281
- return i2 * 60;
282
- case "days":
283
- return i2 * 24 * 60;
284
- case "weeks":
285
- return i2 * 7 * 24 * 60;
286
- default:
287
- return i2;
288
- }
289
- }
290
- return 0;
291
- }
292
- /**
293
- * 将 Duration 转换为天数
294
- */
295
- durationToDays(t) {
296
- if (typeof t == "number")
297
- return t;
298
- if (t?.type === "Duration") {
299
- const i2 = t.value;
300
- switch (t.unit) {
301
- case "days":
302
- return i2;
303
- case "weeks":
304
- return i2 * 7;
305
- case "hours":
306
- return i2 / 24;
307
- case "minutes":
308
- return i2 / 1440;
309
- default:
310
- return i2;
311
- }
312
- }
313
- return 0;
314
- }
315
- /**
316
- * 格式化持续时间为可读字符串
317
- */
318
- formatDuration(t) {
319
- if (t < 60)
320
- return `${t} 分钟`;
321
- if (t < 1440) {
322
- const i2 = Math.floor(t / 60), s = t % 60;
323
- return s > 0 ? `${i2} 小时 ${s} 分钟` : `${i2} 小时`;
324
- } else {
325
- const i2 = Math.floor(t / 1440), s = Math.floor(t % 1440 / 60);
326
- return s > 0 ? `${i2} 天 ${s} 小时` : `${i2} 天`;
327
- }
328
- }
329
- /**
330
- * 渲染事件
331
- */
332
- render(t, i2) {
333
- const s = {
334
- title: t.title,
335
- color: "#4285f4",
336
- description: ""
337
- }, e = this.dataModel.displayRules || [];
338
- for (const n of e) {
339
- const r = this.evaluateDisplayValue(n.value, t, i2);
340
- switch (n.name) {
341
- case "color":
342
- s.color = typeof r == "string" ? r : String(r);
343
- break;
344
- case "icon":
345
- s.icon = r;
346
- break;
347
- case "title":
348
- s.title = typeof r == "string" ? r : String(r);
349
- break;
350
- case "description":
351
- s.description = typeof r == "string" ? r : String(r);
352
- break;
353
- }
354
- }
355
- return t.allDay !== void 0 && (s.allDay = t.allDay), s;
356
- }
357
- /**
358
- * 检查是否可以执行某个操作
359
- */
360
- canPerform(t, i2, s) {
361
- const n = (this.dataModel.behaviorRules || []).find(
362
- (r) => r.name === t
363
- );
364
- return n ? typeof n.value == "boolean" ? n.value : this.evaluateExpression(n.value, i2, { user: s }) : false;
365
- }
366
- /**
367
- * 评估验证规则
368
- */
369
- evaluateValidationRule(t, i2, s) {
370
- if (!t)
371
- return { valid: true };
372
- if (t.type === "When") {
373
- if (this.evaluateExpression(
374
- t.condition,
375
- i2,
376
- s
377
- )) {
378
- const n = [];
379
- for (const r of t.rules || []) {
380
- const a = this.evaluateValidationRule(r, i2, s);
381
- a.valid || n.push(...a.errors || []);
382
- }
383
- return {
384
- valid: n.length === 0,
385
- errors: n.length > 0 ? n : void 0
386
- };
387
- }
388
- return { valid: true, errors: [] };
389
- }
390
- if (t.type === "Between") {
391
- const e = this.getFieldValue(t.field, i2, s), n = this.getLiteralValue(t.min), r = this.getLiteralValue(t.max);
392
- if (e == null)
393
- return {
394
- valid: false,
395
- errors: [`字段 ${t.field.path.join(".")} 未定义`]
396
- };
397
- const a = typeof e == "number" ? e : Number(e), o = typeof n == "number" ? n : Number(n), c = typeof r == "number" ? r : Number(r);
398
- if (isNaN(a) || isNaN(o) || isNaN(c))
399
- return {
400
- valid: false,
401
- errors: [`字段 ${t.field.path.join(".")} 无法进行数值比较`]
402
- };
403
- const f = a >= o && a <= c;
404
- return {
405
- valid: f,
406
- errors: f ? void 0 : [`字段 ${t.field.path.join(".")} 必须在 ${n} 和 ${r} 之间`]
407
- };
408
- }
409
- if (t.type === "In") {
410
- const e = this.getFieldValue(t.field, i2, s);
411
- if (e == null)
412
- return {
413
- valid: false,
414
- errors: [`字段 ${t.field.path.join(".")} 未定义`]
415
- };
416
- const r = (t.values || []).some((a) => {
417
- const o = this.getLiteralValue(a);
418
- return this.compareValues(e, o, "equals");
419
- });
420
- return {
421
- valid: r,
422
- errors: r ? void 0 : [`字段 ${t.field.path.join(".")} 不在允许的值列表中`]
423
- };
424
- }
425
- if (t.type === "ModComparison") {
426
- const e = this.getFieldValue(t.left, i2, s), n = this.getLiteralValue(t.modValue), r = this.getLiteralValue(t.right);
427
- if (e == null)
428
- return {
429
- valid: false,
430
- errors: [`字段 ${t.left.path.join(".")} 未定义`]
431
- };
432
- const a = Number(e), o = Number(n);
433
- if (isNaN(a) || isNaN(o) || o === 0)
434
- return {
435
- valid: false,
436
- errors: [`字段 ${t.left.path.join(".")} 无法进行模运算`]
437
- };
438
- const c = a % o, f = this.compareValues(c, r, t.operator);
439
- return {
440
- valid: f,
441
- errors: f ? void 0 : [
442
- `验证失败: ${t.left.path.join(".")} mod ${n} ${t.operator} ${r} 不满足`
443
- ]
444
- };
445
- }
446
- if (t.type === "Comparison") {
447
- const e = this.getExpressionValue(t.left, i2, s), n = this.getLiteralValue(t.right), r = this.compareValues(e, n, t.operator);
448
- return {
449
- valid: r,
450
- errors: r ? void 0 : [`验证失败: ${t.operator} 比较不满足`]
451
- };
452
- }
453
- if (t.type === "NoConflict") {
454
- const e = this.checkTimeConflict(i2, s.events || []);
455
- return {
456
- valid: !e,
457
- errors: e ? ["事件时间与其他事件冲突"] : void 0
458
- };
459
- }
460
- if (t.type === "Conflict") {
461
- const e = this.checkTimeConflict(i2, s.events || []);
462
- return {
463
- valid: e,
464
- errors: e ? void 0 : ["事件时间未与其他事件冲突"]
465
- };
466
- }
467
- if (t.type === "BinaryExpression") {
468
- const e = this.evaluateExpression(t.left, i2, s), n = this.evaluateExpression(t.right, i2, s);
469
- if (t.operator === "and")
470
- return { valid: e && n };
471
- if (t.operator === "or")
472
- return { valid: e || n };
473
- }
474
- return t.type === "UnaryExpression" && t.operator === "not" ? { valid: !this.evaluateExpression(t.argument, i2, s) } : { valid: true };
475
- }
476
- /**
477
- * 评估显示值
478
- */
479
- evaluateDisplayValue(t, i2, s) {
480
- return typeof t == "string" ? t : t?.type === "Conditional" ? this.evaluateExpression(
481
- t.condition,
482
- i2,
483
- s
484
- ) ? this.evaluateDisplayValue(t.consequent, i2, s) : t.alternate ? this.evaluateDisplayValue(t.alternate, i2, s) : "" : t?.type === "Template" ? this.evaluateTemplate(t, i2, s) : t;
485
- }
486
- /**
487
- * 评估表达式
488
- */
489
- evaluateExpression(t, i2, s) {
490
- if (!t)
491
- return false;
492
- if (t.type === "FieldAccess")
493
- return !!this.getFieldValue(t, i2, s);
494
- if (t.type === "Comparison") {
495
- const e = this.getExpressionValue(t.left, i2, s), n = this.getLiteralValue(t.right);
496
- return this.compareValues(e, n, t.operator);
497
- }
498
- if (t.type === "BinaryExpression") {
499
- const e = this.evaluateExpression(t.left, i2, s), n = this.evaluateExpression(t.right, i2, s);
500
- if (t.operator === "and")
501
- return e && n;
502
- if (t.operator === "or")
503
- return e || n;
504
- }
505
- return t.type === "UnaryExpression" && t.operator === "not" ? !this.evaluateExpression(t.argument, i2, s) : false;
506
- }
507
- /**
508
- * 评估模板
509
- */
510
- evaluateTemplate(t, i2, s) {
511
- return !t || t.type !== "Template" || !Array.isArray(t.parts) ? "" : t.parts.map((e) => {
512
- if (typeof e == "string")
513
- return e;
514
- if (e && e.type === "FieldAccess") {
515
- const n = this.getFieldValue(e, i2, s);
516
- return n != null ? String(n) : "";
517
- }
518
- return "";
519
- }).join("");
520
- }
521
- /**
522
- * 获取字段值
523
- */
524
- getFieldValue(t, i2, s) {
525
- if (!t || t.type !== "FieldAccess" || !Array.isArray(t.path))
526
- return;
527
- const e = t.path;
528
- if (e.length !== 0) {
529
- if (e[0] === "user" && s?.user) {
530
- let n = s.user;
531
- for (let r = 1; r < e.length; r++) {
532
- if (n == null)
533
- return;
534
- n = n[e[r]];
535
- }
536
- return n;
537
- }
538
- if (e.length >= 1) {
539
- const n = e[0];
540
- if (n === "startTime" || n === "endTime") {
541
- const r = n === "startTime" ? i2.startTime : i2.endTime;
542
- if (e.length === 1)
543
- return r;
544
- if (e.length === 2) {
545
- const a = e[1], o = r instanceof Date ? r : new Date(r);
546
- switch (a) {
547
- case "hour":
548
- return o.getUTCHours();
549
- case "minute":
550
- return o.getUTCMinutes();
551
- case "second":
552
- return o.getUTCSeconds();
553
- case "day":
554
- return o.getUTCDate();
555
- case "month":
556
- return o.getUTCMonth() + 1;
557
- case "year":
558
- return o.getUTCFullYear();
559
- case "date":
560
- return o.toISOString().split("T")[0];
561
- case "dayOfWeek":
562
- return o.getUTCDay();
563
- case "timeZone":
564
- return i2.timeZone || i2.recurring?.timeZone || void 0;
565
- default:
566
- return;
567
- }
568
- }
569
- return;
570
- }
571
- if (e.length === 1) {
572
- if (n === "title")
573
- return i2.title;
574
- if (n === "type")
575
- return i2.type;
576
- if (n === "id")
577
- return i2.id;
578
- if (n === "duration") {
579
- if (i2.data?.duration !== void 0)
580
- return i2.data.duration;
581
- const r = i2.startTime instanceof Date ? i2.startTime : new Date(i2.startTime), a = i2.endTime instanceof Date ? i2.endTime : new Date(i2.endTime);
582
- return Math.round((a.getTime() - r.getTime()) / (1e3 * 60));
583
- }
584
- if (n === "now")
585
- return s?.now || /* @__PURE__ */ new Date();
586
- if (n === "created")
587
- return i2.metadata?.createdAt || void 0;
588
- }
589
- }
590
- if (e[0] === "data") {
591
- let n = i2.data;
592
- for (let r = 1; r < e.length; r++) {
593
- if (n == null)
594
- return;
595
- if (Array.isArray(n) && e[r] === "count")
596
- return n.length;
597
- n = n[e[r]];
598
- }
599
- return n;
600
- }
601
- if (e.length > 1) {
602
- let n = i2.data;
603
- for (let r = 0; r < e.length; r++) {
604
- if (n == null)
605
- return;
606
- if (Array.isArray(n) && e[r] === "count")
607
- return n.length;
608
- n = n[e[r]];
609
- }
610
- return n;
611
- }
612
- if (e.length === 1 && i2.data)
613
- return i2.data[e[0]];
614
- }
615
- }
616
- /**
617
- * 获取表达式值
618
- */
619
- getExpressionValue(t, i2, s) {
620
- return t?.type === "FieldAccess" ? this.getFieldValue(t, i2, s) : t;
621
- }
622
- /**
623
- * 获取字面量值
624
- */
625
- getLiteralValue(t) {
626
- if (t == null)
627
- return t;
628
- if (t?.type === "Duration") {
629
- const i2 = t.value || 0, s = t.unit || "minutes";
630
- return i2 * ({
631
- minutes: 1,
632
- hours: 60,
633
- days: 1440,
634
- weeks: 10080
635
- }[s] || 1);
636
- }
637
- return t;
638
- }
639
- /**
640
- * 比较两个值
641
- * 支持日期字符串(YYYY-MM-DD)和时间字符串(HH:mm 或 HH:mm:ss)比较
642
- */
643
- compareValues(t, i2, s) {
644
- const e = this.parseDateString(t), n = this.parseDateString(i2);
645
- if (e !== null && n !== null)
646
- return this.compareDates(e, n, s);
647
- const r = this.parseTimeString(t), a = this.parseTimeString(i2);
648
- if (r !== null && a !== null)
649
- return this.compareTimes(r, a, s);
650
- const o = t instanceof Date ? t.getTime() : t, c = i2 instanceof Date ? i2.getTime() : i2;
651
- switch (s) {
652
- case "is":
653
- case "equals":
654
- return o === c;
655
- case "is not":
656
- case "not equals":
657
- return o !== c;
658
- case ">":
659
- return Number(o) > Number(c);
660
- case ">=":
661
- return Number(o) >= Number(c);
662
- case "<":
663
- return Number(o) < Number(c);
664
- case "<=":
665
- return Number(o) <= Number(c);
666
- default:
667
- return false;
668
- }
669
- }
670
- /**
671
- * 解析日期字符串(YYYY-MM-DD)
672
- * 返回 Date 对象或 null
673
- */
674
- parseDateString(t) {
675
- if (typeof t != "string")
676
- return null;
677
- const i2 = /^(\d{4})-(\d{2})-(\d{2})$/, s = t.match(i2);
678
- if (!s)
679
- return null;
680
- const e = parseInt(s[1], 10), n = parseInt(s[2], 10) - 1, r = parseInt(s[3], 10), a = new Date(Date.UTC(e, n, r));
681
- return a.getUTCFullYear() === e && a.getUTCMonth() === n && a.getUTCDate() === r ? a : null;
682
- }
683
- /**
684
- * 解析时间字符串(HH:mm 或 HH:mm:ss)
685
- * 返回分钟数(从午夜开始)或 null
686
- */
687
- parseTimeString(t) {
688
- if (typeof t != "string")
689
- return null;
690
- const i2 = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/, s = t.match(i2);
691
- if (!s)
692
- return null;
693
- const e = parseInt(s[1], 10), n = parseInt(s[2], 10);
694
- return e < 0 || e > 23 || n < 0 || n > 59 ? null : e * 60 + n;
695
- }
696
- /**
697
- * 比较日期(Date 对象)
698
- */
699
- compareDates(t, i2, s) {
700
- const e = t.getTime(), n = i2.getTime();
701
- switch (s) {
702
- case "is":
703
- case "equals":
704
- return e === n;
705
- case "is not":
706
- case "not equals":
707
- return e !== n;
708
- case ">":
709
- return e > n;
710
- case ">=":
711
- return e >= n;
712
- case "<":
713
- return e < n;
714
- case "<=":
715
- return e <= n;
716
- default:
717
- return false;
718
- }
719
- }
720
- /**
721
- * 比较时间(分钟数)
722
- */
723
- compareTimes(t, i2, s) {
724
- switch (s) {
725
- case "is":
726
- case "equals":
727
- return t === i2;
728
- case "is not":
729
- case "not equals":
730
- return t !== i2;
731
- case ">":
732
- return t > i2;
733
- case ">=":
734
- return t >= i2;
735
- case "<":
736
- return t < i2;
737
- case "<=":
738
- return t <= i2;
739
- default:
740
- return false;
741
- }
742
- }
743
- /**
744
- * 检查时间冲突
745
- */
746
- checkTimeConflict(t, i2) {
747
- for (const s of i2) {
748
- if (s.id === t.id)
749
- continue;
750
- const e = t.startTime.getTime(), n = t.endTime.getTime(), r = s.startTime.getTime(), a = s.endTime.getTime();
751
- if (e < a && n > r)
752
- return true;
753
- }
754
- return false;
755
- }
756
- }
757
9
  function createRuntimeMap(dataModel) {
758
10
  const map = /* @__PURE__ */ new Map();
759
11
  for (const typeModel of dataModel.types) {
760
- map.set(typeModel.id, new b(typeModel));
12
+ map.set(typeModel.id, new eventRuntime.EventRuntime(typeModel));
761
13
  }
762
14
  return map;
763
15
  }
@@ -809,10 +61,70 @@ function canPerformEventAction(action, event, runtimeByType, user) {
809
61
  }
810
62
  return runtime.canPerform(action, event, user);
811
63
  }
64
+ const INVALID_STATE_DATE = "Invalid date for WSX @state";
65
+ const UNSELECTED_DATE_ISO = (/* @__PURE__ */ new Date(0)).toISOString();
66
+ function toStateIso(value) {
67
+ if (typeof value === "string") {
68
+ const parsed = new Date(value);
69
+ if (Number.isNaN(parsed.getTime())) {
70
+ throw new Error(`${INVALID_STATE_DATE}: ${value}`);
71
+ }
72
+ return parsed.toISOString();
73
+ }
74
+ const time = value.getTime();
75
+ if (Number.isNaN(time)) {
76
+ throw new Error(INVALID_STATE_DATE);
77
+ }
78
+ return new Date(time).toISOString();
79
+ }
80
+ function fromStateIso(iso) {
81
+ return new Date(iso);
82
+ }
83
+ function toStateIsoOrUnselected(value) {
84
+ if (value === null || value === void 0) {
85
+ return UNSELECTED_DATE_ISO;
86
+ }
87
+ if (typeof value === "string") {
88
+ const parsed = new Date(value);
89
+ if (Number.isNaN(parsed.getTime())) {
90
+ return UNSELECTED_DATE_ISO;
91
+ }
92
+ return parsed.toISOString();
93
+ }
94
+ return toStateIso(value);
95
+ }
96
+ function normalizeEventForState(event) {
97
+ return {
98
+ ...event,
99
+ startTime: toStateIso(event.startTime),
100
+ endTime: toStateIso(event.endTime)
101
+ };
102
+ }
103
+ function normalizeEventsForState(events) {
104
+ return events.map((event) => normalizeEventForState(event));
105
+ }
106
+ function upgradeProperty(target, prop) {
107
+ if (!Object.prototype.hasOwnProperty.call(target, prop)) {
108
+ return;
109
+ }
110
+ const descriptor = Object.getOwnPropertyDescriptor(target, prop);
111
+ if (!descriptor || descriptor.get || descriptor.set) {
112
+ return;
113
+ }
114
+ const record = target;
115
+ const value = record[prop];
116
+ delete record[prop];
117
+ record[prop] = value;
118
+ }
119
+ function upgradeProperties(target, props) {
120
+ for (const prop of props) {
121
+ upgradeProperty(target, prop);
122
+ }
123
+ }
812
124
  function groupEventsByDate(events) {
813
125
  const grouped = /* @__PURE__ */ new Map();
814
126
  for (const event of events) {
815
- const dateKey = b$1(event.startTime);
127
+ const dateKey = dateTime.formatDateKey(event.startTime);
816
128
  if (!grouped.has(dateKey)) {
817
129
  grouped.set(dateKey, []);
818
130
  }
@@ -823,18 +135,18 @@ function groupEventsByDate(events) {
823
135
  function getEventsForDate(events, date) {
824
136
  return events.filter((event) => {
825
137
  const eventDate = event.startTime instanceof Date ? event.startTime : new Date(event.startTime);
826
- return y(eventDate, date);
138
+ return dateTime.isSameDay(eventDate, date);
827
139
  });
828
140
  }
829
141
  function sortEventsByTime(events) {
830
- return [...events].sort((a, b2) => {
142
+ return [...events].sort((a, b) => {
831
143
  const timeA = (a.startTime instanceof Date ? a.startTime : new Date(a.startTime)).getTime();
832
- const timeB = (b2.startTime instanceof Date ? b2.startTime : new Date(b2.startTime)).getTime();
144
+ const timeB = (b.startTime instanceof Date ? b.startTime : new Date(b.startTime)).getTime();
833
145
  if (timeA !== timeB) {
834
146
  return timeA - timeB;
835
147
  }
836
148
  const endTimeA = (a.endTime instanceof Date ? a.endTime : new Date(a.endTime)).getTime();
837
- const endTimeB = (b2.endTime instanceof Date ? b2.endTime : new Date(b2.endTime)).getTime();
149
+ const endTimeB = (b.endTime instanceof Date ? b.endTime : new Date(b.endTime)).getTime();
838
150
  return endTimeA - endTimeB;
839
151
  });
840
152
  }
@@ -859,7 +171,7 @@ function _defineProperty$3(e, r, t) {
859
171
  return (r = _toPropertyKey$3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
860
172
  }
861
173
  function _applyDecs$3(e, t, r, n, o, a) {
862
- function i2(e2, t2, r2) {
174
+ function i(e2, t2, r2) {
863
175
  return function(n2, o2) {
864
176
  return r2 && r2(n2), e2[t2].call(n2, o2);
865
177
  };
@@ -872,93 +184,93 @@ function _applyDecs$3(e, t, r, n, o, a) {
872
184
  if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
873
185
  return e2;
874
186
  }
875
- function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l22, f2, p22, d2, h2) {
876
- function m2(e3) {
877
- if (!h2(e3)) throw new TypeError("Attempted to access private element on non-instance");
187
+ function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
188
+ function m(e3) {
189
+ if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
878
190
  }
879
- var y2, v = t2[0], g = t2[3], b2 = !u2;
880
- if (!b2) {
191
+ var y, v = t2[0], g = t2[3], b = !u2;
192
+ if (!b) {
881
193
  r2 || Array.isArray(v) || (v = [v]);
882
- var w2 = {}, S2 = [], A = 3 === o2 ? "get" : 4 === o2 || d2 ? "set" : "value";
883
- f2 ? (p22 || d2 ? w2 = { get: _setFunctionName$3(function() {
194
+ var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
195
+ f2 ? (p2 || d ? w = { get: _setFunctionName$3(function() {
884
196
  return g(this);
885
197
  }, n2, "get"), set: function(e3) {
886
198
  t2[4](this, e3);
887
- } } : w2[A] = g, p22 || _setFunctionName$3(w2[A], n2, 2 === o2 ? "" : A)) : p22 || (w2 = Object.getOwnPropertyDescriptor(e2, n2));
199
+ } } : w[A] = g, p2 || _setFunctionName$3(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
888
200
  }
889
201
  for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
890
- var D2 = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
202
+ var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
891
203
  if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
892
204
  s(t3, "An initializer", "be", true), c2.push(t3);
893
205
  }).bind(null, I) };
894
206
  try {
895
- if (b2) (y2 = s(D2.call(E, P, O), "class decorators", "return")) && (P = y2);
207
+ if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
896
208
  else {
897
209
  var k, F;
898
- O.static = l22, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
899
- return m2(e3), w2.value;
900
- } : (o2 < 4 && (k = i2(w2, "get", m2)), 3 !== o2 && (F = i2(w2, "set", m2))) : (k = function(e3) {
210
+ O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
211
+ return m(e3), w.value;
212
+ } : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
901
213
  return e3[n2];
902
214
  }, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
903
215
  e3[n2] = t3;
904
216
  }));
905
- var N = O.access = { has: f2 ? h2.bind() : function(e3) {
217
+ var N = O.access = { has: f2 ? h.bind() : function(e3) {
906
218
  return n2 in e3;
907
219
  } };
908
- if (k && (N.get = k), F && (N.set = F), P = D2.call(E, d2 ? { get: w2.get, set: w2.set } : w2[A], O), d2) {
909
- if ("object" == typeof P && P) (y2 = s(P.get, "accessor.get")) && (w2.get = y2), (y2 = s(P.set, "accessor.set")) && (w2.set = y2), (y2 = s(P.init, "accessor.init")) && S2.push(y2);
220
+ if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
221
+ if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
910
222
  else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
911
- } else s(P, (p22 ? "field" : "method") + " decorators", "return") && (p22 ? S2.push(P) : w2[A] = P);
223
+ } else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
912
224
  }
913
225
  } finally {
914
226
  I.v = true;
915
227
  }
916
228
  }
917
- return (p22 || d2) && u2.push(function(e3, t3) {
918
- for (var r3 = S2.length - 1; r3 >= 0; r3--) t3 = S2[r3].call(e3, t3);
229
+ return (p2 || d) && u2.push(function(e3, t3) {
230
+ for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
919
231
  return t3;
920
- }), p22 || b2 || (f2 ? d2 ? u2.push(i2(w2, "get"), i2(w2, "set")) : u2.push(2 === o2 ? w2[A] : i2.call.bind(w2[A])) : Object.defineProperty(e2, n2, w2)), P;
232
+ }), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
921
233
  }
922
234
  function u(e2, t2) {
923
235
  return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
924
236
  }
925
- if (arguments.length >= 6) var l2 = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
926
- var f = Object.create(null == l2 ? null : l2), p2 = (function(e2, t2, r2, n2) {
927
- var o2, a2, i22 = [], s2 = function(t3) {
237
+ if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
238
+ var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
239
+ var o2, a2, i2 = [], s2 = function(t3) {
928
240
  return _checkInRHS$3(t3) === e2;
929
241
  }, u2 = /* @__PURE__ */ new Map();
930
- function l22(e3) {
931
- e3 && i22.push(c.bind(null, e3));
242
+ function l2(e3) {
243
+ e3 && i2.push(c.bind(null, e3));
932
244
  }
933
245
  for (var f2 = 0; f2 < t2.length; f2++) {
934
- var p22 = t2[f2];
935
- if (Array.isArray(p22)) {
936
- var d2 = p22[1], h2 = p22[2], m2 = p22.length > 3, y2 = 16 & d2, v = !!(8 & d2), g = 0 == (d2 &= 7), b2 = h2 + "/" + v;
937
- if (!g && !m2) {
938
- var w2 = u2.get(b2);
939
- if (true === w2 || 3 === w2 && 4 !== d2 || 4 === w2 && 3 !== d2) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h2);
940
- u2.set(b2, !(d2 > 2) || d2);
246
+ var p2 = t2[f2];
247
+ if (Array.isArray(p2)) {
248
+ var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
249
+ if (!g && !m) {
250
+ var w = u2.get(b);
251
+ if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
252
+ u2.set(b, !(d > 2) || d);
941
253
  }
942
- applyDec(v ? e2 : e2.prototype, p22, y2, m2 ? "#" + h2 : _toPropertyKey$3(h2), d2, n2, v ? a2 = a2 || [] : o2 = o2 || [], i22, v, m2, g, 1 === d2, v && m2 ? s2 : r2);
254
+ applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey$3(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
943
255
  }
944
256
  }
945
- return l22(o2), l22(a2), i22;
257
+ return l2(o2), l2(a2), i2;
946
258
  })(e, t, o, f);
947
- return r.length || u(e, f), { e: p2, get c() {
259
+ return r.length || u(e, f), { e: p, get c() {
948
260
  var t2 = [];
949
261
  return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
950
262
  } };
951
263
  }
952
264
  function _toPropertyKey$3(t) {
953
- var i2 = _toPrimitive$3(t, "string");
954
- return "symbol" == typeof i2 ? i2 : i2 + "";
265
+ var i = _toPrimitive$3(t, "string");
266
+ return "symbol" == typeof i ? i : i + "";
955
267
  }
956
268
  function _toPrimitive$3(t, r) {
957
269
  if ("object" != typeof t || !t) return t;
958
270
  var e = t[Symbol.toPrimitive];
959
271
  if (void 0 !== e) {
960
- var i2 = e.call(t, r);
961
- if ("object" != typeof i2) return i2;
272
+ var i = e.call(t, r);
273
+ if ("object" != typeof i) return i;
962
274
  throw new TypeError("@@toPrimitive must return a primitive value.");
963
275
  }
964
276
  return String(t);
@@ -975,6 +287,7 @@ function _checkInRHS$3(e) {
975
287
  if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
976
288
  return e;
977
289
  }
290
+ const UPGRADABLE_PROPS$3 = ["viewDate", "events", "user"];
978
291
  _classDecs$3 = [wsxCore.autoRegister({
979
292
  tagName: "wsx-day-view"
980
293
  })];
@@ -985,18 +298,15 @@ class DayView extends wsxCore.WebComponent {
985
298
  return ["view-date", "events", "user"];
986
299
  }
987
300
  // ========== 内部状态 ==========
301
+ // 日期存 ISO:避免 WSX reactive Proxy 破坏 Date
988
302
  // ========== Property 访问器(WSX 组件之间使用) ==========
989
303
  get viewDate() {
990
- return this._viewDate;
304
+ return fromStateIso(this._viewDateIso);
991
305
  }
992
306
  set viewDate(value) {
993
- if (value instanceof Date) {
994
- this._viewDate = value;
995
- } else if (typeof value === "string") {
996
- const date = new Date(value);
997
- if (!isNaN(date.getTime())) {
998
- this._viewDate = date;
999
- }
307
+ try {
308
+ this._viewDateIso = toStateIso(value);
309
+ } catch {
1000
310
  }
1001
311
  }
1002
312
  get events() {
@@ -1004,10 +314,11 @@ class DayView extends wsxCore.WebComponent {
1004
314
  }
1005
315
  set events(value) {
1006
316
  if (Array.isArray(value)) {
1007
- this._events = value;
317
+ this._events = normalizeEventsForState(value);
1008
318
  } else if (typeof value === "string") {
1009
319
  try {
1010
- this._events = JSON.parse(value);
320
+ const parsed = JSON.parse(value);
321
+ this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
1011
322
  } catch (e) {
1012
323
  console.error("Invalid events JSON:", value);
1013
324
  this._events = [];
@@ -1037,7 +348,7 @@ class DayView extends wsxCore.WebComponent {
1037
348
  styleName: "wsx-day-view"
1038
349
  });
1039
350
  _defineProperty$3(this, "_autoStyles", styles$2);
1040
- _defineProperty$3(this, "_viewDate", void 0);
351
+ _defineProperty$3(this, "_viewDateIso", void 0);
1041
352
  _defineProperty$3(this, "_events", void 0);
1042
353
  _defineProperty$3(this, "_user", void 0);
1043
354
  _defineProperty$3(this, "_today", void 0);
@@ -1056,10 +367,10 @@ class DayView extends wsxCore.WebComponent {
1056
367
  const today = /* @__PURE__ */ new Date();
1057
368
  today.setHours(0, 0, 0, 0);
1058
369
  this._today = today;
1059
- const [_get_viewDate, _set_viewDate] = this.useState("_viewDate", /* @__PURE__ */ new Date());
1060
- Object.defineProperty(this, "_viewDate", {
1061
- get: _get_viewDate,
1062
- set: _set_viewDate,
370
+ const [_get_viewDateIso, _set_viewDateIso] = this.useState("_viewDateIso", (/* @__PURE__ */ new Date()).toISOString());
371
+ Object.defineProperty(this, "_viewDateIso", {
372
+ get: _get_viewDateIso,
373
+ set: _set_viewDateIso,
1063
374
  enumerable: true,
1064
375
  configurable: true
1065
376
  });
@@ -1091,6 +402,7 @@ class DayView extends wsxCore.WebComponent {
1091
402
  // ========== 生命周期 ==========
1092
403
  onConnected() {
1093
404
  super.onConnected?.();
405
+ upgradeProperties(this, UPGRADABLE_PROPS$3);
1094
406
  this.initializeFromAttributes();
1095
407
  }
1096
408
  onAttributeChanged(name, oldValue, newValue) {
@@ -1135,7 +447,7 @@ class DayView extends wsxCore.WebComponent {
1135
447
  return sortEventsByTime(getEventsForDate(this.events, this.viewDate));
1136
448
  }
1137
449
  get hours() {
1138
- return x();
450
+ return dateTime.getDayHours();
1139
451
  }
1140
452
  get dayStart() {
1141
453
  const dayStart = new Date(this.viewDate);
@@ -1149,7 +461,7 @@ class DayView extends wsxCore.WebComponent {
1149
461
  }
1150
462
  // ========== 渲染 ==========
1151
463
  render() {
1152
- return /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-header" }, /* @__PURE__ */ wsxCore.jsx("div", { class: `day-view-date ${y(this.viewDate, this._today) ? "today" : ""}` }, this.viewDate.getFullYear(), "年", this.viewDate.getMonth() + 1, "月", this.viewDate.getDate(), "日"), /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-events-count" }, this.dayEvents.length, " 个事件")), /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-body" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-time-column" }, this.hours.map((hour) => {
464
+ return /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-header" }, /* @__PURE__ */ wsxCore.jsx("div", { class: `day-view-date ${dateTime.isSameDay(this.viewDate, this._today) ? "today" : ""}` }, this.viewDate.getFullYear(), "年", this.viewDate.getMonth() + 1, "月", this.viewDate.getDate(), "日"), /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-events-count" }, this.dayEvents.length, " 个事件")), /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-body" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-time-column" }, this.hours.map((hour) => {
1153
465
  const hourStr = hour < 10 ? `0${hour}` : `${hour}`;
1154
466
  const timeStr = `${hourStr}:00`;
1155
467
  return /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-hour-label", key: `left-hour-${hour}` }, timeStr);
@@ -1159,7 +471,7 @@ class DayView extends wsxCore.WebComponent {
1159
471
  const position = calculateEventPosition(event, this.dayStart, this.dayEnd);
1160
472
  const eventColor = event.color || "#4285f4";
1161
473
  const eventDescription = event.data?.description;
1162
- return /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event", key: event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event), title: event.title }, /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event-time" }, W(event.startTime), " -", " ", W(event.endTime)), /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event-title" }, event.title), eventDescription && /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event-description" }, eventDescription));
474
+ return /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event", key: event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event), title: event.title }, /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event-time" }, dateTime.getTimeString(event.startTime), " -", " ", dateTime.getTimeString(event.endTime)), /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event-title" }, event.title), eventDescription && /* @__PURE__ */ wsxCore.jsx("div", { class: "day-view-event-description" }, eventDescription));
1163
475
  }))));
1164
476
  }
1165
477
  }
@@ -1173,7 +485,7 @@ function _defineProperty$2(e, r, t) {
1173
485
  return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
1174
486
  }
1175
487
  function _applyDecs$2(e, t, r, n, o, a) {
1176
- function i2(e2, t2, r2) {
488
+ function i(e2, t2, r2) {
1177
489
  return function(n2, o2) {
1178
490
  return r2 && r2(n2), e2[t2].call(n2, o2);
1179
491
  };
@@ -1186,93 +498,93 @@ function _applyDecs$2(e, t, r, n, o, a) {
1186
498
  if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
1187
499
  return e2;
1188
500
  }
1189
- function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l22, f2, p22, d2, h2) {
1190
- function m2(e3) {
1191
- if (!h2(e3)) throw new TypeError("Attempted to access private element on non-instance");
501
+ function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
502
+ function m(e3) {
503
+ if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
1192
504
  }
1193
- var y2, v = t2[0], g = t2[3], b2 = !u2;
1194
- if (!b2) {
505
+ var y, v = t2[0], g = t2[3], b = !u2;
506
+ if (!b) {
1195
507
  r2 || Array.isArray(v) || (v = [v]);
1196
- var w2 = {}, S2 = [], A = 3 === o2 ? "get" : 4 === o2 || d2 ? "set" : "value";
1197
- f2 ? (p22 || d2 ? w2 = { get: _setFunctionName$2(function() {
508
+ var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
509
+ f2 ? (p2 || d ? w = { get: _setFunctionName$2(function() {
1198
510
  return g(this);
1199
511
  }, n2, "get"), set: function(e3) {
1200
512
  t2[4](this, e3);
1201
- } } : w2[A] = g, p22 || _setFunctionName$2(w2[A], n2, 2 === o2 ? "" : A)) : p22 || (w2 = Object.getOwnPropertyDescriptor(e2, n2));
513
+ } } : w[A] = g, p2 || _setFunctionName$2(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
1202
514
  }
1203
515
  for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
1204
- var D2 = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
516
+ var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
1205
517
  if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
1206
518
  s(t3, "An initializer", "be", true), c2.push(t3);
1207
519
  }).bind(null, I) };
1208
520
  try {
1209
- if (b2) (y2 = s(D2.call(E, P, O), "class decorators", "return")) && (P = y2);
521
+ if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
1210
522
  else {
1211
523
  var k, F;
1212
- O.static = l22, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
1213
- return m2(e3), w2.value;
1214
- } : (o2 < 4 && (k = i2(w2, "get", m2)), 3 !== o2 && (F = i2(w2, "set", m2))) : (k = function(e3) {
524
+ O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
525
+ return m(e3), w.value;
526
+ } : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
1215
527
  return e3[n2];
1216
528
  }, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
1217
529
  e3[n2] = t3;
1218
530
  }));
1219
- var N = O.access = { has: f2 ? h2.bind() : function(e3) {
531
+ var N = O.access = { has: f2 ? h.bind() : function(e3) {
1220
532
  return n2 in e3;
1221
533
  } };
1222
- if (k && (N.get = k), F && (N.set = F), P = D2.call(E, d2 ? { get: w2.get, set: w2.set } : w2[A], O), d2) {
1223
- if ("object" == typeof P && P) (y2 = s(P.get, "accessor.get")) && (w2.get = y2), (y2 = s(P.set, "accessor.set")) && (w2.set = y2), (y2 = s(P.init, "accessor.init")) && S2.push(y2);
534
+ if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
535
+ if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
1224
536
  else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1225
- } else s(P, (p22 ? "field" : "method") + " decorators", "return") && (p22 ? S2.push(P) : w2[A] = P);
537
+ } else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
1226
538
  }
1227
539
  } finally {
1228
540
  I.v = true;
1229
541
  }
1230
542
  }
1231
- return (p22 || d2) && u2.push(function(e3, t3) {
1232
- for (var r3 = S2.length - 1; r3 >= 0; r3--) t3 = S2[r3].call(e3, t3);
543
+ return (p2 || d) && u2.push(function(e3, t3) {
544
+ for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
1233
545
  return t3;
1234
- }), p22 || b2 || (f2 ? d2 ? u2.push(i2(w2, "get"), i2(w2, "set")) : u2.push(2 === o2 ? w2[A] : i2.call.bind(w2[A])) : Object.defineProperty(e2, n2, w2)), P;
546
+ }), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
1235
547
  }
1236
548
  function u(e2, t2) {
1237
549
  return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
1238
550
  }
1239
- if (arguments.length >= 6) var l2 = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
1240
- var f = Object.create(null == l2 ? null : l2), p2 = (function(e2, t2, r2, n2) {
1241
- var o2, a2, i22 = [], s2 = function(t3) {
551
+ if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
552
+ var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
553
+ var o2, a2, i2 = [], s2 = function(t3) {
1242
554
  return _checkInRHS$2(t3) === e2;
1243
555
  }, u2 = /* @__PURE__ */ new Map();
1244
- function l22(e3) {
1245
- e3 && i22.push(c.bind(null, e3));
556
+ function l2(e3) {
557
+ e3 && i2.push(c.bind(null, e3));
1246
558
  }
1247
559
  for (var f2 = 0; f2 < t2.length; f2++) {
1248
- var p22 = t2[f2];
1249
- if (Array.isArray(p22)) {
1250
- var d2 = p22[1], h2 = p22[2], m2 = p22.length > 3, y2 = 16 & d2, v = !!(8 & d2), g = 0 == (d2 &= 7), b2 = h2 + "/" + v;
1251
- if (!g && !m2) {
1252
- var w2 = u2.get(b2);
1253
- if (true === w2 || 3 === w2 && 4 !== d2 || 4 === w2 && 3 !== d2) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h2);
1254
- u2.set(b2, !(d2 > 2) || d2);
560
+ var p2 = t2[f2];
561
+ if (Array.isArray(p2)) {
562
+ var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
563
+ if (!g && !m) {
564
+ var w = u2.get(b);
565
+ if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
566
+ u2.set(b, !(d > 2) || d);
1255
567
  }
1256
- applyDec(v ? e2 : e2.prototype, p22, y2, m2 ? "#" + h2 : _toPropertyKey$2(h2), d2, n2, v ? a2 = a2 || [] : o2 = o2 || [], i22, v, m2, g, 1 === d2, v && m2 ? s2 : r2);
568
+ applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey$2(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
1257
569
  }
1258
570
  }
1259
- return l22(o2), l22(a2), i22;
571
+ return l2(o2), l2(a2), i2;
1260
572
  })(e, t, o, f);
1261
- return r.length || u(e, f), { e: p2, get c() {
573
+ return r.length || u(e, f), { e: p, get c() {
1262
574
  var t2 = [];
1263
575
  return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
1264
576
  } };
1265
577
  }
1266
578
  function _toPropertyKey$2(t) {
1267
- var i2 = _toPrimitive$2(t, "string");
1268
- return "symbol" == typeof i2 ? i2 : i2 + "";
579
+ var i = _toPrimitive$2(t, "string");
580
+ return "symbol" == typeof i ? i : i + "";
1269
581
  }
1270
582
  function _toPrimitive$2(t, r) {
1271
583
  if ("object" != typeof t || !t) return t;
1272
584
  var e = t[Symbol.toPrimitive];
1273
585
  if (void 0 !== e) {
1274
- var i2 = e.call(t, r);
1275
- if ("object" != typeof i2) return i2;
586
+ var i = e.call(t, r);
587
+ if ("object" != typeof i) return i;
1276
588
  throw new TypeError("@@toPrimitive must return a primitive value.");
1277
589
  }
1278
590
  return String(t);
@@ -1289,6 +601,7 @@ function _checkInRHS$2(e) {
1289
601
  if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
1290
602
  return e;
1291
603
  }
604
+ const UPGRADABLE_PROPS$2 = ["viewDate", "events", "selectedDate", "user"];
1292
605
  _classDecs$2 = [wsxCore.autoRegister({
1293
606
  tagName: "wsx-month-view"
1294
607
  })];
@@ -1299,18 +612,15 @@ class MonthView extends wsxCore.WebComponent {
1299
612
  return ["view-date", "events", "selected-date", "user"];
1300
613
  }
1301
614
  // ========== 内部状态 ==========
615
+ // 日期存 ISO:避免 WSX reactive Proxy 破坏 Date
1302
616
  // ========== Property 访问器(WSX 组件之间使用) ==========
1303
617
  get viewDate() {
1304
- return this._viewDate;
618
+ return fromStateIso(this._viewDateIso);
1305
619
  }
1306
620
  set viewDate(value) {
1307
- if (value instanceof Date) {
1308
- this._viewDate = new Date(value);
1309
- } else if (typeof value === "string") {
1310
- const date = new Date(value);
1311
- if (!isNaN(date.getTime())) {
1312
- this._viewDate = date;
1313
- }
621
+ try {
622
+ this._viewDateIso = toStateIso(value);
623
+ } catch {
1314
624
  }
1315
625
  }
1316
626
  get events() {
@@ -1318,10 +628,11 @@ class MonthView extends wsxCore.WebComponent {
1318
628
  }
1319
629
  set events(value) {
1320
630
  if (Array.isArray(value)) {
1321
- this._events = value;
631
+ this._events = normalizeEventsForState(value);
1322
632
  } else if (typeof value === "string") {
1323
633
  try {
1324
- this._events = JSON.parse(value);
634
+ const parsed = JSON.parse(value);
635
+ this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
1325
636
  } catch (e) {
1326
637
  console.error("Invalid events JSON:", value);
1327
638
  this._events = [];
@@ -1331,21 +642,10 @@ class MonthView extends wsxCore.WebComponent {
1331
642
  }
1332
643
  }
1333
644
  get selectedDate() {
1334
- return this._selectedDate;
645
+ return fromStateIso(this._selectedDateIso);
1335
646
  }
1336
647
  set selectedDate(value) {
1337
- if (value instanceof Date) {
1338
- this._selectedDate = value;
1339
- } else if (typeof value === "string") {
1340
- const date = new Date(value);
1341
- if (!isNaN(date.getTime())) {
1342
- this._selectedDate = date;
1343
- } else {
1344
- this._selectedDate = /* @__PURE__ */ new Date(0);
1345
- }
1346
- } else if (value === void 0 || value === null) {
1347
- this._selectedDate = /* @__PURE__ */ new Date(0);
1348
- }
648
+ this._selectedDateIso = toStateIsoOrUnselected(value);
1349
649
  }
1350
650
  get user() {
1351
651
  return this._user;
@@ -1368,9 +668,9 @@ class MonthView extends wsxCore.WebComponent {
1368
668
  styleName: "wsx-month-view"
1369
669
  });
1370
670
  _defineProperty$2(this, "_autoStyles", styles$1);
1371
- _defineProperty$2(this, "_viewDate", void 0);
671
+ _defineProperty$2(this, "_viewDateIso", void 0);
1372
672
  _defineProperty$2(this, "_events", void 0);
1373
- _defineProperty$2(this, "_selectedDate", void 0);
673
+ _defineProperty$2(this, "_selectedDateIso", void 0);
1374
674
  _defineProperty$2(this, "_user", void 0);
1375
675
  _defineProperty$2(this, "_today", void 0);
1376
676
  _defineProperty$2(this, "onDateClick", void 0);
@@ -1430,10 +730,10 @@ class MonthView extends wsxCore.WebComponent {
1430
730
  const today = /* @__PURE__ */ new Date();
1431
731
  today.setHours(0, 0, 0, 0);
1432
732
  this._today = today;
1433
- const [_get_viewDate, _set_viewDate] = this.useState("_viewDate", /* @__PURE__ */ new Date());
1434
- Object.defineProperty(this, "_viewDate", {
1435
- get: _get_viewDate,
1436
- set: _set_viewDate,
733
+ const [_get_viewDateIso, _set_viewDateIso] = this.useState("_viewDateIso", (/* @__PURE__ */ new Date()).toISOString());
734
+ Object.defineProperty(this, "_viewDateIso", {
735
+ get: _get_viewDateIso,
736
+ set: _set_viewDateIso,
1437
737
  enumerable: true,
1438
738
  configurable: true
1439
739
  });
@@ -1447,10 +747,10 @@ class MonthView extends wsxCore.WebComponent {
1447
747
  enumerable: true,
1448
748
  configurable: true
1449
749
  });
1450
- const [_get_selectedDate, _set_selectedDate] = this.useState("_selectedDate", /* @__PURE__ */ new Date(0));
1451
- Object.defineProperty(this, "_selectedDate", {
1452
- get: _get_selectedDate,
1453
- set: _set_selectedDate,
750
+ const [_get_selectedDateIso, _set_selectedDateIso] = this.useState("_selectedDateIso", UNSELECTED_DATE_ISO);
751
+ Object.defineProperty(this, "_selectedDateIso", {
752
+ get: _get_selectedDateIso,
753
+ set: _set_selectedDateIso,
1454
754
  enumerable: true,
1455
755
  configurable: true
1456
756
  });
@@ -1472,6 +772,7 @@ class MonthView extends wsxCore.WebComponent {
1472
772
  // ========== 生命周期 ==========
1473
773
  onConnected() {
1474
774
  super.onConnected?.();
775
+ upgradeProperties(this, UPGRADABLE_PROPS$2);
1475
776
  this.initializeFromAttributes();
1476
777
  }
1477
778
  onAttributeChanged(name, oldValue, newValue) {
@@ -1526,11 +827,13 @@ class MonthView extends wsxCore.WebComponent {
1526
827
  }
1527
828
  // ========== Getters ==========
1528
829
  get monthDates() {
1529
- if (!this._viewDate || !(this._viewDate instanceof Date) || isNaN(this._viewDate.getTime())) {
1530
- this._viewDate = /* @__PURE__ */ new Date();
830
+ let viewDate = this.viewDate;
831
+ if (Number.isNaN(viewDate.getTime())) {
832
+ this._viewDateIso = toStateIso(/* @__PURE__ */ new Date());
833
+ viewDate = this.viewDate;
1531
834
  }
1532
835
  try {
1533
- return p(this._viewDate, 0);
836
+ return dateTime.getMonthDates(viewDate, 0);
1534
837
  } catch (e) {
1535
838
  console.error("Error getting month dates:", e);
1536
839
  return [];
@@ -1552,14 +855,14 @@ class MonthView extends wsxCore.WebComponent {
1552
855
  }
1553
856
  const normalizedDate = new Date(date);
1554
857
  normalizedDate.setHours(0, 0, 0, 0);
1555
- const dateKey = b$1(normalizedDate);
858
+ const dateKey = dateTime.formatDateKey(normalizedDate);
1556
859
  const dayEvents = sortEventsByTime(this.eventsByDate.get(dateKey) || []);
1557
- const isCurrentMonth = this._viewDate && this._viewDate instanceof Date && !isNaN(this._viewDate.getTime()) ? $(normalizedDate, this._viewDate) : false;
1558
- this._selectedDate.getTime() !== 0 && y(normalizedDate, this._selectedDate);
1559
- const isToday = y(normalizedDate, this._today);
860
+ const isCurrentMonth = !Number.isNaN(this.viewDate.getTime()) ? dateTime.isSameMonth(normalizedDate, this.viewDate) : false;
861
+ this.selectedDate.getTime() !== 0 && dateTime.isSameDay(normalizedDate, this.selectedDate);
862
+ const isToday = dateTime.isSameDay(normalizedDate, this._today);
1560
863
  return /* @__PURE__ */ wsxCore.jsx("div", { key: dateKey, class: `month-view-cell ${!isCurrentMonth ? "other-month" : ""} ${isToday && isCurrentMonth ? "today" : ""}`, onClick: () => this.handleDateClick(normalizedDate), onDblClick: () => this.handleDateDoubleClick(normalizedDate) }, /* @__PURE__ */ wsxCore.jsx("div", { class: "month-view-cell-date" }, normalizedDate.getDate()), /* @__PURE__ */ wsxCore.jsx("div", { class: "month-view-cell-events" }, dayEvents.slice(0, 3).map((event) => {
1561
864
  const eventColor = event.color || "#4285f4";
1562
- return /* @__PURE__ */ wsxCore.jsx("div", { class: "month-view-event", key: event.id, style: `background-color: ${eventColor}`, onClick: (evt) => this.handleEventClick(event, evt) }, /* @__PURE__ */ wsxCore.jsx("span", { class: "month-view-event-title" }, event.title), this.onEventDelete && /* @__PURE__ */ wsxCore.jsx("button", { class: "month-view-event-delete", onClick: (evt) => this.handleEventDelete(event, evt), "data-wsx-key": "MonthView-button-text-0" }, "×"));
865
+ return /* @__PURE__ */ wsxCore.jsx("div", { class: "month-view-event", key: event.id, style: `background-color: ${eventColor}`, onClick: (evt) => this.handleEventClick(event, evt) }, /* @__PURE__ */ wsxCore.jsx("span", { class: "month-view-event-title" }, event.title), this.onEventDelete && /* @__PURE__ */ wsxCore.jsx("button", { class: "month-view-event-delete", onClick: (evt) => this.handleEventDelete(event, evt) }, "×"));
1563
866
  }), dayEvents.length > 3 && /* @__PURE__ */ wsxCore.jsx("div", { class: "month-view-more" }, "+", dayEvents.length - 3, " 更多")));
1564
867
  })));
1565
868
  }
@@ -1574,7 +877,7 @@ function _defineProperty$1(e, r, t) {
1574
877
  return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
1575
878
  }
1576
879
  function _applyDecs$1(e, t, r, n, o, a) {
1577
- function i2(e2, t2, r2) {
880
+ function i(e2, t2, r2) {
1578
881
  return function(n2, o2) {
1579
882
  return r2 && r2(n2), e2[t2].call(n2, o2);
1580
883
  };
@@ -1587,93 +890,93 @@ function _applyDecs$1(e, t, r, n, o, a) {
1587
890
  if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
1588
891
  return e2;
1589
892
  }
1590
- function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l22, f2, p22, d2, h2) {
1591
- function m2(e3) {
1592
- if (!h2(e3)) throw new TypeError("Attempted to access private element on non-instance");
893
+ function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
894
+ function m(e3) {
895
+ if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
1593
896
  }
1594
- var y2, v = t2[0], g = t2[3], b2 = !u2;
1595
- if (!b2) {
897
+ var y, v = t2[0], g = t2[3], b = !u2;
898
+ if (!b) {
1596
899
  r2 || Array.isArray(v) || (v = [v]);
1597
- var w2 = {}, S2 = [], A = 3 === o2 ? "get" : 4 === o2 || d2 ? "set" : "value";
1598
- f2 ? (p22 || d2 ? w2 = { get: _setFunctionName$1(function() {
900
+ var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
901
+ f2 ? (p2 || d ? w = { get: _setFunctionName$1(function() {
1599
902
  return g(this);
1600
903
  }, n2, "get"), set: function(e3) {
1601
904
  t2[4](this, e3);
1602
- } } : w2[A] = g, p22 || _setFunctionName$1(w2[A], n2, 2 === o2 ? "" : A)) : p22 || (w2 = Object.getOwnPropertyDescriptor(e2, n2));
905
+ } } : w[A] = g, p2 || _setFunctionName$1(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
1603
906
  }
1604
907
  for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
1605
- var D2 = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
908
+ var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
1606
909
  if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
1607
910
  s(t3, "An initializer", "be", true), c2.push(t3);
1608
911
  }).bind(null, I) };
1609
912
  try {
1610
- if (b2) (y2 = s(D2.call(E, P, O), "class decorators", "return")) && (P = y2);
913
+ if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
1611
914
  else {
1612
915
  var k, F;
1613
- O.static = l22, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
1614
- return m2(e3), w2.value;
1615
- } : (o2 < 4 && (k = i2(w2, "get", m2)), 3 !== o2 && (F = i2(w2, "set", m2))) : (k = function(e3) {
916
+ O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
917
+ return m(e3), w.value;
918
+ } : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
1616
919
  return e3[n2];
1617
920
  }, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
1618
921
  e3[n2] = t3;
1619
922
  }));
1620
- var N = O.access = { has: f2 ? h2.bind() : function(e3) {
923
+ var N = O.access = { has: f2 ? h.bind() : function(e3) {
1621
924
  return n2 in e3;
1622
925
  } };
1623
- if (k && (N.get = k), F && (N.set = F), P = D2.call(E, d2 ? { get: w2.get, set: w2.set } : w2[A], O), d2) {
1624
- if ("object" == typeof P && P) (y2 = s(P.get, "accessor.get")) && (w2.get = y2), (y2 = s(P.set, "accessor.set")) && (w2.set = y2), (y2 = s(P.init, "accessor.init")) && S2.push(y2);
926
+ if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
927
+ if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
1625
928
  else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1626
- } else s(P, (p22 ? "field" : "method") + " decorators", "return") && (p22 ? S2.push(P) : w2[A] = P);
929
+ } else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
1627
930
  }
1628
931
  } finally {
1629
932
  I.v = true;
1630
933
  }
1631
934
  }
1632
- return (p22 || d2) && u2.push(function(e3, t3) {
1633
- for (var r3 = S2.length - 1; r3 >= 0; r3--) t3 = S2[r3].call(e3, t3);
935
+ return (p2 || d) && u2.push(function(e3, t3) {
936
+ for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
1634
937
  return t3;
1635
- }), p22 || b2 || (f2 ? d2 ? u2.push(i2(w2, "get"), i2(w2, "set")) : u2.push(2 === o2 ? w2[A] : i2.call.bind(w2[A])) : Object.defineProperty(e2, n2, w2)), P;
938
+ }), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
1636
939
  }
1637
940
  function u(e2, t2) {
1638
941
  return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
1639
942
  }
1640
- if (arguments.length >= 6) var l2 = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
1641
- var f = Object.create(null == l2 ? null : l2), p2 = (function(e2, t2, r2, n2) {
1642
- var o2, a2, i22 = [], s2 = function(t3) {
943
+ if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
944
+ var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
945
+ var o2, a2, i2 = [], s2 = function(t3) {
1643
946
  return _checkInRHS$1(t3) === e2;
1644
947
  }, u2 = /* @__PURE__ */ new Map();
1645
- function l22(e3) {
1646
- e3 && i22.push(c.bind(null, e3));
948
+ function l2(e3) {
949
+ e3 && i2.push(c.bind(null, e3));
1647
950
  }
1648
951
  for (var f2 = 0; f2 < t2.length; f2++) {
1649
- var p22 = t2[f2];
1650
- if (Array.isArray(p22)) {
1651
- var d2 = p22[1], h2 = p22[2], m2 = p22.length > 3, y2 = 16 & d2, v = !!(8 & d2), g = 0 == (d2 &= 7), b2 = h2 + "/" + v;
1652
- if (!g && !m2) {
1653
- var w2 = u2.get(b2);
1654
- if (true === w2 || 3 === w2 && 4 !== d2 || 4 === w2 && 3 !== d2) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h2);
1655
- u2.set(b2, !(d2 > 2) || d2);
952
+ var p2 = t2[f2];
953
+ if (Array.isArray(p2)) {
954
+ var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
955
+ if (!g && !m) {
956
+ var w = u2.get(b);
957
+ if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
958
+ u2.set(b, !(d > 2) || d);
1656
959
  }
1657
- applyDec(v ? e2 : e2.prototype, p22, y2, m2 ? "#" + h2 : _toPropertyKey$1(h2), d2, n2, v ? a2 = a2 || [] : o2 = o2 || [], i22, v, m2, g, 1 === d2, v && m2 ? s2 : r2);
960
+ applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey$1(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
1658
961
  }
1659
962
  }
1660
- return l22(o2), l22(a2), i22;
963
+ return l2(o2), l2(a2), i2;
1661
964
  })(e, t, o, f);
1662
- return r.length || u(e, f), { e: p2, get c() {
965
+ return r.length || u(e, f), { e: p, get c() {
1663
966
  var t2 = [];
1664
967
  return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
1665
968
  } };
1666
969
  }
1667
970
  function _toPropertyKey$1(t) {
1668
- var i2 = _toPrimitive$1(t, "string");
1669
- return "symbol" == typeof i2 ? i2 : i2 + "";
971
+ var i = _toPrimitive$1(t, "string");
972
+ return "symbol" == typeof i ? i : i + "";
1670
973
  }
1671
974
  function _toPrimitive$1(t, r) {
1672
975
  if ("object" != typeof t || !t) return t;
1673
976
  var e = t[Symbol.toPrimitive];
1674
977
  if (void 0 !== e) {
1675
- var i2 = e.call(t, r);
1676
- if ("object" != typeof i2) return i2;
978
+ var i = e.call(t, r);
979
+ if ("object" != typeof i) return i;
1677
980
  throw new TypeError("@@toPrimitive must return a primitive value.");
1678
981
  }
1679
982
  return String(t);
@@ -1690,6 +993,7 @@ function _checkInRHS$1(e) {
1690
993
  if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
1691
994
  return e;
1692
995
  }
996
+ const UPGRADABLE_PROPS$1 = ["viewDate", "events", "selectedDate", "user"];
1693
997
  _classDecs$1 = [wsxCore.autoRegister({
1694
998
  tagName: "wsx-week-view"
1695
999
  })];
@@ -1700,18 +1004,15 @@ class WeekView extends wsxCore.WebComponent {
1700
1004
  return ["view-date", "events", "selected-date", "user"];
1701
1005
  }
1702
1006
  // ========== 内部状态 ==========
1007
+ // 日期存 ISO:避免 WSX reactive Proxy 破坏 Date
1703
1008
  // ========== Property 访问器(WSX 组件之间使用) ==========
1704
1009
  get viewDate() {
1705
- return this._viewDate;
1010
+ return fromStateIso(this._viewDateIso);
1706
1011
  }
1707
1012
  set viewDate(value) {
1708
- if (value instanceof Date) {
1709
- this._viewDate = value;
1710
- } else if (typeof value === "string") {
1711
- const date = new Date(value);
1712
- if (!isNaN(date.getTime())) {
1713
- this._viewDate = date;
1714
- }
1013
+ try {
1014
+ this._viewDateIso = toStateIso(value);
1015
+ } catch {
1715
1016
  }
1716
1017
  }
1717
1018
  get events() {
@@ -1719,10 +1020,11 @@ class WeekView extends wsxCore.WebComponent {
1719
1020
  }
1720
1021
  set events(value) {
1721
1022
  if (Array.isArray(value)) {
1722
- this._events = value;
1023
+ this._events = normalizeEventsForState(value);
1723
1024
  } else if (typeof value === "string") {
1724
1025
  try {
1725
- this._events = JSON.parse(value);
1026
+ const parsed = JSON.parse(value);
1027
+ this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
1726
1028
  } catch (e) {
1727
1029
  console.error("Invalid events JSON:", value);
1728
1030
  this._events = [];
@@ -1732,21 +1034,10 @@ class WeekView extends wsxCore.WebComponent {
1732
1034
  }
1733
1035
  }
1734
1036
  get selectedDate() {
1735
- return this._selectedDate;
1037
+ return fromStateIso(this._selectedDateIso);
1736
1038
  }
1737
1039
  set selectedDate(value) {
1738
- if (value instanceof Date) {
1739
- this._selectedDate = value;
1740
- } else if (typeof value === "string") {
1741
- const date = new Date(value);
1742
- if (!isNaN(date.getTime())) {
1743
- this._selectedDate = date;
1744
- } else {
1745
- this._selectedDate = /* @__PURE__ */ new Date(0);
1746
- }
1747
- } else if (value === void 0 || value === null) {
1748
- this._selectedDate = /* @__PURE__ */ new Date(0);
1749
- }
1040
+ this._selectedDateIso = toStateIsoOrUnselected(value);
1750
1041
  }
1751
1042
  get user() {
1752
1043
  return this._user;
@@ -1769,9 +1060,9 @@ class WeekView extends wsxCore.WebComponent {
1769
1060
  styleName: "wsx-week-view"
1770
1061
  });
1771
1062
  _defineProperty$1(this, "_autoStyles", styles);
1772
- _defineProperty$1(this, "_viewDate", void 0);
1063
+ _defineProperty$1(this, "_viewDateIso", void 0);
1773
1064
  _defineProperty$1(this, "_events", void 0);
1774
- _defineProperty$1(this, "_selectedDate", void 0);
1065
+ _defineProperty$1(this, "_selectedDateIso", void 0);
1775
1066
  _defineProperty$1(this, "_user", void 0);
1776
1067
  _defineProperty$1(this, "_today", void 0);
1777
1068
  _defineProperty$1(this, "onDateClick", void 0);
@@ -1814,10 +1105,10 @@ class WeekView extends wsxCore.WebComponent {
1814
1105
  const today = /* @__PURE__ */ new Date();
1815
1106
  today.setHours(0, 0, 0, 0);
1816
1107
  this._today = today;
1817
- const [_get_viewDate, _set_viewDate] = this.useState("_viewDate", /* @__PURE__ */ new Date());
1818
- Object.defineProperty(this, "_viewDate", {
1819
- get: _get_viewDate,
1820
- set: _set_viewDate,
1108
+ const [_get_viewDateIso, _set_viewDateIso] = this.useState("_viewDateIso", (/* @__PURE__ */ new Date()).toISOString());
1109
+ Object.defineProperty(this, "_viewDateIso", {
1110
+ get: _get_viewDateIso,
1111
+ set: _set_viewDateIso,
1821
1112
  enumerable: true,
1822
1113
  configurable: true
1823
1114
  });
@@ -1831,10 +1122,10 @@ class WeekView extends wsxCore.WebComponent {
1831
1122
  enumerable: true,
1832
1123
  configurable: true
1833
1124
  });
1834
- const [_get_selectedDate, _set_selectedDate] = this.useState("_selectedDate", /* @__PURE__ */ new Date(0));
1835
- Object.defineProperty(this, "_selectedDate", {
1836
- get: _get_selectedDate,
1837
- set: _set_selectedDate,
1125
+ const [_get_selectedDateIso, _set_selectedDateIso] = this.useState("_selectedDateIso", UNSELECTED_DATE_ISO);
1126
+ Object.defineProperty(this, "_selectedDateIso", {
1127
+ get: _get_selectedDateIso,
1128
+ set: _set_selectedDateIso,
1838
1129
  enumerable: true,
1839
1130
  configurable: true
1840
1131
  });
@@ -1856,6 +1147,7 @@ class WeekView extends wsxCore.WebComponent {
1856
1147
  // ========== 生命周期 ==========
1857
1148
  onConnected() {
1858
1149
  super.onConnected?.();
1150
+ upgradeProperties(this, UPGRADABLE_PROPS$1);
1859
1151
  this.initializeFromAttributes();
1860
1152
  }
1861
1153
  onAttributeChanged(name, oldValue, newValue) {
@@ -1910,20 +1202,20 @@ class WeekView extends wsxCore.WebComponent {
1910
1202
  }
1911
1203
  // ========== Getters ==========
1912
1204
  get weekDates() {
1913
- return S(this.viewDate, 0);
1205
+ return dateTime.getWeekDates(this.viewDate, 0);
1914
1206
  }
1915
1207
  get hours() {
1916
1208
  return Array.from({
1917
1209
  length: 24
1918
- }, (_, i2) => i2);
1210
+ }, (_, i) => i);
1919
1211
  }
1920
1212
  // ========== 渲染 ==========
1921
1213
  render() {
1922
1214
  return /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-header" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-time-gutter" }), this.weekDates.map((date) => {
1923
1215
  const normalizedDate = new Date(date);
1924
1216
  normalizedDate.setHours(0, 0, 0, 0);
1925
- this.selectedDate.getTime() !== 0 && y(normalizedDate, this.selectedDate);
1926
- const isToday = y(normalizedDate, this._today);
1217
+ this.selectedDate.getTime() !== 0 && dateTime.isSameDay(normalizedDate, this.selectedDate);
1218
+ const isToday = dateTime.isSameDay(normalizedDate, this._today);
1927
1219
  const dayEvents = sortEventsByTime(getEventsForDate(this.events, normalizedDate));
1928
1220
  return /* @__PURE__ */ wsxCore.jsx("div", { class: `week-view-day-header ${isToday ? "today" : ""}`, onClick: () => this.handleDateClick(normalizedDate) }, /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-day-name" }, ["日", "一", "二", "三", "四", "五", "六"][normalizedDate.getDay()]), /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-day-date" }, normalizedDate.getDate()), /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-day-events-count" }, dayEvents.length, " 个事件"));
1929
1221
  })), /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-body" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-time-gutter" }, this.hours.map((hour) => {
@@ -1944,7 +1236,7 @@ class WeekView extends wsxCore.WebComponent {
1944
1236
  const position = calculateEventPosition(event, dayStart, dayEnd);
1945
1237
  const eventColor = event.color || "#4285f4";
1946
1238
  const eventDescription = event.data?.description;
1947
- return /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event", key: "time-slot-event-" + event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event) }, /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event-time" }, W(event.startTime), " ", "-", " ", W(event.endTime)), /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event-title" }, event.title), eventDescription && /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event-description" }, eventDescription));
1239
+ return /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event", key: "time-slot-event-" + event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event) }, /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event-time" }, dateTime.getTimeString(event.startTime), " ", "-", " ", dateTime.getTimeString(event.endTime)), /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event-title" }, event.title), eventDescription && /* @__PURE__ */ wsxCore.jsx("div", { class: "week-view-event-description" }, eventDescription));
1948
1240
  }));
1949
1241
  }))));
1950
1242
  }
@@ -1958,7 +1250,7 @@ function _defineProperty(e, r, t) {
1958
1250
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
1959
1251
  }
1960
1252
  function _applyDecs(e, t, r, n, o, a) {
1961
- function i2(e2, t2, r2) {
1253
+ function i(e2, t2, r2) {
1962
1254
  return function(n2, o2) {
1963
1255
  return r2 && r2(n2), e2[t2].call(n2, o2);
1964
1256
  };
@@ -1971,93 +1263,93 @@ function _applyDecs(e, t, r, n, o, a) {
1971
1263
  if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
1972
1264
  return e2;
1973
1265
  }
1974
- function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l22, f2, p22, d2, h2) {
1975
- function m2(e3) {
1976
- if (!h2(e3)) throw new TypeError("Attempted to access private element on non-instance");
1266
+ function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
1267
+ function m(e3) {
1268
+ if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
1977
1269
  }
1978
- var y2, v = t2[0], g = t2[3], b2 = !u2;
1979
- if (!b2) {
1270
+ var y, v = t2[0], g = t2[3], b = !u2;
1271
+ if (!b) {
1980
1272
  r2 || Array.isArray(v) || (v = [v]);
1981
- var w2 = {}, S2 = [], A = 3 === o2 ? "get" : 4 === o2 || d2 ? "set" : "value";
1982
- f2 ? (p22 || d2 ? w2 = { get: _setFunctionName(function() {
1273
+ var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
1274
+ f2 ? (p2 || d ? w = { get: _setFunctionName(function() {
1983
1275
  return g(this);
1984
1276
  }, n2, "get"), set: function(e3) {
1985
1277
  t2[4](this, e3);
1986
- } } : w2[A] = g, p22 || _setFunctionName(w2[A], n2, 2 === o2 ? "" : A)) : p22 || (w2 = Object.getOwnPropertyDescriptor(e2, n2));
1278
+ } } : w[A] = g, p2 || _setFunctionName(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
1987
1279
  }
1988
1280
  for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
1989
- var D2 = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
1281
+ var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
1990
1282
  if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
1991
1283
  s(t3, "An initializer", "be", true), c2.push(t3);
1992
1284
  }).bind(null, I) };
1993
1285
  try {
1994
- if (b2) (y2 = s(D2.call(E, P, O), "class decorators", "return")) && (P = y2);
1286
+ if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
1995
1287
  else {
1996
1288
  var k, F;
1997
- O.static = l22, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
1998
- return m2(e3), w2.value;
1999
- } : (o2 < 4 && (k = i2(w2, "get", m2)), 3 !== o2 && (F = i2(w2, "set", m2))) : (k = function(e3) {
1289
+ O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
1290
+ return m(e3), w.value;
1291
+ } : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
2000
1292
  return e3[n2];
2001
1293
  }, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
2002
1294
  e3[n2] = t3;
2003
1295
  }));
2004
- var N = O.access = { has: f2 ? h2.bind() : function(e3) {
1296
+ var N = O.access = { has: f2 ? h.bind() : function(e3) {
2005
1297
  return n2 in e3;
2006
1298
  } };
2007
- if (k && (N.get = k), F && (N.set = F), P = D2.call(E, d2 ? { get: w2.get, set: w2.set } : w2[A], O), d2) {
2008
- if ("object" == typeof P && P) (y2 = s(P.get, "accessor.get")) && (w2.get = y2), (y2 = s(P.set, "accessor.set")) && (w2.set = y2), (y2 = s(P.init, "accessor.init")) && S2.push(y2);
1299
+ if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
1300
+ if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
2009
1301
  else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2010
- } else s(P, (p22 ? "field" : "method") + " decorators", "return") && (p22 ? S2.push(P) : w2[A] = P);
1302
+ } else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
2011
1303
  }
2012
1304
  } finally {
2013
1305
  I.v = true;
2014
1306
  }
2015
1307
  }
2016
- return (p22 || d2) && u2.push(function(e3, t3) {
2017
- for (var r3 = S2.length - 1; r3 >= 0; r3--) t3 = S2[r3].call(e3, t3);
1308
+ return (p2 || d) && u2.push(function(e3, t3) {
1309
+ for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
2018
1310
  return t3;
2019
- }), p22 || b2 || (f2 ? d2 ? u2.push(i2(w2, "get"), i2(w2, "set")) : u2.push(2 === o2 ? w2[A] : i2.call.bind(w2[A])) : Object.defineProperty(e2, n2, w2)), P;
1311
+ }), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
2020
1312
  }
2021
1313
  function u(e2, t2) {
2022
1314
  return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
2023
1315
  }
2024
- if (arguments.length >= 6) var l2 = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
2025
- var f = Object.create(null == l2 ? null : l2), p2 = (function(e2, t2, r2, n2) {
2026
- var o2, a2, i22 = [], s2 = function(t3) {
1316
+ if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
1317
+ var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
1318
+ var o2, a2, i2 = [], s2 = function(t3) {
2027
1319
  return _checkInRHS(t3) === e2;
2028
1320
  }, u2 = /* @__PURE__ */ new Map();
2029
- function l22(e3) {
2030
- e3 && i22.push(c.bind(null, e3));
1321
+ function l2(e3) {
1322
+ e3 && i2.push(c.bind(null, e3));
2031
1323
  }
2032
1324
  for (var f2 = 0; f2 < t2.length; f2++) {
2033
- var p22 = t2[f2];
2034
- if (Array.isArray(p22)) {
2035
- var d2 = p22[1], h2 = p22[2], m2 = p22.length > 3, y2 = 16 & d2, v = !!(8 & d2), g = 0 == (d2 &= 7), b2 = h2 + "/" + v;
2036
- if (!g && !m2) {
2037
- var w2 = u2.get(b2);
2038
- if (true === w2 || 3 === w2 && 4 !== d2 || 4 === w2 && 3 !== d2) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h2);
2039
- u2.set(b2, !(d2 > 2) || d2);
1325
+ var p2 = t2[f2];
1326
+ if (Array.isArray(p2)) {
1327
+ var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
1328
+ if (!g && !m) {
1329
+ var w = u2.get(b);
1330
+ if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
1331
+ u2.set(b, !(d > 2) || d);
2040
1332
  }
2041
- applyDec(v ? e2 : e2.prototype, p22, y2, m2 ? "#" + h2 : _toPropertyKey(h2), d2, n2, v ? a2 = a2 || [] : o2 = o2 || [], i22, v, m2, g, 1 === d2, v && m2 ? s2 : r2);
1333
+ applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
2042
1334
  }
2043
1335
  }
2044
- return l22(o2), l22(a2), i22;
1336
+ return l2(o2), l2(a2), i2;
2045
1337
  })(e, t, o, f);
2046
- return r.length || u(e, f), { e: p2, get c() {
1338
+ return r.length || u(e, f), { e: p, get c() {
2047
1339
  var t2 = [];
2048
1340
  return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
2049
1341
  } };
2050
1342
  }
2051
1343
  function _toPropertyKey(t) {
2052
- var i2 = _toPrimitive(t, "string");
2053
- return "symbol" == typeof i2 ? i2 : i2 + "";
1344
+ var i = _toPrimitive(t, "string");
1345
+ return "symbol" == typeof i ? i : i + "";
2054
1346
  }
2055
1347
  function _toPrimitive(t, r) {
2056
1348
  if ("object" != typeof t || !t) return t;
2057
1349
  var e = t[Symbol.toPrimitive];
2058
1350
  if (void 0 !== e) {
2059
- var i2 = e.call(t, r);
2060
- if ("object" != typeof i2) return i2;
1351
+ var i = e.call(t, r);
1352
+ if ("object" != typeof i) return i;
2061
1353
  throw new TypeError("@@toPrimitive must return a primitive value.");
2062
1354
  }
2063
1355
  return String(t);
@@ -2074,6 +1366,8 @@ function _checkInRHS(e) {
2074
1366
  if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
2075
1367
  return e;
2076
1368
  }
1369
+ const UPGRADABLE_PROPS = ["view", "date", "defaultView", "events", "user", "eventDSL", "eventRuntime"];
1370
+ const VALID_VIEWS = ["month", "week", "day"];
2077
1371
  _classDecs = [wsxCore.autoRegister({
2078
1372
  tagName: "wsx-calendar"
2079
1373
  })];
@@ -2084,13 +1378,40 @@ class Calendar extends wsxCore.WebComponent {
2084
1378
  return ["view", "date", "events", "user"];
2085
1379
  }
2086
1380
  // ========== 内部状态(@state 装饰器) ==========
1381
+ // 日期存 ISO:WSX reactive Proxy 会破坏 Date 品牌方法
2087
1382
  // ========== 属性访问器(支持 property 和 attribute 两种设置方式) ==========
1383
+ get currentDate() {
1384
+ return fromStateIso(this._currentDateIso);
1385
+ }
1386
+ set currentDate(value) {
1387
+ this._currentDateIso = toStateIso(value);
1388
+ }
2088
1389
  get defaultView() {
2089
1390
  return this.currentView;
2090
1391
  }
2091
1392
  set defaultView(value) {
2092
1393
  this.currentView = value;
2093
1394
  }
1395
+ /** 与 observedAttributes 的 "view" 对应的 property(框架包装器使用) */
1396
+ get view() {
1397
+ return this.currentView;
1398
+ }
1399
+ set view(value) {
1400
+ if (VALID_VIEWS.includes(value)) {
1401
+ this.currentView = value;
1402
+ }
1403
+ }
1404
+ /** 与 observedAttributes 的 "date" 对应的 property(框架包装器使用) */
1405
+ get date() {
1406
+ return this.currentDate;
1407
+ }
1408
+ set date(value) {
1409
+ try {
1410
+ this.currentDate = value;
1411
+ } catch {
1412
+ console.error("Invalid date value:", value);
1413
+ }
1414
+ }
2094
1415
  get eventDSL() {
2095
1416
  return this._eventDSL;
2096
1417
  }
@@ -2119,10 +1440,11 @@ class Calendar extends wsxCore.WebComponent {
2119
1440
  }
2120
1441
  set events(value) {
2121
1442
  if (Array.isArray(value)) {
2122
- this._events = value;
1443
+ this._events = normalizeEventsForState(value);
2123
1444
  } else if (typeof value === "string") {
2124
1445
  try {
2125
- this._events = JSON.parse(value);
1446
+ const parsed = JSON.parse(value);
1447
+ this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
2126
1448
  } catch (e) {
2127
1449
  console.error("Invalid events JSON:", value);
2128
1450
  this._events = [];
@@ -2152,7 +1474,7 @@ class Calendar extends wsxCore.WebComponent {
2152
1474
  });
2153
1475
  _defineProperty(this, "_autoStyles", styles$3);
2154
1476
  _defineProperty(this, "currentView", void 0);
2155
- _defineProperty(this, "currentDate", void 0);
1477
+ _defineProperty(this, "_currentDateIso", void 0);
2156
1478
  _defineProperty(this, "_events", void 0);
2157
1479
  _defineProperty(this, "_user", void 0);
2158
1480
  _defineProperty(this, "_eventDSL", void 0);
@@ -2188,10 +1510,10 @@ class Calendar extends wsxCore.WebComponent {
2188
1510
  enumerable: true,
2189
1511
  configurable: true
2190
1512
  });
2191
- const [_getcurrentDate, _setcurrentDate] = this.useState("currentDate", /* @__PURE__ */ new Date());
2192
- Object.defineProperty(this, "currentDate", {
2193
- get: _getcurrentDate,
2194
- set: _setcurrentDate,
1513
+ const [_get_currentDateIso, _set_currentDateIso] = this.useState("_currentDateIso", (/* @__PURE__ */ new Date()).toISOString());
1514
+ Object.defineProperty(this, "_currentDateIso", {
1515
+ get: _get_currentDateIso,
1516
+ set: _set_currentDateIso,
2195
1517
  enumerable: true,
2196
1518
  configurable: true
2197
1519
  });
@@ -2230,6 +1552,7 @@ class Calendar extends wsxCore.WebComponent {
2230
1552
  // ========== Web Components 生命周期 ==========
2231
1553
  onConnected() {
2232
1554
  super.onConnected?.();
1555
+ upgradeProperties(this, UPGRADABLE_PROPS);
2233
1556
  this.setupEventListeners();
2234
1557
  }
2235
1558
  onDisconnected() {
@@ -2300,7 +1623,7 @@ class Calendar extends wsxCore.WebComponent {
2300
1623
  return /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar" }, this.renderToolbar(), this.renderView());
2301
1624
  }
2302
1625
  renderToolbar() {
2303
- return /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar-left" }, /* @__PURE__ */ wsxCore.jsx("button", { class: "calendar-nav-button", onClick: () => this.handleNavigate(-1), "aria-label": "上一页", "data-wsx-key": "Calendar-button-text-1-1" }, /* @__PURE__ */ wsxCore.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24" }, /* @__PURE__ */ wsxCore.jsx("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }))), /* @__PURE__ */ wsxCore.jsx("button", { class: "calendar-nav-button", onClick: () => this.handleNavigate(1), "aria-label": "下一页", "data-wsx-key": "Calendar-button-text-1-3" }, /* @__PURE__ */ wsxCore.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24" }, /* @__PURE__ */ wsxCore.jsx("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }))), /* @__PURE__ */ wsxCore.jsx("button", { class: "calendar-today-button", onClick: () => this.handleToday(), "data-wsx-key": "Calendar-button-text-1-5" }, "今天"), /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar-date" }, this.formatViewDate())), /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar-right" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-view-buttons" }, /* @__PURE__ */ wsxCore.jsx("button", { class: `calendar-view-button ${this.currentView === "month" ? "active" : ""}`, onClick: () => this.handleViewChange("month"), "data-wsx-key": "Calendar-button-text-3-1-1" }, "月"), /* @__PURE__ */ wsxCore.jsx("button", { class: `calendar-view-button ${this.currentView === "week" ? "active" : ""}`, onClick: () => this.handleViewChange("week"), "data-wsx-key": "Calendar-button-text-3-1-3" }, "周"), /* @__PURE__ */ wsxCore.jsx("button", { class: `calendar-view-button ${this.currentView === "day" ? "active" : ""}`, onClick: () => this.handleViewChange("day"), "data-wsx-key": "Calendar-button-text-3-1-5" }, "日"))));
1626
+ return /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar-left" }, /* @__PURE__ */ wsxCore.jsx("button", { class: "calendar-nav-button", onClick: () => this.handleNavigate(-1), "aria-label": "上一页" }, /* @__PURE__ */ wsxCore.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24" }, /* @__PURE__ */ wsxCore.jsx("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }))), /* @__PURE__ */ wsxCore.jsx("button", { class: "calendar-nav-button", onClick: () => this.handleNavigate(1), "aria-label": "下一页" }, /* @__PURE__ */ wsxCore.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24" }, /* @__PURE__ */ wsxCore.jsx("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }))), /* @__PURE__ */ wsxCore.jsx("button", { class: "calendar-today-button", onClick: () => this.handleToday() }, "今天"), /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar-date" }, this.formatViewDate())), /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-toolbar-right" }, /* @__PURE__ */ wsxCore.jsx("div", { class: "calendar-view-buttons" }, /* @__PURE__ */ wsxCore.jsx("button", { class: `calendar-view-button ${this.currentView === "month" ? "active" : ""}`, onClick: () => this.handleViewChange("month") }, "月"), /* @__PURE__ */ wsxCore.jsx("button", { class: `calendar-view-button ${this.currentView === "week" ? "active" : ""}`, onClick: () => this.handleViewChange("week") }, "周"), /* @__PURE__ */ wsxCore.jsx("button", { class: `calendar-view-button ${this.currentView === "day" ? "active" : ""}`, onClick: () => this.handleViewChange("day") }, "日"))));
2304
1627
  }
2305
1628
  renderView() {
2306
1629
  const view = this.currentView || "month";
@@ -2336,8 +1659,8 @@ class Calendar extends wsxCore.WebComponent {
2336
1659
  case "month":
2337
1660
  return `${date.getFullYear()}年${date.getMonth() + 1}月`;
2338
1661
  case "week":
2339
- const weekStart = S(date)[0];
2340
- const weekEnd = S(date)[6];
1662
+ const weekStart = dateTime.getWeekDates(date)[0];
1663
+ const weekEnd = dateTime.getWeekDates(date)[6];
2341
1664
  return `${weekStart.getMonth() + 1}/${weekStart.getDate()} - ${weekEnd.getMonth() + 1}/${weekEnd.getDate()}`;
2342
1665
  case "day":
2343
1666
  return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;