(function(l, r) { if (l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (window.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(window.document); var app = (function () { 'use strict'; function noop() { } function assign(tar, src) { // @ts-ignore for (const k in src) tar[k] = src[k]; return tar; } function add_location(element, file, line, column, char) { element.__svelte_meta = { loc: { file, line, column, char } }; } function run(fn) { return fn(); } function blank_object() { return 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'); } 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) { return noop; } const unsub = store.subscribe(...callbacks); return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; } 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 === undefined) { 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(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); if (slot_changes) { const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn); slot.p(slot_context, slot_changes); } } 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 append(target, node) { target.appendChild(node); } function insert(target, node, anchor) { target.insertBefore(node, anchor || null); } function detach(node) { 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 text(data) { return document.createTextNode(data); } function space() { return text(' '); } function empty() { return text(''); } 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(); // @ts-ignore return 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); } function set_attributes(node, attributes) { // @ts-ignore 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) { node[key] = attributes[key]; } else { attr(node, key, attributes[key]); } } } function children(element) { return Array.from(element.childNodes); } function set_input_value(input, value) { input.value = value == null ? '' : value; } function toggle_class(element, name, toggle) { element.classList[toggle ? 'add' : 'remove'](name); } function custom_event(type, detail) { const e = document.createEvent('CustomEvent'); e.initCustomEvent(type, false, false, detail); return e; } class HtmlTag { constructor(anchor = null) { this.a = anchor; this.e = this.n = null; } m(html, target, anchor = null) { if (!this.e) { this.e = element(target.nodeName); this.t = target; this.h(html); } this.i(anchor); } h(html) { this.e.innerHTML = html; this.n = Array.from(this.e.childNodes); } i(anchor) { for (let i = 0; i < this.n.length; i += 1) { insert(this.t, this.n[i], anchor); } } p(html) { this.d(); this.h(html); this.i(this.a); } d() { this.n.forEach(detach); } } let current_component; function set_current_component(component) { current_component = component; } function get_current_component() { if (!current_component) throw new Error('Function called outside component initialization'); return current_component; } function onMount(fn) { get_current_component().$$.on_mount.push(fn); } function onDestroy(fn) { get_current_component().$$.on_destroy.push(fn); } function createEventDispatcher() { const component = get_current_component(); return (type, detail) => { const callbacks = component.$$.callbacks[type]; if (callbacks) { // TODO are there situations where events could be dispatched // in a server (non-DOM) environment? const event = custom_event(type, detail); callbacks.slice().forEach(fn => { fn.call(component, event); }); } }; } function setContext(key, context) { get_current_component().$$.context.set(key, context); } function getContext(key) { return get_current_component().$$.context.get(key); } const dirty_components = []; const binding_callbacks = []; const render_callbacks = []; const flush_callbacks = []; const resolved_promise = Promise.resolve(); let update_scheduled = false; function schedule_update() { if (!update_scheduled) { update_scheduled = true; resolved_promise.then(flush); } } function add_render_callback(fn) { render_callbacks.push(fn); } let flushing = false; const seen_callbacks = new Set(); function flush() { if (flushing) return; flushing = true; do { // first, call beforeUpdate functions // and update components for (let i = 0; i < dirty_components.length; i += 1) { const component = dirty_components[i]; set_current_component(component); update(component.$$); } set_current_component(null); dirty_components.length = 0; while (binding_callbacks.length) binding_callbacks.pop()(); // then, once components are updated, call // afterUpdate functions. This may cause // subsequent updates... for (let i = 0; i < render_callbacks.length; i += 1) { const callback = render_callbacks[i]; if (!seen_callbacks.has(callback)) { // ...so guard against infinite loops seen_callbacks.add(callback); callback(); } } render_callbacks.length = 0; } while (dirty_components.length); while (flush_callbacks.length) { flush_callbacks.pop()(); } update_scheduled = false; flushing = false; seen_callbacks.clear(); } function update($$) { if ($$.fragment !== null) { $$.update(); run_all($$.before_update); const dirty = $$.dirty; $$.dirty = [-1]; $$.fragment && $$.fragment.p($$.ctx, dirty); $$.after_update.forEach(add_render_callback); } } const outroing = new Set(); let outros; function group_outros() { outros = { r: 0, c: [], p: outros // parent group }; } function check_outros() { if (!outros.r) { run_all(outros.c); } outros = outros.p; } function transition_in(block, local) { if (block && block.i) { outroing.delete(block); block.i(local); } } function transition_out(block, local, detach, callback) { if (block && block.o) { if (outroing.has(block)) return; outroing.add(block); outros.c.push(() => { outroing.delete(block); if (callback) { if (detach) block.d(1); callback(); } }); block.o(local); } } const globals = (typeof window !== 'undefined' ? window : typeof globalThis !== 'undefined' ? globalThis : global); function outro_and_destroy_block(block, lookup) { transition_out(block, 1, 1, () => { lookup.delete(block.key); }); } function update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) { let o = old_blocks.length; let n = list.length; let i = o; const old_indexes = {}; while (i--) old_indexes[old_blocks[i].key] = i; const new_blocks = []; const new_lookup = new Map(); const deltas = new Map(); i = n; while (i--) { const child_ctx = get_context(ctx, list, i); const key = get_key(child_ctx); let block = lookup.get(key); if (!block) { block = create_each_block(key, child_ctx); block.c(); } else if (dynamic) { block.p(child_ctx, dirty); } new_lookup.set(key, new_blocks[i] = block); if (key in old_indexes) deltas.set(key, Math.abs(i - old_indexes[key])); } const will_move = new Set(); const did_move = new Set(); function insert(block) { transition_in(block, 1); block.m(node, next); lookup.set(block.key, block); next = block.first; n--; } while (o && n) { const new_block = new_blocks[n - 1]; const old_block = old_blocks[o - 1]; const new_key = new_block.key; const old_key = old_block.key; if (new_block === old_block) { // do nothing next = new_block.first; o--; n--; } else if (!new_lookup.has(old_key)) { // remove old block destroy(old_block, lookup); o--; } else if (!lookup.has(new_key) || will_move.has(new_key)) { insert(new_block); } else if (did_move.has(old_key)) { o--; } else if (deltas.get(new_key) > deltas.get(old_key)) { did_move.add(new_key); insert(new_block); } else { will_move.add(old_key); o--; } } while (o--) { const old_block = old_blocks[o]; if (!new_lookup.has(old_block.key)) destroy(old_block, lookup); } while (n) insert(new_blocks[n - 1]); return new_blocks; } function validate_each_keys(ctx, list, get_context, get_key) { const keys = new Set(); for (let i = 0; i < list.length; i++) { const key = get_key(get_context(ctx, list, i)); if (keys.has(key)) { throw new Error('Cannot have duplicate keys in a keyed each'); } keys.add(key); } } function get_spread_update(levels, updates) { const update = {}; const to_null_out = {}; const accounted_for = { $$scope: 1 }; let i = levels.length; while (i--) { const o = levels[i]; const n = updates[i]; if (n) { for (const key in o) { if (!(key in n)) to_null_out[key] = 1; } for (const key in n) { if (!accounted_for[key]) { update[key] = n[key]; accounted_for[key] = 1; } } levels[i] = n; } else { for (const key in o) { accounted_for[key] = 1; } } } for (const key in to_null_out) { if (!(key in update)) update[key] = undefined; } return update; } function get_spread_object(spread_props) { return typeof spread_props === 'object' && spread_props !== null ? spread_props : {}; } function create_component(block) { block && block.c(); } function mount_component(component, target, anchor, customElement) { const { fragment, on_mount, on_destroy, after_update } = component.$$; fragment && fragment.m(target, anchor); if (!customElement) { // onMount happens before the initial afterUpdate add_render_callback(() => { const new_on_destroy = on_mount.map(run).filter(is_function); if (on_destroy) { on_destroy.push(...new_on_destroy); } else { // Edge case - component was destroyed immediately, // most likely as a result of a binding initialising run_all(new_on_destroy); } component.$$.on_mount = []; }); } after_update.forEach(add_render_callback); } function destroy_component(component, detaching) { const $$ = component.$$; if ($$.fragment !== null) { run_all($$.on_destroy); $$.fragment && $$.fragment.d(detaching); // TODO null out other refs, including component.$$ (but need to // preserve final state?) $$.on_destroy = $$.fragment = null; $$.ctx = []; } } function make_dirty(component, i) { if (component.$$.dirty[0] === -1) { dirty_components.push(component); schedule_update(); component.$$.dirty.fill(0); } component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { const parent_component = current_component; set_current_component(component); const $$ = component.$$ = { fragment: null, ctx: null, // state props, update: noop, not_equal, bound: blank_object(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], context: new Map(parent_component ? parent_component.$$.context : options.context || []), // everything else callbacks: blank_object(), dirty, skip_bound: false }; let ready = false; $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value); if (ready) make_dirty(component, i); } return ret; }) : []; $$.update(); ready = true; run_all($$.before_update); // `false` as a special case of no DOM component $$.fragment = create_fragment ? create_fragment($$.ctx) : false; if (options.target) { if (options.hydrate) { const nodes = children(options.target); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.l(nodes); nodes.forEach(detach); } else { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.c(); } if (options.intro) transition_in(component.$$.fragment); mount_component(component, options.target, options.anchor, options.customElement); flush(); } set_current_component(parent_component); } /** * Base class for Svelte components. Used when dev=false. */ class SvelteComponent { $destroy() { destroy_component(this, 1); this.$destroy = noop; } $on(type, callback) { const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); callbacks.push(callback); return () => { const index = callbacks.indexOf(callback); if (index !== -1) callbacks.splice(index, 1); }; } $set($$props) { if (this.$$set && !is_empty($$props)) { this.$$.skip_bound = true; this.$$set($$props); this.$$.skip_bound = false; } } } function dispatch_dev(type, detail) { document.dispatchEvent(custom_event(type, Object.assign({ version: '3.38.2' }, detail))); } function append_dev(target, node) { dispatch_dev('SvelteDOMInsert', { target, node }); append(target, node); } function insert_dev(target, node, anchor) { dispatch_dev('SvelteDOMInsert', { target, node, anchor }); insert(target, node, anchor); } function detach_dev(node) { dispatch_dev('SvelteDOMRemove', { node }); detach(node); } function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) { const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : []; if (has_prevent_default) modifiers.push('preventDefault'); if (has_stop_propagation) modifiers.push('stopPropagation'); dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers }); const dispose = listen(node, event, handler, options); return () => { dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers }); dispose(); }; } function attr_dev(node, attribute, value) { attr(node, attribute, value); if (value == null) dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute }); else dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value }); } function prop_dev(node, property, value) { node[property] = value; dispatch_dev('SvelteDOMSetProperty', { node, property, value }); } function set_data_dev(text, data) { data = '' + data; if (text.wholeText === data) return; dispatch_dev('SvelteDOMSetData', { node: text, data }); text.data = data; } function validate_each_argument(arg) { if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) { let msg = '{#each} only iterates over array-like objects.'; if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) { msg += ' You can use a spread to convert this iterable into an array.'; } throw new Error(msg); } } function validate_slots(name, slot, keys) { for (const slot_key of Object.keys(slot)) { if (!~keys.indexOf(slot_key)) { console.warn(`<${name}> received an unexpected slot "${slot_key}".`); } } } /** * Base class for Svelte components with some minor dev-enhancements. Used when dev=true. */ class SvelteComponentDev extends SvelteComponent { constructor(options) { if (!options || (!options.target && !options.$$inline)) { throw new Error("'target' is a required option"); } super(); } $destroy() { super.$destroy(); this.$destroy = () => { console.warn('Component was already destroyed'); // eslint-disable-line no-console }; } $capture_state() { } $inject_state() { } } const subscriber_queue = []; /** * Creates a `Readable` store that allows reading by subscription. * @param value initial value * @param {StartStopNotifier}start start and stop notifications for subscriptions */ function readable(value, start) { return { subscribe: writable(value, start).subscribe }; } /** * Create a `Writable` store that allows both updating and reading by subscription. * @param {*=}value initial value * @param {StartStopNotifier=}start start and stop notifications for subscriptions */ function writable(value, start = noop) { let stop; const subscribers = []; function set(new_value) { if (safe_not_equal(value, new_value)) { value = new_value; if (stop) { // store is ready const run_queue = !subscriber_queue.length; for (let i = 0; i < subscribers.length; i += 1) { const s = subscribers[i]; s[1](); subscriber_queue.push(s, value); } if (run_queue) { for (let i = 0; i < subscriber_queue.length; i += 2) { subscriber_queue[i][0](subscriber_queue[i + 1]); } subscriber_queue.length = 0; } } } } function update(fn) { set(fn(value)); } function subscribe(run, invalidate = noop) { const subscriber = [run, invalidate]; subscribers.push(subscriber); if (subscribers.length === 1) { stop = start(set) || noop; } run(value); return () => { const index = subscribers.indexOf(subscriber); if (index !== -1) { subscribers.splice(index, 1); } if (subscribers.length === 0) { stop(); stop = null; } }; } return { set, update, subscribe }; } function derived(stores, fn, initial_value) { const single = !Array.isArray(stores); const stores_array = single ? [stores] : stores; const auto = fn.length < 2; return readable(initial_value, (set) => { let inited = false; const values = []; let pending = 0; let cleanup = noop; const sync = () => { if (pending) { return; } cleanup(); const result = fn(single ? values[0] : values, set); if (auto) { set(result); } else { cleanup = is_function(result) ? result : noop; } }; const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => { values[i] = value; pending &= ~(1 << i); if (inited) { sync(); } }, () => { pending |= (1 << i); })); inited = true; sync(); return function stop() { run_all(unsubscribers); cleanup(); }; }); } const LOCATION = {}; const ROUTER = {}; /** * Adapted from https://github.com/reach/router/blob/b60e6dd781d5d3a4bdaaf4de665649c0f6a7e78d/src/lib/history.js * * https://github.com/reach/router/blob/master/LICENSE * */ function getLocation(source) { return { ...source.location, state: source.history.state, key: (source.history.state && source.history.state.key) || "initial" }; } function createHistory(source, options) { const listeners = []; let location = getLocation(source); return { get location() { return location; }, listen(listener) { listeners.push(listener); const popstateListener = () => { location = getLocation(source); listener({ location, action: "POP" }); }; source.addEventListener("popstate", popstateListener); return () => { source.removeEventListener("popstate", popstateListener); const index = listeners.indexOf(listener); listeners.splice(index, 1); }; }, navigate(to, { state, replace = false } = {}) { state = { ...state, key: Date.now() + "" }; // try...catch iOS Safari limits to 100 pushState calls try { if (replace) { source.history.replaceState(state, null, to); } else { source.history.pushState(state, null, to); } } catch (e) { source.location[replace ? "replace" : "assign"](to); } location = getLocation(source); listeners.forEach(listener => listener({ location, action: "PUSH" })); } }; } // Stores history entries in memory for testing or other platforms like Native function createMemorySource(initialPathname = "/") { let index = 0; const stack = [{ pathname: initialPathname, search: "" }]; const states = []; return { get location() { return stack[index]; }, addEventListener(name, fn) {}, removeEventListener(name, fn) {}, history: { get entries() { return stack; }, get index() { return index; }, get state() { return states[index]; }, pushState(state, _, uri) { const [pathname, search = ""] = uri.split("?"); index++; stack.push({ pathname, search }); states.push(state); }, replaceState(state, _, uri) { const [pathname, search = ""] = uri.split("?"); stack[index] = { pathname, search }; states[index] = state; } } }; } // Global history uses window.history as the source if available, // otherwise a memory history const canUseDOM = Boolean( typeof window !== "undefined" && window.document && window.document.createElement ); const globalHistory = createHistory(canUseDOM ? window : createMemorySource()); const { navigate } = globalHistory; /** * Adapted from https://github.com/reach/router/blob/b60e6dd781d5d3a4bdaaf4de665649c0f6a7e78d/src/lib/utils.js * * https://github.com/reach/router/blob/master/LICENSE * */ const paramRe = /^:(.+)/; const SEGMENT_POINTS = 4; const STATIC_POINTS = 3; const DYNAMIC_POINTS = 2; const SPLAT_PENALTY = 1; const ROOT_POINTS = 1; /** * Check if `string` starts with `search` * @param {string} string * @param {string} search * @return {boolean} */ function startsWith(string, search) { return string.substr(0, search.length) === search; } /** * Check if `segment` is a root segment * @param {string} segment * @return {boolean} */ function isRootSegment(segment) { return segment === ""; } /** * Check if `segment` is a dynamic segment * @param {string} segment * @return {boolean} */ function isDynamic(segment) { return paramRe.test(segment); } /** * Check if `segment` is a splat * @param {string} segment * @return {boolean} */ function isSplat(segment) { return segment[0] === "*"; } /** * Split up the URI into segments delimited by `/` * @param {string} uri * @return {string[]} */ function segmentize(uri) { return ( uri // Strip starting/ending `/` .replace(/(^\/+|\/+$)/g, "") .split("/") ); } /** * Strip `str` of potential start and end `/` * @param {string} str * @return {string} */ function stripSlashes(str) { return str.replace(/(^\/+|\/+$)/g, ""); } /** * Score a route depending on how its individual segments look * @param {object} route * @param {number} index * @return {object} */ function rankRoute(route, index) { const score = route.default ? 0 : segmentize(route.path).reduce((score, segment) => { score += SEGMENT_POINTS; if (isRootSegment(segment)) { score += ROOT_POINTS; } else if (isDynamic(segment)) { score += DYNAMIC_POINTS; } else if (isSplat(segment)) { score -= SEGMENT_POINTS + SPLAT_PENALTY; } else { score += STATIC_POINTS; } return score; }, 0); return { route, score, index }; } /** * Give a score to all routes and sort them on that * @param {object[]} routes * @return {object[]} */ function rankRoutes(routes) { return ( routes .map(rankRoute) // If two routes have the exact same score, we go by index instead .sort((a, b) => a.score < b.score ? 1 : a.score > b.score ? -1 : a.index - b.index ) ); } /** * Ranks and picks the best route to match. Each segment gets the highest * amount of points, then the type of segment gets an additional amount of * points where * * static > dynamic > splat > root * * This way we don't have to worry about the order of our routes, let the * computers do it. * * A route looks like this * * { path, default, value } * * And a returned match looks like: * * { route, params, uri } * * @param {object[]} routes * @param {string} uri * @return {?object} */ function pick(routes, uri) { let match; let default_; const [uriPathname] = uri.split("?"); const uriSegments = segmentize(uriPathname); const isRootUri = uriSegments[0] === ""; const ranked = rankRoutes(routes); for (let i = 0, l = ranked.length; i < l; i++) { const route = ranked[i].route; let missed = false; if (route.default) { default_ = { route, params: {}, uri }; continue; } const routeSegments = segmentize(route.path); const params = {}; const max = Math.max(uriSegments.length, routeSegments.length); let index = 0; for (; index < max; index++) { const routeSegment = routeSegments[index]; const uriSegment = uriSegments[index]; if (routeSegment !== undefined && isSplat(routeSegment)) { // Hit a splat, just grab the rest, and return a match // uri: /files/documents/work // route: /files/* or /files/*splatname const splatName = routeSegment === "*" ? "*" : routeSegment.slice(1); params[splatName] = uriSegments .slice(index) .map(decodeURIComponent) .join("/"); break; } if (uriSegment === undefined) { // URI is shorter than the route, no match // uri: /users // route: /users/:userId missed = true; break; } let dynamicMatch = paramRe.exec(routeSegment); if (dynamicMatch && !isRootUri) { const value = decodeURIComponent(uriSegment); params[dynamicMatch[1]] = value; } else if (routeSegment !== uriSegment) { // Current segments don't match, not dynamic, not splat, so no match // uri: /users/123/settings // route: /users/:id/profile missed = true; break; } } if (!missed) { match = { route, params, uri: "/" + uriSegments.slice(0, index).join("/") }; break; } } return match || default_ || null; } /** * Check if the `path` matches the `uri`. * @param {string} path * @param {string} uri * @return {?object} */ function match(route, uri) { return pick([route], uri); } /** * Add the query to the pathname if a query is given * @param {string} pathname * @param {string} [query] * @return {string} */ function addQuery(pathname, query) { return pathname + (query ? `?${query}` : ""); } /** * Resolve URIs as though every path is a directory, no files. Relative URIs * in the browser can feel awkward because not only can you be "in a directory", * you can be "at a file", too. For example: * * browserSpecResolve('foo', '/bar/') => /bar/foo * browserSpecResolve('foo', '/bar') => /foo * * But on the command line of a file system, it's not as complicated. You can't * `cd` from a file, only directories. This way, links have to know less about * their current path. To go deeper you can do this: * * * // instead of * * * Just like `cd`, if you want to go deeper from the command line, you do this: * * cd deeper * # not * cd $(pwd)/deeper * * By treating every path as a directory, linking to relative paths should * require less contextual information and (fingers crossed) be more intuitive. * @param {string} to * @param {string} base * @return {string} */ function resolve(to, base) { // /foo/bar, /baz/qux => /foo/bar if (startsWith(to, "/")) { return to; } const [toPathname, toQuery] = to.split("?"); const [basePathname] = base.split("?"); const toSegments = segmentize(toPathname); const baseSegments = segmentize(basePathname); // ?a=b, /users?b=c => /users?a=b if (toSegments[0] === "") { return addQuery(basePathname, toQuery); } // profile, /users/789 => /users/789/profile if (!startsWith(toSegments[0], ".")) { const pathname = baseSegments.concat(toSegments).join("/"); return addQuery((basePathname === "/" ? "" : "/") + pathname, toQuery); } // ./ , /users/123 => /users/123 // ../ , /users/123 => /users // ../.. , /users/123 => / // ../../one, /a/b/c/d => /a/b/one // .././one , /a/b/c/d => /a/b/c/one const allSegments = baseSegments.concat(toSegments); const segments = []; allSegments.forEach(segment => { if (segment === "..") { segments.pop(); } else if (segment !== ".") { segments.push(segment); } }); return addQuery("/" + segments.join("/"), toQuery); } /** * Combines the `basepath` and the `path` into one path. * @param {string} basepath * @param {string} path */ function combinePaths(basepath, path) { return `${stripSlashes( path === "/" ? basepath : `${stripSlashes(basepath)}/${stripSlashes(path)}` )}/`; } /** * Decides whether a given `event` should result in a navigation or not. * @param {object} event */ function shouldNavigate(event) { return ( !event.defaultPrevented && event.button === 0 && !(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) ); } /* node_modules/svelte-routing/src/Router.svelte generated by Svelte v3.38.2 */ function create_fragment$d(ctx) { let current; const default_slot_template = /*#slots*/ ctx[9].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[8], null); const block = { c: function create() { if (default_slot) default_slot.c(); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { if (default_slot) { default_slot.m(target, anchor); } current = true; }, p: function update(ctx, [dirty]) { if (default_slot) { if (default_slot.p && (!current || dirty & /*$$scope*/ 256)) { update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[8], dirty, null, null); } } }, i: function intro(local) { if (current) return; transition_in(default_slot, local); current = true; }, o: function outro(local) { transition_out(default_slot, local); current = false; }, d: function destroy(detaching) { if (default_slot) default_slot.d(detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$d.name, type: "component", source: "", ctx }); return block; } function instance$d($$self, $$props, $$invalidate) { let $base; let $location; let $routes; let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Router", slots, ['default']); let { basepath = "/" } = $$props; let { url = null } = $$props; const locationContext = getContext(LOCATION); const routerContext = getContext(ROUTER); const routes = writable([]); validate_store(routes, "routes"); component_subscribe($$self, routes, value => $$invalidate(7, $routes = value)); const activeRoute = writable(null); let hasActiveRoute = false; // Used in SSR to synchronously set that a Route is active. // If locationContext is not set, this is the topmost Router in the tree. // If the `url` prop is given we force the location to it. const location = locationContext || writable(url ? { pathname: url } : globalHistory.location); validate_store(location, "location"); component_subscribe($$self, location, value => $$invalidate(6, $location = value)); // If routerContext is set, the routerBase of the parent Router // will be the base for this Router's descendants. // If routerContext is not set, the path and resolved uri will both // have the value of the basepath prop. const base = routerContext ? routerContext.routerBase : writable({ path: basepath, uri: basepath }); validate_store(base, "base"); component_subscribe($$self, base, value => $$invalidate(5, $base = value)); const routerBase = derived([base, activeRoute], ([base, activeRoute]) => { // If there is no activeRoute, the routerBase will be identical to the base. if (activeRoute === null) { return base; } const { path: basepath } = base; const { route, uri } = activeRoute; // Remove the potential /* or /*splatname from // the end of the child Routes relative paths. const path = route.default ? basepath : route.path.replace(/\*.*$/, ""); return { path, uri }; }); function registerRoute(route) { const { path: basepath } = $base; let { path } = route; // We store the original path in the _path property so we can reuse // it when the basepath changes. The only thing that matters is that // the route reference is intact, so mutation is fine. route._path = path; route.path = combinePaths(basepath, path); if (typeof window === "undefined") { // In SSR we should set the activeRoute immediately if it is a match. // If there are more Routes being registered after a match is found, // we just skip them. if (hasActiveRoute) { return; } const matchingRoute = match(route, $location.pathname); if (matchingRoute) { activeRoute.set(matchingRoute); hasActiveRoute = true; } } else { routes.update(rs => { rs.push(route); return rs; }); } } function unregisterRoute(route) { routes.update(rs => { const index = rs.indexOf(route); rs.splice(index, 1); return rs; }); } if (!locationContext) { // The topmost Router in the tree is responsible for updating // the location store and supplying it through context. onMount(() => { const unlisten = globalHistory.listen(history => { location.set(history.location); }); return unlisten; }); setContext(LOCATION, location); } setContext(ROUTER, { activeRoute, base, routerBase, registerRoute, unregisterRoute }); const writable_props = ["basepath", "url"]; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); $$self.$$set = $$props => { if ("basepath" in $$props) $$invalidate(3, basepath = $$props.basepath); if ("url" in $$props) $$invalidate(4, url = $$props.url); if ("$$scope" in $$props) $$invalidate(8, $$scope = $$props.$$scope); }; $$self.$capture_state = () => ({ getContext, setContext, onMount, writable, derived, LOCATION, ROUTER, globalHistory, pick, match, stripSlashes, combinePaths, basepath, url, locationContext, routerContext, routes, activeRoute, hasActiveRoute, location, base, routerBase, registerRoute, unregisterRoute, $base, $location, $routes }); $$self.$inject_state = $$props => { if ("basepath" in $$props) $$invalidate(3, basepath = $$props.basepath); if ("url" in $$props) $$invalidate(4, url = $$props.url); if ("hasActiveRoute" in $$props) hasActiveRoute = $$props.hasActiveRoute; }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } $$self.$$.update = () => { if ($$self.$$.dirty & /*$base*/ 32) { // This reactive statement will update all the Routes' path when // the basepath changes. { const { path: basepath } = $base; routes.update(rs => { rs.forEach(r => r.path = combinePaths(basepath, r._path)); return rs; }); } } if ($$self.$$.dirty & /*$routes, $location*/ 192) { // This reactive statement will be run when the Router is created // when there are no Routes and then again the following tick, so it // will not find an active Route in SSR and in the browser it will only // pick an active Route after all Routes have been registered. { const bestMatch = pick($routes, $location.pathname); activeRoute.set(bestMatch); } } }; return [ routes, location, base, basepath, url, $base, $location, $routes, $$scope, slots ]; } class Router extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$d, create_fragment$d, safe_not_equal, { basepath: 3, url: 4 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Router", options, id: create_fragment$d.name }); } get basepath() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set basepath(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get url() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set url(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } /* node_modules/svelte-routing/src/Route.svelte generated by Svelte v3.38.2 */ const get_default_slot_changes = dirty => ({ params: dirty & /*routeParams*/ 4, location: dirty & /*$location*/ 16 }); const get_default_slot_context = ctx => ({ params: /*routeParams*/ ctx[2], location: /*$location*/ ctx[4] }); // (40:0) {#if $activeRoute !== null && $activeRoute.route === route} function create_if_block$5(ctx) { let current_block_type_index; let if_block; let if_block_anchor; let current; const if_block_creators = [create_if_block_1$5, create_else_block$3]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*component*/ ctx[0] !== null) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); const block = { c: function create() { if_block.c(); if_block_anchor = empty(); }, m: function mount(target, anchor) { if_blocks[current_block_type_index].m(target, anchor); insert_dev(target, if_block_anchor, anchor); current = true; }, p: function update(ctx, dirty) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } else { if_block.p(ctx, dirty); } transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } }, i: function intro(local) { if (current) return; transition_in(if_block); current = true; }, o: function outro(local) { transition_out(if_block); current = false; }, d: function destroy(detaching) { if_blocks[current_block_type_index].d(detaching); if (detaching) detach_dev(if_block_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block$5.name, type: "if", source: "(40:0) {#if $activeRoute !== null && $activeRoute.route === route}", ctx }); return block; } // (43:2) {:else} function create_else_block$3(ctx) { let current; const default_slot_template = /*#slots*/ ctx[10].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[9], get_default_slot_context); const block = { c: function create() { if (default_slot) default_slot.c(); }, m: function mount(target, anchor) { if (default_slot) { default_slot.m(target, anchor); } current = true; }, p: function update(ctx, dirty) { if (default_slot) { if (default_slot.p && (!current || dirty & /*$$scope, routeParams, $location*/ 532)) { update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[9], dirty, get_default_slot_changes, get_default_slot_context); } } }, i: function intro(local) { if (current) return; transition_in(default_slot, local); current = true; }, o: function outro(local) { transition_out(default_slot, local); current = false; }, d: function destroy(detaching) { if (default_slot) default_slot.d(detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_else_block$3.name, type: "else", source: "(43:2) {:else}", ctx }); return block; } // (41:2) {#if component !== null} function create_if_block_1$5(ctx) { let switch_instance; let switch_instance_anchor; let current; const switch_instance_spread_levels = [ { location: /*$location*/ ctx[4] }, /*routeParams*/ ctx[2], /*routeProps*/ ctx[3] ]; var switch_value = /*component*/ ctx[0]; function switch_props(ctx) { let switch_instance_props = {}; for (let i = 0; i < switch_instance_spread_levels.length; i += 1) { switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]); } return { props: switch_instance_props, $$inline: true }; } if (switch_value) { switch_instance = new switch_value(switch_props()); } const block = { c: function create() { if (switch_instance) create_component(switch_instance.$$.fragment); switch_instance_anchor = empty(); }, m: function mount(target, anchor) { if (switch_instance) { mount_component(switch_instance, target, anchor); } insert_dev(target, switch_instance_anchor, anchor); current = true; }, p: function update(ctx, dirty) { const switch_instance_changes = (dirty & /*$location, routeParams, routeProps*/ 28) ? get_spread_update(switch_instance_spread_levels, [ dirty & /*$location*/ 16 && { location: /*$location*/ ctx[4] }, dirty & /*routeParams*/ 4 && get_spread_object(/*routeParams*/ ctx[2]), dirty & /*routeProps*/ 8 && get_spread_object(/*routeProps*/ ctx[3]) ]) : {}; if (switch_value !== (switch_value = /*component*/ ctx[0])) { if (switch_instance) { group_outros(); const old_component = switch_instance; transition_out(old_component.$$.fragment, 1, 0, () => { destroy_component(old_component, 1); }); check_outros(); } if (switch_value) { switch_instance = new switch_value(switch_props()); create_component(switch_instance.$$.fragment); transition_in(switch_instance.$$.fragment, 1); mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor); } else { switch_instance = null; } } else if (switch_value) { switch_instance.$set(switch_instance_changes); } }, i: function intro(local) { if (current) return; if (switch_instance) transition_in(switch_instance.$$.fragment, local); current = true; }, o: function outro(local) { if (switch_instance) transition_out(switch_instance.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(switch_instance_anchor); if (switch_instance) destroy_component(switch_instance, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1$5.name, type: "if", source: "(41:2) {#if component !== null}", ctx }); return block; } function create_fragment$c(ctx) { let if_block_anchor; let current; let if_block = /*$activeRoute*/ ctx[1] !== null && /*$activeRoute*/ ctx[1].route === /*route*/ ctx[7] && create_if_block$5(ctx); const block = { c: function create() { if (if_block) if_block.c(); if_block_anchor = empty(); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { if (if_block) if_block.m(target, anchor); insert_dev(target, if_block_anchor, anchor); current = true; }, p: function update(ctx, [dirty]) { if (/*$activeRoute*/ ctx[1] !== null && /*$activeRoute*/ ctx[1].route === /*route*/ ctx[7]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*$activeRoute*/ 2) { transition_in(if_block, 1); } } else { if_block = create_if_block$5(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i: function intro(local) { if (current) return; transition_in(if_block); current = true; }, o: function outro(local) { transition_out(if_block); current = false; }, d: function destroy(detaching) { if (if_block) if_block.d(detaching); if (detaching) detach_dev(if_block_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$c.name, type: "component", source: "", ctx }); return block; } function instance$c($$self, $$props, $$invalidate) { let $activeRoute; let $location; let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Route", slots, ['default']); let { path = "" } = $$props; let { component = null } = $$props; const { registerRoute, unregisterRoute, activeRoute } = getContext(ROUTER); validate_store(activeRoute, "activeRoute"); component_subscribe($$self, activeRoute, value => $$invalidate(1, $activeRoute = value)); const location = getContext(LOCATION); validate_store(location, "location"); component_subscribe($$self, location, value => $$invalidate(4, $location = value)); const route = { path, // If no path prop is given, this Route will act as the default Route // that is rendered if no other Route in the Router is a match. default: path === "" }; let routeParams = {}; let routeProps = {}; registerRoute(route); // There is no need to unregister Routes in SSR since it will all be // thrown away anyway. if (typeof window !== "undefined") { onDestroy(() => { unregisterRoute(route); }); } $$self.$$set = $$new_props => { $$invalidate(13, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props))); if ("path" in $$new_props) $$invalidate(8, path = $$new_props.path); if ("component" in $$new_props) $$invalidate(0, component = $$new_props.component); if ("$$scope" in $$new_props) $$invalidate(9, $$scope = $$new_props.$$scope); }; $$self.$capture_state = () => ({ getContext, onDestroy, ROUTER, LOCATION, path, component, registerRoute, unregisterRoute, activeRoute, location, route, routeParams, routeProps, $activeRoute, $location }); $$self.$inject_state = $$new_props => { $$invalidate(13, $$props = assign(assign({}, $$props), $$new_props)); if ("path" in $$props) $$invalidate(8, path = $$new_props.path); if ("component" in $$props) $$invalidate(0, component = $$new_props.component); if ("routeParams" in $$props) $$invalidate(2, routeParams = $$new_props.routeParams); if ("routeProps" in $$props) $$invalidate(3, routeProps = $$new_props.routeProps); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } $$self.$$.update = () => { if ($$self.$$.dirty & /*$activeRoute*/ 2) { if ($activeRoute && $activeRoute.route === route) { $$invalidate(2, routeParams = $activeRoute.params); } } { const { path, component, ...rest } = $$props; $$invalidate(3, routeProps = rest); } }; $$props = exclude_internal_props($$props); return [ component, $activeRoute, routeParams, routeProps, $location, activeRoute, location, route, path, $$scope, slots ]; } class Route extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$c, create_fragment$c, safe_not_equal, { path: 8, component: 0 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Route", options, id: create_fragment$c.name }); } get path() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set path(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get component() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set component(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } /* node_modules/svelte-routing/src/Link.svelte generated by Svelte v3.38.2 */ const file$a = "node_modules/svelte-routing/src/Link.svelte"; function create_fragment$b(ctx) { let a; let current; let mounted; let dispose; const default_slot_template = /*#slots*/ ctx[16].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[15], null); let a_levels = [ { href: /*href*/ ctx[0] }, { "aria-current": /*ariaCurrent*/ ctx[2] }, /*props*/ ctx[1], /*$$restProps*/ ctx[6] ]; let a_data = {}; for (let i = 0; i < a_levels.length; i += 1) { a_data = assign(a_data, a_levels[i]); } const block = { c: function create() { a = element("a"); if (default_slot) default_slot.c(); set_attributes(a, a_data); add_location(a, file$a, 40, 0, 1249); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, a, anchor); if (default_slot) { default_slot.m(a, null); } current = true; if (!mounted) { dispose = listen_dev(a, "click", /*onClick*/ ctx[5], false, false, false); mounted = true; } }, p: function update(ctx, [dirty]) { if (default_slot) { if (default_slot.p && (!current || dirty & /*$$scope*/ 32768)) { update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[15], dirty, null, null); } } set_attributes(a, a_data = get_spread_update(a_levels, [ (!current || dirty & /*href*/ 1) && { href: /*href*/ ctx[0] }, (!current || dirty & /*ariaCurrent*/ 4) && { "aria-current": /*ariaCurrent*/ ctx[2] }, dirty & /*props*/ 2 && /*props*/ ctx[1], dirty & /*$$restProps*/ 64 && /*$$restProps*/ ctx[6] ])); }, i: function intro(local) { if (current) return; transition_in(default_slot, local); current = true; }, o: function outro(local) { transition_out(default_slot, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(a); if (default_slot) default_slot.d(detaching); mounted = false; dispose(); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$b.name, type: "component", source: "", ctx }); return block; } function instance$b($$self, $$props, $$invalidate) { let ariaCurrent; const omit_props_names = ["to","replace","state","getProps"]; let $$restProps = compute_rest_props($$props, omit_props_names); let $base; let $location; let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Link", slots, ['default']); let { to = "#" } = $$props; let { replace = false } = $$props; let { state = {} } = $$props; let { getProps = () => ({}) } = $$props; const { base } = getContext(ROUTER); validate_store(base, "base"); component_subscribe($$self, base, value => $$invalidate(13, $base = value)); const location = getContext(LOCATION); validate_store(location, "location"); component_subscribe($$self, location, value => $$invalidate(14, $location = value)); const dispatch = createEventDispatcher(); let href, isPartiallyCurrent, isCurrent, props; function onClick(event) { dispatch("click", event); if (shouldNavigate(event)) { event.preventDefault(); // Don't push another entry to the history stack when the user // clicks on a Link to the page they are currently on. const shouldReplace = $location.pathname === href || replace; navigate(href, { state, replace: shouldReplace }); } } $$self.$$set = $$new_props => { $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)); $$invalidate(6, $$restProps = compute_rest_props($$props, omit_props_names)); if ("to" in $$new_props) $$invalidate(7, to = $$new_props.to); if ("replace" in $$new_props) $$invalidate(8, replace = $$new_props.replace); if ("state" in $$new_props) $$invalidate(9, state = $$new_props.state); if ("getProps" in $$new_props) $$invalidate(10, getProps = $$new_props.getProps); if ("$$scope" in $$new_props) $$invalidate(15, $$scope = $$new_props.$$scope); }; $$self.$capture_state = () => ({ getContext, createEventDispatcher, ROUTER, LOCATION, navigate, startsWith, resolve, shouldNavigate, to, replace, state, getProps, base, location, dispatch, href, isPartiallyCurrent, isCurrent, props, onClick, $base, $location, ariaCurrent }); $$self.$inject_state = $$new_props => { if ("to" in $$props) $$invalidate(7, to = $$new_props.to); if ("replace" in $$props) $$invalidate(8, replace = $$new_props.replace); if ("state" in $$props) $$invalidate(9, state = $$new_props.state); if ("getProps" in $$props) $$invalidate(10, getProps = $$new_props.getProps); if ("href" in $$props) $$invalidate(0, href = $$new_props.href); if ("isPartiallyCurrent" in $$props) $$invalidate(11, isPartiallyCurrent = $$new_props.isPartiallyCurrent); if ("isCurrent" in $$props) $$invalidate(12, isCurrent = $$new_props.isCurrent); if ("props" in $$props) $$invalidate(1, props = $$new_props.props); if ("ariaCurrent" in $$props) $$invalidate(2, ariaCurrent = $$new_props.ariaCurrent); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } $$self.$$.update = () => { if ($$self.$$.dirty & /*to, $base*/ 8320) { $$invalidate(0, href = to === "/" ? $base.uri : resolve(to, $base.uri)); } if ($$self.$$.dirty & /*$location, href*/ 16385) { $$invalidate(11, isPartiallyCurrent = startsWith($location.pathname, href)); } if ($$self.$$.dirty & /*href, $location*/ 16385) { $$invalidate(12, isCurrent = href === $location.pathname); } if ($$self.$$.dirty & /*isCurrent*/ 4096) { $$invalidate(2, ariaCurrent = isCurrent ? "page" : undefined); } if ($$self.$$.dirty & /*getProps, $location, href, isPartiallyCurrent, isCurrent*/ 23553) { $$invalidate(1, props = getProps({ location: $location, href, isPartiallyCurrent, isCurrent })); } }; return [ href, props, ariaCurrent, base, location, onClick, $$restProps, to, replace, state, getProps, isPartiallyCurrent, isCurrent, $base, $location, $$scope, slots ]; } class Link extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$b, create_fragment$b, safe_not_equal, { to: 7, replace: 8, state: 9, getProps: 10 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Link", options, id: create_fragment$b.name }); } get to() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set to(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get replace() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set replace(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get state() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set state(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get getProps() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set getProps(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } const storedToken = localStorage.getItem("apiToken"); const token$1 = writable(storedToken); token$1.subscribe(value => { localStorage.setItem("apiToken", value); }); /* src/Navbar.svelte generated by Svelte v3.38.2 */ const file$9 = "src/Navbar.svelte"; // (19:8) function create_default_slot_5$1(ctx) { let t; const block = { c: function create() { t = text("Shioriko"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_5$1.name, type: "slot", source: "(19:8) ", ctx }); return block; } // (37:12) function create_default_slot_4$1(ctx) { let t; const block = { c: function create() { t = text("Posts"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_4$1.name, type: "slot", source: "(37:12) ", ctx }); return block; } // (38:12) {#if loggedIn} function create_if_block_1$4(ctx) { let link; let current; link = new Link({ props: { class: "navbar-item", to: "/upload", $$slots: { default: [create_default_slot_3$1] }, $$scope: { ctx } }, $$inline: true }); const block = { c: function create() { create_component(link.$$.fragment); }, m: function mount(target, anchor) { mount_component(link, target, anchor); current = true; }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { destroy_component(link, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1$4.name, type: "if", source: "(38:12) {#if loggedIn}", ctx }); return block; } // (39:16) function create_default_slot_3$1(ctx) { let t; const block = { c: function create() { t = text("Upload"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_3$1.name, type: "slot", source: "(39:16) ", ctx }); return block; } // (52:12) {:else} function create_else_block$2(ctx) { let div1; let div0; let link0; let t; let link1; let current; link0 = new Link({ props: { to: "/auth/register", class: "button is-primary", $$slots: { default: [create_default_slot_2$1] }, $$scope: { ctx } }, $$inline: true }); link1 = new Link({ props: { to: "/auth/login", class: "button is-light", $$slots: { default: [create_default_slot_1$1] }, $$scope: { ctx } }, $$inline: true }); const block = { c: function create() { div1 = element("div"); div0 = element("div"); create_component(link0.$$.fragment); t = space(); create_component(link1.$$.fragment); attr_dev(div0, "class", "buttons"); add_location(div0, file$9, 53, 20, 1515); attr_dev(div1, "class", "navbar-item"); add_location(div1, file$9, 52, 16, 1469); }, m: function mount(target, anchor) { insert_dev(target, div1, anchor); append_dev(div1, div0); mount_component(link0, div0, null); append_dev(div0, t); mount_component(link1, div0, null); current = true; }, i: function intro(local) { if (current) return; transition_in(link0.$$.fragment, local); transition_in(link1.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link0.$$.fragment, local); transition_out(link1.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(div1); destroy_component(link0); destroy_component(link1); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_else_block$2.name, type: "else", source: "(52:12) {:else}", ctx }); return block; } // (44:12) {#if loggedIn} function create_if_block$4(ctx) { let div1; let div0; let link; let current; link = new Link({ props: { to: "/auth/logout", class: "button is-light", $$slots: { default: [create_default_slot$3] }, $$scope: { ctx } }, $$inline: true }); const block = { c: function create() { div1 = element("div"); div0 = element("div"); create_component(link.$$.fragment); attr_dev(div0, "class", "buttons"); add_location(div0, file$9, 45, 20, 1220); attr_dev(div1, "class", "navbar-item"); add_location(div1, file$9, 44, 16, 1174); }, m: function mount(target, anchor) { insert_dev(target, div1, anchor); append_dev(div1, div0); mount_component(link, div0, null); current = true; }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(div1); destroy_component(link); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block$4.name, type: "if", source: "(44:12) {#if loggedIn}", ctx }); return block; } // (55:24) function create_default_slot_2$1(ctx) { let strong; const block = { c: function create() { strong = element("strong"); strong.textContent = "Register"; add_location(strong, file$9, 55, 28, 1642); }, m: function mount(target, anchor) { insert_dev(target, strong, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(strong); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_2$1.name, type: "slot", source: "(55:24) ", ctx }); return block; } // (58:24) function create_default_slot_1$1(ctx) { let t; const block = { c: function create() { t = text("Log in"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_1$1.name, type: "slot", source: "(58:24) ", ctx }); return block; } // (47:24) function create_default_slot$3(ctx) { let t; const block = { c: function create() { t = text("Log out"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot$3.name, type: "slot", source: "(47:24) ", ctx }); return block; } function create_fragment$a(ctx) { let nav; let div0; let link0; let t0; let a; let span0; let t1; let span1; let t2; let span2; let t3; let div3; let div1; let link1; let t4; let t5; let div2; let current_block_type_index; let if_block1; let current; let mounted; let dispose; link0 = new Link({ props: { class: "navbar-item", to: "/", $$slots: { default: [create_default_slot_5$1] }, $$scope: { ctx } }, $$inline: true }); link1 = new Link({ props: { class: "navbar-item", to: "/posts", $$slots: { default: [create_default_slot_4$1] }, $$scope: { ctx } }, $$inline: true }); let if_block0 = /*loggedIn*/ ctx[1] && create_if_block_1$4(ctx); const if_block_creators = [create_if_block$4, create_else_block$2]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*loggedIn*/ ctx[1]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); const block = { c: function create() { nav = element("nav"); div0 = element("div"); create_component(link0.$$.fragment); t0 = space(); a = element("a"); span0 = element("span"); t1 = space(); span1 = element("span"); t2 = space(); span2 = element("span"); t3 = space(); div3 = element("div"); div1 = element("div"); create_component(link1.$$.fragment); t4 = space(); if (if_block0) if_block0.c(); t5 = space(); div2 = element("div"); if_block1.c(); attr_dev(span0, "aria-hidden", "true"); add_location(span0, file$9, 28, 12, 678); attr_dev(span1, "aria-hidden", "true"); add_location(span1, file$9, 29, 12, 718); attr_dev(span2, "aria-hidden", "true"); add_location(span2, file$9, 30, 12, 758); attr_dev(a, "href", "#"); attr_dev(a, "role", "button"); attr_dev(a, "class", "navbar-burger"); attr_dev(a, "aria-label", "menu"); attr_dev(a, "aria-expanded", "false"); add_location(a, file$9, 20, 8, 472); attr_dev(div0, "class", "navbar-brand"); add_location(div0, file$9, 17, 4, 379); attr_dev(div1, "class", "navbar-start"); add_location(div1, file$9, 35, 8, 878); attr_dev(div2, "class", "navbar-end"); add_location(div2, file$9, 42, 8, 1106); attr_dev(div3, "class", "navbar-menu"); toggle_class(div3, "is-active", /*menu_shown*/ ctx[0]); add_location(div3, file$9, 34, 4, 815); attr_dev(nav, "class", "navbar"); attr_dev(nav, "role", "navigation"); attr_dev(nav, "aria-label", "main navigation"); add_location(nav, file$9, 16, 0, 307); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, nav, anchor); append_dev(nav, div0); mount_component(link0, div0, null); append_dev(div0, t0); append_dev(div0, a); append_dev(a, span0); append_dev(a, t1); append_dev(a, span1); append_dev(a, t2); append_dev(a, span2); append_dev(nav, t3); append_dev(nav, div3); append_dev(div3, div1); mount_component(link1, div1, null); append_dev(div1, t4); if (if_block0) if_block0.m(div1, null); append_dev(div3, t5); append_dev(div3, div2); if_blocks[current_block_type_index].m(div2, null); current = true; if (!mounted) { dispose = listen_dev(a, "click", /*toggleMenu*/ ctx[2], false, false, false); mounted = true; } }, p: function update(ctx, [dirty]) { const link0_changes = {}; if (dirty & /*$$scope*/ 8) { link0_changes.$$scope = { dirty, ctx }; } link0.$set(link0_changes); const link1_changes = {}; if (dirty & /*$$scope*/ 8) { link1_changes.$$scope = { dirty, ctx }; } link1.$set(link1_changes); if (/*loggedIn*/ ctx[1]) { if (if_block0) { if (dirty & /*loggedIn*/ 2) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_1$4(ctx); if_block0.c(); transition_in(if_block0, 1); if_block0.m(div1, null); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index !== previous_block_index) { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block1 = if_blocks[current_block_type_index]; if (!if_block1) { if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block1.c(); } transition_in(if_block1, 1); if_block1.m(div2, null); } if (dirty & /*menu_shown*/ 1) { toggle_class(div3, "is-active", /*menu_shown*/ ctx[0]); } }, i: function intro(local) { if (current) return; transition_in(link0.$$.fragment, local); transition_in(link1.$$.fragment, local); transition_in(if_block0); transition_in(if_block1); current = true; }, o: function outro(local) { transition_out(link0.$$.fragment, local); transition_out(link1.$$.fragment, local); transition_out(if_block0); transition_out(if_block1); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(nav); destroy_component(link0); destroy_component(link1); if (if_block0) if_block0.d(); if_blocks[current_block_type_index].d(); mounted = false; dispose(); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$a.name, type: "component", source: "", ctx }); return block; } function instance$a($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Navbar", slots, []); let menu_shown = false; let loggedIn = false; token$1.subscribe(value => { $$invalidate(1, loggedIn = value !== ""); }); const toggleMenu = () => { $$invalidate(0, menu_shown = !menu_shown); }; const writable_props = []; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); $$self.$capture_state = () => ({ Link, token: token$1, menu_shown, loggedIn, toggleMenu }); $$self.$inject_state = $$props => { if ("menu_shown" in $$props) $$invalidate(0, menu_shown = $$props.menu_shown); if ("loggedIn" in $$props) $$invalidate(1, loggedIn = $$props.loggedIn); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [menu_shown, loggedIn, toggleMenu]; } class Navbar extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$a, create_fragment$a, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Navbar", options, id: create_fragment$a.name }); } } /* src/routes/Home.svelte generated by Svelte v3.38.2 */ const file$8 = "src/routes/Home.svelte"; function create_fragment$9(ctx) { let section; let div; let p0; let t1; let p1; const block = { c: function create() { section = element("section"); div = element("div"); p0 = element("p"); p0.textContent = "Shioriko"; t1 = space(); p1 = element("p"); p1.textContent = "Booru-style gallery written in Go and Svelte"; attr_dev(p0, "class", "title"); add_location(p0, file$8, 5, 4, 94); attr_dev(p1, "class", "subtitle"); add_location(p1, file$8, 6, 4, 128); attr_dev(div, "class", "hero-body"); add_location(div, file$8, 4, 2, 66); attr_dev(section, "class", "hero is-primary is-medium"); add_location(section, file$8, 3, 0, 20); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, section, anchor); append_dev(section, div); append_dev(div, p0); append_dev(div, t1); append_dev(div, p1); }, p: noop, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(section); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$9.name, type: "component", source: "", ctx }); return block; } function instance$9($$self, $$props) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Home", slots, []); const writable_props = []; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); return []; } class Home extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$9, create_fragment$9, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Home", options, id: create_fragment$9.name }); } } var bind = function bind(fn, thisArg) { return function wrap() { var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { args[i] = arguments[i]; } return fn.apply(thisArg, args); }; }; /*global toString:true*/ // utils is a library of generic helper functions non-specific to axios var toString = Object.prototype.toString; /** * Determine if a value is an Array * * @param {Object} val The value to test * @returns {boolean} True if value is an Array, otherwise false */ function isArray(val) { return toString.call(val) === '[object Array]'; } /** * Determine if a value is undefined * * @param {Object} val The value to test * @returns {boolean} True if the value is undefined, otherwise false */ function isUndefined(val) { return typeof val === 'undefined'; } /** * Determine if a value is a Buffer * * @param {Object} val The value to test * @returns {boolean} True if value is a Buffer, otherwise false */ function isBuffer(val) { return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); } /** * Determine if a value is an ArrayBuffer * * @param {Object} val The value to test * @returns {boolean} True if value is an ArrayBuffer, otherwise false */ function isArrayBuffer(val) { return toString.call(val) === '[object ArrayBuffer]'; } /** * Determine if a value is a FormData * * @param {Object} val The value to test * @returns {boolean} True if value is an FormData, otherwise false */ function isFormData(val) { return (typeof FormData !== 'undefined') && (val instanceof FormData); } /** * Determine if a value is a view on an ArrayBuffer * * @param {Object} val The value to test * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false */ function isArrayBufferView(val) { var result; if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { result = ArrayBuffer.isView(val); } else { result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); } return result; } /** * Determine if a value is a String * * @param {Object} val The value to test * @returns {boolean} True if value is a String, otherwise false */ function isString(val) { return typeof val === 'string'; } /** * Determine if a value is a Number * * @param {Object} val The value to test * @returns {boolean} True if value is a Number, otherwise false */ function isNumber(val) { return typeof val === 'number'; } /** * Determine if a value is an Object * * @param {Object} val The value to test * @returns {boolean} True if value is an Object, otherwise false */ function isObject(val) { return val !== null && typeof val === 'object'; } /** * Determine if a value is a plain Object * * @param {Object} val The value to test * @return {boolean} True if value is a plain Object, otherwise false */ function isPlainObject(val) { if (toString.call(val) !== '[object Object]') { return false; } var prototype = Object.getPrototypeOf(val); return prototype === null || prototype === Object.prototype; } /** * Determine if a value is a Date * * @param {Object} val The value to test * @returns {boolean} True if value is a Date, otherwise false */ function isDate(val) { return toString.call(val) === '[object Date]'; } /** * Determine if a value is a File * * @param {Object} val The value to test * @returns {boolean} True if value is a File, otherwise false */ function isFile(val) { return toString.call(val) === '[object File]'; } /** * Determine if a value is a Blob * * @param {Object} val The value to test * @returns {boolean} True if value is a Blob, otherwise false */ function isBlob(val) { return toString.call(val) === '[object Blob]'; } /** * Determine if a value is a Function * * @param {Object} val The value to test * @returns {boolean} True if value is a Function, otherwise false */ function isFunction(val) { return toString.call(val) === '[object Function]'; } /** * Determine if a value is a Stream * * @param {Object} val The value to test * @returns {boolean} True if value is a Stream, otherwise false */ function isStream(val) { return isObject(val) && isFunction(val.pipe); } /** * Determine if a value is a URLSearchParams object * * @param {Object} val The value to test * @returns {boolean} True if value is a URLSearchParams object, otherwise false */ function isURLSearchParams(val) { return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; } /** * Trim excess whitespace off the beginning and end of a string * * @param {String} str The String to trim * @returns {String} The String freed of excess whitespace */ function trim(str) { return str.replace(/^\s*/, '').replace(/\s*$/, ''); } /** * Determine if we're running in a standard browser environment * * This allows axios to run in a web worker, and react-native. * Both environments support XMLHttpRequest, but not fully standard globals. * * web workers: * typeof window -> undefined * typeof document -> undefined * * react-native: * navigator.product -> 'ReactNative' * nativescript * navigator.product -> 'NativeScript' or 'NS' */ function isStandardBrowserEnv() { if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || navigator.product === 'NativeScript' || navigator.product === 'NS')) { return false; } return ( typeof window !== 'undefined' && typeof document !== 'undefined' ); } /** * Iterate over an Array or an Object invoking a function for each item. * * If `obj` is an Array callback will be called passing * the value, index, and complete array for each item. * * If 'obj' is an Object callback will be called passing * the value, key, and complete object for each property. * * @param {Object|Array} obj The object to iterate * @param {Function} fn The callback to invoke for each item */ function forEach(obj, fn) { // Don't bother if no value provided if (obj === null || typeof obj === 'undefined') { return; } // Force an array if not already something iterable if (typeof obj !== 'object') { /*eslint no-param-reassign:0*/ obj = [obj]; } if (isArray(obj)) { // Iterate over array values for (var i = 0, l = obj.length; i < l; i++) { fn.call(null, obj[i], i, obj); } } else { // Iterate over object keys for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { fn.call(null, obj[key], key, obj); } } } } /** * Accepts varargs expecting each argument to be an object, then * immutably merges the properties of each object and returns result. * * When multiple objects contain the same key the later object in * the arguments list will take precedence. * * Example: * * ```js * var result = merge({foo: 123}, {foo: 456}); * console.log(result.foo); // outputs 456 * ``` * * @param {Object} obj1 Object to merge * @returns {Object} Result of all merge properties */ function merge(/* obj1, obj2, obj3, ... */) { var result = {}; function assignValue(val, key) { if (isPlainObject(result[key]) && isPlainObject(val)) { result[key] = merge(result[key], val); } else if (isPlainObject(val)) { result[key] = merge({}, val); } else if (isArray(val)) { result[key] = val.slice(); } else { result[key] = val; } } for (var i = 0, l = arguments.length; i < l; i++) { forEach(arguments[i], assignValue); } return result; } /** * Extends object a by mutably adding to it the properties of object b. * * @param {Object} a The object to be extended * @param {Object} b The object to copy properties from * @param {Object} thisArg The object to bind function to * @return {Object} The resulting value of object a */ function extend(a, b, thisArg) { forEach(b, function assignValue(val, key) { if (thisArg && typeof val === 'function') { a[key] = bind(val, thisArg); } else { a[key] = val; } }); return a; } /** * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) * * @param {string} content with BOM * @return {string} content value without BOM */ function stripBOM(content) { if (content.charCodeAt(0) === 0xFEFF) { content = content.slice(1); } return content; } var utils = { isArray: isArray, isArrayBuffer: isArrayBuffer, isBuffer: isBuffer, isFormData: isFormData, isArrayBufferView: isArrayBufferView, isString: isString, isNumber: isNumber, isObject: isObject, isPlainObject: isPlainObject, isUndefined: isUndefined, isDate: isDate, isFile: isFile, isBlob: isBlob, isFunction: isFunction, isStream: isStream, isURLSearchParams: isURLSearchParams, isStandardBrowserEnv: isStandardBrowserEnv, forEach: forEach, merge: merge, extend: extend, trim: trim, stripBOM: stripBOM }; function encode(val) { return encodeURIComponent(val). replace(/%3A/gi, ':'). replace(/%24/g, '$'). replace(/%2C/gi, ','). replace(/%20/g, '+'). replace(/%5B/gi, '['). replace(/%5D/gi, ']'); } /** * Build a URL by appending params to the end * * @param {string} url The base of the url (e.g., http://www.google.com) * @param {object} [params] The params to be appended * @returns {string} The formatted url */ var buildURL = function buildURL(url, params, paramsSerializer) { /*eslint no-param-reassign:0*/ if (!params) { return url; } var serializedParams; if (paramsSerializer) { serializedParams = paramsSerializer(params); } else if (utils.isURLSearchParams(params)) { serializedParams = params.toString(); } else { var parts = []; utils.forEach(params, function serialize(val, key) { if (val === null || typeof val === 'undefined') { return; } if (utils.isArray(val)) { key = key + '[]'; } else { val = [val]; } utils.forEach(val, function parseValue(v) { if (utils.isDate(v)) { v = v.toISOString(); } else if (utils.isObject(v)) { v = JSON.stringify(v); } parts.push(encode(key) + '=' + encode(v)); }); }); serializedParams = parts.join('&'); } if (serializedParams) { var hashmarkIndex = url.indexOf('#'); if (hashmarkIndex !== -1) { url = url.slice(0, hashmarkIndex); } url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; } return url; }; function InterceptorManager() { this.handlers = []; } /** * Add a new interceptor to the stack * * @param {Function} fulfilled The function to handle `then` for a `Promise` * @param {Function} rejected The function to handle `reject` for a `Promise` * * @return {Number} An ID used to remove interceptor later */ InterceptorManager.prototype.use = function use(fulfilled, rejected) { this.handlers.push({ fulfilled: fulfilled, rejected: rejected }); return this.handlers.length - 1; }; /** * Remove an interceptor from the stack * * @param {Number} id The ID that was returned by `use` */ InterceptorManager.prototype.eject = function eject(id) { if (this.handlers[id]) { this.handlers[id] = null; } }; /** * Iterate over all the registered interceptors * * This method is particularly useful for skipping over any * interceptors that may have become `null` calling `eject`. * * @param {Function} fn The function to call for each interceptor */ InterceptorManager.prototype.forEach = function forEach(fn) { utils.forEach(this.handlers, function forEachHandler(h) { if (h !== null) { fn(h); } }); }; var InterceptorManager_1 = InterceptorManager; /** * Transform the data for a request or a response * * @param {Object|String} data The data to be transformed * @param {Array} headers The headers for the request or response * @param {Array|Function} fns A single function or Array of functions * @returns {*} The resulting transformed data */ var transformData = function transformData(data, headers, fns) { /*eslint no-param-reassign:0*/ utils.forEach(fns, function transform(fn) { data = fn(data, headers); }); return data; }; var isCancel = function isCancel(value) { return !!(value && value.__CANCEL__); }; var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) { utils.forEach(headers, function processHeader(value, name) { if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { headers[normalizedName] = value; delete headers[name]; } }); }; /** * Update an Error with the specified config, error code, and response. * * @param {Error} error The error to update. * @param {Object} config The config. * @param {string} [code] The error code (for example, 'ECONNABORTED'). * @param {Object} [request] The request. * @param {Object} [response] The response. * @returns {Error} The error. */ var enhanceError = function enhanceError(error, config, code, request, response) { error.config = config; if (code) { error.code = code; } error.request = request; error.response = response; error.isAxiosError = true; error.toJSON = function toJSON() { return { // Standard message: this.message, name: this.name, // Microsoft description: this.description, number: this.number, // Mozilla fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, // Axios config: this.config, code: this.code }; }; return error; }; /** * Create an Error with the specified message, config, error code, request and response. * * @param {string} message The error message. * @param {Object} config The config. * @param {string} [code] The error code (for example, 'ECONNABORTED'). * @param {Object} [request] The request. * @param {Object} [response] The response. * @returns {Error} The created error. */ var createError = function createError(message, config, code, request, response) { var error = new Error(message); return enhanceError(error, config, code, request, response); }; /** * Resolve or reject a Promise based on response status. * * @param {Function} resolve A function that resolves the promise. * @param {Function} reject A function that rejects the promise. * @param {object} response The response. */ var settle = function settle(resolve, reject, response) { var validateStatus = response.config.validateStatus; if (!response.status || !validateStatus || validateStatus(response.status)) { resolve(response); } else { reject(createError( 'Request failed with status code ' + response.status, response.config, null, response.request, response )); } }; var cookies = ( utils.isStandardBrowserEnv() ? // Standard browser envs support document.cookie (function standardBrowserEnv() { return { write: function write(name, value, expires, path, domain, secure) { var cookie = []; cookie.push(name + '=' + encodeURIComponent(value)); if (utils.isNumber(expires)) { cookie.push('expires=' + new Date(expires).toGMTString()); } if (utils.isString(path)) { cookie.push('path=' + path); } if (utils.isString(domain)) { cookie.push('domain=' + domain); } if (secure === true) { cookie.push('secure'); } document.cookie = cookie.join('; '); }, read: function read(name) { var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); return (match ? decodeURIComponent(match[3]) : null); }, remove: function remove(name) { this.write(name, '', Date.now() - 86400000); } }; })() : // Non standard browser env (web workers, react-native) lack needed support. (function nonStandardBrowserEnv() { return { write: function write() {}, read: function read() { return null; }, remove: function remove() {} }; })() ); /** * Determines whether the specified URL is absolute * * @param {string} url The URL to test * @returns {boolean} True if the specified URL is absolute, otherwise false */ var isAbsoluteURL = function isAbsoluteURL(url) { // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed // by any combination of letters, digits, plus, period, or hyphen. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); }; /** * Creates a new URL by combining the specified URLs * * @param {string} baseURL The base URL * @param {string} relativeURL The relative URL * @returns {string} The combined URL */ var combineURLs = function combineURLs(baseURL, relativeURL) { return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL; }; /** * Creates a new URL by combining the baseURL with the requestedURL, * only when the requestedURL is not already an absolute URL. * If the requestURL is absolute, this function returns the requestedURL untouched. * * @param {string} baseURL The base URL * @param {string} requestedURL Absolute or relative URL to combine * @returns {string} The combined full path */ var buildFullPath = function buildFullPath(baseURL, requestedURL) { if (baseURL && !isAbsoluteURL(requestedURL)) { return combineURLs(baseURL, requestedURL); } return requestedURL; }; // Headers whose duplicates are ignored by node // c.f. https://nodejs.org/api/http.html#http_message_headers var ignoreDuplicateOf = [ 'age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent' ]; /** * Parse headers into an object * * ``` * Date: Wed, 27 Aug 2014 08:58:49 GMT * Content-Type: application/json * Connection: keep-alive * Transfer-Encoding: chunked * ``` * * @param {String} headers Headers needing to be parsed * @returns {Object} Headers parsed into an object */ var parseHeaders = function parseHeaders(headers) { var parsed = {}; var key; var val; var i; if (!headers) { return parsed; } utils.forEach(headers.split('\n'), function parser(line) { i = line.indexOf(':'); key = utils.trim(line.substr(0, i)).toLowerCase(); val = utils.trim(line.substr(i + 1)); if (key) { if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { return; } if (key === 'set-cookie') { parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); } else { parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; } } }); return parsed; }; var isURLSameOrigin = ( utils.isStandardBrowserEnv() ? // Standard browser envs have full support of the APIs needed to test // whether the request URL is of the same origin as current location. (function standardBrowserEnv() { var msie = /(msie|trident)/i.test(navigator.userAgent); var urlParsingNode = document.createElement('a'); var originURL; /** * Parse a URL to discover it's components * * @param {String} url The URL to be parsed * @returns {Object} */ function resolveURL(url) { var href = url; if (msie) { // IE needs attribute set twice to normalize properties urlParsingNode.setAttribute('href', href); href = urlParsingNode.href; } urlParsingNode.setAttribute('href', href); // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils return { href: urlParsingNode.href, protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', host: urlParsingNode.host, search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', hostname: urlParsingNode.hostname, port: urlParsingNode.port, pathname: (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname : '/' + urlParsingNode.pathname }; } originURL = resolveURL(window.location.href); /** * Determine if a URL shares the same origin as the current location * * @param {String} requestURL The URL to test * @returns {boolean} True if URL shares the same origin, otherwise false */ return function isURLSameOrigin(requestURL) { var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; return (parsed.protocol === originURL.protocol && parsed.host === originURL.host); }; })() : // Non standard browser envs (web workers, react-native) lack needed support. (function nonStandardBrowserEnv() { return function isURLSameOrigin() { return true; }; })() ); var xhr = function xhrAdapter(config) { return new Promise(function dispatchXhrRequest(resolve, reject) { var requestData = config.data; var requestHeaders = config.headers; if (utils.isFormData(requestData)) { delete requestHeaders['Content-Type']; // Let the browser set it } var request = new XMLHttpRequest(); // HTTP basic authentication if (config.auth) { var username = config.auth.username || ''; var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); } var fullPath = buildFullPath(config.baseURL, config.url); request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); // Set the request timeout in MS request.timeout = config.timeout; // Listen for ready state request.onreadystatechange = function handleLoad() { if (!request || request.readyState !== 4) { return; } // The request errored out and we didn't get a response, this will be // handled by onerror instead // With one exception: request that using file: protocol, most browsers // will return status as 0 even though it's a successful request if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { return; } // Prepare the response var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; var response = { data: responseData, status: request.status, statusText: request.statusText, headers: responseHeaders, config: config, request: request }; settle(resolve, reject, response); // Clean up request request = null; }; // Handle browser request cancellation (as opposed to a manual cancellation) request.onabort = function handleAbort() { if (!request) { return; } reject(createError('Request aborted', config, 'ECONNABORTED', request)); // Clean up request request = null; }; // Handle low level network errors request.onerror = function handleError() { // Real errors are hidden from us by the browser // onerror should only fire if it's a network error reject(createError('Network Error', config, null, request)); // Clean up request request = null; }; // Handle timeout request.ontimeout = function handleTimeout() { var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; if (config.timeoutErrorMessage) { timeoutErrorMessage = config.timeoutErrorMessage; } reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', request)); // Clean up request request = null; }; // Add xsrf header // This is only done if running in a standard browser environment. // Specifically not if we're in a web worker, or react-native. if (utils.isStandardBrowserEnv()) { // Add xsrf header var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : undefined; if (xsrfValue) { requestHeaders[config.xsrfHeaderName] = xsrfValue; } } // Add headers to the request if ('setRequestHeader' in request) { utils.forEach(requestHeaders, function setRequestHeader(val, key) { if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { // Remove Content-Type if data is undefined delete requestHeaders[key]; } else { // Otherwise add header to the request request.setRequestHeader(key, val); } }); } // Add withCredentials to request if needed if (!utils.isUndefined(config.withCredentials)) { request.withCredentials = !!config.withCredentials; } // Add responseType to request if needed if (config.responseType) { try { request.responseType = config.responseType; } catch (e) { // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. if (config.responseType !== 'json') { throw e; } } } // Handle progress if needed if (typeof config.onDownloadProgress === 'function') { request.addEventListener('progress', config.onDownloadProgress); } // Not all browsers support upload events if (typeof config.onUploadProgress === 'function' && request.upload) { request.upload.addEventListener('progress', config.onUploadProgress); } if (config.cancelToken) { // Handle cancellation config.cancelToken.promise.then(function onCanceled(cancel) { if (!request) { return; } request.abort(); reject(cancel); // Clean up request request = null; }); } if (!requestData) { requestData = null; } // Send the request request.send(requestData); }); }; var DEFAULT_CONTENT_TYPE = { 'Content-Type': 'application/x-www-form-urlencoded' }; function setContentTypeIfUnset(headers, value) { if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { headers['Content-Type'] = value; } } function getDefaultAdapter() { var adapter; if (typeof XMLHttpRequest !== 'undefined') { // For browsers use XHR adapter adapter = xhr; } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { // For node use HTTP adapter adapter = xhr; } return adapter; } var defaults = { adapter: getDefaultAdapter(), transformRequest: [function transformRequest(data, headers) { normalizeHeaderName(headers, 'Accept'); normalizeHeaderName(headers, 'Content-Type'); if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data) ) { return data; } if (utils.isArrayBufferView(data)) { return data.buffer; } if (utils.isURLSearchParams(data)) { setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); return data.toString(); } if (utils.isObject(data)) { setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); return JSON.stringify(data); } return data; }], transformResponse: [function transformResponse(data) { /*eslint no-param-reassign:0*/ if (typeof data === 'string') { try { data = JSON.parse(data); } catch (e) { /* Ignore */ } } return data; }], /** * A timeout in milliseconds to abort a request. If set to 0 (default) a * timeout is not created. */ timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: function validateStatus(status) { return status >= 200 && status < 300; } }; defaults.headers = { common: { 'Accept': 'application/json, text/plain, */*' } }; utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { defaults.headers[method] = {}; }); utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); }); var defaults_1 = defaults; /** * Throws a `Cancel` if cancellation has been requested. */ function throwIfCancellationRequested(config) { if (config.cancelToken) { config.cancelToken.throwIfRequested(); } } /** * Dispatch a request to the server using the configured adapter. * * @param {object} config The config that is to be used for the request * @returns {Promise} The Promise to be fulfilled */ var dispatchRequest = function dispatchRequest(config) { throwIfCancellationRequested(config); // Ensure headers exist config.headers = config.headers || {}; // Transform request data config.data = transformData( config.data, config.headers, config.transformRequest ); // Flatten headers config.headers = utils.merge( config.headers.common || {}, config.headers[config.method] || {}, config.headers ); utils.forEach( ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function cleanHeaderConfig(method) { delete config.headers[method]; } ); var adapter = config.adapter || defaults_1.adapter; return adapter(config).then(function onAdapterResolution(response) { throwIfCancellationRequested(config); // Transform response data response.data = transformData( response.data, response.headers, config.transformResponse ); return response; }, function onAdapterRejection(reason) { if (!isCancel(reason)) { throwIfCancellationRequested(config); // Transform response data if (reason && reason.response) { reason.response.data = transformData( reason.response.data, reason.response.headers, config.transformResponse ); } } return Promise.reject(reason); }); }; /** * Config-specific merge-function which creates a new config-object * by merging two configuration objects together. * * @param {Object} config1 * @param {Object} config2 * @returns {Object} New object resulting from merging config2 to config1 */ var mergeConfig = function mergeConfig(config1, config2) { // eslint-disable-next-line no-param-reassign config2 = config2 || {}; var config = {}; var valueFromConfig2Keys = ['url', 'method', 'data']; var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; var defaultToConfig2Keys = [ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' ]; var directMergeKeys = ['validateStatus']; function getMergedValue(target, source) { if (utils.isPlainObject(target) && utils.isPlainObject(source)) { return utils.merge(target, source); } else if (utils.isPlainObject(source)) { return utils.merge({}, source); } else if (utils.isArray(source)) { return source.slice(); } return source; } function mergeDeepProperties(prop) { if (!utils.isUndefined(config2[prop])) { config[prop] = getMergedValue(config1[prop], config2[prop]); } else if (!utils.isUndefined(config1[prop])) { config[prop] = getMergedValue(undefined, config1[prop]); } } utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { if (!utils.isUndefined(config2[prop])) { config[prop] = getMergedValue(undefined, config2[prop]); } }); utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { if (!utils.isUndefined(config2[prop])) { config[prop] = getMergedValue(undefined, config2[prop]); } else if (!utils.isUndefined(config1[prop])) { config[prop] = getMergedValue(undefined, config1[prop]); } }); utils.forEach(directMergeKeys, function merge(prop) { if (prop in config2) { config[prop] = getMergedValue(config1[prop], config2[prop]); } else if (prop in config1) { config[prop] = getMergedValue(undefined, config1[prop]); } }); var axiosKeys = valueFromConfig2Keys .concat(mergeDeepPropertiesKeys) .concat(defaultToConfig2Keys) .concat(directMergeKeys); var otherKeys = Object .keys(config1) .concat(Object.keys(config2)) .filter(function filterAxiosKeys(key) { return axiosKeys.indexOf(key) === -1; }); utils.forEach(otherKeys, mergeDeepProperties); return config; }; /** * Create a new instance of Axios * * @param {Object} instanceConfig The default config for the instance */ function Axios(instanceConfig) { this.defaults = instanceConfig; this.interceptors = { request: new InterceptorManager_1(), response: new InterceptorManager_1() }; } /** * Dispatch a request * * @param {Object} config The config specific for this request (merged with this.defaults) */ Axios.prototype.request = function request(config) { /*eslint no-param-reassign:0*/ // Allow for axios('example/url'[, config]) a la fetch API if (typeof config === 'string') { config = arguments[1] || {}; config.url = arguments[0]; } else { config = config || {}; } config = mergeConfig(this.defaults, config); // Set config.method if (config.method) { config.method = config.method.toLowerCase(); } else if (this.defaults.method) { config.method = this.defaults.method.toLowerCase(); } else { config.method = 'get'; } // Hook up interceptors middleware var chain = [dispatchRequest, undefined]; var promise = Promise.resolve(config); this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { chain.unshift(interceptor.fulfilled, interceptor.rejected); }); this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { chain.push(interceptor.fulfilled, interceptor.rejected); }); while (chain.length) { promise = promise.then(chain.shift(), chain.shift()); } return promise; }; Axios.prototype.getUri = function getUri(config) { config = mergeConfig(this.defaults, config); return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); }; // Provide aliases for supported request methods utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { /*eslint func-names:0*/ Axios.prototype[method] = function(url, config) { return this.request(mergeConfig(config || {}, { method: method, url: url, data: (config || {}).data })); }; }); utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { /*eslint func-names:0*/ Axios.prototype[method] = function(url, data, config) { return this.request(mergeConfig(config || {}, { method: method, url: url, data: data })); }; }); var Axios_1 = Axios; /** * A `Cancel` is an object that is thrown when an operation is canceled. * * @class * @param {string=} message The message. */ function Cancel(message) { this.message = message; } Cancel.prototype.toString = function toString() { return 'Cancel' + (this.message ? ': ' + this.message : ''); }; Cancel.prototype.__CANCEL__ = true; var Cancel_1 = Cancel; /** * A `CancelToken` is an object that can be used to request cancellation of an operation. * * @class * @param {Function} executor The executor function. */ function CancelToken(executor) { if (typeof executor !== 'function') { throw new TypeError('executor must be a function.'); } var resolvePromise; this.promise = new Promise(function promiseExecutor(resolve) { resolvePromise = resolve; }); var token = this; executor(function cancel(message) { if (token.reason) { // Cancellation has already been requested return; } token.reason = new Cancel_1(message); resolvePromise(token.reason); }); } /** * Throws a `Cancel` if cancellation has been requested. */ CancelToken.prototype.throwIfRequested = function throwIfRequested() { if (this.reason) { throw this.reason; } }; /** * Returns an object that contains a new `CancelToken` and a function that, when called, * cancels the `CancelToken`. */ CancelToken.source = function source() { var cancel; var token = new CancelToken(function executor(c) { cancel = c; }); return { token: token, cancel: cancel }; }; var CancelToken_1 = CancelToken; /** * Syntactic sugar for invoking a function and expanding an array for arguments. * * Common use case would be to use `Function.prototype.apply`. * * ```js * function f(x, y, z) {} * var args = [1, 2, 3]; * f.apply(null, args); * ``` * * With `spread` this example can be re-written. * * ```js * spread(function(x, y, z) {})([1, 2, 3]); * ``` * * @param {Function} callback * @returns {Function} */ var spread = function spread(callback) { return function wrap(arr) { return callback.apply(null, arr); }; }; /** * Determines whether the payload is an error thrown by Axios * * @param {*} payload The value to test * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false */ var isAxiosError = function isAxiosError(payload) { return (typeof payload === 'object') && (payload.isAxiosError === true); }; /** * Create an instance of Axios * * @param {Object} defaultConfig The default config for the instance * @return {Axios} A new instance of Axios */ function createInstance(defaultConfig) { var context = new Axios_1(defaultConfig); var instance = bind(Axios_1.prototype.request, context); // Copy axios.prototype to instance utils.extend(instance, Axios_1.prototype, context); // Copy context to instance utils.extend(instance, context); return instance; } // Create the default instance to be exported var axios$1 = createInstance(defaults_1); // Expose Axios class to allow class inheritance axios$1.Axios = Axios_1; // Factory for creating new instances axios$1.create = function create(instanceConfig) { return createInstance(mergeConfig(axios$1.defaults, instanceConfig)); }; // Expose Cancel & CancelToken axios$1.Cancel = Cancel_1; axios$1.CancelToken = CancelToken_1; axios$1.isCancel = isCancel; // Expose all/spread axios$1.all = function all(promises) { return Promise.all(promises); }; axios$1.spread = spread; // Expose isAxiosError axios$1.isAxiosError = isAxiosError; var axios_1 = axios$1; // Allow use of default import syntax in TypeScript var _default = axios$1; axios_1.default = _default; var axios = axios_1; let url = window.BASE_URL; let current_token; token$1.subscribe(value => { current_token = value; }); async function login({ username, password }) { const endpoint = url + "/api/auth/login"; const response = await axios({ url: endpoint, method: "POST", data: JSON.stringify({ username, password, }), }); token$1.set(response.data.token); return response.data; } async function getPosts({ page }) { const endpoint = url + "/api/post?page=" + page; const response = await axios.get(endpoint); return response.data; } async function getPostsTag({ page, tag }) { const endpoint = url + "/api/post/tag/" + tag + "?page=" + page; const response = await axios(endpoint); return response.data; } async function getPost({ id }) { const endpoint = url + "/api/post/" + id; const response = await axios(endpoint); return response.data; } async function uploadBlob({ file, onProgress }) { var formData = new FormData(); formData.append("file", file); const endpoint = url + "/api/blob/upload"; const response = await axios({ url: endpoint, method: "POST", headers: { 'Authorization': 'Bearer ' + current_token, 'Content-Type': 'multipart/form-data', }, withCredentials: true, data: formData, onUploadProgress: e => { if (onProgress) { onProgress(e); } } }); return response.data; } async function postCreate({ blob_id, source_url, tags }) { const endpoint = url + "/api/post/create"; const response = await axios({ url: endpoint, method: "POST", headers: { 'Authorization': 'Bearer ' + current_token, }, withCredentials: true, data: { blob_id, source_url, tags } }); return response.data; } function createCommonjsModule(fn) { var module = { exports: {} }; return fn(module, module.exports), module.exports; } var strictUriEncode = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`); var token = '%[a-f0-9]{2}'; var singleMatcher = new RegExp(token, 'gi'); var multiMatcher = new RegExp('(' + token + ')+', 'gi'); function decodeComponents(components, split) { try { // Try to decode the entire string first return decodeURIComponent(components.join('')); } catch (err) { // Do nothing } if (components.length === 1) { return components; } split = split || 1; // Split the array in 2 parts var left = components.slice(0, split); var right = components.slice(split); return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); } function decode(input) { try { return decodeURIComponent(input); } catch (err) { var tokens = input.match(singleMatcher); for (var i = 1; i < tokens.length; i++) { input = decodeComponents(tokens, i).join(''); tokens = input.match(singleMatcher); } return input; } } function customDecodeURIComponent(input) { // Keep track of all the replacements and prefill the map with the `BOM` var replaceMap = { '%FE%FF': '\uFFFD\uFFFD', '%FF%FE': '\uFFFD\uFFFD' }; var match = multiMatcher.exec(input); while (match) { try { // Decode as big chunks as possible replaceMap[match[0]] = decodeURIComponent(match[0]); } catch (err) { var result = decode(match[0]); if (result !== match[0]) { replaceMap[match[0]] = result; } } match = multiMatcher.exec(input); } // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else replaceMap['%C2'] = '\uFFFD'; var entries = Object.keys(replaceMap); for (var i = 0; i < entries.length; i++) { // Replace all decoded components var key = entries[i]; input = input.replace(new RegExp(key, 'g'), replaceMap[key]); } return input; } var decodeUriComponent = function (encodedURI) { if (typeof encodedURI !== 'string') { throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`'); } try { encodedURI = encodedURI.replace(/\+/g, ' '); // Try the built in decoder first return decodeURIComponent(encodedURI); } catch (err) { // Fallback to a more advanced decoder return customDecodeURIComponent(encodedURI); } }; var splitOnFirst = (string, separator) => { if (!(typeof string === 'string' && typeof separator === 'string')) { throw new TypeError('Expected the arguments to be of type `string`'); } if (separator === '') { return [string]; } const separatorIndex = string.indexOf(separator); if (separatorIndex === -1) { return [string]; } return [ string.slice(0, separatorIndex), string.slice(separatorIndex + separator.length) ]; }; var filterObj = function (obj, predicate) { var ret = {}; var keys = Object.keys(obj); var isArr = Array.isArray(predicate); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var val = obj[key]; if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { ret[key] = val; } } return ret; }; var queryString = createCommonjsModule(function (module, exports) { const isNullOrUndefined = value => value === null || value === undefined; function encoderForArrayFormat(options) { switch (options.arrayFormat) { case 'index': return key => (result, value) => { const index = result.length; if ( value === undefined || (options.skipNull && value === null) || (options.skipEmptyString && value === '') ) { return result; } if (value === null) { return [...result, [encode(key, options), '[', index, ']'].join('')]; } return [ ...result, [encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('') ]; }; case 'bracket': return key => (result, value) => { if ( value === undefined || (options.skipNull && value === null) || (options.skipEmptyString && value === '') ) { return result; } if (value === null) { return [...result, [encode(key, options), '[]'].join('')]; } return [...result, [encode(key, options), '[]=', encode(value, options)].join('')]; }; case 'comma': case 'separator': case 'bracket-separator': { const keyValueSep = options.arrayFormat === 'bracket-separator' ? '[]=' : '='; return key => (result, value) => { if ( value === undefined || (options.skipNull && value === null) || (options.skipEmptyString && value === '') ) { return result; } // Translate null to an empty string so that it doesn't serialize as 'null' value = value === null ? '' : value; if (result.length === 0) { return [[encode(key, options), keyValueSep, encode(value, options)].join('')]; } return [[result, encode(value, options)].join(options.arrayFormatSeparator)]; }; } default: return key => (result, value) => { if ( value === undefined || (options.skipNull && value === null) || (options.skipEmptyString && value === '') ) { return result; } if (value === null) { return [...result, encode(key, options)]; } return [...result, [encode(key, options), '=', encode(value, options)].join('')]; }; } } function parserForArrayFormat(options) { let result; switch (options.arrayFormat) { case 'index': return (key, value, accumulator) => { result = /\[(\d*)\]$/.exec(key); key = key.replace(/\[\d*\]$/, ''); if (!result) { accumulator[key] = value; return; } if (accumulator[key] === undefined) { accumulator[key] = {}; } accumulator[key][result[1]] = value; }; case 'bracket': return (key, value, accumulator) => { result = /(\[\])$/.exec(key); key = key.replace(/\[\]$/, ''); if (!result) { accumulator[key] = value; return; } if (accumulator[key] === undefined) { accumulator[key] = [value]; return; } accumulator[key] = [].concat(accumulator[key], value); }; case 'comma': case 'separator': return (key, value, accumulator) => { const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator); const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator)); value = isEncodedArray ? decode(value, options) : value; const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options); accumulator[key] = newValue; }; case 'bracket-separator': return (key, value, accumulator) => { const isArray = /(\[\])$/.test(key); key = key.replace(/\[\]$/, ''); if (!isArray) { accumulator[key] = value ? decode(value, options) : value; return; } const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map(item => decode(item, options)); if (accumulator[key] === undefined) { accumulator[key] = arrayValue; return; } accumulator[key] = [].concat(accumulator[key], arrayValue); }; default: return (key, value, accumulator) => { if (accumulator[key] === undefined) { accumulator[key] = value; return; } accumulator[key] = [].concat(accumulator[key], value); }; } } function validateArrayFormatSeparator(value) { if (typeof value !== 'string' || value.length !== 1) { throw new TypeError('arrayFormatSeparator must be single character string'); } } function encode(value, options) { if (options.encode) { return options.strict ? strictUriEncode(value) : encodeURIComponent(value); } return value; } function decode(value, options) { if (options.decode) { return decodeUriComponent(value); } return value; } function keysSorter(input) { if (Array.isArray(input)) { return input.sort(); } if (typeof input === 'object') { return keysSorter(Object.keys(input)) .sort((a, b) => Number(a) - Number(b)) .map(key => input[key]); } return input; } function removeHash(input) { const hashStart = input.indexOf('#'); if (hashStart !== -1) { input = input.slice(0, hashStart); } return input; } function getHash(url) { let hash = ''; const hashStart = url.indexOf('#'); if (hashStart !== -1) { hash = url.slice(hashStart); } return hash; } function extract(input) { input = removeHash(input); const queryStart = input.indexOf('?'); if (queryStart === -1) { return ''; } return input.slice(queryStart + 1); } function parseValue(value, options) { if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) { value = Number(value); } else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) { value = value.toLowerCase() === 'true'; } return value; } function parse(query, options) { options = Object.assign({ decode: true, sort: true, arrayFormat: 'none', arrayFormatSeparator: ',', parseNumbers: false, parseBooleans: false }, options); validateArrayFormatSeparator(options.arrayFormatSeparator); const formatter = parserForArrayFormat(options); // Create an object with no prototype const ret = Object.create(null); if (typeof query !== 'string') { return ret; } query = query.trim().replace(/^[?#&]/, ''); if (!query) { return ret; } for (const param of query.split('&')) { if (param === '') { continue; } let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '='); // Missing `=` should be `null`: // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters value = value === undefined ? null : ['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options); formatter(decode(key, options), value, ret); } for (const key of Object.keys(ret)) { const value = ret[key]; if (typeof value === 'object' && value !== null) { for (const k of Object.keys(value)) { value[k] = parseValue(value[k], options); } } else { ret[key] = parseValue(value, options); } } if (options.sort === false) { return ret; } return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { const value = ret[key]; if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) { // Sort object keys, not values result[key] = keysSorter(value); } else { result[key] = value; } return result; }, Object.create(null)); } exports.extract = extract; exports.parse = parse; exports.stringify = (object, options) => { if (!object) { return ''; } options = Object.assign({ encode: true, strict: true, arrayFormat: 'none', arrayFormatSeparator: ',' }, options); validateArrayFormatSeparator(options.arrayFormatSeparator); const shouldFilter = key => ( (options.skipNull && isNullOrUndefined(object[key])) || (options.skipEmptyString && object[key] === '') ); const formatter = encoderForArrayFormat(options); const objectCopy = {}; for (const key of Object.keys(object)) { if (!shouldFilter(key)) { objectCopy[key] = object[key]; } } const keys = Object.keys(objectCopy); if (options.sort !== false) { keys.sort(options.sort); } return keys.map(key => { const value = object[key]; if (value === undefined) { return ''; } if (value === null) { return encode(key, options); } if (Array.isArray(value)) { if (value.length === 0 && options.arrayFormat === 'bracket-separator') { return encode(key, options) + '[]'; } return value .reduce(formatter(key), []) .join('&'); } return encode(key, options) + '=' + encode(value, options); }).filter(x => x.length > 0).join('&'); }; exports.parseUrl = (url, options) => { options = Object.assign({ decode: true }, options); const [url_, hash] = splitOnFirst(url, '#'); return Object.assign( { url: url_.split('?')[0] || '', query: parse(extract(url), options) }, options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {} ); }; exports.stringifyUrl = (object, options) => { options = Object.assign({ encode: true, strict: true }, options); const url = removeHash(object.url).split('?')[0] || ''; const queryFromUrl = exports.extract(object.url); const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false}); const query = Object.assign(parsedQueryFromUrl, object.query); let queryString = exports.stringify(query, options); if (queryString) { queryString = `?${queryString}`; } let hash = getHash(object.url); if (object.fragmentIdentifier) { hash = `#${encode(object.fragmentIdentifier, options)}`; } return `${url}${queryString}${hash}`; }; exports.pick = (input, filter, options) => { options = Object.assign({ parseFragmentIdentifier: true }, options); const {url, query, fragmentIdentifier} = exports.parseUrl(input, options); return exports.stringifyUrl({ url, query: filterObj(query, filter), fragmentIdentifier }, options); }; exports.exclude = (input, filter, options) => { const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value); return exports.pick(input, exclusionFilter, options); }; }); /* src/PostPaginator.svelte generated by Svelte v3.38.2 */ const file$7 = "src/PostPaginator.svelte"; function get_each_context$2(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[6] = list[i]; return child_ctx; } function get_each_context_1$1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[9] = list[i]; return child_ctx; } function get_each_context_2(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[12] = list[i]; return child_ctx; } // (14:12) {#if page > 1} function create_if_block_5(ctx) { let link; let current; link = new Link({ props: { to: "" + (/*url*/ ctx[4] + "?page=" + (/*page*/ ctx[1] - 1)), class: "pagination-previous", "aria-label": "Previous", $$slots: { default: [create_default_slot_7] }, $$scope: { ctx } }, $$inline: true }); link.$on("click", function () { if (is_function(/*handlePage*/ ctx[3](/*page*/ ctx[1] - 1))) /*handlePage*/ ctx[3](/*page*/ ctx[1] - 1).apply(this, arguments); }); const block = { c: function create() { create_component(link.$$.fragment); }, m: function mount(target, anchor) { mount_component(link, target, anchor); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*url, page*/ 18) link_changes.to = "" + (/*url*/ ctx[4] + "?page=" + (/*page*/ ctx[1] - 1)); if (dirty & /*$$scope*/ 32768) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { destroy_component(link, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_5.name, type: "if", source: "(14:12) {#if page > 1}", ctx }); return block; } // (15:16) function create_default_slot_7(ctx) { let t; const block = { c: function create() { t = text("Previous"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_7.name, type: "slot", source: "(15:16) ", ctx }); return block; } // (22:12) {#if page < totalPages} function create_if_block_4(ctx) { let link; let current; link = new Link({ props: { to: "" + (/*url*/ ctx[4] + "?page=" + (/*page*/ ctx[1] + 1)), class: "pagination-next", "aria-label": "Next", $$slots: { default: [create_default_slot_6] }, $$scope: { ctx } }, $$inline: true }); link.$on("click", function () { if (is_function(/*handlePage*/ ctx[3](/*page*/ ctx[1] + 1))) /*handlePage*/ ctx[3](/*page*/ ctx[1] + 1).apply(this, arguments); }); const block = { c: function create() { create_component(link.$$.fragment); }, m: function mount(target, anchor) { mount_component(link, target, anchor); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*url, page*/ 18) link_changes.to = "" + (/*url*/ ctx[4] + "?page=" + (/*page*/ ctx[1] + 1)); if (dirty & /*$$scope*/ 32768) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { destroy_component(link, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_4.name, type: "if", source: "(22:12) {#if page < totalPages}", ctx }); return block; } // (23:16) function create_default_slot_6(ctx) { let t; const block = { c: function create() { t = text("Next"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_6.name, type: "slot", source: "(23:16) ", ctx }); return block; } // (31:16) {#if page > 3} function create_if_block_3$1(ctx) { let li0; let link; let t0; let li1; let span; let current; link = new Link({ props: { to: "" + (/*url*/ ctx[4] + "?page=" + 1), class: "pagination-link", "aria-label": "Goto page 1", $$slots: { default: [create_default_slot_5] }, $$scope: { ctx } }, $$inline: true }); link.$on("click", function () { if (is_function(/*handlePage*/ ctx[3](1))) /*handlePage*/ ctx[3](1).apply(this, arguments); }); const block = { c: function create() { li0 = element("li"); create_component(link.$$.fragment); t0 = space(); li1 = element("li"); span = element("span"); span.textContent = "…"; add_location(li0, file$7, 31, 20, 1014); attr_dev(span, "class", "pagination-ellipsis"); add_location(span, file$7, 40, 24, 1364); add_location(li1, file$7, 39, 20, 1335); }, m: function mount(target, anchor) { insert_dev(target, li0, anchor); mount_component(link, li0, null); insert_dev(target, t0, anchor); insert_dev(target, li1, anchor); append_dev(li1, span); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*url*/ 16) link_changes.to = "" + (/*url*/ ctx[4] + "?page=" + 1); if (dirty & /*$$scope*/ 32768) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(li0); destroy_component(link); if (detaching) detach_dev(t0); if (detaching) detach_dev(li1); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_3$1.name, type: "if", source: "(31:16) {#if page > 3}", ctx }); return block; } // (33:24) function create_default_slot_5(ctx) { let t; const block = { c: function create() { t = text("1"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_5.name, type: "slot", source: "(33:24) ", ctx }); return block; } // (45:20) {#if i >= 1 && i <= totalPages} function create_if_block_1$3(ctx) { let current_block_type_index; let if_block; let if_block_anchor; let current; const if_block_creators = [create_if_block_2$1, create_else_block$1]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*i*/ ctx[12] == /*page*/ ctx[1]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); const block = { c: function create() { if_block.c(); if_block_anchor = empty(); }, m: function mount(target, anchor) { if_blocks[current_block_type_index].m(target, anchor); insert_dev(target, if_block_anchor, anchor); current = true; }, p: function update(ctx, dirty) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } else { if_block.p(ctx, dirty); } transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } }, i: function intro(local) { if (current) return; transition_in(if_block); current = true; }, o: function outro(local) { transition_out(if_block); current = false; }, d: function destroy(detaching) { if_blocks[current_block_type_index].d(detaching); if (detaching) detach_dev(if_block_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1$3.name, type: "if", source: "(45:20) {#if i >= 1 && i <= totalPages}", ctx }); return block; } // (55:24) {:else} function create_else_block$1(ctx) { let li; let link; let current; link = new Link({ props: { to: "" + (/*url*/ ctx[4] + "?page=" + /*i*/ ctx[12]), class: "pagination-link", "aria-label": "Goto page " + /*i*/ ctx[12], $$slots: { default: [create_default_slot_4] }, $$scope: { ctx } }, $$inline: true }); link.$on("click", function () { if (is_function(/*handlePage*/ ctx[3](/*i*/ ctx[12]))) /*handlePage*/ ctx[3](/*i*/ ctx[12]).apply(this, arguments); }); const block = { c: function create() { li = element("li"); create_component(link.$$.fragment); add_location(li, file$7, 55, 28, 2089); }, m: function mount(target, anchor) { insert_dev(target, li, anchor); mount_component(link, li, null); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*url, page*/ 18) link_changes.to = "" + (/*url*/ ctx[4] + "?page=" + /*i*/ ctx[12]); if (dirty & /*page*/ 2) link_changes["aria-label"] = "Goto page " + /*i*/ ctx[12]; if (dirty & /*$$scope, page*/ 32770) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(li); destroy_component(link); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_else_block$1.name, type: "else", source: "(55:24) {:else}", ctx }); return block; } // (46:24) {#if i == page} function create_if_block_2$1(ctx) { let li; let link; let current; link = new Link({ props: { to: "" + (/*url*/ ctx[4] + "?page=" + /*i*/ ctx[12]), class: "pagination-link is-current", "aria-label": "Goto page " + /*i*/ ctx[12], $$slots: { default: [create_default_slot_3] }, $$scope: { ctx } }, $$inline: true }); link.$on("click", function () { if (is_function(/*handlePage*/ ctx[3](/*i*/ ctx[12]))) /*handlePage*/ ctx[3](/*i*/ ctx[12]).apply(this, arguments); }); const block = { c: function create() { li = element("li"); create_component(link.$$.fragment); add_location(li, file$7, 46, 28, 1657); }, m: function mount(target, anchor) { insert_dev(target, li, anchor); mount_component(link, li, null); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*url, page*/ 18) link_changes.to = "" + (/*url*/ ctx[4] + "?page=" + /*i*/ ctx[12]); if (dirty & /*page*/ 2) link_changes["aria-label"] = "Goto page " + /*i*/ ctx[12]; if (dirty & /*$$scope, page*/ 32770) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(li); destroy_component(link); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_2$1.name, type: "if", source: "(46:24) {#if i == page}", ctx }); return block; } // (57:32) function create_default_slot_4(ctx) { let t_value = /*i*/ ctx[12] + ""; let t; const block = { c: function create() { t = text(t_value); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, p: function update(ctx, dirty) { if (dirty & /*page*/ 2 && t_value !== (t_value = /*i*/ ctx[12] + "")) set_data_dev(t, t_value); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_4.name, type: "slot", source: "(57:32) ", ctx }); return block; } // (48:32) function create_default_slot_3(ctx) { let t_value = /*i*/ ctx[12] + ""; let t; const block = { c: function create() { t = text(t_value); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, p: function update(ctx, dirty) { if (dirty & /*page*/ 2 && t_value !== (t_value = /*i*/ ctx[12] + "")) set_data_dev(t, t_value); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_3.name, type: "slot", source: "(48:32) ", ctx }); return block; } // (44:16) {#each [...Array(5).keys()].map((x) => x + page - 2) as i} function create_each_block_2(ctx) { let if_block_anchor; let current; let if_block = /*i*/ ctx[12] >= 1 && /*i*/ ctx[12] <= /*totalPages*/ ctx[2] && create_if_block_1$3(ctx); const block = { c: function create() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m: function mount(target, anchor) { if (if_block) if_block.m(target, anchor); insert_dev(target, if_block_anchor, anchor); current = true; }, p: function update(ctx, dirty) { if (/*i*/ ctx[12] >= 1 && /*i*/ ctx[12] <= /*totalPages*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*page, totalPages*/ 6) { transition_in(if_block, 1); } } else { if_block = create_if_block_1$3(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i: function intro(local) { if (current) return; transition_in(if_block); current = true; }, o: function outro(local) { transition_out(if_block); current = false; }, d: function destroy(detaching) { if (if_block) if_block.d(detaching); if (detaching) detach_dev(if_block_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block_2.name, type: "each", source: "(44:16) {#each [...Array(5).keys()].map((x) => x + page - 2) as i}", ctx }); return block; } // (67:16) {#if totalPages - page > 2} function create_if_block$3(ctx) { let li0; let span; let t1; let li1; let link; let current; link = new Link({ props: { to: "" + (/*url*/ ctx[4] + "?page=" + /*totalPages*/ ctx[2]), class: "pagination-link", "aria-label": "Goto page " + /*totalPages*/ ctx[2], $$slots: { default: [create_default_slot_2] }, $$scope: { ctx } }, $$inline: true }); link.$on("click", function () { if (is_function(/*handlePage*/ ctx[3](/*totalPages*/ ctx[2]))) /*handlePage*/ ctx[3](/*totalPages*/ ctx[2]).apply(this, arguments); }); const block = { c: function create() { li0 = element("li"); span = element("span"); span.textContent = "…"; t1 = space(); li1 = element("li"); create_component(link.$$.fragment); attr_dev(span, "class", "pagination-ellipsis"); add_location(span, file$7, 68, 24, 2623); add_location(li0, file$7, 67, 20, 2594); add_location(li1, file$7, 70, 20, 2719); }, m: function mount(target, anchor) { insert_dev(target, li0, anchor); append_dev(li0, span); insert_dev(target, t1, anchor); insert_dev(target, li1, anchor); mount_component(link, li1, null); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*url, totalPages*/ 20) link_changes.to = "" + (/*url*/ ctx[4] + "?page=" + /*totalPages*/ ctx[2]); if (dirty & /*totalPages*/ 4) link_changes["aria-label"] = "Goto page " + /*totalPages*/ ctx[2]; if (dirty & /*$$scope, totalPages*/ 32772) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(li0); if (detaching) detach_dev(t1); if (detaching) detach_dev(li1); destroy_component(link); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block$3.name, type: "if", source: "(67:16) {#if totalPages - page > 2}", ctx }); return block; } // (72:24) function create_default_slot_2(ctx) { let t; const block = { c: function create() { t = text(/*totalPages*/ ctx[2]); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, p: function update(ctx, dirty) { if (dirty & /*totalPages*/ 4) set_data_dev(t, /*totalPages*/ ctx[2]); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_2.name, type: "slot", source: "(72:24) ", ctx }); return block; } // (88:28) function create_default_slot_1(ctx) { let img; let img_alt_value; let img_src_value; const block = { c: function create() { img = element("img"); attr_dev(img, "alt", img_alt_value = /*post*/ ctx[6].id); if (img.src !== (img_src_value = /*post*/ ctx[6].image_path)) attr_dev(img, "src", img_src_value); add_location(img, file$7, 88, 32, 3468); }, m: function mount(target, anchor) { insert_dev(target, img, anchor); }, p: function update(ctx, dirty) { if (dirty & /*posts*/ 1 && img_alt_value !== (img_alt_value = /*post*/ ctx[6].id)) { attr_dev(img, "alt", img_alt_value); } if (dirty & /*posts*/ 1 && img.src !== (img_src_value = /*post*/ ctx[6].image_path)) { attr_dev(img, "src", img_src_value); } }, d: function destroy(detaching) { if (detaching) detach_dev(img); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot_1.name, type: "slot", source: "(88:28) ", ctx }); return block; } // (97:36) function create_default_slot$2(ctx) { let t_value = /*tag*/ ctx[9] + ""; let t; const block = { c: function create() { t = text(t_value); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, p: function update(ctx, dirty) { if (dirty & /*posts*/ 1 && t_value !== (t_value = /*tag*/ ctx[9] + "")) set_data_dev(t, t_value); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot$2.name, type: "slot", source: "(97:36) ", ctx }); return block; } // (95:28) {#each post.tags as tag (tag)} function create_each_block_1$1(key_1, ctx) { let p; let link; let t; let current; link = new Link({ props: { to: "/tag/" + /*tag*/ ctx[9], $$slots: { default: [create_default_slot$2] }, $$scope: { ctx } }, $$inline: true }); const block = { key: key_1, first: null, c: function create() { p = element("p"); create_component(link.$$.fragment); t = space(); add_location(p, file$7, 95, 32, 3793); this.first = p; }, m: function mount(target, anchor) { insert_dev(target, p, anchor); mount_component(link, p, null); append_dev(p, t); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*posts*/ 1) link_changes.to = "/tag/" + /*tag*/ ctx[9]; if (dirty & /*$$scope, posts*/ 32769) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(p); destroy_component(link); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block_1$1.name, type: "each", source: "(95:28) {#each post.tags as tag (tag)}", ctx }); return block; } // (84:12) {#each posts as post (post.id)} function create_each_block$2(key_1, ctx) { let div3; let div0; let figure; let link; let t0; let div2; let div1; let each_blocks = []; let each_1_lookup = new Map(); let t1; let current; link = new Link({ props: { to: "/post/" + /*post*/ ctx[6].id, $$slots: { default: [create_default_slot_1] }, $$scope: { ctx } }, $$inline: true }); let each_value_1 = /*post*/ ctx[6].tags; validate_each_argument(each_value_1); const get_key = ctx => /*tag*/ ctx[9]; validate_each_keys(ctx, each_value_1, get_each_context_1$1, get_key); for (let i = 0; i < each_value_1.length; i += 1) { let child_ctx = get_each_context_1$1(ctx, each_value_1, i); let key = get_key(child_ctx); each_1_lookup.set(key, each_blocks[i] = create_each_block_1$1(key, child_ctx)); } const block = { key: key_1, first: null, c: function create() { div3 = element("div"); div0 = element("div"); figure = element("figure"); create_component(link.$$.fragment); t0 = space(); div2 = element("div"); div1 = element("div"); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } t1 = space(); attr_dev(figure, "class", "image"); add_location(figure, file$7, 86, 24, 3357); attr_dev(div0, "class", "card-image"); add_location(div0, file$7, 85, 20, 3308); attr_dev(div1, "class", "content"); add_location(div1, file$7, 93, 24, 3680); attr_dev(div2, "class", "card-content"); add_location(div2, file$7, 92, 20, 3629); attr_dev(div3, "class", "column is-one-quarter card"); add_location(div3, file$7, 84, 16, 3247); this.first = div3; }, m: function mount(target, anchor) { insert_dev(target, div3, anchor); append_dev(div3, div0); append_dev(div0, figure); mount_component(link, figure, null); append_dev(div3, t0); append_dev(div3, div2); append_dev(div2, div1); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(div1, null); } append_dev(div3, t1); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*posts*/ 1) link_changes.to = "/post/" + /*post*/ ctx[6].id; if (dirty & /*$$scope, posts*/ 32769) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); if (dirty & /*posts*/ 1) { each_value_1 = /*post*/ ctx[6].tags; validate_each_argument(each_value_1); group_outros(); validate_each_keys(ctx, each_value_1, get_each_context_1$1, get_key); each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value_1, each_1_lookup, div1, outro_and_destroy_block, create_each_block_1$1, null, get_each_context_1$1); check_outros(); } }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); for (let i = 0; i < each_value_1.length; i += 1) { transition_in(each_blocks[i]); } current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); for (let i = 0; i < each_blocks.length; i += 1) { transition_out(each_blocks[i]); } current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(div3); destroy_component(link); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].d(); } } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block$2.name, type: "each", source: "(84:12) {#each posts as post (post.id)}", ctx }); return block; } function create_fragment$8(ctx) { let section; let div1; let nav; let t0; let t1; let ul; let t2; let t3; let t4; let div0; let each_blocks = []; let each1_lookup = new Map(); let current; let if_block0 = /*page*/ ctx[1] > 1 && create_if_block_5(ctx); let if_block1 = /*page*/ ctx[1] < /*totalPages*/ ctx[2] && create_if_block_4(ctx); let if_block2 = /*page*/ ctx[1] > 3 && create_if_block_3$1(ctx); let each_value_2 = [...Array(5).keys()].map(/*func*/ ctx[5]); validate_each_argument(each_value_2); let each_blocks_1 = []; for (let i = 0; i < each_value_2.length; i += 1) { each_blocks_1[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i)); } const out = i => transition_out(each_blocks_1[i], 1, 1, () => { each_blocks_1[i] = null; }); let if_block3 = /*totalPages*/ ctx[2] - /*page*/ ctx[1] > 2 && create_if_block$3(ctx); let each_value = /*posts*/ ctx[0]; validate_each_argument(each_value); const get_key = ctx => /*post*/ ctx[6].id; validate_each_keys(ctx, each_value, get_each_context$2, get_key); for (let i = 0; i < each_value.length; i += 1) { let child_ctx = get_each_context$2(ctx, each_value, i); let key = get_key(child_ctx); each1_lookup.set(key, each_blocks[i] = create_each_block$2(key, child_ctx)); } const block = { c: function create() { section = element("section"); div1 = element("div"); nav = element("nav"); if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); ul = element("ul"); if (if_block2) if_block2.c(); t2 = space(); for (let i = 0; i < each_blocks_1.length; i += 1) { each_blocks_1[i].c(); } t3 = space(); if (if_block3) if_block3.c(); t4 = space(); div0 = element("div"); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } attr_dev(ul, "class", "pagination-list"); add_location(ul, file$7, 29, 12, 934); attr_dev(nav, "class", "pagination"); attr_dev(nav, "role", "navigation"); attr_dev(nav, "aria-label", "pagination"); add_location(nav, file$7, 12, 8, 280); attr_dev(div0, "class", "columns is-multiline"); add_location(div0, file$7, 82, 8, 3152); attr_dev(div1, "class", "container"); add_location(div1, file$7, 11, 4, 248); attr_dev(section, "class", "section"); add_location(section, file$7, 10, 0, 218); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, section, anchor); append_dev(section, div1); append_dev(div1, nav); if (if_block0) if_block0.m(nav, null); append_dev(nav, t0); if (if_block1) if_block1.m(nav, null); append_dev(nav, t1); append_dev(nav, ul); if (if_block2) if_block2.m(ul, null); append_dev(ul, t2); for (let i = 0; i < each_blocks_1.length; i += 1) { each_blocks_1[i].m(ul, null); } append_dev(ul, t3); if (if_block3) if_block3.m(ul, null); append_dev(div1, t4); append_dev(div1, div0); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(div0, null); } current = true; }, p: function update(ctx, [dirty]) { if (/*page*/ ctx[1] > 1) { if (if_block0) { if_block0.p(ctx, dirty); if (dirty & /*page*/ 2) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_5(ctx); if_block0.c(); transition_in(if_block0, 1); if_block0.m(nav, t0); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } if (/*page*/ ctx[1] < /*totalPages*/ ctx[2]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*page, totalPages*/ 6) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_4(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(nav, t1); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (/*page*/ ctx[1] > 3) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty & /*page*/ 2) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block_3$1(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(ul, t2); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } if (dirty & /*url, Array, page, handlePage, totalPages*/ 30) { each_value_2 = [...Array(5).keys()].map(/*func*/ ctx[5]); validate_each_argument(each_value_2); let i; for (i = 0; i < each_value_2.length; i += 1) { const child_ctx = get_each_context_2(ctx, each_value_2, i); if (each_blocks_1[i]) { each_blocks_1[i].p(child_ctx, dirty); transition_in(each_blocks_1[i], 1); } else { each_blocks_1[i] = create_each_block_2(child_ctx); each_blocks_1[i].c(); transition_in(each_blocks_1[i], 1); each_blocks_1[i].m(ul, t3); } } group_outros(); for (i = each_value_2.length; i < each_blocks_1.length; i += 1) { out(i); } check_outros(); } if (/*totalPages*/ ctx[2] - /*page*/ ctx[1] > 2) { if (if_block3) { if_block3.p(ctx, dirty); if (dirty & /*totalPages, page*/ 6) { transition_in(if_block3, 1); } } else { if_block3 = create_if_block$3(ctx); if_block3.c(); transition_in(if_block3, 1); if_block3.m(ul, null); } } else if (if_block3) { group_outros(); transition_out(if_block3, 1, 1, () => { if_block3 = null; }); check_outros(); } if (dirty & /*posts*/ 1) { each_value = /*posts*/ ctx[0]; validate_each_argument(each_value); group_outros(); validate_each_keys(ctx, each_value, get_each_context$2, get_key); each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each1_lookup, div0, outro_and_destroy_block, create_each_block$2, null, get_each_context$2); check_outros(); } }, i: function intro(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); transition_in(if_block2); for (let i = 0; i < each_value_2.length; i += 1) { transition_in(each_blocks_1[i]); } transition_in(if_block3); for (let i = 0; i < each_value.length; i += 1) { transition_in(each_blocks[i]); } current = true; }, o: function outro(local) { transition_out(if_block0); transition_out(if_block1); transition_out(if_block2); each_blocks_1 = each_blocks_1.filter(Boolean); for (let i = 0; i < each_blocks_1.length; i += 1) { transition_out(each_blocks_1[i]); } transition_out(if_block3); for (let i = 0; i < each_blocks.length; i += 1) { transition_out(each_blocks[i]); } current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(section); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); destroy_each(each_blocks_1, detaching); if (if_block3) if_block3.d(); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].d(); } } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$8.name, type: "component", source: "", ctx }); return block; } function instance$8($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("PostPaginator", slots, []); let { posts = [] } = $$props; let { page = 1 } = $$props; let { totalPages = 1 } = $$props; let { handlePage = i => { } } = $$props; let { url = "/posts" } = $$props; const writable_props = ["posts", "page", "totalPages", "handlePage", "url"]; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); const func = x => x + page - 2; $$self.$$set = $$props => { if ("posts" in $$props) $$invalidate(0, posts = $$props.posts); if ("page" in $$props) $$invalidate(1, page = $$props.page); if ("totalPages" in $$props) $$invalidate(2, totalPages = $$props.totalPages); if ("handlePage" in $$props) $$invalidate(3, handlePage = $$props.handlePage); if ("url" in $$props) $$invalidate(4, url = $$props.url); }; $$self.$capture_state = () => ({ Link, posts, page, totalPages, handlePage, url }); $$self.$inject_state = $$props => { if ("posts" in $$props) $$invalidate(0, posts = $$props.posts); if ("page" in $$props) $$invalidate(1, page = $$props.page); if ("totalPages" in $$props) $$invalidate(2, totalPages = $$props.totalPages); if ("handlePage" in $$props) $$invalidate(3, handlePage = $$props.handlePage); if ("url" in $$props) $$invalidate(4, url = $$props.url); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [posts, page, totalPages, handlePage, url, func]; } class PostPaginator extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$8, create_fragment$8, safe_not_equal, { posts: 0, page: 1, totalPages: 2, handlePage: 3, url: 4 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "PostPaginator", options, id: create_fragment$8.name }); } get posts() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set posts(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get page() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set page(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get totalPages() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set totalPages(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get handlePage() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set handlePage(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get url() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set url(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } /* src/routes/Posts.svelte generated by Svelte v3.38.2 */ const file$6 = "src/routes/Posts.svelte"; function create_fragment$7(ctx) { let section; let div; let p; let t1; let postpaginator; let current; postpaginator = new PostPaginator({ props: { url: "/posts", posts: /*posts*/ ctx[2], page: /*page*/ ctx[0], totalPages: /*totalPages*/ ctx[1], handlePage: /*handlePage*/ ctx[3] }, $$inline: true }); const block = { c: function create() { section = element("section"); div = element("div"); p = element("p"); p.textContent = "Posts"; t1 = space(); create_component(postpaginator.$$.fragment); attr_dev(p, "class", "title"); add_location(p, file$6, 38, 8, 953); attr_dev(div, "class", "hero-body"); add_location(div, file$6, 37, 4, 921); attr_dev(section, "class", "hero is-primary"); add_location(section, file$6, 36, 0, 883); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, section, anchor); append_dev(section, div); append_dev(div, p); insert_dev(target, t1, anchor); mount_component(postpaginator, target, anchor); current = true; }, p: function update(ctx, [dirty]) { const postpaginator_changes = {}; if (dirty & /*posts*/ 4) postpaginator_changes.posts = /*posts*/ ctx[2]; if (dirty & /*page*/ 1) postpaginator_changes.page = /*page*/ ctx[0]; if (dirty & /*totalPages*/ 2) postpaginator_changes.totalPages = /*totalPages*/ ctx[1]; postpaginator.$set(postpaginator_changes); }, i: function intro(local) { if (current) return; transition_in(postpaginator.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(postpaginator.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(section); if (detaching) detach_dev(t1); destroy_component(postpaginator, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$7.name, type: "component", source: "", ctx }); return block; } function instance$7($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Posts", slots, []); let { location } = $$props; let page = 1; let totalPages = 1; let posts = []; const getData = async () => { const data = await getPosts({ page }); if (Array.isArray(data.posts)) { $$invalidate(2, posts = data.posts); $$invalidate(1, totalPages = data.totalPage); } }; onMount(() => { let queryParams; queryParams = queryString.parse(location.search); if (queryParams.page) { $$invalidate(0, page = parseInt(queryParams.page)); } getData(); }); const handlePage = i => { return () => { $$invalidate(0, page = i); getData(); }; }; const writable_props = ["location"]; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); $$self.$$set = $$props => { if ("location" in $$props) $$invalidate(4, location = $$props.location); }; $$self.$capture_state = () => ({ onMount, getPosts, Link, queryString, PostPaginator, location, page, totalPages, posts, getData, handlePage }); $$self.$inject_state = $$props => { if ("location" in $$props) $$invalidate(4, location = $$props.location); if ("page" in $$props) $$invalidate(0, page = $$props.page); if ("totalPages" in $$props) $$invalidate(1, totalPages = $$props.totalPages); if ("posts" in $$props) $$invalidate(2, posts = $$props.posts); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [page, totalPages, posts, handlePage, location]; } class Posts extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$7, create_fragment$7, safe_not_equal, { location: 4 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Posts", options, id: create_fragment$7.name }); const { ctx } = this.$$; const props = options.props || {}; if (/*location*/ ctx[4] === undefined && !("location" in props)) { console.warn(" was created without expected prop 'location'"); } } get location() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set location(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } /* src/routes/Post.svelte generated by Svelte v3.38.2 */ const file$5 = "src/routes/Post.svelte"; function get_each_context$1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[4] = list[i]; return child_ctx; } // (25:8) {#if post} function create_if_block_1$2(ctx) { let p; let t0; let t1_value = /*post*/ ctx[0].id + ""; let t1; const block = { c: function create() { p = element("p"); t0 = text("Post ID: "); t1 = text(t1_value); attr_dev(p, "class", "title"); add_location(p, file$5, 25, 6, 545); }, m: function mount(target, anchor) { insert_dev(target, p, anchor); append_dev(p, t0); append_dev(p, t1); }, p: function update(ctx, dirty) { if (dirty & /*post*/ 1 && t1_value !== (t1_value = /*post*/ ctx[0].id + "")) set_data_dev(t1, t1_value); }, d: function destroy(detaching) { if (detaching) detach_dev(p); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1$2.name, type: "if", source: "(25:8) {#if post}", ctx }); return block; } // (32:0) {#if post} function create_if_block$2(ctx) { let div3; let section; let div2; let div0; let p0; let t0; let a; let t1_value = /*trimUrl*/ ctx[1](/*post*/ ctx[0].source_url) + ""; let t1; let a_href_value; let t2; let p1; let t3; let each_blocks = []; let each_1_lookup = new Map(); let t4; let div1; let figure; let img; let img_alt_value; let img_src_value; let current; let each_value = /*post*/ ctx[0].tags; validate_each_argument(each_value); const get_key = ctx => /*tag*/ ctx[4]; validate_each_keys(ctx, each_value, get_each_context$1, get_key); for (let i = 0; i < each_value.length; i += 1) { let child_ctx = get_each_context$1(ctx, each_value, i); let key = get_key(child_ctx); each_1_lookup.set(key, each_blocks[i] = create_each_block$1(key, child_ctx)); } const block = { c: function create() { div3 = element("div"); section = element("section"); div2 = element("div"); div0 = element("div"); p0 = element("p"); t0 = text("Source URL: "); a = element("a"); t1 = text(t1_value); t2 = space(); p1 = element("p"); t3 = text("Tags: \n "); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } t4 = space(); div1 = element("div"); figure = element("figure"); img = element("img"); attr_dev(a, "href", a_href_value = /*post*/ ctx[0].source_url); add_location(a, file$5, 37, 36, 840); add_location(p0, file$5, 36, 20, 800); add_location(p1, file$5, 39, 20, 944); attr_dev(div0, "class", "column is-one-third box"); add_location(div0, file$5, 35, 12, 742); attr_dev(img, "alt", img_alt_value = /*post*/ ctx[0].id); if (img.src !== (img_src_value = /*post*/ ctx[0].image_path)) attr_dev(img, "src", img_src_value); add_location(img, file$5, 52, 20, 1395); attr_dev(figure, "class", "image"); add_location(figure, file$5, 51, 16, 1352); attr_dev(div1, "class", "column"); add_location(div1, file$5, 50, 12, 1315); attr_dev(div2, "class", "columns"); add_location(div2, file$5, 34, 8, 708); attr_dev(section, "class", "section"); add_location(section, file$5, 33, 4, 674); attr_dev(div3, "class", "container"); add_location(div3, file$5, 32, 0, 646); }, m: function mount(target, anchor) { insert_dev(target, div3, anchor); append_dev(div3, section); append_dev(section, div2); append_dev(div2, div0); append_dev(div0, p0); append_dev(p0, t0); append_dev(p0, a); append_dev(a, t1); append_dev(div0, t2); append_dev(div0, p1); append_dev(p1, t3); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(p1, null); } append_dev(div2, t4); append_dev(div2, div1); append_dev(div1, figure); append_dev(figure, img); current = true; }, p: function update(ctx, dirty) { if ((!current || dirty & /*post*/ 1) && t1_value !== (t1_value = /*trimUrl*/ ctx[1](/*post*/ ctx[0].source_url) + "")) set_data_dev(t1, t1_value); if (!current || dirty & /*post*/ 1 && a_href_value !== (a_href_value = /*post*/ ctx[0].source_url)) { attr_dev(a, "href", a_href_value); } if (dirty & /*post*/ 1) { each_value = /*post*/ ctx[0].tags; validate_each_argument(each_value); group_outros(); validate_each_keys(ctx, each_value, get_each_context$1, get_key); each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, p1, outro_and_destroy_block, create_each_block$1, null, get_each_context$1); check_outros(); } if (!current || dirty & /*post*/ 1 && img_alt_value !== (img_alt_value = /*post*/ ctx[0].id)) { attr_dev(img, "alt", img_alt_value); } if (!current || dirty & /*post*/ 1 && img.src !== (img_src_value = /*post*/ ctx[0].image_path)) { attr_dev(img, "src", img_src_value); } }, i: function intro(local) { if (current) return; for (let i = 0; i < each_value.length; i += 1) { transition_in(each_blocks[i]); } current = true; }, o: function outro(local) { for (let i = 0; i < each_blocks.length; i += 1) { transition_out(each_blocks[i]); } current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(div3); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].d(); } } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block$2.name, type: "if", source: "(32:0) {#if post}", ctx }); return block; } // (45:32) function create_default_slot$1(ctx) { let t_value = /*tag*/ ctx[4] + ""; let t; const block = { c: function create() { t = text(t_value); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, p: function update(ctx, dirty) { if (dirty & /*post*/ 1 && t_value !== (t_value = /*tag*/ ctx[4] + "")) set_data_dev(t, t_value); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot$1.name, type: "slot", source: "(45:32) ", ctx }); return block; } // (42:24) {#each post.tags as tag (tag)} function create_each_block$1(key_1, ctx) { let ul; let li; let link; let t; let current; link = new Link({ props: { to: "/tag/" + /*tag*/ ctx[4], $$slots: { default: [create_default_slot$1] }, $$scope: { ctx } }, $$inline: true }); const block = { key: key_1, first: null, c: function create() { ul = element("ul"); li = element("li"); create_component(link.$$.fragment); t = space(); add_location(li, file$5, 43, 28, 1091); add_location(ul, file$5, 42, 24, 1058); this.first = ul; }, m: function mount(target, anchor) { insert_dev(target, ul, anchor); append_dev(ul, li); mount_component(link, li, null); append_dev(ul, t); current = true; }, p: function update(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*post*/ 1) link_changes.to = "/tag/" + /*tag*/ ctx[4]; if (dirty & /*$$scope, post*/ 129) { link_changes.$$scope = { dirty, ctx }; } link.$set(link_changes); }, i: function intro(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(link.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(ul); destroy_component(link); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block$1.name, type: "each", source: "(42:24) {#each post.tags as tag (tag)}", ctx }); return block; } function create_fragment$6(ctx) { let section; let div; let t; let if_block1_anchor; let current; let if_block0 = /*post*/ ctx[0] && create_if_block_1$2(ctx); let if_block1 = /*post*/ ctx[0] && create_if_block$2(ctx); const block = { c: function create() { section = element("section"); div = element("div"); if (if_block0) if_block0.c(); t = space(); if (if_block1) if_block1.c(); if_block1_anchor = empty(); attr_dev(div, "class", "hero-body"); add_location(div, file$5, 23, 4, 496); attr_dev(section, "class", "hero is-primary"); add_location(section, file$5, 22, 0, 458); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, section, anchor); append_dev(section, div); if (if_block0) if_block0.m(div, null); insert_dev(target, t, anchor); if (if_block1) if_block1.m(target, anchor); insert_dev(target, if_block1_anchor, anchor); current = true; }, p: function update(ctx, [dirty]) { if (/*post*/ ctx[0]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$2(ctx); if_block0.c(); if_block0.m(div, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*post*/ ctx[0]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*post*/ 1) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$2(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } }, i: function intro(local) { if (current) return; transition_in(if_block1); current = true; }, o: function outro(local) { transition_out(if_block1); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(section); if (if_block0) if_block0.d(); if (detaching) detach_dev(t); if (if_block1) if_block1.d(detaching); if (detaching) detach_dev(if_block1_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$6.name, type: "component", source: "", ctx }); return block; } function instance$6($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Post", slots, []); let { id } = $$props; let post; const getData = async () => { const data = await getPost({ id }); $$invalidate(0, post = data); }; const trimUrl = str => { if (str.length > 30) { return str.substring(0, 30) + "..."; } return str; }; onMount(() => { getData(); }); const writable_props = ["id"]; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); $$self.$$set = $$props => { if ("id" in $$props) $$invalidate(2, id = $$props.id); }; $$self.$capture_state = () => ({ onMount, Link, getPost, id, post, getData, trimUrl }); $$self.$inject_state = $$props => { if ("id" in $$props) $$invalidate(2, id = $$props.id); if ("post" in $$props) $$invalidate(0, post = $$props.post); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [post, trimUrl, id]; } class Post extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$6, create_fragment$6, safe_not_equal, { id: 2 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Post", options, id: create_fragment$6.name }); const { ctx } = this.$$; const props = options.props || {}; if (/*id*/ ctx[2] === undefined && !("id" in props)) { console.warn(" was created without expected prop 'id'"); } } get id() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set id(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } /* src/routes/Login.svelte generated by Svelte v3.38.2 */ const file$4 = "src/routes/Login.svelte"; function create_fragment$5(ctx) { let div6; let form; let div1; let label0; let t1; let div0; let input0; let t2; let div3; let label1; let t4; let div2; let input1; let t5; let div5; let div4; let button; let mounted; let dispose; const block = { c: function create() { div6 = element("div"); form = element("form"); div1 = element("div"); label0 = element("label"); label0.textContent = "Username"; t1 = space(); div0 = element("div"); input0 = element("input"); t2 = space(); div3 = element("div"); label1 = element("label"); label1.textContent = "Password"; t4 = space(); div2 = element("div"); input1 = element("input"); t5 = space(); div5 = element("div"); div4 = element("div"); button = element("button"); button.textContent = "Login"; attr_dev(label0, "for", "username"); attr_dev(label0, "class", "label"); add_location(label0, file$4, 16, 12, 391); attr_dev(input0, "id", "username"); attr_dev(input0, "class", "input"); attr_dev(input0, "type", "text"); attr_dev(input0, "placeholder", "Username"); input0.required = true; add_location(input0, file$4, 18, 16, 494); attr_dev(div0, "class", "control"); add_location(div0, file$4, 17, 12, 456); attr_dev(div1, "class", "field"); add_location(div1, file$4, 15, 8, 359); attr_dev(label1, "for", "password"); attr_dev(label1, "class", "label"); add_location(label1, file$4, 29, 12, 808); attr_dev(input1, "id", "password"); attr_dev(input1, "class", "input"); attr_dev(input1, "type", "password"); attr_dev(input1, "placeholder", "Password"); input1.required = true; add_location(input1, file$4, 31, 16, 911); attr_dev(div2, "class", "control"); add_location(div2, file$4, 30, 12, 873); attr_dev(div3, "class", "field"); add_location(div3, file$4, 28, 8, 776); attr_dev(button, "class", "button is-link"); add_location(button, file$4, 43, 16, 1267); attr_dev(div4, "class", "control"); add_location(div4, file$4, 42, 12, 1229); attr_dev(div5, "class", "field"); add_location(div5, file$4, 41, 8, 1197); add_location(form, file$4, 14, 4, 309); attr_dev(div6, "class", "container"); add_location(div6, file$4, 13, 0, 281); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, div6, anchor); append_dev(div6, form); append_dev(form, div1); append_dev(div1, label0); append_dev(div1, t1); append_dev(div1, div0); append_dev(div0, input0); set_input_value(input0, /*username*/ ctx[0]); append_dev(form, t2); append_dev(form, div3); append_dev(div3, label1); append_dev(div3, t4); append_dev(div3, div2); append_dev(div2, input1); set_input_value(input1, /*password*/ ctx[1]); append_dev(form, t5); append_dev(form, div5); append_dev(div5, div4); append_dev(div4, button); if (!mounted) { dispose = [ listen_dev(input0, "input", /*input0_input_handler*/ ctx[3]), listen_dev(input1, "input", /*input1_input_handler*/ ctx[4]), listen_dev(form, "submit", prevent_default(/*doLogin*/ ctx[2]), false, true, false) ]; mounted = true; } }, p: function update(ctx, [dirty]) { if (dirty & /*username*/ 1 && input0.value !== /*username*/ ctx[0]) { set_input_value(input0, /*username*/ ctx[0]); } if (dirty & /*password*/ 2 && input1.value !== /*password*/ ctx[1]) { set_input_value(input1, /*password*/ ctx[1]); } }, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(div6); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$5.name, type: "component", source: "", ctx }); return block; } function instance$5($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Login", slots, []); let username = ""; let password = ""; const doLogin = async () => { await login({ username, password }); navigate("/"); }; const writable_props = []; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); function input0_input_handler() { username = this.value; $$invalidate(0, username); } function input1_input_handler() { password = this.value; $$invalidate(1, password); } $$self.$capture_state = () => ({ login, navigate, username, password, doLogin }); $$self.$inject_state = $$props => { if ("username" in $$props) $$invalidate(0, username = $$props.username); if ("password" in $$props) $$invalidate(1, password = $$props.password); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [username, password, doLogin, input0_input_handler, input1_input_handler]; } class Login extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$5, create_fragment$5, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Login", options, id: create_fragment$5.name }); } } /* src/routes/Logout.svelte generated by Svelte v3.38.2 */ function create_fragment$4(ctx) { const block = { c: noop, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: noop, p: noop, i: noop, o: noop, d: noop }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$4.name, type: "component", source: "", ctx }); return block; } function instance$4($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Logout", slots, []); onMount(() => { token$1.set(""); navigate("/"); }); const writable_props = []; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); $$self.$capture_state = () => ({ token: token$1, navigate, onMount }); return []; } class Logout extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$4, create_fragment$4, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Logout", options, id: create_fragment$4.name }); } } /* src/routes/Tag.svelte generated by Svelte v3.38.2 */ const file$3 = "src/routes/Tag.svelte"; function create_fragment$3(ctx) { let section; let div; let p0; let t0; let t1; let p1; let t3; let postpaginator; let current; postpaginator = new PostPaginator({ props: { url: "/tag/" + /*id*/ ctx[0], posts: /*posts*/ ctx[3], page: /*page*/ ctx[1], totalPages: /*totalPages*/ ctx[2], handlePage: /*handlePage*/ ctx[4] }, $$inline: true }); const block = { c: function create() { section = element("section"); div = element("div"); p0 = element("p"); t0 = text(/*id*/ ctx[0]); t1 = space(); p1 = element("p"); p1.textContent = "Tag"; t3 = space(); create_component(postpaginator.$$.fragment); attr_dev(p0, "class", "title"); add_location(p0, file$3, 39, 8, 945); attr_dev(p1, "class", "subtitle"); add_location(p1, file$3, 42, 8, 1001); attr_dev(div, "class", "hero-body"); add_location(div, file$3, 38, 4, 913); attr_dev(section, "class", "hero is-primary"); add_location(section, file$3, 37, 0, 875); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, section, anchor); append_dev(section, div); append_dev(div, p0); append_dev(p0, t0); append_dev(div, t1); append_dev(div, p1); insert_dev(target, t3, anchor); mount_component(postpaginator, target, anchor); current = true; }, p: function update(ctx, [dirty]) { if (!current || dirty & /*id*/ 1) set_data_dev(t0, /*id*/ ctx[0]); const postpaginator_changes = {}; if (dirty & /*id*/ 1) postpaginator_changes.url = "/tag/" + /*id*/ ctx[0]; if (dirty & /*posts*/ 8) postpaginator_changes.posts = /*posts*/ ctx[3]; if (dirty & /*page*/ 2) postpaginator_changes.page = /*page*/ ctx[1]; if (dirty & /*totalPages*/ 4) postpaginator_changes.totalPages = /*totalPages*/ ctx[2]; postpaginator.$set(postpaginator_changes); }, i: function intro(local) { if (current) return; transition_in(postpaginator.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(postpaginator.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(section); if (detaching) detach_dev(t3); destroy_component(postpaginator, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$3.name, type: "component", source: "", ctx }); return block; } function instance$3($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Tag", slots, []); let { location } = $$props; let { id } = $$props; let page = 1; let totalPages = 1; let posts = []; const getData = async () => { const data = await getPostsTag({ page, tag: id }); if (Array.isArray(data.posts)) { $$invalidate(3, posts = data.posts); $$invalidate(2, totalPages = data.totalPage); } }; onMount(() => { let queryParams; queryParams = queryString.parse(location.search); if (queryParams.page) { $$invalidate(1, page = parseInt(queryParams.page)); } getData(); }); const handlePage = i => { return () => { $$invalidate(1, page = i); getData(); }; }; const writable_props = ["location", "id"]; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); $$self.$$set = $$props => { if ("location" in $$props) $$invalidate(5, location = $$props.location); if ("id" in $$props) $$invalidate(0, id = $$props.id); }; $$self.$capture_state = () => ({ onMount, getPostsTag, PostPaginator, queryString, location, id, page, totalPages, posts, getData, handlePage }); $$self.$inject_state = $$props => { if ("location" in $$props) $$invalidate(5, location = $$props.location); if ("id" in $$props) $$invalidate(0, id = $$props.id); if ("page" in $$props) $$invalidate(1, page = $$props.page); if ("totalPages" in $$props) $$invalidate(2, totalPages = $$props.totalPages); if ("posts" in $$props) $$invalidate(3, posts = $$props.posts); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [id, page, totalPages, posts, handlePage, location]; } class Tag extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$3, create_fragment$3, safe_not_equal, { location: 5, id: 0 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Tag", options, id: create_fragment$3.name }); const { ctx } = this.$$; const props = options.props || {}; if (/*location*/ ctx[5] === undefined && !("location" in props)) { console.warn(" was created without expected prop 'location'"); } if (/*id*/ ctx[0] === undefined && !("id" in props)) { console.warn(" was created without expected prop 'id'"); } } get location() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set location(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get id() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set id(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } /* node_modules/svelte-tags-input/src/Tags.svelte generated by Svelte v3.38.2 */ const { console: console_1 } = globals; const file$2 = "node_modules/svelte-tags-input/src/Tags.svelte"; function get_each_context(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[37] = list[i]; child_ctx[39] = i; return child_ctx; } function get_each_context_1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[8] = list[i]; child_ctx[41] = i; return child_ctx; } // (309:4) {#if tags.length > 0} function create_if_block_1$1(ctx) { let each_1_anchor; let each_value_1 = /*tags*/ ctx[0]; validate_each_argument(each_value_1); let each_blocks = []; for (let i = 0; i < each_value_1.length; i += 1) { each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); } const block = { c: function create() { for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } each_1_anchor = empty(); }, m: function mount(target, anchor) { for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(target, anchor); } insert_dev(target, each_1_anchor, anchor); }, p: function update(ctx, dirty) { if (dirty[0] & /*removeTag, disable, tags, autoCompleteKey*/ 2121) { each_value_1 = /*tags*/ ctx[0]; validate_each_argument(each_value_1); let i; for (i = 0; i < each_value_1.length; i += 1) { const child_ctx = get_each_context_1(ctx, each_value_1, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { each_blocks[i] = create_each_block_1(child_ctx); each_blocks[i].c(); each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); } } for (; i < each_blocks.length; i += 1) { each_blocks[i].d(1); } each_blocks.length = each_value_1.length; } }, d: function destroy(detaching) { destroy_each(each_blocks, detaching); if (detaching) detach_dev(each_1_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1$1.name, type: "if", source: "(309:4) {#if tags.length > 0}", ctx }); return block; } // (314:16) {:else} function create_else_block(ctx) { let t_value = /*tag*/ ctx[8][/*autoCompleteKey*/ ctx[3]] + ""; let t; const block = { c: function create() { t = text(t_value); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, p: function update(ctx, dirty) { if (dirty[0] & /*tags, autoCompleteKey*/ 9 && t_value !== (t_value = /*tag*/ ctx[8][/*autoCompleteKey*/ ctx[3]] + "")) set_data_dev(t, t_value); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_else_block.name, type: "else", source: "(314:16) {:else}", ctx }); return block; } // (312:16) {#if typeof tag === 'string'} function create_if_block_3(ctx) { let t_value = /*tag*/ ctx[8] + ""; let t; const block = { c: function create() { t = text(t_value); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, p: function update(ctx, dirty) { if (dirty[0] & /*tags*/ 1 && t_value !== (t_value = /*tag*/ ctx[8] + "")) set_data_dev(t, t_value); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_3.name, type: "if", source: "(312:16) {#if typeof tag === 'string'}", ctx }); return block; } // (317:16) {#if !disable} function create_if_block_2(ctx) { let span; let mounted; let dispose; function click_handler() { return /*click_handler*/ ctx[27](/*i*/ ctx[41]); } const block = { c: function create() { span = element("span"); span.textContent = "×"; attr_dev(span, "class", "svelte-tags-input-tag-remove svelte-1xz5xok"); add_location(span, file$2, 317, 16, 9118); }, m: function mount(target, anchor) { insert_dev(target, span, anchor); if (!mounted) { dispose = listen_dev(span, "click", click_handler, false, false, false); mounted = true; } }, p: function update(new_ctx, dirty) { ctx = new_ctx; }, d: function destroy(detaching) { if (detaching) detach_dev(span); mounted = false; dispose(); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_2.name, type: "if", source: "(317:16) {#if !disable}", ctx }); return block; } // (310:8) {#each tags as tag, i} function create_each_block_1(ctx) { let span; let t0; let t1; function select_block_type(ctx, dirty) { if (typeof /*tag*/ ctx[8] === "string") return create_if_block_3; return create_else_block; } let current_block_type = select_block_type(ctx); let if_block0 = current_block_type(ctx); let if_block1 = !/*disable*/ ctx[6] && create_if_block_2(ctx); const block = { c: function create() { span = element("span"); if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); attr_dev(span, "class", "svelte-tags-input-tag svelte-1xz5xok"); add_location(span, file$2, 310, 12, 8866); }, m: function mount(target, anchor) { insert_dev(target, span, anchor); if_block0.m(span, null); append_dev(span, t0); if (if_block1) if_block1.m(span, null); append_dev(span, t1); }, p: function update(ctx, dirty) { if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block0) { if_block0.p(ctx, dirty); } else { if_block0.d(1); if_block0 = current_block_type(ctx); if (if_block0) { if_block0.c(); if_block0.m(span, t0); } } if (!/*disable*/ ctx[6]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_2(ctx); if_block1.c(); if_block1.m(span, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } }, d: function destroy(detaching) { if (detaching) detach_dev(span); if_block0.d(); if (if_block1) if_block1.d(); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block_1.name, type: "each", source: "(310:8) {#each tags as tag, i}", ctx }); return block; } // (339:0) {#if autoComplete && arrelementsmatch.length > 0} function create_if_block$1(ctx) { let div; let ul; let ul_id_value; let each_value = /*arrelementsmatch*/ ctx[7]; validate_each_argument(each_value); let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); } const block = { c: function create() { div = element("div"); ul = element("ul"); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } attr_dev(ul, "id", ul_id_value = "" + (/*id*/ ctx[5] + "_matchs")); attr_dev(ul, "class", "svelte-tags-input-matchs svelte-1xz5xok"); add_location(ul, file$2, 340, 8, 9758); attr_dev(div, "class", "svelte-tags-input-matchs-parent svelte-1xz5xok"); add_location(div, file$2, 339, 4, 9703); }, m: function mount(target, anchor) { insert_dev(target, div, anchor); append_dev(div, ul); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(ul, null); } }, p: function update(ctx, dirty) { if (dirty[0] & /*navigateAutoComplete, arrelementsmatch, addTag*/ 66688) { each_value = /*arrelementsmatch*/ ctx[7]; validate_each_argument(each_value); let i; for (i = 0; i < each_value.length; i += 1) { const child_ctx = get_each_context(ctx, each_value, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { each_blocks[i] = create_each_block(child_ctx); each_blocks[i].c(); each_blocks[i].m(ul, null); } } for (; i < each_blocks.length; i += 1) { each_blocks[i].d(1); } each_blocks.length = each_value.length; } if (dirty[0] & /*id*/ 32 && ul_id_value !== (ul_id_value = "" + (/*id*/ ctx[5] + "_matchs"))) { attr_dev(ul, "id", ul_id_value); } }, d: function destroy(detaching) { if (detaching) detach_dev(div); destroy_each(each_blocks, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block$1.name, type: "if", source: "(339:0) {#if autoComplete && arrelementsmatch.length > 0}", ctx }); return block; } // (342:12) {#each arrelementsmatch as element, index} function create_each_block(ctx) { let li; let html_tag; let raw_value = /*element*/ ctx[37].search + ""; let t; let mounted; let dispose; function keydown_handler() { return /*keydown_handler*/ ctx[30](/*index*/ ctx[39], /*element*/ ctx[37]); } function click_handler_1() { return /*click_handler_1*/ ctx[31](/*element*/ ctx[37]); } const block = { c: function create() { li = element("li"); t = space(); html_tag = new HtmlTag(t); attr_dev(li, "tabindex", "-1"); attr_dev(li, "class", "svelte-1xz5xok"); add_location(li, file$2, 342, 16, 9886); }, m: function mount(target, anchor) { insert_dev(target, li, anchor); html_tag.m(raw_value, li); append_dev(li, t); if (!mounted) { dispose = [ listen_dev(li, "keydown", keydown_handler, false, false, false), listen_dev(li, "click", click_handler_1, false, false, false) ]; mounted = true; } }, p: function update(new_ctx, dirty) { ctx = new_ctx; if (dirty[0] & /*arrelementsmatch*/ 128 && raw_value !== (raw_value = /*element*/ ctx[37].search + "")) html_tag.p(raw_value); }, d: function destroy(detaching) { if (detaching) detach_dev(li); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block.name, type: "each", source: "(342:12) {#each arrelementsmatch as element, index}", ctx }); return block; } function create_fragment$2(ctx) { let div; let t0; let input; let t1; let if_block1_anchor; let mounted; let dispose; let if_block0 = /*tags*/ ctx[0].length > 0 && create_if_block_1$1(ctx); let if_block1 = /*autoComplete*/ ctx[2] && /*arrelementsmatch*/ ctx[7].length > 0 && create_if_block$1(ctx); const block = { c: function create() { div = element("div"); if (if_block0) if_block0.c(); t0 = space(); input = element("input"); t1 = space(); if (if_block1) if_block1.c(); if_block1_anchor = empty(); attr_dev(input, "type", "text"); attr_dev(input, "id", /*id*/ ctx[5]); attr_dev(input, "name", /*name*/ ctx[4]); attr_dev(input, "class", "svelte-tags-input svelte-1xz5xok"); attr_dev(input, "placeholder", /*placeholder*/ ctx[1]); input.disabled = /*disable*/ ctx[6]; add_location(input, file$2, 322, 4, 9283); attr_dev(div, "class", "svelte-tags-input-layout svelte-1xz5xok"); toggle_class(div, "sti-layout-disable", /*disable*/ ctx[6]); add_location(div, file$2, 307, 0, 8720); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, div, anchor); if (if_block0) if_block0.m(div, null); append_dev(div, t0); append_dev(div, input); set_input_value(input, /*tag*/ ctx[8]); insert_dev(target, t1, anchor); if (if_block1) if_block1.m(target, anchor); insert_dev(target, if_block1_anchor, anchor); if (!mounted) { dispose = [ listen_dev(input, "input", /*input_input_handler*/ ctx[28]), listen_dev(input, "keydown", /*setTag*/ ctx[9], false, false, false), listen_dev(input, "keyup", /*getMatchElements*/ ctx[15], false, false, false), listen_dev(input, "paste", /*onPaste*/ ctx[12], false, false, false), listen_dev(input, "drop", /*onDrop*/ ctx[13], false, false, false), listen_dev(input, "blur", /*blur_handler*/ ctx[29], false, false, false) ]; mounted = true; } }, p: function update(ctx, dirty) { if (/*tags*/ ctx[0].length > 0) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$1(ctx); if_block0.c(); if_block0.m(div, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (dirty[0] & /*id*/ 32) { attr_dev(input, "id", /*id*/ ctx[5]); } if (dirty[0] & /*name*/ 16) { attr_dev(input, "name", /*name*/ ctx[4]); } if (dirty[0] & /*placeholder*/ 2) { attr_dev(input, "placeholder", /*placeholder*/ ctx[1]); } if (dirty[0] & /*disable*/ 64) { prop_dev(input, "disabled", /*disable*/ ctx[6]); } if (dirty[0] & /*tag*/ 256 && input.value !== /*tag*/ ctx[8]) { set_input_value(input, /*tag*/ ctx[8]); } if (dirty[0] & /*disable*/ 64) { toggle_class(div, "sti-layout-disable", /*disable*/ ctx[6]); } if (/*autoComplete*/ ctx[2] && /*arrelementsmatch*/ ctx[7].length > 0) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$1(ctx); if_block1.c(); if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } }, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(div); if (if_block0) if_block0.d(); if (detaching) detach_dev(t1); if (if_block1) if_block1.d(detaching); if (detaching) detach_dev(if_block1_anchor); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$2.name, type: "component", source: "", ctx }); return block; } function getClipboardData(e) { if (window.clipboardData) { return window.clipboardData.getData("Text"); } if (e.clipboardData) { return e.clipboardData.getData("text/plain"); } return ""; } function uniqueID() { return "sti_" + Math.random().toString(36).substr(2, 9); } function instance$2($$self, $$props, $$invalidate) { let matchsID; let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Tags", slots, []); const dispatch = createEventDispatcher(); let tag = ""; let arrelementsmatch = []; let regExpEscape = s => { return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); }; let { tags } = $$props; let { addKeys } = $$props; let { maxTags } = $$props; let { onlyUnique } = $$props; let { removeKeys } = $$props; let { placeholder } = $$props; let { allowPaste } = $$props; let { allowDrop } = $$props; let { splitWith } = $$props; let { autoComplete } = $$props; let { autoCompleteKey } = $$props; let { name } = $$props; let { id } = $$props; let { allowBlur } = $$props; let { disable } = $$props; let { minChars } = $$props; let { onlyAutocomplete } = $$props; let storePlaceholder = placeholder; function setTag(input) { const currentTag = input.target.value; if (addKeys) { addKeys.forEach(function (key) { if (key === input.keyCode) { if (currentTag) input.preventDefault(); switch (input.keyCode) { case 9: // TAB add first element on the autoComplete list if (autoComplete && document.getElementById(matchsID)) { addTag(document.getElementById(matchsID).querySelectorAll("li")[0].textContent); } else { addTag(currentTag); } break; default: addTag(currentTag); break; } } }); } if (removeKeys) { removeKeys.forEach(function (key) { if (key === input.keyCode && tag === "") { tags.pop(); $$invalidate(0, tags); dispatch("tags", { tags }); $$invalidate(7, arrelementsmatch = []); document.getElementById(id).readOnly = false; $$invalidate(1, placeholder = storePlaceholder); document.getElementById(id).focus(); } }); } // ArrowDown : focus on first element of the autocomplete if (input.keyCode === 40 && autoComplete && document.getElementById(matchsID)) { event.preventDefault(); document.getElementById(matchsID).querySelector("li:first-child").focus(); } else if (input.keyCode === 38 && autoComplete && document.getElementById(matchsID)) { event.preventDefault(); // ArrowUp : focus on last element of the autocomplete document.getElementById(matchsID).querySelector("li:last-child").focus(); } } function addTag(currentTag) { if (typeof currentTag === "object" && currentTag !== null) { if (!autoCompleteKey) { return console.error("'autoCompleteKey' is necessary if 'autoComplete' result is an array of objects"); } var currentObjTags = currentTag; currentTag = currentTag[autoCompleteKey].trim(); } else { currentTag = currentTag.trim(); } if (currentTag == "") return; if (maxTags && tags.length == maxTags) return; if (onlyUnique && tags.includes(currentTag)) return; if (onlyAutocomplete && arrelementsmatch.length === 0) return; tags.push(currentObjTags ? currentObjTags : currentTag); $$invalidate(0, tags); $$invalidate(8, tag = ""); dispatch("tags", { tags }); // Hide autocomplete list // Focus on svelte tags input $$invalidate(7, arrelementsmatch = []); document.getElementById(id).focus(); if (maxTags && tags.length == maxTags) { document.getElementById(id).readOnly = true; $$invalidate(1, placeholder = ""); } } function removeTag(i) { tags.splice(i, 1); $$invalidate(0, tags); dispatch("tags", { tags }); // Hide autocomplete list // Focus on svelte tags input $$invalidate(7, arrelementsmatch = []); document.getElementById(id).readOnly = false; $$invalidate(1, placeholder = storePlaceholder); document.getElementById(id).focus(); } function onPaste(e) { if (!allowPaste) return; e.preventDefault(); const data = getClipboardData(e); splitTags(data).map(tag => addTag(tag)); } function onDrop(e) { if (!allowDrop) return; e.preventDefault(); const data = e.dataTransfer.getData("Text"); splitTags(data).map(tag => addTag(tag)); } function onBlur(tag) { if (!document.getElementById(matchsID) && allowBlur) { event.preventDefault(); addTag(tag); } } function splitTags(data) { return data.split(splitWith).map(tag => tag.trim()); } async function getMatchElements(input) { if (!autoComplete) return; let autoCompleteValues = []; if (Array.isArray(autoComplete)) { autoCompleteValues = autoComplete; } if (typeof autoComplete === "function") { if (autoComplete.constructor.name === "AsyncFunction") { autoCompleteValues = await autoComplete(); } else { autoCompleteValues = autoComplete(); } } var value = input.target.value; // Escape if (value == "" || input.keyCode === 27 || value.length < minChars) { $$invalidate(7, arrelementsmatch = []); return; } if (typeof autoCompleteValues[0] === "object" && autoCompleteValues !== null) { if (!autoCompleteKey) { return console.error("'autoCompleteValue' is necessary if 'autoComplete' result is an array of objects"); } var matchs = autoCompleteValues.filter(e => e[autoCompleteKey].toLowerCase().includes(value.toLowerCase())).map(matchTag => { return { label: matchTag, search: matchTag[autoCompleteKey].replace(RegExp(regExpEscape(value.toLowerCase()), "i"), "$&") }; }); } else { var matchs = autoCompleteValues.filter(e => e.toLowerCase().includes(value.toLowerCase())).map(matchTag => { return { label: matchTag, search: matchTag.replace(RegExp(regExpEscape(value.toLowerCase()), "i"), "$&") }; }); } if (onlyUnique === true && !autoCompleteKey) { matchs = matchs.filter(tag => !tags.includes(tag.label)); } $$invalidate(7, arrelementsmatch = matchs); } function navigateAutoComplete(autoCompleteIndex, autoCompleteLength, autoCompleteElement) { if (!autoComplete) return; event.preventDefault(); // ArrowDown if (event.keyCode === 40) { // Last element on the list ? Go to the first if (autoCompleteIndex + 1 === autoCompleteLength) { document.getElementById(matchsID).querySelector("li:first-child").focus(); return; } document.getElementById(matchsID).querySelectorAll("li")[autoCompleteIndex + 1].focus(); } else if (event.keyCode === 38) { // ArrowUp // First element on the list ? Go to the last if (autoCompleteIndex === 0) { document.getElementById(matchsID).querySelector("li:last-child").focus(); return; } document.getElementById(matchsID).querySelectorAll("li")[autoCompleteIndex - 1].focus(); } else if (event.keyCode === 13) { // Enter addTag(autoCompleteElement); } else if (event.keyCode === 27) { // Escape $$invalidate(7, arrelementsmatch = []); document.getElementById(id).focus(); } } const writable_props = [ "tags", "addKeys", "maxTags", "onlyUnique", "removeKeys", "placeholder", "allowPaste", "allowDrop", "splitWith", "autoComplete", "autoCompleteKey", "name", "id", "allowBlur", "disable", "minChars", "onlyAutocomplete" ]; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console_1.warn(` was created with unknown prop '${key}'`); }); const click_handler = i => removeTag(i); function input_input_handler() { tag = this.value; $$invalidate(8, tag); } const blur_handler = () => onBlur(tag); const keydown_handler = (index, element) => navigateAutoComplete(index, arrelementsmatch.length, element.label); const click_handler_1 = element => addTag(element.label); $$self.$$set = $$props => { if ("tags" in $$props) $$invalidate(0, tags = $$props.tags); if ("addKeys" in $$props) $$invalidate(17, addKeys = $$props.addKeys); if ("maxTags" in $$props) $$invalidate(18, maxTags = $$props.maxTags); if ("onlyUnique" in $$props) $$invalidate(19, onlyUnique = $$props.onlyUnique); if ("removeKeys" in $$props) $$invalidate(20, removeKeys = $$props.removeKeys); if ("placeholder" in $$props) $$invalidate(1, placeholder = $$props.placeholder); if ("allowPaste" in $$props) $$invalidate(21, allowPaste = $$props.allowPaste); if ("allowDrop" in $$props) $$invalidate(22, allowDrop = $$props.allowDrop); if ("splitWith" in $$props) $$invalidate(23, splitWith = $$props.splitWith); if ("autoComplete" in $$props) $$invalidate(2, autoComplete = $$props.autoComplete); if ("autoCompleteKey" in $$props) $$invalidate(3, autoCompleteKey = $$props.autoCompleteKey); if ("name" in $$props) $$invalidate(4, name = $$props.name); if ("id" in $$props) $$invalidate(5, id = $$props.id); if ("allowBlur" in $$props) $$invalidate(24, allowBlur = $$props.allowBlur); if ("disable" in $$props) $$invalidate(6, disable = $$props.disable); if ("minChars" in $$props) $$invalidate(25, minChars = $$props.minChars); if ("onlyAutocomplete" in $$props) $$invalidate(26, onlyAutocomplete = $$props.onlyAutocomplete); }; $$self.$capture_state = () => ({ createEventDispatcher, dispatch, tag, arrelementsmatch, regExpEscape, tags, addKeys, maxTags, onlyUnique, removeKeys, placeholder, allowPaste, allowDrop, splitWith, autoComplete, autoCompleteKey, name, id, allowBlur, disable, minChars, onlyAutocomplete, storePlaceholder, setTag, addTag, removeTag, onPaste, onDrop, onBlur, getClipboardData, splitTags, getMatchElements, navigateAutoComplete, uniqueID, matchsID }); $$self.$inject_state = $$props => { if ("tag" in $$props) $$invalidate(8, tag = $$props.tag); if ("arrelementsmatch" in $$props) $$invalidate(7, arrelementsmatch = $$props.arrelementsmatch); if ("regExpEscape" in $$props) regExpEscape = $$props.regExpEscape; if ("tags" in $$props) $$invalidate(0, tags = $$props.tags); if ("addKeys" in $$props) $$invalidate(17, addKeys = $$props.addKeys); if ("maxTags" in $$props) $$invalidate(18, maxTags = $$props.maxTags); if ("onlyUnique" in $$props) $$invalidate(19, onlyUnique = $$props.onlyUnique); if ("removeKeys" in $$props) $$invalidate(20, removeKeys = $$props.removeKeys); if ("placeholder" in $$props) $$invalidate(1, placeholder = $$props.placeholder); if ("allowPaste" in $$props) $$invalidate(21, allowPaste = $$props.allowPaste); if ("allowDrop" in $$props) $$invalidate(22, allowDrop = $$props.allowDrop); if ("splitWith" in $$props) $$invalidate(23, splitWith = $$props.splitWith); if ("autoComplete" in $$props) $$invalidate(2, autoComplete = $$props.autoComplete); if ("autoCompleteKey" in $$props) $$invalidate(3, autoCompleteKey = $$props.autoCompleteKey); if ("name" in $$props) $$invalidate(4, name = $$props.name); if ("id" in $$props) $$invalidate(5, id = $$props.id); if ("allowBlur" in $$props) $$invalidate(24, allowBlur = $$props.allowBlur); if ("disable" in $$props) $$invalidate(6, disable = $$props.disable); if ("minChars" in $$props) $$invalidate(25, minChars = $$props.minChars); if ("onlyAutocomplete" in $$props) $$invalidate(26, onlyAutocomplete = $$props.onlyAutocomplete); if ("storePlaceholder" in $$props) storePlaceholder = $$props.storePlaceholder; if ("matchsID" in $$props) matchsID = $$props.matchsID; }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } $$self.$$.update = () => { if ($$self.$$.dirty[0] & /*tags*/ 1) { $$invalidate(0, tags = tags || []); } if ($$self.$$.dirty[0] & /*addKeys*/ 131072) { $$invalidate(17, addKeys = addKeys || [13]); } if ($$self.$$.dirty[0] & /*maxTags*/ 262144) { $$invalidate(18, maxTags = maxTags || false); } if ($$self.$$.dirty[0] & /*onlyUnique*/ 524288) { $$invalidate(19, onlyUnique = onlyUnique || false); } if ($$self.$$.dirty[0] & /*removeKeys*/ 1048576) { $$invalidate(20, removeKeys = removeKeys || [8]); } if ($$self.$$.dirty[0] & /*placeholder*/ 2) { $$invalidate(1, placeholder = placeholder || ""); } if ($$self.$$.dirty[0] & /*allowPaste*/ 2097152) { $$invalidate(21, allowPaste = allowPaste || false); } if ($$self.$$.dirty[0] & /*allowDrop*/ 4194304) { $$invalidate(22, allowDrop = allowDrop || false); } if ($$self.$$.dirty[0] & /*splitWith*/ 8388608) { $$invalidate(23, splitWith = splitWith || ","); } if ($$self.$$.dirty[0] & /*autoComplete*/ 4) { $$invalidate(2, autoComplete = autoComplete || false); } if ($$self.$$.dirty[0] & /*autoCompleteKey*/ 8) { $$invalidate(3, autoCompleteKey = autoCompleteKey || false); } if ($$self.$$.dirty[0] & /*name*/ 16) { $$invalidate(4, name = name || "svelte-tags-input"); } if ($$self.$$.dirty[0] & /*id*/ 32) { $$invalidate(5, id = id || uniqueID()); } if ($$self.$$.dirty[0] & /*allowBlur*/ 16777216) { $$invalidate(24, allowBlur = allowBlur || false); } if ($$self.$$.dirty[0] & /*disable*/ 64) { $$invalidate(6, disable = disable || false); } if ($$self.$$.dirty[0] & /*minChars*/ 33554432) { $$invalidate(25, minChars = minChars || 1); } if ($$self.$$.dirty[0] & /*onlyAutocomplete*/ 67108864) { $$invalidate(26, onlyAutocomplete = onlyAutocomplete || false); } if ($$self.$$.dirty[0] & /*id*/ 32) { matchsID = id + "_matchs"; } }; return [ tags, placeholder, autoComplete, autoCompleteKey, name, id, disable, arrelementsmatch, tag, setTag, addTag, removeTag, onPaste, onDrop, onBlur, getMatchElements, navigateAutoComplete, addKeys, maxTags, onlyUnique, removeKeys, allowPaste, allowDrop, splitWith, allowBlur, minChars, onlyAutocomplete, click_handler, input_input_handler, blur_handler, keydown_handler, click_handler_1 ]; } class Tags extends SvelteComponentDev { constructor(options) { super(options); init( this, options, instance$2, create_fragment$2, safe_not_equal, { tags: 0, addKeys: 17, maxTags: 18, onlyUnique: 19, removeKeys: 20, placeholder: 1, allowPaste: 21, allowDrop: 22, splitWith: 23, autoComplete: 2, autoCompleteKey: 3, name: 4, id: 5, allowBlur: 24, disable: 6, minChars: 25, onlyAutocomplete: 26 }, [-1, -1] ); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Tags", options, id: create_fragment$2.name }); const { ctx } = this.$$; const props = options.props || {}; if (/*tags*/ ctx[0] === undefined && !("tags" in props)) { console_1.warn(" was created without expected prop 'tags'"); } if (/*addKeys*/ ctx[17] === undefined && !("addKeys" in props)) { console_1.warn(" was created without expected prop 'addKeys'"); } if (/*maxTags*/ ctx[18] === undefined && !("maxTags" in props)) { console_1.warn(" was created without expected prop 'maxTags'"); } if (/*onlyUnique*/ ctx[19] === undefined && !("onlyUnique" in props)) { console_1.warn(" was created without expected prop 'onlyUnique'"); } if (/*removeKeys*/ ctx[20] === undefined && !("removeKeys" in props)) { console_1.warn(" was created without expected prop 'removeKeys'"); } if (/*placeholder*/ ctx[1] === undefined && !("placeholder" in props)) { console_1.warn(" was created without expected prop 'placeholder'"); } if (/*allowPaste*/ ctx[21] === undefined && !("allowPaste" in props)) { console_1.warn(" was created without expected prop 'allowPaste'"); } if (/*allowDrop*/ ctx[22] === undefined && !("allowDrop" in props)) { console_1.warn(" was created without expected prop 'allowDrop'"); } if (/*splitWith*/ ctx[23] === undefined && !("splitWith" in props)) { console_1.warn(" was created without expected prop 'splitWith'"); } if (/*autoComplete*/ ctx[2] === undefined && !("autoComplete" in props)) { console_1.warn(" was created without expected prop 'autoComplete'"); } if (/*autoCompleteKey*/ ctx[3] === undefined && !("autoCompleteKey" in props)) { console_1.warn(" was created without expected prop 'autoCompleteKey'"); } if (/*name*/ ctx[4] === undefined && !("name" in props)) { console_1.warn(" was created without expected prop 'name'"); } if (/*id*/ ctx[5] === undefined && !("id" in props)) { console_1.warn(" was created without expected prop 'id'"); } if (/*allowBlur*/ ctx[24] === undefined && !("allowBlur" in props)) { console_1.warn(" was created without expected prop 'allowBlur'"); } if (/*disable*/ ctx[6] === undefined && !("disable" in props)) { console_1.warn(" was created without expected prop 'disable'"); } if (/*minChars*/ ctx[25] === undefined && !("minChars" in props)) { console_1.warn(" was created without expected prop 'minChars'"); } if (/*onlyAutocomplete*/ ctx[26] === undefined && !("onlyAutocomplete" in props)) { console_1.warn(" was created without expected prop 'onlyAutocomplete'"); } } get tags() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set tags(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get addKeys() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set addKeys(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get maxTags() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set maxTags(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get onlyUnique() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set onlyUnique(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get removeKeys() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set removeKeys(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get placeholder() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set placeholder(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get allowPaste() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set allowPaste(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get allowDrop() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set allowDrop(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get splitWith() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set splitWith(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get autoComplete() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set autoComplete(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get autoCompleteKey() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set autoCompleteKey(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get name() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set name(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get id() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set id(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get allowBlur() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set allowBlur(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get disable() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set disable(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get minChars() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set minChars(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } get onlyAutocomplete() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set onlyAutocomplete(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } /* src/routes/Upload.svelte generated by Svelte v3.38.2 */ const file$1 = "src/routes/Upload.svelte"; // (69:16) {#if currentProgress > 0 && currentProgress < 100} function create_if_block_1(ctx) { let p; let t0; let t1; const block = { c: function create() { p = element("p"); t0 = text(/*currentProgress*/ ctx[0]); t1 = text("%"); attr_dev(p, "class", "help"); add_location(p, file$1, 69, 20, 2116); }, m: function mount(target, anchor) { insert_dev(target, p, anchor); append_dev(p, t0); append_dev(p, t1); }, p: function update(ctx, dirty) { if (dirty & /*currentProgress*/ 1) set_data_dev(t0, /*currentProgress*/ ctx[0]); }, d: function destroy(detaching) { if (detaching) detach_dev(p); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1.name, type: "if", source: "(69:16) {#if currentProgress > 0 && currentProgress < 100}", ctx }); return block; } // (72:16) {#if fileName !== ""} function create_if_block(ctx) { let p; let t0; let t1; const block = { c: function create() { p = element("p"); t0 = text(/*fileName*/ ctx[1]); t1 = text(" uploaded"); attr_dev(p, "class", "help"); add_location(p, file$1, 72, 20, 2235); }, m: function mount(target, anchor) { insert_dev(target, p, anchor); append_dev(p, t0); append_dev(p, t1); }, p: function update(ctx, dirty) { if (dirty & /*fileName*/ 2) set_data_dev(t0, /*fileName*/ ctx[1]); }, d: function destroy(detaching) { if (detaching) detach_dev(p); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block.name, type: "if", source: "(72:16) {#if fileName !== \\\"\\\"}", ctx }); return block; } function create_fragment$1(ctx) { let section0; let div0; let p; let t1; let section1; let div9; let form_1; let div3; let label0; let t3; let div2; let div1; let label1; let input0; let t4; let span2; let span0; let t5; let span1; let t7; let t8; let t9; let div5; let label2; let t11; let div4; let input1; let t12; let div7; let label3; let t14; let div6; let tags; let t15; let div8; let button; let current; let mounted; let dispose; let if_block0 = /*currentProgress*/ ctx[0] > 0 && /*currentProgress*/ ctx[0] < 100 && create_if_block_1(ctx); let if_block1 = /*fileName*/ ctx[1] !== "" && create_if_block(ctx); tags = new Tags({ $$inline: true }); tags.$on("tags", /*onTagChange*/ ctx[4]); const block = { c: function create() { section0 = element("section"); div0 = element("div"); p = element("p"); p.textContent = "Upload"; t1 = space(); section1 = element("section"); div9 = element("div"); form_1 = element("form"); div3 = element("div"); label0 = element("label"); label0.textContent = "Image File"; t3 = space(); div2 = element("div"); div1 = element("div"); label1 = element("label"); input0 = element("input"); t4 = space(); span2 = element("span"); span0 = element("span"); t5 = space(); span1 = element("span"); span1.textContent = "Choose a file…"; t7 = space(); if (if_block0) if_block0.c(); t8 = space(); if (if_block1) if_block1.c(); t9 = space(); div5 = element("div"); label2 = element("label"); label2.textContent = "Source URL"; t11 = space(); div4 = element("div"); input1 = element("input"); t12 = space(); div7 = element("div"); label3 = element("label"); label3.textContent = "Tags"; t14 = space(); div6 = element("div"); create_component(tags.$$.fragment); t15 = space(); div8 = element("div"); button = element("button"); button.textContent = "Submit"; attr_dev(p, "class", "title"); add_location(p, file$1, 42, 8, 1029); attr_dev(div0, "class", "hero-body"); add_location(div0, file$1, 41, 4, 997); attr_dev(section0, "class", "hero is-primary"); add_location(section0, file$1, 40, 0, 959); attr_dev(label0, "for", "file"); attr_dev(label0, "class", "label"); add_location(label0, file$1, 50, 16, 1233); attr_dev(input0, "id", "file"); attr_dev(input0, "class", "file-input"); attr_dev(input0, "type", "file"); attr_dev(input0, "name", "resume"); add_location(input0, file$1, 54, 28, 1440); attr_dev(span0, "class", "file-icon"); add_location(span0, file$1, 62, 32, 1802); attr_dev(span1, "class", "file-label"); add_location(span1, file$1, 63, 32, 1861); attr_dev(span2, "class", "file-cta"); add_location(span2, file$1, 61, 28, 1746); attr_dev(label1, "class", "file-label"); add_location(label1, file$1, 53, 24, 1385); attr_dev(div1, "class", "file"); add_location(div1, file$1, 52, 20, 1342); attr_dev(div2, "class", "control"); add_location(div2, file$1, 51, 16, 1300); attr_dev(div3, "class", "field"); add_location(div3, file$1, 49, 12, 1197); attr_dev(label2, "for", "source"); attr_dev(label2, "class", "label"); add_location(label2, file$1, 76, 16, 2364); attr_dev(input1, "id", "source"); attr_dev(input1, "class", "input"); attr_dev(input1, "type", "url"); attr_dev(input1, "placeholder", "Source URL"); add_location(input1, file$1, 78, 20, 2475); attr_dev(div4, "class", "control"); add_location(div4, file$1, 77, 16, 2433); attr_dev(div5, "class", "field"); add_location(div5, file$1, 75, 12, 2328); attr_dev(label3, "for", "tags"); attr_dev(label3, "class", "label"); add_location(label3, file$1, 88, 16, 2806); attr_dev(div6, "class", "control"); attr_dev(div6, "id", "tags"); add_location(div6, file$1, 89, 16, 2867); attr_dev(div7, "class", "field"); add_location(div7, file$1, 87, 12, 2770); attr_dev(button, "type", "submit"); attr_dev(button, "class", "button is-primary"); add_location(button, file$1, 94, 16, 3042); attr_dev(div8, "class", "control"); add_location(div8, file$1, 93, 12, 3004); add_location(form_1, file$1, 48, 8, 1142); attr_dev(div9, "class", "container"); add_location(div9, file$1, 47, 4, 1110); attr_dev(section1, "class", "section"); add_location(section1, file$1, 46, 0, 1080); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, section0, anchor); append_dev(section0, div0); append_dev(div0, p); insert_dev(target, t1, anchor); insert_dev(target, section1, anchor); append_dev(section1, div9); append_dev(div9, form_1); append_dev(form_1, div3); append_dev(div3, label0); append_dev(div3, t3); append_dev(div3, div2); append_dev(div2, div1); append_dev(div1, label1); append_dev(label1, input0); append_dev(label1, t4); append_dev(label1, span2); append_dev(span2, span0); append_dev(span2, t5); append_dev(span2, span1); append_dev(div3, t7); if (if_block0) if_block0.m(div3, null); append_dev(div3, t8); if (if_block1) if_block1.m(div3, null); append_dev(form_1, t9); append_dev(form_1, div5); append_dev(div5, label2); append_dev(div5, t11); append_dev(div5, div4); append_dev(div4, input1); set_input_value(input1, /*form*/ ctx[2].source_url); append_dev(form_1, t12); append_dev(form_1, div7); append_dev(div7, label3); append_dev(div7, t14); append_dev(div7, div6); mount_component(tags, div6, null); append_dev(form_1, t15); append_dev(form_1, div8); append_dev(div8, button); current = true; if (!mounted) { dispose = [ listen_dev(input0, "change", /*onFileChange*/ ctx[3], false, false, false), listen_dev(input1, "input", /*input1_input_handler*/ ctx[6]), listen_dev(form_1, "submit", prevent_default(/*onSubmit*/ ctx[5]), false, true, false) ]; mounted = true; } }, p: function update(ctx, [dirty]) { if (/*currentProgress*/ ctx[0] > 0 && /*currentProgress*/ ctx[0] < 100) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1(ctx); if_block0.c(); if_block0.m(div3, t8); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*fileName*/ ctx[1] !== "") { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block(ctx); if_block1.c(); if_block1.m(div3, null); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (dirty & /*form*/ 4) { set_input_value(input1, /*form*/ ctx[2].source_url); } }, i: function intro(local) { if (current) return; transition_in(tags.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(tags.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(section0); if (detaching) detach_dev(t1); if (detaching) detach_dev(section1); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); destroy_component(tags); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$1.name, type: "component", source: "", ctx }); return block; } function instance$1($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("Upload", slots, []); let currentProgress = 0; let fileName = ""; let form = { blob_id: "", source_url: "", tags: [] }; const onProgress = e => { var percentCompleted = Math.round(e.loaded * 100 / e.total); $$invalidate(0, currentProgress = percentCompleted); }; const onFileChange = async e => { $$invalidate(1, fileName = ""); var file = e.target.files[0]; if (file) { var response = await uploadBlob({ file, onProgress }); $$invalidate(2, form.blob_id = response.id, form); $$invalidate(1, fileName = file.name); } }; const onTagChange = value => { $$invalidate(2, form.tags = value.detail.tags, form); }; const onSubmit = async () => { const response = await postCreate(form); navigate(`/post/${response.id}`); }; const writable_props = []; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); function input1_input_handler() { form.source_url = this.value; $$invalidate(2, form); } $$self.$capture_state = () => ({ uploadBlob, postCreate, navigate, Tags, currentProgress, fileName, form, onProgress, onFileChange, onTagChange, onSubmit }); $$self.$inject_state = $$props => { if ("currentProgress" in $$props) $$invalidate(0, currentProgress = $$props.currentProgress); if ("fileName" in $$props) $$invalidate(1, fileName = $$props.fileName); if ("form" in $$props) $$invalidate(2, form = $$props.form); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [ currentProgress, fileName, form, onFileChange, onTagChange, onSubmit, input1_input_handler ]; } class Upload extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$1, create_fragment$1, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Upload", options, id: create_fragment$1.name }); } } /* src/App.svelte generated by Svelte v3.38.2 */ const file = "src/App.svelte"; // (18:0) function create_default_slot(ctx) { let navbar; let t0; let div; let route0; let t1; let route1; let t2; let route2; let t3; let route3; let t4; let route4; let t5; let route5; let t6; let route6; let current; navbar = new Navbar({ $$inline: true }); route0 = new Route({ props: { path: "/", component: Home }, $$inline: true }); route1 = new Route({ props: { path: "/posts", component: Posts }, $$inline: true }); route2 = new Route({ props: { path: "/tag/:id", component: Tag }, $$inline: true }); route3 = new Route({ props: { path: "/post/:id", component: Post }, $$inline: true }); route4 = new Route({ props: { path: "/auth/login", component: Login }, $$inline: true }); route5 = new Route({ props: { path: "/auth/logout", component: Logout }, $$inline: true }); route6 = new Route({ props: { path: "/upload", component: Upload }, $$inline: true }); const block = { c: function create() { create_component(navbar.$$.fragment); t0 = space(); div = element("div"); create_component(route0.$$.fragment); t1 = space(); create_component(route1.$$.fragment); t2 = space(); create_component(route2.$$.fragment); t3 = space(); create_component(route3.$$.fragment); t4 = space(); create_component(route4.$$.fragment); t5 = space(); create_component(route5.$$.fragment); t6 = space(); create_component(route6.$$.fragment); add_location(div, file, 19, 1, 503); }, m: function mount(target, anchor) { mount_component(navbar, target, anchor); insert_dev(target, t0, anchor); insert_dev(target, div, anchor); mount_component(route0, div, null); append_dev(div, t1); mount_component(route1, div, null); append_dev(div, t2); mount_component(route2, div, null); append_dev(div, t3); mount_component(route3, div, null); append_dev(div, t4); mount_component(route4, div, null); append_dev(div, t5); mount_component(route5, div, null); append_dev(div, t6); mount_component(route6, div, null); current = true; }, p: noop, i: function intro(local) { if (current) return; transition_in(navbar.$$.fragment, local); transition_in(route0.$$.fragment, local); transition_in(route1.$$.fragment, local); transition_in(route2.$$.fragment, local); transition_in(route3.$$.fragment, local); transition_in(route4.$$.fragment, local); transition_in(route5.$$.fragment, local); transition_in(route6.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(navbar.$$.fragment, local); transition_out(route0.$$.fragment, local); transition_out(route1.$$.fragment, local); transition_out(route2.$$.fragment, local); transition_out(route3.$$.fragment, local); transition_out(route4.$$.fragment, local); transition_out(route5.$$.fragment, local); transition_out(route6.$$.fragment, local); current = false; }, d: function destroy(detaching) { destroy_component(navbar, detaching); if (detaching) detach_dev(t0); if (detaching) detach_dev(div); destroy_component(route0); destroy_component(route1); destroy_component(route2); destroy_component(route3); destroy_component(route4); destroy_component(route5); destroy_component(route6); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_default_slot.name, type: "slot", source: "(18:0) ", ctx }); return block; } function create_fragment(ctx) { let router; let current; router = new Router({ props: { url: /*url*/ ctx[0], $$slots: { default: [create_default_slot] }, $$scope: { ctx } }, $$inline: true }); const block = { c: function create() { create_component(router.$$.fragment); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { mount_component(router, target, anchor); current = true; }, p: function update(ctx, [dirty]) { const router_changes = {}; if (dirty & /*url*/ 1) router_changes.url = /*url*/ ctx[0]; if (dirty & /*$$scope*/ 4) { router_changes.$$scope = { dirty, ctx }; } router.$set(router_changes); }, i: function intro(local) { if (current) return; transition_in(router.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(router.$$.fragment, local); current = false; }, d: function destroy(detaching) { destroy_component(router, detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); return block; } function instance($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots("App", slots, []); let { url = "" } = $$props; let baseURL = window.BASE_URL; const writable_props = ["url"]; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(` was created with unknown prop '${key}'`); }); $$self.$$set = $$props => { if ("url" in $$props) $$invalidate(0, url = $$props.url); }; $$self.$capture_state = () => ({ Router, Link, Route, Navbar, Home, Posts, Post, Login, Logout, Tag, Upload, url, baseURL }); $$self.$inject_state = $$props => { if ("url" in $$props) $$invalidate(0, url = $$props.url); if ("baseURL" in $$props) baseURL = $$props.baseURL; }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [url]; } class App extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, { url: 0 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "App", options, id: create_fragment.name }); } get url() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set url(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } const app = new App({ target: document.body, hydrate: false, }); return app; }()); //# sourceMappingURL=bundle.js.map