UNPKG

adwaveui

Version:

Interactive Web Components inspired by the Gtk Adwaita theme.

1,712 lines (1,695 loc) 187 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // node_modules/jsxte/dist/esm/jsx/jsx-runtime.mjs (() => { if (typeof Symbol.toHtmlTag === "symbol") return; Object.defineProperty(Symbol, "toHtmlTag", { value: Symbol("toHtmlTag"), enumerable: false, configurable: true }); })(); var mapChildren = /* @__PURE__ */ __name((children, accumulator) => { switch (typeof children) { case "string": accumulator.push({ type: "textNode", text: children }); break; case "number": accumulator.push({ type: "textNode", text: children.toString() }); break; case "object": if (Array.isArray(children)) { for (let i = 0; i < children.length; i++) { const child = children[i]; mapChildren(child, accumulator); } } else if (children != null) { if (Symbol.toHtmlTag in children && typeof children[Symbol.toHtmlTag] === "function") { const html = String(children[Symbol.toHtmlTag]()); accumulator.push({ type: "textNode", text: html }); } else { accumulator.push(children); } } break; } return accumulator; }, "mapChildren"); var createElement = /* @__PURE__ */ __name((tag, props, ...children) => { props ?? (props = {}); const finalChildren = []; for (let i = 0; i < children.length; i++) { mapChildren(children[i], finalChildren); } if (props?.children) { mapChildren(props.children, finalChildren); } props.children = finalChildren; Object.freeze(finalChildren); Object.freeze(props); return { type: "tag", // @ts-expect-error tag, props }; }, "createElement"); var jsx = createElement; var jsxs = jsx; var Fragment = ""; // node_modules/adwavecss/dist/index.js var Theme = class _Theme { static { __name(this, "Theme"); } static dark = "dark-theme"; static light = "light-theme"; static light2 = "light-theme-2"; static className(params) { switch (params.type) { case "light": return _Theme.light; case "light2": return _Theme.light2; } return _Theme.dark; } }; var Box = class _Box { static { __name(this, "Box"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/box.md#ClassNames */ static box = "box"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/box.md#ClassNames */ static rounded = "rounded"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/box.md#ClassNames */ static bg2 = "bg-level-2"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/box.md#ClassNames */ static bg3 = "bg-level-3"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/box.md#ClassNames */ static bg4 = "bg-level-4"; static className(params) { let className = _Box.box; if (params.rounded) { className += ` ${_Box.rounded}`; } if (params.bg) { switch (params.bg) { case 4: className += ` ${_Box.bg4}`; break; case 3: className += ` ${_Box.bg3}`; break; case 2: className += ` ${_Box.bg2}`; break; } } return className; } }; var Button = class _Button { static { __name(this, "Button"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static button = "btn"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static disabled = "disabled"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static primary = "primary"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static danger = "danger"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static flat = "flat"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static pill = "pill"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static circular = "circular"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static square = "square"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static toggled = "toggled"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static wrapper = "btn-wrapper"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/button.md#ClassNames */ static adaptive = "adaptive"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/linked.md */ static linked = "linked"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/linked.md */ static linkedVertical = "vertical"; static className(params) { let className = _Button.button; if (params.disabled) { className += ` ${_Button.disabled}`; } if (params.color) { switch (params.color) { case "primary": className += ` ${_Button.primary}`; break; case "danger": className += ` ${_Button.danger}`; break; } } if (params.shape) { switch (params.shape) { case "circular": className += ` ${_Button.circular}`; break; case "square": className += ` ${_Button.square}`; break; } } if (params.flat) { className += ` ${_Button.flat}`; } if (params.pill) { className += ` ${_Button.pill}`; } if (params.toggled) { className += ` ${_Button.toggled}`; } if (params.adaptive) { className += ` ${_Button.adaptive}`; } if (params.linked) { className += ` ${_Button.linked}`; } if (params.linkedVertical) { className += ` ${_Button.linkedVertical}`; } return className; } }; var Card = class _Card { static { __name(this, "Card"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/card.md#ClassNames */ static card = "card"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/card.md#ClassNames */ static activable = "activable"; static className(params) { let className = _Card.card; if (params.activable) { className += ` ${_Card.activable}`; } return className; } }; var Checkbox = class _Checkbox { static { __name(this, "Checkbox"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/checkbox.md#ClassNames */ static checkbox = "checkbox"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/checkbox.md#ClassNames */ static disabled = "disabled"; static className(params) { let className = _Checkbox.checkbox; if (params.disabled) { className += ` ${_Checkbox.disabled}`; } return className; } }; var Frame = class _Frame { static { __name(this, "Frame"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/frame.md#ClassNames */ static frame = "frame"; static className() { return _Frame.frame; } }; var Input = class _Input { static { __name(this, "Input"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/input.md#ClassNames */ static input = "input"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/input.md#ClassNames */ static disabled = "disabled"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/linked.md */ static linked = "linked"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/linked.md */ static linkedVertical = "vertical"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/input.md#ClassNames */ static wrapper = "input-wrapper"; static className(params) { let className = _Input.input; if (params.disabled) { className += ` ${_Input.disabled}`; } if (params.linked) { className += ` ${_Input.linked}`; } if (params.linkedVertical) { className += ` ${_Input.linkedVertical}`; } return className; } static wrapperClassName() { return _Input.wrapper; } }; var List = class _List { static { __name(this, "List"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/list.md#ClassNames */ static list = "list"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/list.md#ClassNames */ static element = "list-element"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/list.md#ClassNames */ static activableElement = "activable"; static className() { let className = _List.list; return className; } static elementClassName(params) { let className = _List.element; if (params.activable) { className += ` ${_List.activableElement}`; } return className; } }; var Message = class _Message { static { __name(this, "Message"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/message.md#ClassNames */ static message = "message"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/message.md#ClassNames */ static success = "success"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/message.md#ClassNames */ static alert = "alert"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/message.md#ClassNames */ static error = "error"; static className(params) { let className = _Message.message; if (params.type) { switch (params.type) { case "success": className += ` ${_Message.success}`; break; case "alert": className += ` ${_Message.alert}`; break; case "error": className += ` ${_Message.error}`; break; } } return className; } }; var NavSidebar = class _NavSidebar { static { __name(this, "NavSidebar"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/nav-sidebar.md#ClassNames */ static navSidebar = "nav-sidebar"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/nav-sidebar.md#ClassNames */ static button = "nav-sidebar-btn"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/nav-sidebar.md#ClassNames */ static separator = "separator"; static active = "active"; static className() { return _NavSidebar.navSidebar; } static btnClassName(params) { let className = _NavSidebar.button; if (params.active) { className += ` ${_NavSidebar.active}`; } return className; } static separatorClassName() { return _NavSidebar.separator; } }; var ScrollView = class _ScrollView { static { __name(this, "ScrollView"); } static scrollView = "scrollview"; static className() { return _ScrollView.scrollView; } }; var Selector = class _Selector { static { __name(this, "Selector"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static selector = "selector"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static disabled = "disabled"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static selectedOption = "selected-option"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static downButton = "down-button"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static opened = "opened"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static optionsList = "options-list"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static option = "option"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static top = "top"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/selector.md#ClassNames */ static noPosition = "no-position"; static className(params) { let className = _Selector.selector; if (params.disabled) { className += ` ${_Selector.disabled}`; } if (params.opened) { className += ` ${_Selector.opened}`; } if (params.noPosition) { className += ` ${_Selector.noPosition}`; } if (params.position === "top") { className += ` ${_Selector.top}`; } return className; } static optionClassName() { let className = _Selector.option; return className; } static selectedOptionClassName() { let className = _Selector.selectedOption; return className; } static listClassName() { let className = _Selector.optionsList; return className; } static downButtonClassName() { let className = _Selector.downButton; return className; } }; var Separator = class _Separator { static { __name(this, "Separator"); } static separator = "separator"; static vertical = "vertical"; static className(params) { let className = _Separator.separator; if (params.vertical) { className += ` ${_Separator.vertical}`; } return className; } }; var Skeleton = class _Skeleton { static { __name(this, "Skeleton"); } static skeleton = "skeleton"; static className() { return _Skeleton.skeleton; } }; var Slider = class _Slider { static { __name(this, "Slider"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/slider.md#ClassNames */ static slider = "slider"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/slider.md#ClassNames */ static disabled = "disabled"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/slider.md#ClassNames */ static track = "slider-track"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/slider.md#ClassNames */ static progress = "slider-progress"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/slider.md#ClassNames */ static thumb = "slider-thumb"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/slider.md#ClassNames */ static noPosition = "no-position"; static className(params) { let className = _Slider.slider; if (params.disabled) { className += ` ${_Slider.disabled}`; } if (params.noPosition) { className += ` ${_Slider.noPosition}`; } return className; } static trackClassName() { let className = _Slider.track; return className; } static progressClassName() { let className = _Slider.progress; return className; } static thumbClassName() { let className = _Slider.thumb; return className; } }; var Suggestions = class _Suggestions { static { __name(this, "Suggestions"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/suggestions.md#ClassNames */ static suggestions = "suggestions"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/suggestions.md#ClassNames */ static option = "suggestions-option"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/suggestions.md#ClassNames */ static active = "active"; static className() { let className = _Suggestions.suggestions; return className; } static optionClassName(params) { let className = _Suggestions.option; if (params.active) { className += ` ${_Suggestions.active}`; } return className; } }; var Switch = class _Switch { static { __name(this, "Switch"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/switch.md#ClassNames */ static switch = "switch"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/switch.md#ClassNames */ static disabled = "disabled"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/switch.md#ClassNames */ static knob = "switch-knob"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/switch.md#ClassNames */ static active = "active"; static className(params) { let className = _Switch.switch; if (params.disabled) { className += ` ${_Switch.disabled}`; } if (params.active) { className += ` ${_Switch.active}`; } return className; } }; var Typography = class _Typography { static { __name(this, "Typography"); } /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/typography.md#ClassNames */ static text = "text"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/typography.md#ClassNames */ static subtitle = "subtitle"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/typography.md#ClassNames */ static label = "label"; /** * Read more at @link https://github.com/ncpa0/ADWaveCSS/blob/master/docs/components/typography.md#ClassNames */ static header = "header"; static className(params) { switch (params.type) { case "subtitle": return _Typography.subtitle; case "label": return _Typography.label; case "header": return _Typography.header; } return _Typography.text; } }; Object.freeze(Box); Object.freeze(Button); Object.freeze(Card); Object.freeze(Checkbox); Object.freeze(Frame); Object.freeze(Input); Object.freeze(List); Object.freeze(Message); Object.freeze(NavSidebar); Object.freeze(ScrollView); Object.freeze(Selector); Object.freeze(Separator); Object.freeze(Skeleton); Object.freeze(Slider); Object.freeze(Suggestions); Object.freeze(Switch); Object.freeze(Theme); Object.freeze(Typography); // node_modules/jsxte/dist/esm/utilities/array-flat-polyfill.mjs function flat(depth) { const copy = []; if (depth === void 0) { depth = 1; } for (let i = 0; i < this.length; i++) { const item = this[i]; if (depth > 0 && Array.isArray(item)) { const itemFlatCopy = flat.call(item, depth - 1); for (let j = 0; j < itemFlatCopy.length; j++) { copy.push(itemFlatCopy[j]); } } else { copy.push(item); } } return copy; } __name(flat, "flat"); if (!Array.prototype.flat) { Object.defineProperty(Array.prototype, "flat", { configurable: true, value: flat, writable: true }); } // node_modules/jsxte/dist/esm/jsxte-render-error.mjs var __defProp2 = Object.defineProperty; var __defNormalProp = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp"); var __publicField = /* @__PURE__ */ __name((obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }, "__publicField"); var mapReverse = /* @__PURE__ */ __name((arr, fn) => { const result = []; for (let i = arr.length - 1; i >= 0; i--) { result.push(fn(arr[i])); } return result; }, "mapReverse"); var JsxteRenderError = class _JsxteRenderError extends Error { static { __name(this, "_JsxteRenderError"); } constructor(message, insideTag, causedBy) { super(message, { cause: causedBy }); __publicField(this, "baseMessage", ""); __publicField(this, "parentTags", []); this.name = "JsxteRenderError"; this.baseMessage = message; if (insideTag) { this.parentTags.push(insideTag); } if (this.cause == null) { Object.defineProperty(this, "cause", { value: causedBy, enumerable: true, writable: true }); } } static is(err) { return err instanceof _JsxteRenderError; } /** * @internal */ pushParent(tag) { this.parentTags.push(tag); } /** * @internal */ regenerateMessage() { this.message = `The below error has occurred in: ${mapReverse( this.parentTags.filter((t) => t !== ""), (tag) => `<${tag}>` ).join("\n")} ${this.baseMessage}`; } }; // node_modules/jsxte/dist/esm/dom-renderer/dom-renderer.mjs var __defProp3 = Object.defineProperty; var __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp"); var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => { __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }, "__publicField"); var DomRenderer = class { static { __name(this, "DomRenderer"); } constructor(window2, options = {}) { this.window = window2; this.options = options; __publicField2(this, "generator"); __publicField2(this, "setAttribute", (element, name, value) => { if (typeof value === "boolean") { if (value) { value = name; } else { return; } } element.setAttribute(name, value); }); if (options.attributeSetter) { this.setAttribute = options.attributeSetter; } const doc = this.window.document; const domrenderer = this; class DomGenerator { static { __name(this, "DomGenerator"); } createElement(type, attributes, children) { const element = doc.createElement(type); for (const [name, value] of attributes) { domrenderer.setAttribute(element, name, value); } for (const child of children) { element.appendChild(child); } return element; } createTextNode(text) { return doc.createTextNode(String(text)); } createFragment(children) { const fragment = doc.createDocumentFragment(); for (const child of children) { fragment.appendChild(child); } return fragment; } } this.generator = new DomGenerator(); } render(component, componentApi) { const renderer = new JsxteRenderer(this.generator, { ...this.options, allowAsync: false }, componentApi); return renderer.render(component); } async renderAsync(component, componentApi) { const renderer = new JsxteRenderer(this.generator, { ...this.options, allowAsync: true }, componentApi); return renderer.render(component); } }; // node_modules/jsxte/dist/esm/utilities/join.mjs function join(arr, separator = "\n") { let result = arr[0] ?? ""; const until = arr.length; for (let i = 1; i < until; i++) { result += separator + arr[i]; } return result; } __name(join, "join"); // node_modules/jsxte/dist/esm/html-renderer/attribute-to-html-tag-string.mjs var attributeToHtmlTagString = /* @__PURE__ */ __name(([key, value]) => { if (value === true) { return `${key}`; } if (value === false || value === null || value === void 0) { return ""; } return `${key}="${value.toString().replace(/"/g, "&quot;")}"`; }, "attributeToHtmlTagString"); var mapAttributesToHtmlTagString = /* @__PURE__ */ __name((attributes) => { const results = []; for (let i = 0; i < attributes.length; i++) { const attribute = attributes[i]; const html = attributeToHtmlTagString(attribute); if (html.length > 0) results.push(html); } return join(results, " "); }, "mapAttributesToHtmlTagString"); // node_modules/jsxte/dist/esm/utilities/self-closing-tag-list.mjs var SELF_CLOSING_TAG_LIST = [ "area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr" ]; // node_modules/jsxte/dist/esm/html-renderer/base-html-generator.mjs var BaseHtmlGenerator = class _BaseHtmlGenerator { static { __name(this, "_BaseHtmlGenerator"); } constructor(options) { this.options = options; } generateTagCompact(tag, attributes, content) { if (attributes) { attributes = " " + attributes; } else { attributes = ""; } if (!content || content.length === 0) { if (SELF_CLOSING_TAG_LIST.includes(tag)) { return `<${tag}${attributes} />`; } else { return `<${tag}${attributes}></${tag}>`; } } return `<${tag}${attributes}>${content}</${tag}>`; } flattenChildrenCompact(children) { return join(children, ""); } generateTag(tag, attributes, content) { if (attributes) { attributes = " " + attributes; } else { attributes = ""; } if (!content || content.length === 0) { if (SELF_CLOSING_TAG_LIST.includes(tag)) { return [{ type: "tag-selfclose", tag, content: `<${tag}${attributes} />` }]; } else { return [{ type: "tag-inline", tag, content: `<${tag}${attributes}></${tag}>` }]; } } return [ { type: "tag-open", tag, content: `<${tag}${attributes}>` }, ...content, { type: "tag-close", tag, content: `</${tag}>` } ]; } flattenChildren(children) { const result = []; for (let i = 0; i < children.length; i++) { const child = children[i]; if (child.length === 1 && child[0].type === "text") { const last = result.at(-1); if (last?.type === "text") { last.content += child[0].content; continue; } } const lasIdx = result.length; for (let j = 0; j < child.length; j++) { result[lasIdx + j] = child[j]; } } return result; } static leftPad(str, pad) { if (!str.includes("\n")) { return pad + str; } else { const lines = str.split("\n"); for (let i = 0; i < lines.length; i++) { lines[i] = pad + lines[i]; } return join(lines); } } static trimContent(content) { let leftWhitespace = 0; let rightWhitespace = 0; let wsLeft = false; let wsRight = false; for (let i = 0; i < content.length; i++) { if (content[i] === " " || content[i] === "\n") { leftWhitespace += 1; } else { break; } } if (leftWhitespace === content.length) { return { wsLeft: true, wsRight: true, trimmed: "" }; } if (leftWhitespace > 0) { content = content.substring(leftWhitespace); wsLeft = true; } for (let i = content.length - 1; i >= 0; i--) { if (content[i] === " " || content[i] === "\n") { rightWhitespace += 1; } else { break; } } if (rightWhitespace > 0) { content = content.substring(0, content.length - rightWhitespace); wsRight = true; } return { wsLeft, wsRight, trimmed: content }; } static concatHtmlLines(lines, options) { let result = ""; const indentLength = options?.indent ?? 2; const singleIndent = " ".repeat(indentLength); let currentIndent = ""; let inPre = 0; for (let i = 0; i < lines.length; i++) { const line = lines[i]; if (inPre > 0) { const isLast = lines[i + 1]?.type === "tag-close" && lines[i + 1]?.tag === "pre"; const suffix = isLast ? "" : "\n"; switch (line.type) { case "tag-open": if (line.tag === "pre") { inPre += 1; } result += line.content + suffix; currentIndent += singleIndent; break; case "tag-close": if (line.tag === "pre") { inPre -= 1; } result += line.content + suffix; currentIndent = currentIndent.substring(indentLength); break; case "tag-inline": result += line.content + suffix; break; case "tag-selfclose": result += line.content + suffix; break; case "text": result += line.content + suffix; break; } } else { switch (line.type) { case "tag-open": { let suffix = "\n"; if (line.tag === "pre") { inPre += 1; suffix = ""; } else { const nextLine = lines[i + 1]; const addNewLine = nextLine ? nextLine.type === "tag-open" || nextLine.type === "tag-selfclose" : true; if (!addNewLine) { suffix = ""; } else if (result.length && result.at(-1) !== "\n") { result += "\n"; } } const addIndent = result.at(-1) === "\n"; if (addIndent) { result += currentIndent + line.content + suffix; } else { result += line.content + suffix; } currentIndent += singleIndent; break; } case "tag-close": { currentIndent = currentIndent.substring(indentLength); const nextLine = lines[i + 1]; const addIndent = result.at(-1) === "\n"; const addNewLine = nextLine ? nextLine.type === "tag-close" || nextLine.type === "tag-selfclose" : true; if (addIndent) { result += currentIndent; } result += line.content; if (addNewLine) { result += "\n"; } break; } case "tag-inline": { const nextLine = lines[i + 1]; const addIndent = result.at(-1) === "\n"; const addNewLine = nextLine ? nextLine.type !== "text" : true; if (addIndent) { result += currentIndent; } result += line.content; if (addNewLine) { result += "\n"; } break; } case "tag-selfclose": { result += currentIndent + line.content + "\n"; break; } case "text": { const content = _BaseHtmlGenerator.trimContent(line.content); const nextLine = lines[i + 1]; const addIndent = result.at(-1) === "\n"; if (addIndent) { result += _BaseHtmlGenerator.leftPad( content.trimmed, currentIndent ); } else { if (content.wsLeft && content.trimmed !== "") { result += "\n" + _BaseHtmlGenerator.leftPad(content.trimmed, currentIndent); } else { result += content.trimmed; } } if (content.wsRight && nextLine?.type !== "tag-close") { result += "\n"; } break; } } } } return result; } }; // node_modules/jsxte/dist/esm/html-renderer/jsx-elem-to-html-sync.mjs var HtmlCompactGenerator = class extends BaseHtmlGenerator { static { __name(this, "HtmlCompactGenerator"); } createTextNode(text) { return String(text); } createElement(type, attributes, children) { const attributesString = mapAttributesToHtmlTagString(attributes); const content = this.flattenChildrenCompact(children); return this.generateTagCompact(type, attributesString, content); } createFragment(children) { return this.flattenChildrenCompact(children); } }; var HtmlPrettyGenerator = class extends BaseHtmlGenerator { static { __name(this, "HtmlPrettyGenerator"); } createTextNode(text) { return [{ type: "text", content: String(text) }]; } createElement(type, attributes, children) { const attributesString = mapAttributesToHtmlTagString(attributes); const content = this.flattenChildren(children); return this.generateTag(type, attributesString, content); } createFragment(children) { return this.flattenChildren(children); } }; var jsxElemToHtmlSync = /* @__PURE__ */ __name((element, componentApi, options = {}) => { const { pretty = false } = options; if (pretty) { const renderer = new JsxteRenderer( new HtmlPrettyGenerator(options), { ...options, allowAsync: false }, componentApi ); const lines = renderer.render(element); return HtmlPrettyGenerator.concatHtmlLines(lines, options); } else { const renderer = new JsxteRenderer( new HtmlCompactGenerator(options), { ...options, allowAsync: false }, componentApi ); return renderer.render(element); } }, "jsxElemToHtmlSync"); // node_modules/jsxte/dist/esm/json-renderer/jsx-elem-to-json.mjs var JsonGenerator = class { static { __name(this, "JsonGenerator"); } createTextNode(text) { return text; } createElement(type, attributes, children) { return { element: type, attributes, children }; } createFragment(children) { return { element: "", attributes: [], children }; } }; var jsxElemToJsonSync = /* @__PURE__ */ __name((element, componentApi, options) => { const renderer = new JsxteRenderer( new JsonGenerator(), { ...options, allowAsync: false }, componentApi ); return renderer.render(element); }, "jsxElemToJsonSync"); var AsyncJsonGenerator = class { static { __name(this, "AsyncJsonGenerator"); } createTextNode(text) { return text; } async createElement(type, attributes, children) { return { element: type, attributes, children: await Promise.resolve(children).then((c) => Promise.all(c)) }; } async createFragment(children) { return { element: "", attributes: [], children: await Promise.resolve(children).then((c) => Promise.all(c)) }; } }; var jsxElemToJsonAsync = /* @__PURE__ */ __name((element, componentApi, options) => { const renderer = new JsxteRenderer( new AsyncJsonGenerator(), { ...options, allowAsync: true }, componentApi ); return renderer.render(element); }, "jsxElemToJsonAsync"); // node_modules/jsxte/dist/esm/component-api/component-api.mjs var __defProp4 = Object.defineProperty; var __defNormalProp3 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp"); var __publicField3 = /* @__PURE__ */ __name((obj, key, value) => { __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }, "__publicField"); var ContextAccessor = class _ContextAccessor { static { __name(this, "_ContextAccessor"); } constructor(map = /* @__PURE__ */ new Map()) { this.map = map; } static clone(original) { return new _ContextAccessor(new Map(original.map)); } /** * Retrieve the context data for the specified context. If the context has * never been set by any of this component ancestors an error will be thrown. */ getOrFail(ref) { const value = this.map.get(ref.id); if (value === void 0) { throw new Error( "Context not defined! Make sure the context is set before accessing it." ); } return value; } /** Retrieve the context data for the specified context. */ get(ref) { const value = this.map.get(ref.id); return value; } /** * Partially update the state of the context data. Works only for objects and * can only be used if some context data is already set beforehand. * * Updates to the context made with this method are only visible to this * component and it's descendants. */ update(ref, updateData) { const data = this.get(ref); if (typeof data === "object" && data !== null && typeof updateData === "object" && updateData !== null) { if (Array.isArray(data)) { const arr = Array.from(data); const entries = Object.entries(updateData); for (let i = 0; i < entries.length; i++) { const [key, value] = entries[i]; const index = Number(key); if (!isNaN(index)) arr[index] = value; } return void this.map.set(ref.id, arr); } else { return void this.map.set(ref.id, { ...data, ...updateData }); } } else { throw new Error( "Context data is not an object!. Partial updates are only possible for objects." ); } } /** * Sets the context data for the specified context. * * Changes to the context made with this method are only visible to this * component and it's descendants. */ set(ref, data) { this.map.set(ref.id, data); } /** Check if the context data for the specified context is set. */ has(ref) { return this.map.has(ref.id); } /** * Replaces this context entries with the entries of the context provided. * * @internal */ replace(context) { this.map = context.map; } }; var ComponentApi = class _ComponentApi { static { __name(this, "_ComponentApi"); } constructor(options, accessor) { this.options = options; __publicField3(this, "ctx"); this.ctx = accessor ?? new ContextAccessor(); } static create(options) { return new _ComponentApi(options); } static clone(original) { return new _ComponentApi( original.options, ContextAccessor.clone(original.ctx) ); } /** * Renders the given JSX component to pure html as if it was a child of this * component. All context available to this component will be available to the * given component as well. */ render(component, optionsOverrides) { const thisCopy = _ComponentApi.clone(this); if (optionsOverrides) { return jsxElemToHtmlSync(component, thisCopy, { ...this.options, ...optionsOverrides }); } return jsxElemToHtmlSync(component, thisCopy, this.options); } async renderAsync(component, optionsOverrides) { const thisCopy = _ComponentApi.clone(this); if (optionsOverrides) { return Promise.resolve(component).then( (c) => jsxElemToHtmlAsync(c, thisCopy, { ...this.options, ...optionsOverrides }) ); } return Promise.resolve(component).then( (c) => jsxElemToHtmlAsync(c, thisCopy, this.options) ); } renderToJson(component, optionsOverrides) { const thisCopy = _ComponentApi.clone(this); if (optionsOverrides) { return jsxElemToJsonSync(component, thisCopy, { ...this.options, ...optionsOverrides }); } return jsxElemToJsonSync(component, thisCopy, this.options); } async renderToJsonAsync(component, optionsOverrides) { const thisCopy = _ComponentApi.clone(this); if (optionsOverrides) { return Promise.resolve(component).then( (c) => jsxElemToJsonAsync(c, thisCopy, { ...this.options, ...optionsOverrides }) ); } return Promise.resolve(component).then( (c) => jsxElemToJsonAsync(c, thisCopy, this.options) ); } renderToDom(window2, component, optionsOverrides) { const thisCopy = _ComponentApi.clone(this); if (optionsOverrides) { const r2 = new DomRenderer(window2, { ...this.options, ...optionsOverrides }); return r2.render(component, thisCopy); } const r = new DomRenderer(window2, this.options); return r.render(component, thisCopy); } async renderToDomAsync(window2, component, optionsOverrides) { const thisCopy = _ComponentApi.clone(this); if (optionsOverrides) { const r2 = new DomRenderer(window2, { ...this.options, ...optionsOverrides }); return Promise.resolve(component).then((c) => r2.renderAsync(c, thisCopy)); } const r = new DomRenderer(window2, this.options); return Promise.resolve(component).then((c) => r.renderAsync(c, thisCopy)); } }; // node_modules/jsxte/dist/esm/error-boundary/error-boundary.mjs var __defProp5 = Object.defineProperty; var __defNormalProp4 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp"); var __publicField4 = /* @__PURE__ */ __name((obj, key, value) => { __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }, "__publicField"); var ErrorBoundary = class { static { __name(this, "ErrorBoundary"); } /** * @internal */ static _isErrorBoundary(o) { const canBeClass = typeof o === "function"; const isNotNull = o !== null; if (!canBeClass || !isNotNull) return false; const baseName = o._baseName; return baseName === this._baseName; } constructor(_) { } }; __publicField4(ErrorBoundary, "_baseName", "ErrorBoundary"); // node_modules/jsxte/dist/esm/utilities/get-component-name.mjs var getComponentName = /* @__PURE__ */ __name((element) => { if (typeof element.tag === "string") { return element.tag; } if ("displayName" in element.tag && typeof element.tag.displayName === "string") { return element.tag.displayName; } if ("name" in element.tag && typeof element.tag.name === "string") { return element.tag.name; } return "AnonymousComponent"; }, "getComponentName"); // node_modules/jsxte/dist/esm/utilities/get-err-message.mjs var getErrorMessage = /* @__PURE__ */ __name((err) => { if (err instanceof Error) { return err.message; } if (typeof err === "string") { return err; } return String(err); }, "getErrorMessage"); // node_modules/jsxte/dist/esm/renderer/renderer.mjs var __defProp6 = Object.defineProperty; var __defNormalProp5 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp"); var __publicField5 = /* @__PURE__ */ __name((obj, key, value) => { __defNormalProp5(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }, "__publicField"); var NIL = Symbol("NIL"); function isTagElement(element) { return typeof element === "object" && element !== null && "type" in element && element.type === "tag"; } __name(isTagElement, "isTagElement"); function isErrorBoundaryElement(element) { return typeof element.tag === "function" && ErrorBoundary._isErrorBoundary(element.tag); } __name(isErrorBoundaryElement, "isErrorBoundaryElement"); function isPromiseLike(obj) { return obj instanceof Promise || typeof obj === "object" && obj !== null && typeof obj.then === "function" && typeof obj.catch === "function"; } __name(isPromiseLike, "isPromiseLike"); function asyncError() { throw new JsxteRenderError( "Encountered an async Component: Asynchronous Component's cannot be parsed by this renderer." ); } __name(asyncError, "asyncError"); var ElementMatcher = class { static { __name(this, "ElementMatcher"); } constructor(options) { this.options = options; __publicField5(this, "stringTagHandler"); __publicField5(this, "functionTagHandler"); __publicField5(this, "classTagHandler"); __publicField5(this, "fragmentHandler"); __publicField5(this, "textHandler"); __publicField5(this, "primitiveHandler"); __publicField5(this, "handleError"); } matchSyncElem(element, context) { switch (typeof element) { case "string": case "bigint": case "number": return this.primitiveHandler(element, context, element); case "boolean": case "function": case "symbol": case "undefined": return NIL; } if (element === null) { return NIL; } if (element.type === "textNode") { return this.textHandler(element, context, element); } if (element.type === "tag") { if (typeof element.tag === "string") { if (element.tag === "") { return this.fragmentHandler(element.props.children, context, element); } return this.stringTagHandler( { tag: element.tag, props: element.props }, context, element ); } if (typeof element.tag === "function") { if (ErrorBoundary._isErrorBoundary(element.tag)) { return this.classTagHandler( { classComponent: element.tag, props: element.props }, context, element ); } else { return this.functionTagHandler( { funcComponent: element.tag, props: element.props }, context, element ); } } } return NIL; } createHandler(func) { return (...args) => { try { const result = func.apply(null, args); if (isPromiseLike(result)) { return result.catch((err) => { return this.handleError(err, args[2], args[1]); }); } return result; } catch (err) { return this.handleError(err, args[2], args[1]); } }; } functionTag(on) { this.functionTagHandler = this.createHandler(on); return this; } classTag(on) { this.classTagHandler = this.createHandler(on); return this; } stringTag(on) { this.stringTagHandler = this.createHandler(on); return this; } fragment(on) { this.fragmentHandler = this.createHandler(on); return this; } text(on) { this.textHandler = this.createHandler(on); return this; } primitive(on) { this.primitiveHandler = this.createHandler(on); return this; } onError(on) { this.handleError = on; return this; } match(element, context) { if (isPromiseLike(element)) { if (this.options.allowAsync === false) { asyncError(); } return element.then((element2) => { return this.matchSyncElem(element2, { componentApi: ComponentApi.clone(context.componentApi) }); }); } return this.matchSyncElem(element, { componentApi: ComponentApi.clone(context.componentApi) }); } matchMap(elements, mapFn) { const results = []; const awaits = []; for (let i = 0; i < elements.length; i++) { const element = elements[i]; const r = mapFn( element, (element2, context) => this.match(element2, context) ); if (isPromiseLike(r)) { if (this.options.allowAsync === false) { asyncError(); } awaits.push( r.then((result) => { if (result !== NIL) { results[i] = result; } }) ); } else if (r !== NIL) { results[i] = r; } } if (awaits.length === 0) { return results; } return Promise.all(awaits).then(() => { return results; }); } }; var JsxteRenderer = class { static { __name(this, "JsxteRenderer"); } constructor(generator, options = { allowAsync: false }, rootComponentApi = ComponentApi.create(options)) { this.generator = generator; this.options = options; this.rootComponentApi = rootComponentApi; __publicField5(this, "matcher"); this.matcher = new ElementMatcher(options); const renderer = this; this.matcher.functionTag((tagElement, context) => { const elem = tagElement.funcComponent( tagElement.props, context.componentApi ); return renderer.renderChild(elem, context); }).classTag((tagElement, context) => { const compoentInstance = new tagElement.classComponent( tagElement.props ); const elem = compoentInstance.render( tagElement.props, context.componentApi ); return renderer.renderChild(elem, context); }).stringTag((tagElement, context) => { const { attributes, children } = this.resolveProps(tagElement.props); const renderedChildren = this.matcher.matchMap( children, (child, next) => next(child, { componentApi: ComponentApi.clone(context.componentApi) }) ); return this.generator.createElement( tagElement.tag, attributes, // assume generator accepts promises of T[] (allowAsync is true) renderedChildren ); }).fragment((fragmentElement, context) => { const childrenArray = Array.isArray