2021-05-10 22:47:35 +07:00
( 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 ;
}
2021-05-11 00:37:27 +07:00
class HtmlTag {
constructor ( anchor = null ) {
this . a = anchor ;
this . e = this . n = null ;
}
m ( html , target , anchor = null ) {
if ( ! this . e ) {
this . e = element ( target . nodeName ) ;
this . t = target ;
this . h ( html ) ;
}
this . i ( anchor ) ;
}
h ( html ) {
this . e . innerHTML = html ;
this . n = Array . from ( this . e . childNodes ) ;
}
i ( anchor ) {
for ( let i = 0 ; i < this . n . length ; i += 1 ) {
insert ( this . t , this . n [ i ] , anchor ) ;
}
}
p ( html ) {
this . d ( ) ;
this . h ( html ) ;
this . i ( this . a ) ;
}
d ( ) {
this . n . forEach ( detach ) ;
}
}
2021-05-10 22:47:35 +07:00
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 ) ;
}
}
2021-05-11 00:37:27 +07:00
const globals = ( typeof window !== 'undefined'
? window
: typeof globalThis !== 'undefined'
? globalThis
: global ) ;
2021-05-10 22:47:35 +07:00
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 } ) ;
}
2021-05-11 00:37:27 +07:00
function prop _dev ( node , property , value ) {
node [ property ] = value ;
dispatch _dev ( 'SvelteDOMSetProperty' , { node , property , value } ) ;
}
2021-05-10 22:47:35 +07:00
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 */
2021-05-11 03:25:33 +07:00
function create _fragment$e ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 03:25:33 +07:00
id : create _fragment$e . name ,
2021-05-10 22:47:35 +07:00
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function instance$e ( $$self , $$props , $$invalidate ) {
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
init ( this , options , instance$e , create _fragment$e , safe _not _equal , { basepath : 3 , url : 4 } ) ;
2021-05-10 22:47:35 +07:00
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Router" ,
options ,
2021-05-11 03:25:33 +07:00
id : create _fragment$e . name
2021-05-10 22:47:35 +07:00
} ) ;
}
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}
2021-05-11 00:37:27 +07:00
function create _if _block$5 ( ctx ) {
2021-05-10 22:47:35 +07:00
let current _block _type _index ;
let if _block ;
let if _block _anchor ;
let current ;
2021-05-11 03:25:33 +07:00
const if _block _creators = [ create _if _block _1$5 , create _else _block$4 ] ;
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 00:37:27 +07:00
id : create _if _block$5 . name ,
2021-05-10 22:47:35 +07:00
type : "if" ,
source : "(40:0) {#if $activeRoute !== null && $activeRoute.route === route}" ,
ctx
} ) ;
return block ;
}
// (43:2) {:else}
2021-05-11 03:25:33 +07:00
function create _else _block$4 ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 03:25:33 +07:00
id : create _else _block$4 . name ,
2021-05-10 22:47:35 +07:00
type : "else" ,
source : "(43:2) {:else}" ,
ctx
} ) ;
return block ;
}
// (41:2) {#if component !== null}
2021-05-11 00:37:27 +07:00
function create _if _block _1$5 ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 00:37:27 +07:00
id : create _if _block _1$5 . name ,
2021-05-10 22:47:35 +07:00
type : "if" ,
source : "(41:2) {#if component !== null}" ,
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function create _fragment$d ( ctx ) {
2021-05-10 22:47:35 +07:00
let if _block _anchor ;
let current ;
2021-05-11 00:37:27 +07:00
let if _block = /*$activeRoute*/ ctx [ 1 ] !== null && /*$activeRoute*/ ctx [ 1 ] . route === /*route*/ ctx [ 7 ] && create _if _block$5 ( ctx ) ;
2021-05-10 22:47:35 +07:00
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 {
2021-05-11 00:37:27 +07:00
if _block = create _if _block$5 ( ctx ) ;
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 03:25:33 +07:00
id : create _fragment$d . name ,
2021-05-10 22:47:35 +07:00
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function instance$d ( $$self , $$props , $$invalidate ) {
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
init ( this , options , instance$d , create _fragment$d , safe _not _equal , { path : 8 , component : 0 } ) ;
2021-05-10 22:47:35 +07:00
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Route" ,
options ,
2021-05-11 03:25:33 +07:00
id : create _fragment$d . name
2021-05-10 22:47:35 +07:00
} ) ;
}
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 */
2021-05-11 00:37:27 +07:00
const file$a = "node_modules/svelte-routing/src/Link.svelte" ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function create _fragment$c ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 00:37:27 +07:00
add _location ( a , file$a , 40 , 0 , 1249 ) ;
2021-05-10 22:47:35 +07:00
} ,
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 ,
2021-05-11 03:25:33 +07:00
id : create _fragment$c . name ,
2021-05-10 22:47:35 +07:00
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function instance$c ( $$self , $$props , $$invalidate ) {
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
init ( this , options , instance$c , create _fragment$c , safe _not _equal , {
2021-05-10 22:47:35 +07:00
to : 7 ,
replace : 8 ,
state : 9 ,
getProps : 10
} ) ;
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Link" ,
options ,
2021-05-11 03:25:33 +07:00
id : create _fragment$c . name
2021-05-10 22:47:35 +07:00
} ) ;
}
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 */
2021-05-11 00:37:27 +07:00
const file$9 = "src/Navbar.svelte" ;
2021-05-10 22:47:35 +07:00
// (19:8) <Link class="navbar-item" to="/">
2021-05-11 00:37:27 +07:00
function create _default _slot _5$1 ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 00:37:27 +07:00
id : create _default _slot _5$1 . name ,
2021-05-10 22:47:35 +07:00
type : "slot" ,
source : "(19:8) <Link class=\\\"navbar-item\\\" to=\\\"/\\\">" ,
ctx
} ) ;
return block ;
}
// (37:12) <Link class="navbar-item" to="/posts">
2021-05-11 00:37:27 +07:00
function create _default _slot _4$1 ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 00:37:27 +07:00
id : create _default _slot _4$1 . name ,
2021-05-10 22:47:35 +07:00
type : "slot" ,
source : "(37:12) <Link class=\\\"navbar-item\\\" to=\\\"/posts\\\">" ,
ctx
} ) ;
return block ;
}
// (38:12) {#if loggedIn}
2021-05-11 00:37:27 +07:00
function create _if _block _1$4 ( ctx ) {
2021-05-10 22:47:35 +07:00
let link ;
let current ;
link = new Link ( {
props : {
class : "navbar-item" ,
to : "/upload" ,
2021-05-11 00:37:27 +07:00
$$slots : { default : [ create _default _slot _3$1 ] } ,
2021-05-10 22:47:35 +07:00
$$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 ,
2021-05-11 00:37:27 +07:00
id : create _if _block _1$4 . name ,
2021-05-10 22:47:35 +07:00
type : "if" ,
source : "(38:12) {#if loggedIn}" ,
ctx
} ) ;
return block ;
}
// (39:16) <Link class="navbar-item" to="/upload">
2021-05-11 00:37:27 +07:00
function create _default _slot _3$1 ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 00:37:27 +07:00
id : create _default _slot _3$1 . name ,
2021-05-10 22:47:35 +07:00
type : "slot" ,
source : "(39:16) <Link class=\\\"navbar-item\\\" to=\\\"/upload\\\">" ,
ctx
} ) ;
return block ;
}
// (52:12) {:else}
2021-05-11 03:25:33 +07:00
function create _else _block$3 ( ctx ) {
2021-05-10 22:47:35 +07:00
let div1 ;
let div0 ;
let link0 ;
let t ;
let link1 ;
let current ;
link0 = new Link ( {
props : {
to : "/auth/register" ,
class : "button is-primary" ,
2021-05-11 00:37:27 +07:00
$$slots : { default : [ create _default _slot _2$1 ] } ,
2021-05-10 22:47:35 +07:00
$$scope : { ctx }
} ,
$$inline : true
} ) ;
link1 = new Link ( {
props : {
to : "/auth/login" ,
class : "button is-light" ,
2021-05-11 00:37:27 +07:00
$$slots : { default : [ create _default _slot _1$1 ] } ,
2021-05-10 22:47:35 +07:00
$$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" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div0 , file$9 , 53 , 20 , 1515 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div1 , "class" , "navbar-item" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div1 , file$9 , 52 , 16 , 1469 ) ;
2021-05-10 22:47:35 +07:00
} ,
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 ,
2021-05-11 03:25:33 +07:00
id : create _else _block$3 . name ,
2021-05-10 22:47:35 +07:00
type : "else" ,
source : "(52:12) {:else}" ,
ctx
} ) ;
return block ;
}
// (44:12) {#if loggedIn}
2021-05-11 00:37:27 +07:00
function create _if _block$4 ( ctx ) {
2021-05-10 22:47:35 +07:00
let div1 ;
let div0 ;
let link ;
let current ;
link = new Link ( {
props : {
to : "/auth/logout" ,
class : "button is-light" ,
2021-05-11 03:25:33 +07:00
$$slots : { default : [ create _default _slot$5 ] } ,
2021-05-10 22:47:35 +07:00
$$scope : { ctx }
} ,
$$inline : true
} ) ;
const block = {
c : function create ( ) {
div1 = element ( "div" ) ;
div0 = element ( "div" ) ;
create _component ( link . $$ . fragment ) ;
attr _dev ( div0 , "class" , "buttons" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div0 , file$9 , 45 , 20 , 1220 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div1 , "class" , "navbar-item" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div1 , file$9 , 44 , 16 , 1174 ) ;
2021-05-10 22:47:35 +07:00
} ,
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 ,
2021-05-11 00:37:27 +07:00
id : create _if _block$4 . name ,
2021-05-10 22:47:35 +07:00
type : "if" ,
source : "(44:12) {#if loggedIn}" ,
ctx
} ) ;
return block ;
}
// (55:24) <Link to="/auth/register" class="button is-primary">
2021-05-11 00:37:27 +07:00
function create _default _slot _2$1 ( ctx ) {
2021-05-10 22:47:35 +07:00
let strong ;
const block = {
c : function create ( ) {
strong = element ( "strong" ) ;
strong . textContent = "Register" ;
2021-05-11 00:37:27 +07:00
add _location ( strong , file$9 , 55 , 28 , 1642 ) ;
2021-05-10 22:47:35 +07:00
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , strong , anchor ) ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( strong ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 00:37:27 +07:00
id : create _default _slot _2$1 . name ,
2021-05-10 22:47:35 +07:00
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">
2021-05-11 00:37:27 +07:00
function create _default _slot _1$1 ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 00:37:27 +07:00
id : create _default _slot _1$1 . name ,
2021-05-10 22:47:35 +07:00
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">
2021-05-11 03:25:33 +07:00
function create _default _slot$5 ( ctx ) {
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 03:25:33 +07:00
id : create _default _slot$5 . name ,
2021-05-10 22:47:35 +07:00
type : "slot" ,
source : "(47:24) <Link to=\\\"/auth/logout\\\" class=\\\"button is-light\\\">" ,
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function create _fragment$b ( ctx ) {
2021-05-10 22:47:35 +07:00
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 : "/" ,
2021-05-11 00:37:27 +07:00
$$slots : { default : [ create _default _slot _5$1 ] } ,
2021-05-10 22:47:35 +07:00
$$scope : { ctx }
} ,
$$inline : true
} ) ;
link1 = new Link ( {
props : {
class : "navbar-item" ,
to : "/posts" ,
2021-05-11 00:37:27 +07:00
$$slots : { default : [ create _default _slot _4$1 ] } ,
2021-05-10 22:47:35 +07:00
$$scope : { ctx }
} ,
$$inline : true
} ) ;
2021-05-11 00:37:27 +07:00
let if _block0 = /*loggedIn*/ ctx [ 1 ] && create _if _block _1$4 ( ctx ) ;
2021-05-11 03:25:33 +07:00
const if _block _creators = [ create _if _block$4 , create _else _block$3 ] ;
2021-05-10 22:47:35 +07:00
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" ) ;
2021-05-11 00:37:27 +07:00
add _location ( span0 , file$9 , 28 , 12 , 678 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( span1 , "aria-hidden" , "true" ) ;
2021-05-11 00:37:27 +07:00
add _location ( span1 , file$9 , 29 , 12 , 718 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( span2 , "aria-hidden" , "true" ) ;
2021-05-11 00:37:27 +07:00
add _location ( span2 , file$9 , 30 , 12 , 758 ) ;
2021-05-10 22:47:35 +07:00
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" ) ;
2021-05-11 00:37:27 +07:00
add _location ( a , file$9 , 20 , 8 , 472 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div0 , "class" , "navbar-brand" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div0 , file$9 , 17 , 4 , 379 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div1 , "class" , "navbar-start" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div1 , file$9 , 35 , 8 , 878 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div2 , "class" , "navbar-end" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div2 , file$9 , 42 , 8 , 1106 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div3 , "class" , "navbar-menu" ) ;
toggle _class ( div3 , "is-active" , /*menu_shown*/ ctx [ 0 ] ) ;
2021-05-11 00:37:27 +07:00
add _location ( div3 , file$9 , 34 , 4 , 815 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( nav , "class" , "navbar" ) ;
attr _dev ( nav , "role" , "navigation" ) ;
attr _dev ( nav , "aria-label" , "main navigation" ) ;
2021-05-11 00:37:27 +07:00
add _location ( nav , file$9 , 16 , 0 , 307 ) ;
2021-05-10 22:47:35 +07:00
} ,
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 {
2021-05-11 00:37:27 +07:00
if _block0 = create _if _block _1$4 ( ctx ) ;
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 03:25:33 +07:00
id : create _fragment$b . name ,
2021-05-10 22:47:35 +07:00
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function instance$b ( $$self , $$props , $$invalidate ) {
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
init ( this , options , instance$b , create _fragment$b , safe _not _equal , { } ) ;
2021-05-10 22:47:35 +07:00
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Navbar" ,
options ,
2021-05-11 03:25:33 +07:00
id : create _fragment$b . name
2021-05-10 22:47:35 +07:00
} ) ;
}
}
/* src/routes/Home.svelte generated by Svelte v3.38.2 */
2021-05-11 00:37:27 +07:00
const file$8 = "src/routes/Home.svelte" ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function create _fragment$a ( ctx ) {
2021-05-10 22:47:35 +07:00
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" ) ;
2021-05-11 00:37:27 +07:00
add _location ( p0 , file$8 , 5 , 4 , 94 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( p1 , "class" , "subtitle" ) ;
2021-05-11 00:37:27 +07:00
add _location ( p1 , file$8 , 6 , 4 , 128 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div , "class" , "hero-body" ) ;
2021-05-11 00:37:27 +07:00
add _location ( div , file$8 , 4 , 2 , 66 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( section , "class" , "hero is-primary is-medium" ) ;
2021-05-11 00:37:27 +07:00
add _location ( section , file$8 , 3 , 0 , 20 ) ;
2021-05-10 22:47:35 +07:00
} ,
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 ,
2021-05-11 03:25:33 +07:00
id : create _fragment$a . name ,
2021-05-10 22:47:35 +07:00
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function instance$a ( $$self , $$props ) {
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
init ( this , options , instance$a , create _fragment$a , safe _not _equal , { } ) ;
2021-05-10 22:47:35 +07:00
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Home" ,
options ,
2021-05-11 03:25:33 +07:00
id : create _fragment$a . name
2021-05-10 22:47:35 +07:00
} ) ;
}
}
2021-05-11 00:37:27 +07:00
var bind = function bind ( fn , thisArg ) {
return function wrap ( ) {
var args = new Array ( arguments . length ) ;
for ( var i = 0 ; i < args . length ; i ++ ) {
args [ i ] = arguments [ i ] ;
}
return fn . apply ( thisArg , args ) ;
} ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/*global toString:true*/
// utils is a library of generic helper functions non-specific to axios
var toString = Object . prototype . toString ;
/ * *
* Determine if a value is an Array
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is an Array , otherwise false
* /
function isArray ( val ) {
return toString . call ( val ) === '[object Array]' ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is undefined
*
* @ param { Object } val The value to test
* @ returns { boolean } True if the value is undefined , otherwise false
* /
function isUndefined ( val ) {
return typeof val === 'undefined' ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a Buffer
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a Buffer , otherwise false
* /
function isBuffer ( val ) {
return val !== null && ! isUndefined ( val ) && val . constructor !== null && ! isUndefined ( val . constructor )
&& typeof val . constructor . isBuffer === 'function' && val . constructor . isBuffer ( val ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is an ArrayBuffer
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is an ArrayBuffer , otherwise false
* /
function isArrayBuffer ( val ) {
return toString . call ( val ) === '[object ArrayBuffer]' ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a FormData
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is an FormData , otherwise false
* /
function isFormData ( val ) {
return ( typeof FormData !== 'undefined' ) && ( val instanceof FormData ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a view on an ArrayBuffer
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a view on an ArrayBuffer , otherwise false
* /
function isArrayBufferView ( val ) {
var result ;
if ( ( typeof ArrayBuffer !== 'undefined' ) && ( ArrayBuffer . isView ) ) {
result = ArrayBuffer . isView ( val ) ;
} else {
result = ( val ) && ( val . buffer ) && ( val . buffer instanceof ArrayBuffer ) ;
}
return result ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a String
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a String , otherwise false
* /
function isString ( val ) {
return typeof val === 'string' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a Number
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a Number , otherwise false
* /
function isNumber ( val ) {
return typeof val === 'number' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is an Object
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is an Object , otherwise false
* /
function isObject ( val ) {
return val !== null && typeof val === 'object' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a plain Object
*
* @ param { Object } val The value to test
* @ return { boolean } True if value is a plain Object , otherwise false
* /
function isPlainObject ( val ) {
if ( toString . call ( val ) !== '[object Object]' ) {
return false ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var prototype = Object . getPrototypeOf ( val ) ;
return prototype === null || prototype === Object . prototype ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a Date
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a Date , otherwise false
* /
function isDate ( val ) {
return toString . call ( val ) === '[object Date]' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a File
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a File , otherwise false
* /
function isFile ( val ) {
return toString . call ( val ) === '[object File]' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a Blob
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a Blob , otherwise false
* /
function isBlob ( val ) {
return toString . call ( val ) === '[object Blob]' ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a Function
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a Function , otherwise false
* /
function isFunction ( val ) {
return toString . call ( val ) === '[object Function]' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a Stream
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a Stream , otherwise false
* /
function isStream ( val ) {
return isObject ( val ) && isFunction ( val . pipe ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if a value is a URLSearchParams object
*
* @ param { Object } val The value to test
* @ returns { boolean } True if value is a URLSearchParams object , otherwise false
* /
function isURLSearchParams ( val ) {
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Trim excess whitespace off the beginning and end of a string
*
* @ param { String } str The String to trim
* @ returns { String } The String freed of excess whitespace
* /
function trim ( str ) {
return str . replace ( /^\s*/ , '' ) . replace ( /\s*$/ , '' ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determine if we ' re running in a standard browser environment
*
* This allows axios to run in a web worker , and react - native .
* Both environments support XMLHttpRequest , but not fully standard globals .
*
* web workers :
* typeof window - > undefined
* typeof document - > undefined
*
* react - native :
* navigator . product - > 'ReactNative'
* nativescript
* navigator . product - > 'NativeScript' or 'NS'
* /
function isStandardBrowserEnv ( ) {
if ( typeof navigator !== 'undefined' && ( navigator . product === 'ReactNative' ||
navigator . product === 'NativeScript' ||
navigator . product === 'NS' ) ) {
return false ;
}
return (
typeof window !== 'undefined' &&
typeof document !== 'undefined'
) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Iterate over an Array or an Object invoking a function for each item .
*
* If ` obj ` is an Array callback will be called passing
* the value , index , and complete array for each item .
*
* If 'obj' is an Object callback will be called passing
* the value , key , and complete object for each property .
*
* @ param { Object | Array } obj The object to iterate
* @ param { Function } fn The callback to invoke for each item
* /
function forEach ( obj , fn ) {
// Don't bother if no value provided
if ( obj === null || typeof obj === 'undefined' ) {
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Force an array if not already something iterable
if ( typeof obj !== 'object' ) {
/*eslint no-param-reassign:0*/
obj = [ obj ] ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( isArray ( obj ) ) {
// Iterate over array values
for ( var i = 0 , l = obj . length ; i < l ; i ++ ) {
fn . call ( null , obj [ i ] , i , obj ) ;
}
} else {
// Iterate over object keys
for ( var key in obj ) {
if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) {
fn . call ( null , obj [ key ] , key , obj ) ;
}
}
}
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Accepts varargs expecting each argument to be an object , then
* immutably merges the properties of each object and returns result .
*
* When multiple objects contain the same key the later object in
* the arguments list will take precedence .
*
* Example :
*
* ` ` ` js
* var result = merge ( { foo : 123 } , { foo : 456 } ) ;
* console . log ( result . foo ) ; // outputs 456
* ` ` `
*
* @ param { Object } obj1 Object to merge
* @ returns { Object } Result of all merge properties
* /
function merge ( /* obj1, obj2, obj3, ... */ ) {
var result = { } ;
function assignValue ( val , key ) {
if ( isPlainObject ( result [ key ] ) && isPlainObject ( val ) ) {
result [ key ] = merge ( result [ key ] , val ) ;
} else if ( isPlainObject ( val ) ) {
result [ key ] = merge ( { } , val ) ;
} else if ( isArray ( val ) ) {
result [ key ] = val . slice ( ) ;
} else {
result [ key ] = val ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
for ( var i = 0 , l = arguments . length ; i < l ; i ++ ) {
forEach ( arguments [ i ] , assignValue ) ;
}
return result ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Extends object a by mutably adding to it the properties of object b .
*
* @ param { Object } a The object to be extended
* @ param { Object } b The object to copy properties from
* @ param { Object } thisArg The object to bind function to
* @ return { Object } The resulting value of object a
* /
function extend ( a , b , thisArg ) {
forEach ( b , function assignValue ( val , key ) {
if ( thisArg && typeof val === 'function' ) {
a [ key ] = bind ( val , thisArg ) ;
} else {
a [ key ] = val ;
}
} ) ;
return a ;
}
/ * *
* Remove byte order marker . This catches EF BB BF ( the UTF - 8 BOM )
*
* @ param { string } content with BOM
* @ return { string } content value without BOM
* /
function stripBOM ( content ) {
if ( content . charCodeAt ( 0 ) === 0xFEFF ) {
content = content . slice ( 1 ) ;
}
return content ;
}
var utils = {
isArray : isArray ,
isArrayBuffer : isArrayBuffer ,
isBuffer : isBuffer ,
isFormData : isFormData ,
isArrayBufferView : isArrayBufferView ,
isString : isString ,
isNumber : isNumber ,
isObject : isObject ,
isPlainObject : isPlainObject ,
isUndefined : isUndefined ,
isDate : isDate ,
isFile : isFile ,
isBlob : isBlob ,
isFunction : isFunction ,
isStream : isStream ,
isURLSearchParams : isURLSearchParams ,
isStandardBrowserEnv : isStandardBrowserEnv ,
forEach : forEach ,
merge : merge ,
extend : extend ,
trim : trim ,
stripBOM : stripBOM
2021-05-10 22:47:35 +07:00
} ;
2021-05-11 00:37:27 +07:00
function encode ( val ) {
return encodeURIComponent ( val ) .
replace ( /%3A/gi , ':' ) .
replace ( /%24/g , '$' ) .
replace ( /%2C/gi , ',' ) .
replace ( /%20/g , '+' ) .
replace ( /%5B/gi , '[' ) .
replace ( /%5D/gi , ']' ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Build a URL by appending params to the end
*
* @ param { string } url The base of the url ( e . g . , http : //www.google.com)
* @ param { object } [ params ] The params to be appended
* @ returns { string } The formatted url
* /
var buildURL = function buildURL ( url , params , paramsSerializer ) {
/*eslint no-param-reassign:0*/
if ( ! params ) {
return url ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var serializedParams ;
if ( paramsSerializer ) {
serializedParams = paramsSerializer ( params ) ;
} else if ( utils . isURLSearchParams ( params ) ) {
serializedParams = params . toString ( ) ;
} else {
var parts = [ ] ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( params , function serialize ( val , key ) {
if ( val === null || typeof val === 'undefined' ) {
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( utils . isArray ( val ) ) {
key = key + '[]' ;
} else {
val = [ val ] ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( val , function parseValue ( v ) {
if ( utils . isDate ( v ) ) {
v = v . toISOString ( ) ;
} else if ( utils . isObject ( v ) ) {
v = JSON . stringify ( v ) ;
}
parts . push ( encode ( key ) + '=' + encode ( v ) ) ;
} ) ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
serializedParams = parts . join ( '&' ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( serializedParams ) {
var hashmarkIndex = url . indexOf ( '#' ) ;
if ( hashmarkIndex !== - 1 ) {
url = url . slice ( 0 , hashmarkIndex ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
url += ( url . indexOf ( '?' ) === - 1 ? '?' : '&' ) + serializedParams ;
}
return url ;
2021-05-10 22:47:35 +07:00
} ;
2021-05-11 00:37:27 +07:00
function InterceptorManager ( ) {
this . handlers = [ ] ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Add a new interceptor to the stack
*
* @ param { Function } fulfilled The function to handle ` then ` for a ` Promise `
* @ param { Function } rejected The function to handle ` reject ` for a ` Promise `
*
* @ return { Number } An ID used to remove interceptor later
* /
InterceptorManager . prototype . use = function use ( fulfilled , rejected ) {
this . handlers . push ( {
fulfilled : fulfilled ,
rejected : rejected
} ) ;
return this . handlers . length - 1 ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Remove an interceptor from the stack
*
* @ param { Number } id The ID that was returned by ` use `
* /
InterceptorManager . prototype . eject = function eject ( id ) {
if ( this . handlers [ id ] ) {
this . handlers [ id ] = null ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become ` null ` calling ` eject ` .
*
* @ param { Function } fn The function to call for each interceptor
* /
InterceptorManager . prototype . forEach = function forEach ( fn ) {
utils . forEach ( this . handlers , function forEachHandler ( h ) {
if ( h !== null ) {
fn ( h ) ;
}
} ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var InterceptorManager _1 = InterceptorManager ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Transform the data for a request or a response
*
* @ param { Object | String } data The data to be transformed
* @ param { Array } headers The headers for the request or response
* @ param { Array | Function } fns A single function or Array of functions
* @ returns { * } The resulting transformed data
* /
var transformData = function transformData ( data , headers , fns ) {
/*eslint no-param-reassign:0*/
utils . forEach ( fns , function transform ( fn ) {
data = fn ( data , headers ) ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
return data ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var isCancel = function isCancel ( value ) {
return ! ! ( value && value . _ _CANCEL _ _ ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var normalizeHeaderName = function normalizeHeaderName ( headers , normalizedName ) {
utils . forEach ( headers , function processHeader ( value , name ) {
if ( name !== normalizedName && name . toUpperCase ( ) === normalizedName . toUpperCase ( ) ) {
headers [ normalizedName ] = value ;
delete headers [ name ] ;
}
} ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Update an Error with the specified config , error code , and response .
*
* @ param { Error } error The error to update .
* @ param { Object } config The config .
* @ param { string } [ code ] The error code ( for example , 'ECONNABORTED' ) .
* @ param { Object } [ request ] The request .
* @ param { Object } [ response ] The response .
* @ returns { Error } The error .
* /
var enhanceError = function enhanceError ( error , config , code , request , response ) {
error . config = config ;
if ( code ) {
error . code = code ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
error . request = request ;
error . response = response ;
error . isAxiosError = true ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
error . toJSON = function toJSON ( ) {
return {
// Standard
message : this . message ,
name : this . name ,
// Microsoft
description : this . description ,
number : this . number ,
// Mozilla
fileName : this . fileName ,
lineNumber : this . lineNumber ,
columnNumber : this . columnNumber ,
stack : this . stack ,
// Axios
config : this . config ,
code : this . code
} ;
} ;
return error ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Create an Error with the specified message , config , error code , request and response .
*
* @ param { string } message The error message .
* @ param { Object } config The config .
* @ param { string } [ code ] The error code ( for example , 'ECONNABORTED' ) .
* @ param { Object } [ request ] The request .
* @ param { Object } [ response ] The response .
* @ returns { Error } The created error .
* /
var createError = function createError ( message , config , code , request , response ) {
var error = new Error ( message ) ;
return enhanceError ( error , config , code , request , response ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Resolve or reject a Promise based on response status .
*
* @ param { Function } resolve A function that resolves the promise .
* @ param { Function } reject A function that rejects the promise .
* @ param { object } response The response .
* /
var settle = function settle ( resolve , reject , response ) {
var validateStatus = response . config . validateStatus ;
if ( ! response . status || ! validateStatus || validateStatus ( response . status ) ) {
resolve ( response ) ;
} else {
reject ( createError (
'Request failed with status code ' + response . status ,
response . config ,
null ,
response . request ,
response
) ) ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var cookies = (
utils . isStandardBrowserEnv ( ) ?
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Standard browser envs support document.cookie
( function standardBrowserEnv ( ) {
return {
write : function write ( name , value , expires , path , domain , secure ) {
var cookie = [ ] ;
cookie . push ( name + '=' + encodeURIComponent ( value ) ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( utils . isNumber ( expires ) ) {
cookie . push ( 'expires=' + new Date ( expires ) . toGMTString ( ) ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( utils . isString ( path ) ) {
cookie . push ( 'path=' + path ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( utils . isString ( domain ) ) {
cookie . push ( 'domain=' + domain ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( secure === true ) {
cookie . push ( 'secure' ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
document . cookie = cookie . join ( '; ' ) ;
} ,
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
read : function read ( name ) {
var match = document . cookie . match ( new RegExp ( '(^|;\\s*)(' + name + ')=([^;]*)' ) ) ;
return ( match ? decodeURIComponent ( match [ 3 ] ) : null ) ;
} ,
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
remove : function remove ( name ) {
this . write ( name , '' , Date . now ( ) - 86400000 ) ;
}
} ;
} ) ( ) :
// Non standard browser env (web workers, react-native) lack needed support.
( function nonStandardBrowserEnv ( ) {
return {
write : function write ( ) { } ,
read : function read ( ) { return null ; } ,
remove : function remove ( ) { }
} ;
} ) ( )
) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determines whether the specified URL is absolute
*
* @ param { string } url The URL to test
* @ returns { boolean } True if the specified URL is absolute , otherwise false
* /
var isAbsoluteURL = function isAbsoluteURL ( url ) {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i . test ( url ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Creates a new URL by combining the specified URLs
*
* @ param { string } baseURL The base URL
* @ param { string } relativeURL The relative URL
* @ returns { string } The combined URL
* /
var combineURLs = function combineURLs ( baseURL , relativeURL ) {
return relativeURL
? baseURL . replace ( /\/+$/ , '' ) + '/' + relativeURL . replace ( /^\/+/ , '' )
: baseURL ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Creates a new URL by combining the baseURL with the requestedURL ,
* only when the requestedURL is not already an absolute URL .
* If the requestURL is absolute , this function returns the requestedURL untouched .
*
* @ param { string } baseURL The base URL
* @ param { string } requestedURL Absolute or relative URL to combine
* @ returns { string } The combined full path
* /
var buildFullPath = function buildFullPath ( baseURL , requestedURL ) {
if ( baseURL && ! isAbsoluteURL ( requestedURL ) ) {
return combineURLs ( baseURL , requestedURL ) ;
}
return requestedURL ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Headers whose duplicates are ignored by node
// c.f. https://nodejs.org/api/http.html#http_message_headers
var ignoreDuplicateOf = [
'age' , 'authorization' , 'content-length' , 'content-type' , 'etag' ,
'expires' , 'from' , 'host' , 'if-modified-since' , 'if-unmodified-since' ,
'last-modified' , 'location' , 'max-forwards' , 'proxy-authorization' ,
'referer' , 'retry-after' , 'user-agent'
] ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Parse headers into an object
*
* ` ` `
* Date : Wed , 27 Aug 2014 08 : 58 : 49 GMT
* Content - Type : application / json
* Connection : keep - alive
* Transfer - Encoding : chunked
* ` ` `
*
* @ param { String } headers Headers needing to be parsed
* @ returns { Object } Headers parsed into an object
* /
var parseHeaders = function parseHeaders ( headers ) {
var parsed = { } ;
var key ;
var val ;
var i ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( ! headers ) { return parsed ; }
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( headers . split ( '\n' ) , function parser ( line ) {
i = line . indexOf ( ':' ) ;
key = utils . trim ( line . substr ( 0 , i ) ) . toLowerCase ( ) ;
val = utils . trim ( line . substr ( i + 1 ) ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( key ) {
if ( parsed [ key ] && ignoreDuplicateOf . indexOf ( key ) >= 0 ) {
return ;
}
if ( key === 'set-cookie' ) {
parsed [ key ] = ( parsed [ key ] ? parsed [ key ] : [ ] ) . concat ( [ val ] ) ;
} else {
parsed [ key ] = parsed [ key ] ? parsed [ key ] + ', ' + val : val ;
}
}
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
return parsed ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var isURLSameOrigin = (
utils . isStandardBrowserEnv ( ) ?
// Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location.
( function standardBrowserEnv ( ) {
var msie = /(msie|trident)/i . test ( navigator . userAgent ) ;
var urlParsingNode = document . createElement ( 'a' ) ;
var originURL ;
/ * *
* Parse a URL to discover it ' s components
*
* @ param { String } url The URL to be parsed
* @ returns { Object }
* /
function resolveURL ( url ) {
var href = url ;
if ( msie ) {
// IE needs attribute set twice to normalize properties
urlParsingNode . setAttribute ( 'href' , href ) ;
href = urlParsingNode . href ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
urlParsingNode . setAttribute ( 'href' , href ) ;
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href : urlParsingNode . href ,
protocol : urlParsingNode . protocol ? urlParsingNode . protocol . replace ( /:$/ , '' ) : '' ,
host : urlParsingNode . host ,
search : urlParsingNode . search ? urlParsingNode . search . replace ( /^\?/ , '' ) : '' ,
hash : urlParsingNode . hash ? urlParsingNode . hash . replace ( /^#/ , '' ) : '' ,
hostname : urlParsingNode . hostname ,
port : urlParsingNode . port ,
pathname : ( urlParsingNode . pathname . charAt ( 0 ) === '/' ) ?
urlParsingNode . pathname :
'/' + urlParsingNode . pathname
} ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
originURL = resolveURL ( window . location . href ) ;
/ * *
* Determine if a URL shares the same origin as the current location
*
* @ param { String } requestURL The URL to test
* @ returns { boolean } True if URL shares the same origin , otherwise false
* /
return function isURLSameOrigin ( requestURL ) {
var parsed = ( utils . isString ( requestURL ) ) ? resolveURL ( requestURL ) : requestURL ;
return ( parsed . protocol === originURL . protocol &&
parsed . host === originURL . host ) ;
} ;
} ) ( ) :
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Non standard browser envs (web workers, react-native) lack needed support.
( function nonStandardBrowserEnv ( ) {
return function isURLSameOrigin ( ) {
return true ;
} ;
} ) ( )
) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var xhr = function xhrAdapter ( config ) {
return new Promise ( function dispatchXhrRequest ( resolve , reject ) {
var requestData = config . data ;
var requestHeaders = config . headers ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( utils . isFormData ( requestData ) ) {
delete requestHeaders [ 'Content-Type' ] ; // Let the browser set it
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var request = new XMLHttpRequest ( ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// HTTP basic authentication
if ( config . auth ) {
var username = config . auth . username || '' ;
var password = config . auth . password ? unescape ( encodeURIComponent ( config . auth . password ) ) : '' ;
requestHeaders . Authorization = 'Basic ' + btoa ( username + ':' + password ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var fullPath = buildFullPath ( config . baseURL , config . url ) ;
request . open ( config . method . toUpperCase ( ) , buildURL ( fullPath , config . params , config . paramsSerializer ) , true ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Set the request timeout in MS
request . timeout = config . timeout ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Listen for ready state
request . onreadystatechange = function handleLoad ( ) {
if ( ! request || request . readyState !== 4 ) {
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// The request errored out and we didn't get a response, this will be
// handled by onerror instead
// With one exception: request that using file: protocol, most browsers
// will return status as 0 even though it's a successful request
if ( request . status === 0 && ! ( request . responseURL && request . responseURL . indexOf ( 'file:' ) === 0 ) ) {
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Prepare the response
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders ( request . getAllResponseHeaders ( ) ) : null ;
var responseData = ! config . responseType || config . responseType === 'text' ? request . responseText : request . response ;
var response = {
data : responseData ,
status : request . status ,
statusText : request . statusText ,
headers : responseHeaders ,
config : config ,
request : request
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
settle ( resolve , reject , response ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Clean up request
request = null ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Handle browser request cancellation (as opposed to a manual cancellation)
request . onabort = function handleAbort ( ) {
if ( ! request ) {
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
reject ( createError ( 'Request aborted' , config , 'ECONNABORTED' , request ) ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Clean up request
request = null ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Handle low level network errors
request . onerror = function handleError ( ) {
// Real errors are hidden from us by the browser
// onerror should only fire if it's a network error
reject ( createError ( 'Network Error' , config , null , request ) ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Clean up request
request = null ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Handle timeout
request . ontimeout = function handleTimeout ( ) {
var timeoutErrorMessage = 'timeout of ' + config . timeout + 'ms exceeded' ;
if ( config . timeoutErrorMessage ) {
timeoutErrorMessage = config . timeoutErrorMessage ;
}
reject ( createError ( timeoutErrorMessage , config , 'ECONNABORTED' ,
request ) ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Clean up request
request = null ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Add xsrf header
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if ( utils . isStandardBrowserEnv ( ) ) {
// Add xsrf header
var xsrfValue = ( config . withCredentials || isURLSameOrigin ( fullPath ) ) && config . xsrfCookieName ?
cookies . read ( config . xsrfCookieName ) :
undefined ;
if ( xsrfValue ) {
requestHeaders [ config . xsrfHeaderName ] = xsrfValue ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Add headers to the request
if ( 'setRequestHeader' in request ) {
utils . forEach ( requestHeaders , function setRequestHeader ( val , key ) {
if ( typeof requestData === 'undefined' && key . toLowerCase ( ) === 'content-type' ) {
// Remove Content-Type if data is undefined
delete requestHeaders [ key ] ;
} else {
// Otherwise add header to the request
request . setRequestHeader ( key , val ) ;
}
} ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Add withCredentials to request if needed
if ( ! utils . isUndefined ( config . withCredentials ) ) {
request . withCredentials = ! ! config . withCredentials ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Add responseType to request if needed
if ( config . responseType ) {
try {
request . responseType = config . responseType ;
} catch ( e ) {
// Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
// But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
if ( config . responseType !== 'json' ) {
throw e ;
}
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Handle progress if needed
if ( typeof config . onDownloadProgress === 'function' ) {
request . addEventListener ( 'progress' , config . onDownloadProgress ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Not all browsers support upload events
if ( typeof config . onUploadProgress === 'function' && request . upload ) {
request . upload . addEventListener ( 'progress' , config . onUploadProgress ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( config . cancelToken ) {
// Handle cancellation
config . cancelToken . promise . then ( function onCanceled ( cancel ) {
if ( ! request ) {
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
request . abort ( ) ;
reject ( cancel ) ;
// Clean up request
request = null ;
} ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( ! requestData ) {
requestData = null ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Send the request
request . send ( requestData ) ;
} ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var DEFAULT _CONTENT _TYPE = {
'Content-Type' : 'application/x-www-form-urlencoded'
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function setContentTypeIfUnset ( headers , value ) {
if ( ! utils . isUndefined ( headers ) && utils . isUndefined ( headers [ 'Content-Type' ] ) ) {
headers [ 'Content-Type' ] = value ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function getDefaultAdapter ( ) {
var adapter ;
if ( typeof XMLHttpRequest !== 'undefined' ) {
// For browsers use XHR adapter
adapter = xhr ;
} else if ( typeof process !== 'undefined' && Object . prototype . toString . call ( process ) === '[object process]' ) {
// For node use HTTP adapter
adapter = xhr ;
}
return adapter ;
}
var defaults = {
adapter : getDefaultAdapter ( ) ,
transformRequest : [ function transformRequest ( data , headers ) {
normalizeHeaderName ( headers , 'Accept' ) ;
normalizeHeaderName ( headers , 'Content-Type' ) ;
if ( utils . isFormData ( data ) ||
utils . isArrayBuffer ( data ) ||
utils . isBuffer ( data ) ||
utils . isStream ( data ) ||
utils . isFile ( data ) ||
utils . isBlob ( data )
) {
return data ;
}
if ( utils . isArrayBufferView ( data ) ) {
return data . buffer ;
}
if ( utils . isURLSearchParams ( data ) ) {
setContentTypeIfUnset ( headers , 'application/x-www-form-urlencoded;charset=utf-8' ) ;
return data . toString ( ) ;
}
if ( utils . isObject ( data ) ) {
setContentTypeIfUnset ( headers , 'application/json;charset=utf-8' ) ;
return JSON . stringify ( data ) ;
}
return data ;
} ] ,
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
transformResponse : [ function transformResponse ( data ) {
/*eslint no-param-reassign:0*/
if ( typeof data === 'string' ) {
try {
data = JSON . parse ( data ) ;
} catch ( e ) { /* Ignore */ }
}
return data ;
} ] ,
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* A timeout in milliseconds to abort a request . If set to 0 ( default ) a
* timeout is not created .
* /
timeout : 0 ,
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
xsrfCookieName : 'XSRF-TOKEN' ,
xsrfHeaderName : 'X-XSRF-TOKEN' ,
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
maxContentLength : - 1 ,
maxBodyLength : - 1 ,
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
validateStatus : function validateStatus ( status ) {
return status >= 200 && status < 300 ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
defaults . headers = {
common : {
'Accept' : 'application/json, text/plain, */*'
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( [ 'delete' , 'get' , 'head' ] , function forEachMethodNoData ( method ) {
defaults . headers [ method ] = { } ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( [ 'post' , 'put' , 'patch' ] , function forEachMethodWithData ( method ) {
defaults . headers [ method ] = utils . merge ( DEFAULT _CONTENT _TYPE ) ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var defaults _1 = defaults ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Throws a ` Cancel ` if cancellation has been requested .
* /
function throwIfCancellationRequested ( config ) {
if ( config . cancelToken ) {
config . cancelToken . throwIfRequested ( ) ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Dispatch a request to the server using the configured adapter .
*
* @ param { object } config The config that is to be used for the request
* @ returns { Promise } The Promise to be fulfilled
* /
var dispatchRequest = function dispatchRequest ( config ) {
throwIfCancellationRequested ( config ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Ensure headers exist
config . headers = config . headers || { } ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Transform request data
config . data = transformData (
config . data ,
config . headers ,
config . transformRequest
) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Flatten headers
config . headers = utils . merge (
config . headers . common || { } ,
config . headers [ config . method ] || { } ,
config . headers
) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach (
[ 'delete' , 'get' , 'head' , 'post' , 'put' , 'patch' , 'common' ] ,
function cleanHeaderConfig ( method ) {
delete config . headers [ method ] ;
}
) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var adapter = config . adapter || defaults _1 . adapter ;
return adapter ( config ) . then ( function onAdapterResolution ( response ) {
throwIfCancellationRequested ( config ) ;
// Transform response data
response . data = transformData (
response . data ,
response . headers ,
config . transformResponse
) ;
return response ;
} , function onAdapterRejection ( reason ) {
if ( ! isCancel ( reason ) ) {
throwIfCancellationRequested ( config ) ;
// Transform response data
if ( reason && reason . response ) {
reason . response . data = transformData (
reason . response . data ,
reason . response . headers ,
config . transformResponse
) ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
return Promise . reject ( reason ) ;
} ) ;
2021-05-10 22:47:35 +07:00
} ;
2021-05-11 00:37:27 +07:00
/ * *
* Config - specific merge - function which creates a new config - object
* by merging two configuration objects together .
*
* @ param { Object } config1
* @ param { Object } config2
* @ returns { Object } New object resulting from merging config2 to config1
* /
var mergeConfig = function mergeConfig ( config1 , config2 ) {
// eslint-disable-next-line no-param-reassign
config2 = config2 || { } ;
var config = { } ;
var valueFromConfig2Keys = [ 'url' , 'method' , 'data' ] ;
var mergeDeepPropertiesKeys = [ 'headers' , 'auth' , 'proxy' , 'params' ] ;
var defaultToConfig2Keys = [
'baseURL' , 'transformRequest' , 'transformResponse' , 'paramsSerializer' ,
'timeout' , 'timeoutMessage' , 'withCredentials' , 'adapter' , 'responseType' , 'xsrfCookieName' ,
'xsrfHeaderName' , 'onUploadProgress' , 'onDownloadProgress' , 'decompress' ,
'maxContentLength' , 'maxBodyLength' , 'maxRedirects' , 'transport' , 'httpAgent' ,
'httpsAgent' , 'cancelToken' , 'socketPath' , 'responseEncoding'
] ;
var directMergeKeys = [ 'validateStatus' ] ;
function getMergedValue ( target , source ) {
if ( utils . isPlainObject ( target ) && utils . isPlainObject ( source ) ) {
return utils . merge ( target , source ) ;
} else if ( utils . isPlainObject ( source ) ) {
return utils . merge ( { } , source ) ;
} else if ( utils . isArray ( source ) ) {
return source . slice ( ) ;
}
return source ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function mergeDeepProperties ( prop ) {
if ( ! utils . isUndefined ( config2 [ prop ] ) ) {
config [ prop ] = getMergedValue ( config1 [ prop ] , config2 [ prop ] ) ;
} else if ( ! utils . isUndefined ( config1 [ prop ] ) ) {
config [ prop ] = getMergedValue ( undefined , config1 [ prop ] ) ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( valueFromConfig2Keys , function valueFromConfig2 ( prop ) {
if ( ! utils . isUndefined ( config2 [ prop ] ) ) {
config [ prop ] = getMergedValue ( undefined , config2 [ prop ] ) ;
}
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( mergeDeepPropertiesKeys , mergeDeepProperties ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( defaultToConfig2Keys , function defaultToConfig2 ( prop ) {
if ( ! utils . isUndefined ( config2 [ prop ] ) ) {
config [ prop ] = getMergedValue ( undefined , config2 [ prop ] ) ;
} else if ( ! utils . isUndefined ( config1 [ prop ] ) ) {
config [ prop ] = getMergedValue ( undefined , config1 [ prop ] ) ;
}
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( directMergeKeys , function merge ( prop ) {
if ( prop in config2 ) {
config [ prop ] = getMergedValue ( config1 [ prop ] , config2 [ prop ] ) ;
} else if ( prop in config1 ) {
config [ prop ] = getMergedValue ( undefined , config1 [ prop ] ) ;
}
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var axiosKeys = valueFromConfig2Keys
. concat ( mergeDeepPropertiesKeys )
. concat ( defaultToConfig2Keys )
. concat ( directMergeKeys ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var otherKeys = Object
. keys ( config1 )
. concat ( Object . keys ( config2 ) )
. filter ( function filterAxiosKeys ( key ) {
return axiosKeys . indexOf ( key ) === - 1 ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( otherKeys , mergeDeepProperties ) ;
return config ;
2021-05-10 22:47:35 +07:00
} ;
2021-05-11 00:37:27 +07:00
/ * *
* Create a new instance of Axios
*
* @ param { Object } instanceConfig The default config for the instance
* /
function Axios ( instanceConfig ) {
this . defaults = instanceConfig ;
this . interceptors = {
request : new InterceptorManager _1 ( ) ,
response : new InterceptorManager _1 ( )
} ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Dispatch a request
*
* @ param { Object } config The config specific for this request ( merged with this . defaults )
* /
Axios . prototype . request = function request ( config ) {
/*eslint no-param-reassign:0*/
// Allow for axios('example/url'[, config]) a la fetch API
if ( typeof config === 'string' ) {
config = arguments [ 1 ] || { } ;
config . url = arguments [ 0 ] ;
} else {
config = config || { } ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
config = mergeConfig ( this . defaults , config ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Set config.method
if ( config . method ) {
config . method = config . method . toLowerCase ( ) ;
} else if ( this . defaults . method ) {
config . method = this . defaults . method . toLowerCase ( ) ;
} else {
config . method = 'get' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Hook up interceptors middleware
var chain = [ dispatchRequest , undefined ] ;
var promise = Promise . resolve ( config ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
this . interceptors . request . forEach ( function unshiftRequestInterceptors ( interceptor ) {
chain . unshift ( interceptor . fulfilled , interceptor . rejected ) ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
this . interceptors . response . forEach ( function pushResponseInterceptors ( interceptor ) {
chain . push ( interceptor . fulfilled , interceptor . rejected ) ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
while ( chain . length ) {
promise = promise . then ( chain . shift ( ) , chain . shift ( ) ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
return promise ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
Axios . prototype . getUri = function getUri ( config ) {
config = mergeConfig ( this . defaults , config ) ;
return buildURL ( config . url , config . params , config . paramsSerializer ) . replace ( /^\?/ , '' ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Provide aliases for supported request methods
utils . forEach ( [ 'delete' , 'get' , 'head' , 'options' ] , function forEachMethodNoData ( method ) {
/*eslint func-names:0*/
Axios . prototype [ method ] = function ( url , config ) {
return this . request ( mergeConfig ( config || { } , {
method : method ,
url : url ,
data : ( config || { } ) . data
} ) ) ;
} ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
utils . forEach ( [ 'post' , 'put' , 'patch' ] , function forEachMethodWithData ( method ) {
/*eslint func-names:0*/
Axios . prototype [ method ] = function ( url , data , config ) {
return this . request ( mergeConfig ( config || { } , {
method : method ,
url : url ,
data : data
} ) ) ;
} ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var Axios _1 = Axios ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* A ` Cancel ` is an object that is thrown when an operation is canceled .
*
* @ class
* @ param { string = } message The message .
* /
function Cancel ( message ) {
this . message = message ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
Cancel . prototype . toString = function toString ( ) {
return 'Cancel' + ( this . message ? ': ' + this . message : '' ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
Cancel . prototype . _ _CANCEL _ _ = true ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var Cancel _1 = Cancel ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* A ` CancelToken ` is an object that can be used to request cancellation of an operation .
*
* @ class
* @ param { Function } executor The executor function .
* /
function CancelToken ( executor ) {
if ( typeof executor !== 'function' ) {
throw new TypeError ( 'executor must be a function.' ) ;
}
var resolvePromise ;
this . promise = new Promise ( function promiseExecutor ( resolve ) {
resolvePromise = resolve ;
} ) ;
var token = this ;
executor ( function cancel ( message ) {
if ( token . reason ) {
// Cancellation has already been requested
return ;
}
token . reason = new Cancel _1 ( message ) ;
resolvePromise ( token . reason ) ;
} ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
/ * *
* Throws a ` Cancel ` if cancellation has been requested .
* /
CancelToken . prototype . throwIfRequested = function throwIfRequested ( ) {
if ( this . reason ) {
throw this . reason ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Returns an object that contains a new ` CancelToken ` and a function that , when called ,
* cancels the ` CancelToken ` .
* /
CancelToken . source = function source ( ) {
var cancel ;
var token = new CancelToken ( function executor ( c ) {
cancel = c ;
} ) ;
return {
token : token ,
cancel : cancel
} ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var CancelToken _1 = CancelToken ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Syntactic sugar for invoking a function and expanding an array for arguments .
*
* Common use case would be to use ` Function.prototype.apply ` .
*
* ` ` ` js
* function f ( x , y , z ) { }
* var args = [ 1 , 2 , 3 ] ;
* f . apply ( null , args ) ;
* ` ` `
*
* With ` spread ` this example can be re - written .
*
* ` ` ` js
* spread ( function ( x , y , z ) { } ) ( [ 1 , 2 , 3 ] ) ;
* ` ` `
*
* @ param { Function } callback
* @ returns { Function }
* /
var spread = function spread ( callback ) {
return function wrap ( arr ) {
return callback . apply ( null , arr ) ;
} ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Determines whether the payload is an error thrown by Axios
*
* @ param { * } payload The value to test
* @ returns { boolean } True if the payload is an error thrown by Axios , otherwise false
* /
var isAxiosError = function isAxiosError ( payload ) {
return ( typeof payload === 'object' ) && ( payload . isAxiosError === true ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
/ * *
* Create an instance of Axios
*
* @ param { Object } defaultConfig The default config for the instance
* @ return { Axios } A new instance of Axios
* /
function createInstance ( defaultConfig ) {
var context = new Axios _1 ( defaultConfig ) ;
var instance = bind ( Axios _1 . prototype . request , context ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Copy axios.prototype to instance
utils . extend ( instance , Axios _1 . prototype , context ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Copy context to instance
utils . extend ( instance , context ) ;
return instance ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
// Create the default instance to be exported
var axios$1 = createInstance ( defaults _1 ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Expose Axios class to allow class inheritance
axios$1 . Axios = Axios _1 ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Factory for creating new instances
axios$1 . create = function create ( instanceConfig ) {
return createInstance ( mergeConfig ( axios$1 . defaults , instanceConfig ) ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Expose Cancel & CancelToken
axios$1 . Cancel = Cancel _1 ;
axios$1 . CancelToken = CancelToken _1 ;
axios$1 . isCancel = isCancel ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Expose all/spread
axios$1 . all = function all ( promises ) {
return Promise . all ( promises ) ;
} ;
axios$1 . spread = spread ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Expose isAxiosError
axios$1 . isAxiosError = isAxiosError ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var axios _1 = axios$1 ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Allow use of default import syntax in TypeScript
var _default = axios$1 ;
axios _1 . default = _default ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var axios = axios _1 ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
let url = window . BASE _URL ;
let current _token ;
token$1 . subscribe ( value => {
current _token = value ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
async function login ( { username , password } ) {
const endpoint = url + "/api/auth/login" ;
const response = await axios ( {
url : endpoint ,
method : "POST" ,
data : JSON . stringify ( {
username ,
password ,
} ) ,
} ) ;
token$1 . set ( response . data . token ) ;
return response . data ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
async function getPostSearchTag ( { page , q } ) {
if ( q ) {
const endpoint = url + "/api/post?tags=" + q + "&page=" + page ;
const response = await axios ( endpoint ) ;
return response . data ;
} else {
const endpoint = url + "/api/post?page=" + page ;
const response = await axios ( endpoint ) ;
return response . data ;
}
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
async function getPost ( { id } ) {
const endpoint = url + "/api/post/" + id ;
const response = await axios ( endpoint ) ;
return response . data ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
async function uploadBlob ( { file , onProgress } ) {
var formData = new FormData ( ) ;
formData . append ( "file" , file ) ;
const endpoint = url + "/api/blob/upload" ;
const response = await axios ( {
url : endpoint ,
method : "POST" ,
headers : {
'Authorization' : 'Bearer ' + current _token ,
'Content-Type' : 'multipart/form-data' ,
} ,
withCredentials : true ,
data : formData ,
onUploadProgress : e => {
if ( onProgress ) {
onProgress ( e ) ;
}
}
} ) ;
return response . data ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
async function postCreate ( { blob _id , source _url , tags } ) {
const endpoint = url + "/api/post/create" ;
const response = await axios ( {
url : endpoint ,
method : "POST" ,
headers : {
'Authorization' : 'Bearer ' + current _token ,
} ,
withCredentials : true ,
data : {
blob _id , source _url , tags
}
} ) ;
return response . data ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
async function postUpdate ( id , { source _url , tags } ) {
const endpoint = url + "/api/post/" + id ;
const response = await axios ( {
url : endpoint ,
method : "POST" ,
headers : {
'Authorization' : 'Bearer ' + current _token ,
} ,
withCredentials : true ,
data : {
source _url , tags
}
} ) ;
return response . data ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
/* src/TagLink.svelte generated by Svelte v3.38.2 */
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
// (10:0) <Link class="button is-rounded is-primary is-small m-1" to="/posts?tags={tagName}">
function create _default _slot$4 ( ctx ) {
let t ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const block = {
c : function create ( ) {
t = text ( /*tagName*/ ctx [ 0 ] ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , t , anchor ) ;
} ,
p : noop ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( t ) ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _default _slot$4 . name ,
type : "slot" ,
source : "(10:0) <Link class=\\\"button is-rounded is-primary is-small m-1\\\" to=\\\"/posts?tags={tagName}\\\">" ,
ctx
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return block ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function create _fragment$9 ( ctx ) {
let link ;
let current ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
link = new Link ( {
props : {
class : "button is-rounded is-primary is-small m-1" ,
to : "/posts?tags=" + /*tagName*/ ctx [ 0 ] ,
$$slots : { default : [ create _default _slot$4 ] } ,
$$scope : { ctx }
} ,
$$inline : true
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const block = {
c : function create ( ) {
create _component ( link . $$ . 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 ( link , target , anchor ) ;
current = true ;
} ,
p : function update ( ctx , [ dirty ] ) {
const link _changes = { } ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope*/ 8 ) {
link _changes . $$scope = { dirty , ctx } ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _fragment$9 . name ,
type : "component" ,
source : "" ,
ctx
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return block ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function instance$9 ( $$self , $$props , $$invalidate ) {
let { $$slots : slots = { } , $$scope } = $$props ;
validate _slots ( "TagLink" , slots , [ ] ) ;
let { tag } = $$props ;
let tagType = tag . split ( ":" ) [ 0 ] ? ? "" ;
let tagName = tag . split ( ":" ) [ 1 ] ? ? "" ;
const writable _props = [ "tag" ] ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
Object . keys ( $$props ) . forEach ( key => {
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== "$$" ) console . warn ( ` <TagLink> was created with unknown prop ' ${ key } ' ` ) ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
$$self . $$set = $$props => {
if ( "tag" in $$props ) $$invalidate ( 1 , tag = $$props . tag ) ;
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
$$self . $capture _state = ( ) => ( { Link , tag , tagType , tagName } ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
$$self . $inject _state = $$props => {
if ( "tag" in $$props ) $$invalidate ( 1 , tag = $$props . tag ) ;
if ( "tagType" in $$props ) tagType = $$props . tagType ;
if ( "tagName" in $$props ) $$invalidate ( 0 , tagName = $$props . tagName ) ;
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( $$props && "$$inject" in $$props ) {
$$self . $inject _state ( $$props . $$inject ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
return [ tagName , tag ] ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
class TagLink extends SvelteComponentDev {
constructor ( options ) {
super ( options ) ;
init ( this , options , instance$9 , create _fragment$9 , safe _not _equal , { tag : 1 } ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "TagLink" ,
options ,
id : create _fragment$9 . name
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const { ctx } = this . $$ ;
const props = options . props || { } ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( /*tag*/ ctx [ 1 ] === undefined && ! ( "tag" in props ) ) {
console . warn ( "<TagLink> was created without expected prop 'tag'" ) ;
}
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
get tag ( ) {
throw new Error ( "<TagLink>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
set tag ( value ) {
throw new Error ( "<TagLink>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
/* src/PostPaginator.svelte generated by Svelte v3.38.2 */
const file$7 = "src/PostPaginator.svelte" ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function get _each _context$2 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 7 ] = list [ i ] ;
return child _ctx ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function get _each _context _1$1 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 10 ] = list [ i ] ;
child _ctx [ 12 ] = i ;
return child _ctx ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function get _each _context _2 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 13 ] = list [ i ] ;
return child _ctx ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function get _each _context _3 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 12 ] = list [ i ] ;
return child _ctx ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
// (26:4) {#if page > 1}
function create _if _block _6 ( ctx ) {
let link ;
let current ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link = new Link ( {
props : {
to : "" + ( /*url*/ ctx [ 3 ] + "page=" + ( /*page*/ ctx [ 0 ] - 1 ) ) ,
class : "pagination-previous" ,
"aria-label" : "Previous" ,
$$slots : { default : [ create _default _slot _6 ] } ,
$$scope : { ctx }
} ,
$$inline : true
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link . $on ( "click" , function ( ) {
if ( is _function ( /*handlePage*/ ctx [ 2 ] ( /*page*/ ctx [ 0 ] - 1 ) ) ) /*handlePage*/ ctx [ 2 ] ( /*page*/ ctx [ 0 ] - 1 ) . apply ( this , arguments ) ;
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const block = {
c : function create ( ) {
create _component ( link . $$ . fragment ) ;
} ,
m : function mount ( target , anchor ) {
mount _component ( link , target , anchor ) ;
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const link _changes = { } ;
if ( dirty & /*url, page*/ 9 ) link _changes . to = "" + ( /*url*/ ctx [ 3 ] + "page=" + ( /*page*/ ctx [ 0 ] - 1 ) ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope*/ 262144 ) {
link _changes . $$scope = { dirty , ctx } ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
}
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block _6 . name ,
type : "if" ,
source : "(26:4) {#if page > 1}" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
// (27:8) <Link on:click={handlePage(page - 1)} to="{url}page={page - 1}" class="pagination-previous" aria-label="Previous">
function create _default _slot _6 ( ctx ) {
let t ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
}
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _default _slot _6 . name ,
type : "slot" ,
source : "(27:8) <Link on:click={handlePage(page - 1)} to=\\\"{url}page={page - 1}\\\" class=\\\"pagination-previous\\\" aria-label=\\\"Previous\\\">" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
// (34:4) {#if page < totalPages}
function create _if _block _5 ( ctx ) {
let link ;
let current ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link = new Link ( {
props : {
to : "" + ( /*url*/ ctx [ 3 ] + "page=" + ( /*page*/ ctx [ 0 ] + 1 ) ) ,
class : "pagination-next" ,
"aria-label" : "Next" ,
$$slots : { default : [ create _default _slot _5 ] } ,
$$scope : { ctx }
} ,
$$inline : true
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link . $on ( "click" , function ( ) {
if ( is _function ( /*handlePage*/ ctx [ 2 ] ( /*page*/ ctx [ 0 ] + 1 ) ) ) /*handlePage*/ ctx [ 2 ] ( /*page*/ ctx [ 0 ] + 1 ) . apply ( this , arguments ) ;
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const block = {
c : function create ( ) {
create _component ( link . $$ . fragment ) ;
} ,
m : function mount ( target , anchor ) {
mount _component ( link , target , anchor ) ;
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const link _changes = { } ;
if ( dirty & /*url, page*/ 9 ) link _changes . to = "" + ( /*url*/ ctx [ 3 ] + "page=" + ( /*page*/ ctx [ 0 ] + 1 ) ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope*/ 262144 ) {
link _changes . $$scope = { dirty , ctx } ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block _5 . name ,
type : "if" ,
source : "(34:4) {#if page < totalPages}" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
// (35:8) <Link on:click={handlePage(page + 1)} to="{url}page={page + 1}" class="pagination-next" aria-label="Next">
function create _default _slot _5 ( ctx ) {
let t ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
}
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _default _slot _5 . name ,
type : "slot" ,
source : "(35:8) <Link on:click={handlePage(page + 1)} to=\\\"{url}page={page + 1}\\\" class=\\\"pagination-next\\\" aria-label=\\\"Next\\\">" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
// (43:8) {#if page > 3}
function create _if _block _4 ( ctx ) {
let li0 ;
let link ;
let t0 ;
let li1 ;
let span ;
let current ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link = new Link ( {
props : {
to : "" + ( /*url*/ ctx [ 3 ] + "page=" + 1 ) ,
class : "pagination-link" ,
"aria-label" : "Goto page 1" ,
$$slots : { default : [ create _default _slot _4 ] } ,
$$scope : { ctx }
} ,
$$inline : true
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link . $on ( "click" , function ( ) {
if ( is _function ( /*handlePage*/ ctx [ 2 ] ( 1 ) ) ) /*handlePage*/ ctx [ 2 ] ( 1 ) . apply ( this , arguments ) ;
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const block = {
c : function create ( ) {
li0 = element ( "li" ) ;
create _component ( link . $$ . fragment ) ;
t0 = space ( ) ;
li1 = element ( "li" ) ;
span = element ( "span" ) ;
span . textContent = "…" ;
add _location ( li0 , file$7 , 43 , 12 , 1280 ) ;
attr _dev ( span , "class" , "pagination-ellipsis" ) ;
add _location ( span , file$7 , 52 , 16 , 1557 ) ;
add _location ( li1 , file$7 , 51 , 12 , 1536 ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , li0 , anchor ) ;
mount _component ( link , li0 , null ) ;
insert _dev ( target , t0 , anchor ) ;
insert _dev ( target , li1 , anchor ) ;
append _dev ( li1 , span ) ;
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const link _changes = { } ;
if ( dirty & /*url*/ 8 ) link _changes . to = "" + ( /*url*/ ctx [ 3 ] + "page=" + 1 ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope*/ 262144 ) {
link _changes . $$scope = { dirty , ctx } ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
}
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block _4 . name ,
type : "if" ,
source : "(43:8) {#if page > 3}" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
// (45:16) <Link on:click={handlePage(1)} to="{url}page={1}" class="pagination-link" aria-label="Goto page 1">
function create _default _slot _4 ( ctx ) {
let t ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
}
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _default _slot _4 . name ,
type : "slot" ,
source : "(45:16) <Link on:click={handlePage(1)} to=\\\"{url}page={1}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page 1\\\">" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
// (57:12) {#if i >= 1 && i <= totalPages}
function create _if _block _2$2 ( ctx ) {
let current _block _type _index ;
let if _block ;
let if _block _anchor ;
let current ;
const if _block _creators = [ create _if _block _3$1 , create _else _block _1 ] ;
const if _blocks = [ ] ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function select _block _type ( ctx , dirty ) {
if ( /*i*/ ctx [ 12 ] == /*page*/ ctx [ 0 ] ) return 0 ;
return 1 ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
current _block _type _index = select _block _type ( ctx ) ;
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( current _block _type _index === previous _block _index ) {
if _blocks [ current _block _type _index ] . p ( ctx , dirty ) ;
} else {
group _outros ( ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
transition _out ( if _blocks [ previous _block _index ] , 1 , 1 , ( ) => {
if _blocks [ previous _block _index ] = null ;
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
check _outros ( ) ;
if _block = if _blocks [ current _block _type _index ] ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
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 ) ;
}
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block _2$2 . name ,
type : "if" ,
source : "(57:12) {#if i >= 1 && i <= totalPages}" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
// (67:16) {:else}
function create _else _block _1 ( ctx ) {
let li ;
let link ;
let current ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link = new Link ( {
props : {
to : "" + ( /*url*/ ctx [ 3 ] + "page=" + /*i*/ ctx [ 12 ] ) ,
class : "pagination-link" ,
"aria-label" : "Goto page " + /*i*/ ctx [ 12 ] ,
$$slots : { default : [ create _default _slot _3 ] } ,
$$scope : { ctx }
} ,
$$inline : true
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
link . $on ( "click" , function ( ) {
if ( is _function ( /*handlePage*/ ctx [ 2 ] ( /*i*/ ctx [ 12 ] ) ) ) /*handlePage*/ ctx [ 2 ] ( /*i*/ ctx [ 12 ] ) . apply ( this , arguments ) ;
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const block = {
c : function create ( ) {
li = element ( "li" ) ;
create _component ( link . $$ . fragment ) ;
add _location ( li , file$7 , 67 , 20 , 2161 ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , li , anchor ) ;
mount _component ( link , li , null ) ;
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const link _changes = { } ;
if ( dirty & /*url, page*/ 9 ) link _changes . to = "" + ( /*url*/ ctx [ 3 ] + "page=" + /*i*/ ctx [ 12 ] ) ;
if ( dirty & /*page*/ 1 ) link _changes [ "aria-label" ] = "Goto page " + /*i*/ ctx [ 12 ] ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope, page*/ 262145 ) {
link _changes . $$scope = { dirty , ctx } ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
link . $set ( link _changes ) ;
2021-05-11 00:37:27 +07:00
} ,
2021-05-11 03:25:33 +07:00
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 ) ;
}
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _else _block _1 . name ,
type : "else" ,
source : "(67:16) {:else}" ,
ctx
} ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return block ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
// (58:16) {#if i == page}
function create _if _block _3$1 ( ctx ) {
let li ;
2021-05-11 00:37:27 +07:00
let link ;
let current ;
link = new Link ( {
props : {
2021-05-11 03:25:33 +07:00
to : "" + ( /*url*/ ctx [ 3 ] + "page=" + /*i*/ ctx [ 12 ] ) ,
class : "pagination-link is-current" ,
"aria-label" : "Goto page " + /*i*/ ctx [ 12 ] ,
$$slots : { default : [ create _default _slot _2 ] } ,
2021-05-11 00:37:27 +07:00
$$scope : { ctx }
} ,
$$inline : true
} ) ;
link . $on ( "click" , function ( ) {
2021-05-11 03:25:33 +07:00
if ( is _function ( /*handlePage*/ ctx [ 2 ] ( /*i*/ ctx [ 12 ] ) ) ) /*handlePage*/ ctx [ 2 ] ( /*i*/ ctx [ 12 ] ) . apply ( this , arguments ) ;
2021-05-11 00:37:27 +07:00
} ) ;
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
li = element ( "li" ) ;
2021-05-11 00:37:27 +07:00
create _component ( link . $$ . fragment ) ;
2021-05-11 03:25:33 +07:00
add _location ( li , file$7 , 58 , 20 , 1802 ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , li , anchor ) ;
mount _component ( link , li , null ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const link _changes = { } ;
2021-05-11 03:25:33 +07:00
if ( dirty & /*url, page*/ 9 ) link _changes . to = "" + ( /*url*/ ctx [ 3 ] + "page=" + /*i*/ ctx [ 12 ] ) ;
if ( dirty & /*page*/ 1 ) link _changes [ "aria-label" ] = "Goto page " + /*i*/ ctx [ 12 ] ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope, page*/ 262145 ) {
2021-05-11 00:37:27 +07:00
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 ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( li ) ;
destroy _component ( link ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _if _block _3$1 . name ,
2021-05-11 00:37:27 +07:00
type : "if" ,
2021-05-11 03:25:33 +07:00
source : "(58:16) {#if i == page}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (69:24) <Link on:click={handlePage(i)} to="{url}page={i}" class="pagination-link" aria-label="Goto page {i}">
function create _default _slot _3 ( ctx ) {
let t _value = /*i*/ ctx [ 12 ] + "" ;
2021-05-11 00:37:27 +07:00
let t ;
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
t = text ( t _value ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , t , anchor ) ;
} ,
2021-05-11 03:25:33 +07:00
p : function update ( ctx , dirty ) {
if ( dirty & /*page*/ 1 && t _value !== ( t _value = /*i*/ ctx [ 12 ] + "" ) ) set _data _dev ( t , t _value ) ;
} ,
2021-05-11 00:37:27 +07:00
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( t ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _default _slot _3 . name ,
2021-05-11 00:37:27 +07:00
type : "slot" ,
2021-05-11 03:25:33 +07:00
source : "(69:24) <Link on:click={handlePage(i)} to=\\\"{url}page={i}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page {i}\\\">" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (60:24) <Link on:click={handlePage(i)} to="{url}page={i}" class="pagination-link is-current" aria-label="Goto page {i}">
function create _default _slot _2 ( ctx ) {
let t _value = /*i*/ ctx [ 12 ] + "" ;
let t ;
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
t = text ( t _value ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , t , anchor ) ;
2021-05-11 00:37:27 +07:00
} ,
2021-05-11 03:25:33 +07:00
p : function update ( ctx , dirty ) {
if ( dirty & /*page*/ 1 && t _value !== ( t _value = /*i*/ ctx [ 12 ] + "" ) ) set _data _dev ( t , t _value ) ;
2021-05-11 00:37:27 +07:00
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( t ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _default _slot _2 . name ,
type : "slot" ,
source : "(60:24) <Link on:click={handlePage(i)} to=\\\"{url}page={i}\\\" class=\\\"pagination-link is-current\\\" aria-label=\\\"Goto page {i}\\\">" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (56:8) {#each [...Array(5).keys()].map((x) => x + page - 2) as i}
function create _each _block _3 ( ctx ) {
let if _block _anchor ;
let current ;
let if _block = /*i*/ ctx [ 12 ] >= 1 && /*i*/ ctx [ 12 ] <= /*totalPages*/ ctx [ 1 ] && create _if _block _2$2 ( ctx ) ;
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
if ( if _block ) if _block . c ( ) ;
if _block _anchor = empty ( ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
if ( if _block ) if _block . m ( target , anchor ) ;
insert _dev ( target , if _block _anchor , anchor ) ;
current = true ;
} ,
p : function update ( ctx , dirty ) {
if ( /*i*/ ctx [ 12 ] >= 1 && /*i*/ ctx [ 12 ] <= /*totalPages*/ ctx [ 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 _2$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 ;
2021-05-11 00:37:27 +07:00
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( if _block ) if _block . d ( detaching ) ;
if ( detaching ) detach _dev ( if _block _anchor ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _each _block _3 . name ,
type : "each" ,
source : "(56:8) {#each [...Array(5).keys()].map((x) => x + page - 2) as i}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (79:8) {#if totalPages - page > 2}
function create _if _block _1$3 ( ctx ) {
2021-05-11 00:37:27 +07:00
let li0 ;
let span ;
2021-05-11 03:25:33 +07:00
let t1 ;
let li1 ;
let link ;
2021-05-11 00:37:27 +07:00
let current ;
link = new Link ( {
props : {
2021-05-11 03:25:33 +07:00
to : "" + ( /*url*/ ctx [ 3 ] + "page=" + /*totalPages*/ ctx [ 1 ] ) ,
2021-05-11 00:37:27 +07:00
class : "pagination-link" ,
2021-05-11 03:25:33 +07:00
"aria-label" : "Goto page " + /*totalPages*/ ctx [ 1 ] ,
$$slots : { default : [ create _default _slot _1 ] } ,
2021-05-11 00:37:27 +07:00
$$scope : { ctx }
} ,
$$inline : true
} ) ;
link . $on ( "click" , function ( ) {
2021-05-11 03:25:33 +07:00
if ( is _function ( /*handlePage*/ ctx [ 2 ] ( /*totalPages*/ ctx [ 1 ] ) ) ) /*handlePage*/ ctx [ 2 ] ( /*totalPages*/ ctx [ 1 ] ) . apply ( this , arguments ) ;
2021-05-11 00:37:27 +07:00
} ) ;
const block = {
c : function create ( ) {
li0 = element ( "li" ) ;
span = element ( "span" ) ;
span . textContent = "…" ;
2021-05-11 03:25:33 +07:00
t1 = space ( ) ;
li1 = element ( "li" ) ;
create _component ( link . $$ . fragment ) ;
2021-05-11 00:37:27 +07:00
attr _dev ( span , "class" , "pagination-ellipsis" ) ;
2021-05-11 03:25:33 +07:00
add _location ( span , file$7 , 80 , 16 , 2590 ) ;
add _location ( li0 , file$7 , 79 , 12 , 2569 ) ;
add _location ( li1 , file$7 , 82 , 12 , 2670 ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , li0 , anchor ) ;
2021-05-11 03:25:33 +07:00
append _dev ( li0 , span ) ;
insert _dev ( target , t1 , anchor ) ;
2021-05-11 00:37:27 +07:00
insert _dev ( target , li1 , anchor ) ;
2021-05-11 03:25:33 +07:00
mount _component ( link , li1 , null ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const link _changes = { } ;
2021-05-11 03:25:33 +07:00
if ( dirty & /*url, totalPages*/ 10 ) link _changes . to = "" + ( /*url*/ ctx [ 3 ] + "page=" + /*totalPages*/ ctx [ 1 ] ) ;
if ( dirty & /*totalPages*/ 2 ) link _changes [ "aria-label" ] = "Goto page " + /*totalPages*/ ctx [ 1 ] ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope, totalPages*/ 262146 ) {
2021-05-11 00:37:27 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( t1 ) ;
2021-05-11 00:37:27 +07:00
if ( detaching ) detach _dev ( li1 ) ;
2021-05-11 03:25:33 +07:00
destroy _component ( link ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _if _block _1$3 . name ,
2021-05-11 00:37:27 +07:00
type : "if" ,
2021-05-11 03:25:33 +07:00
source : "(79:8) {#if totalPages - page > 2}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (84:16) <Link on:click={handlePage(totalPages)} to="{url}page={totalPages}" class="pagination-link" aria-label="Goto page {totalPages}">
function create _default _slot _1 ( ctx ) {
2021-05-11 00:37:27 +07:00
let t ;
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
t = text ( /*totalPages*/ ctx [ 1 ] ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , t , anchor ) ;
} ,
2021-05-11 03:25:33 +07:00
p : function update ( ctx , dirty ) {
if ( dirty & /*totalPages*/ 2 ) set _data _dev ( t , /*totalPages*/ ctx [ 1 ] ) ;
} ,
2021-05-11 00:37:27 +07:00
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( t ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _default _slot _1 . name ,
2021-05-11 00:37:27 +07:00
type : "slot" ,
2021-05-11 03:25:33 +07:00
source : "(84:16) <Link on:click={handlePage(totalPages)} to=\\\"{url}page={totalPages}\\\" class=\\\"pagination-link\\\" aria-label=\\\"Goto page {totalPages}\\\">" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (101:28) <Link to="/post/{post.id}">
function create _default _slot$3 ( ctx ) {
let img ;
let img _alt _value ;
let img _src _value ;
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
img = element ( "img" ) ;
attr _dev ( img , "alt" , img _alt _value = /*post*/ ctx [ 10 ] . id ) ;
if ( img . src !== ( img _src _value = /*post*/ ctx [ 10 ] . image _path ) ) attr _dev ( img , "src" , img _src _value ) ;
add _location ( img , file$7 , 101 , 32 , 3411 ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , img , anchor ) ;
2021-05-11 00:37:27 +07:00
} ,
p : function update ( ctx , dirty ) {
2021-05-11 03:25:33 +07:00
if ( dirty & /*postChunks*/ 16 && img _alt _value !== ( img _alt _value = /*post*/ ctx [ 10 ] . id ) ) {
attr _dev ( img , "alt" , img _alt _value ) ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*postChunks*/ 16 && img . src !== ( img _src _value = /*post*/ ctx [ 10 ] . image _path ) ) {
attr _dev ( img , "src" , img _src _value ) ;
2021-05-11 00:37:27 +07:00
}
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( img ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _default _slot$3 . name ,
type : "slot" ,
source : "(101:28) <Link to=\\\"/post/{post.id}\\\">" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (111:24) {:else}
function create _else _block$2 ( ctx ) {
let t ;
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
t = text ( "None" ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , t , anchor ) ;
2021-05-11 00:37:27 +07:00
} ,
2021-05-11 03:25:33 +07:00
p : noop ,
i : noop ,
o : noop ,
2021-05-11 00:37:27 +07:00
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( t ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _else _block$2 . name ,
2021-05-11 00:37:27 +07:00
type : "else" ,
2021-05-11 03:25:33 +07:00
source : "(111:24) {:else}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (107:24) {#if post.tags}
function create _if _block$3 ( ctx ) {
let each _blocks = [ ] ;
let each _1 _lookup = new Map ( ) ;
let each _1 _anchor ;
let current ;
let each _value _2 = /*post*/ ctx [ 10 ] . tags ;
validate _each _argument ( each _value _2 ) ;
const get _key = ctx => /*tag*/ ctx [ 13 ] ;
validate _each _keys ( ctx , each _value _2 , get _each _context _2 , get _key ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _value _2 . length ; i += 1 ) {
let child _ctx = get _each _context _2 ( ctx , each _value _2 , i ) ;
let key = get _key ( child _ctx ) ;
each _1 _lookup . set ( key , each _blocks [ i ] = create _each _block _2 ( key , child _ctx ) ) ;
}
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
each _1 _anchor = empty ( ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( target , anchor ) ;
}
insert _dev ( target , each _1 _anchor , anchor ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
2021-05-11 03:25:33 +07:00
p : function update ( ctx , dirty ) {
if ( dirty & /*postChunks*/ 16 ) {
each _value _2 = /*post*/ ctx [ 10 ] . tags ;
validate _each _argument ( each _value _2 ) ;
group _outros ( ) ;
validate _each _keys ( ctx , each _value _2 , get _each _context _2 , get _key ) ;
each _blocks = update _keyed _each ( each _blocks , dirty , get _key , 1 , ctx , each _value _2 , each _1 _lookup , each _1 _anchor . parentNode , outro _and _destroy _block , create _each _block _2 , each _1 _anchor , get _each _context _2 ) ;
check _outros ( ) ;
2021-05-11 00:37:27 +07:00
}
} ,
i : function intro ( local ) {
if ( current ) return ;
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _value _2 . length ; i += 1 ) {
transition _in ( each _blocks [ i ] ) ;
}
2021-05-11 00:37:27 +07:00
current = true ;
} ,
o : function outro ( local ) {
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
current = false ;
2021-05-11 00:37:27 +07:00
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . d ( detaching ) ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( each _1 _anchor ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _if _block$3 . name ,
type : "if" ,
source : "(107:24) {#if post.tags}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (108:28) {#each post.tags as tag (tag)}
function create _each _block _2 ( key _1 , ctx ) {
let first ;
let taglink ;
2021-05-11 00:37:27 +07:00
let current ;
2021-05-11 03:25:33 +07:00
taglink = new TagLink ( {
props : { tag : /*tag*/ ctx [ 13 ] } ,
$$inline : true
} ) ;
2021-05-11 00:37:27 +07:00
const block = {
2021-05-11 03:25:33 +07:00
key : key _1 ,
first : null ,
2021-05-11 00:37:27 +07:00
c : function create ( ) {
2021-05-11 03:25:33 +07:00
first = empty ( ) ;
create _component ( taglink . $$ . fragment ) ;
this . first = first ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , first , anchor ) ;
mount _component ( taglink , target , anchor ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
2021-05-11 03:25:33 +07:00
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const taglink _changes = { } ;
if ( dirty & /*postChunks*/ 16 ) taglink _changes . tag = /*tag*/ ctx [ 13 ] ;
taglink . $set ( taglink _changes ) ;
2021-05-11 00:37:27 +07:00
} ,
i : function intro ( local ) {
if ( current ) return ;
2021-05-11 03:25:33 +07:00
transition _in ( taglink . $$ . fragment , local ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
o : function outro ( local ) {
2021-05-11 03:25:33 +07:00
transition _out ( taglink . $$ . fragment , local ) ;
2021-05-11 00:37:27 +07:00
current = false ;
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( first ) ;
destroy _component ( taglink , detaching ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _each _block _2 . name ,
type : "each" ,
2021-05-11 03:25:33 +07:00
source : "(108:28) {#each post.tags as tag (tag)}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (97:12) {#each postChunk as post, i (post.id)}
function create _each _block _1$1 ( key _1 , ctx ) {
let div2 ;
let div0 ;
let figure ;
2021-05-11 00:37:27 +07:00
let link ;
2021-05-11 03:25:33 +07:00
let t ;
let div1 ;
let current _block _type _index ;
let if _block ;
2021-05-11 00:37:27 +07:00
let current ;
link = new Link ( {
props : {
2021-05-11 03:25:33 +07:00
to : "/post/" + /*post*/ ctx [ 10 ] . id ,
$$slots : { default : [ create _default _slot$3 ] } ,
2021-05-11 00:37:27 +07:00
$$scope : { ctx }
} ,
$$inline : true
} ) ;
2021-05-11 03:25:33 +07:00
const if _block _creators = [ create _if _block$3 , create _else _block$2 ] ;
const if _blocks = [ ] ;
function select _block _type _1 ( ctx , dirty ) {
if ( /*post*/ ctx [ 10 ] . tags ) return 0 ;
return 1 ;
}
current _block _type _index = select _block _type _1 ( ctx ) ;
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
2021-05-11 00:37:27 +07:00
const block = {
2021-05-11 03:25:33 +07:00
key : key _1 ,
first : null ,
2021-05-11 00:37:27 +07:00
c : function create ( ) {
2021-05-11 03:25:33 +07:00
div2 = element ( "div" ) ;
div0 = element ( "div" ) ;
figure = element ( "figure" ) ;
2021-05-11 00:37:27 +07:00
create _component ( link . $$ . fragment ) ;
2021-05-11 03:25:33 +07:00
t = space ( ) ;
div1 = element ( "div" ) ;
if _block . c ( ) ;
attr _dev ( figure , "class" , "image" ) ;
add _location ( figure , file$7 , 99 , 24 , 3300 ) ;
attr _dev ( div0 , "class" , "card-image" ) ;
add _location ( div0 , file$7 , 98 , 20 , 3251 ) ;
attr _dev ( div1 , "class" , "card-content" ) ;
add _location ( div1 , file$7 , 105 , 20 , 3572 ) ;
attr _dev ( div2 , "class" , "tile is-child is-vertical card" ) ;
add _location ( div2 , file$7 , 97 , 16 , 3186 ) ;
this . first = div2 ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , div2 , anchor ) ;
append _dev ( div2 , div0 ) ;
append _dev ( div0 , figure ) ;
mount _component ( link , figure , null ) ;
append _dev ( div2 , t ) ;
append _dev ( div2 , div1 ) ;
if _blocks [ current _block _type _index ] . m ( div1 , null ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const link _changes = { } ;
2021-05-11 03:25:33 +07:00
if ( dirty & /*postChunks*/ 16 ) link _changes . to = "/post/" + /*post*/ ctx [ 10 ] . id ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope, postChunks*/ 262160 ) {
2021-05-11 00:37:27 +07:00
link _changes . $$scope = { dirty , ctx } ;
}
link . $set ( link _changes ) ;
2021-05-11 03:25:33 +07:00
let previous _block _index = current _block _type _index ;
current _block _type _index = select _block _type _1 ( 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 ( div1 , null ) ;
}
2021-05-11 00:37:27 +07:00
} ,
i : function intro ( local ) {
if ( current ) return ;
transition _in ( link . $$ . fragment , local ) ;
2021-05-11 03:25:33 +07:00
transition _in ( if _block ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
o : function outro ( local ) {
transition _out ( link . $$ . fragment , local ) ;
2021-05-11 03:25:33 +07:00
transition _out ( if _block ) ;
2021-05-11 00:37:27 +07:00
current = false ;
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( div2 ) ;
2021-05-11 00:37:27 +07:00
destroy _component ( link ) ;
2021-05-11 03:25:33 +07:00
if _blocks [ current _block _type _index ] . d ( ) ;
2021-05-11 00:37:27 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _each _block _1$1 . name ,
type : "each" ,
source : "(97:12) {#each postChunk as post, i (post.id)}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
// (95:4) {#each postChunks as postChunk}
function create _each _block$2 ( ctx ) {
let div ;
let each _blocks = [ ] ;
let each _1 _lookup = new Map ( ) ;
2021-05-11 00:37:27 +07:00
let t ;
2021-05-11 03:25:33 +07:00
let current ;
let each _value _1 = /*postChunk*/ ctx [ 7 ] ;
validate _each _argument ( each _value _1 ) ;
const get _key = ctx => /*post*/ ctx [ 10 ] . id ;
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 ) ) ;
}
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
div = element ( "div" ) ;
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
2021-05-11 03:25:33 +07:00
t = space ( ) ;
attr _dev ( div , "class" , "tile is-parent is-vertical is-3" ) ;
add _location ( div , file$7 , 95 , 8 , 3073 ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , div , anchor ) ;
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
2021-05-11 03:25:33 +07:00
each _blocks [ i ] . m ( div , null ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
append _dev ( div , t ) ;
2021-05-11 00:37:27 +07:00
current = true ;
} ,
2021-05-11 03:25:33 +07:00
p : function update ( ctx , dirty ) {
if ( dirty & /*postChunks*/ 16 ) {
each _value _1 = /*postChunk*/ ctx [ 7 ] ;
2021-05-11 00:37:27 +07:00
validate _each _argument ( each _value _1 ) ;
group _outros ( ) ;
validate _each _keys ( ctx , each _value _1 , get _each _context _1$1 , get _key ) ;
2021-05-11 03:25:33 +07:00
each _blocks = update _keyed _each ( each _blocks , dirty , get _key , 1 , ctx , each _value _1 , each _1 _lookup , div , outro _and _destroy _block , create _each _block _1$1 , t , get _each _context _1$1 ) ;
2021-05-11 00:37:27 +07:00
check _outros ( ) ;
}
} ,
i : function intro ( local ) {
if ( current ) return ;
for ( let i = 0 ; i < each _value _1 . 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 ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( div ) ;
2021-05-11 00:37:27 +07:00
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" ,
2021-05-11 03:25:33 +07:00
source : "(95:4) {#each postChunks as postChunk}" ,
2021-05-11 00:37:27 +07:00
ctx
} ) ;
return block ;
}
function create _fragment$8 ( ctx ) {
let nav ;
let t0 ;
let t1 ;
let ul ;
let t2 ;
let t3 ;
let t4 ;
2021-05-11 03:25:33 +07:00
let div ;
2021-05-11 00:37:27 +07:00
let current ;
2021-05-11 03:25:33 +07:00
let if _block0 = /*page*/ ctx [ 0 ] > 1 && create _if _block _6 ( ctx ) ;
let if _block1 = /*page*/ ctx [ 0 ] < /*totalPages*/ ctx [ 1 ] && create _if _block _5 ( ctx ) ;
let if _block2 = /*page*/ ctx [ 0 ] > 3 && create _if _block _4 ( ctx ) ;
let each _value _3 = [ ... Array ( 5 ) . keys ( ) ] . map ( /*func*/ ctx [ 6 ] ) ;
validate _each _argument ( each _value _3 ) ;
2021-05-11 00:37:27 +07:00
let each _blocks _1 = [ ] ;
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _value _3 . length ; i += 1 ) {
each _blocks _1 [ i ] = create _each _block _3 ( get _each _context _3 ( ctx , each _value _3 , i ) ) ;
2021-05-11 00:37:27 +07:00
}
const out = i => transition _out ( each _blocks _1 [ i ] , 1 , 1 , ( ) => {
each _blocks _1 [ i ] = null ;
} ) ;
2021-05-11 03:25:33 +07:00
let if _block3 = /*totalPages*/ ctx [ 1 ] - /*page*/ ctx [ 0 ] > 2 && create _if _block _1$3 ( ctx ) ;
let each _value = /*postChunks*/ ctx [ 4 ] ;
2021-05-11 00:37:27 +07:00
validate _each _argument ( each _value ) ;
2021-05-11 03:25:33 +07:00
let each _blocks = [ ] ;
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
2021-05-11 03:25:33 +07:00
each _blocks [ i ] = create _each _block$2 ( get _each _context$2 ( ctx , each _value , i ) ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-11 03:25:33 +07:00
const out _1 = i => transition _out ( each _blocks [ i ] , 1 , 1 , ( ) => {
each _blocks [ i ] = null ;
} ) ;
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
nav = element ( "nav" ) ;
if ( if _block0 ) if _block0 . c ( ) ;
t0 = space ( ) ;
if ( if _block1 ) if _block1 . c ( ) ;
t1 = space ( ) ;
ul = element ( "ul" ) ;
if ( if _block2 ) if _block2 . c ( ) ;
t2 = space ( ) ;
for ( let i = 0 ; i < each _blocks _1 . length ; i += 1 ) {
each _blocks _1 [ i ] . c ( ) ;
}
t3 = space ( ) ;
if ( if _block3 ) if _block3 . c ( ) ;
t4 = space ( ) ;
2021-05-11 03:25:33 +07:00
div = element ( "div" ) ;
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
attr _dev ( ul , "class" , "pagination-list" ) ;
2021-05-11 03:25:33 +07:00
add _location ( ul , file$7 , 41 , 4 , 1216 ) ;
2021-05-11 00:37:27 +07:00
attr _dev ( nav , "class" , "pagination" ) ;
attr _dev ( nav , "role" , "navigation" ) ;
attr _dev ( nav , "aria-label" , "pagination" ) ;
2021-05-11 03:25:33 +07:00
add _location ( nav , file$7 , 24 , 0 , 700 ) ;
attr _dev ( div , "class" , "tile is-multiline is-ancestor" ) ;
add _location ( div , file$7 , 93 , 0 , 2985 ) ;
2021-05-11 00:37:27 +07:00
} ,
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 ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , nav , anchor ) ;
2021-05-11 00:37:27 +07:00
if ( if _block0 ) if _block0 . m ( nav , null ) ;
append _dev ( nav , t0 ) ;
if ( if _block1 ) if _block1 . m ( nav , null ) ;
append _dev ( nav , t1 ) ;
append _dev ( nav , ul ) ;
if ( if _block2 ) if _block2 . m ( ul , null ) ;
append _dev ( ul , t2 ) ;
for ( let i = 0 ; i < each _blocks _1 . length ; i += 1 ) {
each _blocks _1 [ i ] . m ( ul , null ) ;
}
append _dev ( ul , t3 ) ;
if ( if _block3 ) if _block3 . m ( ul , null ) ;
2021-05-11 03:25:33 +07:00
insert _dev ( target , t4 , anchor ) ;
insert _dev ( target , div , anchor ) ;
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
2021-05-11 03:25:33 +07:00
each _blocks [ i ] . m ( div , null ) ;
2021-05-11 00:37:27 +07:00
}
current = true ;
} ,
p : function update ( ctx , [ dirty ] ) {
2021-05-11 03:25:33 +07:00
if ( /*page*/ ctx [ 0 ] > 1 ) {
2021-05-11 00:37:27 +07:00
if ( if _block0 ) {
if _block0 . p ( ctx , dirty ) ;
2021-05-11 03:25:33 +07:00
if ( dirty & /*page*/ 1 ) {
2021-05-11 00:37:27 +07:00
transition _in ( if _block0 , 1 ) ;
}
} else {
2021-05-11 03:25:33 +07:00
if _block0 = create _if _block _6 ( ctx ) ;
2021-05-11 00:37:27 +07:00
if _block0 . c ( ) ;
transition _in ( if _block0 , 1 ) ;
if _block0 . m ( nav , t0 ) ;
}
} else if ( if _block0 ) {
group _outros ( ) ;
transition _out ( if _block0 , 1 , 1 , ( ) => {
if _block0 = null ;
} ) ;
check _outros ( ) ;
}
2021-05-11 03:25:33 +07:00
if ( /*page*/ ctx [ 0 ] < /*totalPages*/ ctx [ 1 ] ) {
2021-05-11 00:37:27 +07:00
if ( if _block1 ) {
if _block1 . p ( ctx , dirty ) ;
2021-05-11 03:25:33 +07:00
if ( dirty & /*page, totalPages*/ 3 ) {
2021-05-11 00:37:27 +07:00
transition _in ( if _block1 , 1 ) ;
}
} else {
2021-05-11 03:25:33 +07:00
if _block1 = create _if _block _5 ( ctx ) ;
2021-05-11 00:37:27 +07:00
if _block1 . c ( ) ;
transition _in ( if _block1 , 1 ) ;
if _block1 . m ( nav , t1 ) ;
}
} else if ( if _block1 ) {
group _outros ( ) ;
transition _out ( if _block1 , 1 , 1 , ( ) => {
if _block1 = null ;
} ) ;
check _outros ( ) ;
}
2021-05-11 03:25:33 +07:00
if ( /*page*/ ctx [ 0 ] > 3 ) {
2021-05-11 00:37:27 +07:00
if ( if _block2 ) {
if _block2 . p ( ctx , dirty ) ;
2021-05-11 03:25:33 +07:00
if ( dirty & /*page*/ 1 ) {
2021-05-11 00:37:27 +07:00
transition _in ( if _block2 , 1 ) ;
}
} else {
2021-05-11 03:25:33 +07:00
if _block2 = create _if _block _4 ( ctx ) ;
2021-05-11 00:37:27 +07:00
if _block2 . c ( ) ;
transition _in ( if _block2 , 1 ) ;
if _block2 . m ( ul , t2 ) ;
}
} else if ( if _block2 ) {
group _outros ( ) ;
transition _out ( if _block2 , 1 , 1 , ( ) => {
if _block2 = null ;
} ) ;
check _outros ( ) ;
}
2021-05-11 03:25:33 +07:00
if ( dirty & /*url, Array, page, handlePage, totalPages*/ 15 ) {
each _value _3 = [ ... Array ( 5 ) . keys ( ) ] . map ( /*func*/ ctx [ 6 ] ) ;
validate _each _argument ( each _value _3 ) ;
2021-05-11 00:37:27 +07:00
let i ;
2021-05-11 03:25:33 +07:00
for ( i = 0 ; i < each _value _3 . length ; i += 1 ) {
const child _ctx = get _each _context _3 ( ctx , each _value _3 , i ) ;
2021-05-11 00:37:27 +07:00
if ( each _blocks _1 [ i ] ) {
each _blocks _1 [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks _1 [ i ] , 1 ) ;
} else {
2021-05-11 03:25:33 +07:00
each _blocks _1 [ i ] = create _each _block _3 ( child _ctx ) ;
2021-05-11 00:37:27 +07:00
each _blocks _1 [ i ] . c ( ) ;
transition _in ( each _blocks _1 [ i ] , 1 ) ;
each _blocks _1 [ i ] . m ( ul , t3 ) ;
}
}
group _outros ( ) ;
2021-05-11 03:25:33 +07:00
for ( i = each _value _3 . length ; i < each _blocks _1 . length ; i += 1 ) {
2021-05-11 00:37:27 +07:00
out ( i ) ;
}
check _outros ( ) ;
}
2021-05-11 03:25:33 +07:00
if ( /*totalPages*/ ctx [ 1 ] - /*page*/ ctx [ 0 ] > 2 ) {
2021-05-11 00:37:27 +07:00
if ( if _block3 ) {
if _block3 . p ( ctx , dirty ) ;
2021-05-11 03:25:33 +07:00
if ( dirty & /*totalPages, page*/ 3 ) {
2021-05-11 00:37:27 +07:00
transition _in ( if _block3 , 1 ) ;
}
} else {
2021-05-11 03:25:33 +07:00
if _block3 = create _if _block _1$3 ( ctx ) ;
2021-05-11 00:37:27 +07:00
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 ( ) ;
}
2021-05-11 03:25:33 +07:00
if ( dirty & /*postChunks*/ 16 ) {
each _value = /*postChunks*/ ctx [ 4 ] ;
2021-05-11 00:37:27 +07:00
validate _each _argument ( each _value ) ;
2021-05-11 03:25:33 +07:00
let i ;
for ( i = 0 ; i < each _value . length ; i += 1 ) {
const child _ctx = get _each _context$2 ( ctx , each _value , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
} else {
each _blocks [ i ] = create _each _block$2 ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
each _blocks [ i ] . m ( div , null ) ;
}
}
2021-05-11 00:37:27 +07:00
group _outros ( ) ;
2021-05-11 03:25:33 +07:00
for ( i = each _value . length ; i < each _blocks . length ; i += 1 ) {
out _1 ( i ) ;
}
2021-05-11 00:37:27 +07:00
check _outros ( ) ;
}
} ,
2021-05-10 22:47:35 +07:00
i : function intro ( local ) {
if ( current ) return ;
2021-05-11 00:37:27 +07:00
transition _in ( if _block0 ) ;
transition _in ( if _block1 ) ;
transition _in ( if _block2 ) ;
2021-05-11 03:25:33 +07:00
for ( let i = 0 ; i < each _value _3 . length ; i += 1 ) {
2021-05-11 00:37:27 +07:00
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 ] ) ;
}
2021-05-10 22:47:35 +07:00
current = true ;
} ,
o : function outro ( local ) {
2021-05-11 00:37:27 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
each _blocks = each _blocks . filter ( Boolean ) ;
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
2021-05-10 22:47:35 +07:00
current = false ;
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( nav ) ;
2021-05-11 00:37:27 +07:00
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 ( ) ;
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( t4 ) ;
if ( detaching ) detach _dev ( div ) ;
destroy _each ( each _blocks , detaching ) ;
2021-05-10 22:47:35 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 00:37:27 +07:00
id : create _fragment$8 . name ,
type : "component" ,
source : "" ,
2021-05-10 22:47:35 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 00:37:27 +07:00
function instance$8 ( $$self , $$props , $$invalidate ) {
let { $$slots : slots = { } , $$scope } = $$props ;
validate _slots ( "PostPaginator" , slots , [ ] ) ;
let { posts = [ ] } = $$props ;
2021-05-11 03:25:33 +07:00
let postChunks = [ ] ;
2021-05-11 00:37:27 +07:00
let { page = 1 } = $$props ;
let { totalPages = 1 } = $$props ;
let { handlePage = i => {
} } = $$props ;
let { url = "/posts" } = $$props ;
const writable _props = [ "posts" , "page" , "totalPages" , "handlePage" , "url" ] ;
Object . keys ( $$props ) . forEach ( key => {
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== "$$" ) console . warn ( ` <PostPaginator> was created with unknown prop ' ${ key } ' ` ) ;
} ) ;
const func = x => x + page - 2 ;
$$self . $$set = $$props => {
2021-05-11 03:25:33 +07:00
if ( "posts" in $$props ) $$invalidate ( 5 , posts = $$props . posts ) ;
if ( "page" in $$props ) $$invalidate ( 0 , page = $$props . page ) ;
if ( "totalPages" in $$props ) $$invalidate ( 1 , totalPages = $$props . totalPages ) ;
if ( "handlePage" in $$props ) $$invalidate ( 2 , handlePage = $$props . handlePage ) ;
if ( "url" in $$props ) $$invalidate ( 3 , url = $$props . url ) ;
2021-05-11 00:37:27 +07:00
} ;
$$self . $capture _state = ( ) => ( {
Link ,
2021-05-11 03:25:33 +07:00
TagLink ,
2021-05-11 00:37:27 +07:00
posts ,
2021-05-11 03:25:33 +07:00
postChunks ,
2021-05-11 00:37:27 +07:00
page ,
totalPages ,
handlePage ,
url
} ) ;
$$self . $inject _state = $$props => {
2021-05-11 03:25:33 +07:00
if ( "posts" in $$props ) $$invalidate ( 5 , posts = $$props . posts ) ;
if ( "postChunks" in $$props ) $$invalidate ( 4 , postChunks = $$props . postChunks ) ;
if ( "page" in $$props ) $$invalidate ( 0 , page = $$props . page ) ;
if ( "totalPages" in $$props ) $$invalidate ( 1 , totalPages = $$props . totalPages ) ;
if ( "handlePage" in $$props ) $$invalidate ( 2 , handlePage = $$props . handlePage ) ;
if ( "url" in $$props ) $$invalidate ( 3 , url = $$props . url ) ;
2021-05-11 00:37:27 +07:00
} ;
if ( $$props && "$$inject" in $$props ) {
$$self . $inject _state ( $$props . $$inject ) ;
}
2021-05-11 03:25:33 +07:00
$$self . $$ . update = ( ) => {
if ( $$self . $$ . dirty & /*posts*/ 32 ) {
// split posts into 4 columns
$$invalidate ( 4 , postChunks = Array ( Math . min ( posts . length , 4 ) ) . fill ( ) . map ( function ( _ , i ) {
let chunkSize = Math . floor ( posts . length / 4 ) ;
if ( chunkSize % 4 > i + 1 ) {
chunkSize += 1 ;
}
chunkSize = Math . max ( chunkSize , 1 ) ;
return posts . slice ( i * chunkSize , i * chunkSize + chunkSize ) ;
} ) ) ;
}
} ;
return [ page , totalPages , handlePage , url , postChunks , posts , func ] ;
2021-05-11 00:37:27 +07:00
}
class PostPaginator extends SvelteComponentDev {
constructor ( options ) {
super ( options ) ;
init ( this , options , instance$8 , create _fragment$8 , safe _not _equal , {
2021-05-11 03:25:33 +07:00
posts : 5 ,
page : 0 ,
totalPages : 1 ,
handlePage : 2 ,
url : 3
2021-05-11 00:37:27 +07:00
} ) ;
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "PostPaginator" ,
options ,
id : create _fragment$8 . name
} ) ;
}
get posts ( ) {
throw new Error ( "<PostPaginator>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set posts ( value ) {
throw new Error ( "<PostPaginator>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get page ( ) {
throw new Error ( "<PostPaginator>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set page ( value ) {
throw new Error ( "<PostPaginator>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get totalPages ( ) {
throw new Error ( "<PostPaginator>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set totalPages ( value ) {
throw new Error ( "<PostPaginator>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get handlePage ( ) {
throw new Error ( "<PostPaginator>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set handlePage ( value ) {
throw new Error ( "<PostPaginator>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get url ( ) {
throw new Error ( "<PostPaginator>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set url ( value ) {
throw new Error ( "<PostPaginator>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
}
2021-05-11 03:25:33 +07:00
function createCommonjsModule ( fn ) {
var module = { exports : { } } ;
return fn ( module , module . exports ) , module . exports ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
var strictUriEncode = str => encodeURIComponent ( str ) . replace ( /[!'()*]/g , x => ` % ${ x . charCodeAt ( 0 ) . toString ( 16 ) . toUpperCase ( ) } ` ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
var token = '%[a-f0-9]{2}' ;
var singleMatcher = new RegExp ( token , 'gi' ) ;
var multiMatcher = new RegExp ( '(' + token + ')+' , 'gi' ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function decodeComponents ( components , split ) {
try {
// Try to decode the entire string first
return decodeURIComponent ( components . join ( '' ) ) ;
} catch ( err ) {
// Do nothing
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( components . length === 1 ) {
return components ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
split = split || 1 ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
// Split the array in 2 parts
var left = components . slice ( 0 , split ) ;
var right = components . slice ( split ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return Array . prototype . concat . call ( [ ] , decodeComponents ( left ) , decodeComponents ( right ) ) ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function decode ( input ) {
try {
return decodeURIComponent ( input ) ;
} catch ( err ) {
var tokens = input . match ( singleMatcher ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
for ( var i = 1 ; i < tokens . length ; i ++ ) {
input = decodeComponents ( tokens , i ) . join ( '' ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
tokens = input . match ( singleMatcher ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
return input ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
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'
2021-05-11 00:37:27 +07:00
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
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 ] ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( result !== match [ 0 ] ) {
replaceMap [ match [ 0 ] ] = result ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
match = multiMatcher . exec ( input ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
replaceMap [ '%C2' ] = '\uFFFD' ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
var entries = Object . keys ( replaceMap ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
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 ] ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return input ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
var decodeUriComponent = function ( encodedURI ) {
if ( typeof encodedURI !== 'string' ) {
throw new TypeError ( 'Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`' ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
try {
encodedURI = encodedURI . replace ( /\+/g , ' ' ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
// Try the built in decoder first
return decodeURIComponent ( encodedURI ) ;
} catch ( err ) {
// Fallback to a more advanced decoder
return customDecodeURIComponent ( encodedURI ) ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
var splitOnFirst = ( string , separator ) => {
if ( ! ( typeof string === 'string' && typeof separator === 'string' ) ) {
throw new TypeError ( 'Expected the arguments to be of type `string`' ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( separator === '' ) {
return [ string ] ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const separatorIndex = string . indexOf ( separator ) ;
if ( separatorIndex === - 1 ) {
return [ string ] ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return [
string . slice ( 0 , separatorIndex ) ,
string . slice ( separatorIndex + separator . length )
] ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
var filterObj = function ( obj , predicate ) {
var ret = { } ;
var keys = Object . keys ( obj ) ;
var isArr = Array . isArray ( predicate ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
for ( var i = 0 ; i < keys . length ; i ++ ) {
var key = keys [ i ] ;
var val = obj [ key ] ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( isArr ? predicate . indexOf ( key ) !== - 1 : predicate ( key , val , obj ) ) {
ret [ key ] = val ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return ret ;
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
var queryString = createCommonjsModule ( function ( module , exports ) {
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const isNullOrUndefined = value => value === null || value === undefined ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function encoderForArrayFormat ( options ) {
switch ( options . arrayFormat ) {
case 'index' :
return key => ( result , value ) => {
const index = result . length ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if (
value === undefined ||
( options . skipNull && value === null ) ||
( options . skipEmptyString && value === '' )
) {
return result ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( value === null ) {
return [ ... result , [ encode ( key , options ) , '[' , index , ']' ] . join ( '' ) ] ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return [
... result ,
[ encode ( key , options ) , '[' , encode ( index , options ) , ']=' , encode ( value , options ) ] . join ( '' )
] ;
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
case 'bracket' :
return key => ( result , value ) => {
if (
value === undefined ||
( options . skipNull && value === null ) ||
( options . skipEmptyString && value === '' )
) {
return result ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( value === null ) {
return [ ... result , [ encode ( key , options ) , '[]' ] . join ( '' ) ] ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return [ ... result , [ encode ( key , options ) , '[]=' , encode ( value , options ) ] . join ( '' ) ] ;
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
case 'comma' :
case 'separator' :
case 'bracket-separator' : {
const keyValueSep = options . arrayFormat === 'bracket-separator' ?
'[]=' :
'=' ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return key => ( result , value ) => {
if (
value === undefined ||
( options . skipNull && value === null ) ||
( options . skipEmptyString && value === '' )
) {
return result ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
// Translate null to an empty string so that it doesn't serialize as 'null'
value = value === null ? '' : value ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( result . length === 0 ) {
return [ [ encode ( key , options ) , keyValueSep , encode ( value , options ) ] . join ( '' ) ] ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return [ [ result , encode ( value , options ) ] . join ( options . arrayFormatSeparator ) ] ;
} ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
default :
return key => ( result , value ) => {
if (
value === undefined ||
( options . skipNull && value === null ) ||
( options . skipEmptyString && value === '' )
) {
return result ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( value === null ) {
return [ ... result , encode ( key , options ) ] ;
}
return [ ... result , [ encode ( key , options ) , '=' , encode ( value , options ) ] . join ( '' ) ] ;
} ;
}
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
function parserForArrayFormat ( options ) {
let result ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
switch ( options . arrayFormat ) {
case 'index' :
return ( key , value , accumulator ) => {
result = /\[(\d*)\]$/ . exec ( key ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
key = key . replace ( /\[\d*\]$/ , '' ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( ! result ) {
accumulator [ key ] = value ;
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( accumulator [ key ] === undefined ) {
accumulator [ key ] = { } ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
accumulator [ key ] [ result [ 1 ] ] = value ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
case 'bracket' :
return ( key , value , accumulator ) => {
result = /(\[\])$/ . exec ( key ) ;
key = key . replace ( /\[\]$/ , '' ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( ! result ) {
accumulator [ key ] = value ;
return ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
if ( accumulator [ key ] === undefined ) {
accumulator [ key ] = [ value ] ;
return ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
accumulator [ key ] = [ ] . concat ( accumulator [ key ] , value ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
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 ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
case 'bracket-separator' :
return ( key , value , accumulator ) => {
const isArray = /(\[\])$/ . test ( key ) ;
key = key . replace ( /\[\]$/ , '' ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( ! isArray ) {
accumulator [ key ] = value ? decode ( value , options ) : value ;
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const arrayValue = value === null ?
[ ] :
value . split ( options . arrayFormatSeparator ) . map ( item => decode ( item , options ) ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( accumulator [ key ] === undefined ) {
accumulator [ key ] = arrayValue ;
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
accumulator [ key ] = [ ] . concat ( accumulator [ key ] , arrayValue ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
default :
return ( key , value , accumulator ) => {
if ( accumulator [ key ] === undefined ) {
accumulator [ key ] = value ;
return ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
accumulator [ key ] = [ ] . concat ( accumulator [ key ] , value ) ;
} ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function validateArrayFormatSeparator ( value ) {
if ( typeof value !== 'string' || value . length !== 1 ) {
throw new TypeError ( 'arrayFormatSeparator must be single character string' ) ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function encode ( value , options ) {
if ( options . encode ) {
return options . strict ? strictUriEncode ( value ) : encodeURIComponent ( value ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
return value ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
function decode ( value , options ) {
if ( options . decode ) {
return decodeUriComponent ( value ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return value ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function keysSorter ( input ) {
if ( Array . isArray ( input ) ) {
return input . sort ( ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
if ( typeof input === 'object' ) {
return keysSorter ( Object . keys ( input ) )
. sort ( ( a , b ) => Number ( a ) - Number ( b ) )
. map ( key => input [ key ] ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
return input ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
function removeHash ( input ) {
const hashStart = input . indexOf ( '#' ) ;
if ( hashStart !== - 1 ) {
input = input . slice ( 0 , hashStart ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return input ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function getHash ( url ) {
let hash = '' ;
const hashStart = url . indexOf ( '#' ) ;
if ( hashStart !== - 1 ) {
hash = url . slice ( hashStart ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return hash ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
function extract ( input ) {
input = removeHash ( input ) ;
const queryStart = input . indexOf ( '?' ) ;
if ( queryStart === - 1 ) {
return '' ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
return input . slice ( queryStart + 1 ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
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' ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return value ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
function parse ( query , options ) {
options = Object . assign ( {
decode : true ,
sort : true ,
arrayFormat : 'none' ,
arrayFormatSeparator : ',' ,
parseNumbers : false ,
parseBooleans : false
} , options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
validateArrayFormatSeparator ( options . arrayFormatSeparator ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const formatter = parserForArrayFormat ( options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
// Create an object with no prototype
const ret = Object . create ( null ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( typeof query !== 'string' ) {
return ret ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
query = query . trim ( ) . replace ( /^[?#&]/ , '' ) ;
if ( ! query ) {
return ret ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
for ( const param of query . split ( '&' ) ) {
if ( param === '' ) {
continue ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
let [ key , value ] = splitOnFirst ( options . decode ? param . replace ( /\+/g , ' ' ) : param , '=' ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
// 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 ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
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 ) ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
exports . extract = extract ;
exports . parse = parse ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
exports . stringify = ( object , options ) => {
if ( ! object ) {
return '' ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
options = Object . assign ( {
encode : true ,
strict : true ,
arrayFormat : 'none' ,
arrayFormatSeparator : ','
} , options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
validateArrayFormatSeparator ( options . arrayFormatSeparator ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const shouldFilter = key => (
( options . skipNull && isNullOrUndefined ( object [ key ] ) ) ||
( options . skipEmptyString && object [ key ] === '' )
) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const formatter = encoderForArrayFormat ( options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const objectCopy = { } ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
for ( const key of Object . keys ( object ) ) {
if ( ! shouldFilter ( key ) ) {
objectCopy [ key ] = object [ key ] ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const keys = Object . keys ( objectCopy ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( options . sort !== false ) {
keys . sort ( options . sort ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return keys . map ( key => {
const value = object [ key ] ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( value === undefined ) {
return '' ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
if ( value === null ) {
return encode ( key , options ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( Array . isArray ( value ) ) {
if ( value . length === 0 && options . arrayFormat === 'bracket-separator' ) {
return encode ( key , options ) + '[]' ;
}
return value
. reduce ( formatter ( key ) , [ ] )
. join ( '&' ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
return encode ( key , options ) + '=' + encode ( value , options ) ;
} ) . filter ( x => x . length > 0 ) . join ( '&' ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
exports . parseUrl = ( url , options ) => {
options = Object . assign ( {
decode : true
} , options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const [ url _ , hash ] = splitOnFirst ( url , '#' ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return Object . assign (
{
url : url _ . split ( '?' ) [ 0 ] || '' ,
query : parse ( extract ( url ) , options )
} ,
options && options . parseFragmentIdentifier && hash ? { fragmentIdentifier : decode ( hash , options ) } : { }
) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
exports . stringifyUrl = ( object , options ) => {
options = Object . assign ( {
encode : true ,
strict : true
} , options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const url = removeHash ( object . url ) . split ( '?' ) [ 0 ] || '' ;
const queryFromUrl = exports . extract ( object . url ) ;
const parsedQueryFromUrl = exports . parse ( queryFromUrl , { sort : false } ) ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
const query = Object . assign ( parsedQueryFromUrl , object . query ) ;
let queryString = exports . stringify ( query , options ) ;
if ( queryString ) {
queryString = ` ? ${ queryString } ` ;
}
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
let hash = getHash ( object . url ) ;
if ( object . fragmentIdentifier ) {
hash = ` # ${ encode ( object . fragmentIdentifier , options ) } ` ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return ` ${ url } ${ queryString } ${ hash } ` ;
} ;
2021-05-11 00:37:27 +07:00
2021-05-11 03:25:33 +07:00
exports . pick = ( input , filter , options ) => {
options = Object . assign ( {
parseFragmentIdentifier : true
} , options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const { url , query , fragmentIdentifier } = exports . parseUrl ( input , options ) ;
return exports . stringifyUrl ( {
url ,
query : filterObj ( query , filter ) ,
fragmentIdentifier
} , options ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
exports . exclude = ( input , filter , options ) => {
const exclusionFilter = Array . isArray ( filter ) ? key => ! filter . includes ( key ) : ( key , value ) => ! filter ( key , value ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return exports . pick ( input , exclusionFilter , options ) ;
} ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
/* node_modules/svelte-tags-input/src/Tags.svelte generated by Svelte v3.38.2 */
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const { console : console _1$1 } = globals ;
const file$6 = "node_modules/svelte-tags-input/src/Tags.svelte" ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function get _each _context$1 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 37 ] = list [ i ] ;
child _ctx [ 39 ] = i ;
return child _ctx ;
2021-05-11 00:37:27 +07:00
}
function get _each _context _1 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 8 ] = list [ i ] ;
child _ctx [ 41 ] = i ;
return child _ctx ;
}
// (309:4) {#if tags.length > 0}
2021-05-11 03:25:33 +07:00
function create _if _block _1$2 ( ctx ) {
2021-05-11 00:37:27 +07:00
let each _1 _anchor ;
let each _value _1 = /*tags*/ ctx [ 0 ] ;
validate _each _argument ( each _value _1 ) ;
let each _blocks = [ ] ;
for ( let i = 0 ; i < each _value _1 . length ; i += 1 ) {
each _blocks [ i ] = create _each _block _1 ( get _each _context _1 ( ctx , each _value _1 , i ) ) ;
}
2021-05-10 22:47:35 +07:00
const block = {
c : function create ( ) {
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
each _1 _anchor = empty ( ) ;
2021-05-10 22:47:35 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( target , anchor ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
insert _dev ( target , each _1 _anchor , anchor ) ;
2021-05-10 22:47:35 +07:00
} ,
2021-05-11 00:37:27 +07:00
p : function update ( ctx , dirty ) {
if ( dirty [ 0 ] & /*removeTag, disable, tags, autoCompleteKey*/ 2121 ) {
each _value _1 = /*tags*/ ctx [ 0 ] ;
validate _each _argument ( each _value _1 ) ;
let i ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
for ( i = 0 ; i < each _value _1 . length ; i += 1 ) {
const child _ctx = get _each _context _1 ( ctx , each _value _1 , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
} else {
each _blocks [ i ] = create _each _block _1 ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
each _blocks [ i ] . m ( each _1 _anchor . parentNode , each _1 _anchor ) ;
}
}
for ( ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . d ( 1 ) ;
}
each _blocks . length = each _value _1 . length ;
2021-05-10 22:47:35 +07:00
}
} ,
d : function destroy ( detaching ) {
2021-05-11 00:37:27 +07:00
destroy _each ( each _blocks , detaching ) ;
if ( detaching ) detach _dev ( each _1 _anchor ) ;
2021-05-10 22:47:35 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _if _block _1$2 . name ,
2021-05-11 00:37:27 +07:00
type : "if" ,
source : "(309:4) {#if tags.length > 0}" ,
2021-05-10 22:47:35 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 00:37:27 +07:00
// (314:16) {:else}
2021-05-11 03:25:33 +07:00
function create _else _block$1 ( ctx ) {
2021-05-11 00:37:27 +07:00
let t _value = /*tag*/ ctx [ 8 ] [ /*autoCompleteKey*/ ctx [ 3 ] ] + "" ;
let t ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
t = text ( t _value ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , t , anchor ) ;
} ,
p : function update ( ctx , dirty ) {
if ( dirty [ 0 ] & /*tags, autoCompleteKey*/ 9 && t _value !== ( t _value = /*tag*/ ctx [ 8 ] [ /*autoCompleteKey*/ ctx [ 3 ] ] + "" ) ) set _data _dev ( t , t _value ) ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( t ) ;
}
2021-05-10 22:47:35 +07:00
} ;
2021-05-11 00:37:27 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _else _block$1 . name ,
2021-05-11 00:37:27 +07:00
type : "else" ,
source : "(314:16) {:else}" ,
ctx
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
return block ;
}
// (312:16) {#if typeof tag === 'string'}
function create _if _block _3 ( ctx ) {
let t _value = /*tag*/ ctx [ 8 ] + "" ;
let t ;
const block = {
c : function create ( ) {
t = text ( t _value ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , t , anchor ) ;
} ,
p : function update ( ctx , dirty ) {
if ( dirty [ 0 ] & /*tags*/ 1 && t _value !== ( t _value = /*tag*/ ctx [ 8 ] + "" ) ) set _data _dev ( t , t _value ) ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( t ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block _3 . name ,
type : "if" ,
source : "(312:16) {#if typeof tag === 'string'}" ,
ctx
2021-05-10 22:47:35 +07:00
} ) ;
2021-05-11 00:37:27 +07:00
return block ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// (317:16) {#if !disable}
2021-05-11 03:25:33 +07:00
function create _if _block _2$1 ( ctx ) {
2021-05-11 00:37:27 +07:00
let span ;
let mounted ;
let dispose ;
function click _handler ( ) {
return /*click_handler*/ ctx [ 27 ] ( /*i*/ ctx [ 41 ] ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
span = element ( "span" ) ;
span . textContent = "× " ;
attr _dev ( span , "class" , "svelte-tags-input-tag-remove svelte-1xz5xok" ) ;
2021-05-11 03:25:33 +07:00
add _location ( span , file$6 , 317 , 16 , 9118 ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , span , anchor ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( ! mounted ) {
dispose = listen _dev ( span , "click" , click _handler , false , false , false ) ;
mounted = true ;
}
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( span ) ;
mounted = false ;
dispose ( ) ;
}
2021-05-10 22:47:35 +07:00
} ;
2021-05-11 00:37:27 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _if _block _2$1 . name ,
2021-05-11 00:37:27 +07:00
type : "if" ,
source : "(317:16) {#if !disable}" ,
ctx
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
return block ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
// (310:8) {#each tags as tag, i}
function create _each _block _1 ( ctx ) {
let span ;
let t0 ;
let t1 ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function select _block _type ( ctx , dirty ) {
if ( typeof /*tag*/ ctx [ 8 ] === "string" ) return create _if _block _3 ;
2021-05-11 03:25:33 +07:00
return create _else _block$1 ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
let current _block _type = select _block _type ( ctx ) ;
let if _block0 = current _block _type ( ctx ) ;
2021-05-11 03:25:33 +07:00
let if _block1 = ! /*disable*/ ctx [ 6 ] && create _if _block _2$1 ( ctx ) ;
2021-05-10 22:47:35 +07:00
const block = {
2021-05-11 00:37:27 +07:00
c : function create ( ) {
span = element ( "span" ) ;
if _block0 . c ( ) ;
t0 = space ( ) ;
if ( if _block1 ) if _block1 . c ( ) ;
t1 = space ( ) ;
attr _dev ( span , "class" , "svelte-tags-input-tag svelte-1xz5xok" ) ;
2021-05-11 03:25:33 +07:00
add _location ( span , file$6 , 310 , 12 , 8866 ) ;
2021-05-10 22:47:35 +07:00
} ,
2021-05-11 00:37:27 +07:00
m : function mount ( target , anchor ) {
insert _dev ( target , span , anchor ) ;
if _block0 . m ( span , null ) ;
append _dev ( span , t0 ) ;
if ( if _block1 ) if _block1 . m ( span , null ) ;
append _dev ( span , t1 ) ;
} ,
p : function update ( ctx , dirty ) {
if ( current _block _type === ( current _block _type = select _block _type ( ctx ) ) && if _block0 ) {
if _block0 . p ( ctx , dirty ) ;
} else {
if _block0 . d ( 1 ) ;
if _block0 = current _block _type ( ctx ) ;
if ( if _block0 ) {
if _block0 . c ( ) ;
if _block0 . m ( span , t0 ) ;
}
}
if ( ! /*disable*/ ctx [ 6 ] ) {
if ( if _block1 ) {
if _block1 . p ( ctx , dirty ) ;
} else {
2021-05-11 03:25:33 +07:00
if _block1 = create _if _block _2$1 ( ctx ) ;
2021-05-11 00:37:27 +07:00
if _block1 . c ( ) ;
if _block1 . m ( span , t1 ) ;
}
} else if ( if _block1 ) {
if _block1 . d ( 1 ) ;
if _block1 = null ;
}
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( span ) ;
if _block0 . d ( ) ;
if ( if _block1 ) if _block1 . d ( ) ;
}
2021-05-10 22:47:35 +07:00
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 00:37:27 +07:00
id : create _each _block _1 . name ,
type : "each" ,
source : "(310:8) {#each tags as tag, i}" ,
2021-05-10 22:47:35 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 00:37:27 +07:00
// (339:0) {#if autoComplete && arrelementsmatch.length > 0}
2021-05-11 03:25:33 +07:00
function create _if _block$2 ( ctx ) {
2021-05-11 00:37:27 +07:00
let div ;
let ul ;
let ul _id _value ;
let each _value = /*arrelementsmatch*/ ctx [ 7 ] ;
validate _each _argument ( each _value ) ;
let each _blocks = [ ] ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
2021-05-11 03:25:33 +07:00
each _blocks [ i ] = create _each _block$1 ( get _each _context$1 ( ctx , each _value , i ) ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
const block = {
c : function create ( ) {
div = element ( "div" ) ;
ul = element ( "ul" ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
attr _dev ( ul , "id" , ul _id _value = "" + ( /*id*/ ctx [ 5 ] + "_matchs" ) ) ;
attr _dev ( ul , "class" , "svelte-tags-input-matchs svelte-1xz5xok" ) ;
2021-05-11 03:25:33 +07:00
add _location ( ul , file$6 , 340 , 8 , 9758 ) ;
2021-05-11 00:37:27 +07:00
attr _dev ( div , "class" , "svelte-tags-input-matchs-parent svelte-1xz5xok" ) ;
2021-05-11 03:25:33 +07:00
add _location ( div , file$6 , 339 , 4 , 9703 ) ;
2021-05-11 00:37:27 +07:00
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , div , anchor ) ;
append _dev ( div , ul ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( ul , null ) ;
}
} ,
p : function update ( ctx , dirty ) {
if ( dirty [ 0 ] & /*navigateAutoComplete, arrelementsmatch, addTag*/ 66688 ) {
each _value = /*arrelementsmatch*/ ctx [ 7 ] ;
validate _each _argument ( each _value ) ;
let i ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
for ( i = 0 ; i < each _value . length ; i += 1 ) {
2021-05-11 03:25:33 +07:00
const child _ctx = get _each _context$1 ( ctx , each _value , i ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
} else {
2021-05-11 03:25:33 +07:00
each _blocks [ i ] = create _each _block$1 ( child _ctx ) ;
2021-05-11 00:37:27 +07:00
each _blocks [ i ] . c ( ) ;
each _blocks [ i ] . m ( ul , null ) ;
}
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
for ( ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . d ( 1 ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
each _blocks . length = each _value . length ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( dirty [ 0 ] & /*id*/ 32 && ul _id _value !== ( ul _id _value = "" + ( /*id*/ ctx [ 5 ] + "_matchs" ) ) ) {
attr _dev ( ul , "id" , ul _id _value ) ;
}
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( div ) ;
destroy _each ( each _blocks , detaching ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _if _block$2 . name ,
2021-05-11 00:37:27 +07:00
type : "if" ,
source : "(339:0) {#if autoComplete && arrelementsmatch.length > 0}" ,
ctx
} ) ;
return block ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
// (342:12) {#each arrelementsmatch as element, index}
2021-05-11 03:25:33 +07:00
function create _each _block$1 ( ctx ) {
2021-05-11 00:37:27 +07:00
let li ;
let html _tag ;
let raw _value = /*element*/ ctx [ 37 ] . search + "" ;
let t ;
let mounted ;
let dispose ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function keydown _handler ( ) {
return /*keydown_handler*/ ctx [ 30 ] ( /*index*/ ctx [ 39 ] , /*element*/ ctx [ 37 ] ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function click _handler _1 ( ) {
return /*click_handler_1*/ ctx [ 31 ] ( /*element*/ ctx [ 37 ] ) ;
}
2021-05-10 22:47:35 +07:00
const block = {
c : function create ( ) {
2021-05-11 00:37:27 +07:00
li = element ( "li" ) ;
t = space ( ) ;
html _tag = new HtmlTag ( t ) ;
attr _dev ( li , "tabindex" , "-1" ) ;
attr _dev ( li , "class" , "svelte-1xz5xok" ) ;
2021-05-11 03:25:33 +07:00
add _location ( li , file$6 , 342 , 16 , 9886 ) ;
2021-05-10 22:47:35 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 00:37:27 +07:00
insert _dev ( target , li , anchor ) ;
html _tag . m ( raw _value , li ) ;
append _dev ( li , t ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( ! mounted ) {
dispose = [
listen _dev ( li , "keydown" , keydown _handler , false , false , false ) ,
listen _dev ( li , "click" , click _handler _1 , false , false , false )
] ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
mounted = true ;
}
2021-05-10 22:47:35 +07:00
} ,
2021-05-11 00:37:27 +07:00
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
if ( dirty [ 0 ] & /*arrelementsmatch*/ 128 && raw _value !== ( raw _value = /*element*/ ctx [ 37 ] . search + "" ) ) html _tag . p ( raw _value ) ;
2021-05-10 22:47:35 +07:00
} ,
d : function destroy ( detaching ) {
2021-05-11 00:37:27 +07:00
if ( detaching ) detach _dev ( li ) ;
mounted = false ;
run _all ( dispose ) ;
2021-05-10 22:47:35 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _each _block$1 . name ,
2021-05-11 00:37:27 +07:00
type : "each" ,
source : "(342:12) {#each arrelementsmatch as element, index}" ,
2021-05-10 22:47:35 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 03:25:33 +07:00
function create _fragment$7 ( ctx ) {
2021-05-11 00:37:27 +07:00
let div ;
let t0 ;
let input ;
let t1 ;
let if _block1 _anchor ;
let mounted ;
let dispose ;
2021-05-11 03:25:33 +07:00
let if _block0 = /*tags*/ ctx [ 0 ] . length > 0 && create _if _block _1$2 ( ctx ) ;
let if _block1 = /*autoComplete*/ ctx [ 2 ] && /*arrelementsmatch*/ ctx [ 7 ] . length > 0 && create _if _block$2 ( ctx ) ;
2021-05-10 22:47:35 +07:00
const block = {
c : function create ( ) {
2021-05-11 00:37:27 +07:00
div = element ( "div" ) ;
if ( if _block0 ) if _block0 . c ( ) ;
t0 = space ( ) ;
input = element ( "input" ) ;
t1 = space ( ) ;
if ( if _block1 ) if _block1 . c ( ) ;
if _block1 _anchor = empty ( ) ;
attr _dev ( input , "type" , "text" ) ;
attr _dev ( input , "id" , /*id*/ ctx [ 5 ] ) ;
attr _dev ( input , "name" , /*name*/ ctx [ 4 ] ) ;
attr _dev ( input , "class" , "svelte-tags-input svelte-1xz5xok" ) ;
attr _dev ( input , "placeholder" , /*placeholder*/ ctx [ 1 ] ) ;
input . disabled = /*disable*/ ctx [ 6 ] ;
2021-05-11 03:25:33 +07:00
add _location ( input , file$6 , 322 , 4 , 9283 ) ;
2021-05-11 00:37:27 +07:00
attr _dev ( div , "class" , "svelte-tags-input-layout svelte-1xz5xok" ) ;
toggle _class ( div , "sti-layout-disable" , /*disable*/ ctx [ 6 ] ) ;
2021-05-11 03:25:33 +07:00
add _location ( div , file$6 , 307 , 0 , 8720 ) ;
2021-05-11 00:37:27 +07:00
} ,
l : function claim ( nodes ) {
throw new Error ( "options.hydrate only works if the component was compiled with the `hydratable: true` option" ) ;
2021-05-10 22:47:35 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 00:37:27 +07:00
insert _dev ( target , div , anchor ) ;
if ( if _block0 ) if _block0 . m ( div , null ) ;
append _dev ( div , t0 ) ;
append _dev ( div , input ) ;
set _input _value ( input , /*tag*/ ctx [ 8 ] ) ;
insert _dev ( target , t1 , anchor ) ;
if ( if _block1 ) if _block1 . m ( target , anchor ) ;
insert _dev ( target , if _block1 _anchor , anchor ) ;
if ( ! mounted ) {
dispose = [
listen _dev ( input , "input" , /*input_input_handler*/ ctx [ 28 ] ) ,
listen _dev ( input , "keydown" , /*setTag*/ ctx [ 9 ] , false , false , false ) ,
listen _dev ( input , "keyup" , /*getMatchElements*/ ctx [ 15 ] , false , false , false ) ,
listen _dev ( input , "paste" , /*onPaste*/ ctx [ 12 ] , false , false , false ) ,
listen _dev ( input , "drop" , /*onDrop*/ ctx [ 13 ] , false , false , false ) ,
listen _dev ( input , "blur" , /*blur_handler*/ ctx [ 29 ] , false , false , false )
] ;
mounted = true ;
}
} ,
p : function update ( ctx , dirty ) {
if ( /*tags*/ ctx [ 0 ] . length > 0 ) {
if ( if _block0 ) {
if _block0 . p ( ctx , dirty ) ;
} else {
2021-05-11 03:25:33 +07:00
if _block0 = create _if _block _1$2 ( ctx ) ;
2021-05-11 00:37:27 +07:00
if _block0 . c ( ) ;
if _block0 . m ( div , t0 ) ;
}
} else if ( if _block0 ) {
if _block0 . d ( 1 ) ;
if _block0 = null ;
}
if ( dirty [ 0 ] & /*id*/ 32 ) {
attr _dev ( input , "id" , /*id*/ ctx [ 5 ] ) ;
}
if ( dirty [ 0 ] & /*name*/ 16 ) {
attr _dev ( input , "name" , /*name*/ ctx [ 4 ] ) ;
}
if ( dirty [ 0 ] & /*placeholder*/ 2 ) {
attr _dev ( input , "placeholder" , /*placeholder*/ ctx [ 1 ] ) ;
}
if ( dirty [ 0 ] & /*disable*/ 64 ) {
prop _dev ( input , "disabled" , /*disable*/ ctx [ 6 ] ) ;
}
if ( dirty [ 0 ] & /*tag*/ 256 && input . value !== /*tag*/ ctx [ 8 ] ) {
set _input _value ( input , /*tag*/ ctx [ 8 ] ) ;
}
if ( dirty [ 0 ] & /*disable*/ 64 ) {
toggle _class ( div , "sti-layout-disable" , /*disable*/ ctx [ 6 ] ) ;
}
if ( /*autoComplete*/ ctx [ 2 ] && /*arrelementsmatch*/ ctx [ 7 ] . length > 0 ) {
if ( if _block1 ) {
if _block1 . p ( ctx , dirty ) ;
} else {
2021-05-11 03:25:33 +07:00
if _block1 = create _if _block$2 ( ctx ) ;
2021-05-11 00:37:27 +07:00
if _block1 . c ( ) ;
if _block1 . m ( if _block1 _anchor . parentNode , if _block1 _anchor ) ;
}
} else if ( if _block1 ) {
if _block1 . d ( 1 ) ;
if _block1 = null ;
}
2021-05-10 22:47:35 +07:00
} ,
2021-05-11 00:37:27 +07:00
i : noop ,
o : noop ,
2021-05-10 22:47:35 +07:00
d : function destroy ( detaching ) {
2021-05-11 00:37:27 +07:00
if ( detaching ) detach _dev ( div ) ;
if ( if _block0 ) if _block0 . d ( ) ;
if ( detaching ) detach _dev ( t1 ) ;
if ( if _block1 ) if _block1 . d ( detaching ) ;
if ( detaching ) detach _dev ( if _block1 _anchor ) ;
mounted = false ;
run _all ( dispose ) ;
2021-05-10 22:47:35 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _fragment$7 . name ,
2021-05-11 00:37:27 +07:00
type : "component" ,
source : "" ,
2021-05-10 22:47:35 +07:00
ctx
} ) ;
return block ;
}
2021-05-11 00:37:27 +07:00
function getClipboardData ( e ) {
if ( window . clipboardData ) {
return window . clipboardData . getData ( "Text" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( e . clipboardData ) {
return e . clipboardData . getData ( "text/plain" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
return "" ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function uniqueID ( ) {
return "sti_" + Math . random ( ) . toString ( 36 ) . substr ( 2 , 9 ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function instance$7 ( $$self , $$props , $$invalidate ) {
2021-05-11 00:37:27 +07:00
let matchsID ;
let { $$slots : slots = { } , $$scope } = $$props ;
validate _slots ( "Tags" , slots , [ ] ) ;
const dispatch = createEventDispatcher ( ) ;
let tag = "" ;
let arrelementsmatch = [ ] ;
let regExpEscape = s => {
return s . replace ( /[-\\^$*+?.()|[\]{}]/g , "\\$&" ) ;
} ;
let { tags } = $$props ;
let { addKeys } = $$props ;
let { maxTags } = $$props ;
let { onlyUnique } = $$props ;
let { removeKeys } = $$props ;
let { placeholder } = $$props ;
let { allowPaste } = $$props ;
let { allowDrop } = $$props ;
let { splitWith } = $$props ;
let { autoComplete } = $$props ;
let { autoCompleteKey } = $$props ;
let { name } = $$props ;
let { id } = $$props ;
let { allowBlur } = $$props ;
let { disable } = $$props ;
let { minChars } = $$props ;
let { onlyAutocomplete } = $$props ;
let storePlaceholder = placeholder ;
function setTag ( input ) {
const currentTag = input . target . value ;
if ( addKeys ) {
addKeys . forEach ( function ( key ) {
if ( key === input . keyCode ) {
if ( currentTag ) input . preventDefault ( ) ;
switch ( input . keyCode ) {
case 9 :
// TAB add first element on the autoComplete list
if ( autoComplete && document . getElementById ( matchsID ) ) {
addTag ( document . getElementById ( matchsID ) . querySelectorAll ( "li" ) [ 0 ] . textContent ) ;
} else {
addTag ( currentTag ) ;
}
break ;
default :
addTag ( currentTag ) ;
break ;
}
}
} ) ;
}
if ( removeKeys ) {
removeKeys . forEach ( function ( key ) {
if ( key === input . keyCode && tag === "" ) {
tags . pop ( ) ;
$$invalidate ( 0 , tags ) ;
dispatch ( "tags" , { tags } ) ;
$$invalidate ( 7 , arrelementsmatch = [ ] ) ;
document . getElementById ( id ) . readOnly = false ;
$$invalidate ( 1 , placeholder = storePlaceholder ) ;
document . getElementById ( id ) . focus ( ) ;
}
} ) ;
}
// ArrowDown : focus on first element of the autocomplete
if ( input . keyCode === 40 && autoComplete && document . getElementById ( matchsID ) ) {
event . preventDefault ( ) ;
document . getElementById ( matchsID ) . querySelector ( "li:first-child" ) . focus ( ) ;
} else if ( input . keyCode === 38 && autoComplete && document . getElementById ( matchsID ) ) {
event . preventDefault ( ) ; // ArrowUp : focus on last element of the autocomplete
document . getElementById ( matchsID ) . querySelector ( "li:last-child" ) . focus ( ) ;
}
}
function addTag ( currentTag ) {
if ( typeof currentTag === "object" && currentTag !== null ) {
if ( ! autoCompleteKey ) {
return console . error ( "'autoCompleteKey' is necessary if 'autoComplete' result is an array of objects" ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
var currentObjTags = currentTag ;
currentTag = currentTag [ autoCompleteKey ] . trim ( ) ;
} else {
currentTag = currentTag . trim ( ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
if ( currentTag == "" ) return ;
if ( maxTags && tags . length == maxTags ) return ;
if ( onlyUnique && tags . includes ( currentTag ) ) return ;
if ( onlyAutocomplete && arrelementsmatch . length === 0 ) return ;
tags . push ( currentObjTags ? currentObjTags : currentTag ) ;
$$invalidate ( 0 , tags ) ;
$$invalidate ( 8 , tag = "" ) ;
dispatch ( "tags" , { tags } ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Hide autocomplete list
// Focus on svelte tags input
$$invalidate ( 7 , arrelementsmatch = [ ] ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
document . getElementById ( id ) . focus ( ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( maxTags && tags . length == maxTags ) {
document . getElementById ( id ) . readOnly = true ;
$$invalidate ( 1 , placeholder = "" ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function removeTag ( i ) {
tags . splice ( i , 1 ) ;
$$invalidate ( 0 , tags ) ;
dispatch ( "tags" , { tags } ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
// Hide autocomplete list
// Focus on svelte tags input
$$invalidate ( 7 , arrelementsmatch = [ ] ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
document . getElementById ( id ) . readOnly = false ;
$$invalidate ( 1 , placeholder = storePlaceholder ) ;
document . getElementById ( id ) . focus ( ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function onPaste ( e ) {
if ( ! allowPaste ) return ;
e . preventDefault ( ) ;
const data = getClipboardData ( e ) ;
splitTags ( data ) . map ( tag => addTag ( tag ) ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function onDrop ( e ) {
if ( ! allowDrop ) return ;
e . preventDefault ( ) ;
const data = e . dataTransfer . getData ( "Text" ) ;
splitTags ( data ) . map ( tag => addTag ( tag ) ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function onBlur ( tag ) {
if ( ! document . getElementById ( matchsID ) && allowBlur ) {
event . preventDefault ( ) ;
addTag ( tag ) ;
}
}
function splitTags ( data ) {
return data . split ( splitWith ) . map ( tag => tag . trim ( ) ) ;
}
async function getMatchElements ( input ) {
if ( ! autoComplete ) return ;
let autoCompleteValues = [ ] ;
if ( Array . isArray ( autoComplete ) ) {
autoCompleteValues = autoComplete ;
}
if ( typeof autoComplete === "function" ) {
if ( autoComplete . constructor . name === "AsyncFunction" ) {
autoCompleteValues = await autoComplete ( ) ;
} else {
autoCompleteValues = autoComplete ( ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var value = input . target . value ;
// Escape
if ( value == "" || input . keyCode === 27 || value . length < minChars ) {
$$invalidate ( 7 , arrelementsmatch = [ ] ) ;
return ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
if ( typeof autoCompleteValues [ 0 ] === "object" && autoCompleteValues !== null ) {
if ( ! autoCompleteKey ) {
return console . error ( "'autoCompleteValue' is necessary if 'autoComplete' result is an array of objects" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
var matchs = autoCompleteValues . filter ( e => e [ autoCompleteKey ] . toLowerCase ( ) . includes ( value . toLowerCase ( ) ) ) . map ( matchTag => {
return {
label : matchTag ,
search : matchTag [ autoCompleteKey ] . replace ( RegExp ( regExpEscape ( value . toLowerCase ( ) ) , "i" ) , "<strong>$&</strong>" )
} ;
} ) ;
} else {
var matchs = autoCompleteValues . filter ( e => e . toLowerCase ( ) . includes ( value . toLowerCase ( ) ) ) . map ( matchTag => {
return {
label : matchTag ,
search : matchTag . replace ( RegExp ( regExpEscape ( value . toLowerCase ( ) ) , "i" ) , "<strong>$&</strong>" )
} ;
} ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( onlyUnique === true && ! autoCompleteKey ) {
matchs = matchs . filter ( tag => ! tags . includes ( tag . label ) ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
$$invalidate ( 7 , arrelementsmatch = matchs ) ;
}
function navigateAutoComplete ( autoCompleteIndex , autoCompleteLength , autoCompleteElement ) {
if ( ! autoComplete ) return ;
event . preventDefault ( ) ;
// ArrowDown
if ( event . keyCode === 40 ) {
// Last element on the list ? Go to the first
if ( autoCompleteIndex + 1 === autoCompleteLength ) {
document . getElementById ( matchsID ) . querySelector ( "li:first-child" ) . focus ( ) ;
return ;
}
document . getElementById ( matchsID ) . querySelectorAll ( "li" ) [ autoCompleteIndex + 1 ] . focus ( ) ;
} else if ( event . keyCode === 38 ) {
// ArrowUp
// First element on the list ? Go to the last
if ( autoCompleteIndex === 0 ) {
document . getElementById ( matchsID ) . querySelector ( "li:last-child" ) . focus ( ) ;
return ;
}
document . getElementById ( matchsID ) . querySelectorAll ( "li" ) [ autoCompleteIndex - 1 ] . focus ( ) ;
} else if ( event . keyCode === 13 ) {
// Enter
addTag ( autoCompleteElement ) ;
} else if ( event . keyCode === 27 ) {
// Escape
$$invalidate ( 7 , arrelementsmatch = [ ] ) ;
document . getElementById ( id ) . focus ( ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
const writable _props = [
"tags" ,
"addKeys" ,
"maxTags" ,
"onlyUnique" ,
"removeKeys" ,
"placeholder" ,
"allowPaste" ,
"allowDrop" ,
"splitWith" ,
"autoComplete" ,
"autoCompleteKey" ,
"name" ,
"id" ,
"allowBlur" ,
"disable" ,
"minChars" ,
"onlyAutocomplete"
] ;
Object . keys ( $$props ) . forEach ( key => {
2021-05-11 03:25:33 +07:00
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== "$$" ) console _1$1 . warn ( ` <Tags> was created with unknown prop ' ${ key } ' ` ) ;
2021-05-10 22:47:35 +07:00
} ) ;
2021-05-11 00:37:27 +07:00
const click _handler = i => removeTag ( i ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
function input _input _handler ( ) {
tag = this . value ;
$$invalidate ( 8 , tag ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
const blur _handler = ( ) => onBlur ( tag ) ;
const keydown _handler = ( index , element ) => navigateAutoComplete ( index , arrelementsmatch . length , element . label ) ;
const click _handler _1 = element => addTag ( element . label ) ;
$$self . $$set = $$props => {
if ( "tags" in $$props ) $$invalidate ( 0 , tags = $$props . tags ) ;
if ( "addKeys" in $$props ) $$invalidate ( 17 , addKeys = $$props . addKeys ) ;
if ( "maxTags" in $$props ) $$invalidate ( 18 , maxTags = $$props . maxTags ) ;
if ( "onlyUnique" in $$props ) $$invalidate ( 19 , onlyUnique = $$props . onlyUnique ) ;
if ( "removeKeys" in $$props ) $$invalidate ( 20 , removeKeys = $$props . removeKeys ) ;
if ( "placeholder" in $$props ) $$invalidate ( 1 , placeholder = $$props . placeholder ) ;
if ( "allowPaste" in $$props ) $$invalidate ( 21 , allowPaste = $$props . allowPaste ) ;
if ( "allowDrop" in $$props ) $$invalidate ( 22 , allowDrop = $$props . allowDrop ) ;
if ( "splitWith" in $$props ) $$invalidate ( 23 , splitWith = $$props . splitWith ) ;
if ( "autoComplete" in $$props ) $$invalidate ( 2 , autoComplete = $$props . autoComplete ) ;
if ( "autoCompleteKey" in $$props ) $$invalidate ( 3 , autoCompleteKey = $$props . autoCompleteKey ) ;
if ( "name" in $$props ) $$invalidate ( 4 , name = $$props . name ) ;
if ( "id" in $$props ) $$invalidate ( 5 , id = $$props . id ) ;
if ( "allowBlur" in $$props ) $$invalidate ( 24 , allowBlur = $$props . allowBlur ) ;
if ( "disable" in $$props ) $$invalidate ( 6 , disable = $$props . disable ) ;
if ( "minChars" in $$props ) $$invalidate ( 25 , minChars = $$props . minChars ) ;
if ( "onlyAutocomplete" in $$props ) $$invalidate ( 26 , onlyAutocomplete = $$props . onlyAutocomplete ) ;
} ;
$$self . $capture _state = ( ) => ( {
createEventDispatcher ,
dispatch ,
tag ,
arrelementsmatch ,
regExpEscape ,
tags ,
addKeys ,
maxTags ,
onlyUnique ,
removeKeys ,
placeholder ,
allowPaste ,
allowDrop ,
splitWith ,
autoComplete ,
autoCompleteKey ,
name ,
id ,
allowBlur ,
disable ,
minChars ,
onlyAutocomplete ,
storePlaceholder ,
setTag ,
addTag ,
removeTag ,
onPaste ,
onDrop ,
onBlur ,
getClipboardData ,
splitTags ,
getMatchElements ,
navigateAutoComplete ,
uniqueID ,
matchsID
} ) ;
$$self . $inject _state = $$props => {
if ( "tag" in $$props ) $$invalidate ( 8 , tag = $$props . tag ) ;
if ( "arrelementsmatch" in $$props ) $$invalidate ( 7 , arrelementsmatch = $$props . arrelementsmatch ) ;
if ( "regExpEscape" in $$props ) regExpEscape = $$props . regExpEscape ;
if ( "tags" in $$props ) $$invalidate ( 0 , tags = $$props . tags ) ;
if ( "addKeys" in $$props ) $$invalidate ( 17 , addKeys = $$props . addKeys ) ;
if ( "maxTags" in $$props ) $$invalidate ( 18 , maxTags = $$props . maxTags ) ;
if ( "onlyUnique" in $$props ) $$invalidate ( 19 , onlyUnique = $$props . onlyUnique ) ;
if ( "removeKeys" in $$props ) $$invalidate ( 20 , removeKeys = $$props . removeKeys ) ;
if ( "placeholder" in $$props ) $$invalidate ( 1 , placeholder = $$props . placeholder ) ;
if ( "allowPaste" in $$props ) $$invalidate ( 21 , allowPaste = $$props . allowPaste ) ;
if ( "allowDrop" in $$props ) $$invalidate ( 22 , allowDrop = $$props . allowDrop ) ;
if ( "splitWith" in $$props ) $$invalidate ( 23 , splitWith = $$props . splitWith ) ;
if ( "autoComplete" in $$props ) $$invalidate ( 2 , autoComplete = $$props . autoComplete ) ;
if ( "autoCompleteKey" in $$props ) $$invalidate ( 3 , autoCompleteKey = $$props . autoCompleteKey ) ;
if ( "name" in $$props ) $$invalidate ( 4 , name = $$props . name ) ;
if ( "id" in $$props ) $$invalidate ( 5 , id = $$props . id ) ;
if ( "allowBlur" in $$props ) $$invalidate ( 24 , allowBlur = $$props . allowBlur ) ;
if ( "disable" in $$props ) $$invalidate ( 6 , disable = $$props . disable ) ;
if ( "minChars" in $$props ) $$invalidate ( 25 , minChars = $$props . minChars ) ;
if ( "onlyAutocomplete" in $$props ) $$invalidate ( 26 , onlyAutocomplete = $$props . onlyAutocomplete ) ;
if ( "storePlaceholder" in $$props ) storePlaceholder = $$props . storePlaceholder ;
if ( "matchsID" in $$props ) matchsID = $$props . matchsID ;
} ;
if ( $$props && "$$inject" in $$props ) {
$$self . $inject _state ( $$props . $$inject ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
$$self . $$ . update = ( ) => {
if ( $$self . $$ . dirty [ 0 ] & /*tags*/ 1 ) {
$$invalidate ( 0 , tags = tags || [ ] ) ;
}
if ( $$self . $$ . dirty [ 0 ] & /*addKeys*/ 131072 ) {
$$invalidate ( 17 , addKeys = addKeys || [ 13 ] ) ;
}
if ( $$self . $$ . dirty [ 0 ] & /*maxTags*/ 262144 ) {
$$invalidate ( 18 , maxTags = maxTags || false ) ;
}
if ( $$self . $$ . dirty [ 0 ] & /*onlyUnique*/ 524288 ) {
$$invalidate ( 19 , onlyUnique = onlyUnique || false ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*removeKeys*/ 1048576 ) {
$$invalidate ( 20 , removeKeys = removeKeys || [ 8 ] ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*placeholder*/ 2 ) {
$$invalidate ( 1 , placeholder = placeholder || "" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*allowPaste*/ 2097152 ) {
$$invalidate ( 21 , allowPaste = allowPaste || false ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*allowDrop*/ 4194304 ) {
$$invalidate ( 22 , allowDrop = allowDrop || false ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*splitWith*/ 8388608 ) {
$$invalidate ( 23 , splitWith = splitWith || "," ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*autoComplete*/ 4 ) {
$$invalidate ( 2 , autoComplete = autoComplete || false ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*autoCompleteKey*/ 8 ) {
$$invalidate ( 3 , autoCompleteKey = autoCompleteKey || false ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*name*/ 16 ) {
$$invalidate ( 4 , name = name || "svelte-tags-input" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*id*/ 32 ) {
$$invalidate ( 5 , id = id || uniqueID ( ) ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*allowBlur*/ 16777216 ) {
$$invalidate ( 24 , allowBlur = allowBlur || false ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*disable*/ 64 ) {
$$invalidate ( 6 , disable = disable || false ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*minChars*/ 33554432 ) {
$$invalidate ( 25 , minChars = minChars || 1 ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*onlyAutocomplete*/ 67108864 ) {
$$invalidate ( 26 , onlyAutocomplete = onlyAutocomplete || false ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( $$self . $$ . dirty [ 0 ] & /*id*/ 32 ) {
matchsID = id + "_matchs" ;
2021-05-10 22:47:35 +07:00
}
} ;
2021-05-11 00:37:27 +07:00
return [
tags ,
placeholder ,
autoComplete ,
autoCompleteKey ,
name ,
id ,
disable ,
arrelementsmatch ,
tag ,
setTag ,
addTag ,
removeTag ,
onPaste ,
onDrop ,
onBlur ,
getMatchElements ,
navigateAutoComplete ,
addKeys ,
maxTags ,
onlyUnique ,
removeKeys ,
allowPaste ,
allowDrop ,
splitWith ,
allowBlur ,
minChars ,
onlyAutocomplete ,
click _handler ,
input _input _handler ,
blur _handler ,
keydown _handler ,
click _handler _1
] ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
class Tags extends SvelteComponentDev {
constructor ( options ) {
super ( options ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
init (
this ,
options ,
2021-05-11 03:25:33 +07:00
instance$7 ,
create _fragment$7 ,
2021-05-11 00:37:27 +07:00
safe _not _equal ,
{
tags : 0 ,
addKeys : 17 ,
maxTags : 18 ,
onlyUnique : 19 ,
removeKeys : 20 ,
placeholder : 1 ,
allowPaste : 21 ,
allowDrop : 22 ,
splitWith : 23 ,
autoComplete : 2 ,
autoCompleteKey : 3 ,
name : 4 ,
id : 5 ,
allowBlur : 24 ,
disable : 6 ,
minChars : 25 ,
onlyAutocomplete : 26
2021-05-10 22:47:35 +07:00
} ,
2021-05-11 00:37:27 +07:00
[ - 1 , - 1 ]
) ;
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Tags" ,
options ,
2021-05-11 03:25:33 +07:00
id : create _fragment$7 . name
2021-05-10 22:47:35 +07:00
} ) ;
2021-05-11 00:37:27 +07:00
const { ctx } = this . $$ ;
const props = options . props || { } ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*tags*/ ctx [ 0 ] === undefined && ! ( "tags" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'tags'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*addKeys*/ ctx [ 17 ] === undefined && ! ( "addKeys" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'addKeys'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*maxTags*/ ctx [ 18 ] === undefined && ! ( "maxTags" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'maxTags'" ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
if ( /*onlyUnique*/ ctx [ 19 ] === undefined && ! ( "onlyUnique" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'onlyUnique'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*removeKeys*/ ctx [ 20 ] === undefined && ! ( "removeKeys" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'removeKeys'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*placeholder*/ ctx [ 1 ] === undefined && ! ( "placeholder" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'placeholder'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*allowPaste*/ ctx [ 21 ] === undefined && ! ( "allowPaste" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'allowPaste'" ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
if ( /*allowDrop*/ ctx [ 22 ] === undefined && ! ( "allowDrop" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'allowDrop'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*splitWith*/ ctx [ 23 ] === undefined && ! ( "splitWith" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'splitWith'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*autoComplete*/ ctx [ 2 ] === undefined && ! ( "autoComplete" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'autoComplete'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*autoCompleteKey*/ ctx [ 3 ] === undefined && ! ( "autoCompleteKey" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'autoCompleteKey'" ) ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 00:37:27 +07:00
if ( /*name*/ ctx [ 4 ] === undefined && ! ( "name" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'name'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*id*/ ctx [ 5 ] === undefined && ! ( "id" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'id'" ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( /*allowBlur*/ ctx [ 24 ] === undefined && ! ( "allowBlur" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'allowBlur'" ) ;
2021-05-11 00:37:27 +07:00
}
if ( /*disable*/ ctx [ 6 ] === undefined && ! ( "disable" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'disable'" ) ;
2021-05-11 00:37:27 +07:00
}
if ( /*minChars*/ ctx [ 25 ] === undefined && ! ( "minChars" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'minChars'" ) ;
2021-05-11 00:37:27 +07:00
}
if ( /*onlyAutocomplete*/ ctx [ 26 ] === undefined && ! ( "onlyAutocomplete" in props ) ) {
2021-05-11 03:25:33 +07:00
console _1$1 . warn ( "<Tags> was created without expected prop 'onlyAutocomplete'" ) ;
2021-05-11 00:37:27 +07:00
}
}
get tags ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set tags ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get addKeys ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set addKeys ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
get maxTags ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
set maxTags ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
get onlyUnique ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
set onlyUnique ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
get removeKeys ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
set removeKeys ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
get placeholder ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
set placeholder ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
get allowPaste ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
set allowPaste ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
get allowDrop ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
set allowDrop ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
get splitWith ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
set splitWith ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
get autoComplete ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set autoComplete ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get autoCompleteKey ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set autoCompleteKey ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get name ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set name ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get id ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set id ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get allowBlur ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set allowBlur ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get disable ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set disable ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get minChars ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set minChars ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
get onlyAutocomplete ( ) {
throw new Error ( "<Tags>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set onlyAutocomplete ( value ) {
throw new Error ( "<Tags>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
}
/* src/routes/Posts.svelte generated by Svelte v3.38.2 */
const { console : console _1 } = globals ;
const file$5 = "src/routes/Posts.svelte" ;
function create _fragment$6 ( ctx ) {
let section0 ;
let div0 ;
let p ;
let t1 ;
let section1 ;
let div7 ;
let div5 ;
let form ;
let div4 ;
let div2 ;
let div1 ;
let tags ;
let t2 ;
let div3 ;
let button ;
let t4 ;
let div6 ;
let postpaginator ;
let current ;
let mounted ;
let dispose ;
tags = new Tags ( {
props : {
tags : /*searchTerms*/ ctx [ 0 ] ,
addKeys : [ 9 , 32 ]
} ,
$$inline : true
} ) ;
tags . $on ( "tags" , /*onTagChange*/ ctx [ 4 ] ) ;
postpaginator = new PostPaginator ( {
props : {
url : "/posts?tags=" + /*searchTerms*/ ctx [ 0 ] . join ( "+" ) + "&" ,
posts : /*posts*/ ctx [ 3 ] ,
page : /*page*/ ctx [ 1 ] ,
totalPages : /*totalPages*/ ctx [ 2 ] ,
handlePage : /*handlePage*/ ctx [ 5 ]
} ,
$$inline : true
} ) ;
const block = {
c : function create ( ) {
section0 = element ( "section" ) ;
div0 = element ( "div" ) ;
p = element ( "p" ) ;
p . textContent = "Posts" ;
t1 = space ( ) ;
section1 = element ( "section" ) ;
div7 = element ( "div" ) ;
div5 = element ( "div" ) ;
form = element ( "form" ) ;
div4 = element ( "div" ) ;
div2 = element ( "div" ) ;
div1 = element ( "div" ) ;
create _component ( tags . $$ . fragment ) ;
t2 = space ( ) ;
div3 = element ( "div" ) ;
button = element ( "button" ) ;
button . textContent = "Search" ;
t4 = space ( ) ;
div6 = element ( "div" ) ;
create _component ( postpaginator . $$ . fragment ) ;
attr _dev ( p , "class" , "title" ) ;
add _location ( p , file$5 , 61 , 8 , 1514 ) ;
attr _dev ( div0 , "class" , "hero-body" ) ;
add _location ( div0 , file$5 , 60 , 4 , 1482 ) ;
attr _dev ( section0 , "class" , "hero is-primary" ) ;
add _location ( section0 , file$5 , 59 , 0 , 1444 ) ;
attr _dev ( div1 , "class" , "control" ) ;
attr _dev ( div1 , "id" , "tags" ) ;
add _location ( div1 , file$5 , 71 , 24 , 1826 ) ;
attr _dev ( div2 , "class" , "control is-expanded" ) ;
add _location ( div2 , file$5 , 70 , 20 , 1768 ) ;
attr _dev ( button , "type" , "submit" ) ;
attr _dev ( button , "class" , "button is-primary" ) ;
add _location ( button , file$5 , 80 , 24 , 2201 ) ;
attr _dev ( div3 , "class" , "control" ) ;
add _location ( div3 , file$5 , 79 , 20 , 2155 ) ;
attr _dev ( div4 , "class" , "field has-addons" ) ;
add _location ( div4 , file$5 , 69 , 16 , 1717 ) ;
add _location ( form , file$5 , 68 , 12 , 1658 ) ;
attr _dev ( div5 , "class" , "block" ) ;
add _location ( div5 , file$5 , 67 , 8 , 1626 ) ;
attr _dev ( div6 , "class" , "block" ) ;
add _location ( div6 , file$5 , 87 , 8 , 2412 ) ;
attr _dev ( div7 , "class" , "container" ) ;
add _location ( div7 , file$5 , 66 , 4 , 1594 ) ;
attr _dev ( section1 , "class" , "section" ) ;
add _location ( section1 , file$5 , 65 , 0 , 1564 ) ;
} ,
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 , div7 ) ;
append _dev ( div7 , div5 ) ;
append _dev ( div5 , form ) ;
append _dev ( form , div4 ) ;
append _dev ( div4 , div2 ) ;
append _dev ( div2 , div1 ) ;
mount _component ( tags , div1 , null ) ;
append _dev ( div4 , t2 ) ;
append _dev ( div4 , div3 ) ;
append _dev ( div3 , button ) ;
append _dev ( div7 , t4 ) ;
append _dev ( div7 , div6 ) ;
mount _component ( postpaginator , div6 , null ) ;
current = true ;
if ( ! mounted ) {
dispose = listen _dev ( form , "submit" , prevent _default ( /*onSearch*/ ctx [ 6 ] ) , false , true , false ) ;
mounted = true ;
}
} ,
p : function update ( ctx , [ dirty ] ) {
const tags _changes = { } ;
if ( dirty & /*searchTerms*/ 1 ) tags _changes . tags = /*searchTerms*/ ctx [ 0 ] ;
tags . $set ( tags _changes ) ;
const postpaginator _changes = { } ;
if ( dirty & /*searchTerms*/ 1 ) postpaginator _changes . url = "/posts?tags=" + /*searchTerms*/ ctx [ 0 ] . join ( "+" ) + "&" ;
if ( dirty & /*posts*/ 8 ) postpaginator _changes . posts = /*posts*/ ctx [ 3 ] ;
if ( dirty & /*page*/ 2 ) postpaginator _changes . page = /*page*/ ctx [ 1 ] ;
if ( dirty & /*totalPages*/ 4 ) postpaginator _changes . totalPages = /*totalPages*/ ctx [ 2 ] ;
postpaginator . $set ( postpaginator _changes ) ;
} ,
i : function intro ( local ) {
if ( current ) return ;
transition _in ( tags . $$ . fragment , local ) ;
transition _in ( postpaginator . $$ . fragment , local ) ;
current = true ;
} ,
o : function outro ( local ) {
transition _out ( tags . $$ . fragment , local ) ;
transition _out ( postpaginator . $$ . fragment , local ) ;
current = false ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( section0 ) ;
if ( detaching ) detach _dev ( t1 ) ;
if ( detaching ) detach _dev ( section1 ) ;
destroy _component ( tags ) ;
destroy _component ( postpaginator ) ;
mounted = false ;
dispose ( ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _fragment$6 . name ,
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
function instance$6 ( $$self , $$props , $$invalidate ) {
let { $$slots : slots = { } , $$scope } = $$props ;
validate _slots ( "Posts" , slots , [ ] ) ;
let { location } = $$props ;
let searchTerms = [ ] ;
let page = 1 ;
let totalPages = 1 ;
let posts = [ ] ;
const getData = async ( ) => {
const data = await getPostSearchTag ( { page , q : searchTerms . join ( "+" ) } ) ;
if ( Array . isArray ( data . posts ) ) {
$$invalidate ( 3 , posts = data . posts ) ;
$$invalidate ( 2 , totalPages = data . totalPage ) ;
}
} ;
let queryParams ;
const onTagChange = value => {
$$invalidate ( 0 , searchTerms = value . detail . tags ) ;
} ;
const handlePage = i => {
return ( ) => {
$$invalidate ( 1 , page = i ) ;
getData ( ) ;
} ;
} ;
const onSearch = i => {
if ( searchTerms . length > 0 ) {
navigate ( ` /posts?tags= ${ searchTerms . join ( "+" ) } ` ) ;
} else {
navigate ( ` /posts ` ) ;
}
} ;
const writable _props = [ "location" ] ;
Object . keys ( $$props ) . forEach ( key => {
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== "$$" ) console _1 . warn ( ` <Posts> was created with unknown prop ' ${ key } ' ` ) ;
} ) ;
$$self . $$set = $$props => {
if ( "location" in $$props ) $$invalidate ( 7 , location = $$props . location ) ;
} ;
$$self . $capture _state = ( ) => ( {
onMount ,
getPostSearchTag ,
navigate ,
PostPaginator ,
queryString ,
Tags ,
location ,
searchTerms ,
page ,
totalPages ,
posts ,
getData ,
queryParams ,
onTagChange ,
handlePage ,
onSearch
} ) ;
$$self . $inject _state = $$props => {
if ( "location" in $$props ) $$invalidate ( 7 , location = $$props . location ) ;
if ( "searchTerms" in $$props ) $$invalidate ( 0 , searchTerms = $$props . searchTerms ) ;
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 ( "queryParams" in $$props ) $$invalidate ( 8 , queryParams = $$props . queryParams ) ;
} ;
if ( $$props && "$$inject" in $$props ) {
$$self . $inject _state ( $$props . $$inject ) ;
}
$$self . $$ . update = ( ) => {
if ( $$self . $$ . dirty & /*location, queryParams*/ 384 ) {
{
$$invalidate ( 8 , queryParams = queryString . parse ( location . search ) ) ;
console . log ( queryParams ) ;
if ( queryParams . page ) {
$$invalidate ( 1 , page = parseInt ( queryParams . page ) ) ;
}
if ( queryParams . tags ) {
$$invalidate ( 0 , searchTerms = queryParams . tags . split ( " " ) ) ;
} else {
$$invalidate ( 0 , searchTerms = [ ] ) ;
}
getData ( ) ;
}
}
} ;
return [
searchTerms ,
page ,
totalPages ,
posts ,
onTagChange ,
handlePage ,
onSearch ,
location ,
queryParams
] ;
}
class Posts extends SvelteComponentDev {
constructor ( options ) {
super ( options ) ;
init ( this , options , instance$6 , create _fragment$6 , safe _not _equal , { location : 7 } ) ;
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Posts" ,
options ,
id : create _fragment$6 . name
} ) ;
const { ctx } = this . $$ ;
const props = options . props || { } ;
if ( /*location*/ ctx [ 7 ] === undefined && ! ( "location" in props ) ) {
console _1 . 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$4 = "src/routes/Post.svelte" ;
function get _each _context ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 4 ] = list [ i ] ;
return child _ctx ;
}
// (27:8) {#if post}
function create _if _block _2 ( ctx ) {
let p ;
let t0 ;
let t1 _value = /*post*/ ctx [ 0 ] . id + "" ;
let t1 ;
const block = {
c : function create ( ) {
p = element ( "p" ) ;
t0 = text ( "Post ID: " ) ;
t1 = text ( t1 _value ) ;
attr _dev ( p , "class" , "title" ) ;
add _location ( p , file$4 , 27 , 12 , 628 ) ;
} ,
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 _2 . name ,
type : "if" ,
source : "(27:8) {#if post}" ,
ctx
} ) ;
return block ;
}
// (34:0) {#if post}
function create _if _block$1 ( ctx ) {
let div4 ;
let section ;
let div3 ;
let div1 ;
let div0 ;
let p0 ;
let link ;
let t0 ;
let p1 ;
let t1 ;
let a ;
let t2 _value = /*trimUrl*/ ctx [ 1 ] ( /*post*/ ctx [ 0 ] . source _url ) + "" ;
let t2 ;
let a _href _value ;
let t3 ;
let p2 ;
let t4 ;
let br ;
let t5 ;
let p3 ;
let current _block _type _index ;
let if _block ;
let t6 ;
let div2 ;
let figure ;
let img ;
let img _alt _value ;
let img _src _value ;
let current ;
link = new Link ( {
props : {
class : "button is-primary" ,
to : "/post/edit/" + /*post*/ ctx [ 0 ] . id ,
$$slots : { default : [ create _default _slot$2 ] } ,
$$scope : { ctx }
} ,
$$inline : true
} ) ;
const if _block _creators = [ create _if _block _1$1 , create _else _block ] ;
const if _blocks = [ ] ;
function select _block _type ( ctx , dirty ) {
if ( /*post*/ ctx [ 0 ] . tags ) 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 ( ) {
div4 = element ( "div" ) ;
section = element ( "section" ) ;
div3 = element ( "div" ) ;
div1 = element ( "div" ) ;
div0 = element ( "div" ) ;
p0 = element ( "p" ) ;
create _component ( link . $$ . fragment ) ;
t0 = space ( ) ;
p1 = element ( "p" ) ;
t1 = text ( "Source URL: " ) ;
a = element ( "a" ) ;
t2 = text ( t2 _value ) ;
t3 = space ( ) ;
p2 = element ( "p" ) ;
t4 = text ( "Tags:" ) ;
br = element ( "br" ) ;
t5 = space ( ) ;
p3 = element ( "p" ) ;
if _block . c ( ) ;
t6 = space ( ) ;
div2 = element ( "div" ) ;
figure = element ( "figure" ) ;
img = element ( "img" ) ;
add _location ( p0 , file$4 , 39 , 24 , 961 ) ;
attr _dev ( a , "href" , a _href _value = /*post*/ ctx [ 0 ] . source _url ) ;
add _location ( a , file$4 , 46 , 40 , 1253 ) ;
add _location ( p1 , file$4 , 45 , 24 , 1209 ) ;
add _location ( br , file$4 , 51 , 33 , 1462 ) ;
add _location ( p2 , file$4 , 50 , 24 , 1425 ) ;
add _location ( p3 , file$4 , 53 , 24 , 1522 ) ;
attr _dev ( div0 , "class" , "content" ) ;
add _location ( div0 , file$4 , 38 , 20 , 915 ) ;
attr _dev ( div1 , "class" , "column is-one-third box" ) ;
add _location ( div1 , file$4 , 37 , 16 , 857 ) ;
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$4 , 66 , 24 , 2017 ) ;
attr _dev ( figure , "class" , "image" ) ;
add _location ( figure , file$4 , 65 , 20 , 1970 ) ;
attr _dev ( div2 , "class" , "column" ) ;
add _location ( div2 , file$4 , 64 , 16 , 1929 ) ;
attr _dev ( div3 , "class" , "columns" ) ;
add _location ( div3 , file$4 , 36 , 12 , 819 ) ;
attr _dev ( section , "class" , "section" ) ;
add _location ( section , file$4 , 35 , 8 , 781 ) ;
attr _dev ( div4 , "class" , "container" ) ;
add _location ( div4 , file$4 , 34 , 4 , 749 ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , div4 , anchor ) ;
append _dev ( div4 , section ) ;
append _dev ( section , div3 ) ;
append _dev ( div3 , div1 ) ;
append _dev ( div1 , div0 ) ;
append _dev ( div0 , p0 ) ;
mount _component ( link , p0 , null ) ;
append _dev ( div0 , t0 ) ;
append _dev ( div0 , p1 ) ;
append _dev ( p1 , t1 ) ;
append _dev ( p1 , a ) ;
append _dev ( a , t2 ) ;
append _dev ( div0 , t3 ) ;
append _dev ( div0 , p2 ) ;
append _dev ( p2 , t4 ) ;
append _dev ( p2 , br ) ;
append _dev ( div0 , t5 ) ;
append _dev ( div0 , p3 ) ;
if _blocks [ current _block _type _index ] . m ( p3 , null ) ;
append _dev ( div3 , t6 ) ;
append _dev ( div3 , div2 ) ;
append _dev ( div2 , figure ) ;
append _dev ( figure , img ) ;
current = true ;
} ,
p : function update ( ctx , dirty ) {
const link _changes = { } ;
if ( dirty & /*post*/ 1 ) link _changes . to = "/post/edit/" + /*post*/ ctx [ 0 ] . id ;
if ( dirty & /*$$scope*/ 128 ) {
link _changes . $$scope = { dirty , ctx } ;
}
link . $set ( link _changes ) ;
if ( ( ! current || dirty & /*post*/ 1 ) && t2 _value !== ( t2 _value = /*trimUrl*/ ctx [ 1 ] ( /*post*/ ctx [ 0 ] . source _url ) + "" ) ) set _data _dev ( t2 , t2 _value ) ;
if ( ! current || dirty & /*post*/ 1 && a _href _value !== ( a _href _value = /*post*/ ctx [ 0 ] . source _url ) ) {
attr _dev ( a , "href" , a _href _value ) ;
}
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 ( p3 , null ) ;
}
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 ;
transition _in ( link . $$ . fragment , local ) ;
transition _in ( if _block ) ;
current = true ;
} ,
o : function outro ( local ) {
transition _out ( link . $$ . fragment , local ) ;
transition _out ( if _block ) ;
current = false ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( div4 ) ;
destroy _component ( link ) ;
if _blocks [ current _block _type _index ] . d ( ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block$1 . name ,
type : "if" ,
source : "(34:0) {#if post}" ,
ctx
} ) ;
return block ;
}
// (41:28) <Link class="button is-primary" to="/post/edit/{post.id}">
function create _default _slot$2 ( ctx ) {
let t ;
const block = {
c : function create ( ) {
t = text ( "Edit" ) ;
} ,
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$2 . name ,
type : "slot" ,
source : "(41:28) <Link class=\\\"button is-primary\\\" to=\\\"/post/edit/{post.id}\\\">" ,
ctx
} ) ;
return block ;
}
// (59:28) {:else}
function create _else _block ( ctx ) {
let t ;
const block = {
c : function create ( ) {
t = text ( "None" ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , t , anchor ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( t ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _else _block . name ,
type : "else" ,
source : "(59:28) {:else}" ,
ctx
} ) ;
return block ;
}
// (55:28) {#if post.tags}
function create _if _block _1$1 ( ctx ) {
let each _blocks = [ ] ;
let each _1 _lookup = new Map ( ) ;
let each _1 _anchor ;
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 , 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 ) ;
each _1 _lookup . set ( key , each _blocks [ i ] = create _each _block ( key , child _ctx ) ) ;
}
const block = {
c : function create ( ) {
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
each _1 _anchor = empty ( ) ;
} ,
m : function mount ( target , anchor ) {
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( target , anchor ) ;
}
insert _dev ( target , each _1 _anchor , anchor ) ;
current = true ;
} ,
p : function update ( ctx , dirty ) {
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 , get _key ) ;
each _blocks = update _keyed _each ( each _blocks , dirty , get _key , 1 , ctx , each _value , each _1 _lookup , each _1 _anchor . parentNode , outro _and _destroy _block , create _each _block , each _1 _anchor , get _each _context ) ;
check _outros ( ) ;
}
} ,
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 ) {
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . d ( detaching ) ;
}
if ( detaching ) detach _dev ( each _1 _anchor ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block _1$1 . name ,
type : "if" ,
source : "(55:28) {#if post.tags}" ,
ctx
} ) ;
return block ;
}
// (56:32) {#each post.tags as tag (tag)}
function create _each _block ( key _1 , ctx ) {
let first ;
let taglink ;
let current ;
taglink = new TagLink ( {
props : { tag : /*tag*/ ctx [ 4 ] } ,
$$inline : true
} ) ;
const block = {
key : key _1 ,
first : null ,
c : function create ( ) {
first = empty ( ) ;
create _component ( taglink . $$ . fragment ) ;
this . first = first ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , first , anchor ) ;
mount _component ( taglink , target , anchor ) ;
current = true ;
} ,
p : function update ( new _ctx , dirty ) {
ctx = new _ctx ;
const taglink _changes = { } ;
if ( dirty & /*post*/ 1 ) taglink _changes . tag = /*tag*/ ctx [ 4 ] ;
taglink . $set ( taglink _changes ) ;
} ,
i : function intro ( local ) {
if ( current ) return ;
transition _in ( taglink . $$ . fragment , local ) ;
current = true ;
} ,
o : function outro ( local ) {
transition _out ( taglink . $$ . fragment , local ) ;
current = false ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( first ) ;
destroy _component ( taglink , detaching ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _each _block . name ,
type : "each" ,
source : "(56:32) {#each post.tags as tag (tag)}" ,
ctx
} ) ;
return block ;
}
function create _fragment$5 ( ctx ) {
let section ;
let div ;
let t ;
let if _block1 _anchor ;
let current ;
let if _block0 = /*post*/ ctx [ 0 ] && create _if _block _2 ( 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$4 , 25 , 4 , 573 ) ;
attr _dev ( section , "class" , "hero is-primary" ) ;
add _location ( section , file$4 , 24 , 0 , 535 ) ;
} ,
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 _2 ( ctx ) ;
if _block0 . c ( ) ;
if _block0 . m ( div , null ) ;
}
} else if ( if _block0 ) {
if _block0 . d ( 1 ) ;
if _block0 = null ;
}
if ( /*post*/ ctx [ 0 ] ) {
if ( if _block1 ) {
if _block1 . p ( ctx , dirty ) ;
if ( dirty & /*post*/ 1 ) {
transition _in ( if _block1 , 1 ) ;
}
} else {
if _block1 = create _if _block$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$5 . name ,
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
function instance$5 ( $$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 ,
TagLink ,
getPost ,
postCreate ,
Link ,
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$5 , create _fragment$5 , safe _not _equal , { id : 2 } ) ;
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Post" ,
options ,
id : create _fragment$5 . 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$3 = "src/routes/Login.svelte" ;
function create _fragment$4 ( 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$3 , 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$3 , 18 , 16 , 494 ) ;
attr _dev ( div0 , "class" , "control" ) ;
add _location ( div0 , file$3 , 17 , 12 , 456 ) ;
attr _dev ( div1 , "class" , "field" ) ;
add _location ( div1 , file$3 , 15 , 8 , 359 ) ;
attr _dev ( label1 , "for" , "password" ) ;
attr _dev ( label1 , "class" , "label" ) ;
add _location ( label1 , file$3 , 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$3 , 31 , 16 , 911 ) ;
attr _dev ( div2 , "class" , "control" ) ;
add _location ( div2 , file$3 , 30 , 12 , 873 ) ;
attr _dev ( div3 , "class" , "field" ) ;
add _location ( div3 , file$3 , 28 , 8 , 776 ) ;
attr _dev ( button , "class" , "button is-link" ) ;
add _location ( button , file$3 , 43 , 16 , 1267 ) ;
attr _dev ( div4 , "class" , "control" ) ;
add _location ( div4 , file$3 , 42 , 12 , 1229 ) ;
attr _dev ( div5 , "class" , "field" ) ;
add _location ( div5 , file$3 , 41 , 8 , 1197 ) ;
add _location ( form , file$3 , 14 , 4 , 309 ) ;
attr _dev ( div6 , "class" , "container" ) ;
add _location ( div6 , file$3 , 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$4 . name ,
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
function instance$4 ( $$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$4 , create _fragment$4 , safe _not _equal , { } ) ;
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Login" ,
options ,
id : create _fragment$4 . name
} ) ;
}
}
/* src/routes/Logout.svelte generated by Svelte v3.38.2 */
function create _fragment$3 ( 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$3 . name ,
type : "component" ,
source : "" ,
ctx
} ) ;
return block ;
}
function instance$3 ( $$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$3 , create _fragment$3 , safe _not _equal , { } ) ;
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Logout" ,
options ,
id : create _fragment$3 . name
} ) ;
}
}
/* src/routes/Upload.svelte generated by Svelte v3.38.2 */
const file$2 = "src/routes/Upload.svelte" ;
// (69:16) {#if currentProgress > 0 && currentProgress < 100}
function create _if _block _1 ( ctx ) {
let p ;
let t0 ;
let t1 ;
const block = {
c : function create ( ) {
p = element ( "p" ) ;
t0 = text ( /*currentProgress*/ ctx [ 0 ] ) ;
t1 = text ( "%" ) ;
attr _dev ( p , "class" , "help" ) ;
add _location ( p , file$2 , 69 , 20 , 2116 ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , p , anchor ) ;
append _dev ( p , t0 ) ;
append _dev ( p , t1 ) ;
} ,
p : function update ( ctx , dirty ) {
if ( dirty & /*currentProgress*/ 1 ) set _data _dev ( t0 , /*currentProgress*/ ctx [ 0 ] ) ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( p ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block _1 . name ,
type : "if" ,
source : "(69:16) {#if currentProgress > 0 && currentProgress < 100}" ,
ctx
} ) ;
return block ;
}
// (72:16) {#if fileName !== ""}
function create _if _block ( ctx ) {
let p ;
let t0 ;
let t1 ;
const block = {
c : function create ( ) {
p = element ( "p" ) ;
t0 = text ( /*fileName*/ ctx [ 1 ] ) ;
t1 = text ( " uploaded" ) ;
attr _dev ( p , "class" , "help" ) ;
add _location ( p , file$2 , 72 , 20 , 2235 ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , p , anchor ) ;
append _dev ( p , t0 ) ;
append _dev ( p , t1 ) ;
} ,
p : function update ( ctx , dirty ) {
if ( dirty & /*fileName*/ 2 ) set _data _dev ( t0 , /*fileName*/ ctx [ 1 ] ) ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( p ) ;
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _if _block . name ,
type : "if" ,
source : "(72:16) {#if fileName !== \\\"\\\"}" ,
ctx
} ) ;
return block ;
}
function create _fragment$2 ( ctx ) {
let section0 ;
let div0 ;
let p ;
let t1 ;
let section1 ;
let div9 ;
let form _1 ;
let div3 ;
let label0 ;
let t3 ;
let div2 ;
let div1 ;
let label1 ;
let input0 ;
let t4 ;
let span2 ;
let span0 ;
let t5 ;
let span1 ;
let t7 ;
let t8 ;
let t9 ;
let div5 ;
let label2 ;
let t11 ;
let div4 ;
let input1 ;
let t12 ;
let div7 ;
let label3 ;
let t14 ;
let div6 ;
let tags ;
let t15 ;
let div8 ;
let button ;
let current ;
let mounted ;
let dispose ;
let if _block0 = /*currentProgress*/ ctx [ 0 ] > 0 && /*currentProgress*/ ctx [ 0 ] < 100 && create _if _block _1 ( ctx ) ;
let if _block1 = /*fileName*/ ctx [ 1 ] !== "" && create _if _block ( ctx ) ;
tags = new Tags ( {
props : { addKeys : [ 9 , 32 ] } ,
$$inline : true
} ) ;
tags . $on ( "tags" , /*onTagChange*/ ctx [ 4 ] ) ;
const block = {
c : function create ( ) {
section0 = element ( "section" ) ;
div0 = element ( "div" ) ;
p = element ( "p" ) ;
p . textContent = "Upload" ;
t1 = space ( ) ;
section1 = element ( "section" ) ;
div9 = element ( "div" ) ;
form _1 = element ( "form" ) ;
div3 = element ( "div" ) ;
label0 = element ( "label" ) ;
label0 . textContent = "Image File" ;
t3 = space ( ) ;
div2 = element ( "div" ) ;
div1 = element ( "div" ) ;
label1 = element ( "label" ) ;
input0 = element ( "input" ) ;
t4 = space ( ) ;
span2 = element ( "span" ) ;
span0 = element ( "span" ) ;
t5 = space ( ) ;
span1 = element ( "span" ) ;
span1 . textContent = "Choose a file…" ;
t7 = space ( ) ;
if ( if _block0 ) if _block0 . c ( ) ;
t8 = space ( ) ;
if ( if _block1 ) if _block1 . c ( ) ;
t9 = space ( ) ;
div5 = element ( "div" ) ;
label2 = element ( "label" ) ;
label2 . textContent = "Source URL" ;
t11 = space ( ) ;
div4 = element ( "div" ) ;
input1 = element ( "input" ) ;
t12 = space ( ) ;
div7 = element ( "div" ) ;
label3 = element ( "label" ) ;
label3 . textContent = "Tags" ;
t14 = space ( ) ;
div6 = element ( "div" ) ;
create _component ( tags . $$ . fragment ) ;
t15 = space ( ) ;
div8 = element ( "div" ) ;
button = element ( "button" ) ;
button . textContent = "Submit" ;
attr _dev ( p , "class" , "title" ) ;
add _location ( p , file$2 , 42 , 8 , 1029 ) ;
attr _dev ( div0 , "class" , "hero-body" ) ;
add _location ( div0 , file$2 , 41 , 4 , 997 ) ;
attr _dev ( section0 , "class" , "hero is-primary" ) ;
add _location ( section0 , file$2 , 40 , 0 , 959 ) ;
attr _dev ( label0 , "for" , "file" ) ;
attr _dev ( label0 , "class" , "label" ) ;
add _location ( label0 , file$2 , 50 , 16 , 1233 ) ;
attr _dev ( input0 , "id" , "file" ) ;
attr _dev ( input0 , "class" , "file-input" ) ;
attr _dev ( input0 , "type" , "file" ) ;
attr _dev ( input0 , "name" , "resume" ) ;
add _location ( input0 , file$2 , 54 , 28 , 1440 ) ;
attr _dev ( span0 , "class" , "file-icon" ) ;
add _location ( span0 , file$2 , 62 , 32 , 1802 ) ;
attr _dev ( span1 , "class" , "file-label" ) ;
add _location ( span1 , file$2 , 63 , 32 , 1861 ) ;
attr _dev ( span2 , "class" , "file-cta" ) ;
add _location ( span2 , file$2 , 61 , 28 , 1746 ) ;
attr _dev ( label1 , "class" , "file-label" ) ;
add _location ( label1 , file$2 , 53 , 24 , 1385 ) ;
attr _dev ( div1 , "class" , "file" ) ;
add _location ( div1 , file$2 , 52 , 20 , 1342 ) ;
attr _dev ( div2 , "class" , "control" ) ;
add _location ( div2 , file$2 , 51 , 16 , 1300 ) ;
attr _dev ( div3 , "class" , "field" ) ;
add _location ( div3 , file$2 , 49 , 12 , 1197 ) ;
attr _dev ( label2 , "for" , "source" ) ;
attr _dev ( label2 , "class" , "label" ) ;
add _location ( label2 , file$2 , 76 , 16 , 2364 ) ;
attr _dev ( input1 , "id" , "source" ) ;
attr _dev ( input1 , "class" , "input" ) ;
attr _dev ( input1 , "type" , "url" ) ;
attr _dev ( input1 , "placeholder" , "Source URL" ) ;
add _location ( input1 , file$2 , 78 , 20 , 2475 ) ;
attr _dev ( div4 , "class" , "control" ) ;
add _location ( div4 , file$2 , 77 , 16 , 2433 ) ;
attr _dev ( div5 , "class" , "field" ) ;
add _location ( div5 , file$2 , 75 , 12 , 2328 ) ;
attr _dev ( label3 , "for" , "tags" ) ;
attr _dev ( label3 , "class" , "label" ) ;
add _location ( label3 , file$2 , 88 , 16 , 2806 ) ;
attr _dev ( div6 , "class" , "control" ) ;
attr _dev ( div6 , "id" , "tags" ) ;
add _location ( div6 , file$2 , 89 , 16 , 2867 ) ;
attr _dev ( div7 , "class" , "field" ) ;
add _location ( div7 , file$2 , 87 , 12 , 2770 ) ;
attr _dev ( button , "type" , "submit" ) ;
attr _dev ( button , "class" , "button is-primary" ) ;
add _location ( button , file$2 , 94 , 16 , 3059 ) ;
attr _dev ( div8 , "class" , "control" ) ;
add _location ( div8 , file$2 , 93 , 12 , 3021 ) ;
add _location ( form _1 , file$2 , 48 , 8 , 1142 ) ;
attr _dev ( div9 , "class" , "container" ) ;
add _location ( div9 , file$2 , 47 , 4 , 1110 ) ;
attr _dev ( section1 , "class" , "section" ) ;
add _location ( section1 , file$2 , 46 , 0 , 1080 ) ;
} ,
l : function claim ( nodes ) {
throw new Error ( "options.hydrate only works if the component was compiled with the `hydratable: true` option" ) ;
} ,
m : function mount ( target , anchor ) {
insert _dev ( target , section0 , anchor ) ;
append _dev ( section0 , div0 ) ;
append _dev ( div0 , p ) ;
insert _dev ( target , t1 , anchor ) ;
insert _dev ( target , section1 , anchor ) ;
append _dev ( section1 , div9 ) ;
append _dev ( div9 , form _1 ) ;
append _dev ( form _1 , div3 ) ;
append _dev ( div3 , label0 ) ;
append _dev ( div3 , t3 ) ;
append _dev ( div3 , div2 ) ;
append _dev ( div2 , div1 ) ;
append _dev ( div1 , label1 ) ;
append _dev ( label1 , input0 ) ;
append _dev ( label1 , t4 ) ;
append _dev ( label1 , span2 ) ;
append _dev ( span2 , span0 ) ;
append _dev ( span2 , t5 ) ;
append _dev ( span2 , span1 ) ;
append _dev ( div3 , t7 ) ;
if ( if _block0 ) if _block0 . m ( div3 , null ) ;
append _dev ( div3 , t8 ) ;
if ( if _block1 ) if _block1 . m ( div3 , null ) ;
append _dev ( form _1 , t9 ) ;
append _dev ( form _1 , div5 ) ;
append _dev ( div5 , label2 ) ;
append _dev ( div5 , t11 ) ;
append _dev ( div5 , div4 ) ;
append _dev ( div4 , input1 ) ;
set _input _value ( input1 , /*form*/ ctx [ 2 ] . source _url ) ;
append _dev ( form _1 , t12 ) ;
append _dev ( form _1 , div7 ) ;
append _dev ( div7 , label3 ) ;
append _dev ( div7 , t14 ) ;
append _dev ( div7 , div6 ) ;
mount _component ( tags , div6 , null ) ;
append _dev ( form _1 , t15 ) ;
append _dev ( form _1 , div8 ) ;
append _dev ( div8 , button ) ;
current = true ;
if ( ! mounted ) {
dispose = [
listen _dev ( input0 , "change" , /*onFileChange*/ ctx [ 3 ] , false , false , false ) ,
listen _dev ( input1 , "input" , /*input1_input_handler*/ ctx [ 6 ] ) ,
listen _dev ( form _1 , "submit" , prevent _default ( /*onSubmit*/ ctx [ 5 ] ) , false , true , false )
] ;
mounted = true ;
}
} ,
p : function update ( ctx , [ dirty ] ) {
if ( /*currentProgress*/ ctx [ 0 ] > 0 && /*currentProgress*/ ctx [ 0 ] < 100 ) {
if ( if _block0 ) {
if _block0 . p ( ctx , dirty ) ;
} else {
if _block0 = create _if _block _1 ( ctx ) ;
if _block0 . c ( ) ;
if _block0 . m ( div3 , t8 ) ;
}
} else if ( if _block0 ) {
if _block0 . d ( 1 ) ;
if _block0 = null ;
}
if ( /*fileName*/ ctx [ 1 ] !== "" ) {
if ( if _block1 ) {
if _block1 . p ( ctx , dirty ) ;
} else {
if _block1 = create _if _block ( ctx ) ;
if _block1 . c ( ) ;
if _block1 . m ( div3 , null ) ;
}
} else if ( if _block1 ) {
if _block1 . d ( 1 ) ;
if _block1 = null ;
}
if ( dirty & /*form*/ 4 ) {
set _input _value ( input1 , /*form*/ ctx [ 2 ] . source _url ) ;
}
} ,
i : function intro ( local ) {
if ( current ) return ;
transition _in ( tags . $$ . fragment , local ) ;
current = true ;
} ,
o : function outro ( local ) {
transition _out ( tags . $$ . fragment , local ) ;
current = false ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( section0 ) ;
if ( detaching ) detach _dev ( t1 ) ;
if ( detaching ) detach _dev ( section1 ) ;
if ( if _block0 ) if _block0 . d ( ) ;
if ( if _block1 ) if _block1 . d ( ) ;
destroy _component ( tags ) ;
mounted = false ;
run _all ( dispose ) ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _fragment$2 . name ,
type : "component" ,
source : "" ,
ctx
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return block ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function instance$2 ( $$self , $$props , $$invalidate ) {
let { $$slots : slots = { } , $$scope } = $$props ;
validate _slots ( "Upload" , slots , [ ] ) ;
let currentProgress = 0 ;
let fileName = "" ;
let form = { blob _id : "" , source _url : "" , tags : [ ] } ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const onProgress = e => {
var percentCompleted = Math . round ( e . loaded * 100 / e . total ) ;
$$invalidate ( 0 , currentProgress = percentCompleted ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const onFileChange = async e => {
$$invalidate ( 1 , fileName = "" ) ;
var file = e . target . files [ 0 ] ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( file ) {
var response = await uploadBlob ( { file , onProgress } ) ;
$$invalidate ( 2 , form . blob _id = response . id , form ) ;
$$invalidate ( 1 , fileName = file . name ) ;
}
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const onTagChange = value => {
$$invalidate ( 2 , form . tags = value . detail . tags , form ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const onSubmit = async ( ) => {
const response = await postCreate ( form ) ;
navigate ( ` /post/ ${ response . id } ` ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const writable _props = [ ] ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
Object . keys ( $$props ) . forEach ( key => {
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== "$$" ) console . warn ( ` <Upload> was created with unknown prop ' ${ key } ' ` ) ;
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
function input1 _input _handler ( ) {
form . source _url = this . value ;
$$invalidate ( 2 , form ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
$$self . $capture _state = ( ) => ( {
uploadBlob ,
postCreate ,
navigate ,
Tags ,
currentProgress ,
fileName ,
form ,
onProgress ,
onFileChange ,
onTagChange ,
onSubmit
} ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
$$self . $inject _state = $$props => {
if ( "currentProgress" in $$props ) $$invalidate ( 0 , currentProgress = $$props . currentProgress ) ;
if ( "fileName" in $$props ) $$invalidate ( 1 , fileName = $$props . fileName ) ;
if ( "form" in $$props ) $$invalidate ( 2 , form = $$props . form ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( $$props && "$$inject" in $$props ) {
$$self . $inject _state ( $$props . $$inject ) ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
return [
currentProgress ,
fileName ,
form ,
onFileChange ,
onTagChange ,
onSubmit ,
input1 _input _handler
] ;
2021-05-11 00:37:27 +07:00
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
class Upload extends SvelteComponentDev {
constructor ( options ) {
super ( options ) ;
init ( this , options , instance$2 , create _fragment$2 , safe _not _equal , { } ) ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
tagName : "Upload" ,
options ,
id : create _fragment$2 . name
} ) ;
}
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
/* src/routes/Edit.svelte generated by Svelte v3.38.2 */
const file$1 = "src/routes/Edit.svelte" ;
// (49:20) <Link class="button is-primary" to="/post/{id}" >
function create _default _slot$1 ( ctx ) {
let t ;
2021-05-10 22:47:35 +07:00
const block = {
c : function create ( ) {
2021-05-11 03:25:33 +07:00
t = text ( "Back" ) ;
2021-05-10 22:47:35 +07:00
} ,
m : function mount ( target , anchor ) {
2021-05-11 03:25:33 +07:00
insert _dev ( target , t , anchor ) ;
2021-05-10 22:47:35 +07:00
} ,
d : function destroy ( detaching ) {
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( t ) ;
2021-05-10 22:47:35 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
2021-05-11 03:25:33 +07:00
id : create _default _slot$1 . name ,
type : "slot" ,
source : "(49:20) <Link class=\\\"button is-primary\\\" to=\\\"/post/{id}\\\" >" ,
2021-05-10 22:47:35 +07:00
ctx
} ) ;
return block ;
}
function create _fragment$1 ( ctx ) {
let section0 ;
let div0 ;
2021-05-11 03:25:33 +07:00
let p0 ;
let t0 ;
2021-05-10 22:47:35 +07:00
let t1 ;
2021-05-11 03:25:33 +07:00
let t2 ;
2021-05-11 00:37:27 +07:00
let div9 ;
2021-05-11 03:25:33 +07:00
let section1 ;
let div8 ;
let div6 ;
let p1 ;
let link ;
2021-05-11 00:37:27 +07:00
let t3 ;
2021-05-11 03:25:33 +07:00
let form _1 ;
2021-05-10 22:47:35 +07:00
let div2 ;
2021-05-11 03:25:33 +07:00
let label0 ;
let t5 ;
2021-05-11 00:37:27 +07:00
let div1 ;
2021-05-11 03:25:33 +07:00
let input ;
let t6 ;
let div4 ;
2021-05-11 00:37:27 +07:00
let label1 ;
2021-05-10 22:47:35 +07:00
let t8 ;
2021-05-11 03:25:33 +07:00
let div3 ;
let tags ;
2021-05-11 00:37:27 +07:00
let t9 ;
let div5 ;
2021-05-11 03:25:33 +07:00
let button ;
2021-05-11 00:37:27 +07:00
let t11 ;
let div7 ;
2021-05-11 03:25:33 +07:00
let figure ;
let img ;
let img _src _value ;
2021-05-10 22:47:35 +07:00
let current ;
2021-05-11 00:37:27 +07:00
let mounted ;
let dispose ;
2021-05-11 03:25:33 +07:00
link = new Link ( {
props : {
class : "button is-primary" ,
to : "/post/" + /*id*/ ctx [ 0 ] ,
$$slots : { default : [ create _default _slot$1 ] } ,
$$scope : { ctx }
} ,
$$inline : true
} ) ;
tags = new Tags ( {
props : {
tags : /*form*/ ctx [ 2 ] . tags ,
addKeys : [ 9 , 32 ]
} ,
$$inline : true
} ) ;
tags . $on ( "tags" , /*onTagChange*/ ctx [ 3 ] ) ;
2021-05-10 22:47:35 +07:00
const block = {
c : function create ( ) {
section0 = element ( "section" ) ;
div0 = element ( "div" ) ;
2021-05-11 03:25:33 +07:00
p0 = element ( "p" ) ;
t0 = text ( "Edit Post: " ) ;
t1 = text ( /*id*/ ctx [ 0 ] ) ;
t2 = space ( ) ;
2021-05-11 00:37:27 +07:00
div9 = element ( "div" ) ;
2021-05-11 03:25:33 +07:00
section1 = element ( "section" ) ;
div8 = element ( "div" ) ;
div6 = element ( "div" ) ;
p1 = element ( "p" ) ;
create _component ( link . $$ . fragment ) ;
2021-05-11 00:37:27 +07:00
t3 = space ( ) ;
2021-05-11 03:25:33 +07:00
form _1 = element ( "form" ) ;
2021-05-10 22:47:35 +07:00
div2 = element ( "div" ) ;
2021-05-11 03:25:33 +07:00
label0 = element ( "label" ) ;
label0 . textContent = "Source URL" ;
t5 = space ( ) ;
2021-05-11 00:37:27 +07:00
div1 = element ( "div" ) ;
2021-05-11 03:25:33 +07:00
input = element ( "input" ) ;
t6 = space ( ) ;
div4 = element ( "div" ) ;
2021-05-11 00:37:27 +07:00
label1 = element ( "label" ) ;
2021-05-11 03:25:33 +07:00
label1 . textContent = "Tags" ;
2021-05-10 22:47:35 +07:00
t8 = space ( ) ;
2021-05-11 03:25:33 +07:00
div3 = element ( "div" ) ;
create _component ( tags . $$ . fragment ) ;
2021-05-11 00:37:27 +07:00
t9 = space ( ) ;
div5 = element ( "div" ) ;
button = element ( "button" ) ;
button . textContent = "Submit" ;
2021-05-11 03:25:33 +07:00
t11 = space ( ) ;
div7 = element ( "div" ) ;
figure = element ( "figure" ) ;
img = element ( "img" ) ;
attr _dev ( p0 , "class" , "title" ) ;
add _location ( p0 , file$1 , 39 , 8 , 894 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( div0 , "class" , "hero-body" ) ;
2021-05-11 03:25:33 +07:00
add _location ( div0 , file$1 , 38 , 4 , 862 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( section0 , "class" , "hero is-primary" ) ;
2021-05-11 03:25:33 +07:00
add _location ( section0 , file$1 , 37 , 0 , 824 ) ;
add _location ( p1 , file$1 , 47 , 16 , 1104 ) ;
attr _dev ( label0 , "for" , "source" ) ;
2021-05-11 00:37:27 +07:00
attr _dev ( label0 , "class" , "label" ) ;
2021-05-11 03:25:33 +07:00
add _location ( label0 , file$1 , 54 , 24 , 1378 ) ;
attr _dev ( input , "id" , "source" ) ;
attr _dev ( input , "class" , "input" ) ;
attr _dev ( input , "type" , "url" ) ;
attr _dev ( input , "placeholder" , "Source URL" ) ;
add _location ( input , file$1 , 56 , 28 , 1505 ) ;
attr _dev ( div1 , "class" , "control" ) ;
add _location ( div1 , file$1 , 55 , 24 , 1455 ) ;
attr _dev ( div2 , "class" , "field" ) ;
add _location ( div2 , file$1 , 53 , 20 , 1334 ) ;
attr _dev ( label1 , "for" , "tags" ) ;
attr _dev ( label1 , "class" , "label" ) ;
add _location ( label1 , file$1 , 66 , 24 , 1916 ) ;
attr _dev ( div3 , "class" , "control" ) ;
attr _dev ( div3 , "id" , "tags" ) ;
add _location ( div3 , file$1 , 67 , 24 , 1985 ) ;
attr _dev ( div4 , "class" , "field" ) ;
add _location ( div4 , file$1 , 65 , 20 , 1872 ) ;
2021-05-11 00:37:27 +07:00
attr _dev ( button , "type" , "submit" ) ;
attr _dev ( button , "class" , "button is-primary" ) ;
2021-05-11 03:25:33 +07:00
add _location ( button , file$1 , 76 , 24 , 2358 ) ;
attr _dev ( div5 , "class" , "control" ) ;
add _location ( div5 , file$1 , 75 , 20 , 2312 ) ;
add _location ( form _1 , file$1 , 52 , 16 , 1271 ) ;
attr _dev ( div6 , "class" , "column is-one-third box" ) ;
add _location ( div6 , file$1 , 46 , 12 , 1050 ) ;
attr _dev ( img , "alt" , /*id*/ ctx [ 0 ] ) ;
if ( img . src !== ( img _src _value = /*image_path*/ ctx [ 1 ] ) ) attr _dev ( img , "src" , img _src _value ) ;
add _location ( img , file$1 , 84 , 20 , 2638 ) ;
attr _dev ( figure , "class" , "image" ) ;
add _location ( figure , file$1 , 83 , 16 , 2595 ) ;
attr _dev ( div7 , "class" , "column" ) ;
add _location ( div7 , file$1 , 82 , 12 , 2558 ) ;
attr _dev ( div8 , "class" , "columns" ) ;
add _location ( div8 , file$1 , 45 , 8 , 1016 ) ;
2021-05-10 22:47:35 +07:00
attr _dev ( section1 , "class" , "section" ) ;
2021-05-11 03:25:33 +07:00
add _location ( section1 , file$1 , 44 , 4 , 982 ) ;
attr _dev ( div9 , "class" , "container" ) ;
add _location ( div9 , file$1 , 43 , 0 , 954 ) ;
2021-05-10 22:47:35 +07:00
} ,
2021-05-11 00:37:27 +07:00
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 ) ;
2021-05-11 03:25:33 +07:00
append _dev ( div0 , p0 ) ;
append _dev ( p0 , t0 ) ;
append _dev ( p0 , t1 ) ;
insert _dev ( target , t2 , anchor ) ;
insert _dev ( target , div9 , anchor ) ;
append _dev ( div9 , section1 ) ;
append _dev ( section1 , div8 ) ;
append _dev ( div8 , div6 ) ;
append _dev ( div6 , p1 ) ;
mount _component ( link , p1 , null ) ;
append _dev ( div6 , t3 ) ;
append _dev ( div6 , form _1 ) ;
append _dev ( form _1 , div2 ) ;
append _dev ( div2 , label0 ) ;
append _dev ( div2 , t5 ) ;
2021-05-10 22:47:35 +07:00
append _dev ( div2 , div1 ) ;
2021-05-11 03:25:33 +07:00
append _dev ( div1 , input ) ;
set _input _value ( input , /*form*/ ctx [ 2 ] . source _url ) ;
append _dev ( form _1 , t6 ) ;
append _dev ( form _1 , div4 ) ;
append _dev ( div4 , label1 ) ;
append _dev ( div4 , t8 ) ;
append _dev ( div4 , div3 ) ;
mount _component ( tags , div3 , null ) ;
2021-05-11 00:37:27 +07:00
append _dev ( form _1 , t9 ) ;
append _dev ( form _1 , div5 ) ;
2021-05-11 03:25:33 +07:00
append _dev ( div5 , button ) ;
append _dev ( div8 , t11 ) ;
append _dev ( div8 , div7 ) ;
append _dev ( div7 , figure ) ;
append _dev ( figure , img ) ;
2021-05-11 00:37:27 +07:00
current = true ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
if ( ! mounted ) {
dispose = [
2021-05-11 03:25:33 +07:00
listen _dev ( input , "input" , /*input_input_handler*/ ctx [ 5 ] ) ,
listen _dev ( form _1 , "submit" , prevent _default ( /*onSubmit*/ ctx [ 4 ] ) , false , true , false )
2021-05-11 00:37:27 +07:00
] ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
mounted = true ;
}
2021-05-10 22:47:35 +07:00
} ,
p : function update ( ctx , [ dirty ] ) {
2021-05-11 03:25:33 +07:00
if ( ! current || dirty & /*id*/ 1 ) set _data _dev ( t1 , /*id*/ ctx [ 0 ] ) ;
const link _changes = { } ;
if ( dirty & /*id*/ 1 ) link _changes . to = "/post/" + /*id*/ ctx [ 0 ] ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
if ( dirty & /*$$scope*/ 128 ) {
link _changes . $$scope = { dirty , ctx } ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
link . $set ( link _changes ) ;
2021-05-11 00:37:27 +07:00
if ( dirty & /*form*/ 4 ) {
2021-05-11 03:25:33 +07:00
set _input _value ( input , /*form*/ ctx [ 2 ] . source _url ) ;
}
const tags _changes = { } ;
if ( dirty & /*form*/ 4 ) tags _changes . tags = /*form*/ ctx [ 2 ] . tags ;
tags . $set ( tags _changes ) ;
if ( ! current || dirty & /*id*/ 1 ) {
attr _dev ( img , "alt" , /*id*/ ctx [ 0 ] ) ;
}
if ( ! current || dirty & /*image_path*/ 2 && img . src !== ( img _src _value = /*image_path*/ ctx [ 1 ] ) ) {
attr _dev ( img , "src" , img _src _value ) ;
2021-05-10 22:47:35 +07:00
}
} ,
i : function intro ( local ) {
if ( current ) return ;
2021-05-11 03:25:33 +07:00
transition _in ( link . $$ . fragment , local ) ;
2021-05-11 00:37:27 +07:00
transition _in ( tags . $$ . fragment , local ) ;
2021-05-10 22:47:35 +07:00
current = true ;
} ,
o : function outro ( local ) {
2021-05-11 03:25:33 +07:00
transition _out ( link . $$ . fragment , local ) ;
2021-05-11 00:37:27 +07:00
transition _out ( tags . $$ . fragment , local ) ;
2021-05-10 22:47:35 +07:00
current = false ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) detach _dev ( section0 ) ;
2021-05-11 03:25:33 +07:00
if ( detaching ) detach _dev ( t2 ) ;
if ( detaching ) detach _dev ( div9 ) ;
destroy _component ( link ) ;
2021-05-11 00:37:27 +07:00
destroy _component ( tags ) ;
mounted = false ;
run _all ( dispose ) ;
2021-05-10 22:47:35 +07:00
}
} ;
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 ;
2021-05-11 03:25:33 +07:00
validate _slots ( "Edit" , slots , [ ] ) ;
let { id } = $$props ;
let image _path = "" ;
let form = { source _url : "" , tags : [ ] } ;
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
const getData = async ( ) => {
const data = await getPost ( { id } ) ;
$$invalidate ( 2 , form . source _url = data . source _url , form ) ;
$$invalidate ( 2 , form . tags = data . tags , form ) ;
$$invalidate ( 1 , image _path = data . image _path ) ;
2021-05-11 00:37:27 +07:00
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
const onTagChange = value => {
$$invalidate ( 2 , form . tags = value . detail . tags , form ) ;
} ;
2021-05-10 22:47:35 +07:00
2021-05-11 00:37:27 +07:00
const onSubmit = async ( ) => {
2021-05-11 03:25:33 +07:00
const response = await postUpdate ( id , form ) ;
2021-05-11 00:37:27 +07:00
navigate ( ` /post/ ${ response . id } ` ) ;
2021-05-10 22:47:35 +07:00
} ;
2021-05-11 03:25:33 +07:00
onMount ( ( ) => {
getData ( ) ;
} ) ;
const writable _props = [ "id" ] ;
2021-05-10 22:47:35 +07:00
Object . keys ( $$props ) . forEach ( key => {
2021-05-11 03:25:33 +07:00
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== "$$" ) console . warn ( ` <Edit> was created with unknown prop ' ${ key } ' ` ) ;
2021-05-10 22:47:35 +07:00
} ) ;
2021-05-11 03:25:33 +07:00
function input _input _handler ( ) {
2021-05-11 00:37:27 +07:00
form . source _url = this . value ;
$$invalidate ( 2 , form ) ;
}
2021-05-10 22:47:35 +07:00
2021-05-11 03:25:33 +07:00
$$self . $$set = $$props => {
if ( "id" in $$props ) $$invalidate ( 0 , id = $$props . id ) ;
} ;
2021-05-10 22:47:35 +07:00
$$self . $capture _state = ( ) => ( {
2021-05-11 03:25:33 +07:00
getPost ,
postUpdate ,
2021-05-11 00:37:27 +07:00
navigate ,
Tags ,
2021-05-11 03:25:33 +07:00
onMount ,
Link ,
id ,
image _path ,
2021-05-11 00:37:27 +07:00
form ,
2021-05-11 03:25:33 +07:00
getData ,
2021-05-11 00:37:27 +07:00
onTagChange ,
onSubmit
2021-05-10 22:47:35 +07:00
} ) ;
$$self . $inject _state = $$props => {
2021-05-11 03:25:33 +07:00
if ( "id" in $$props ) $$invalidate ( 0 , id = $$props . id ) ;
if ( "image_path" in $$props ) $$invalidate ( 1 , image _path = $$props . image _path ) ;
2021-05-11 00:37:27 +07:00
if ( "form" in $$props ) $$invalidate ( 2 , form = $$props . form ) ;
2021-05-10 22:47:35 +07:00
} ;
if ( $$props && "$$inject" in $$props ) {
$$self . $inject _state ( $$props . $$inject ) ;
}
2021-05-11 03:25:33 +07:00
return [ id , image _path , form , onTagChange , onSubmit , input _input _handler ] ;
2021-05-10 22:47:35 +07:00
}
2021-05-11 03:25:33 +07:00
class Edit extends SvelteComponentDev {
2021-05-10 22:47:35 +07:00
constructor ( options ) {
super ( options ) ;
2021-05-11 03:25:33 +07:00
init ( this , options , instance$1 , create _fragment$1 , safe _not _equal , { id : 0 } ) ;
2021-05-10 22:47:35 +07:00
dispatch _dev ( "SvelteRegisterComponent" , {
component : this ,
2021-05-11 03:25:33 +07:00
tagName : "Edit" ,
2021-05-10 22:47:35 +07:00
options ,
id : create _fragment$1 . name
} ) ;
2021-05-11 03:25:33 +07:00
const { ctx } = this . $$ ;
const props = options . props || { } ;
if ( /*id*/ ctx [ 0 ] === undefined && ! ( "id" in props ) ) {
console . warn ( "<Edit> was created without expected prop 'id'" ) ;
}
}
get id ( ) {
throw new Error ( "<Edit>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
}
set id ( value ) {
throw new Error ( "<Edit>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
2021-05-10 22:47:35 +07:00
}
}
/* src/App.svelte generated by Svelte v3.38.2 */
const file = "src/App.svelte" ;
2021-05-11 00:37:27 +07:00
// (18:0) <Router {url}>
2021-05-10 22:47:35 +07:00
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 ;
2021-05-11 00:37:27 +07:00
let t6 ;
let route6 ;
2021-05-10 22:47:35 +07:00
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 ( {
2021-05-11 03:25:33 +07:00
props : { path : "/post/:id" , component : Post } ,
2021-05-10 22:47:35 +07:00
$$inline : true
} ) ;
route3 = new Route ( {
2021-05-11 03:25:33 +07:00
props : { path : "/post/edit/:id" , component : Edit } ,
2021-05-10 22:47:35 +07:00
$$inline : true
} ) ;
route4 = new Route ( {
props : { path : "/auth/login" , component : Login } ,
$$inline : true
} ) ;
route5 = new Route ( {
props : { path : "/auth/logout" , component : Logout } ,
$$inline : true
} ) ;
2021-05-11 00:37:27 +07:00
route6 = new Route ( {
props : { path : "/upload" , component : Upload } ,
$$inline : true
} ) ;
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 00:37:27 +07:00
t6 = space ( ) ;
create _component ( route6 . $$ . fragment ) ;
2021-05-11 03:25:33 +07:00
add _location ( div , file , 19 , 1 , 505 ) ;
2021-05-10 22:47:35 +07:00
} ,
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 ) ;
2021-05-11 00:37:27 +07:00
append _dev ( div , t6 ) ;
mount _component ( route6 , div , null ) ;
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 00:37:27 +07:00
transition _in ( route6 . $$ . fragment , local ) ;
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 00:37:27 +07:00
transition _out ( route6 . $$ . fragment , local ) ;
2021-05-10 22:47:35 +07:00
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 ) ;
2021-05-11 00:37:27 +07:00
destroy _component ( route6 ) ;
2021-05-10 22:47:35 +07:00
}
} ;
dispatch _dev ( "SvelteRegisterBlock" , {
block ,
id : create _default _slot . name ,
type : "slot" ,
2021-05-11 00:37:27 +07:00
source : "(18:0) <Router {url}>" ,
2021-05-10 22:47:35 +07:00
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 ,
2021-05-11 00:37:27 +07:00
Upload ,
2021-05-11 03:25:33 +07:00
Edit ,
2021-05-10 22:47:35 +07:00
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 ;
} ( ) ) ;
2021-05-09 22:07:23 +07:00
//# sourceMappingURL=bundle.js.map