diff --git a/assets/back.png b/assets/back.png new file mode 100644 index 00000000..cb679482 Binary files /dev/null and b/assets/back.png differ diff --git a/frontend/.svelte-kit/generated/client/app.js b/frontend/.svelte-kit/generated/client/app.js index f5f91dc2..5dae92e5 100644 --- a/frontend/.svelte-kit/generated/client/app.js +++ b/frontend/.svelte-kit/generated/client/app.js @@ -14,7 +14,7 @@ export const server_loads = []; export const dictionary = { "/": [2], "/card_display": [3], - "/cards/interpret/[id]": [4], + "/cards": [4], "/cassandra": [5] }; diff --git a/frontend/.svelte-kit/generated/client/nodes/4.js b/frontend/.svelte-kit/generated/client/nodes/4.js index 67af0050..10d03ae4 100644 --- a/frontend/.svelte-kit/generated/client/nodes/4.js +++ b/frontend/.svelte-kit/generated/client/nodes/4.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/cards/interpret/[id]/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/cards/+page.svelte"; \ No newline at end of file diff --git a/frontend/.svelte-kit/generated/server/internal.js b/frontend/.svelte-kit/generated/server/internal.js index 90232f80..ef7af9f4 100644 --- a/frontend/.svelte-kit/generated/server/internal.js +++ b/frontend/.svelte-kit/generated/server/internal.js @@ -21,7 +21,7 @@ export const options = { app: ({ head, body, assets, nonce, env }) => "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t" + head + "\n\t\n\t\n\t\t
" + body + "
\n\t\n\n", error: ({ status, message }) => "\n\n\t\n\t\t\n\t\t" + message + "\n\n\t\t\n\t\n\t\n\t\t
\n\t\t\t" + status + "\n\t\t\t
\n\t\t\t\t

" + message + "

\n\t\t\t
\n\t\t
\n\t\n\n" }, - version_hash: "1y6zzef" + version_hash: "gdmqy8" }; export async function get_hooks() { diff --git a/frontend/README.md b/frontend/README.md index e69de29b..d0440fb1 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -0,0 +1,80 @@ +

Team Tarot

