2023-03-09 19:58:08 +01:00
var $hx _exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this ;
( function ( $global ) { "use strict" ;
$hx _exports [ "xrfragment" ] = $hx _exports [ "xrfragment" ] || { } ;
$hx _exports [ "xrfragment" ] [ "Query" ] = $hx _exports [ "xrfragment" ] [ "Query" ] || { } ;
var EReg = function ( r , opt ) {
this . r = new RegExp ( r , opt . split ( "u" ) . join ( "" ) ) ;
} ;
2023-03-10 18:49:16 +01:00
EReg . _ _name _ _ = true ;
2023-03-09 19:58:08 +01:00
EReg . prototype = {
2023-03-09 22:32:28 +01:00
match : function ( s ) {
2023-03-09 19:58:08 +01:00
if ( this . r . global ) {
this . r . lastIndex = 0 ;
}
this . r . m = this . r . exec ( s ) ;
this . r . s = s ;
return this . r . m != null ;
}
2023-03-10 18:49:16 +01:00
, split : function ( s ) {
var d = "#__delim__#" ;
return s . replace ( this . r , d ) . split ( d ) ;
}
2023-03-09 19:58:08 +01:00
} ;
var HxOverrides = function ( ) { } ;
2023-03-10 18:49:16 +01:00
HxOverrides . _ _name _ _ = true ;
2023-03-09 19:58:08 +01:00
HxOverrides . substr = function ( s , pos , len ) {
if ( len == null ) {
len = s . length ;
} else if ( len < 0 ) {
if ( pos == 0 ) {
len = s . length + len ;
} else {
return "" ;
}
}
return s . substr ( pos , len ) ;
} ;
HxOverrides . now = function ( ) {
return Date . now ( ) ;
} ;
2023-03-10 18:49:16 +01:00
Math . _ _name _ _ = true ;
2023-03-09 19:58:08 +01:00
var Reflect = function ( ) { } ;
2023-03-10 18:49:16 +01:00
Reflect . _ _name _ _ = true ;
2023-03-09 19:58:08 +01:00
Reflect . field = function ( o , field ) {
try {
return o [ field ] ;
} catch ( _g ) {
return null ;
}
} ;
Reflect . fields = function ( o ) {
var a = [ ] ;
if ( o != null ) {
var hasOwnProperty = Object . prototype . hasOwnProperty ;
for ( var f in o ) {
if ( f != "__id__" && f != "hx__closures__" && hasOwnProperty . call ( o , f ) ) {
a . push ( f ) ;
}
}
}
return a ;
} ;
var Std = function ( ) { } ;
2023-03-10 18:49:16 +01:00
Std . _ _name _ _ = true ;
Std . string = function ( s ) {
return js _Boot . _ _string _rec ( s , "" ) ;
} ;
2023-03-09 19:58:08 +01:00
Std . parseInt = function ( x ) {
if ( x != null ) {
var _g = 0 ;
var _g1 = x . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
var c = x . charCodeAt ( i ) ;
if ( c <= 8 || c >= 14 && c != 32 && c != 45 ) {
var nc = x . charCodeAt ( i + 1 ) ;
var v = parseInt ( x , nc == 120 || nc == 88 ? 16 : 10 ) ;
if ( isNaN ( v ) ) {
return null ;
} else {
return v ;
}
}
}
}
return null ;
} ;
var Test = function ( ) { } ;
2023-03-10 18:49:16 +01:00
Test . _ _name _ _ = true ;
2023-03-09 19:58:08 +01:00
Test . main = function ( ) {
2023-03-17 16:06:24 +01:00
Test . test ( [ { fn : "query" , expect : { fn : "selected" , input : "foo" , out : true } , data : "foo or bar" } , { fn : "query" , expect : { fn : "selected" , input : "xxx" , out : false } , label : "nonselected entity" , data : "foo or bar" } ] ) ;
Test . test ( [ { fn : "url" , expect : { fn : "equal.string" , input : "bar" , out : "flop" } , data : "http://foo.com?foo=1#bar=flop&a=1,2&b=c|d|1,2,3" } , { fn : "url" , expect : { fn : "equal.xy" , input : "a" , out : "1.22.2" } , label : "a equal.xy" , data : "http://foo.com?foo=1#bar=flop&a=1.2,2.2&b=c|d|1,2,3" } , { fn : "url" , expect : { fn : "equal.multi" , input : "b" , out : "c|d|1,2,3" } , label : "b equal.multi" , data : "http://foo.com?foo=1#b=c|d|1,2,3" } ] ) ;
2023-03-09 19:58:08 +01:00
} ;
2023-03-17 16:06:24 +01:00
Test . test = function ( spec ) {
var Query = xrfragment _Query ;
var errors = 0 ;
var _g = 0 ;
var _g1 = spec . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
var q = null ;
var res = null ;
var valid = false ;
var item = spec [ i ] ;
if ( item . fn == "query" ) {
q = new xrfragment _Query ( item . data ) ;
}
if ( item . fn == "url" ) {
res = xrfragment _Url . parse ( item . data ) ;
}
if ( item . expect . fn == "selected" ) {
valid = item . expect . out == q . selected ( item . expect . input ) ;
}
if ( item . expect . fn == "equal.string" ) {
valid = item . expect . out == res [ item . expect . input ] . string ;
}
if ( item . expect . fn == "equal.xy" ) {
valid = item . expect . out == Std . string ( res [ item . expect . input ] . x ) + Std . string ( res [ item . expect . input ] . y ) ;
}
if ( item . expect . fn == "equal.multi" ) {
valid = Test . equalMulti ( res , item ) ;
}
var ok = valid ? "[ ✔ ] " : "[ ❌] " ;
console . log ( "src/Test.hx:34:" , ok + Std . string ( item . fn ) + ": '" + Std . string ( item . data ) + "'" + ( item . label ? " <= " + ( item . label ? item . label : item . expect . fn ) : "" ) ) ;
if ( ! valid ) {
++ errors ;
}
}
if ( errors > 1 ) {
console . log ( "src/Test.hx:37:" , "\n-----\n[ ❌] " + errors + " errors :/" ) ;
}
2023-03-09 19:58:08 +01:00
} ;
2023-03-17 16:06:24 +01:00
Test . equalMulti = function ( res , item ) {
var target = res [ item . expect . input ] ;
var str = "" ;
var _g = 0 ;
var _g1 = target . args . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
str = str + "|" + target . args [ i ] . string ;
2023-03-10 18:49:16 +01:00
}
2023-03-17 16:06:24 +01:00
str = HxOverrides . substr ( str , 1 , null ) ;
return str == item . expect . out ;
2023-03-09 19:58:08 +01:00
} ;
2023-03-09 22:32:28 +01:00
var haxe _iterators _ArrayIterator = function ( array ) {
this . current = 0 ;
this . array = array ;
2023-03-09 19:58:08 +01:00
} ;
2023-03-10 18:49:16 +01:00
haxe _iterators _ArrayIterator . _ _name _ _ = true ;
2023-03-09 22:32:28 +01:00
haxe _iterators _ArrayIterator . prototype = {
hasNext : function ( ) {
return this . current < this . array . length ;
2023-03-09 19:58:08 +01:00
}
, next : function ( ) {
return this . array [ this . current ++ ] ;
}
} ;
2023-03-10 18:49:16 +01:00
var js _Boot = function ( ) { } ;
js _Boot . _ _name _ _ = true ;
js _Boot . _ _string _rec = function ( o , s ) {
if ( o == null ) {
return "null" ;
}
if ( s . length >= 5 ) {
return "<...>" ;
}
var t = typeof ( o ) ;
if ( t == "function" && ( o . _ _name _ _ || o . _ _ename _ _ ) ) {
t = "object" ;
}
switch ( t ) {
case "function" :
return "<function>" ;
case "object" :
if ( ( ( o ) instanceof Array ) ) {
var str = "[" ;
s += "\t" ;
var _g = 0 ;
var _g1 = o . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
str += ( i > 0 ? "," : "" ) + js _Boot . _ _string _rec ( o [ i ] , s ) ;
}
str += "]" ;
return str ;
}
var tostr ;
try {
tostr = o . toString ;
} catch ( _g ) {
return "???" ;
}
if ( tostr != null && tostr != Object . toString && typeof ( tostr ) == "function" ) {
var s2 = o . toString ( ) ;
if ( s2 != "[object Object]" ) {
return s2 ;
}
}
var str = "{\n" ;
s += "\t" ;
var hasp = o . hasOwnProperty != null ;
var k = null ;
for ( k in o ) {
if ( hasp && ! o . hasOwnProperty ( k ) ) {
continue ;
}
if ( k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__" ) {
continue ;
}
if ( str . length != 2 ) {
str += ", \n" ;
}
str += s + k + " : " + js _Boot . _ _string _rec ( o [ k ] , s ) ;
}
s = s . substring ( 1 ) ;
str += "\n" + s + "}" ;
return str ;
case "string" :
return o ;
default :
return String ( o ) ;
}
} ;
2023-03-09 19:58:08 +01:00
var xrfragment _Query = function ( str ) {
this . preset = "" ;
this . accept = false ;
this . exclude = [ ] ;
this . include = [ ] ;
this . q = { } ;
if ( str != null ) {
this . parse ( str ) ;
}
} ;
2023-03-10 18:49:16 +01:00
xrfragment _Query . _ _name _ _ = true ;
2023-03-09 19:58:08 +01:00
xrfragment _Query . prototype = {
2023-03-17 16:06:24 +01:00
selected : function ( nodename ) {
2023-03-09 19:58:08 +01:00
if ( this . q . copy _all ) {
this . accept = true ;
}
if ( this . include . indexOf ( nodename ) != - 1 ) {
this . accept = true ;
}
if ( this . exclude . indexOf ( nodename ) != - 1 ) {
this . accept = false ;
}
return this . accept ;
}
, parse : function ( str , recurse ) {
if ( recurse == null ) {
recurse = false ;
}
var _gthis = this ;
var copyAll = recurse ? this . q . copy _all : HxOverrides . substr ( str , 0 , 1 ) == "-" || HxOverrides . substr ( str , 0 , 1 ) == "?" || str == "" ;
var isOr = new EReg ( "^or$" , "" ) ;
var isProp = new EReg ( ".*:[><=!]?" , "" ) ;
var isName = new EReg ( "[^:/]" , "" ) ;
var isExclude = new EReg ( "^-" , "" ) ;
var isInclude = new EReg ( "^\\+" , "" ) ;
var isPreset = new EReg ( "^\\?" , "" ) ;
var token = str . split ( " " ) ;
var ors = [ ] ;
var q = { } ;
var composeQuery = function ( ) {
q = { } ;
var value = [ ] ;
q [ "object" ] = value ;
var value = [ ] ;
q [ "-object" ] = value ;
ors . push ( q ) ;
return q ;
} ;
composeQuery ( ) ;
var match = null ;
match = function ( str , prefix ) {
if ( prefix == null ) {
prefix = "" ;
}
if ( isPreset . match ( str ) && ! recurse ) {
_gthis . preset = str ;
return ;
}
if ( isExclude . match ( str ) || isInclude . match ( str ) ) {
var t = HxOverrides . substr ( str , 1 , null ) ;
match ( t , HxOverrides . substr ( str , 0 , 1 ) ) ;
return ;
}
if ( isProp . match ( str ) ) {
var skip = 0 ;
var type = "=" ;
if ( str . indexOf ( "*" ) != - 1 ) {
type = "*" ;
}
if ( str . indexOf ( ">" ) != - 1 ) {
type = ">" ;
}
if ( str . indexOf ( "<" ) != - 1 ) {
type = "<" ;
}
if ( str . indexOf ( "!=" ) != - 1 ) {
type = "!=" ;
}
if ( str . indexOf ( ">=" ) != - 1 ) {
type = ">=" ;
}
if ( str . indexOf ( "<=" ) != - 1 ) {
type = "<=" ;
}
if ( type != "=" ) {
skip += type . length ;
}
var property = str . split ( ":" ) [ 0 ] ;
var value ;
if ( q [ prefix + property ] ) {
value = q [ prefix + property ] ;
} else {
value = { } ;
}
value [ type ] = HxOverrides . substr ( str . split ( ":" ) [ 1 ] , skip , null ) ;
q [ prefix + property ] = value ;
return ;
}
if ( isName . match ( str ) ) {
if ( prefix == "-" ) {
q [ "-object" ] . push ( str ) ;
while ( q [ "object" ] . contains ( str ) == true ) q [ "object" ] . remove ( str ) ;
} else {
q [ "object" ] . push ( str ) ;
while ( q [ "-object" ] . contains ( str ) == true ) q [ "-object" ] . remove ( str ) ;
}
return ;
}
} ;
var _g = 0 ;
var _g1 = token . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
if ( isOr . match ( token [ i ] ) ) {
composeQuery ( ) ;
} else {
match ( token [ i ] ) ;
}
}
var _g = 0 ;
var _g1 = ors . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
var or = ors [ i ] ;
if ( Reflect . field ( or , "object" ) != null ) {
this . include = this . include . concat ( Reflect . field ( or , "object" ) ) ;
}
if ( Reflect . field ( or , "-object" ) != null ) {
this . exclude = this . exclude . concat ( Reflect . field ( or , "-object" ) ) ;
}
}
this . q = { or : ors , copy _all : copyAll } ;
return this . q ;
}
, test : function ( property , value ) {
if ( this . preset == property ) {
this . parse ( value , true ) ;
}
var _g = 0 ;
var _g1 = this . q . or . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
var or = this . q . or [ i ] ;
var conds = [ 0 ] ;
var fails = [ 0 ] ;
var pass = 0 ;
var when = ( function ( fails , conds ) {
return function ( expr ) {
conds [ 0 ] += 1 ;
fails [ 0 ] += expr ? 0 : 1 ;
return expr ;
} ;
} ) ( fails , conds ) ;
var _g2 = 0 ;
var _g3 = Reflect . fields ( or ) ;
while ( _g2 < _g3 . length ) {
var k = _g3 [ _g2 ] ;
++ _g2 ;
var orval = Reflect . field ( or , k ) ;
if ( k != property ) {
continue ;
}
if ( Reflect . field ( orval , "=" ) != null && when ( value == Reflect . field ( orval , "=" ) ) ) {
++ pass ;
}
if ( Reflect . field ( orval , "*" ) != null && when ( value != null ) ) {
++ pass ;
}
if ( Reflect . field ( orval , ">" ) != null && when ( value > Std . parseInt ( Reflect . field ( orval , ">" ) ) ) ) {
++ pass ;
}
if ( Reflect . field ( orval , "<" ) != null && when ( value < Std . parseInt ( Reflect . field ( orval , "<" ) ) ) ) {
++ pass ;
}
if ( Reflect . field ( orval , ">=" ) != null && when ( value >= Std . parseInt ( Reflect . field ( orval , ">=" ) ) ) ) {
++ pass ;
}
if ( Reflect . field ( orval , "<=" ) != null && when ( value >= Std . parseInt ( Reflect . field ( orval , "<=" ) ) ) ) {
++ pass ;
}
if ( Reflect . field ( orval , "!=" ) != null && when ( value != Std . parseInt ( Reflect . field ( orval , "!=" ) ) ) ) {
++ pass ;
}
}
if ( this . accept && conds [ 0 ] > 0 && fails [ 0 ] > 0 ) {
this . accept = false ;
}
if ( conds [ 0 ] > 0 && pass > 0 && fails [ 0 ] == 0 ) {
this . accept = true ;
}
}
}
} ;
2023-03-10 18:49:16 +01:00
var xrfragment _Value = $hx _exports [ "xrfragment" ] [ "Value" ] = function ( ) {
} ;
xrfragment _Value . _ _name _ _ = true ;
var xrfragment _Url = function ( ) { } ;
xrfragment _Url . _ _name _ _ = true ;
xrfragment _Url . parse = function ( qs ) {
var fragment = qs . split ( "#" ) ;
var splitArray = fragment [ 1 ] . split ( "&" ) ;
var regexPlus = new EReg ( "\\+" , "g" ) ;
2023-03-17 16:06:24 +01:00
var resultMap = { } ;
2023-03-10 18:49:16 +01:00
var _g = 0 ;
var _g1 = splitArray . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
var splitByEqual = splitArray [ i ] . split ( "=" ) ;
var key = splitByEqual [ 0 ] ;
var v = new xrfragment _Value ( ) ;
if ( splitByEqual . length > 1 ) {
var s = regexPlus . split ( splitByEqual [ 1 ] ) . join ( " " ) ;
var value = decodeURIComponent ( s . split ( "+" ) . join ( " " ) ) ;
xrfragment _Url . guessType ( v , value ) ;
if ( value . split ( "|" ) . length > 1 ) {
v . args = [ ] ;
var args = value . split ( "|" ) ;
var _g2 = 0 ;
var _g3 = args . length ;
while ( _g2 < _g3 ) {
var i1 = _g2 ++ ;
var x = new xrfragment _Value ( ) ;
xrfragment _Url . guessType ( x , args [ i1 ] ) ;
v . args . push ( x ) ;
}
}
2023-03-17 16:06:24 +01:00
resultMap [ key ] = v ;
2023-03-10 18:49:16 +01:00
}
}
return resultMap ;
} ;
xrfragment _Url . guessType = function ( v , str ) {
var isColor = new EReg ( "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" , "" ) ;
var isInt = new EReg ( "^[0-9]+$" , "" ) ;
var isFloat = new EReg ( "^[0-9]+\\.[0-9]+$" , "" ) ;
v . string = str ;
if ( str . split ( "," ) . length > 1 ) {
var xyz = str . split ( "," ) ;
if ( xyz . length > 0 ) {
v . x = parseFloat ( xyz [ 0 ] ) ;
}
if ( xyz . length > 1 ) {
v . y = parseFloat ( xyz [ 1 ] ) ;
}
if ( xyz . length > 2 ) {
v . z = parseFloat ( xyz [ 2 ] ) ;
}
}
if ( isColor . match ( str ) ) {
v . color = str ;
}
if ( isFloat . match ( str ) ) {
v . float = parseFloat ( str ) ;
}
if ( isInt . match ( str ) ) {
v . int = Std . parseInt ( str ) ;
}
} ;
2023-03-09 19:58:08 +01:00
if ( typeof ( performance ) != "undefined" ? typeof ( performance . now ) == "function" : false ) {
HxOverrides . now = performance . now . bind ( performance ) ;
}
2023-03-10 18:49:16 +01:00
String . _ _name _ _ = true ;
Array . _ _name _ _ = true ;
js _Boot . _ _toStr = ( { } ) . toString ;
2023-03-09 19:58:08 +01:00
var xrfragment _Query _ok = $hx _exports [ "xrfragment" ] [ "Query" ] [ "ok" ] =
// haxe workarounds
Array . prototype . contains = Array . prototype . includes
if ( typeof Array . prototype . remove !== "function" ) {
Array . prototype . remove = function ( item ) {
const oldLength = this . length
let newLength = 0
for ( let i = 0 ; i < oldLength ; i ++ ) {
const entry = this [ i ]
if ( entry === item ) {
let newLength = i ++
while ( i !== this . length ) {
const entry = this [ i ]
if ( entry !== item ) this [ newLength ++ ] = entry
i ++
}
this . length = newLength
for ( let i = newLength ; i < oldLength ; i ++ ) delete this [ i ]
return true
}
}
return false
}
}
;
Test . main ( ) ;
2023-03-09 22:32:28 +01:00
} ) ( { } ) ;
2023-03-09 19:58:08 +01:00
var xrfragment = $hx _exports [ "xrfragment" ] ;