Shioriko/web/static/bundle.js

7569 lines
216 KiB
JavaScript

(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;
}
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);
}
}
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 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:
*
* <Link to="deeper"/>
* // instead of
* <Link to=`{${props.uri}/deeper}`/>
*
* 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$a(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$a.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$a($$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(`<Router> 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$a, create_fragment$a, safe_not_equal, { basepath: 3, url: 4 });
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Router",
options,
id: create_fragment$a.name
});
}
get basepath() {
throw new Error("<Router>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set basepath(value) {
throw new Error("<Router>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get url() {
throw new Error("<Router>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set url(value) {
throw new Error("<Router>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
/* 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$4(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block_1$4, 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$4.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$4(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$4.name,
type: "if",
source: "(41:2) {#if component !== null}",
ctx
});
return block;
}
function create_fragment$9(ctx) {
let if_block_anchor;
let current;
let if_block = /*$activeRoute*/ ctx[1] !== null && /*$activeRoute*/ ctx[1].route === /*route*/ ctx[7] && create_if_block$4(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$4(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$9.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$9($$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$9, create_fragment$9, safe_not_equal, { path: 8, component: 0 });
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Route",
options,
id: create_fragment$9.name
});
}
get path() {
throw new Error("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set path(value) {
throw new Error("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get component() {
throw new Error("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set component(value) {
throw new Error("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
/* node_modules/svelte-routing/src/Link.svelte generated by Svelte v3.38.2 */
const file$7 = "node_modules/svelte-routing/src/Link.svelte";
function create_fragment$8(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$7, 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$8.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$8($$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$8, create_fragment$8, safe_not_equal, {
to: 7,
replace: 8,
state: 9,
getProps: 10
});
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Link",
options,
id: create_fragment$8.name
});
}
get to() {
throw new Error("<Link>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set to(value) {
throw new Error("<Link>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get replace() {
throw new Error("<Link>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set replace(value) {
throw new Error("<Link>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get state() {
throw new Error("<Link>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set state(value) {
throw new Error("<Link>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get getProps() {
throw new Error("<Link>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set getProps(value) {
throw new Error("<Link>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
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$6 = "src/Navbar.svelte";
// (19:8) <Link class="navbar-item" to="/">
function create_default_slot_5$2(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$2.name,
type: "slot",
source: "(19:8) <Link class=\\\"navbar-item\\\" to=\\\"/\\\">",
ctx
});
return block;
}
// (37:12) <Link class="navbar-item" to="/posts">
function create_default_slot_4$2(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$2.name,
type: "slot",
source: "(37:12) <Link class=\\\"navbar-item\\\" to=\\\"/posts\\\">",
ctx
});
return block;
}
// (38:12) {#if loggedIn}
function create_if_block_1$3(ctx) {
let link;
let current;
link = new Link({
props: {
class: "navbar-item",
to: "/upload",
$$slots: { default: [create_default_slot_3$2] },
$$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$3.name,
type: "if",
source: "(38:12) {#if loggedIn}",
ctx
});
return block;
}
// (39:16) <Link class="navbar-item" to="/upload">
function create_default_slot_3$2(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$2.name,
type: "slot",
source: "(39:16) <Link class=\\\"navbar-item\\\" to=\\\"/upload\\\">",
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$2] },
$$scope: { ctx }
},
$$inline: true
});
link1 = new Link({
props: {
to: "/auth/login",
class: "button is-light",
$$slots: { default: [create_default_slot_1$2] },
$$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$6, 53, 20, 1515);
attr_dev(div1, "class", "navbar-item");
add_location(div1, file$6, 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$3(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$4] },
$$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$6, 45, 20, 1220);
attr_dev(div1, "class", "navbar-item");
add_location(div1, file$6, 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$3.name,
type: "if",
source: "(44:12) {#if loggedIn}",
ctx
});
return block;
}
// (55:24) <Link to="/auth/register" class="button is-primary">
function create_default_slot_2$2(ctx) {
let strong;
const block = {
c: function create() {
strong = element("strong");
strong.textContent = "Register";
add_location(strong, file$6, 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$2.name,
type: "slot",
source: "(55:24) <Link to=\\\"/auth/register\\\" class=\\\"button is-primary\\\">",
ctx
});
return block;
}
// (58:24) <Link to="/auth/login" class="button is-light">
function create_default_slot_1$2(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$2.name,
type: "slot",
source: "(58:24) <Link to=\\\"/auth/login\\\" class=\\\"button is-light\\\">",
ctx
});
return block;
}
// (47:24) <Link to="/auth/logout" class="button is-light">
function create_default_slot$4(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$4.name,
type: "slot",
source: "(47:24) <Link to=\\\"/auth/logout\\\" class=\\\"button is-light\\\">",
ctx
});
return block;
}
function create_fragment$7(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$2] },
$$scope: { ctx }
},
$$inline: true
});
link1 = new Link({
props: {
class: "navbar-item",
to: "/posts",
$$slots: { default: [create_default_slot_4$2] },
$$scope: { ctx }
},
$$inline: true
});
let if_block0 = /*loggedIn*/ ctx[1] && create_if_block_1$3(ctx);
const if_block_creators = [create_if_block$3, 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$6, 28, 12, 678);
attr_dev(span1, "aria-hidden", "true");
add_location(span1, file$6, 29, 12, 718);
attr_dev(span2, "aria-hidden", "true");
add_location(span2, file$6, 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$6, 20, 8, 472);
attr_dev(div0, "class", "navbar-brand");
add_location(div0, file$6, 17, 4, 379);
attr_dev(div1, "class", "navbar-start");
add_location(div1, file$6, 35, 8, 878);
attr_dev(div2, "class", "navbar-end");
add_location(div2, file$6, 42, 8, 1106);
attr_dev(div3, "class", "navbar-menu");
toggle_class(div3, "is-active", /*menu_shown*/ ctx[0]);
add_location(div3, file$6, 34, 4, 815);
attr_dev(nav, "class", "navbar");
attr_dev(nav, "role", "navigation");
attr_dev(nav, "aria-label", "main navigation");
add_location(nav, file$6, 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$3(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$7.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$7($$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(`<Navbar> 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$7, create_fragment$7, safe_not_equal, {});
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Navbar",
options,
id: create_fragment$7.name
});
}
}
/* src/routes/Home.svelte generated by Svelte v3.38.2 */
const file$5 = "src/routes/Home.svelte";
function create_fragment$6(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$5, 5, 4, 94);
attr_dev(p1, "class", "subtitle");
add_location(p1, file$5, 6, 4, 128);
attr_dev(div, "class", "hero-body");
add_location(div, file$5, 4, 2, 66);
attr_dev(section, "class", "hero is-primary is-medium");
add_location(section, file$5, 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$6.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$6($$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(`<Home> was created with unknown prop '${key}'`);
});
return [];
}
class Home extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance$6, create_fragment$6, safe_not_equal, {});
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Home",
options,
id: create_fragment$6.name
});
}
}
let url = window.BASE_URL;
token$1.subscribe(value => {
});
async function login({ username, password }) {
const endpoint = url + "/api/auth/login";
const response = await fetch(endpoint, {
method: "POST",
body: JSON.stringify({
username,
password,
}),
});
const data = await response.json();
token$1.set(data.token);
return data;
}
async function getPosts({ page }) {
const endpoint = url + "/api/post?page=" + page;
const response = await fetch(endpoint);
const data = await response.json();
return data;
}
async function getPostsTag({ page, tag }) {
const endpoint = url + "/api/post/tag/" + tag + "?page=" + page;
const response = await fetch(endpoint);
const data = await response.json();
return data;
}
async function getPost({ id }) {
const endpoint = url + "/api/post/" + id;
const response = await fetch(endpoint);
const data = await response.json();
return 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/routes/Posts.svelte generated by Svelte v3.38.2 */
const file$4 = "src/routes/Posts.svelte";
function get_each_context$2(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
return child_ctx;
}
function get_each_context_1$1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[10] = list[i];
return child_ctx;
}
function get_each_context_2$1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[13] = list[i];
return child_ctx;
}
// (45:12) {#if page > 1}
function create_if_block_5$1(ctx) {
let link;
let current;
link = new Link({
props: {
to: "/posts?page=" + (/*page*/ ctx[0] - 1),
class: "pagination-previous",
"aria-label": "Previous",
$$slots: { default: [create_default_slot_7$1] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", function () {
if (is_function(/*handlePage*/ ctx[3](/*page*/ ctx[0] - 1))) /*handlePage*/ ctx[3](/*page*/ ctx[0] - 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 & /*page*/ 1) link_changes.to = "/posts?page=" + (/*page*/ ctx[0] - 1);
if (dirty & /*$$scope*/ 65536) {
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$1.name,
type: "if",
source: "(45:12) {#if page > 1}",
ctx
});
return block;
}
// (46:16) <Link on:click={handlePage(page - 1)} to="/posts?page={page - 1}" class="pagination-previous" aria-label="Previous">
function create_default_slot_7$1(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$1.name,
type: "slot",
source: "(46:16) <Link on:click={handlePage(page - 1)} to=\\\"/posts?page={page - 1}\\\" class=\\\"pagination-previous\\\" aria-label=\\\"Previous\\\">",
ctx
});
return block;
}
// (53:12) {#if page < totalPages}
function create_if_block_4$1(ctx) {
let link;
let current;
link = new Link({
props: {
to: "/posts?page=" + (/*page*/ ctx[0] + 1),
class: "pagination-next",
"aria-label": "Next",
$$slots: { default: [create_default_slot_6$1] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", function () {
if (is_function(/*handlePage*/ ctx[3](/*page*/ ctx[0] + 1))) /*handlePage*/ ctx[3](/*page*/ ctx[0] + 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 & /*page*/ 1) link_changes.to = "/posts?page=" + (/*page*/ ctx[0] + 1);
if (dirty & /*$$scope*/ 65536) {
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$1.name,
type: "if",
source: "(53:12) {#if page < totalPages}",
ctx
});
return block;
}
// (54:16) <Link on:click={handlePage(page + 1)} to="/posts?page={page + 1}" class="pagination-next" aria-label="Next">
function create_default_slot_6$1(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$1.name,
type: "slot",
source: "(54:16) <Link on:click={handlePage(page + 1)} to=\\\"/posts?page={page + 1}\\\" class=\\\"pagination-next\\\" aria-label=\\\"Next\\\">",
ctx
});
return block;
}
// (62: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: "/posts?page=" + 1,
class: "pagination-link",
"aria-label": "Goto page 1",
$$slots: { default: [create_default_slot_5$1] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", /*handlePage*/ ctx[3](1));
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$4, 62, 20, 1744);
attr_dev(span, "class", "pagination-ellipsis");
add_location(span, file$4, 71, 24, 2095);
add_location(li1, file$4, 70, 20, 2066);
},
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(ctx, dirty) {
const link_changes = {};
if (dirty & /*$$scope*/ 65536) {
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: "(62:16) {#if page > 3}",
ctx
});
return block;
}
// (64:24) <Link on:click={handlePage(1)} to="/posts?page={1}" class="pagination-link" aria-label="Goto page 1">
function create_default_slot_5$1(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$1.name,
type: "slot",
source: "(64:24) <Link on:click={handlePage(1)} to=\\\"/posts?page={1}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page 1\\\">",
ctx
});
return block;
}
// (76:20) {#if i >= 1 && i <= totalPages}
function create_if_block_1$2(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[13] == /*page*/ ctx[0]) 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$2.name,
type: "if",
source: "(76:20) {#if i >= 1 && i <= totalPages}",
ctx
});
return block;
}
// (86:24) {:else}
function create_else_block$1(ctx) {
let li;
let link;
let current;
link = new Link({
props: {
to: "/posts?page=" + /*i*/ ctx[13],
class: "pagination-link",
"aria-label": "Goto page " + /*i*/ ctx[13],
$$slots: { default: [create_default_slot_4$1] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", function () {
if (is_function(/*handlePage*/ ctx[3](/*i*/ ctx[13]))) /*handlePage*/ ctx[3](/*i*/ ctx[13]).apply(this, arguments);
});
const block = {
c: function create() {
li = element("li");
create_component(link.$$.fragment);
add_location(li, file$4, 86, 28, 2821);
},
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 & /*page*/ 1) link_changes.to = "/posts?page=" + /*i*/ ctx[13];
if (dirty & /*page*/ 1) link_changes["aria-label"] = "Goto page " + /*i*/ ctx[13];
if (dirty & /*$$scope, page*/ 65537) {
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: "(86:24) {:else}",
ctx
});
return block;
}
// (77:24) {#if i == page}
function create_if_block_2$1(ctx) {
let li;
let link;
let current;
link = new Link({
props: {
to: "/posts?page=" + /*i*/ ctx[13],
class: "pagination-link is-current",
"aria-label": "Goto page " + /*i*/ ctx[13],
$$slots: { default: [create_default_slot_3$1] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", function () {
if (is_function(/*handlePage*/ ctx[3](/*i*/ ctx[13]))) /*handlePage*/ ctx[3](/*i*/ ctx[13]).apply(this, arguments);
});
const block = {
c: function create() {
li = element("li");
create_component(link.$$.fragment);
add_location(li, file$4, 77, 28, 2388);
},
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 & /*page*/ 1) link_changes.to = "/posts?page=" + /*i*/ ctx[13];
if (dirty & /*page*/ 1) link_changes["aria-label"] = "Goto page " + /*i*/ ctx[13];
if (dirty & /*$$scope, page*/ 65537) {
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: "(77:24) {#if i == page}",
ctx
});
return block;
}
// (88:32) <Link on:click={handlePage(i)} to="/posts?page={i}" class="pagination-link" aria-label="Goto page {i}">
function create_default_slot_4$1(ctx) {
let t_value = /*i*/ ctx[13] + "";
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*/ 1 && t_value !== (t_value = /*i*/ ctx[13] + "")) set_data_dev(t, t_value);
},
d: function destroy(detaching) {
if (detaching) detach_dev(t);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_4$1.name,
type: "slot",
source: "(88:32) <Link on:click={handlePage(i)} to=\\\"/posts?page={i}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page {i}\\\">",
ctx
});
return block;
}
// (79:32) <Link on:click={handlePage(i)} to="/posts?page={i}" class="pagination-link is-current" aria-label="Goto page {i}">
function create_default_slot_3$1(ctx) {
let t_value = /*i*/ ctx[13] + "";
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*/ 1 && t_value !== (t_value = /*i*/ ctx[13] + "")) set_data_dev(t, t_value);
},
d: function destroy(detaching) {
if (detaching) detach_dev(t);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_3$1.name,
type: "slot",
source: "(79:32) <Link on:click={handlePage(i)} to=\\\"/posts?page={i}\\\" class=\\\"pagination-link is-current\\\" aria-label=\\\"Goto page {i}\\\">",
ctx
});
return block;
}
// (75:16) {#each [...Array(5).keys()].map((x) => x + page - 2) as i}
function create_each_block_2$1(ctx) {
let if_block_anchor;
let current;
let if_block = /*i*/ ctx[13] >= 1 && /*i*/ ctx[13] <= /*totalPages*/ ctx[1] && create_if_block_1$2(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[13] >= 1 && /*i*/ ctx[13] <= /*totalPages*/ ctx[1]) {
if (if_block) {
if_block.p(ctx, dirty);
if (dirty & /*page, totalPages*/ 3) {
transition_in(if_block, 1);
}
} else {
if_block = create_if_block_1$2(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$1.name,
type: "each",
source: "(75:16) {#each [...Array(5).keys()].map((x) => x + page - 2) as i}",
ctx
});
return block;
}
// (98:16) {#if totalPages - page > 2}
function create_if_block$2(ctx) {
let li0;
let span;
let t1;
let li1;
let link;
let current;
link = new Link({
props: {
to: "/posts?page=" + /*totalPages*/ ctx[1],
class: "pagination-link",
"aria-label": "Goto page " + /*totalPages*/ ctx[1],
$$slots: { default: [create_default_slot_2$1] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", function () {
if (is_function(/*handlePage*/ ctx[3](/*totalPages*/ ctx[1]))) /*handlePage*/ ctx[3](/*totalPages*/ ctx[1]).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$4, 99, 24, 3356);
add_location(li0, file$4, 98, 20, 3327);
add_location(li1, file$4, 101, 20, 3452);
},
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 & /*totalPages*/ 2) link_changes.to = "/posts?page=" + /*totalPages*/ ctx[1];
if (dirty & /*totalPages*/ 2) link_changes["aria-label"] = "Goto page " + /*totalPages*/ ctx[1];
if (dirty & /*$$scope, totalPages*/ 65538) {
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$2.name,
type: "if",
source: "(98:16) {#if totalPages - page > 2}",
ctx
});
return block;
}
// (103:24) <Link on:click={handlePage(totalPages)} to="/posts?page={totalPages}" class="pagination-link" aria-label="Goto page {totalPages}" >
function create_default_slot_2$1(ctx) {
let t;
const block = {
c: function create() {
t = text(/*totalPages*/ ctx[1]);
},
m: function mount(target, anchor) {
insert_dev(target, t, anchor);
},
p: function update(ctx, dirty) {
if (dirty & /*totalPages*/ 2) set_data_dev(t, /*totalPages*/ ctx[1]);
},
d: function destroy(detaching) {
if (detaching) detach_dev(t);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_2$1.name,
type: "slot",
source: "(103:24) <Link on:click={handlePage(totalPages)} to=\\\"/posts?page={totalPages}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page {totalPages}\\\" >",
ctx
});
return block;
}
// (119:28) <Link to="/post/{post.id}">
function create_default_slot_1$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[7].id);
if (img.src !== (img_src_value = /*post*/ ctx[7].image_path)) attr_dev(img, "src", img_src_value);
add_location(img, file$4, 119, 32, 4202);
},
m: function mount(target, anchor) {
insert_dev(target, img, anchor);
},
p: function update(ctx, dirty) {
if (dirty & /*posts*/ 4 && img_alt_value !== (img_alt_value = /*post*/ ctx[7].id)) {
attr_dev(img, "alt", img_alt_value);
}
if (dirty & /*posts*/ 4 && img.src !== (img_src_value = /*post*/ ctx[7].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$1.name,
type: "slot",
source: "(119:28) <Link to=\\\"/post/{post.id}\\\">",
ctx
});
return block;
}
// (128:36) <Link to="/tag/{tag}">
function create_default_slot$3(ctx) {
let t_value = /*tag*/ ctx[10] + "";
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*/ 4 && t_value !== (t_value = /*tag*/ ctx[10] + "")) 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: "(128:36) <Link to=\\\"/tag/{tag}\\\">",
ctx
});
return block;
}
// (126: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[10],
$$slots: { default: [create_default_slot$3] },
$$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$4, 126, 32, 4527);
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*/ 4) link_changes.to = "/tag/" + /*tag*/ ctx[10];
if (dirty & /*$$scope, posts*/ 65540) {
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: "(126:28) {#each post.tags as tag (tag)}",
ctx
});
return block;
}
// (115: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[7].id,
$$slots: { default: [create_default_slot_1$1] },
$$scope: { ctx }
},
$$inline: true
});
let each_value_1 = /*post*/ ctx[7].tags;
validate_each_argument(each_value_1);
const get_key = ctx => /*tag*/ ctx[10];
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$4, 117, 24, 4091);
attr_dev(div0, "class", "card-image");
add_location(div0, file$4, 116, 20, 4042);
attr_dev(div1, "class", "content");
add_location(div1, file$4, 124, 24, 4414);
attr_dev(div2, "class", "card-content");
add_location(div2, file$4, 123, 20, 4363);
attr_dev(div3, "class", "column is-one-quarter card");
add_location(div3, file$4, 115, 16, 3981);
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*/ 4) link_changes.to = "/post/" + /*post*/ ctx[7].id;
if (dirty & /*$$scope, posts*/ 65540) {
link_changes.$$scope = { dirty, ctx };
}
link.$set(link_changes);
if (dirty & /*posts*/ 4) {
each_value_1 = /*post*/ ctx[7].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: "(115:12) {#each posts as post (post.id)}",
ctx
});
return block;
}
function create_fragment$5(ctx) {
let section0;
let div0;
let p;
let t1;
let section1;
let div2;
let nav;
let t2;
let t3;
let ul;
let t4;
let t5;
let t6;
let div1;
let each_blocks = [];
let each1_lookup = new Map();
let current;
let if_block0 = /*page*/ ctx[0] > 1 && create_if_block_5$1(ctx);
let if_block1 = /*page*/ ctx[0] < /*totalPages*/ ctx[1] && create_if_block_4$1(ctx);
let if_block2 = /*page*/ ctx[0] > 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$1(get_each_context_2$1(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[1] - /*page*/ ctx[0] > 2 && create_if_block$2(ctx);
let each_value = /*posts*/ ctx[2];
validate_each_argument(each_value);
const get_key = ctx => /*post*/ ctx[7].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() {
section0 = element("section");
div0 = element("div");
p = element("p");
p.textContent = "Posts";
t1 = space();
section1 = element("section");
div2 = element("div");
nav = element("nav");
if (if_block0) if_block0.c();
t2 = space();
if (if_block1) if_block1.c();
t3 = space();
ul = element("ul");
if (if_block2) if_block2.c();
t4 = space();
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].c();
}
t5 = space();
if (if_block3) if_block3.c();
t6 = space();
div1 = element("div");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr_dev(p, "class", "title");
add_location(p, file$4, 37, 8, 896);
attr_dev(div0, "class", "hero-body");
add_location(div0, file$4, 36, 4, 864);
attr_dev(section0, "class", "hero is-primary");
add_location(section0, file$4, 35, 0, 826);
attr_dev(ul, "class", "pagination-list");
add_location(ul, file$4, 60, 12, 1664);
attr_dev(nav, "class", "pagination");
attr_dev(nav, "role", "navigation");
attr_dev(nav, "aria-label", "pagination");
add_location(nav, file$4, 43, 8, 1008);
attr_dev(div1, "class", "columns is-multiline");
add_location(div1, file$4, 113, 8, 3886);
attr_dev(div2, "class", "container");
add_location(div2, file$4, 42, 4, 976);
attr_dev(section1, "class", "section");
add_location(section1, file$4, 41, 0, 946);
},
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, div2);
append_dev(div2, nav);
if (if_block0) if_block0.m(nav, null);
append_dev(nav, t2);
if (if_block1) if_block1.m(nav, null);
append_dev(nav, t3);
append_dev(nav, ul);
if (if_block2) if_block2.m(ul, null);
append_dev(ul, t4);
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].m(ul, null);
}
append_dev(ul, t5);
if (if_block3) if_block3.m(ul, null);
append_dev(div2, t6);
append_dev(div2, div1);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div1, null);
}
current = true;
},
p: function update(ctx, [dirty]) {
if (/*page*/ ctx[0] > 1) {
if (if_block0) {
if_block0.p(ctx, dirty);
if (dirty & /*page*/ 1) {
transition_in(if_block0, 1);
}
} else {
if_block0 = create_if_block_5$1(ctx);
if_block0.c();
transition_in(if_block0, 1);
if_block0.m(nav, t2);
}
} else if (if_block0) {
group_outros();
transition_out(if_block0, 1, 1, () => {
if_block0 = null;
});
check_outros();
}
if (/*page*/ ctx[0] < /*totalPages*/ ctx[1]) {
if (if_block1) {
if_block1.p(ctx, dirty);
if (dirty & /*page, totalPages*/ 3) {
transition_in(if_block1, 1);
}
} else {
if_block1 = create_if_block_4$1(ctx);
if_block1.c();
transition_in(if_block1, 1);
if_block1.m(nav, t3);
}
} else if (if_block1) {
group_outros();
transition_out(if_block1, 1, 1, () => {
if_block1 = null;
});
check_outros();
}
if (/*page*/ ctx[0] > 3) {
if (if_block2) {
if_block2.p(ctx, dirty);
if (dirty & /*page*/ 1) {
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, t4);
}
} else if (if_block2) {
group_outros();
transition_out(if_block2, 1, 1, () => {
if_block2 = null;
});
check_outros();
}
if (dirty & /*Array, page, handlePage, totalPages*/ 11) {
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$1(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$1(child_ctx);
each_blocks_1[i].c();
transition_in(each_blocks_1[i], 1);
each_blocks_1[i].m(ul, t5);
}
}
group_outros();
for (i = each_value_2.length; i < each_blocks_1.length; i += 1) {
out(i);
}
check_outros();
}
if (/*totalPages*/ ctx[1] - /*page*/ ctx[0] > 2) {
if (if_block3) {
if_block3.p(ctx, dirty);
if (dirty & /*totalPages, page*/ 3) {
transition_in(if_block3, 1);
}
} else {
if_block3 = create_if_block$2(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*/ 4) {
each_value = /*posts*/ ctx[2];
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, div1, 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(section0);
if (detaching) detach_dev(t1);
if (detaching) detach_dev(section1);
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$5.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$5($$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(`<Posts> was created with unknown prop '${key}'`);
});
const func = x => x + page - 2;
$$self.$$set = $$props => {
if ("location" in $$props) $$invalidate(4, location = $$props.location);
};
$$self.$capture_state = () => ({
onMount,
getPosts,
Link,
queryString,
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, func];
}
class Posts extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance$5, create_fragment$5, safe_not_equal, { location: 4 });
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Posts",
options,
id: create_fragment$5.name
});
const { ctx } = this.$$;
const props = options.props || {};
if (/*location*/ ctx[4] === undefined && !("location" in props)) {
console.warn("<Posts> was created without expected prop 'location'");
}
}
get location() {
throw new Error("<Posts>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set location(value) {
throw new Error("<Posts>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
/* src/routes/Post.svelte generated by Svelte v3.38.2 */
const file$3 = "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$1(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$3, 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$1.name,
type: "if",
source: "(25:8) {#if post}",
ctx
});
return block;
}
// (32:0) {#if post}
function create_if_block$1(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$3, 37, 36, 840);
add_location(p0, file$3, 36, 20, 800);
add_location(p1, file$3, 39, 20, 944);
attr_dev(div0, "class", "column is-one-third box");
add_location(div0, file$3, 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$3, 52, 20, 1395);
attr_dev(figure, "class", "image");
add_location(figure, file$3, 51, 16, 1352);
attr_dev(div1, "class", "column");
add_location(div1, file$3, 50, 12, 1315);
attr_dev(div2, "class", "columns");
add_location(div2, file$3, 34, 8, 708);
attr_dev(section, "class", "section");
add_location(section, file$3, 33, 4, 674);
attr_dev(div3, "class", "container");
add_location(div3, file$3, 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$1.name,
type: "if",
source: "(32:0) {#if post}",
ctx
});
return block;
}
// (45:32) <Link to="/tag/{tag}">
function create_default_slot$2(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$2.name,
type: "slot",
source: "(45:32) <Link to=\\\"/tag/{tag}\\\">",
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$2] },
$$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$3, 43, 28, 1091);
add_location(ul, file$3, 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$4(ctx) {
let section;
let div;
let t;
let if_block1_anchor;
let current;
let if_block0 = /*post*/ ctx[0] && create_if_block_1$1(ctx);
let if_block1 = /*post*/ ctx[0] && create_if_block$1(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$3, 23, 4, 496);
attr_dev(section, "class", "hero is-primary");
add_location(section, file$3, 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$1(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$1(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$4.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$4($$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(`<Post> 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$4, create_fragment$4, safe_not_equal, { id: 2 });
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Post",
options,
id: create_fragment$4.name
});
const { ctx } = this.$$;
const props = options.props || {};
if (/*id*/ ctx[2] === undefined && !("id" in props)) {
console.warn("<Post> was created without expected prop 'id'");
}
}
get id() {
throw new Error("<Post>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set id(value) {
throw new Error("<Post>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
/* src/routes/Login.svelte generated by Svelte v3.38.2 */
const file$2 = "src/routes/Login.svelte";
function create_fragment$3(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$2, 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$2, 18, 16, 494);
attr_dev(div0, "class", "control");
add_location(div0, file$2, 17, 12, 456);
attr_dev(div1, "class", "field");
add_location(div1, file$2, 15, 8, 359);
attr_dev(label1, "for", "password");
attr_dev(label1, "class", "label");
add_location(label1, file$2, 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$2, 31, 16, 911);
attr_dev(div2, "class", "control");
add_location(div2, file$2, 30, 12, 873);
attr_dev(div3, "class", "field");
add_location(div3, file$2, 28, 8, 776);
attr_dev(button, "class", "button is-link");
add_location(button, file$2, 43, 16, 1267);
attr_dev(div4, "class", "control");
add_location(div4, file$2, 42, 12, 1229);
attr_dev(div5, "class", "field");
add_location(div5, file$2, 41, 8, 1197);
add_location(form, file$2, 14, 4, 309);
attr_dev(div6, "class", "container");
add_location(div6, file$2, 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$3.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$3($$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(`<Login> 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$3, create_fragment$3, safe_not_equal, {});
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Login",
options,
id: create_fragment$3.name
});
}
}
/* src/routes/Logout.svelte generated by Svelte v3.38.2 */
function create_fragment$2(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$2.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$2($$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(`<Logout> 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$2, create_fragment$2, safe_not_equal, {});
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Logout",
options,
id: create_fragment$2.name
});
}
}
/* src/routes/Tag.svelte generated by Svelte v3.38.2 */
const file$1 = "src/routes/Tag.svelte";
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[8] = list[i];
return child_ctx;
}
function get_each_context_1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[11] = list[i];
return child_ctx;
}
function get_each_context_2(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[14] = list[i];
return child_ctx;
}
// (50:12) {#if page > 1}
function create_if_block_5(ctx) {
let link;
let current;
link = new Link({
props: {
to: "/tag/" + /*id*/ ctx[0] + "?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[4](/*page*/ ctx[1] - 1))) /*handlePage*/ ctx[4](/*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 & /*id, page*/ 3) link_changes.to = "/tag/" + /*id*/ ctx[0] + "?page=" + (/*page*/ ctx[1] - 1);
if (dirty & /*$$scope*/ 131072) {
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: "(50:12) {#if page > 1}",
ctx
});
return block;
}
// (51:16) <Link on:click={handlePage(page - 1)} to="/tag/{id}?page={page - 1}" class="pagination-previous" aria-label="Previous">
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: "(51:16) <Link on:click={handlePage(page - 1)} to=\\\"/tag/{id}?page={page - 1}\\\" class=\\\"pagination-previous\\\" aria-label=\\\"Previous\\\">",
ctx
});
return block;
}
// (58:12) {#if page < totalPages}
function create_if_block_4(ctx) {
let link;
let current;
link = new Link({
props: {
to: "/tag/" + /*id*/ ctx[0] + "?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[4](/*page*/ ctx[1] + 1))) /*handlePage*/ ctx[4](/*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 & /*id, page*/ 3) link_changes.to = "/tag/" + /*id*/ ctx[0] + "?page=" + (/*page*/ ctx[1] + 1);
if (dirty & /*$$scope*/ 131072) {
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: "(58:12) {#if page < totalPages}",
ctx
});
return block;
}
// (59:16) <Link on:click={handlePage(page + 1)} to="/tag/{id}?page={page + 1}" class="pagination-next" aria-label="Next">
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: "(59:16) <Link on:click={handlePage(page + 1)} to=\\\"/tag/{id}?page={page + 1}\\\" class=\\\"pagination-next\\\" aria-label=\\\"Next\\\">",
ctx
});
return block;
}
// (67:16) {#if page > 3}
function create_if_block_3(ctx) {
let li0;
let link;
let t0;
let li1;
let span;
let current;
link = new Link({
props: {
to: "/tag/" + /*id*/ ctx[0] + "?page=" + 1,
class: "pagination-link",
"aria-label": "Goto page 1",
$$slots: { default: [create_default_slot_5] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", /*handlePage*/ ctx[4](1));
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$1, 67, 20, 1842);
attr_dev(span, "class", "pagination-ellipsis");
add_location(span, file$1, 76, 24, 2196);
add_location(li1, file$1, 75, 20, 2167);
},
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(ctx, dirty) {
const link_changes = {};
if (dirty & /*id*/ 1) link_changes.to = "/tag/" + /*id*/ ctx[0] + "?page=" + 1;
if (dirty & /*$$scope*/ 131072) {
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.name,
type: "if",
source: "(67:16) {#if page > 3}",
ctx
});
return block;
}
// (69:24) <Link on:click={handlePage(1)} to="/tag/{id}?page={1}" class="pagination-link" aria-label="Goto page 1">
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: "(69:24) <Link on:click={handlePage(1)} to=\\\"/tag/{id}?page={1}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page 1\\\">",
ctx
});
return block;
}
// (81:20) {#if i >= 1 && i <= totalPages}
function create_if_block_1(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block_2, create_else_block];
const if_blocks = [];
function select_block_type(ctx, dirty) {
if (/*i*/ ctx[14] == /*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.name,
type: "if",
source: "(81:20) {#if i >= 1 && i <= totalPages}",
ctx
});
return block;
}
// (91:24) {:else}
function create_else_block(ctx) {
let li;
let link;
let current;
link = new Link({
props: {
to: "/tag/" + /*id*/ ctx[0] + "?page=" + /*i*/ ctx[14],
class: "pagination-link",
"aria-label": "Goto page " + /*i*/ ctx[14],
$$slots: { default: [create_default_slot_4] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", function () {
if (is_function(/*handlePage*/ ctx[4](/*i*/ ctx[14]))) /*handlePage*/ ctx[4](/*i*/ ctx[14]).apply(this, arguments);
});
const block = {
c: function create() {
li = element("li");
create_component(link.$$.fragment);
add_location(li, file$1, 91, 28, 2925);
},
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 & /*id, page*/ 3) link_changes.to = "/tag/" + /*id*/ ctx[0] + "?page=" + /*i*/ ctx[14];
if (dirty & /*page*/ 2) link_changes["aria-label"] = "Goto page " + /*i*/ ctx[14];
if (dirty & /*$$scope, page*/ 131074) {
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.name,
type: "else",
source: "(91:24) {:else}",
ctx
});
return block;
}
// (82:24) {#if i == page}
function create_if_block_2(ctx) {
let li;
let link;
let current;
link = new Link({
props: {
to: "/tag/" + /*id*/ ctx[0] + "?page=" + /*i*/ ctx[14],
class: "pagination-link is-current",
"aria-label": "Goto page " + /*i*/ ctx[14],
$$slots: { default: [create_default_slot_3] },
$$scope: { ctx }
},
$$inline: true
});
link.$on("click", function () {
if (is_function(/*handlePage*/ ctx[4](/*i*/ ctx[14]))) /*handlePage*/ ctx[4](/*i*/ ctx[14]).apply(this, arguments);
});
const block = {
c: function create() {
li = element("li");
create_component(link.$$.fragment);
add_location(li, file$1, 82, 28, 2489);
},
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 & /*id, page*/ 3) link_changes.to = "/tag/" + /*id*/ ctx[0] + "?page=" + /*i*/ ctx[14];
if (dirty & /*page*/ 2) link_changes["aria-label"] = "Goto page " + /*i*/ ctx[14];
if (dirty & /*$$scope, page*/ 131074) {
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.name,
type: "if",
source: "(82:24) {#if i == page}",
ctx
});
return block;
}
// (93:32) <Link on:click={handlePage(i)} to="/tag/{id}?page={i}" class="pagination-link" aria-label="Goto page {i}">
function create_default_slot_4(ctx) {
let t_value = /*i*/ ctx[14] + "";
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[14] + "")) 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: "(93:32) <Link on:click={handlePage(i)} to=\\\"/tag/{id}?page={i}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page {i}\\\">",
ctx
});
return block;
}
// (84:32) <Link on:click={handlePage(i)} to="/tag/{id}?page={i}" class="pagination-link is-current" aria-label="Goto page {i}">
function create_default_slot_3(ctx) {
let t_value = /*i*/ ctx[14] + "";
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[14] + "")) 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: "(84:32) <Link on:click={handlePage(i)} to=\\\"/tag/{id}?page={i}\\\" class=\\\"pagination-link is-current\\\" aria-label=\\\"Goto page {i}\\\">",
ctx
});
return block;
}
// (80: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[14] >= 1 && /*i*/ ctx[14] <= /*totalPages*/ ctx[2] && create_if_block_1(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[14] >= 1 && /*i*/ ctx[14] <= /*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(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: "(80:16) {#each [...Array(5).keys()].map((x) => x + page - 2) as i}",
ctx
});
return block;
}
// (103:16) {#if totalPages - page > 2}
function create_if_block(ctx) {
let li0;
let span;
let t1;
let li1;
let link;
let current;
link = new Link({
props: {
to: "/tag/" + /*id*/ ctx[0] + "?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[4](/*totalPages*/ ctx[2]))) /*handlePage*/ ctx[4](/*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$1, 104, 24, 3463);
add_location(li0, file$1, 103, 20, 3434);
add_location(li1, file$1, 106, 20, 3559);
},
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 & /*id, totalPages*/ 5) link_changes.to = "/tag/" + /*id*/ ctx[0] + "?page=" + /*totalPages*/ ctx[2];
if (dirty & /*totalPages*/ 4) link_changes["aria-label"] = "Goto page " + /*totalPages*/ ctx[2];
if (dirty & /*$$scope, totalPages*/ 131076) {
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.name,
type: "if",
source: "(103:16) {#if totalPages - page > 2}",
ctx
});
return block;
}
// (108:24) <Link on:click={handlePage(totalPages)} to="/tag/{id}?page={totalPages}" class="pagination-link" aria-label="Goto page {totalPages}" >
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: "(108:24) <Link on:click={handlePage(totalPages)} to=\\\"/tag/{id}?page={totalPages}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page {totalPages}\\\" >",
ctx
});
return block;
}
// (124:28) <Link to="/post/{post.id}">
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[8].id);
if (img.src !== (img_src_value = /*post*/ ctx[8].image_path)) attr_dev(img, "src", img_src_value);
add_location(img, file$1, 124, 32, 4312);
},
m: function mount(target, anchor) {
insert_dev(target, img, anchor);
},
p: function update(ctx, dirty) {
if (dirty & /*posts*/ 8 && img_alt_value !== (img_alt_value = /*post*/ ctx[8].id)) {
attr_dev(img, "alt", img_alt_value);
}
if (dirty & /*posts*/ 8 && img.src !== (img_src_value = /*post*/ ctx[8].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: "(124:28) <Link to=\\\"/post/{post.id}\\\">",
ctx
});
return block;
}
// (133:36) <Link to="/tag/{tag}">
function create_default_slot$1(ctx) {
let t_value = /*tag*/ ctx[11] + "";
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*/ 8 && t_value !== (t_value = /*tag*/ ctx[11] + "")) 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: "(133:36) <Link to=\\\"/tag/{tag}\\\">",
ctx
});
return block;
}
// (131:28) {#each post.tags as tag (tag)}
function create_each_block_1(key_1, ctx) {
let p;
let link;
let t;
let current;
link = new Link({
props: {
to: "/tag/" + /*tag*/ ctx[11],
$$slots: { default: [create_default_slot$1] },
$$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$1, 131, 32, 4637);
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*/ 8) link_changes.to = "/tag/" + /*tag*/ ctx[11];
if (dirty & /*$$scope, posts*/ 131080) {
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.name,
type: "each",
source: "(131:28) {#each post.tags as tag (tag)}",
ctx
});
return block;
}
// (120:12) {#each posts as post (post.id)}
function create_each_block(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[8].id,
$$slots: { default: [create_default_slot_1] },
$$scope: { ctx }
},
$$inline: true
});
let each_value_1 = /*post*/ ctx[8].tags;
validate_each_argument(each_value_1);
const get_key = ctx => /*tag*/ ctx[11];
validate_each_keys(ctx, each_value_1, get_each_context_1, get_key);
for (let i = 0; i < each_value_1.length; i += 1) {
let child_ctx = get_each_context_1(ctx, each_value_1, i);
let key = get_key(child_ctx);
each_1_lookup.set(key, each_blocks[i] = create_each_block_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$1, 122, 24, 4201);
attr_dev(div0, "class", "card-image");
add_location(div0, file$1, 121, 20, 4152);
attr_dev(div1, "class", "content");
add_location(div1, file$1, 129, 24, 4524);
attr_dev(div2, "class", "card-content");
add_location(div2, file$1, 128, 20, 4473);
attr_dev(div3, "class", "column is-one-quarter card");
add_location(div3, file$1, 120, 16, 4091);
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*/ 8) link_changes.to = "/post/" + /*post*/ ctx[8].id;
if (dirty & /*$$scope, posts*/ 131080) {
link_changes.$$scope = { dirty, ctx };
}
link.$set(link_changes);
if (dirty & /*posts*/ 8) {
each_value_1 = /*post*/ ctx[8].tags;
validate_each_argument(each_value_1);
group_outros();
validate_each_keys(ctx, each_value_1, get_each_context_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, null, get_each_context_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.name,
type: "each",
source: "(120:12) {#each posts as post (post.id)}",
ctx
});
return block;
}
function create_fragment$1(ctx) {
let section0;
let div0;
let p0;
let t0;
let t1;
let p1;
let t3;
let section1;
let div2;
let nav;
let t4;
let t5;
let ul;
let t6;
let t7;
let t8;
let div1;
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(ctx);
let each_value_2 = [...Array(5).keys()].map(/*func*/ ctx[6]);
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(ctx);
let each_value = /*posts*/ ctx[3];
validate_each_argument(each_value);
const get_key = ctx => /*post*/ ctx[8].id;
validate_each_keys(ctx, each_value, get_each_context, get_key);
for (let i = 0; i < each_value.length; i += 1) {
let child_ctx = get_each_context(ctx, each_value, i);
let key = get_key(child_ctx);
each1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
}
const block = {
c: function create() {
section0 = element("section");
div0 = element("div");
p0 = element("p");
t0 = text(/*id*/ ctx[0]);
t1 = space();
p1 = element("p");
p1.textContent = "Tag";
t3 = space();
section1 = element("section");
div2 = element("div");
nav = element("nav");
if (if_block0) if_block0.c();
t4 = space();
if (if_block1) if_block1.c();
t5 = space();
ul = element("ul");
if (if_block2) if_block2.c();
t6 = space();
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].c();
}
t7 = space();
if (if_block3) if_block3.c();
t8 = space();
div1 = element("div");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr_dev(p0, "class", "title");
add_location(p0, file$1, 39, 8, 931);
attr_dev(p1, "class", "subtitle");
add_location(p1, file$1, 42, 8, 987);
attr_dev(div0, "class", "hero-body");
add_location(div0, file$1, 38, 4, 899);
attr_dev(section0, "class", "hero is-primary");
add_location(section0, file$1, 37, 0, 861);
attr_dev(ul, "class", "pagination-list");
add_location(ul, file$1, 65, 12, 1762);
attr_dev(nav, "class", "pagination");
attr_dev(nav, "role", "navigation");
attr_dev(nav, "aria-label", "pagination");
add_location(nav, file$1, 48, 8, 1100);
attr_dev(div1, "class", "columns is-multiline");
add_location(div1, file$1, 118, 8, 3996);
attr_dev(div2, "class", "container");
add_location(div2, file$1, 47, 4, 1068);
attr_dev(section1, "class", "section");
add_location(section1, file$1, 46, 0, 1038);
},
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, p0);
append_dev(p0, t0);
append_dev(div0, t1);
append_dev(div0, p1);
insert_dev(target, t3, anchor);
insert_dev(target, section1, anchor);
append_dev(section1, div2);
append_dev(div2, nav);
if (if_block0) if_block0.m(nav, null);
append_dev(nav, t4);
if (if_block1) if_block1.m(nav, null);
append_dev(nav, t5);
append_dev(nav, ul);
if (if_block2) if_block2.m(ul, null);
append_dev(ul, t6);
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].m(ul, null);
}
append_dev(ul, t7);
if (if_block3) if_block3.m(ul, null);
append_dev(div2, t8);
append_dev(div2, div1);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div1, null);
}
current = true;
},
p: function update(ctx, [dirty]) {
if (!current || dirty & /*id*/ 1) set_data_dev(t0, /*id*/ ctx[0]);
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, t4);
}
} 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, t5);
}
} 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(ctx);
if_block2.c();
transition_in(if_block2, 1);
if_block2.m(ul, t6);
}
} else if (if_block2) {
group_outros();
transition_out(if_block2, 1, 1, () => {
if_block2 = null;
});
check_outros();
}
if (dirty & /*id, Array, page, handlePage, totalPages*/ 23) {
each_value_2 = [...Array(5).keys()].map(/*func*/ ctx[6]);
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, t7);
}
}
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(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*/ 8) {
each_value = /*posts*/ ctx[3];
validate_each_argument(each_value);
group_outros();
validate_each_keys(ctx, each_value, get_each_context, get_key);
each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each1_lookup, div1, outro_and_destroy_block, create_each_block, null, get_each_context);
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(section0);
if (detaching) detach_dev(t3);
if (detaching) detach_dev(section1);
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$1.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance$1($$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(`<Tag> was created with unknown prop '${key}'`);
});
const func = x => x + page - 2;
$$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,
Link,
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, func];
}
class Tag extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance$1, create_fragment$1, safe_not_equal, { location: 5, id: 0 });
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Tag",
options,
id: create_fragment$1.name
});
const { ctx } = this.$$;
const props = options.props || {};
if (/*location*/ ctx[5] === undefined && !("location" in props)) {
console.warn("<Tag> was created without expected prop 'location'");
}
if (/*id*/ ctx[0] === undefined && !("id" in props)) {
console.warn("<Tag> was created without expected prop 'id'");
}
}
get location() {
throw new Error("<Tag>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set location(value) {
throw new Error("<Tag>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get id() {
throw new Error("<Tag>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set id(value) {
throw new Error("<Tag>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
/* src/App.svelte generated by Svelte v3.38.2 */
const file = "src/App.svelte";
// (20:0) <Router {url}>
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 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
});
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);
add_location(div, file, 21, 1, 461);
},
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);
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);
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);
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);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot.name,
type: "slot",
source: "(20:0) <Router {url}>",
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(`<App> 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,
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("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set url(value) {
throw new Error("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
const app = new App({
target: document.body,
hydrate: false,
});
return app;
}());
//# sourceMappingURL=bundle.js.map