+ +Welcome to the README for Team Tarot, you're new favourite fortune teller + +This repo contains the codebase for the Tarot Card Reading +Application made by Team Tarot (Alannah Lawlor, Josh Day, Fara Ifaturoti, Oli Kelly, +Giandomenico Loparco and Matt Doyle). + +## Table of Contents + +- [Description](#description) +- [Installation](#installation) +- [Usage](#usage) +- [Features](#features) +- [Technologies Used](#technologies-used) +- [Project Structure](#project-structure) +- [Contributing](#contributing) +- [License](#license) +- [Acknowledgements](#acknowledgements) +- [Contact](#contact) + +## Description +Team Tarot is a tarot card reading application that, when the user is ready, will deal 3 random cards from a 78 card deck of tarot cards, provide an explanation for each, and then give a reading. Each card will appear reversed or upright and their meanings will be displayed accordingly. The type of card whether major or minor will also be printed, each of the three tarot cards printed will provide information about the past, present and the future. + +## Installation +To run Team Tarot locally, you'll need to install: +- [Golang](https://go.dev/) +- [Gin Framework](https://go.dev/doc/modules/) +- [SvelteKit](https://github.com/sveltejs/kit) +- [Node](https://nodejs.org/en) + + +## Usage +1. Clone the repository `git clone https://github.com/pirateking92/teamtarot` + +2. Go to the project directory `cd teamtarot` + +3. Install dependencies `npm install ` + +4. Run the backend server `go run main.go` + +5. Run the frontend server `npm run dev` + +6. Navigate to `http://localhost:5173` + +## Features +- Users provide their name and a user story. +- The application generates 3 random tarot cards facing down. +- Upon clicking, the application reveals 3 random tarot cards along with their names, types, and descriptions, based on whether the card is displayed upright or reversed. +- The generated tarot cards and the user story are used to generate a personalized tarot card reading. + + +## Technologies Used +- GoLang is used for the backend with a Gin framework to handle HTTP requests. +- SvelteKit is used for the frontend, requiring that node.js be installed. +- Tailwind CSS library is used for styling + +## Project Structure +Frontend +- .svelte-kit: This directory contains configuration files and settings specific to the SvelteKit framework. It includes files related to routing, server setup, and other SvelteKit-specific configurations. +- node_modules: This directory holds the dependencies required by the frontend. These dependencies are installed via npm and include libraries and packages. +- src: Where the bulk of the frontend code is. It contains the source code, including Svelte components, JavaScript modules, CSS files, and other assets. +- static: This directory stores static assets. + +Backend +- controllers: This directory hold the logic behing incomming HTTP requests, interacts with models and generates responses +- env: Holds functionality for loading environment variables +- models: Defines the properties of the tarot cards allowing for manipulaton of the tarot cards within the application +- routes: This contains files that define API endpoints and map them to corresponding controllers +- services: Holds functions for fetching tarot card data from an external API and interpreting them using the OpenAI API + + + +## Acknowledgements + + + +## Contact + + diff --git a/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-F3FYYIAV.js b/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-F3FYYIAV.js deleted file mode 100644 index 82ce66a8..00000000 --- a/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-F3FYYIAV.js +++ /dev/null @@ -1,11 +0,0 @@ -var __defProp = Object.defineProperty; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField = (obj, key, value) => { - __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); - return value; -}; - -export { - __publicField -}; -//# sourceMappingURL=chunk-F3FYYIAV.js.map diff --git a/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-F3FYYIAV.js.map b/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-F3FYYIAV.js.map deleted file mode 100644 index 98652118..00000000 --- a/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-F3FYYIAV.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": [], - "sourcesContent": [], - "mappings": "", - "names": [] -} diff --git a/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-GJ3NJHGJ.js b/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-GJ3NJHGJ.js deleted file mode 100644 index fb14dac3..00000000 --- a/frontend/node_modules/.vite/deps_temp_f34e232c/chunk-GJ3NJHGJ.js +++ /dev/null @@ -1,2910 +0,0 @@ -import { - VERSION -} from "./chunk-YK27YCQ4.js"; -import { - __publicField -} from "./chunk-F3FYYIAV.js"; - -// node_modules/svelte/src/runtime/internal/utils.js -function noop() { -} -var identity = (x) => x; -function assign(tar, src) { - for (const k in src) - tar[k] = src[k]; - return ( - /** @type {T & S} */ - tar - ); -} -function is_promise(value) { - return !!value && (typeof value === "object" || typeof value === "function") && typeof /** @type {any} */ - value.then === "function"; -} -function add_location(element2, file, line, column, char) { - element2.__svelte_meta = { - loc: { file, line, column, char } - }; -} -function run(fn) { - return fn(); -} -function blank_object() { - return /* @__PURE__ */ Object.create(null); -} -function run_all(fns) { - fns.forEach(run); -} -function is_function(thing) { - return typeof thing === "function"; -} -function safe_not_equal(a, b) { - return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function"; -} -var src_url_equal_anchor; -function src_url_equal(element_src, url) { - if (element_src === url) - return true; - if (!src_url_equal_anchor) { - src_url_equal_anchor = document.createElement("a"); - } - src_url_equal_anchor.href = url; - return element_src === src_url_equal_anchor.href; -} -function split_srcset(srcset) { - return srcset.split(",").map((src) => src.trim().split(" ").filter(Boolean)); -} -function srcset_url_equal(element_srcset, srcset) { - const element_urls = split_srcset(element_srcset.srcset); - const urls = split_srcset(srcset || ""); - return urls.length === element_urls.length && urls.every( - ([url, width], i) => width === element_urls[i][1] && // We need to test both ways because Vite will create an a full URL with - // `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the - // relative URLs inside srcset are not automatically resolved to absolute URLs by - // browsers (in contrast to img.src). This means both SSR and DOM code could - // contain relative or absolute URLs. - (src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0])) - ); -} -function not_equal(a, b) { - return a != a ? b == b : a !== b; -} -function is_empty(obj) { - return Object.keys(obj).length === 0; -} -function validate_store(store, name) { - if (store != null && typeof store.subscribe !== "function") { - throw new Error(`'${name}' is not a store with a 'subscribe' method`); - } -} -function subscribe(store, ...callbacks) { - if (store == null) { - for (const callback of callbacks) { - callback(void 0); - } - return noop; - } - const unsub = store.subscribe(...callbacks); - return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; -} -function get_store_value(store) { - let value; - subscribe(store, (_) => value = _)(); - return value; -} -function component_subscribe(component, store, callback) { - component.$$.on_destroy.push(subscribe(store, callback)); -} -function create_slot(definition, ctx, $$scope, fn) { - if (definition) { - const slot_ctx = get_slot_context(definition, ctx, $$scope, fn); - return definition[0](slot_ctx); - } -} -function get_slot_context(definition, ctx, $$scope, fn) { - return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx; -} -function get_slot_changes(definition, $$scope, dirty, fn) { - if (definition[2] && fn) { - const lets = definition[2](fn(dirty)); - if ($$scope.dirty === void 0) { - return lets; - } - if (typeof lets === "object") { - const merged = []; - const len = Math.max($$scope.dirty.length, lets.length); - for (let i = 0; i < len; i += 1) { - merged[i] = $$scope.dirty[i] | lets[i]; - } - return merged; - } - return $$scope.dirty | lets; - } - return $$scope.dirty; -} -function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) { - if (slot_changes) { - const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn); - slot.p(slot_context, slot_changes); - } -} -function update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) { - const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn); - update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn); -} -function get_all_dirty_from_scope($$scope) { - if ($$scope.ctx.length > 32) { - const dirty = []; - const length = $$scope.ctx.length / 32; - for (let i = 0; i < length; i++) { - dirty[i] = -1; - } - return dirty; - } - return -1; -} -function exclude_internal_props(props) { - const result = {}; - for (const k in props) - if (k[0] !== "$") - result[k] = props[k]; - return result; -} -function compute_rest_props(props, keys) { - const rest = {}; - keys = new Set(keys); - for (const k in props) - if (!keys.has(k) && k[0] !== "$") - rest[k] = props[k]; - return rest; -} -function compute_slots(slots) { - const result = {}; - for (const key in slots) { - result[key] = true; - } - return result; -} -function once(fn) { - let ran = false; - return function(...args) { - if (ran) - return; - ran = true; - fn.call(this, ...args); - }; -} -function null_to_empty(value) { - return value == null ? "" : value; -} -function set_store_value(store, ret, value) { - store.set(value); - return ret; -} -var has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); -function action_destroyer(action_result) { - return action_result && is_function(action_result.destroy) ? action_result.destroy : noop; -} -function split_css_unit(value) { - const split = typeof value === "string" && value.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/); - return split ? [parseFloat(split[1]), split[2] || "px"] : [ - /** @type {number} */ - value, - "px" - ]; -} -var contenteditable_truthy_values = ["", true, 1, "true", "contenteditable"]; - -// node_modules/svelte/src/runtime/internal/environment.js -var is_client = typeof window !== "undefined"; -var now = is_client ? () => window.performance.now() : () => Date.now(); -var raf = is_client ? (cb) => requestAnimationFrame(cb) : noop; -function set_now(fn) { - now = fn; -} -function set_raf(fn) { - raf = fn; -} - -// node_modules/svelte/src/runtime/internal/loop.js -var tasks = /* @__PURE__ */ new Set(); -function run_tasks(now2) { - tasks.forEach((task) => { - if (!task.c(now2)) { - tasks.delete(task); - task.f(); - } - }); - if (tasks.size !== 0) - raf(run_tasks); -} -function clear_loops() { - tasks.clear(); -} -function loop(callback) { - let task; - if (tasks.size === 0) - raf(run_tasks); - return { - promise: new Promise((fulfill) => { - tasks.add(task = { c: callback, f: fulfill }); - }), - abort() { - tasks.delete(task); - } - }; -} - -// node_modules/svelte/src/runtime/internal/globals.js -var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : ( - // @ts-ignore Node typings have this - global -); - -// node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js -var ResizeObserverSingleton = class _ResizeObserverSingleton { - /** @param {ResizeObserverOptions} options */ - constructor(options) { - /** - * @private - * @readonly - * @type {WeakMap} - */ - __publicField(this, "_listeners", "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0); - /** - * @private - * @type {ResizeObserver} - */ - __publicField(this, "_observer"); - /** @type {ResizeObserverOptions} */ - __publicField(this, "options"); - this.options = options; - } - /** - * @param {Element} element - * @param {import('./private.js').Listener} listener - * @returns {() => void} - */ - observe(element2, listener) { - this._listeners.set(element2, listener); - this._getObserver().observe(element2, this.options); - return () => { - this._listeners.delete(element2); - this._observer.unobserve(element2); - }; - } - /** - * @private - */ - _getObserver() { - return this._observer ?? (this._observer = new ResizeObserver((entries) => { - var _a; - for (const entry of entries) { - _ResizeObserverSingleton.entries.set(entry.target, entry); - (_a = this._listeners.get(entry.target)) == null ? void 0 : _a(entry); - } - })); - } -}; -ResizeObserverSingleton.entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0; - -// node_modules/svelte/src/runtime/internal/dom.js -var is_hydrating = false; -function start_hydrating() { - is_hydrating = true; -} -function end_hydrating() { - is_hydrating = false; -} -function upper_bound(low, high, key, value) { - while (low < high) { - const mid = low + (high - low >> 1); - if (key(mid) <= value) { - low = mid + 1; - } else { - high = mid; - } - } - return low; -} -function init_hydrate(target) { - if (target.hydrate_init) - return; - target.hydrate_init = true; - let children2 = ( - /** @type {ArrayLike} */ - target.childNodes - ); - if (target.nodeName === "HEAD") { - const my_children = []; - for (let i = 0; i < children2.length; i++) { - const node = children2[i]; - if (node.claim_order !== void 0) { - my_children.push(node); - } - } - children2 = my_children; - } - const m = new Int32Array(children2.length + 1); - const p = new Int32Array(children2.length); - m[0] = -1; - let longest = 0; - for (let i = 0; i < children2.length; i++) { - const current = children2[i].claim_order; - const seq_len = (longest > 0 && children2[m[longest]].claim_order <= current ? longest + 1 : upper_bound(1, longest, (idx) => children2[m[idx]].claim_order, current)) - 1; - p[i] = m[seq_len] + 1; - const new_len = seq_len + 1; - m[new_len] = i; - longest = Math.max(new_len, longest); - } - const lis = []; - const to_move = []; - let last = children2.length - 1; - for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) { - lis.push(children2[cur - 1]); - for (; last >= cur; last--) { - to_move.push(children2[last]); - } - last--; - } - for (; last >= 0; last--) { - to_move.push(children2[last]); - } - lis.reverse(); - to_move.sort((a, b) => a.claim_order - b.claim_order); - for (let i = 0, j = 0; i < to_move.length; i++) { - while (j < lis.length && to_move[i].claim_order >= lis[j].claim_order) { - j++; - } - const anchor = j < lis.length ? lis[j] : null; - target.insertBefore(to_move[i], anchor); - } -} -function append(target, node) { - target.appendChild(node); -} -function append_styles(target, style_sheet_id, styles) { - const append_styles_to = get_root_for_style(target); - if (!append_styles_to.getElementById(style_sheet_id)) { - const style = element("style"); - style.id = style_sheet_id; - style.textContent = styles; - append_stylesheet(append_styles_to, style); - } -} -function get_root_for_style(node) { - if (!node) - return document; - const root = node.getRootNode ? node.getRootNode() : node.ownerDocument; - if (root && /** @type {ShadowRoot} */ - root.host) { - return ( - /** @type {ShadowRoot} */ - root - ); - } - return node.ownerDocument; -} -function append_empty_stylesheet(node) { - const style_element = element("style"); - style_element.textContent = "/* empty */"; - append_stylesheet(get_root_for_style(node), style_element); - return style_element.sheet; -} -function append_stylesheet(node, style) { - append( - /** @type {Document} */ - node.head || node, - style - ); - return style.sheet; -} -function append_hydration(target, node) { - if (is_hydrating) { - init_hydrate(target); - if (target.actual_end_child === void 0 || target.actual_end_child !== null && target.actual_end_child.parentNode !== target) { - target.actual_end_child = target.firstChild; - } - while (target.actual_end_child !== null && target.actual_end_child.claim_order === void 0) { - target.actual_end_child = target.actual_end_child.nextSibling; - } - if (node !== target.actual_end_child) { - if (node.claim_order !== void 0 || node.parentNode !== target) { - target.insertBefore(node, target.actual_end_child); - } - } else { - target.actual_end_child = node.nextSibling; - } - } else if (node.parentNode !== target || node.nextSibling !== null) { - target.appendChild(node); - } -} -function insert(target, node, anchor) { - target.insertBefore(node, anchor || null); -} -function insert_hydration(target, node, anchor) { - if (is_hydrating && !anchor) { - append_hydration(target, node); - } else if (node.parentNode !== target || node.nextSibling != anchor) { - target.insertBefore(node, anchor || null); - } -} -function detach(node) { - if (node.parentNode) { - node.parentNode.removeChild(node); - } -} -function destroy_each(iterations, detaching) { - for (let i = 0; i < iterations.length; i += 1) { - if (iterations[i]) - iterations[i].d(detaching); - } -} -function element(name) { - return document.createElement(name); -} -function element_is(name, is) { - return document.createElement(name, { is }); -} -function object_without_properties(obj, exclude) { - const target = ( - /** @type {Pick>} */ - {} - ); - for (const k in obj) { - if (has_prop(obj, k) && // @ts-ignore - exclude.indexOf(k) === -1) { - target[k] = obj[k]; - } - } - return target; -} -function svg_element(name) { - return document.createElementNS("http://www.w3.org/2000/svg", name); -} -function text(data) { - return document.createTextNode(data); -} -function space() { - return text(" "); -} -function empty() { - return text(""); -} -function comment(content) { - return document.createComment(content); -} -function listen(node, event, handler, options) { - node.addEventListener(event, handler, options); - return () => node.removeEventListener(event, handler, options); -} -function prevent_default(fn) { - return function(event) { - event.preventDefault(); - return fn.call(this, event); - }; -} -function stop_propagation(fn) { - return function(event) { - event.stopPropagation(); - return fn.call(this, event); - }; -} -function stop_immediate_propagation(fn) { - return function(event) { - event.stopImmediatePropagation(); - return fn.call(this, event); - }; -} -function self(fn) { - return function(event) { - if (event.target === this) - fn.call(this, event); - }; -} -function trusted(fn) { - return function(event) { - if (event.isTrusted) - fn.call(this, event); - }; -} -function attr(node, attribute, value) { - if (value == null) - node.removeAttribute(attribute); - else if (node.getAttribute(attribute) !== value) - node.setAttribute(attribute, value); -} -var always_set_through_set_attribute = ["width", "height"]; -function set_attributes(node, attributes) { - const descriptors = Object.getOwnPropertyDescriptors(node.__proto__); - for (const key in attributes) { - if (attributes[key] == null) { - node.removeAttribute(key); - } else if (key === "style") { - node.style.cssText = attributes[key]; - } else if (key === "__value") { - node.value = node[key] = attributes[key]; - } else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) { - node[key] = attributes[key]; - } else { - attr(node, key, attributes[key]); - } - } -} -function set_svg_attributes(node, attributes) { - for (const key in attributes) { - attr(node, key, attributes[key]); - } -} -function set_custom_element_data_map(node, data_map) { - Object.keys(data_map).forEach((key) => { - set_custom_element_data(node, key, data_map[key]); - }); -} -function set_custom_element_data(node, prop, value) { - const lower = prop.toLowerCase(); - if (lower in node) { - node[lower] = typeof node[lower] === "boolean" && value === "" ? true : value; - } else if (prop in node) { - node[prop] = typeof node[prop] === "boolean" && value === "" ? true : value; - } else { - attr(node, prop, value); - } -} -function set_dynamic_element_data(tag) { - return /-/.test(tag) ? set_custom_element_data_map : set_attributes; -} -function xlink_attr(node, attribute, value) { - node.setAttributeNS("http://www.w3.org/1999/xlink", attribute, value); -} -function get_svelte_dataset(node) { - return node.dataset.svelteH; -} -function get_binding_group_value(group, __value, checked) { - const value = /* @__PURE__ */ new Set(); - for (let i = 0; i < group.length; i += 1) { - if (group[i].checked) - value.add(group[i].__value); - } - if (!checked) { - value.delete(__value); - } - return Array.from(value); -} -function init_binding_group(group) { - let _inputs; - return { - /* push */ - p(...inputs) { - _inputs = inputs; - _inputs.forEach((input) => group.push(input)); - }, - /* remove */ - r() { - _inputs.forEach((input) => group.splice(group.indexOf(input), 1)); - } - }; -} -function init_binding_group_dynamic(group, indexes) { - let _group = get_binding_group(group); - let _inputs; - function get_binding_group(group2) { - for (let i = 0; i < indexes.length; i++) { - group2 = group2[indexes[i]] = group2[indexes[i]] || []; - } - return group2; - } - function push() { - _inputs.forEach((input) => _group.push(input)); - } - function remove() { - _inputs.forEach((input) => _group.splice(_group.indexOf(input), 1)); - } - return { - /* update */ - u(new_indexes) { - indexes = new_indexes; - const new_group = get_binding_group(group); - if (new_group !== _group) { - remove(); - _group = new_group; - push(); - } - }, - /* push */ - p(...inputs) { - _inputs = inputs; - push(); - }, - /* remove */ - r: remove - }; -} -function to_number(value) { - return value === "" ? null : +value; -} -function time_ranges_to_array(ranges) { - const array = []; - for (let i = 0; i < ranges.length; i += 1) { - array.push({ start: ranges.start(i), end: ranges.end(i) }); - } - return array; -} -function children(element2) { - return Array.from(element2.childNodes); -} -function init_claim_info(nodes) { - if (nodes.claim_info === void 0) { - nodes.claim_info = { last_index: 0, total_claimed: 0 }; - } -} -function claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) { - init_claim_info(nodes); - const result_node = (() => { - for (let i = nodes.claim_info.last_index; i < nodes.length; i++) { - const node = nodes[i]; - if (predicate(node)) { - const replacement = process_node(node); - if (replacement === void 0) { - nodes.splice(i, 1); - } else { - nodes[i] = replacement; - } - if (!dont_update_last_index) { - nodes.claim_info.last_index = i; - } - return node; - } - } - for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) { - const node = nodes[i]; - if (predicate(node)) { - const replacement = process_node(node); - if (replacement === void 0) { - nodes.splice(i, 1); - } else { - nodes[i] = replacement; - } - if (!dont_update_last_index) { - nodes.claim_info.last_index = i; - } else if (replacement === void 0) { - nodes.claim_info.last_index--; - } - return node; - } - } - return create_node(); - })(); - result_node.claim_order = nodes.claim_info.total_claimed; - nodes.claim_info.total_claimed += 1; - return result_node; -} -function claim_element_base(nodes, name, attributes, create_element) { - return claim_node( - nodes, - /** @returns {node is Element | SVGElement} */ - (node) => node.nodeName === name, - /** @param {Element} node */ - (node) => { - const remove = []; - for (let j = 0; j < node.attributes.length; j++) { - const attribute = node.attributes[j]; - if (!attributes[attribute.name]) { - remove.push(attribute.name); - } - } - remove.forEach((v) => node.removeAttribute(v)); - return void 0; - }, - () => create_element(name) - ); -} -function claim_element(nodes, name, attributes) { - return claim_element_base(nodes, name, attributes, element); -} -function claim_svg_element(nodes, name, attributes) { - return claim_element_base(nodes, name, attributes, svg_element); -} -function claim_text(nodes, data) { - return claim_node( - nodes, - /** @returns {node is Text} */ - (node) => node.nodeType === 3, - /** @param {Text} node */ - (node) => { - const data_str = "" + data; - if (node.data.startsWith(data_str)) { - if (node.data.length !== data_str.length) { - return node.splitText(data_str.length); - } - } else { - node.data = data_str; - } - }, - () => text(data), - true - // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements - ); -} -function claim_space(nodes) { - return claim_text(nodes, " "); -} -function claim_comment(nodes, data) { - return claim_node( - nodes, - /** @returns {node is Comment} */ - (node) => node.nodeType === 8, - /** @param {Comment} node */ - (node) => { - node.data = "" + data; - return void 0; - }, - () => comment(data), - true - ); -} -function get_comment_idx(nodes, text2, start) { - for (let i = start; i < nodes.length; i += 1) { - const node = nodes[i]; - if (node.nodeType === 8 && node.textContent.trim() === text2) { - return i; - } - } - return -1; -} -function claim_html_tag(nodes, is_svg) { - const start_index = get_comment_idx(nodes, "HTML_TAG_START", 0); - const end_index = get_comment_idx(nodes, "HTML_TAG_END", start_index + 1); - if (start_index === -1 || end_index === -1) { - return new HtmlTagHydration(is_svg); - } - init_claim_info(nodes); - const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1); - detach(html_tag_nodes[0]); - detach(html_tag_nodes[html_tag_nodes.length - 1]); - const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1); - if (claimed_nodes.length === 0) { - return new HtmlTagHydration(is_svg); - } - for (const n of claimed_nodes) { - n.claim_order = nodes.claim_info.total_claimed; - nodes.claim_info.total_claimed += 1; - } - return new HtmlTagHydration(is_svg, claimed_nodes); -} -function set_data(text2, data) { - data = "" + data; - if (text2.data === data) - return; - text2.data = /** @type {string} */ - data; -} -function set_data_contenteditable(text2, data) { - data = "" + data; - if (text2.wholeText === data) - return; - text2.data = /** @type {string} */ - data; -} -function set_data_maybe_contenteditable(text2, data, attr_value) { - if (~contenteditable_truthy_values.indexOf(attr_value)) { - set_data_contenteditable(text2, data); - } else { - set_data(text2, data); - } -} -function set_input_value(input, value) { - input.value = value == null ? "" : value; -} -function set_input_type(input, type) { - try { - input.type = type; - } catch (e) { - } -} -function set_style(node, key, value, important) { - if (value == null) { - node.style.removeProperty(key); - } else { - node.style.setProperty(key, value, important ? "important" : ""); - } -} -function select_option(select, value, mounting) { - for (let i = 0; i < select.options.length; i += 1) { - const option = select.options[i]; - if (option.__value === value) { - option.selected = true; - return; - } - } - if (!mounting || value !== void 0) { - select.selectedIndex = -1; - } -} -function select_options(select, value) { - for (let i = 0; i < select.options.length; i += 1) { - const option = select.options[i]; - option.selected = ~value.indexOf(option.__value); - } -} -function select_value(select) { - const selected_option = select.querySelector(":checked"); - return selected_option && selected_option.__value; -} -function select_multiple_value(select) { - return [].map.call(select.querySelectorAll(":checked"), (option) => option.__value); -} -var crossorigin; -function is_crossorigin() { - if (crossorigin === void 0) { - crossorigin = false; - try { - if (typeof window !== "undefined" && window.parent) { - void window.parent.document; - } - } catch (error) { - crossorigin = true; - } - } - return crossorigin; -} -function add_iframe_resize_listener(node, fn) { - const computed_style = getComputedStyle(node); - if (computed_style.position === "static") { - node.style.position = "relative"; - } - const iframe = element("iframe"); - iframe.setAttribute( - "style", - "display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;" - ); - iframe.setAttribute("aria-hidden", "true"); - iframe.tabIndex = -1; - const crossorigin2 = is_crossorigin(); - let unsubscribe; - if (crossorigin2) { - iframe.src = "data:text/html,\";\n\t\tunsubscribe = listen(\n\t\t\twindow,\n\t\t\t'message',\n\t\t\t/** @param {MessageEvent} event */ (event) => {\n\t\t\t\tif (event.source === iframe.contentWindow) fn();\n\t\t\t}\n\t\t);\n\t} else {\n\t\tiframe.src = 'about:blank';\n\t\tiframe.onload = () => {\n\t\t\tunsubscribe = listen(iframe.contentWindow, 'resize', fn);\n\t\t\t// make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n\t\t\t// see https://github.com/sveltejs/svelte/issues/4233\n\t\t\tfn();\n\t\t};\n\t}\n\tappend(node, iframe);\n\treturn () => {\n\t\tif (crossorigin) {\n\t\t\tunsubscribe();\n\t\t} else if (unsubscribe && iframe.contentWindow) {\n\t\t\tunsubscribe();\n\t\t}\n\t\tdetach(iframe);\n\t};\n}\nexport const resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'content-box'\n});\nexport const resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'border-box'\n});\nexport const resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton(\n\t{ box: 'device-pixel-content-box' }\n);\nexport { ResizeObserverSingleton };\n\n/**\n * @returns {void} */\nexport function toggle_class(element, name, toggle) {\n\t// The `!!` is required because an `undefined` flag means flipping the current state.\n\telement.classList.toggle(name, !!toggle);\n}\n\n/**\n * @template T\n * @param {string} type\n * @param {T} [detail]\n * @param {{ bubbles?: boolean, cancelable?: boolean }} [options]\n * @returns {CustomEvent}\n */\nexport function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n\treturn new CustomEvent(type, { detail, bubbles, cancelable });\n}\n\n/**\n * @param {string} selector\n * @param {HTMLElement} parent\n * @returns {ChildNodeArray}\n */\nexport function query_selector_all(selector, parent = document.body) {\n\treturn Array.from(parent.querySelectorAll(selector));\n}\n\n/**\n * @param {string} nodeId\n * @param {HTMLElement} head\n * @returns {any[]}\n */\nexport function head_selector(nodeId, head) {\n\tconst result = [];\n\tlet started = 0;\n\tfor (const node of head.childNodes) {\n\t\tif (node.nodeType === 8 /* comment node */) {\n\t\t\tconst comment = node.textContent.trim();\n\t\t\tif (comment === `HEAD_${nodeId}_END`) {\n\t\t\t\tstarted -= 1;\n\t\t\t\tresult.push(node);\n\t\t\t} else if (comment === `HEAD_${nodeId}_START`) {\n\t\t\t\tstarted += 1;\n\t\t\t\tresult.push(node);\n\t\t\t}\n\t\t} else if (started > 0) {\n\t\t\tresult.push(node);\n\t\t}\n\t}\n\treturn result;\n}\n/** */\nexport class HtmlTag {\n\t/**\n\t * @private\n\t * @default false\n\t */\n\tis_svg = false;\n\t/** parent for creating node */\n\te = undefined;\n\t/** html tag nodes */\n\tn = undefined;\n\t/** target */\n\tt = undefined;\n\t/** anchor */\n\ta = undefined;\n\tconstructor(is_svg = false) {\n\t\tthis.is_svg = is_svg;\n\t\tthis.e = this.n = null;\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tc(html) {\n\t\tthis.h(html);\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @param {HTMLElement | SVGElement} target\n\t * @param {HTMLElement | SVGElement} anchor\n\t * @returns {void}\n\t */\n\tm(html, target, anchor = null) {\n\t\tif (!this.e) {\n\t\t\tif (this.is_svg)\n\t\t\t\tthis.e = svg_element(/** @type {keyof SVGElementTagNameMap} */ (target.nodeName));\n\t\t\t/** #7364 target for