import { Base64 } from './util' ; const decode = ( buffer , key ) => { const decoded = new Uint8Array ( buffer . byteLength ) ; for ( let i = 0 ; i < buffer . byteLength ; i ++ ) { decoded [ i ] = buffer [ i ] ^ key ; } return decoded ; } ; export class Decoder { static DecodeList = ( buffer ) => { const aigisAssetsBegin = 'https://drc1bk94f7rq8.cloudfront.net/' ; const b = [ ] ; const d = decode ( buffer , 0xea ^ 0x30 ) ; for ( let i = 0 ; i < d . byteLength ; i ++ ) { b . push ( String . fromCharCode ( d [ i ] ) ) ; } const csvData = b . join ( '' ) ; const csvDatas = csvData . split ( '\n' ) ; const datas = new Map ( ) ; for ( let i = 0 ; i < csvDatas . length ; i ++ ) { const data = csvDatas [ i ] . split ( ',' ) ; datas . set ( data [ 4 ] , aigisAssetsBegin + data [ 0 ] + '/' + data [ 1 ] ) ; } return datas ; } ; static DecodeXml = ( buffer ) => { const head = '<DA>' ; const startByte = head . charCodeAt ( 0 ) ; for ( let i = 0 ; i < Math . min ( 100 , buffer . byteLength ) ; i ++ ) { let test = true ; const _b = buffer [ i ] ; for ( let j = 1 ; j < head . length ; j ++ ) { const testVal = _b ^ buffer [ i + j ] ; const canon = startByte ^ head . charCodeAt ( j ) ; if ( testVal !== canon ) { test = false ; break ; } } if ( test ) { return decode ( buffer , startByte ^ _b ) ; } } return null ; } ; }