import { i, x } from "./lit-z6_uA4GX.mjs"; import { n as n$1, t } from "./property-D0NJdseG.mjs"; import { e, n } from "./ref-CPp9J0V5.mjs"; import { e as escapeXml } from "./index-_IB1wMbZ.mjs"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __decorateClass = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--) if (decorator = decorators[i2]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp(target, key, result); return result; }; let EditCalendarForm = class extends i { constructor() { super(); this.displayname = ""; this.description = ""; this.timezone_id = ""; this.color = ""; this.components = /* @__PURE__ */ new Set(); this.dialog = e(); this.form = e(); } createRenderRoot() { return this; } render() { return x`

Create calendar





${["VEVENT", "VTODO", "VJOURNAL"].map((comp) => x`
`)}
`; } async submit(e2) { e2.preventDefault(); if (!this.principal) { alert("Empty principal"); return; } if (!this.cal_id) { alert("Empty id"); return; } if (!this.displayname) { alert("Empty displayname"); return; } if (!this.components.size) { alert("No calendar components selected"); return; } let response = await fetch(`/caldav/principal/${this.principal}/${this.cal_id}`, { method: "PROPPATCH", headers: { "Content-Type": "application/xml" }, body: ` ${escapeXml(this.displayname)} ${this.timezone_id ? `${escapeXml(this.timezone_id)}` : ""} ${this.description ? `${escapeXml(this.description)}` : ""} ${this.color ? `${escapeXml(this.color)}` : ""} ${Array.from(this.components.keys()).map((comp) => ``).join("\n")} ${!this.timezone_id ? `` : ""} ${!this.description ? "" : ""} ${!this.color ? "" : ""} ` }); if (response.status >= 400) { alert(`Error ${response.status}: ${await response.text()}`); return null; } window.location.reload(); return null; } }; __decorateClass([ n$1() ], EditCalendarForm.prototype, "principal", 2); __decorateClass([ n$1() ], EditCalendarForm.prototype, "cal_id", 2); __decorateClass([ n$1() ], EditCalendarForm.prototype, "displayname", 2); __decorateClass([ n$1() ], EditCalendarForm.prototype, "description", 2); __decorateClass([ n$1() ], EditCalendarForm.prototype, "timezone_id", 2); __decorateClass([ n$1() ], EditCalendarForm.prototype, "color", 2); __decorateClass([ n$1({ converter: { fromAttribute: (value, _type) => new Set(value ? JSON.parse(value) : []), toAttribute: (value, _type) => JSON.stringify(value) } }) ], EditCalendarForm.prototype, "components", 2); EditCalendarForm = __decorateClass([ t("edit-calendar-form") ], EditCalendarForm); export { EditCalendarForm };