Commit a477e625 authored by 18868195926's avatar 18868195926

feat: 初始化项目

parent bed68e98
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
{
"extends": ["taro"],
"rules": {
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
},
"parser": "babel-eslint"
}
dist/
deploy_versions/
.temp/
.rn_temp/
node_modules/
.DS_Store
registry=https://r.cnpmjs.org
disturl=https://r.cnpmjs.org/node
sass_binary_site=https://r.cnpmjs.org/node-sass/
fse_binary_host_mirror=https://r.cnpmjs.org/fsevents
module.exports = {
env: {
NODE_ENV: '"development"'
},
defineConstants: {
},
mini: {},
h5: {}
}
const path = require('path');
console.log(process);
const config = {
projectName: 'xiaoya-agent-program',
date: '2020-4-3',
designWidth: 750,
deviceRatio: {
'640': 2.34 / 2,
'750': 1,
'828': 1.81 / 2
},
sourceRoot: 'src',
outputRoot: `dist/${process.env.TARO_ENV}`,
alias: {
'@': path.resolve(__dirname, '..', 'src')
},
babel: {
sourceMap: true,
presets: [
['env', {
modules: false
}]
],
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread',
['transform-runtime', {
helpers: false,
polyfill: false,
regenerator: true,
moduleName: 'babel-runtime'
}
]
]
},
defineConstants: {
},
mini: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
}
},
pxtransform: {
enable: true,
config: {
}
},
url: {
enable: true,
config: {
limit: 10240 // 设定转换尺寸上限
}
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
},
h5: {
publicPath: '/',
staticDirectory: 'static',
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
}
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
}
}
module.exports = function (merge) {
if (process.env.NODE_ENV === 'development') {
return merge({}, config, require('./dev'))
}
return merge({}, config, require('./prod'))
}
module.exports = {
env: {
NODE_ENV: '"production"'
},
defineConstants: {
},
mini: {},
h5: {
/**
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
* 参考代码如下:
* webpackChain (chain) {
* chain.plugin('analyzer')
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
*/
}
}
{
"name": "xiaoya-agent-program",
"version": "1.0.0",
"private": true,
"description": "小丫统一版代理商小程序",
"templateInfo": {
"name": "redux",
"typescript": false,
"css": "sass"
},
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:quickapp": "taro build --type quickapp",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/components": "2.0.0-beta.13",
"@tarojs/components-qa": "2.0.0-beta.13",
"@tarojs/redux": "2.0.0-beta.13",
"@tarojs/redux-h5": "2.0.0-beta.13",
"@tarojs/router": "2.0.0-beta.13",
"@tarojs/taro": "2.0.0-beta.13",
"@tarojs/taro-alipay": "2.0.0-beta.13",
"@tarojs/taro-h5": "2.0.0-beta.13",
"@tarojs/taro-qq": "2.0.0-beta.13",
"@tarojs/taro-quickapp": "2.0.0-beta.13",
"@tarojs/taro-swan": "2.0.0-beta.13",
"@tarojs/taro-tt": "2.0.0-beta.13",
"@tarojs/taro-weapp": "2.0.0-beta.13",
"babel-runtime": "^6.26.0",
"nervjs": "^1.5.6",
"nerv-devtools": "^1.5.6",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"regenerator-runtime": "0.11.1"
},
"devDependencies": {
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"@tarojs/mini-runner": "2.0.0-beta.13",
"@tarojs/webpack-runner": "2.0.0-beta.13",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-eslint": "^8.2.3",
"eslint": "^5.16.0",
"eslint-config-taro": "2.0.0-beta.13",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^1.6.1",
"eslint-plugin-import": "^2.12.0",
"stylelint": "9.3.0",
"stylelint-config-taro-rn": "2.0.0-beta.13",
"stylelint-taro-rn": "2.0.0-beta.13",
"eslint-plugin-taro": "2.0.0-beta.13"
}
}
{
"miniprogramRoot": "./dist",
"projectname": "xiaoya-agent-program",
"description": "小丫统一版代理商小程序",
"appid": "touristappid",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false
},
"compileType": "miniprogram"
}
import {
ADD,
MINUS
} from '../constants/counter'
export const add = () => {
return {
type: ADD
}
}
export const minus = () => {
return {
type: MINUS
}
}
// 异步的action
export function asyncAdd () {
return dispatch => {
setTimeout(() => {
dispatch(add())
}, 2000)
}
}
import {
NAV,
} from '../constants/nav'
export default function save (obj) {
return {
type: NAV,
obj
}
}
\ No newline at end of file
import {
SET_USER_INFO
} from '@/constants/user'
export const setUserInfo = (data) => {
return {
type: SET_USER_INFO,
payload: data
}
}
import Taro, { Component } from '@tarojs/taro'
import { Provider } from '@tarojs/redux'
import Index from './pages/index'
import save from './actions/nav'
import configStore from './store'
import './app.scss'
// 如果需要在 h5 环境中开启 React Devtools
// 取消以下注释:
// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
// require('nerv-devtools')
// }
const store = configStore()
class App extends Component {
config = {
pages: [
'pages/index/index',
'pages/citySelect/index'
],
permission: {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black',
navigationStyle: 'custom',
}
}
componentDidMount () {
Taro.login({
success: function (res) {
console.log('res...', res)
}
})
let menuButtonObject = Taro.getMenuButtonBoundingClientRect();
Taro.getSystemInfo({
success: res => {
let globalData = {}
let statusBarHeight = res.statusBarHeight,
navTop = menuButtonObject.top,//胶囊按钮与顶部的距离
navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight)*2;//导航高度
globalData.navHeight = navHeight;
globalData.navTop = navTop;
globalData.windowHeight = res.windowHeight;
globalData.navRight = res.windowWidth - menuButtonObject.right;
store.dispatch(save(globalData))
},
fail(err) {
console.log(err);
}
})
}
componentDidShow () {}
componentDidHide () {}
componentDidCatchError () {}
// 在 App 类中的 render() 函数没有实际作用
// 请勿修改此函数
render () {
return (
<Provider store={store}>
<Index />
</Provider>
)
}
}
Taro.render(<App />, document.getElementById('app'))
page {
background-color: #f5f5f9;
}
$BASE-COLOR: #0681FD;
$BUY-BTN-BG: linear-gradient(180deg,rgba(255,255,255,1) 0%,rgba(215,235,249,1) 94%,rgba(234,246,255,1) 100%);
$BUY-BTN-SHADOW: 0px 1px 4px 0px rgba(0,97,169,0.6);
$MY-COUPON-TEXT-COLOR: #108EE9;
\ No newline at end of file
$BASE-COLOR: red;
$FIELD_ERROR_COLOR: #FF8000;
/**
* 项目配置
*/
const common = {
mapKey: '1d513c9e11da27818bcff443487c995f'
}
const config = {
/**
* 开发环境的配置
*/
development: {
//http请求baseUrl
httpBaseUrl: 'https://cashier.test.miyahub.net',
// httpBaseUrl: 'https://cashier.miyahub.com',
},
/**
* 生产环境配置
*/
production: {
//http请求baseUrl
httpBaseUrl: 'https://cashier.miyahub.com'
}
}
export default {
...common,
...config[process.env.NODE_ENV]
}
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components'
import { connect } from '@tarojs/redux'
import './index.scss'
@connect(({ nav }) => ({
nav
}), (dispatch) => ({
}))
class Index extends Component {
componentWillReceiveProps (nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
navBack = () => {
Taro.navigateBack({
delta: 1
})
}
//回主页
toIndex = () => {
Taro.navigateTo({
url: '/pages/admin/home/index/index'
})
}
render () {
const {showNav, bgColor, pageName, nav} = this.props
console.log(this.props)
const titleTop = (nav.globalData.navHeight - nav.globalData.navTop - 20) / 2 + nav.globalData.navTop
return (
<View className='navbar custom-class' style={`height:${nav.globalData.navHeight}px;background-color:${bgColor}`}>
{showNav && <View
className='navbar-action-wrap navbar-action-group'
style={`top:${titleTop}px;background-color:rgba(255,255,255,.6)`}
>
<Image onClick={this.navBack} className='icon' src='http://hh-oss-picture.miyapay.com/box/c66db9ee434dd2061fbb949db0af797d.png' />
</View>
}
{this.props.children}
<View class='navbar-title' style={`top:${titleTop}px`}>
{pageName}
</View>
</View>
)
}
}
export default Index
.navbar {
width: 100%;
overflow: hidden;
position: relative;
top: 0;
left: 0;
z-index: 10;
flex-shrink: 0;
display: flex;
align-items: center;
}
.navbar-title {
width: 100%;
box-sizing: border-box;
padding-left: 115px;
padding-right: 115px;
text-align: center;
position: absolute;
left: 0;
z-index: 10;
color: #333;
font-size: 36px;
font-weight: bold;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.navbar-action-wrap {
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
position: absolute;
left: 10px;
z-index: 11;
line-height: 1;
padding-top: 4px;
padding-bottom: 4px;
}
.navbar-action-group {
border: 1px solid #f0f0f0;
border-radius: 20px;
overflow: hidden;
.icon{
width: 48px;
height: 48px;
}
}
.navbar-action_item {
padding: 3px 0;
color: #333;
}
.navbar-action-group .navbar-action_item {
border-right: 1px solid #f0f0f0;
padding: 3px 14px;
}
.navbar-action-group .last {
border-right: none;
}
\ No newline at end of file
export const ADD = 'ADD'
export const MINUS = 'MINUS'
export const NAV = 'SAVENAV'
export const DELNAV = 'DELNAV'
export const SET_USER_INFO = 'set user info';
import Taro from '@tarojs/taro';
// import {formatPathQuery} from '@/util/base'
// import {fetchQrCodeInfo} from '@/api/qrcode';
import location from '@/helper/location';
import {getStore} from '@tarojs/redux';
import {setUserInfo} from '@/actions/user'
// import userAPI from '@/api/user';
export default class BaseComponent extends Taro.Component {
fetchLocation() {
return new Promise((resolve, reject) => {
location.getLocation({type: 1, detail: true})
.then(res => {
let locationInfo = res || {};
let user = this.props.user;
let data = {
current: {
...locationInfo
}
}
// 疑问
if (user && !user.city) {
data = {...data, ...locationInfo};
}
this.props.setUserInfo && this.props.setUserInfo(data);
resolve(res);
}).catch(err => {
// console.log(err);
Taro.showToast({title: err.errorMessage || '定位失败'})
reject(err);
})
})
}
login() {
let store = getStore();
Taro.getAuthCode({scopes: 'auth_base'})
.then(authCode => {
return userAPI.login({authCode: authCode})
})
.then(res => {
let user = res.data || {};
// user.hasPhone = 0;
store.dispatch(setUserInfo(user));
}).catch(err => {
console.log('err...', err);
})
}
commonQrcode(path){
let params = formatPathQuery(path)
//通用码逻辑
if(params.from === 'qrcode'){
fetchQrCodeInfo({
qrCode: params.id
}).then(res=>{
if(res.success && res.data){
if(params.type === 'store' && res.data.merchantId && res.data.storeId){
Taro.navigateTo({
url: `/pages/storeHome/index?merchantId=${res.data.merchantId}&storeId=${res.data.storeId}&storeName=${res.data.storeName||''}`
})
}
}
})
/*Taro.navigateTo({
url: `/pages/storeHome/index?merchantId=${store.merchantId}&storeId=${store.storeId}&storeName=${store.storeName}`
})*/
}
}
}
import AMap from '@/lib/amap-wx';
import config from '@/base.config';
import Taro from '@tarojs/taro';
let amap = new AMap({
key: config.mapKey
})
let env = Taro.getEnv();
export function getLocation(options) {
if (env === 'ALIPAY') {
return Taro.getLocation(options);
} else {
if (options.detail) {
delete options.detail;
return new Promise((resolve, reject) => {
Taro.getLocation().then(res => {
amap.getRegeo({
location: res.longitude + "," + res.latitude,
success: res => {
let location = Array.isArray(res) && res.length > 0 ? res[0] : {};
let address = location.regeocodeData && location.regeocodeData.addressComponent || {};
resolve({
latitude: location.latitude,
longitude: location.longitude,
city: address.city,
province: address.province,
district: address.district,
// streetNumber: address.streetNumber
})
},
fail: err => {
resolve({
...res,
city: '未知城市'
});
}
});
}).catch(err => {
console.log(err)
reject(err);
})
})
}
return Taro.getLocation(options);
}
}
export default {
getLocation
}
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="format-detection" content="telephone=no,address=no">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
<title></title>
<script>
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
import Taro from '@tarojs/taro';
function AMapWX(a) {
(this.key = a.key),
(this.requestConfig = {
key: a.key,
s: "rsx",
platform: "WXJS",
appname: a.key,
sdkversion: "1.2.0",
logversion: "2.0"
});
}
(AMapWX.prototype.getLocation = function(a, b) {
Taro.getLocation({
type: "gcj02",
success: function(a) {
var c = a.longitude + "," + a.latitude;
wx.setStorage({ key: "userLocation", data: c }), b(c);
},
fail: function(c) {
wx.getStorage({
key: "userLocation",
success: function(a) {
a.data && b(a.data);
}
}),
a.fail({ errCode: "0", errMsg: c.errMsg || "" });
}
});
}),
(AMapWX.prototype.getRegeo = function(a) {
function c(c) {
var d = b.requestConfig;
// 疑问
Taro.request({
url: "https://restapi.amap.com/v3/geocode/regeo",
data: {
key: b.key,
location: c,
extensions: "all",
s: d.s,
platform: d.platform,
appname: b.key,
sdkversion: d.sdkversion,
logversion: d.logversion
},
method: "GET",
header: { "content-type": "application/json" },
success: function(b) {
var d, e, f, g, h, i, j, k, l;
b.data.status && "1" == b.data.status
? ((d = b.data.regeocode),
(e = d.addressComponent),
(f = []),
(g = ""),
d &&
d.roads[0] &&
d.roads[0].name &&
(g = d.roads[0].name + "附近"),
(h = c.split(",")[0]),
(i = c.split(",")[1]),
d.pois &&
d.pois[0] &&
((g = d.pois[0].name + "附近"),
(j = d.pois[0].location),
j &&
((h = parseFloat(j.split(",")[0])),
(i = parseFloat(j.split(",")[1])))),
e.provice && f.push(e.provice),
e.city && f.push(e.city),
e.district && f.push(e.district),
e.streetNumber && e.streetNumber.street && e.streetNumber.number
? (f.push(e.streetNumber.street), f.push(e.streetNumber.number))
: ((k = ""),
d && d.roads[0] && d.roads[0].name && (k = d.roads[0].name),
f.push(k)),
(f = f.join("")),
(l = [
{
iconPath: a.iconPath,
width: a.iconWidth,
height: a.iconHeight,
name: f,
desc: g,
longitude: h,
latitude: i,
id: 0,
regeocodeData: d
}
]),
a.success(l))
: a.fail({ errCode: b.data.infocode, errMsg: b.data.info });
},
fail: function(b) {
a.fail({ errCode: "0", errMsg: b.errMsg || "" });
}
});
}
var b = this;
a.location
? c(a.location)
: b.getLocation(a, function(a) {
c(a);
});
});
(module.exports = AMapWX);
var CHAR_TILDE = 126;
var CODE_FNC1 = 102;
var SET_STARTA = 103;
var SET_STARTB = 104;
var SET_STARTC = 105;
var SET_SHIFT = 98;
var SET_CODEA = 101;
var SET_CODEB = 100;
var SET_STOP = 106;
var REPLACE_CODES = {
CHAR_TILDE: CODE_FNC1 //~ corresponds to FNC1 in GS1-128 standard
}
var CODESET = {
ANY: 1,
AB: 2,
A: 3,
B: 4,
C: 5
};
function getBytes(str) {
var bytes = [];
for (var i = 0; i < str.length; i++) {
bytes.push(str.charCodeAt(i));
}
return bytes;
}
exports.code128 = function (ctx, text, width, height) {
width = parseInt(width);
height = parseInt(height);
var codes = stringToCode128(text);
var g = new Graphics(ctx, width, height);
var barWeight = g.area.width / ((codes.length - 3) * 11 + 35);
var x = g.area.left;
var y = g.area.top;
for (var i = 0; i < codes.length; i++) {
var c = codes[i];
//two bars at a time: 1 black and 1 white
for (var bar = 0; bar < 8; bar += 2) {
var barW = PATTERNS[c][bar] * barWeight;
// var barH = height - y - this.border;
var barH = height - y;
var spcW = PATTERNS[c][bar + 1] * barWeight;
//no need to draw if 0 width
if (barW > 0) {
g.fillFgRect(x, y, barW, barH);
}
x += barW + spcW;
}
}
ctx.draw();
}
function stringToCode128(text) {
var barc = {
currcs: CODESET.C
};
var bytes = getBytes(text);
//decide starting codeset
var index = bytes[0] == CHAR_TILDE ? 1 : 0;
var csa1 = bytes.length > 0 ? codeSetAllowedFor(bytes[index++]) : CODESET.AB;
var csa2 = bytes.length > 0 ? codeSetAllowedFor(bytes[index++]) : CODESET.AB;
barc.currcs = getBestStartSet(csa1, csa2);
barc.currcs = perhapsCodeC(bytes, barc.currcs);
//if no codeset changes this will end up with bytes.length+3
//start, checksum and stop
var codes = new Array();
switch (barc.currcs) {
case CODESET.A:
codes.push(SET_STARTA);
break;
case CODESET.B:
codes.push(SET_STARTB);
break;
default:
codes.push(SET_STARTC);
break;
}
for (var i = 0; i < bytes.length; i++) {
var b1 = bytes[i]; //get the first of a pair
//should we translate/replace
if (b1 in REPLACE_CODES) {
codes.push(REPLACE_CODES[b1]);
i++ //jump to next
b1 = bytes[i];
}
//get the next in the pair if possible
var b2 = bytes.length > (i + 1) ? bytes[i + 1] : -1;
codes = codes.concat(codesForChar(b1, b2, barc.currcs));
//code C takes 2 chars each time
if (barc.currcs == CODESET.C) i++;
}
//calculate checksum according to Code 128 standards
var checksum = codes[0];
for (var weight = 1; weight < codes.length; weight++) {
checksum += (weight * codes[weight]);
}
codes.push(checksum % 103);
codes.push(SET_STOP);
//encoding should now be complete
return codes;
function getBestStartSet(csa1, csa2) {
//tries to figure out the best codeset
//to start with to get the most compact code
var vote = 0;
vote += csa1 == CODESET.A ? 1 : 0;
vote += csa1 == CODESET.B ? -1 : 0;
vote += csa2 == CODESET.A ? 1 : 0;
vote += csa2 == CODESET.B ? -1 : 0;
//tie goes to B due to my own predudices
return vote > 0 ? CODESET.A : CODESET.B;
}
function perhapsCodeC(bytes, codeset) {
for (var i = 0; i < bytes.length; i++) {
var b = bytes[i]
if ((b < 48 || b > 57) && b != CHAR_TILDE)
return codeset;
}
return CODESET.C;
}
//chr1 is current byte
//chr2 is the next byte to process. looks ahead.
function codesForChar(chr1, chr2, currcs) {
var result = [];
var shifter = -1;
if (charCompatible(chr1, currcs)) {
if (currcs == CODESET.C) {
if (chr2 == -1) {
shifter = SET_CODEB;
currcs = CODESET.B;
}
else if ((chr2 != -1) && !charCompatible(chr2, currcs)) {
//need to check ahead as well
if (charCompatible(chr2, CODESET.A)) {
shifter = SET_CODEA;
currcs = CODESET.A;
}
else {
shifter = SET_CODEB;
currcs = CODESET.B;
}
}
}
}
else {
//if there is a next char AND that next char is also not compatible
if ((chr2 != -1) && !charCompatible(chr2, currcs)) {
//need to switch code sets
switch (currcs) {
case CODESET.A:
shifter = SET_CODEB;
currcs = CODESET.B;
break;
case CODESET.B:
shifter = SET_CODEA;
currcs = CODESET.A;
break;
}
}
else {
//no need to shift code sets, a temporary SHIFT will suffice
shifter = SET_SHIFT;
}
}
//ok some type of shift is nessecary
if (shifter != -1) {
result.push(shifter);
result.push(codeValue(chr1));
}
else {
if (currcs == CODESET.C) {
//include next as well
result.push(codeValue(chr1, chr2));
}
else {
result.push(codeValue(chr1));
}
}
barc.currcs = currcs;
return result;
}
}
//reduce the ascii code to fit into the Code128 char table
function codeValue(chr1, chr2) {
if (typeof chr2 == "undefined") {
return chr1 >= 32 ? chr1 - 32 : chr1 + 64;
}
else {
return parseInt(String.fromCharCode(chr1) + String.fromCharCode(chr2));
}
}
function charCompatible(chr, codeset) {
var csa = codeSetAllowedFor(chr);
if (csa == CODESET.ANY) return true;
//if we need to change from current
if (csa == CODESET.AB) return true;
if (csa == CODESET.A && codeset == CODESET.A) return true;
if (csa == CODESET.B && codeset == CODESET.B) return true;
return false;
}
function codeSetAllowedFor(chr) {
if (chr >= 48 && chr <= 57) {
//0-9
return CODESET.ANY;
}
else if (chr >= 32 && chr <= 95) {
//0-9 A-Z
return CODESET.AB;
}
else {
//if non printable
return chr < 32 ? CODESET.A : CODESET.B;
}
}
var Graphics = function(ctx, width, height) {
this.width = width;
this.height = height;
this.quiet = Math.round(this.width / 40);
this.border_size = 0;
this.padding_width = 0;
this.area = {
width : width - this.padding_width * 2 - this.quiet * 2,
height: height - this.border_size * 2,
top : this.border_size - 4,
left : this.padding_width + this.quiet
};
this.ctx = ctx;
this.fg = "#000000";
this.bg = "#ffffff";
// fill background
this.fillBgRect(0,0, width, height);
// fill center to create border
this.fillBgRect(0, this.border_size, width, height - this.border_size * 2);
}
//use native color
Graphics.prototype._fillRect = function(x, y, width, height, color) {
this.ctx.setFillStyle(color)
this.ctx.fillRect(x, y, width, height)
}
Graphics.prototype.fillFgRect = function(x,y, width, height) {
this._fillRect(x, y, width, height, this.fg);
}
Graphics.prototype.fillBgRect = function(x,y, width, height) {
this._fillRect(x, y, width, height, this.bg);
}
var PATTERNS = [
[2, 1, 2, 2, 2, 2, 0, 0], // 0
[2, 2, 2, 1, 2, 2, 0, 0], // 1
[2, 2, 2, 2, 2, 1, 0, 0], // 2
[1, 2, 1, 2, 2, 3, 0, 0], // 3
[1, 2, 1, 3, 2, 2, 0, 0], // 4
[1, 3, 1, 2, 2, 2, 0, 0], // 5
[1, 2, 2, 2, 1, 3, 0, 0], // 6
[1, 2, 2, 3, 1, 2, 0, 0], // 7
[1, 3, 2, 2, 1, 2, 0, 0], // 8
[2, 2, 1, 2, 1, 3, 0, 0], // 9
[2, 2, 1, 3, 1, 2, 0, 0], // 10
[2, 3, 1, 2, 1, 2, 0, 0], // 11
[1, 1, 2, 2, 3, 2, 0, 0], // 12
[1, 2, 2, 1, 3, 2, 0, 0], // 13
[1, 2, 2, 2, 3, 1, 0, 0], // 14
[1, 1, 3, 2, 2, 2, 0, 0], // 15
[1, 2, 3, 1, 2, 2, 0, 0], // 16
[1, 2, 3, 2, 2, 1, 0, 0], // 17
[2, 2, 3, 2, 1, 1, 0, 0], // 18
[2, 2, 1, 1, 3, 2, 0, 0], // 19
[2, 2, 1, 2, 3, 1, 0, 0], // 20
[2, 1, 3, 2, 1, 2, 0, 0], // 21
[2, 2, 3, 1, 1, 2, 0, 0], // 22
[3, 1, 2, 1, 3, 1, 0, 0], // 23
[3, 1, 1, 2, 2, 2, 0, 0], // 24
[3, 2, 1, 1, 2, 2, 0, 0], // 25
[3, 2, 1, 2, 2, 1, 0, 0], // 26
[3, 1, 2, 2, 1, 2, 0, 0], // 27
[3, 2, 2, 1, 1, 2, 0, 0], // 28
[3, 2, 2, 2, 1, 1, 0, 0], // 29
[2, 1, 2, 1, 2, 3, 0, 0], // 30
[2, 1, 2, 3, 2, 1, 0, 0], // 31
[2, 3, 2, 1, 2, 1, 0, 0], // 32
[1, 1, 1, 3, 2, 3, 0, 0], // 33
[1, 3, 1, 1, 2, 3, 0, 0], // 34
[1, 3, 1, 3, 2, 1, 0, 0], // 35
[1, 1, 2, 3, 1, 3, 0, 0], // 36
[1, 3, 2, 1, 1, 3, 0, 0], // 37
[1, 3, 2, 3, 1, 1, 0, 0], // 38
[2, 1, 1, 3, 1, 3, 0, 0], // 39
[2, 3, 1, 1, 1, 3, 0, 0], // 40
[2, 3, 1, 3, 1, 1, 0, 0], // 41
[1, 1, 2, 1, 3, 3, 0, 0], // 42
[1, 1, 2, 3, 3, 1, 0, 0], // 43
[1, 3, 2, 1, 3, 1, 0, 0], // 44
[1, 1, 3, 1, 2, 3, 0, 0], // 45
[1, 1, 3, 3, 2, 1, 0, 0], // 46
[1, 3, 3, 1, 2, 1, 0, 0], // 47
[3, 1, 3, 1, 2, 1, 0, 0], // 48
[2, 1, 1, 3, 3, 1, 0, 0], // 49
[2, 3, 1, 1, 3, 1, 0, 0], // 50
[2, 1, 3, 1, 1, 3, 0, 0], // 51
[2, 1, 3, 3, 1, 1, 0, 0], // 52
[2, 1, 3, 1, 3, 1, 0, 0], // 53
[3, 1, 1, 1, 2, 3, 0, 0], // 54
[3, 1, 1, 3, 2, 1, 0, 0], // 55
[3, 3, 1, 1, 2, 1, 0, 0], // 56
[3, 1, 2, 1, 1, 3, 0, 0], // 57
[3, 1, 2, 3, 1, 1, 0, 0], // 58
[3, 3, 2, 1, 1, 1, 0, 0], // 59
[3, 1, 4, 1, 1, 1, 0, 0], // 60
[2, 2, 1, 4, 1, 1, 0, 0], // 61
[4, 3, 1, 1, 1, 1, 0, 0], // 62
[1, 1, 1, 2, 2, 4, 0, 0], // 63
[1, 1, 1, 4, 2, 2, 0, 0], // 64
[1, 2, 1, 1, 2, 4, 0, 0], // 65
[1, 2, 1, 4, 2, 1, 0, 0], // 66
[1, 4, 1, 1, 2, 2, 0, 0], // 67
[1, 4, 1, 2, 2, 1, 0, 0], // 68
[1, 1, 2, 2, 1, 4, 0, 0], // 69
[1, 1, 2, 4, 1, 2, 0, 0], // 70
[1, 2, 2, 1, 1, 4, 0, 0], // 71
[1, 2, 2, 4, 1, 1, 0, 0], // 72
[1, 4, 2, 1, 1, 2, 0, 0], // 73
[1, 4, 2, 2, 1, 1, 0, 0], // 74
[2, 4, 1, 2, 1, 1, 0, 0], // 75
[2, 2, 1, 1, 1, 4, 0, 0], // 76
[4, 1, 3, 1, 1, 1, 0, 0], // 77
[2, 4, 1, 1, 1, 2, 0, 0], // 78
[1, 3, 4, 1, 1, 1, 0, 0], // 79
[1, 1, 1, 2, 4, 2, 0, 0], // 80
[1, 2, 1, 1, 4, 2, 0, 0], // 81
[1, 2, 1, 2, 4, 1, 0, 0], // 82
[1, 1, 4, 2, 1, 2, 0, 0], // 83
[1, 2, 4, 1, 1, 2, 0, 0], // 84
[1, 2, 4, 2, 1, 1, 0, 0], // 85
[4, 1, 1, 2, 1, 2, 0, 0], // 86
[4, 2, 1, 1, 1, 2, 0, 0], // 87
[4, 2, 1, 2, 1, 1, 0, 0], // 88
[2, 1, 2, 1, 4, 1, 0, 0], // 89
[2, 1, 4, 1, 2, 1, 0, 0], // 90
[4, 1, 2, 1, 2, 1, 0, 0], // 91
[1, 1, 1, 1, 4, 3, 0, 0], // 92
[1, 1, 1, 3, 4, 1, 0, 0], // 93
[1, 3, 1, 1, 4, 1, 0, 0], // 94
[1, 1, 4, 1, 1, 3, 0, 0], // 95
[1, 1, 4, 3, 1, 1, 0, 0], // 96
[4, 1, 1, 1, 1, 3, 0, 0], // 97
[4, 1, 1, 3, 1, 1, 0, 0], // 98
[1, 1, 3, 1, 4, 1, 0, 0], // 99
[1, 1, 4, 1, 3, 1, 0, 0], // 100
[3, 1, 1, 1, 4, 1, 0, 0], // 101
[4, 1, 1, 1, 3, 1, 0, 0], // 102
[2, 1, 1, 4, 1, 2, 0, 0], // 103
[2, 1, 1, 2, 1, 4, 0, 0], // 104
[2, 1, 1, 2, 3, 2, 0, 0], // 105
[2, 3, 3, 1, 1, 1, 2, 0] // 106
]
var QR = (function () {
// alignment pattern
var adelta = [
0, 11, 15, 19, 23, 27, 31, // force 1 pat
16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,
26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28
];
// version block
var vpat = [
0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d,
0x928, 0xb78, 0x45d, 0xa17, 0x532, 0x9a6, 0x683, 0x8c9,
0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75,
0x250, 0x9d5, 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64,
0x541, 0xc69
];
// final format bits with mask: level << 3 | mask
var fmtword = [
0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, //L
0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, //M
0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, //Q
0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b //H
];
// 4 per version: number of blocks 1,2; data width; ecc width
var eccblocks = [
1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17,
1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28,
1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22,
1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16,
1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22,
2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28,
2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26,
2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26,
2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24,
2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28,
4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24,
2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28,
4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22,
3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24,
5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24,
5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30,
1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28,
5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28,
3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26,
3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28,
4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30,
2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24,
4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30,
6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30,
8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30,
10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30,
8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30,
3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30,
7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30,
5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30,
13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30,
17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30,
17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30,
13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30,
12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30,
6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30,
17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30,
4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30,
20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30,
19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30
];
// Galois field log table
var glog = [
0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,
0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71,
0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45,
0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6,
0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88,
0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40,
0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d,
0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57,
0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18,
0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e,
0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61,
0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2,
0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,
0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,
0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,
0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf
];
// Galios field exponent table
var gexp = [
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,
0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,
0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,
0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1,
0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0,
0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2,
0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce,
0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc,
0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54,
0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73,
0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff,
0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41,
0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6,
0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09,
0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,
0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00
];
// Working buffers:
// data input and ecc append, image working buffer, fixed part of image, run lengths for badness
var strinbuf=[], eccbuf=[], qrframe=[], framask=[], rlens=[];
// Control values - width is based on version, last 4 are from table.
var version, width, neccblk1, neccblk2, datablkw, eccblkwid;
var ecclevel = 2;
// set bit to indicate cell in qrframe is immutable. symmetric around diagonal
function setmask(x, y)
{
var bt;
if (x > y) {
bt = x;
x = y;
y = bt;
}
// y*y = 1+3+5...
bt = y;
bt *= y;
bt += y;
bt >>= 1;
bt += x;
framask[bt] = 1;
}
// enter alignment pattern - black to qrframe, white to mask (later black frame merged to mask)
function putalign(x, y)
{
var j;
qrframe[x + width * y] = 1;
for (j = -2; j < 2; j++) {
qrframe[(x + j) + width * (y - 2)] = 1;
qrframe[(x - 2) + width * (y + j + 1)] = 1;
qrframe[(x + 2) + width * (y + j)] = 1;
qrframe[(x + j + 1) + width * (y + 2)] = 1;
}
for (j = 0; j < 2; j++) {
setmask(x - 1, y + j);
setmask(x + 1, y - j);
setmask(x - j, y - 1);
setmask(x + j, y + 1);
}
}
//========================================================================
// Reed Solomon error correction
// exponentiation mod N
function modnn(x)
{
while (x >= 255) {
x -= 255;
x = (x >> 8) + (x & 255);
}
return x;
}
var genpoly = [];
// Calculate and append ECC data to data block. Block is in strinbuf, indexes to buffers given.
function appendrs(data, dlen, ecbuf, eclen)
{
var i, j, fb;
for (i = 0; i < eclen; i++)
strinbuf[ecbuf + i] = 0;
for (i = 0; i < dlen; i++) {
fb = glog[strinbuf[data + i] ^ strinbuf[ecbuf]];
if (fb != 255) /* fb term is non-zero */
for (j = 1; j < eclen; j++)
strinbuf[ecbuf + j - 1] = strinbuf[ecbuf + j] ^ gexp[modnn(fb + genpoly[eclen - j])];
else
for( j = ecbuf ; j < ecbuf + eclen; j++ )
strinbuf[j] = strinbuf[j + 1];
strinbuf[ ecbuf + eclen - 1] = fb == 255 ? 0 : gexp[modnn(fb + genpoly[0])];
}
}
//========================================================================
// Frame data insert following the path rules
// check mask - since symmetrical use half.
function ismasked(x, y)
{
var bt;
if (x > y) {
bt = x;
x = y;
y = bt;
}
bt = y;
bt += y * y;
bt >>= 1;
bt += x;
return framask[bt];
}
//========================================================================
// Apply the selected mask out of the 8.
function applymask(m)
{
var x, y, r3x, r3y;
switch (m) {
case 0:
for (y = 0; y < width; y++)
for (x = 0; x < width; x++)
if (!((x + y) & 1) && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
break;
case 1:
for (y = 0; y < width; y++)
for (x = 0; x < width; x++)
if (!(y & 1) && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
break;
case 2:
for (y = 0; y < width; y++)
for (r3x = 0, x = 0; x < width; x++, r3x++) {
if (r3x == 3)
r3x = 0;
if (!r3x && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
}
break;
case 3:
for (r3y = 0, y = 0; y < width; y++, r3y++) {
if (r3y == 3)
r3y = 0;
for (r3x = r3y, x = 0; x < width; x++, r3x++) {
if (r3x == 3)
r3x = 0;
if (!r3x && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
}
}
break;
case 4:
for (y = 0; y < width; y++)
for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++, r3x++) {
if (r3x == 3) {
r3x = 0;
r3y = !r3y;
}
if (!r3y && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
}
break;
case 5:
for (r3y = 0, y = 0; y < width; y++, r3y++) {
if (r3y == 3)
r3y = 0;
for (r3x = 0, x = 0; x < width; x++, r3x++) {
if (r3x == 3)
r3x = 0;
if (!((x & y & 1) + !(!r3x | !r3y)) && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
}
}
break;
case 6:
for (r3y = 0, y = 0; y < width; y++, r3y++) {
if (r3y == 3)
r3y = 0;
for (r3x = 0, x = 0; x < width; x++, r3x++) {
if (r3x == 3)
r3x = 0;
if (!(((x & y & 1) + (r3x && (r3x == r3y))) & 1) && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
}
}
break;
case 7:
for (r3y = 0, y = 0; y < width; y++, r3y++) {
if (r3y == 3)
r3y = 0;
for (r3x = 0, x = 0; x < width; x++, r3x++) {
if (r3x == 3)
r3x = 0;
if (!(((r3x && (r3x == r3y)) + ((x + y) & 1)) & 1) && !ismasked(x, y))
qrframe[x + y * width] ^= 1;
}
}
break;
}
return;
}
// Badness coefficients.
var N1 = 3, N2 = 3, N3 = 40, N4 = 10;
// Using the table of the length of each run, calculate the amount of bad image
// - long runs or those that look like finders; called twice, once each for X and Y
function badruns(length)
{
var i;
var runsbad = 0;
for (i = 0; i <= length; i++)
if (rlens[i] >= 5)
runsbad += N1 + rlens[i] - 5;
// BwBBBwB as in finder
for (i = 3; i < length - 1; i += 2)
if (rlens[i - 2] == rlens[i + 2]
&& rlens[i + 2] == rlens[i - 1]
&& rlens[i - 1] == rlens[i + 1]
&& rlens[i - 1] * 3 == rlens[i]
// white around the black pattern? Not part of spec
&& (rlens[i - 3] == 0 // beginning
|| i + 3 > length // end
|| rlens[i - 3] * 3 >= rlens[i] * 4 || rlens[i + 3] * 3 >= rlens[i] * 4)
)
runsbad += N3;
return runsbad;
}
// Calculate how bad the masked image is - blocks, imbalance, runs, or finders.
function badcheck()
{
var x, y, h, b, b1;
var thisbad = 0;
var bw = 0;
// blocks of same color.
for (y = 0; y < width - 1; y++)
for (x = 0; x < width - 1; x++)
if ((qrframe[x + width * y] && qrframe[(x + 1) + width * y]
&& qrframe[x + width * (y + 1)] && qrframe[(x + 1) + width * (y + 1)]) // all black
|| !(qrframe[x + width * y] || qrframe[(x + 1) + width * y]
|| qrframe[x + width * (y + 1)] || qrframe[(x + 1) + width * (y + 1)])) // all white
thisbad += N2;
// X runs
for (y = 0; y < width; y++) {
rlens[0] = 0;
for (h = b = x = 0; x < width; x++) {
if ((b1 = qrframe[x + width * y]) == b)
rlens[h]++;
else
rlens[++h] = 1;
b = b1;
bw += b ? 1 : -1;
}
thisbad += badruns(h);
}
// black/white imbalance
if (bw < 0)
bw = -bw;
var big = bw;
var count = 0;
big += big << 2;
big <<= 1;
while (big > width * width)
big -= width * width, count++;
thisbad += count * N4;
// Y runs
for (x = 0; x < width; x++) {
rlens[0] = 0;
for (h = b = y = 0; y < width; y++) {
if ((b1 = qrframe[x + width * y]) == b)
rlens[h]++;
else
rlens[++h] = 1;
b = b1;
}
thisbad += badruns(h);
}
return thisbad;
}
function genframe(instring)
{
var x, y, k, t, v, i, j, m;
// find the smallest version that fits the string
t = instring.length;
version = 0;
do {
version++;
k = (ecclevel - 1) * 4 + (version - 1) * 16;
neccblk1 = eccblocks[k++];
neccblk2 = eccblocks[k++];
datablkw = eccblocks[k++];
eccblkwid = eccblocks[k];
k = datablkw * (neccblk1 + neccblk2) + neccblk2 - 3 + (version <= 9);
if (t <= k)
break;
} while (version < 40);
// FIXME - insure that it fits insted of being truncated
width = 17 + 4 * version;
// allocate, clear and setup data structures
v = datablkw + (datablkw + eccblkwid) * (neccblk1 + neccblk2) + neccblk2;
for( t = 0; t < v; t++ )
eccbuf[t] = 0;
strinbuf = instring.slice(0);
for( t = 0; t < width * width; t++ )
qrframe[t] = 0;
for( t = 0 ; t < (width * (width + 1) + 1) / 2; t++)
framask[t] = 0;
// insert finders - black to frame, white to mask
for (t = 0; t < 3; t++) {
k = 0;
y = 0;
if (t == 1)
k = (width - 7);
if (t == 2)
y = (width - 7);
qrframe[(y + 3) + width * (k + 3)] = 1;
for (x = 0; x < 6; x++) {
qrframe[(y + x) + width * k] = 1;
qrframe[y + width * (k + x + 1)] = 1;
qrframe[(y + 6) + width * (k + x)] = 1;
qrframe[(y + x + 1) + width * (k + 6)] = 1;
}
for (x = 1; x < 5; x++) {
setmask(y + x, k + 1);
setmask(y + 1, k + x + 1);
setmask(y + 5, k + x);
setmask(y + x + 1, k + 5);
}
for (x = 2; x < 4; x++) {
qrframe[(y + x) + width * (k + 2)] = 1;
qrframe[(y + 2) + width * (k + x + 1)] = 1;
qrframe[(y + 4) + width * (k + x)] = 1;
qrframe[(y + x + 1) + width * (k + 4)] = 1;
}
}
// alignment blocks
if (version > 1) {
t = adelta[version];
y = width - 7;
for (;;) {
x = width - 7;
while (x > t - 3) {
putalign(x, y);
if (x < t)
break;
x -= t;
}
if (y <= t + 9)
break;
y -= t;
putalign(6, y);
putalign(y, 6);
}
}
// single black
qrframe[8 + width * (width - 8)] = 1;
// timing gap - mask only
for (y = 0; y < 7; y++) {
setmask(7, y);
setmask(width - 8, y);
setmask(7, y + width - 7);
}
for (x = 0; x < 8; x++) {
setmask(x, 7);
setmask(x + width - 8, 7);
setmask(x, width - 8);
}
// reserve mask-format area
for (x = 0; x < 9; x++)
setmask(x, 8);
for (x = 0; x < 8; x++) {
setmask(x + width - 8, 8);
setmask(8, x);
}
for (y = 0; y < 7; y++)
setmask(8, y + width - 7);
// timing row/col
for (x = 0; x < width - 14; x++)
if (x & 1) {
setmask(8 + x, 6);
setmask(6, 8 + x);
}
else {
qrframe[(8 + x) + width * 6] = 1;
qrframe[6 + width * (8 + x)] = 1;
}
// version block
if (version > 6) {
t = vpat[version - 7];
k = 17;
for (x = 0; x < 6; x++)
for (y = 0; y < 3; y++, k--)
if (1 & (k > 11 ? version >> (k - 12) : t >> k)) {
qrframe[(5 - x) + width * (2 - y + width - 11)] = 1;
qrframe[(2 - y + width - 11) + width * (5 - x)] = 1;
}
else {
setmask(5 - x, 2 - y + width - 11);
setmask(2 - y + width - 11, 5 - x);
}
}
// sync mask bits - only set above for white spaces, so add in black bits
for (y = 0; y < width; y++)
for (x = 0; x <= y; x++)
if (qrframe[x + width * y])
setmask(x, y);
// convert string to bitstream
// 8 bit data to QR-coded 8 bit data (numeric or alphanum, or kanji not supported)
v = strinbuf.length;
// string to array
for( i = 0 ; i < v; i++ )
eccbuf[i] = strinbuf.charCodeAt(i);
strinbuf = eccbuf.slice(0);
// calculate max string length
x = datablkw * (neccblk1 + neccblk2) + neccblk2;
if (v >= x - 2) {
v = x - 2;
if (version > 9)
v--;
}
// shift and repack to insert length prefix
i = v;
if (version > 9) {
strinbuf[i + 2] = 0;
strinbuf[i + 3] = 0;
while (i--) {
t = strinbuf[i];
strinbuf[i + 3] |= 255 & (t << 4);
strinbuf[i + 2] = t >> 4;
}
strinbuf[2] |= 255 & (v << 4);
strinbuf[1] = v >> 4;
strinbuf[0] = 0x40 | (v >> 12);
}
else {
strinbuf[i + 1] = 0;
strinbuf[i + 2] = 0;
while (i--) {
t = strinbuf[i];
strinbuf[i + 2] |= 255 & (t << 4);
strinbuf[i + 1] = t >> 4;
}
strinbuf[1] |= 255 & (v << 4);
strinbuf[0] = 0x40 | (v >> 4);
}
// fill to end with pad pattern
i = v + 3 - (version < 10);
while (i < x) {
strinbuf[i++] = 0xec;
// buffer has room if (i == x) break;
strinbuf[i++] = 0x11;
}
// calculate and append ECC
// calculate generator polynomial
genpoly[0] = 1;
for (i = 0; i < eccblkwid; i++) {
genpoly[i + 1] = 1;
for (j = i; j > 0; j--)
genpoly[j] = genpoly[j]
? genpoly[j - 1] ^ gexp[modnn(glog[genpoly[j]] + i)] : genpoly[j - 1];
genpoly[0] = gexp[modnn(glog[genpoly[0]] + i)];
}
for (i = 0; i <= eccblkwid; i++)
genpoly[i] = glog[genpoly[i]]; // use logs for genpoly[] to save calc step
// append ecc to data buffer
k = x;
y = 0;
for (i = 0; i < neccblk1; i++) {
appendrs(y, datablkw, k, eccblkwid);
y += datablkw;
k += eccblkwid;
}
for (i = 0; i < neccblk2; i++) {
appendrs(y, datablkw + 1, k, eccblkwid);
y += datablkw + 1;
k += eccblkwid;
}
// interleave blocks
y = 0;
for (i = 0; i < datablkw; i++) {
for (j = 0; j < neccblk1; j++)
eccbuf[y++] = strinbuf[i + j * datablkw];
for (j = 0; j < neccblk2; j++)
eccbuf[y++] = strinbuf[(neccblk1 * datablkw) + i + (j * (datablkw + 1))];
}
for (j = 0; j < neccblk2; j++)
eccbuf[y++] = strinbuf[(neccblk1 * datablkw) + i + (j * (datablkw + 1))];
for (i = 0; i < eccblkwid; i++)
for (j = 0; j < neccblk1 + neccblk2; j++)
eccbuf[y++] = strinbuf[x + i + j * eccblkwid];
strinbuf = eccbuf;
// pack bits into frame avoiding masked area.
x = y = width - 1;
k = v = 1; // up, minus
/* inteleaved data and ecc codes */
m = (datablkw + eccblkwid) * (neccblk1 + neccblk2) + neccblk2;
for (i = 0; i < m; i++) {
t = strinbuf[i];
for (j = 0; j < 8; j++, t <<= 1) {
if (0x80 & t)
qrframe[x + width * y] = 1;
do { // find next fill position
if (v)
x--;
else {
x++;
if (k) {
if (y != 0)
y--;
else {
x -= 2;
k = !k;
if (x == 6) {
x--;
y = 9;
}
}
}
else {
if (y != width - 1)
y++;
else {
x -= 2;
k = !k;
if (x == 6) {
x--;
y -= 8;
}
}
}
}
v = !v;
} while (ismasked(x, y));
}
}
// save pre-mask copy of frame
strinbuf = qrframe.slice(0);
t = 0; // best
y = 30000; // demerit
// for instead of while since in original arduino code
// if an early mask was "good enough" it wouldn't try for a better one
// since they get more complex and take longer.
for (k = 0; k < 8; k++) {
applymask(k); // returns black-white imbalance
x = badcheck();
if (x < y) { // current mask better than previous best?
y = x;
t = k;
}
if (t == 7)
break; // don't increment i to a void redoing mask
qrframe = strinbuf.slice(0); // reset for next pass
}
if (t != k) // redo best mask - none good enough, last wasn't t
applymask(t);
// add in final mask/ecclevel bytes
y = fmtword[t + ((ecclevel - 1) << 3)];
// low byte
for (k = 0; k < 8; k++, y >>= 1)
if (y & 1) {
qrframe[(width - 1 - k) + width * 8] = 1;
if (k < 6)
qrframe[8 + width * k] = 1;
else
qrframe[8 + width * (k + 1)] = 1;
}
// high byte
for (k = 0; k < 7; k++, y >>= 1)
if (y & 1) {
qrframe[8 + width * (width - 7 + k)] = 1;
if (k)
qrframe[(6 - k) + width * 8] = 1;
else
qrframe[7 + width * 8] = 1;
}
// return image
return qrframe;
}
var _canvas = null,
_size = null;
var api = {
get ecclevel () {
return ecclevel;
},
set ecclevel (val) {
ecclevel = val;
},
get size () {
return _size;
},
set size (val) {
_size = val
},
get canvas () {
return _canvas;
},
set canvas (el) {
_canvas = el;
},
getFrame: function (string) {
return genframe(string);
},
draw: function (string, canvas, size, ecc) {
ecclevel = ecc || ecclevel;
canvas = canvas || _canvas;
if (!canvas) {
console.warn('No canvas provided to draw QR code in!')
return;
}
size = size || _size || Math.min(canvas.width, canvas.height);
var frame = genframe(string),
ctx = canvas.ctx,
px = Math.round(size / (width + 8));
var roundedSize = px * (width + 8),
offset = Math.floor((size - roundedSize) / 2);
size = roundedSize;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.setFillStyle('#000000');
for (var i = 0; i < width; i++) {
for (var j = 0; j < width; j++) {
if (frame[j * width + i]) {
ctx.fillRect(px * (4 + i) + offset, px * (4 + j) + offset, px, px);
}
}
}
ctx.draw();
}
}
module.exports = {
api: api
}
})()
import Taro from '@tarojs/taro';
var barcode = require('./barcode');
// var qrcode = require('./qrcode');
function barc(canvas, code, width, height) {
barcode.code128(canvas, code, Taro.convertRpxToPx(width), Taro.convertRpxToPx(height))
}
// function qrc(id, code, width, height) {
// qrcode.api.draw(code, {
// ctx: wx.createCanvasContext(id),
// width: convert_length(width),
// height: convert_length(height)
// })
// }
module.exports = {
barcode: barc,
// qrcode: qrc
}
;(function(){
var UPNG = {};
var pako = require('./pako.min.js');
module.exports = UPNG;
(function(UPNG, pako){
UPNG.toRGBA8 = function(out)
{
var w = out.width, h = out.height;
if(out.tabs.acTL==null) return [UPNG.toRGBA8.decodeImage(out.data, w, h, out).buffer];
var frms = [];
if(out.frames[0].data==null) out.frames[0].data = out.data;
var img, empty = new Uint8Array(w*h*4);
for(var i=0; i<out.frames.length; i++)
{
var frm = out.frames[i];
var fx=frm.rect.x, fy=frm.rect.y, fw = frm.rect.width, fh = frm.rect.height;
var fdata = UPNG.toRGBA8.decodeImage(frm.data, fw,fh, out);
if(i==0) img = fdata;
else if(frm.blend ==0) UPNG._copyTile(fdata, fw, fh, img, w, h, fx, fy, 0);
else if(frm.blend ==1) UPNG._copyTile(fdata, fw, fh, img, w, h, fx, fy, 1);
frms.push(img.buffer); img = img.slice(0);
if (frm.dispose==0) {}
else if(frm.dispose==1) UPNG._copyTile(empty, fw, fh, img, w, h, fx, fy, 0);
else if(frm.dispose==2) {
var pi = i-1;
while(out.frames[pi].dispose==2) pi--;
img = new Uint8Array(frms[pi]).slice(0);
}
}
return frms;
}
UPNG.toRGBA8.decodeImage = function(data, w, h, out)
{
var area = w*h, bpp = UPNG.decode._getBPP(out);
var bpl = Math.ceil(w*bpp/8); // bytes per line
var bf = new Uint8Array(area*4), bf32 = new Uint32Array(bf.buffer);
var ctype = out.ctype, depth = out.depth;
var rs = UPNG._bin.readUshort;
//console.log(ctype, depth);
if (ctype==6) { // RGB + alpha
var qarea = area<<2;
if(depth== 8) for(var i=0; i<qarea;i++) { bf[i] = data[i]; /*if((i&3)==3 && data[i]!=0) bf[i]=255;*/ }
if(depth==16) for(var i=0; i<qarea;i++) { bf[i] = data[i<<1]; }
}
else if(ctype==2) { // RGB
var ts=out.tabs["tRNS"], tr=-1, tg=-1, tb=-1;
if(ts) { tr=ts[0]; tg=ts[1]; tb=ts[2]; }
if(depth== 8) for(var i=0; i<area; i++) { var qi=i<<2, ti=i*3; bf[qi] = data[ti]; bf[qi+1] = data[ti+1]; bf[qi+2] = data[ti+2]; bf[qi+3] = 255;
if(tr!=-1 && data[ti] ==tr && data[ti+1] ==tg && data[ti+2] ==tb) bf[qi+3] = 0; }
if(depth==16) for(var i=0; i<area; i++) { var qi=i<<2, ti=i*6; bf[qi] = data[ti]; bf[qi+1] = data[ti+2]; bf[qi+2] = data[ti+4]; bf[qi+3] = 255;
if(tr!=-1 && rs(data,ti)==tr && rs(data,ti+2)==tg && rs(data,ti+4)==tb) bf[qi+3] = 0; }
}
else if(ctype==3) { // palette
var p=out.tabs["PLTE"], ap=out.tabs["tRNS"], tl=ap?ap.length:0;
//console.log(p, ap);
if(depth==1) for(var y=0; y<h; y++) { var s0 = y*bpl, t0 = y*w;
for(var i=0; i<w; i++) { var qi=(t0+i)<<2, j=((data[s0+(i>>3)]>>(7-((i&7)<<0)))& 1), cj=3*j; bf[qi]=p[cj]; bf[qi+1]=p[cj+1]; bf[qi+2]=p[cj+2]; bf[qi+3]=(j<tl)?ap[j]:255; }
}
if(depth==2) for(var y=0; y<h; y++) { var s0 = y*bpl, t0 = y*w;
for(var i=0; i<w; i++) { var qi=(t0+i)<<2, j=((data[s0+(i>>2)]>>(6-((i&3)<<1)))& 3), cj=3*j; bf[qi]=p[cj]; bf[qi+1]=p[cj+1]; bf[qi+2]=p[cj+2]; bf[qi+3]=(j<tl)?ap[j]:255; }
}
if(depth==4) for(var y=0; y<h; y++) { var s0 = y*bpl, t0 = y*w;
for(var i=0; i<w; i++) { var qi=(t0+i)<<2, j=((data[s0+(i>>1)]>>(4-((i&1)<<2)))&15), cj=3*j; bf[qi]=p[cj]; bf[qi+1]=p[cj+1]; bf[qi+2]=p[cj+2]; bf[qi+3]=(j<tl)?ap[j]:255; }
}
if(depth==8) for(var i=0; i<area; i++ ) { var qi=i<<2, j=data[i] , cj=3*j; bf[qi]=p[cj]; bf[qi+1]=p[cj+1]; bf[qi+2]=p[cj+2]; bf[qi+3]=(j<tl)?ap[j]:255; }
}
else if(ctype==4) { // gray + alpha
if(depth== 8) for(var i=0; i<area; i++) { var qi=i<<2, di=i<<1, gr=data[di]; bf[qi]=gr; bf[qi+1]=gr; bf[qi+2]=gr; bf[qi+3]=data[di+1]; }
if(depth==16) for(var i=0; i<area; i++) { var qi=i<<2, di=i<<2, gr=data[di]; bf[qi]=gr; bf[qi+1]=gr; bf[qi+2]=gr; bf[qi+3]=data[di+2]; }
}
else if(ctype==0) { // gray
var tr = out.tabs["tRNS"] ? out.tabs["tRNS"] : -1;
if(depth== 1) for(var i=0; i<area; i++) { var gr=255*((data[i>>3]>>(7 -((i&7) )))& 1), al=(gr==tr*255)?0:255; bf32[i]=(al<<24)|(gr<<16)|(gr<<8)|gr; }
if(depth== 2) for(var i=0; i<area; i++) { var gr= 85*((data[i>>2]>>(6 -((i&3)<<1)))& 3), al=(gr==tr* 85)?0:255; bf32[i]=(al<<24)|(gr<<16)|(gr<<8)|gr; }
if(depth== 4) for(var i=0; i<area; i++) { var gr= 17*((data[i>>1]>>(4 -((i&1)<<2)))&15), al=(gr==tr* 17)?0:255; bf32[i]=(al<<24)|(gr<<16)|(gr<<8)|gr; }
if(depth== 8) for(var i=0; i<area; i++) { var gr=data[i ] , al=(gr ==tr)?0:255; bf32[i]=(al<<24)|(gr<<16)|(gr<<8)|gr; }
if(depth==16) for(var i=0; i<area; i++) { var gr=data[i<<1], al=(rs(data,i<<1)==tr)?0:255; bf32[i]=(al<<24)|(gr<<16)|(gr<<8)|gr; }
}
return bf;
}
UPNG.decode = function(buff)
{
var data = new Uint8Array(buff), offset = 8, bin = UPNG._bin, rUs = bin.readUshort, rUi = bin.readUint;
var out = {tabs:{}, frames:[]};
var dd = new Uint8Array(data.length), doff = 0; // put all IDAT data into it
var fd, foff = 0; // frames
var mgck = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
for(var i=0; i<8; i++) if(data[i]!=mgck[i]) throw "The input is not a PNG file!";
while(offset<data.length)
{
var len = bin.readUint(data, offset); offset += 4;
var type = bin.readASCII(data, offset, 4); offset += 4;
//log(type,len);
if (type=="IHDR") { UPNG.decode._IHDR(data, offset, out); }
else if(type=="IDAT") {
for(var i=0; i<len; i++) dd[doff+i] = data[offset+i];
doff += len;
}
else if(type=="acTL") {
out.tabs[type] = { num_frames:rUi(data, offset), num_plays:rUi(data, offset+4) };
fd = new Uint8Array(data.length);
}
else if(type=="fcTL") {
if(foff!=0) { var fr = out.frames[out.frames.length-1];
fr.data = UPNG.decode._decompress(out, fd.slice(0,foff), fr.rect.width, fr.rect.height); foff=0;
}
var rct = {x:rUi(data, offset+12),y:rUi(data, offset+16),width:rUi(data, offset+4),height:rUi(data, offset+8)};
var del = rUs(data, offset+22); del = rUs(data, offset+20) / (del==0?100:del);
var frm = {rect:rct, delay:Math.round(del*1000), dispose:data[offset+24], blend:data[offset+25]};
//console.log(frm);
out.frames.push(frm);
}
else if(type=="fdAT") {
for(var i=0; i<len-4; i++) fd[foff+i] = data[offset+i+4];
foff += len-4;
}
else if(type=="pHYs") {
out.tabs[type] = [bin.readUint(data, offset), bin.readUint(data, offset+4), data[offset+8]];
}
else if(type=="cHRM") {
out.tabs[type] = [];
for(var i=0; i<8; i++) out.tabs[type].push(bin.readUint(data, offset+i*4));
}
else if(type=="tEXt") {
if(out.tabs[type]==null) out.tabs[type] = {};
var nz = bin.nextZero(data, offset);
var keyw = bin.readASCII(data, offset, nz-offset);
var text = bin.readASCII(data, nz+1, offset+len-nz-1);
out.tabs[type][keyw] = text;
}
else if(type=="iTXt") {
if(out.tabs[type]==null) out.tabs[type] = {};
var nz = 0, off = offset;
nz = bin.nextZero(data, off);
var keyw = bin.readASCII(data, off, nz-off); off = nz + 1;
var cflag = data[off], cmeth = data[off+1]; off+=2;
nz = bin.nextZero(data, off);
var ltag = bin.readASCII(data, off, nz-off); off = nz + 1;
nz = bin.nextZero(data, off);
var tkeyw = bin.readUTF8(data, off, nz-off); off = nz + 1;
var text = bin.readUTF8(data, off, len-(off-offset));
out.tabs[type][keyw] = text;
}
else if(type=="PLTE") {
out.tabs[type] = bin.readBytes(data, offset, len);
}
else if(type=="hIST") {
var pl = out.tabs["PLTE"].length/3;
out.tabs[type] = []; for(var i=0; i<pl; i++) out.tabs[type].push(rUs(data, offset+i*2));
}
else if(type=="tRNS") {
if (out.ctype==3) out.tabs[type] = bin.readBytes(data, offset, len);
else if(out.ctype==0) out.tabs[type] = rUs(data, offset);
else if(out.ctype==2) out.tabs[type] = [ rUs(data,offset),rUs(data,offset+2),rUs(data,offset+4) ];
//else console.log("tRNS for unsupported color type",out.ctype, len);
}
else if(type=="gAMA") out.tabs[type] = bin.readUint(data, offset)/100000;
else if(type=="sRGB") out.tabs[type] = data[offset];
else if(type=="bKGD")
{
if (out.ctype==0 || out.ctype==4) out.tabs[type] = [rUs(data, offset)];
else if(out.ctype==2 || out.ctype==6) out.tabs[type] = [rUs(data, offset), rUs(data, offset+2), rUs(data, offset+4)];
else if(out.ctype==3) out.tabs[type] = data[offset];
}
else if(type=="IEND") {
if(foff!=0) { var fr = out.frames[out.frames.length-1];
fr.data = UPNG.decode._decompress(out, fd.slice(0,foff), fr.rect.width, fr.rect.height); foff=0;
}
out.data = UPNG.decode._decompress(out, dd, out.width, out.height); break;
}
//else { log("unknown chunk type", type, len); }
offset += len;
var crc = bin.readUint(data, offset); offset += 4;
}
delete out.compress; delete out.interlace; delete out.filter;
return out;
}
UPNG.decode._decompress = function(out, dd, w, h) {
if(out.compress ==0) dd = UPNG.decode._inflate(dd);
if (out.interlace==0) dd = UPNG.decode._filterZero(dd, out, 0, w, h);
else if(out.interlace==1) dd = UPNG.decode._readInterlace(dd, out);
return dd;
}
UPNG.decode._inflate = function(data) { return pako["inflate"](data); }
UPNG.decode._readInterlace = function(data, out)
{
var w = out.width, h = out.height;
var bpp = UPNG.decode._getBPP(out), cbpp = bpp>>3, bpl = Math.ceil(w*bpp/8);
var img = new Uint8Array( h * bpl );
var di = 0;
var starting_row = [ 0, 0, 4, 0, 2, 0, 1 ];
var starting_col = [ 0, 4, 0, 2, 0, 1, 0 ];
var row_increment = [ 8, 8, 8, 4, 4, 2, 2 ];
var col_increment = [ 8, 8, 4, 4, 2, 2, 1 ];
var pass=0;
while(pass<7)
{
var ri = row_increment[pass], ci = col_increment[pass];
var sw = 0, sh = 0;
var cr = starting_row[pass]; while(cr<h) { cr+=ri; sh++; }
var cc = starting_col[pass]; while(cc<w) { cc+=ci; sw++; }
var bpll = Math.ceil(sw*bpp/8);
UPNG.decode._filterZero(data, out, di, sw, sh);
var y=0, row = starting_row[pass];
while(row<h)
{
var col = starting_col[pass];
var cdi = (di+y*bpll)<<3;
while(col<w)
{
if(bpp==1) {
var val = data[cdi>>3]; val = (val>>(7-(cdi&7)))&1;
img[row*bpl + (col>>3)] |= (val << (7-((col&3)<<0)));
}
if(bpp==2) {
var val = data[cdi>>3]; val = (val>>(6-(cdi&7)))&3;
img[row*bpl + (col>>2)] |= (val << (6-((col&3)<<1)));
}
if(bpp==4) {
var val = data[cdi>>3]; val = (val>>(4-(cdi&7)))&15;
img[row*bpl + (col>>1)] |= (val << (4-((col&1)<<2)));
}
if(bpp>=8) {
var ii = row*bpl+col*cbpp;
for(var j=0; j<cbpp; j++) img[ii+j] = data[(cdi>>3)+j];
}
cdi+=bpp; col+=ci;
}
y++; row += ri;
}
if(sw*sh!=0) di += sh * (1 + bpll);
pass = pass + 1;
}
return img;
}
UPNG.decode._getBPP = function(out) {
var noc = [1,null,3,1,2,null,4][out.ctype];
return noc * out.depth;
}
UPNG.decode._filterZero = function(data, out, off, w, h)
{
var bpp = UPNG.decode._getBPP(out), bpl = Math.ceil(w*bpp/8), paeth = UPNG.decode._paeth;
bpp = Math.ceil(bpp/8);
for(var y=0; y<h; y++) {
var i = off+y*bpl, di = i+y+1;
var type = data[di-1];
if (type==0) for(var x= 0; x<bpl; x++) data[i+x] = data[di+x];
else if(type==1) {
for(var x= 0; x<bpp; x++) data[i+x] = data[di+x];
for(var x=bpp; x<bpl; x++) data[i+x] = (data[di+x] + data[i+x-bpp])&255;
}
else if(y==0) {
for(var x= 0; x<bpp; x++) data[i+x] = data[di+x];
if(type==2) for(var x=bpp; x<bpl; x++) data[i+x] = (data[di+x])&255;
if(type==3) for(var x=bpp; x<bpl; x++) data[i+x] = (data[di+x] + (data[i+x-bpp]>>1) )&255;
if(type==4) for(var x=bpp; x<bpl; x++) data[i+x] = (data[di+x] + paeth(data[i+x-bpp], 0, 0) )&255;
}
else {
if(type==2) { for(var x= 0; x<bpl; x++) data[i+x] = (data[di+x] + data[i+x-bpl])&255; }
if(type==3) { for(var x= 0; x<bpp; x++) data[i+x] = (data[di+x] + (data[i+x-bpl]>>1))&255;
for(var x=bpp; x<bpl; x++) data[i+x] = (data[di+x] + ((data[i+x-bpl]+data[i+x-bpp])>>1) )&255; }
if(type==4) { for(var x= 0; x<bpp; x++) data[i+x] = (data[di+x] + paeth(0, data[i+x-bpl], 0))&255;
for(var x=bpp; x<bpl; x++) data[i+x] = (data[di+x] + paeth(data[i+x-bpp], data[i+x-bpl], data[i+x-bpp-bpl]) )&255; }
}
}
return data;
}
UPNG.decode._paeth = function(a,b,c)
{
var p = a+b-c, pa = Math.abs(p-a), pb = Math.abs(p-b), pc = Math.abs(p-c);
if (pa <= pb && pa <= pc) return a;
else if (pb <= pc) return b;
return c;
}
UPNG.decode._IHDR = function(data, offset, out)
{
var bin = UPNG._bin;
out.width = bin.readUint(data, offset); offset += 4;
out.height = bin.readUint(data, offset); offset += 4;
out.depth = data[offset]; offset++;
out.ctype = data[offset]; offset++;
out.compress = data[offset]; offset++;
out.filter = data[offset]; offset++;
out.interlace = data[offset]; offset++;
}
UPNG._bin = {
nextZero : function(data,p) { while(data[p]!=0) p++; return p; },
readUshort : function(buff,p) { return (buff[p]<< 8) | buff[p+1]; },
writeUshort: function(buff,p,n){ buff[p] = (n>>8)&255; buff[p+1] = n&255; },
readUint : function(buff,p) { return (buff[p]*(256*256*256)) + ((buff[p+1]<<16) | (buff[p+2]<< 8) | buff[p+3]); },
writeUint : function(buff,p,n){ buff[p]=(n>>24)&255; buff[p+1]=(n>>16)&255; buff[p+2]=(n>>8)&255; buff[p+3]=n&255; },
readASCII : function(buff,p,l){ var s = ""; for(var i=0; i<l; i++) s += String.fromCharCode(buff[p+i]); return s; },
writeASCII : function(data,p,s){ for(var i=0; i<s.length; i++) data[p+i] = s.charCodeAt(i); },
readBytes : function(buff,p,l){ var arr = []; for(var i=0; i<l; i++) arr.push(buff[p+i]); return arr; },
pad : function(n) { return n.length < 2 ? "0" + n : n; },
readUTF8 : function(buff, p, l) {
var s = "", ns;
for(var i=0; i<l; i++) s += "%" + UPNG._bin.pad(buff[p+i].toString(16));
try { ns = decodeURIComponent(s); }
catch(e) { return UPNG._bin.readASCII(buff, p, l); }
return ns;
}
}
UPNG._copyTile = function(sb, sw, sh, tb, tw, th, xoff, yoff, mode)
{
var w = Math.min(sw,tw), h = Math.min(sh,th);
var si=0, ti=0;
for(var y=0; y<h; y++)
for(var x=0; x<w; x++)
{
if(xoff>=0 && yoff>=0) { si = (y*sw+x)<<2; ti = (( yoff+y)*tw+xoff+x)<<2; }
else { si = ((-yoff+y)*sw-xoff+x)<<2; ti = (y*tw+x)<<2; }
if (mode==0) { tb[ti] = sb[si]; tb[ti+1] = sb[si+1]; tb[ti+2] = sb[si+2]; tb[ti+3] = sb[si+3]; }
else if(mode==1) {
var fa = sb[si+3]*(1/255), fr=sb[si]*fa, fg=sb[si+1]*fa, fb=sb[si+2]*fa;
var ba = tb[ti+3]*(1/255), br=tb[ti]*ba, bg=tb[ti+1]*ba, bb=tb[ti+2]*ba;
var ifa=1-fa, oa = fa+ba*ifa, ioa = (oa==0?0:1/oa);
tb[ti+3] = 255*oa;
tb[ti+0] = (fr+br*ifa)*ioa;
tb[ti+1] = (fg+bg*ifa)*ioa;
tb[ti+2] = (fb+bb*ifa)*ioa;
}
else if(mode==2){ // copy only differences, otherwise zero
var fa = sb[si+3], fr=sb[si], fg=sb[si+1], fb=sb[si+2];
var ba = tb[ti+3], br=tb[ti], bg=tb[ti+1], bb=tb[ti+2];
if(fa==ba && fr==br && fg==bg && fb==bb) { tb[ti]=0; tb[ti+1]=0; tb[ti+2]=0; tb[ti+3]=0; }
else { tb[ti]=fr; tb[ti+1]=fg; tb[ti+2]=fb; tb[ti+3]=fa; }
}
else if(mode==3){ // check if can be blended
var fa = sb[si+3], fr=sb[si], fg=sb[si+1], fb=sb[si+2];
var ba = tb[ti+3], br=tb[ti], bg=tb[ti+1], bb=tb[ti+2];
if(fa==ba && fr==br && fg==bg && fb==bb) continue;
//if(fa!=255 && ba!=0) return false;
if(fa<220 && ba>20) return false;
}
}
return true;
}
UPNG.encode = function(bufs, w, h, ps, dels, forbidPlte)
{
if(ps==null) ps=0;
if(forbidPlte==null) forbidPlte = false;
var data = new Uint8Array(bufs[0].byteLength*bufs.length+100);
var wr=[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
for(var i=0; i<8; i++) data[i]=wr[i];
var offset = 8, bin = UPNG._bin, crc = UPNG.crc.crc, wUi = bin.writeUint, wUs = bin.writeUshort, wAs = bin.writeASCII;
var nimg = UPNG.encode.compressPNG(bufs, w, h, ps, forbidPlte);
wUi(data,offset, 13); offset+=4;
wAs(data,offset,"IHDR"); offset+=4;
wUi(data,offset,w); offset+=4;
wUi(data,offset,h); offset+=4;
data[offset] = nimg.depth; offset++; // depth
data[offset] = nimg.ctype; offset++; // ctype
data[offset] = 0; offset++; // compress
data[offset] = 0; offset++; // filter
data[offset] = 0; offset++; // interlace
wUi(data,offset,crc(data,offset-17,17)); offset+=4; // crc
// 9 bytes to say, that it is sRGB
wUi(data,offset, 1); offset+=4;
wAs(data,offset,"sRGB"); offset+=4;
data[offset] = 1; offset++;
wUi(data,offset,crc(data,offset-5,5)); offset+=4; // crc
var anim = bufs.length>1;
if(anim) {
wUi(data,offset, 8); offset+=4;
wAs(data,offset,"acTL"); offset+=4;
wUi(data,offset, bufs.length); offset+=4;
wUi(data,offset, 0); offset+=4;
wUi(data,offset,crc(data,offset-12,12)); offset+=4; // crc
}
if(nimg.ctype==3) {
var dl = nimg.plte.length;
wUi(data,offset, dl*3); offset+=4;
wAs(data,offset,"PLTE"); offset+=4;
for(var i=0; i<dl; i++){
var ti=i*3, c=nimg.plte[i], r=(c)&255, g=(c>>8)&255, b=(c>>16)&255;
data[offset+ti+0]=r; data[offset+ti+1]=g; data[offset+ti+2]=b;
}
offset+=dl*3;
wUi(data,offset,crc(data,offset-dl*3-4,dl*3+4)); offset+=4; // crc
if(nimg.gotAlpha) {
wUi(data,offset, dl); offset+=4;
wAs(data,offset,"tRNS"); offset+=4;
for(var i=0; i<dl; i++) data[offset+i]=(nimg.plte[i]>>24)&255;
offset+=dl;
wUi(data,offset,crc(data,offset-dl-4,dl+4)); offset+=4; // crc
}
}
var fi = 0;
for(var j=0; j<nimg.frames.length; j++)
{
var fr = nimg.frames[j];
if(anim) {
wUi(data,offset, 26); offset+=4;
wAs(data,offset,"fcTL"); offset+=4;
wUi(data, offset, fi++); offset+=4;
wUi(data, offset, fr.rect.width ); offset+=4;
wUi(data, offset, fr.rect.height); offset+=4;
wUi(data, offset, fr.rect.x); offset+=4;
wUi(data, offset, fr.rect.y); offset+=4;
wUs(data, offset, dels[j]); offset+=2;
wUs(data, offset, 1000); offset+=2;
data[offset] = fr.dispose; offset++; // dispose
data[offset] = fr.blend ; offset++; // blend
wUi(data,offset,crc(data,offset-30,30)); offset+=4; // crc
}
var imgd = fr.cimg, dl = imgd.length;
wUi(data,offset, dl+(j==0?0:4)); offset+=4;
var ioff = offset;
wAs(data,offset,(j==0)?"IDAT":"fdAT"); offset+=4;
if(j!=0) { wUi(data, offset, fi++); offset+=4; }
for(var i=0; i<dl; i++) data[offset+i] = imgd[i];
offset += dl;
wUi(data,offset,crc(data,ioff,offset-ioff)); offset+=4; // crc
}
wUi(data,offset, 0); offset+=4;
wAs(data,offset,"IEND"); offset+=4;
wUi(data,offset,crc(data,offset-4,4)); offset+=4; // crc
return data.buffer.slice(0,offset);
}
UPNG.encode.compressPNG = function(bufs, w, h, ps, forbidPlte)
{
var out = UPNG.encode.compress(bufs, w, h, ps, false, forbidPlte);
for(var i=0; i<bufs.length; i++) {
var frm = out.frames[i], nw=frm.rect.width, nh=frm.rect.height, bpl=frm.bpl, bpp=frm.bpp;
var fdata = new Uint8Array(nh*bpl+nh);
frm.cimg = UPNG.encode._filterZero(frm.img,nh,bpp,bpl,fdata);
}
return out;
}
UPNG.encode.compress = function(bufs, w, h, ps, forGIF, forbidPlte)
{
if(forbidPlte==null) forbidPlte = false;
var ctype = 6, depth = 8, bpp = 4, alphaAnd=255
for(var j=0; j<bufs.length; j++) { // when not quantized, other frames can contain colors, that are not in an initial frame
var img = new Uint8Array(bufs[j]), ilen = img.length;
for(var i=0; i<ilen; i+=4) alphaAnd &= img[i+3];
}
var gotAlpha = (alphaAnd)!=255;
var cmap={}, plte=[]; if(bufs.length!=0) { cmap[0]=0; plte.push(0); if(ps!=0) ps--; }
if(ps!=0) {
var qres = UPNG.quantize(bufs, ps, forGIF); bufs = qres.bufs;
for(var i=0; i<qres.plte.length; i++) { var c=qres.plte[i].est.rgba; if(cmap[c]==null) { cmap[c]=plte.length; plte.push(c); } }
}
else {
// what if ps==0, but there are <=256 colors? we still need to detect, if the palette could be used
for(var j=0; j<bufs.length; j++) { // when not quantized, other frames can contain colors, that are not in an initial frame
var img32 = new Uint32Array(bufs[j]), ilen = img32.length;
for(var i=0; i<ilen; i++) {
var c = img32[i];
if((i<w || (c!=img32[i-1] && c!=img32[i-w])) && cmap[c]==null) { cmap[c]=plte.length; plte.push(c); if(plte.length>=300) break; }
}
}
}
var brute = gotAlpha ? forGIF : false; // brute : frames can only be copied, not "blended"
var cc=plte.length; //console.log(cc);
if(cc<=256 && forbidPlte==false) {
if(cc<= 2) depth=1; else if(cc<= 4) depth=2; else if(cc<=16) depth=4; else depth=8;
if(forGIF) depth=8;
gotAlpha = true;
}
var frms = [];
for(var j=0; j<bufs.length; j++)
{
var cimg = new Uint8Array(bufs[j]), cimg32 = new Uint32Array(cimg.buffer);
var nx=0, ny=0, nw=w, nh=h, blend=0;
if(j!=0 && !brute) {
var tlim = (forGIF || j==1 || frms[frms.length-2].dispose==2)?1:2, tstp = 0, tarea = 1e9;
for(var it=0; it<tlim; it++)
{
var pimg = new Uint8Array(bufs[j-1-it]), p32 = new Uint32Array(bufs[j-1-it]);
var mix=w,miy=h,max=-1,may=-1;
for(var y=0; y<h; y++) for(var x=0; x<w; x++) {
var i = y*w+x;
if(cimg32[i]!=p32[i]) {
if(x<mix) mix=x; if(x>max) max=x;
if(y<miy) miy=y; if(y>may) may=y;
}
}
var sarea = (max==-1) ? 1 : (max-mix+1)*(may-miy+1);
if(sarea<tarea) {
tarea = sarea; tstp = it;
if(max==-1) { nx=ny=0; nw=nh=1; }
else { nx = mix; ny = miy; nw = max-mix+1; nh = may-miy+1; }
}
}
var pimg = new Uint8Array(bufs[j-1-tstp]);
if(tstp==1) frms[frms.length-1].dispose = 2;
var nimg = new Uint8Array(nw*nh*4), nimg32 = new Uint32Array(nimg.buffer);
UPNG. _copyTile(pimg,w,h, nimg,nw,nh, -nx,-ny, 0);
if(UPNG._copyTile(cimg,w,h, nimg,nw,nh, -nx,-ny, 3)) {
UPNG._copyTile(cimg,w,h, nimg,nw,nh, -nx,-ny, 2); blend = 1;
}
else {
UPNG._copyTile(cimg,w,h, nimg,nw,nh, -nx,-ny, 0); blend = 0;
}
cimg = nimg; cimg32 = new Uint32Array(cimg.buffer);
}
var bpl = 4*nw;
if(cc<=256 && forbidPlte==false) {
bpl = Math.ceil(depth*nw/8);
var nimg = new Uint8Array(bpl*nh);
for(var y=0; y<nh; y++) { var i=y*bpl, ii=y*nw;
if (depth==8) for(var x=0; x<nw; x++) nimg[i+(x) ] = (cmap[cimg32[ii+x]] );
else if(depth==4) for(var x=0; x<nw; x++) nimg[i+(x>>1)] |= (cmap[cimg32[ii+x]]<<(4-(x&1)*4));
else if(depth==2) for(var x=0; x<nw; x++) nimg[i+(x>>2)] |= (cmap[cimg32[ii+x]]<<(6-(x&3)*2));
else if(depth==1) for(var x=0; x<nw; x++) nimg[i+(x>>3)] |= (cmap[cimg32[ii+x]]<<(7-(x&7)*1));
}
cimg=nimg; ctype=3; bpp=1;
}
else if(gotAlpha==false && bufs.length==1) { // some next "reduced" frames may contain alpha for blending
var nimg = new Uint8Array(nw*nh*3), area=nw*nh;
for(var i=0; i<area; i++) { var ti=i*3, qi=i*4; nimg[ti]=cimg[qi]; nimg[ti+1]=cimg[qi+1]; nimg[ti+2]=cimg[qi+2]; }
cimg=nimg; ctype=2; bpp=3; bpl=3*nw;
}
frms.push({rect:{x:nx,y:ny,width:nw,height:nh}, img:cimg, bpl:bpl, bpp:bpp, blend:blend, dispose:brute?1:0});
}
return {ctype:ctype, depth:depth, plte:plte, gotAlpha:gotAlpha, frames:frms };
}
UPNG.encode._filterZero = function(img,h,bpp,bpl,data)
{
var fls = [];
for(var t=0; t<5; t++) { if(h*bpl>500000 && (t==2 || t==3 || t==4)) continue;
for(var y=0; y<h; y++) UPNG.encode._filterLine(data, img, y, bpl, bpp, t);
fls.push(pako["deflate"](data)); if(bpp==1) break;
}
var ti, tsize=1e9;
for(var i=0; i<fls.length; i++) if(fls[i].length<tsize) { ti=i; tsize=fls[i].length; }
return fls[ti];
}
UPNG.encode._filterLine = function(data, img, y, bpl, bpp, type)
{
var i = y*bpl, di = i+y, paeth = UPNG.decode._paeth
data[di]=type; di++;
if(type==0) for(var x=0; x<bpl; x++) data[di+x] = img[i+x];
else if(type==1) {
for(var x= 0; x<bpp; x++) data[di+x] = img[i+x];
for(var x=bpp; x<bpl; x++) data[di+x] = (img[i+x]-img[i+x-bpp]+256)&255;
}
else if(y==0) {
for(var x= 0; x<bpp; x++) data[di+x] = img[i+x];
if(type==2) for(var x=bpp; x<bpl; x++) data[di+x] = img[i+x];
if(type==3) for(var x=bpp; x<bpl; x++) data[di+x] = (img[i+x] - (img[i+x-bpp]>>1) +256)&255;
if(type==4) for(var x=bpp; x<bpl; x++) data[di+x] = (img[i+x] - paeth(img[i+x-bpp], 0, 0) +256)&255;
}
else {
if(type==2) { for(var x= 0; x<bpl; x++) data[di+x] = (img[i+x]+256 - img[i+x-bpl])&255; }
if(type==3) { for(var x= 0; x<bpp; x++) data[di+x] = (img[i+x]+256 - (img[i+x-bpl]>>1))&255;
for(var x=bpp; x<bpl; x++) data[di+x] = (img[i+x]+256 - ((img[i+x-bpl]+img[i+x-bpp])>>1))&255; }
if(type==4) { for(var x= 0; x<bpp; x++) data[di+x] = (img[i+x]+256 - paeth(0, img[i+x-bpl], 0))&255;
for(var x=bpp; x<bpl; x++) data[di+x] = (img[i+x]+256 - paeth(img[i+x-bpp], img[i+x-bpl], img[i+x-bpp-bpl]))&255; }
}
}
UPNG.crc = {
table : ( function() {
var tab = new Uint32Array(256);
for (var n=0; n<256; n++) {
var c = n;
for (var k=0; k<8; k++) {
if (c & 1) c = 0xedb88320 ^ (c >>> 1);
else c = c >>> 1;
}
tab[n] = c; }
return tab; })(),
update : function(c, buf, off, len) {
for (var i=0; i<len; i++) c = UPNG.crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
return c;
},
crc : function(b,o,l) { return UPNG.crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
}
UPNG.quantize = function(bufs, ps, roundAlpha)
{
var imgs = [], totl = 0;
for(var i=0; i<bufs.length; i++) { imgs.push(UPNG.encode.alphaMul(new Uint8Array(bufs[i]), roundAlpha)); totl+=bufs[i].byteLength; }
var nimg = new Uint8Array(totl), nimg32 = new Uint32Array(nimg.buffer), noff=0;
for(var i=0; i<imgs.length; i++) {
var img = imgs[i], il = img.length;
for(var j=0; j<il; j++) nimg[noff+j] = img[j];
noff += il;
}
var root = {i0:0, i1:nimg.length, bst:null, est:null, tdst:0, left:null, right:null }; // basic statistic, extra statistic
root.bst = UPNG.quantize.stats( nimg,root.i0, root.i1 ); root.est = UPNG.quantize.estats( root.bst );
var leafs = [root];
while(leafs.length<ps)
{
var maxL = 0, mi=0;
for(var i=0; i<leafs.length; i++) if(leafs[i].est.L > maxL) { maxL=leafs[i].est.L; mi=i; }
if(maxL<1e-3) break;
var node = leafs[mi];
var s0 = UPNG.quantize.splitPixels(nimg,nimg32, node.i0, node.i1, node.est.e, node.est.eMq255);
var ln = {i0:node.i0, i1:s0, bst:null, est:null, tdst:0, left:null, right:null }; ln.bst = UPNG.quantize.stats( nimg, ln.i0, ln.i1 );
ln.est = UPNG.quantize.estats( ln.bst );
var rn = {i0:s0, i1:node.i1, bst:null, est:null, tdst:0, left:null, right:null }; rn.bst = {R:[], m:[], N:node.bst.N-ln.bst.N};
for(var i=0; i<16; i++) rn.bst.R[i] = node.bst.R[i]-ln.bst.R[i];
for(var i=0; i< 4; i++) rn.bst.m[i] = node.bst.m[i]-ln.bst.m[i];
rn.est = UPNG.quantize.estats( rn.bst );
node.left = ln; node.right = rn;
leafs[mi]=ln; leafs.push(rn);
}
leafs.sort(function(a,b) { return b.bst.N-a.bst.N; });
for(var ii=0; ii<imgs.length; ii++) {
var planeDst = UPNG.quantize.planeDst;
var sb = new Uint8Array(imgs[ii].buffer), tb = new Uint32Array(imgs[ii].buffer), len = sb.length;
var stack = [], si=0;
for(var i=0; i<len; i+=4) {
var r=sb[i]*(1/255), g=sb[i+1]*(1/255), b=sb[i+2]*(1/255), a=sb[i+3]*(1/255);
// exact, but too slow :(
//var nd = UPNG.quantize.getNearest(root, r, g, b, a);
var nd = root;
while(nd.left) nd = (planeDst(nd.est,r,g,b,a)<=0) ? nd.left : nd.right;
tb[i>>2] = nd.est.rgba;
}
imgs[ii]=tb.buffer;
}
return { bufs:imgs, plte:leafs };
}
UPNG.quantize.getNearest = function(nd, r,g,b,a)
{
if(nd.left==null) { nd.tdst = UPNG.quantize.dist(nd.est.q,r,g,b,a); return nd; }
var planeDst = UPNG.quantize.planeDst(nd.est,r,g,b,a);
var node0 = nd.left, node1 = nd.right;
if(planeDst>0) { node0=nd.right; node1=nd.left; }
var ln = UPNG.quantize.getNearest(node0, r,g,b,a);
if(ln.tdst<=planeDst*planeDst) return ln;
var rn = UPNG.quantize.getNearest(node1, r,g,b,a);
return rn.tdst<ln.tdst ? rn : ln;
}
UPNG.quantize.planeDst = function(est, r,g,b,a) { var e = est.e; return e[0]*r + e[1]*g + e[2]*b + e[3]*a - est.eMq; }
UPNG.quantize.dist = function(q, r,g,b,a) { var d0=r-q[0], d1=g-q[1], d2=b-q[2], d3=a-q[3]; return d0*d0+d1*d1+d2*d2+d3*d3; }
UPNG.quantize.splitPixels = function(nimg, nimg32, i0, i1, e, eMq)
{
var vecDot = UPNG.quantize.vecDot;
i1-=4;
var shfs = 0;
while(i0<i1)
{
while(vecDot(nimg, i0, e)<=eMq) i0+=4;
while(vecDot(nimg, i1, e)> eMq) i1-=4;
if(i0>=i1) break;
var t = nimg32[i0>>2]; nimg32[i0>>2] = nimg32[i1>>2]; nimg32[i1>>2]=t;
i0+=4; i1-=4;
}
while(vecDot(nimg, i0, e)>eMq) i0-=4;
return i0+4;
}
UPNG.quantize.vecDot = function(nimg, i, e)
{
return nimg[i]*e[0] + nimg[i+1]*e[1] + nimg[i+2]*e[2] + nimg[i+3]*e[3];
}
UPNG.quantize.stats = function(nimg, i0, i1){
var R = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
var m = [0,0,0,0];
var N = (i1-i0)>>2;
for(var i=i0; i<i1; i+=4)
{
var r = nimg[i]*(1/255), g = nimg[i+1]*(1/255), b = nimg[i+2]*(1/255), a = nimg[i+3]*(1/255);
//var r = nimg[i], g = nimg[i+1], b = nimg[i+2], a = nimg[i+3];
m[0]+=r; m[1]+=g; m[2]+=b; m[3]+=a;
R[ 0] += r*r; R[ 1] += r*g; R[ 2] += r*b; R[ 3] += r*a;
R[ 5] += g*g; R[ 6] += g*b; R[ 7] += g*a;
R[10] += b*b; R[11] += b*a;
R[15] += a*a;
}
R[4]=R[1]; R[8]=R[2]; R[12]=R[3]; R[9]=R[6]; R[13]=R[7]; R[14]=R[11];
return {R:R, m:m, N:N};
}
UPNG.quantize.estats = function(stats){
var R = stats.R, m = stats.m, N = stats.N;
var m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3], iN = (N==0 ? 0 : 1/N);
var Rj = [
R[ 0] - m0*m0*iN, R[ 1] - m0*m1*iN, R[ 2] - m0*m2*iN, R[ 3] - m0*m3*iN,
R[ 4] - m1*m0*iN, R[ 5] - m1*m1*iN, R[ 6] - m1*m2*iN, R[ 7] - m1*m3*iN,
R[ 8] - m2*m0*iN, R[ 9] - m2*m1*iN, R[10] - m2*m2*iN, R[11] - m2*m3*iN,
R[12] - m3*m0*iN, R[13] - m3*m1*iN, R[14] - m3*m2*iN, R[15] - m3*m3*iN
];
var A = Rj, M = UPNG.M4;
var b = [0.5,0.5,0.5,0.5], mi = 0, tmi = 0;
if(N!=0)
for(var i=0; i<10; i++) {
b = M.multVec(A, b); tmi = Math.sqrt(M.dot(b,b)); b = M.sml(1/tmi, b);
if(Math.abs(tmi-mi)<1e-9) break; mi = tmi;
}
//b = [0,0,1,0]; mi=N;
var q = [m0*iN, m1*iN, m2*iN, m3*iN];
var eMq255 = M.dot(M.sml(255,q),b);
var ia = (q[3]<0.001) ? 0 : 1/q[3];
return { Cov:Rj, q:q, e:b, L:mi, eMq255:eMq255, eMq : M.dot(b,q),
rgba: (((Math.round(255*q[3])<<24) | (Math.round(255*q[2]*ia)<<16) | (Math.round(255*q[1]*ia)<<8) | (Math.round(255*q[0]*ia)<<0))>>>0) };
}
UPNG.M4 = {
multVec : function(m,v) {
return [
m[ 0]*v[0] + m[ 1]*v[1] + m[ 2]*v[2] + m[ 3]*v[3],
m[ 4]*v[0] + m[ 5]*v[1] + m[ 6]*v[2] + m[ 7]*v[3],
m[ 8]*v[0] + m[ 9]*v[1] + m[10]*v[2] + m[11]*v[3],
m[12]*v[0] + m[13]*v[1] + m[14]*v[2] + m[15]*v[3]
];
},
dot : function(x,y) { return x[0]*y[0]+x[1]*y[1]+x[2]*y[2]+x[3]*y[3]; },
sml : function(a,y) { return [a*y[0],a*y[1],a*y[2],a*y[3]]; }
}
UPNG.encode.alphaMul = function(img, roundA) {
var nimg = new Uint8Array(img.length), area = img.length>>2;
for(var i=0; i<area; i++) {
var qi=i<<2, ia=img[qi+3];
if(roundA) ia = ((ia<128))?0:255;
var a = ia*(1/255);
nimg[qi+0] = img[qi+0]*a; nimg[qi+1] = img[qi+1]*a; nimg[qi+2] = img[qi+2]*a; nimg[qi+3] = ia;
}
return nimg;
}
})(UPNG, pako);
})();
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).pako=t()}}(function(){return function t(e,a,i){function n(s,o){if(!a[s]){if(!e[s]){var l="function"==typeof require&&require;if(!o&&l)return l(s,!0);if(r)return r(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var d=a[s]={exports:{}};e[s][0].call(d.exports,function(t){var a=e[s][1][t];return n(a||t)},d,d.exports,t,e,a,i)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e,a){"use strict";function i(t){if(!(this instanceof i))return new i(t);this.options=s.assign({level:_,method:c,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var a=r.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==f)throw new Error(l[a]);if(e.header&&r.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(n="string"==typeof e.dictionary?o.string2buf(e.dictionary):"[object ArrayBuffer]"===d.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,(a=r.deflateSetDictionary(this.strm,n))!==f)throw new Error(l[a]);this._dict_set=!0}}function n(t,e){var a=new i(e);if(a.push(t,!0),a.err)throw a.msg||l[a.err];return a.result}var r=t("./zlib/deflate"),s=t("./utils/common"),o=t("./utils/strings"),l=t("./zlib/messages"),h=t("./zlib/zstream"),d=Object.prototype.toString,f=0,_=-1,u=0,c=8;i.prototype.push=function(t,e){var a,i,n=this.strm,l=this.options.chunkSize;if(this.ended)return!1;i=e===~~e?e:!0===e?4:0,"string"==typeof t?n.input=o.string2buf(t):"[object ArrayBuffer]"===d.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;do{if(0===n.avail_out&&(n.output=new s.Buf8(l),n.next_out=0,n.avail_out=l),1!==(a=r.deflate(n,i))&&a!==f)return this.onEnd(a),this.ended=!0,!1;0!==n.avail_out&&(0!==n.avail_in||4!==i&&2!==i)||("string"===this.options.to?this.onData(o.buf2binstring(s.shrinkBuf(n.output,n.next_out))):this.onData(s.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||0===n.avail_out)&&1!==a);return 4===i?(a=r.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===f):2!==i||(this.onEnd(f),n.avail_out=0,!0)},i.prototype.onData=function(t){this.chunks.push(t)},i.prototype.onEnd=function(t){t===f&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},a.Deflate=i,a.deflate=n,a.deflateRaw=function(t,e){return e=e||{},e.raw=!0,n(t,e)},a.gzip=function(t,e){return e=e||{},e.gzip=!0,n(t,e)}},{"./utils/common":3,"./utils/strings":4,"./zlib/deflate":8,"./zlib/messages":13,"./zlib/zstream":15}],2:[function(t,e,a){"use strict";function i(t){if(!(this instanceof i))return new i(t);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var a=r.inflateInit2(this.strm,e.windowBits);if(a!==l.Z_OK)throw new Error(h[a]);this.header=new f,r.inflateGetHeader(this.strm,this.header)}function n(t,e){var a=new i(e);if(a.push(t,!0),a.err)throw a.msg||h[a.err];return a.result}var r=t("./zlib/inflate"),s=t("./utils/common"),o=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),d=t("./zlib/zstream"),f=t("./zlib/gzheader"),_=Object.prototype.toString;i.prototype.push=function(t,e){var a,i,n,h,d,f,u=this.strm,c=this.options.chunkSize,b=this.options.dictionary,g=!1;if(this.ended)return!1;i=e===~~e?e:!0===e?l.Z_FINISH:l.Z_NO_FLUSH,"string"==typeof t?u.input=o.binstring2buf(t):"[object ArrayBuffer]"===_.call(t)?u.input=new Uint8Array(t):u.input=t,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new s.Buf8(c),u.next_out=0,u.avail_out=c),(a=r.inflate(u,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&b&&(f="string"==typeof b?o.string2buf(b):"[object ArrayBuffer]"===_.call(b)?new Uint8Array(b):b,a=r.inflateSetDictionary(this.strm,f)),a===l.Z_BUF_ERROR&&!0===g&&(a=l.Z_OK,g=!1),a!==l.Z_STREAM_END&&a!==l.Z_OK)return this.onEnd(a),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&a!==l.Z_STREAM_END&&(0!==u.avail_in||i!==l.Z_FINISH&&i!==l.Z_SYNC_FLUSH)||("string"===this.options.to?(n=o.utf8border(u.output,u.next_out),h=u.next_out-n,d=o.buf2string(u.output,n),u.next_out=h,u.avail_out=c-h,h&&s.arraySet(u.output,u.output,n,h,0),this.onData(d)):this.onData(s.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&a!==l.Z_STREAM_END);return a===l.Z_STREAM_END&&(i=l.Z_FINISH),i===l.Z_FINISH?(a=r.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===l.Z_OK):i!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),u.avail_out=0,!0)},i.prototype.onData=function(t){this.chunks.push(t)},i.prototype.onEnd=function(t){t===l.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},a.Inflate=i,a.inflate=n,a.inflateRaw=function(t,e){return e=e||{},e.raw=!0,n(t,e)},a.ungzip=n},{"./utils/common":3,"./utils/strings":4,"./zlib/constants":6,"./zlib/gzheader":9,"./zlib/inflate":11,"./zlib/messages":13,"./zlib/zstream":15}],3:[function(t,e,a){"use strict";function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;a.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var a=e.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(var n in a)i(a,n)&&(t[n]=a[n])}}return t},a.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var r={arraySet:function(t,e,a,i,n){if(e.subarray&&t.subarray)t.set(e.subarray(a,a+i),n);else for(var r=0;r<i;r++)t[n+r]=e[a+r]},flattenChunks:function(t){var e,a,i,n,r,s;for(i=0,e=0,a=t.length;e<a;e++)i+=t[e].length;for(s=new Uint8Array(i),n=0,e=0,a=t.length;e<a;e++)r=t[e],s.set(r,n),n+=r.length;return s}},s={arraySet:function(t,e,a,i,n){for(var r=0;r<i;r++)t[n+r]=e[a+r]},flattenChunks:function(t){return[].concat.apply([],t)}};a.setTyped=function(t){t?(a.Buf8=Uint8Array,a.Buf16=Uint16Array,a.Buf32=Int32Array,a.assign(a,r)):(a.Buf8=Array,a.Buf16=Array,a.Buf32=Array,a.assign(a,s))},a.setTyped(n)},{}],4:[function(t,e,a){"use strict";function i(t,e){if(e<65537&&(t.subarray&&s||!t.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(t,e));for(var a="",i=0;i<e;i++)a+=String.fromCharCode(t[i]);return a}var n=t("./common"),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(t){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){s=!1}for(var o=new n.Buf8(256),l=0;l<256;l++)o[l]=l>=252?6:l>=248?5:l>=240?4:l>=224?3:l>=192?2:1;o[254]=o[254]=1,a.string2buf=function(t){var e,a,i,r,s,o=t.length,l=0;for(r=0;r<o;r++)55296==(64512&(a=t.charCodeAt(r)))&&r+1<o&&56320==(64512&(i=t.charCodeAt(r+1)))&&(a=65536+(a-55296<<10)+(i-56320),r++),l+=a<128?1:a<2048?2:a<65536?3:4;for(e=new n.Buf8(l),s=0,r=0;s<l;r++)55296==(64512&(a=t.charCodeAt(r)))&&r+1<o&&56320==(64512&(i=t.charCodeAt(r+1)))&&(a=65536+(a-55296<<10)+(i-56320),r++),a<128?e[s++]=a:a<2048?(e[s++]=192|a>>>6,e[s++]=128|63&a):a<65536?(e[s++]=224|a>>>12,e[s++]=128|a>>>6&63,e[s++]=128|63&a):(e[s++]=240|a>>>18,e[s++]=128|a>>>12&63,e[s++]=128|a>>>6&63,e[s++]=128|63&a);return e},a.buf2binstring=function(t){return i(t,t.length)},a.binstring2buf=function(t){for(var e=new n.Buf8(t.length),a=0,i=e.length;a<i;a++)e[a]=t.charCodeAt(a);return e},a.buf2string=function(t,e){var a,n,r,s,l=e||t.length,h=new Array(2*l);for(n=0,a=0;a<l;)if((r=t[a++])<128)h[n++]=r;else if((s=o[r])>4)h[n++]=65533,a+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&a<l;)r=r<<6|63&t[a++],s--;s>1?h[n++]=65533:r<65536?h[n++]=r:(r-=65536,h[n++]=55296|r>>10&1023,h[n++]=56320|1023&r)}return i(h,n)},a.utf8border=function(t,e){var a;for((e=e||t.length)>t.length&&(e=t.length),a=e-1;a>=0&&128==(192&t[a]);)a--;return a<0?e:0===a?e:a+o[t[a]]>e?a:e}},{"./common":3}],5:[function(t,e,a){"use strict";e.exports=function(t,e,a,i){for(var n=65535&t|0,r=t>>>16&65535|0,s=0;0!==a;){a-=s=a>2e3?2e3:a;do{r=r+(n=n+e[i++]|0)|0}while(--s);n%=65521,r%=65521}return n|r<<16|0}},{}],6:[function(t,e,a){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],7:[function(t,e,a){"use strict";var i=function(){for(var t,e=[],a=0;a<256;a++){t=a;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e}();e.exports=function(t,e,a,n){var r=i,s=n+a;t^=-1;for(var o=n;o<s;o++)t=t>>>8^r[255&(t^e[o])];return-1^t}},{}],8:[function(t,e,a){"use strict";function i(t,e){return t.msg=A[e],e}function n(t){return(t<<1)-(t>4?9:0)}function r(t){for(var e=t.length;--e>=0;)t[e]=0}function s(t){var e=t.state,a=e.pending;a>t.avail_out&&(a=t.avail_out),0!==a&&(z.arraySet(t.output,e.pending_buf,e.pending_out,a,t.next_out),t.next_out+=a,e.pending_out+=a,t.total_out+=a,t.avail_out-=a,e.pending-=a,0===e.pending&&(e.pending_out=0))}function o(t,e){B._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,s(t.strm)}function l(t,e){t.pending_buf[t.pending++]=e}function h(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function d(t,e,a,i){var n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,z.arraySet(e,t.input,t.next_in,n,a),1===t.state.wrap?t.adler=S(t.adler,e,n,a):2===t.state.wrap&&(t.adler=E(t.adler,e,n,a)),t.next_in+=n,t.total_in+=n,n)}function f(t,e){var a,i,n=t.max_chain_length,r=t.strstart,s=t.prev_length,o=t.nice_match,l=t.strstart>t.w_size-it?t.strstart-(t.w_size-it):0,h=t.window,d=t.w_mask,f=t.prev,_=t.strstart+at,u=h[r+s-1],c=h[r+s];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(a=e,h[a+s]===c&&h[a+s-1]===u&&h[a]===h[r]&&h[++a]===h[r+1]){r+=2,a++;do{}while(h[++r]===h[++a]&&h[++r]===h[++a]&&h[++r]===h[++a]&&h[++r]===h[++a]&&h[++r]===h[++a]&&h[++r]===h[++a]&&h[++r]===h[++a]&&h[++r]===h[++a]&&r<_);if(i=at-(_-r),r=_-at,i>s){if(t.match_start=e,s=i,i>=o)break;u=h[r+s-1],c=h[r+s]}}}while((e=f[e&d])>l&&0!=--n);return s<=t.lookahead?s:t.lookahead}function _(t){var e,a,i,n,r,s=t.w_size;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-it)){z.arraySet(t.window,t.window,s,s,0),t.match_start-=s,t.strstart-=s,t.block_start-=s,e=a=t.hash_size;do{i=t.head[--e],t.head[e]=i>=s?i-s:0}while(--a);e=a=s;do{i=t.prev[--e],t.prev[e]=i>=s?i-s:0}while(--a);n+=s}if(0===t.strm.avail_in)break;if(a=d(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=a,t.lookahead+t.insert>=et)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=(t.ins_h<<t.hash_shift^t.window[r+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[r+et-1])&t.hash_mask,t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<et)););}while(t.lookahead<it&&0!==t.strm.avail_in)}function u(t,e){for(var a,i;;){if(t.lookahead<it){if(_(t),t.lookahead<it&&e===Z)return _t;if(0===t.lookahead)break}if(a=0,t.lookahead>=et&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+et-1])&t.hash_mask,a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==a&&t.strstart-a<=t.w_size-it&&(t.match_length=f(t,a)),t.match_length>=et)if(i=B._tr_tally(t,t.strstart-t.match_start,t.match_length-et),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=et){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+et-1])&t.hash_mask,a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else i=B._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(o(t,!1),0===t.strm.avail_out))return _t}return t.insert=t.strstart<et-1?t.strstart:et-1,e===N?(o(t,!0),0===t.strm.avail_out?ct:bt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?_t:ut}function c(t,e){for(var a,i,n;;){if(t.lookahead<it){if(_(t),t.lookahead<it&&e===Z)return _t;if(0===t.lookahead)break}if(a=0,t.lookahead>=et&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+et-1])&t.hash_mask,a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=et-1,0!==a&&t.prev_length<t.max_lazy_match&&t.strstart-a<=t.w_size-it&&(t.match_length=f(t,a),t.match_length<=5&&(t.strategy===H||t.match_length===et&&t.strstart-t.match_start>4096)&&(t.match_length=et-1)),t.prev_length>=et&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-et,i=B._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-et),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+et-1])&t.hash_mask,a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=et-1,t.strstart++,i&&(o(t,!1),0===t.strm.avail_out))return _t}else if(t.match_available){if((i=B._tr_tally(t,0,t.window[t.strstart-1]))&&o(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return _t}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=B._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<et-1?t.strstart:et-1,e===N?(o(t,!0),0===t.strm.avail_out?ct:bt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?_t:ut}function b(t,e){for(var a,i,n,r,s=t.window;;){if(t.lookahead<=at){if(_(t),t.lookahead<=at&&e===Z)return _t;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=et&&t.strstart>0&&(n=t.strstart-1,(i=s[n])===s[++n]&&i===s[++n]&&i===s[++n])){r=t.strstart+at;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<r);t.match_length=at-(r-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=et?(a=B._tr_tally(t,1,t.match_length-et),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=B._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(o(t,!1),0===t.strm.avail_out))return _t}return t.insert=0,e===N?(o(t,!0),0===t.strm.avail_out?ct:bt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?_t:ut}function g(t,e){for(var a;;){if(0===t.lookahead&&(_(t),0===t.lookahead)){if(e===Z)return _t;break}if(t.match_length=0,a=B._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(o(t,!1),0===t.strm.avail_out))return _t}return t.insert=0,e===N?(o(t,!0),0===t.strm.avail_out?ct:bt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?_t:ut}function m(t,e,a,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=i,this.func=n}function w(t){t.window_size=2*t.w_size,r(t.head),t.max_lazy_match=x[t.level].max_lazy,t.good_match=x[t.level].good_length,t.nice_match=x[t.level].nice_length,t.max_chain_length=x[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=et-1,t.match_available=0,t.ins_h=0}function p(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=q,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new z.Buf16(2*$),this.dyn_dtree=new z.Buf16(2*(2*Q+1)),this.bl_tree=new z.Buf16(2*(2*V+1)),r(this.dyn_ltree),r(this.dyn_dtree),r(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new z.Buf16(tt+1),this.heap=new z.Buf16(2*J+1),r(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new z.Buf16(2*J+1),r(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function v(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=Y,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?rt:dt,t.adler=2===e.wrap?0:1,e.last_flush=Z,B._tr_init(e),D):i(t,U)}function k(t){var e=v(t);return e===D&&w(t.state),e}function y(t,e,a,n,r,s){if(!t)return U;var o=1;if(e===L&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>G||a!==q||n<8||n>15||e<0||e>9||s<0||s>M)return i(t,U);8===n&&(n=9);var l=new p;return t.state=l,l.strm=t,l.wrap=o,l.gzhead=null,l.w_bits=n,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=r+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+et-1)/et),l.window=new z.Buf8(2*l.w_size),l.head=new z.Buf16(l.hash_size),l.prev=new z.Buf16(l.w_size),l.lit_bufsize=1<<r+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new z.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=e,l.strategy=s,l.method=a,k(t)}var x,z=t("../utils/common"),B=t("./trees"),S=t("./adler32"),E=t("./crc32"),A=t("./messages"),Z=0,R=1,C=3,N=4,O=5,D=0,I=1,U=-2,T=-3,F=-5,L=-1,H=1,j=2,K=3,M=4,P=0,Y=2,q=8,G=9,X=15,W=8,J=286,Q=30,V=19,$=2*J+1,tt=15,et=3,at=258,it=at+et+1,nt=32,rt=42,st=69,ot=73,lt=91,ht=103,dt=113,ft=666,_t=1,ut=2,ct=3,bt=4,gt=3;x=[new m(0,0,0,0,function(t,e){var a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(_(t),0===t.lookahead&&e===Z)return _t;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+a;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,o(t,!1),0===t.strm.avail_out))return _t;if(t.strstart-t.block_start>=t.w_size-it&&(o(t,!1),0===t.strm.avail_out))return _t}return t.insert=0,e===N?(o(t,!0),0===t.strm.avail_out?ct:bt):(t.strstart>t.block_start&&(o(t,!1),t.strm.avail_out),_t)}),new m(4,4,8,4,u),new m(4,5,16,8,u),new m(4,6,32,32,u),new m(4,4,16,16,c),new m(8,16,32,32,c),new m(8,16,128,128,c),new m(8,32,128,256,c),new m(32,128,258,1024,c),new m(32,258,258,4096,c)],a.deflateInit=function(t,e){return y(t,e,q,X,W,P)},a.deflateInit2=y,a.deflateReset=k,a.deflateResetKeep=v,a.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?U:(t.state.gzhead=e,D):U},a.deflate=function(t,e){var a,o,d,f;if(!t||!t.state||e>O||e<0)return t?i(t,U):U;if(o=t.state,!t.output||!t.input&&0!==t.avail_in||o.status===ft&&e!==N)return i(t,0===t.avail_out?F:U);if(o.strm=t,a=o.last_flush,o.last_flush=e,o.status===rt)if(2===o.wrap)t.adler=0,l(o,31),l(o,139),l(o,8),o.gzhead?(l(o,(o.gzhead.text?1:0)+(o.gzhead.hcrc?2:0)+(o.gzhead.extra?4:0)+(o.gzhead.name?8:0)+(o.gzhead.comment?16:0)),l(o,255&o.gzhead.time),l(o,o.gzhead.time>>8&255),l(o,o.gzhead.time>>16&255),l(o,o.gzhead.time>>24&255),l(o,9===o.level?2:o.strategy>=j||o.level<2?4:0),l(o,255&o.gzhead.os),o.gzhead.extra&&o.gzhead.extra.length&&(l(o,255&o.gzhead.extra.length),l(o,o.gzhead.extra.length>>8&255)),o.gzhead.hcrc&&(t.adler=E(t.adler,o.pending_buf,o.pending,0)),o.gzindex=0,o.status=st):(l(o,0),l(o,0),l(o,0),l(o,0),l(o,0),l(o,9===o.level?2:o.strategy>=j||o.level<2?4:0),l(o,gt),o.status=dt);else{var _=q+(o.w_bits-8<<4)<<8;_|=(o.strategy>=j||o.level<2?0:o.level<6?1:6===o.level?2:3)<<6,0!==o.strstart&&(_|=nt),_+=31-_%31,o.status=dt,h(o,_),0!==o.strstart&&(h(o,t.adler>>>16),h(o,65535&t.adler)),t.adler=1}if(o.status===st)if(o.gzhead.extra){for(d=o.pending;o.gzindex<(65535&o.gzhead.extra.length)&&(o.pending!==o.pending_buf_size||(o.gzhead.hcrc&&o.pending>d&&(t.adler=E(t.adler,o.pending_buf,o.pending-d,d)),s(t),d=o.pending,o.pending!==o.pending_buf_size));)l(o,255&o.gzhead.extra[o.gzindex]),o.gzindex++;o.gzhead.hcrc&&o.pending>d&&(t.adler=E(t.adler,o.pending_buf,o.pending-d,d)),o.gzindex===o.gzhead.extra.length&&(o.gzindex=0,o.status=ot)}else o.status=ot;if(o.status===ot)if(o.gzhead.name){d=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>d&&(t.adler=E(t.adler,o.pending_buf,o.pending-d,d)),s(t),d=o.pending,o.pending===o.pending_buf_size)){f=1;break}f=o.gzindex<o.gzhead.name.length?255&o.gzhead.name.charCodeAt(o.gzindex++):0,l(o,f)}while(0!==f);o.gzhead.hcrc&&o.pending>d&&(t.adler=E(t.adler,o.pending_buf,o.pending-d,d)),0===f&&(o.gzindex=0,o.status=lt)}else o.status=lt;if(o.status===lt)if(o.gzhead.comment){d=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>d&&(t.adler=E(t.adler,o.pending_buf,o.pending-d,d)),s(t),d=o.pending,o.pending===o.pending_buf_size)){f=1;break}f=o.gzindex<o.gzhead.comment.length?255&o.gzhead.comment.charCodeAt(o.gzindex++):0,l(o,f)}while(0!==f);o.gzhead.hcrc&&o.pending>d&&(t.adler=E(t.adler,o.pending_buf,o.pending-d,d)),0===f&&(o.status=ht)}else o.status=ht;if(o.status===ht&&(o.gzhead.hcrc?(o.pending+2>o.pending_buf_size&&s(t),o.pending+2<=o.pending_buf_size&&(l(o,255&t.adler),l(o,t.adler>>8&255),t.adler=0,o.status=dt)):o.status=dt),0!==o.pending){if(s(t),0===t.avail_out)return o.last_flush=-1,D}else if(0===t.avail_in&&n(e)<=n(a)&&e!==N)return i(t,F);if(o.status===ft&&0!==t.avail_in)return i(t,F);if(0!==t.avail_in||0!==o.lookahead||e!==Z&&o.status!==ft){var u=o.strategy===j?g(o,e):o.strategy===K?b(o,e):x[o.level].func(o,e);if(u!==ct&&u!==bt||(o.status=ft),u===_t||u===ct)return 0===t.avail_out&&(o.last_flush=-1),D;if(u===ut&&(e===R?B._tr_align(o):e!==O&&(B._tr_stored_block(o,0,0,!1),e===C&&(r(o.head),0===o.lookahead&&(o.strstart=0,o.block_start=0,o.insert=0))),s(t),0===t.avail_out))return o.last_flush=-1,D}return e!==N?D:o.wrap<=0?I:(2===o.wrap?(l(o,255&t.adler),l(o,t.adler>>8&255),l(o,t.adler>>16&255),l(o,t.adler>>24&255),l(o,255&t.total_in),l(o,t.total_in>>8&255),l(o,t.total_in>>16&255),l(o,t.total_in>>24&255)):(h(o,t.adler>>>16),h(o,65535&t.adler)),s(t),o.wrap>0&&(o.wrap=-o.wrap),0!==o.pending?D:I)},a.deflateEnd=function(t){var e;return t&&t.state?(e=t.state.status)!==rt&&e!==st&&e!==ot&&e!==lt&&e!==ht&&e!==dt&&e!==ft?i(t,U):(t.state=null,e===dt?i(t,T):D):U},a.deflateSetDictionary=function(t,e){var a,i,n,s,o,l,h,d,f=e.length;if(!t||!t.state)return U;if(a=t.state,2===(s=a.wrap)||1===s&&a.status!==rt||a.lookahead)return U;for(1===s&&(t.adler=S(t.adler,e,f,0)),a.wrap=0,f>=a.w_size&&(0===s&&(r(a.head),a.strstart=0,a.block_start=0,a.insert=0),d=new z.Buf8(a.w_size),z.arraySet(d,e,f-a.w_size,a.w_size,0),e=d,f=a.w_size),o=t.avail_in,l=t.next_in,h=t.input,t.avail_in=f,t.next_in=0,t.input=e,_(a);a.lookahead>=et;){i=a.strstart,n=a.lookahead-(et-1);do{a.ins_h=(a.ins_h<<a.hash_shift^a.window[i+et-1])&a.hash_mask,a.prev[i&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=i,i++}while(--n);a.strstart=i,a.lookahead=et-1,_(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=et-1,a.match_available=0,t.next_in=l,t.input=h,t.avail_in=o,a.wrap=s,D},a.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":3,"./adler32":5,"./crc32":7,"./messages":13,"./trees":14}],9:[function(t,e,a){"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],10:[function(t,e,a){"use strict";e.exports=function(t,e){var a,i,n,r,s,o,l,h,d,f,_,u,c,b,g,m,w,p,v,k,y,x,z,B,S;a=t.state,i=t.next_in,B=t.input,n=i+(t.avail_in-5),r=t.next_out,S=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),l=a.dmax,h=a.wsize,d=a.whave,f=a.wnext,_=a.window,u=a.hold,c=a.bits,b=a.lencode,g=a.distcode,m=(1<<a.lenbits)-1,w=(1<<a.distbits)-1;t:do{c<15&&(u+=B[i++]<<c,c+=8,u+=B[i++]<<c,c+=8),p=b[u&m];e:for(;;){if(v=p>>>24,u>>>=v,c-=v,0===(v=p>>>16&255))S[r++]=65535&p;else{if(!(16&v)){if(0==(64&v)){p=b[(65535&p)+(u&(1<<v)-1)];continue e}if(32&v){a.mode=12;break t}t.msg="invalid literal/length code",a.mode=30;break t}k=65535&p,(v&=15)&&(c<v&&(u+=B[i++]<<c,c+=8),k+=u&(1<<v)-1,u>>>=v,c-=v),c<15&&(u+=B[i++]<<c,c+=8,u+=B[i++]<<c,c+=8),p=g[u&w];a:for(;;){if(v=p>>>24,u>>>=v,c-=v,!(16&(v=p>>>16&255))){if(0==(64&v)){p=g[(65535&p)+(u&(1<<v)-1)];continue a}t.msg="invalid distance code",a.mode=30;break t}if(y=65535&p,v&=15,c<v&&(u+=B[i++]<<c,(c+=8)<v&&(u+=B[i++]<<c,c+=8)),(y+=u&(1<<v)-1)>l){t.msg="invalid distance too far back",a.mode=30;break t}if(u>>>=v,c-=v,v=r-s,y>v){if((v=y-v)>d&&a.sane){t.msg="invalid distance too far back",a.mode=30;break t}if(x=0,z=_,0===f){if(x+=h-v,v<k){k-=v;do{S[r++]=_[x++]}while(--v);x=r-y,z=S}}else if(f<v){if(x+=h+f-v,(v-=f)<k){k-=v;do{S[r++]=_[x++]}while(--v);if(x=0,f<k){k-=v=f;do{S[r++]=_[x++]}while(--v);x=r-y,z=S}}}else if(x+=f-v,v<k){k-=v;do{S[r++]=_[x++]}while(--v);x=r-y,z=S}for(;k>2;)S[r++]=z[x++],S[r++]=z[x++],S[r++]=z[x++],k-=3;k&&(S[r++]=z[x++],k>1&&(S[r++]=z[x++]))}else{x=r-y;do{S[r++]=S[x++],S[r++]=S[x++],S[r++]=S[x++],k-=3}while(k>2);k&&(S[r++]=S[x++],k>1&&(S[r++]=S[x++]))}break}}break}}while(i<n&&r<o);i-=k=c>>3,u&=(1<<(c-=k<<3))-1,t.next_in=i,t.next_out=r,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=r<o?o-r+257:257-(r-o),a.hold=u,a.bits=c}},{}],11:[function(t,e,a){"use strict";function i(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function n(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new u.Buf16(320),this.work=new u.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function r(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=N,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new u.Buf32(dt),e.distcode=e.distdyn=new u.Buf32(ft),e.sane=1,e.back=-1,z):E}function s(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,r(t)):E}function o(t,e){var a,i;return t&&t.state?(i=t.state,e<0?(a=0,e=-e):(a=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?E:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,s(t))):E}function l(t,e){var a,i;return t?(i=new n,t.state=i,i.window=null,(a=o(t,e))!==z&&(t.state=null),a):E}function h(t){if(ut){var e;for(f=new u.Buf32(512),_=new u.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(m(p,t.lens,0,288,f,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;m(v,t.lens,0,32,_,0,t.work,{bits:5}),ut=!1}t.lencode=f,t.lenbits=9,t.distcode=_,t.distbits=5}function d(t,e,a,i){var n,r=t.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new u.Buf8(r.wsize)),i>=r.wsize?(u.arraySet(r.window,e,a-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):((n=r.wsize-r.wnext)>i&&(n=i),u.arraySet(r.window,e,a-i,n,r.wnext),(i-=n)?(u.arraySet(r.window,e,a-i,i,0),r.wnext=i,r.whave=r.wsize):(r.wnext+=n,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=n))),0}var f,_,u=t("../utils/common"),c=t("./adler32"),b=t("./crc32"),g=t("./inffast"),m=t("./inftrees"),w=0,p=1,v=2,k=4,y=5,x=6,z=0,B=1,S=2,E=-2,A=-3,Z=-4,R=-5,C=8,N=1,O=2,D=3,I=4,U=5,T=6,F=7,L=8,H=9,j=10,K=11,M=12,P=13,Y=14,q=15,G=16,X=17,W=18,J=19,Q=20,V=21,$=22,tt=23,et=24,at=25,it=26,nt=27,rt=28,st=29,ot=30,lt=31,ht=32,dt=852,ft=592,_t=15,ut=!0;a.inflateReset=s,a.inflateReset2=o,a.inflateResetKeep=r,a.inflateInit=function(t){return l(t,_t)},a.inflateInit2=l,a.inflate=function(t,e){var a,n,r,s,o,l,f,_,dt,ft,_t,ut,ct,bt,gt,mt,wt,pt,vt,kt,yt,xt,zt,Bt,St=0,Et=new u.Buf8(4),At=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return E;(a=t.state).mode===M&&(a.mode=P),o=t.next_out,r=t.output,f=t.avail_out,s=t.next_in,n=t.input,l=t.avail_in,_=a.hold,dt=a.bits,ft=l,_t=f,xt=z;t:for(;;)switch(a.mode){case N:if(0===a.wrap){a.mode=P;break}for(;dt<16;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(2&a.wrap&&35615===_){a.check=0,Et[0]=255&_,Et[1]=_>>>8&255,a.check=b(a.check,Et,2,0),_=0,dt=0,a.mode=O;break}if(a.flags=0,a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&_)<<8)+(_>>8))%31){t.msg="incorrect header check",a.mode=ot;break}if((15&_)!==C){t.msg="unknown compression method",a.mode=ot;break}if(_>>>=4,dt-=4,yt=8+(15&_),0===a.wbits)a.wbits=yt;else if(yt>a.wbits){t.msg="invalid window size",a.mode=ot;break}a.dmax=1<<yt,t.adler=a.check=1,a.mode=512&_?j:M,_=0,dt=0;break;case O:for(;dt<16;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(a.flags=_,(255&a.flags)!==C){t.msg="unknown compression method",a.mode=ot;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=ot;break}a.head&&(a.head.text=_>>8&1),512&a.flags&&(Et[0]=255&_,Et[1]=_>>>8&255,a.check=b(a.check,Et,2,0)),_=0,dt=0,a.mode=D;case D:for(;dt<32;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}a.head&&(a.head.time=_),512&a.flags&&(Et[0]=255&_,Et[1]=_>>>8&255,Et[2]=_>>>16&255,Et[3]=_>>>24&255,a.check=b(a.check,Et,4,0)),_=0,dt=0,a.mode=I;case I:for(;dt<16;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}a.head&&(a.head.xflags=255&_,a.head.os=_>>8),512&a.flags&&(Et[0]=255&_,Et[1]=_>>>8&255,a.check=b(a.check,Et,2,0)),_=0,dt=0,a.mode=U;case U:if(1024&a.flags){for(;dt<16;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}a.length=_,a.head&&(a.head.extra_len=_),512&a.flags&&(Et[0]=255&_,Et[1]=_>>>8&255,a.check=b(a.check,Et,2,0)),_=0,dt=0}else a.head&&(a.head.extra=null);a.mode=T;case T:if(1024&a.flags&&((ut=a.length)>l&&(ut=l),ut&&(a.head&&(yt=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Array(a.head.extra_len)),u.arraySet(a.head.extra,n,s,ut,yt)),512&a.flags&&(a.check=b(a.check,n,ut,s)),l-=ut,s+=ut,a.length-=ut),a.length))break t;a.length=0,a.mode=F;case F:if(2048&a.flags){if(0===l)break t;ut=0;do{yt=n[s+ut++],a.head&&yt&&a.length<65536&&(a.head.name+=String.fromCharCode(yt))}while(yt&&ut<l);if(512&a.flags&&(a.check=b(a.check,n,ut,s)),l-=ut,s+=ut,yt)break t}else a.head&&(a.head.name=null);a.length=0,a.mode=L;case L:if(4096&a.flags){if(0===l)break t;ut=0;do{yt=n[s+ut++],a.head&&yt&&a.length<65536&&(a.head.comment+=String.fromCharCode(yt))}while(yt&&ut<l);if(512&a.flags&&(a.check=b(a.check,n,ut,s)),l-=ut,s+=ut,yt)break t}else a.head&&(a.head.comment=null);a.mode=H;case H:if(512&a.flags){for(;dt<16;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(_!==(65535&a.check)){t.msg="header crc mismatch",a.mode=ot;break}_=0,dt=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),t.adler=a.check=0,a.mode=M;break;case j:for(;dt<32;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}t.adler=a.check=i(_),_=0,dt=0,a.mode=K;case K:if(0===a.havedict)return t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=l,a.hold=_,a.bits=dt,S;t.adler=a.check=1,a.mode=M;case M:if(e===y||e===x)break t;case P:if(a.last){_>>>=7&dt,dt-=7&dt,a.mode=nt;break}for(;dt<3;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}switch(a.last=1&_,_>>>=1,dt-=1,3&_){case 0:a.mode=Y;break;case 1:if(h(a),a.mode=Q,e===x){_>>>=2,dt-=2;break t}break;case 2:a.mode=X;break;case 3:t.msg="invalid block type",a.mode=ot}_>>>=2,dt-=2;break;case Y:for(_>>>=7&dt,dt-=7&dt;dt<32;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if((65535&_)!=(_>>>16^65535)){t.msg="invalid stored block lengths",a.mode=ot;break}if(a.length=65535&_,_=0,dt=0,a.mode=q,e===x)break t;case q:a.mode=G;case G:if(ut=a.length){if(ut>l&&(ut=l),ut>f&&(ut=f),0===ut)break t;u.arraySet(r,n,s,ut,o),l-=ut,s+=ut,f-=ut,o+=ut,a.length-=ut;break}a.mode=M;break;case X:for(;dt<14;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(a.nlen=257+(31&_),_>>>=5,dt-=5,a.ndist=1+(31&_),_>>>=5,dt-=5,a.ncode=4+(15&_),_>>>=4,dt-=4,a.nlen>286||a.ndist>30){t.msg="too many length or distance symbols",a.mode=ot;break}a.have=0,a.mode=W;case W:for(;a.have<a.ncode;){for(;dt<3;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}a.lens[At[a.have++]]=7&_,_>>>=3,dt-=3}for(;a.have<19;)a.lens[At[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,zt={bits:a.lenbits},xt=m(w,a.lens,0,19,a.lencode,0,a.work,zt),a.lenbits=zt.bits,xt){t.msg="invalid code lengths set",a.mode=ot;break}a.have=0,a.mode=J;case J:for(;a.have<a.nlen+a.ndist;){for(;St=a.lencode[_&(1<<a.lenbits)-1],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(gt<=dt);){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(wt<16)_>>>=gt,dt-=gt,a.lens[a.have++]=wt;else{if(16===wt){for(Bt=gt+2;dt<Bt;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(_>>>=gt,dt-=gt,0===a.have){t.msg="invalid bit length repeat",a.mode=ot;break}yt=a.lens[a.have-1],ut=3+(3&_),_>>>=2,dt-=2}else if(17===wt){for(Bt=gt+3;dt<Bt;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}dt-=gt,yt=0,ut=3+(7&(_>>>=gt)),_>>>=3,dt-=3}else{for(Bt=gt+7;dt<Bt;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}dt-=gt,yt=0,ut=11+(127&(_>>>=gt)),_>>>=7,dt-=7}if(a.have+ut>a.nlen+a.ndist){t.msg="invalid bit length repeat",a.mode=ot;break}for(;ut--;)a.lens[a.have++]=yt}}if(a.mode===ot)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=ot;break}if(a.lenbits=9,zt={bits:a.lenbits},xt=m(p,a.lens,0,a.nlen,a.lencode,0,a.work,zt),a.lenbits=zt.bits,xt){t.msg="invalid literal/lengths set",a.mode=ot;break}if(a.distbits=6,a.distcode=a.distdyn,zt={bits:a.distbits},xt=m(v,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,zt),a.distbits=zt.bits,xt){t.msg="invalid distances set",a.mode=ot;break}if(a.mode=Q,e===x)break t;case Q:a.mode=V;case V:if(l>=6&&f>=258){t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=l,a.hold=_,a.bits=dt,g(t,_t),o=t.next_out,r=t.output,f=t.avail_out,s=t.next_in,n=t.input,l=t.avail_in,_=a.hold,dt=a.bits,a.mode===M&&(a.back=-1);break}for(a.back=0;St=a.lencode[_&(1<<a.lenbits)-1],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(gt<=dt);){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(mt&&0==(240&mt)){for(pt=gt,vt=mt,kt=wt;St=a.lencode[kt+((_&(1<<pt+vt)-1)>>pt)],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(pt+gt<=dt);){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}_>>>=pt,dt-=pt,a.back+=pt}if(_>>>=gt,dt-=gt,a.back+=gt,a.length=wt,0===mt){a.mode=it;break}if(32&mt){a.back=-1,a.mode=M;break}if(64&mt){t.msg="invalid literal/length code",a.mode=ot;break}a.extra=15&mt,a.mode=$;case $:if(a.extra){for(Bt=a.extra;dt<Bt;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}a.length+=_&(1<<a.extra)-1,_>>>=a.extra,dt-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=tt;case tt:for(;St=a.distcode[_&(1<<a.distbits)-1],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(gt<=dt);){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(0==(240&mt)){for(pt=gt,vt=mt,kt=wt;St=a.distcode[kt+((_&(1<<pt+vt)-1)>>pt)],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(pt+gt<=dt);){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}_>>>=pt,dt-=pt,a.back+=pt}if(_>>>=gt,dt-=gt,a.back+=gt,64&mt){t.msg="invalid distance code",a.mode=ot;break}a.offset=wt,a.extra=15&mt,a.mode=et;case et:if(a.extra){for(Bt=a.extra;dt<Bt;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}a.offset+=_&(1<<a.extra)-1,_>>>=a.extra,dt-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){t.msg="invalid distance too far back",a.mode=ot;break}a.mode=at;case at:if(0===f)break t;if(ut=_t-f,a.offset>ut){if((ut=a.offset-ut)>a.whave&&a.sane){t.msg="invalid distance too far back",a.mode=ot;break}ut>a.wnext?(ut-=a.wnext,ct=a.wsize-ut):ct=a.wnext-ut,ut>a.length&&(ut=a.length),bt=a.window}else bt=r,ct=o-a.offset,ut=a.length;ut>f&&(ut=f),f-=ut,a.length-=ut;do{r[o++]=bt[ct++]}while(--ut);0===a.length&&(a.mode=V);break;case it:if(0===f)break t;r[o++]=a.length,f--,a.mode=V;break;case nt:if(a.wrap){for(;dt<32;){if(0===l)break t;l--,_|=n[s++]<<dt,dt+=8}if(_t-=f,t.total_out+=_t,a.total+=_t,_t&&(t.adler=a.check=a.flags?b(a.check,r,_t,o-_t):c(a.check,r,_t,o-_t)),_t=f,(a.flags?_:i(_))!==a.check){t.msg="incorrect data check",a.mode=ot;break}_=0,dt=0}a.mode=rt;case rt:if(a.wrap&&a.flags){for(;dt<32;){if(0===l)break t;l--,_+=n[s++]<<dt,dt+=8}if(_!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=ot;break}_=0,dt=0}a.mode=st;case st:xt=B;break t;case ot:xt=A;break t;case lt:return Z;case ht:default:return E}return t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=l,a.hold=_,a.bits=dt,(a.wsize||_t!==t.avail_out&&a.mode<ot&&(a.mode<nt||e!==k))&&d(t,t.output,t.next_out,_t-t.avail_out)?(a.mode=lt,Z):(ft-=t.avail_in,_t-=t.avail_out,t.total_in+=ft,t.total_out+=_t,a.total+=_t,a.wrap&&_t&&(t.adler=a.check=a.flags?b(a.check,r,_t,t.next_out-_t):c(a.check,r,_t,t.next_out-_t)),t.data_type=a.bits+(a.last?64:0)+(a.mode===M?128:0)+(a.mode===Q||a.mode===q?256:0),(0===ft&&0===_t||e===k)&&xt===z&&(xt=R),xt)},a.inflateEnd=function(t){if(!t||!t.state)return E;var e=t.state;return e.window&&(e.window=null),t.state=null,z},a.inflateGetHeader=function(t,e){var a;return t&&t.state?0==(2&(a=t.state).wrap)?E:(a.head=e,e.done=!1,z):E},a.inflateSetDictionary=function(t,e){var a,i,n=e.length;return t&&t.state?0!==(a=t.state).wrap&&a.mode!==K?E:a.mode===K&&(i=1,(i=c(i,e,n,0))!==a.check)?A:d(t,e,n,n)?(a.mode=lt,Z):(a.havedict=1,z):E},a.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":3,"./adler32":5,"./crc32":7,"./inffast":10,"./inftrees":12}],12:[function(t,e,a){"use strict";var i=t("../utils/common"),n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],r=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(t,e,a,l,h,d,f,_){var u,c,b,g,m,w,p,v,k,y=_.bits,x=0,z=0,B=0,S=0,E=0,A=0,Z=0,R=0,C=0,N=0,O=null,D=0,I=new i.Buf16(16),U=new i.Buf16(16),T=null,F=0;for(x=0;x<=15;x++)I[x]=0;for(z=0;z<l;z++)I[e[a+z]]++;for(E=y,S=15;S>=1&&0===I[S];S--);if(E>S&&(E=S),0===S)return h[d++]=20971520,h[d++]=20971520,_.bits=1,0;for(B=1;B<S&&0===I[B];B++);for(E<B&&(E=B),R=1,x=1;x<=15;x++)if(R<<=1,(R-=I[x])<0)return-1;if(R>0&&(0===t||1!==S))return-1;for(U[1]=0,x=1;x<15;x++)U[x+1]=U[x]+I[x];for(z=0;z<l;z++)0!==e[a+z]&&(f[U[e[a+z]]++]=z);if(0===t?(O=T=f,w=19):1===t?(O=n,D-=257,T=r,F-=257,w=256):(O=s,T=o,w=-1),N=0,z=0,x=B,m=d,A=E,Z=0,b=-1,C=1<<E,g=C-1,1===t&&C>852||2===t&&C>592)return 1;for(;;){p=x-Z,f[z]<w?(v=0,k=f[z]):f[z]>w?(v=T[F+f[z]],k=O[D+f[z]]):(v=96,k=0),u=1<<x-Z,B=c=1<<A;do{h[m+(N>>Z)+(c-=u)]=p<<24|v<<16|k|0}while(0!==c);for(u=1<<x-1;N&u;)u>>=1;if(0!==u?(N&=u-1,N+=u):N=0,z++,0==--I[x]){if(x===S)break;x=e[a+f[z]]}if(x>E&&(N&g)!==b){for(0===Z&&(Z=E),m+=B,R=1<<(A=x-Z);A+Z<S&&!((R-=I[A+Z])<=0);)A++,R<<=1;if(C+=1<<A,1===t&&C>852||2===t&&C>592)return 1;h[b=N&g]=E<<24|A<<16|m-d|0}}return 0!==N&&(h[m+N]=x-Z<<24|64<<16|0),_.bits=E,0}},{"../utils/common":3}],13:[function(t,e,a){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],14:[function(t,e,a){"use strict";function i(t){for(var e=t.length;--e>=0;)t[e]=0}function n(t,e,a,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}function r(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function s(t){return t<256?et[t]:et[256+(t>>>7)]}function o(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function l(t,e,a){t.bi_valid>M-a?(t.bi_buf|=e<<t.bi_valid&65535,o(t,t.bi_buf),t.bi_buf=e>>M-t.bi_valid,t.bi_valid+=a-M):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=a)}function h(t,e,a){l(t,a[2*e],a[2*e+1])}function d(t,e){var a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1}function f(t){16===t.bi_valid?(o(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}function _(t,e){var a,i,n,r,s,o,l=e.dyn_tree,h=e.max_code,d=e.stat_desc.static_tree,f=e.stat_desc.has_stree,_=e.stat_desc.extra_bits,u=e.stat_desc.extra_base,c=e.stat_desc.max_length,b=0;for(r=0;r<=K;r++)t.bl_count[r]=0;for(l[2*t.heap[t.heap_max]+1]=0,a=t.heap_max+1;a<j;a++)(r=l[2*l[2*(i=t.heap[a])+1]+1]+1)>c&&(r=c,b++),l[2*i+1]=r,i>h||(t.bl_count[r]++,s=0,i>=u&&(s=_[i-u]),o=l[2*i],t.opt_len+=o*(r+s),f&&(t.static_len+=o*(d[2*i+1]+s)));if(0!==b){do{for(r=c-1;0===t.bl_count[r];)r--;t.bl_count[r]--,t.bl_count[r+1]+=2,t.bl_count[c]--,b-=2}while(b>0);for(r=c;0!==r;r--)for(i=t.bl_count[r];0!==i;)(n=t.heap[--a])>h||(l[2*n+1]!==r&&(t.opt_len+=(r-l[2*n+1])*l[2*n],l[2*n+1]=r),i--)}}function u(t,e,a){var i,n,r=new Array(K+1),s=0;for(i=1;i<=K;i++)r[i]=s=s+a[i-1]<<1;for(n=0;n<=e;n++){var o=t[2*n+1];0!==o&&(t[2*n]=d(r[o]++,o))}}function c(){var t,e,a,i,r,s=new Array(K+1);for(a=0,i=0;i<U-1;i++)for(it[i]=a,t=0;t<1<<W[i];t++)at[a++]=i;for(at[a-1]=i,r=0,i=0;i<16;i++)for(nt[i]=r,t=0;t<1<<J[i];t++)et[r++]=i;for(r>>=7;i<L;i++)for(nt[i]=r<<7,t=0;t<1<<J[i]-7;t++)et[256+r++]=i;for(e=0;e<=K;e++)s[e]=0;for(t=0;t<=143;)$[2*t+1]=8,t++,s[8]++;for(;t<=255;)$[2*t+1]=9,t++,s[9]++;for(;t<=279;)$[2*t+1]=7,t++,s[7]++;for(;t<=287;)$[2*t+1]=8,t++,s[8]++;for(u($,F+1,s),t=0;t<L;t++)tt[2*t+1]=5,tt[2*t]=d(t,5);rt=new n($,W,T+1,F,K),st=new n(tt,J,0,L,K),ot=new n(new Array(0),Q,0,H,P)}function b(t){var e;for(e=0;e<F;e++)t.dyn_ltree[2*e]=0;for(e=0;e<L;e++)t.dyn_dtree[2*e]=0;for(e=0;e<H;e++)t.bl_tree[2*e]=0;t.dyn_ltree[2*Y]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function g(t){t.bi_valid>8?o(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function m(t,e,a,i){g(t),i&&(o(t,a),o(t,~a)),A.arraySet(t.pending_buf,t.window,e,a,t.pending),t.pending+=a}function w(t,e,a,i){var n=2*e,r=2*a;return t[n]<t[r]||t[n]===t[r]&&i[e]<=i[a]}function p(t,e,a){for(var i=t.heap[a],n=a<<1;n<=t.heap_len&&(n<t.heap_len&&w(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!w(e,i,t.heap[n],t.depth));)t.heap[a]=t.heap[n],a=n,n<<=1;t.heap[a]=i}function v(t,e,a){var i,n,r,o,d=0;if(0!==t.last_lit)do{i=t.pending_buf[t.d_buf+2*d]<<8|t.pending_buf[t.d_buf+2*d+1],n=t.pending_buf[t.l_buf+d],d++,0===i?h(t,n,e):(h(t,(r=at[n])+T+1,e),0!==(o=W[r])&&l(t,n-=it[r],o),h(t,r=s(--i),a),0!==(o=J[r])&&l(t,i-=nt[r],o))}while(d<t.last_lit);h(t,Y,e)}function k(t,e){var a,i,n,r=e.dyn_tree,s=e.stat_desc.static_tree,o=e.stat_desc.has_stree,l=e.stat_desc.elems,h=-1;for(t.heap_len=0,t.heap_max=j,a=0;a<l;a++)0!==r[2*a]?(t.heap[++t.heap_len]=h=a,t.depth[a]=0):r[2*a+1]=0;for(;t.heap_len<2;)r[2*(n=t.heap[++t.heap_len]=h<2?++h:0)]=1,t.depth[n]=0,t.opt_len--,o&&(t.static_len-=s[2*n+1]);for(e.max_code=h,a=t.heap_len>>1;a>=1;a--)p(t,r,a);n=l;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],p(t,r,1),i=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=i,r[2*n]=r[2*a]+r[2*i],t.depth[n]=(t.depth[a]>=t.depth[i]?t.depth[a]:t.depth[i])+1,r[2*a+1]=r[2*i+1]=n,t.heap[1]=n++,p(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],_(t,e),u(r,h,t.bl_count)}function y(t,e,a){var i,n,r=-1,s=e[1],o=0,l=7,h=4;for(0===s&&(l=138,h=3),e[2*(a+1)+1]=65535,i=0;i<=a;i++)n=s,s=e[2*(i+1)+1],++o<l&&n===s||(o<h?t.bl_tree[2*n]+=o:0!==n?(n!==r&&t.bl_tree[2*n]++,t.bl_tree[2*q]++):o<=10?t.bl_tree[2*G]++:t.bl_tree[2*X]++,o=0,r=n,0===s?(l=138,h=3):n===s?(l=6,h=3):(l=7,h=4))}function x(t,e,a){var i,n,r=-1,s=e[1],o=0,d=7,f=4;for(0===s&&(d=138,f=3),i=0;i<=a;i++)if(n=s,s=e[2*(i+1)+1],!(++o<d&&n===s)){if(o<f)do{h(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==r&&(h(t,n,t.bl_tree),o--),h(t,q,t.bl_tree),l(t,o-3,2)):o<=10?(h(t,G,t.bl_tree),l(t,o-3,3)):(h(t,X,t.bl_tree),l(t,o-11,7));o=0,r=n,0===s?(d=138,f=3):n===s?(d=6,f=3):(d=7,f=4)}}function z(t){var e;for(y(t,t.dyn_ltree,t.l_desc.max_code),y(t,t.dyn_dtree,t.d_desc.max_code),k(t,t.bl_desc),e=H-1;e>=3&&0===t.bl_tree[2*V[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}function B(t,e,a,i){var n;for(l(t,e-257,5),l(t,a-1,5),l(t,i-4,4),n=0;n<i;n++)l(t,t.bl_tree[2*V[n]+1],3);x(t,t.dyn_ltree,e-1),x(t,t.dyn_dtree,a-1)}function S(t){var e,a=4093624447;for(e=0;e<=31;e++,a>>>=1)if(1&a&&0!==t.dyn_ltree[2*e])return R;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return C;for(e=32;e<T;e++)if(0!==t.dyn_ltree[2*e])return C;return R}function E(t,e,a,i){l(t,(O<<1)+(i?1:0),3),m(t,e,a,!0)}var A=t("../utils/common"),Z=4,R=0,C=1,N=2,O=0,D=1,I=2,U=29,T=256,F=T+1+U,L=30,H=19,j=2*F+1,K=15,M=16,P=7,Y=256,q=16,G=17,X=18,W=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],J=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Q=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],$=new Array(2*(F+2));i($);var tt=new Array(2*L);i(tt);var et=new Array(512);i(et);var at=new Array(256);i(at);var it=new Array(U);i(it);var nt=new Array(L);i(nt);var rt,st,ot,lt=!1;a._tr_init=function(t){lt||(c(),lt=!0),t.l_desc=new r(t.dyn_ltree,rt),t.d_desc=new r(t.dyn_dtree,st),t.bl_desc=new r(t.bl_tree,ot),t.bi_buf=0,t.bi_valid=0,b(t)},a._tr_stored_block=E,a._tr_flush_block=function(t,e,a,i){var n,r,s=0;t.level>0?(t.strm.data_type===N&&(t.strm.data_type=S(t)),k(t,t.l_desc),k(t,t.d_desc),s=z(t),n=t.opt_len+3+7>>>3,(r=t.static_len+3+7>>>3)<=n&&(n=r)):n=r=a+5,a+4<=n&&-1!==e?E(t,e,a,i):t.strategy===Z||r===n?(l(t,(D<<1)+(i?1:0),3),v(t,$,tt)):(l(t,(I<<1)+(i?1:0),3),B(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),v(t,t.dyn_ltree,t.dyn_dtree)),b(t),i&&g(t)},a._tr_tally=function(t,e,a){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&a,t.last_lit++,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(at[a]+T+1)]++,t.dyn_dtree[2*s(e)]++),t.last_lit===t.lit_bufsize-1},a._tr_align=function(t){l(t,D<<1,3),h(t,Y,$),f(t)}},{"../utils/common":3}],15:[function(t,e,a){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/":[function(t,e,a){"use strict";var i={};(0,t("./lib/utils/common").assign)(i,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),e.exports=i},{"./lib/deflate":1,"./lib/inflate":2,"./lib/utils/common":3,"./lib/zlib/constants":6}]},{},[])("/")});
export default [
{
"name": "阿坝藏族羌族自治州",
"letter": "A",
"longitude": "102.221375",
"latitude": "31.899792"
},
{
"name": "阿克苏",
"letter": "A",
"longitude": "80.265068",
"latitude": "41.170712"
},
{
"name": "阿拉尔市",
"letter": "A",
"longitude": "81.285884",
"latitude": "40.541914"
},
{
"name": "阿拉善盟",
"letter": "A",
"longitude": "105.706423",
"latitude": "38.844814"
},
{
"name": "阿勒泰",
"letter": "A",
"longitude": "88.139630",
"latitude": "47.848393"
},
{
"name": "安康市",
"letter": "A",
"longitude": "109.029273",
"latitude": "32.690300"
},
{
"name": "安庆市",
"letter": "A",
"longitude": "117.043551",
"latitude": "30.508830"
},
{
"name": "鞍山市",
"letter": "A",
"longitude": "122.995632",
"latitude": "41.110626"
},
{
"name": "安顺市",
"letter": "A",
"longitude": "105.932188",
"latitude": "26.245544"
},
{
"name": "安阳市",
"letter": "A",
"longitude": "114.352482",
"latitude": "36.103442"
},
{
"name": "巴彦淖尔市",
"letter": "B",
"longitude": "107.416959",
"latitude": "40.757402"
},
{
"name": "巴音郭楞蒙古自治州",
"letter": "B",
"longitude": "86.150969",
"latitude": "41.768552"
},
{
"name": "巴中市",
"letter": "B",
"longitude": "106.753669",
"latitude": "31.858809"
},
{
"name": "白城市",
"letter": "B",
"longitude": "122.841114",
"latitude": "45.619026"
},
{
"name": "百色市",
"letter": "B",
"longitude": "106.616285",
"latitude": "23.897742"
},
{
"name": "白沙黎族自治县",
"letter": "B",
"longitude": "109.451484",
"latitude": "19.224823"
},
{
"name": "白山市",
"letter": "B",
"longitude": "126.427839",
"latitude": "41.942505"
},
{
"name": "白银市",
"letter": "B",
"longitude": "104.173606",
"latitude": "36.545680"
},
{
"name": "蚌埠市",
"letter": "B",
"longitude": "117.363228",
"latitude": "32.939667"
},
{
"name": "保定市",
"letter": "B",
"longitude": "115.464804",
"latitude": "38.874062"
},
{
"name": "宝鸡市",
"letter": "B",
"longitude": "107.144870",
"latitude": "34.369315"
},
{
"name": "保山市",
"letter": "B",
"longitude": "99.167133",
"latitude": "25.111802"
},
{
"name": "保亭黎族苗族自治县",
"letter": "B",
"longitude": "109.70259",
"latitude": "18.63913"
},
{
"name": "包头市",
"letter": "B",
"longitude": "109.840405",
"latitude": "40.658168"
},
{
"name": "北海市",
"letter": "B",
"longitude": "109.119254",
"latitude": "21.473343"
},
{
"name": "北京市",
"letter": "B",
"longitude": "116.307573",
"latitude": "40.048459"
},
{
"name": "北屯市",
"letter": "B",
"longitude": "87.824932",
"latitude": "47.353177"
},
{
"name": "本溪市",
"letter": "B",
"longitude": "123.770519",
"latitude": "41.297909"
},
{
"name": "毕节市",
"letter": "B",
"longitude": "105.285010",
"latitude": "27.301693"
},
{
"name": "滨州市",
"letter": "B",
"longitude": "118.016974",
"latitude": "37.383542"
},
{
"name": "博尔塔拉蒙古自治州",
"letter": "B",
"longitude": "82.074778",
"latitude": "44.903258"
},
{
"name": "亳州市",
"letter": "B",
"longitude": "115.782939",
"latitude": "33.869338"
},
{
"name": "沧州市",
"letter": "C",
"longitude": "116.857461",
"latitude": "38.310582"
},
{
"name": "长春市",
"letter": "C",
"longitude": "125.323628",
"latitude": "43.817001"
},
{
"name": "常德市",
"letter": "C",
"longitude": "111.691347",
"latitude": "29.040225"
},
{
"name": "昌都市",
"letter": "C",
"longitude": "97.178452",
"latitude": "31.136875"
},
{
"name": "昌吉回族自治州",
"letter": "C",
"longitude": "87.304012",
"latitude": "44.014577"
},
{
"name": "昌江黎族自治县",
"letter": "C",
"longitude": "109.055724",
"latitude": "19.298062"
},
{
"name": "长沙市",
"letter": "C",
"longitude": "112.938888",
"latitude": "28.228272"
},
{
"name": "长治市",
"letter": "C",
"longitude": "113.113556",
"latitude": "36.191112"
},
{
"name": "常州市",
"letter": "C",
"longitude": "119.946973",
"latitude": "31.772752"
},
{
"name": "朝阳市",
"letter": "C",
"longitude": "120.451176",
"latitude": "41.576758"
},
{
"name": "潮州市",
"letter": "C",
"longitude": "116.632301",
"latitude": "23.661701"
},
{
"name": "郴州市",
"letter": "C",
"longitude": "113.014718",
"latitude": "25.770510"
},
{
"name": "承德市",
"letter": "C",
"longitude": "117.939152",
"latitude": "40.976204"
},
{
"name": "成都市",
"letter": "C",
"longitude": "104.066143",
"latitude": "30.573095"
},
{
"name": "澄迈县",
"letter": "C",
"longitude": "110.006755",
"latitude": "19.738521"
},
{
"name": "赤峰市",
"letter": "C",
"longitude": "118.886856",
"latitude": "42.257817"
},
{
"name": "池州市",
"letter": "C",
"longitude": "117.489157",
"latitude": "30.656037"
},
{
"name": "重庆市",
"letter": "C",
"longitude": "106.551557",
"latitude": "29.563009"
},
{
"name": "崇左市",
"letter": "C",
"longitude": "107.353926",
"latitude": "22.404108"
},
{
"name": "楚雄彝族自治州",
"letter": "C",
"longitude": "101.546046",
"latitude": "25.041988"
},
{
"name": "滁州市",
"letter": "C",
"longitude": "118.316264",
"latitude": "32.303627"
},
{
"name": "大理白族自治州",
"letter": "D",
"longitude": "100.225668",
"latitude": "25.589449"
},
{
"name": "大连市",
"letter": "D",
"longitude": "121.618622",
"latitude": "38.914590"
},
{
"name": "大庆市",
"letter": "D",
"longitude": "125.112720",
"latitude": "46.590734"
},
{
"name": "大同市",
"letter": "D",
"longitude": "113.295259",
"latitude": "40.090310"
},
{
"name": "大兴安岭",
"letter": "D",
"longitude": "124.117811",
"latitude": "50.411047"
},
{
"name": "达州市",
"letter": "D",
"longitude": "107.468023",
"latitude": "31.209572"
},
{
"name": "丹东市",
"letter": "D",
"longitude": "124.383044",
"latitude": "40.124296"
},
{
"name": "儋州市",
"letter": "D",
"longitude": "109.576782",
"latitude": "19.517486"
},
{
"name": "德宏傣族景颇族自治州",
"letter": "D",
"longitude": "98.578363",
"latitude": "24.436694"
},
{
"name": "德阳市",
"letter": "D",
"longitude": "104.398651",
"latitude": "31.127991"
},
{
"name": "德州市",
"letter": "D",
"longitude": "116.307428",
"latitude": "37.453968"
},
{
"name": "迪庆藏族自治州",
"letter": "D",
"longitude": "99.706463",
"latitude": "27.826853"
},
{
"name": "定安县",
"letter": "D",
"longitude": "110.358891",
"latitude": "19.681434"
},
{
"name": "定西市",
"letter": "D",
"longitude": "104.626294",
"latitude": "35.579578"
},
{
"name": "东方市",
"letter": "D",
"longitude": "108.653789",
"latitude": "19.10198"
},
{
"name": "东莞市",
"letter": "D",
"longitude": "113.746262",
"latitude": "23.046237"
},
{
"name": "东沙群岛",
"letter": "D",
"longitude": "116.887613",
"latitude": "20.617825"
},
{
"name": "东营市",
"letter": "D",
"longitude": "118.664710",
"latitude": "37.434564"
},
{
"name": "鄂尔多斯市",
"letter": "E",
"longitude": "109.990290",
"latitude": "39.817179"
},
{
"name": "鄂州市",
"letter": "E",
"longitude": "114.890593",
"latitude": "30.396536"
},
{
"name": "恩施土家族苗族自治州",
"letter": "E",
"longitude": "109.486990",
"latitude": "30.283114"
},
{
"name": "防城港市",
"letter": "F",
"longitude": "108.345478",
"latitude": "21.614631"
},
{
"name": "佛山市",
"letter": "F",
"longitude": "113.122717",
"latitude": "23.028762"
},
{
"name": "抚顺市",
"letter": "F",
"longitude": "123.921109",
"latitude": "41.875956"
},
{
"name": "阜新市",
"letter": "F",
"longitude": "121.648962",
"latitude": "42.011796"
},
{
"name": "阜阳市",
"letter": "F",
"longitude": "115.819729",
"latitude": "32.896969"
},
{
"name": "福州市",
"letter": "F",
"longitude": "119.296389",
"latitude": "26.074268"
},
{
"name": "抚州市",
"letter": "F",
"longitude": "116.358351",
"latitude": "27.983850"
},
{
"name": "甘南藏族自治州",
"letter": "G",
"longitude": "102.911008",
"latitude": "34.986354"
},
{
"name": "赣州市",
"letter": "G",
"longitude": "114.940278",
"latitude": "25.850970"
},
{
"name": "甘孜藏族自治州",
"letter": "G",
"longitude": "101.963815",
"latitude": "30.050663"
},
{
"name": "固原市",
"letter": "G",
"longitude": "106.285241",
"latitude": "36.004561"
},
{
"name": "广安市",
"letter": "G",
"longitude": "106.633369",
"latitude": "30.456398"
},
{
"name": "广元市",
"letter": "G",
"longitude": "105.829757",
"latitude": "32.433668"
},
{
"name": "广州市",
"letter": "G",
"longitude": "113.264385",
"latitude": "23.129112"
},
{
"name": "贵港市",
"letter": "G",
"longitude": "109.602146",
"latitude": "23.0936"
},
{
"name": "桂林市",
"letter": "G",
"longitude": "110.299121",
"latitude": "25.274215"
},
{
"name": "贵阳市",
"letter": "G",
"longitude": "106.630153",
"latitude": "26.647661"
},
{
"name": "果洛藏族自治州",
"letter": "G",
"longitude": "100.242143",
"latitude": "34.473600"
},
{
"name": "哈尔滨市",
"letter": "H",
"longitude": "126.535319",
"latitude": "45.803131"
},
{
"name": "哈密市",
"letter": "H",
"longitude": "93.513160",
"latitude": "42.833248"
},
{
"name": "海北藏族自治州",
"letter": "H",
"longitude": "100.901060",
"latitude": "36.959435"
},
{
"name": "海东市",
"letter": "H",
"longitude": "102.104287",
"latitude": "36.502040"
},
{
"name": "海口市",
"letter": "H",
"longitude": "110.198286",
"latitude": "20.044412"
},
{
"name": "海南藏族自治州",
"letter": "H",
"longitude": "100.619542",
"latitude": "36.280353"
},
{
"name": "海西蒙古族藏族自治州",
"letter": "H",
"longitude": "97.370785",
"latitude": "37.374663"
},
{
"name": "邯郸市",
"letter": "H",
"longitude": "114.490686",
"latitude": "36.612273"
},
{
"name": "汉中市",
"letter": "H",
"longitude": "107.028621",
"latitude": "33.077668"
},
{
"name": "杭州市",
"letter": "H",
"longitude": "120.209947",
"latitude": "30.245853"
},
{
"name": "鹤壁市",
"letter": "H",
"longitude": "114.295444",
"latitude": "35.748236"
},
{
"name": "河池市",
"letter": "H",
"longitude": "108.062106",
"latitude": "24.695899"
},
{
"name": "合肥市",
"letter": "H",
"longitude": "117.227308",
"latitude": "31.82057"
},
{
"name": "鹤岗市",
"letter": "H",
"longitude": "130.277487",
"latitude": "47.332085"
},
{
"name": "和田",
"letter": "H",
"longitude": "79.925330",
"latitude": "37.110687"
},
{
"name": "河源市",
"letter": "H",
"longitude": "114.697802",
"latitude": "23.746266"
},
{
"name": "菏泽市",
"letter": "H",
"longitude": "115.469381",
"latitude": "35.246531"
},
{
"name": "贺州市",
"letter": "H",
"longitude": "111.552057",
"latitude": "24.414141"
},
{
"name": "黑河市",
"letter": "H",
"longitude": "127.499023",
"latitude": "50.249585"
},
{
"name": "衡水市",
"letter": "H",
"longitude": "115.665993",
"latitude": "37.735097"
},
{
"name": "衡阳市",
"letter": "H",
"longitude": "112.607693",
"latitude": "26.900358"
},
{
"name": "红河哈尼族彝族自治州",
"letter": "H",
"longitude": "103.384182",
"latitude": "23.366775"
},
{
"name": "呼和浩特市",
"letter": "H",
"longitude": "111.748426",
"latitude": "40.842723"
},
{
"name": "葫芦岛市",
"letter": "H",
"longitude": "120.856394",
"latitude": "40.755572"
},
{
"name": "呼伦贝尔市",
"letter": "H",
"longitude": "119.758168",
"latitude": "49.215333"
},
{
"name": "湖州市",
"letter": "H",
"longitude": "120.102398",
"latitude": "30.867198"
},
{
"name": "淮安市",
"letter": "H",
"longitude": "119.021265",
"latitude": "33.597506"
},
{
"name": "淮北市",
"letter": "H",
"longitude": "116.794664",
"latitude": "33.971707"
},
{
"name": "怀化市",
"letter": "H",
"longitude": "109.978240",
"latitude": "27.550082"
},
{
"name": "淮南市",
"letter": "H",
"longitude": "117.018329",
"latitude": "32.647574"
},
{
"name": "黄冈市",
"letter": "H",
"longitude": "114.879365",
"latitude": "30.447711"
},
{
"name": "黄南藏族自治州",
"letter": "H",
"longitude": "102.019988",
"latitude": "35.517744"
},
{
"name": "黄山市",
"letter": "H",
"longitude": "118.317325",
"latitude": "29.709239"
},
{
"name": "黄石市",
"letter": "H",
"longitude": "115.077048",
"latitude": "30.220074"
},
{
"name": "惠州市",
"letter": "H",
"longitude": "114.412599",
"latitude": "23.079404"
},
{
"name": "吉安市",
"letter": "J",
"longitude": "114.986373",
"latitude": "27.111699"
},
{
"name": "吉林市",
"letter": "J",
"longitude": "126.553020",
"latitude": "43.843577"
},
{
"name": "济南市",
"letter": "J",
"longitude": "117.120098",
"latitude": "36.6512"
},
{
"name": "济宁市",
"letter": "J",
"longitude": "116.587245",
"latitude": "35.415393"
},
{
"name": "鸡西市",
"letter": "J",
"longitude": "130.975966",
"latitude": "45.300046"
},
{
"name": "济源市",
"letter": "J",
"longitude": "112.601919",
"latitude": "35.067243"
},
{
"name": "佳木斯市",
"letter": "J",
"longitude": "130.361634",
"latitude": "46.809606"
},
{
"name": "嘉兴市",
"letter": "J",
"longitude": "120.750865",
"latitude": "30.762653"
},
{
"name": "嘉峪关市",
"letter": "J",
"longitude": "98.277304",
"latitude": "39.786529"
},
{
"name": "江门市",
"letter": "J",
"longitude": "113.094942",
"latitude": "22.590431"
},
{
"name": "焦作市",
"letter": "J",
"longitude": "113.238266",
"latitude": "35.239040"
},
{
"name": "揭阳市",
"letter": "J",
"longitude": "116.355733",
"latitude": "23.543778"
},
{
"name": "金昌市",
"letter": "J",
"longitude": "102.187888",
"latitude": "38.514238"
},
{
"name": "晋城市",
"letter": "J",
"longitude": "112.851274",
"latitude": "35.497553"
},
{
"name": "金华市",
"letter": "J",
"longitude": "119.649506",
"latitude": "29.089524"
},
{
"name": "晋中市",
"letter": "J",
"longitude": "112.736465",
"latitude": "37.696495"
},
{
"name": "锦州市",
"letter": "J",
"longitude": "121.135742",
"latitude": "41.119269"
},
{
"name": "景德镇市",
"letter": "J",
"longitude": "117.214664",
"latitude": "29.292560"
},
{
"name": "荆门市",
"letter": "J",
"longitude": "112.204251",
"latitude": "31.035420"
},
{
"name": "荆州市",
"letter": "J",
"longitude": "112.238130",
"latitude": "30.326857"
},
{
"name": "九江市",
"letter": "J",
"longitude": "115.992811",
"latitude": "29.712034"
},
{
"name": "酒泉市",
"letter": "J",
"longitude": "98.494352",
"latitude": "39.732819"
},
{
"name": "喀什",
"letter": "K",
"longitude": "75.989138",
"latitude": "39.467664"
},
{
"name": "开封市",
"letter": "K",
"longitude": "114.341447",
"latitude": "34.797049"
},
{
"name": "可克达拉市",
"letter": "K",
"longitude": "81.044545",
"latitude": "43.944791"
},
{
"name": "克拉玛依市",
"letter": "K",
"longitude": "84.873946",
"latitude": "45.595886"
},
{
"name": "克孜勒苏柯尔克孜自治州",
"letter": "K",
"longitude": "76.172825",
"latitude": "39.713431"
},
{
"name": "昆明市",
"letter": "K",
"longitude": "102.833722",
"latitude": "24.881539"
},
{
"name": "昆玉市",
"letter": "K",
"longitude": "79.291531",
"latitude": "37.210710"
},
{
"name": "拉萨市",
"letter": "L",
"longitude": "91.171961",
"latitude": "29.653482"
},
{
"name": "来宾市",
"letter": "L",
"longitude": "109.229772",
"latitude": "23.733766"
},
{
"name": "兰州市",
"letter": "L",
"longitude": "103.834249",
"latitude": "36.06081"
},
{
"name": "廊坊市",
"letter": "L",
"longitude": "116.704441",
"latitude": "39.523927"
},
{
"name": "乐东黎族自治县",
"letter": "L",
"longitude": "109.173055",
"latitude": "18.75026"
},
{
"name": "乐山市",
"letter": "L",
"longitude": "103.761263",
"latitude": "29.582024"
},
{
"name": "漯河市",
"letter": "L",
"longitude": "114.026405",
"latitude": "33.575855"
},
{
"name": "丽江市",
"letter": "L",
"longitude": "100.233026",
"latitude": "26.872108"
},
{
"name": "丽水市",
"letter": "L",
"longitude": "119.921786",
"latitude": "28.451993"
},
{
"name": "连云港市",
"letter": "L",
"longitude": "119.178821",
"latitude": "34.600018"
},
{
"name": "凉山彝族自治州",
"letter": "L",
"longitude": "102.258746",
"latitude": "27.886762"
},
{
"name": "聊城市",
"letter": "L",
"longitude": "115.980367",
"latitude": "36.456013"
},
{
"name": "辽阳市",
"letter": "L",
"longitude": "123.181520",
"latitude": "41.269402"
},
{
"name": "辽源市",
"letter": "L",
"longitude": "125.145349",
"latitude": "42.902692"
},
{
"name": "临沧市",
"letter": "L",
"longitude": "100.086970",
"latitude": "23.886567"
},
{
"name": "临汾市",
"letter": "L",
"longitude": "111.517973",
"latitude": "36.084150"
},
{
"name": "临高县",
"letter": "L",
"longitude": "109.690508",
"latitude": "19.912026"
},
{
"name": "临夏回族自治州",
"letter": "L",
"longitude": "103.212006",
"latitude": "35.599446"
},
{
"name": "临沂市",
"letter": "L",
"longitude": "118.326443",
"latitude": "35.065282"
},
{
"name": "林芝市",
"letter": "L",
"longitude": "94.361550",
"latitude": "29.648943"
},
{
"name": "陵水黎族自治县",
"letter": "L",
"longitude": "110.037504",
"latitude": "18.506048"
},
{
"name": "六安市",
"letter": "L",
"longitude": "116.507676",
"latitude": "31.752889"
},
{
"name": "六盘水市",
"letter": "L",
"longitude": "104.846743",
"latitude": "26.584643"
},
{
"name": "柳州市",
"letter": "L",
"longitude": "109.411703",
"latitude": "24.314617"
},
{
"name": "陇南市",
"letter": "L",
"longitude": "104.929379",
"latitude": "33.388598"
},
{
"name": "龙岩市",
"letter": "L",
"longitude": "117.01728",
"latitude": "25.075097"
},
{
"name": "娄底市",
"letter": "L",
"longitude": "112.008497",
"latitude": "27.728136"
},
{
"name": "泸州市",
"letter": "L",
"longitude": "105.443349",
"latitude": "28.889138"
},
{
"name": "洛阳市",
"letter": "L",
"longitude": "112.434468",
"latitude": "34.663041"
},
{
"name": "吕梁市",
"letter": "L",
"longitude": "111.134335",
"latitude": "37.524366"
},
{
"name": "马鞍山市",
"letter": "M",
"longitude": "118.506502",
"latitude": "31.669611"
},
{
"name": "茂名市",
"letter": "M",
"longitude": "110.919229",
"latitude": "21.659751"
},
{
"name": "眉山市",
"letter": "M",
"longitude": "103.831788",
"latitude": "30.048318"
},
{
"name": "梅州市",
"letter": "M",
"longitude": "116.117582",
"latitude": "24.299112"
},
{
"name": "绵阳市",
"letter": "M",
"longitude": "104.741722",
"latitude": "31.464020"
},
{
"name": "牡丹江市",
"letter": "M",
"longitude": "129.618602",
"latitude": "44.582962"
},
{
"name": "内江市",
"letter": "N",
"longitude": "105.057987",
"latitude": "29.580148"
},
{
"name": "那曲市",
"letter": "N",
"longitude": "92.051746",
"latitude": "31.478148"
},
{
"name": "南昌市",
"letter": "N",
"longitude": "115.857963",
"latitude": "28.683016"
},
{
"name": "南充市",
"letter": "N",
"longitude": "106.082974",
"latitude": "30.795282"
},
{
"name": "南京市",
"letter": "N",
"longitude": "118.796623",
"latitude": "32.059352"
},
{
"name": "南宁市",
"letter": "N",
"longitude": "108.36637",
"latitude": "22.817746"
},
{
"name": "南平市",
"letter": "N",
"longitude": "118.178459",
"latitude": "26.635627"
},
{
"name": "南通市",
"letter": "N",
"longitude": "120.864608",
"latitude": "32.016212"
},
{
"name": "南阳市",
"letter": "N",
"longitude": "112.540918",
"latitude": "32.999082"
},
{
"name": "宁波市",
"letter": "N",
"longitude": "121.621600",
"latitude": "29.859515"
},
{
"name": "宁德市",
"letter": "N",
"longitude": "119.527082",
"latitude": "26.659241"
},
{
"name": "怒江傈僳族自治州",
"letter": "N",
"longitude": "98.854304",
"latitude": "25.850949"
},
{
"name": "盘锦市",
"letter": "P",
"longitude": "122.069571",
"latitude": "41.124484"
},
{
"name": "攀枝花市",
"letter": "P",
"longitude": "101.716008",
"latitude": "26.580446"
},
{
"name": "平顶山市",
"letter": "P",
"longitude": "113.307718",
"latitude": "33.735241"
},
{
"name": "平凉市",
"letter": "P",
"longitude": "106.684691",
"latitude": "35.54279"
},
{
"name": "萍乡市",
"letter": "P",
"longitude": "113.852186",
"latitude": "27.622946"
},
{
"name": "普洱市",
"letter": "P",
"longitude": "100.972344",
"latitude": "22.777321"
},
{
"name": "莆田市",
"letter": "P",
"longitude": "119.007558",
"latitude": "25.431011"
},
{
"name": "濮阳市",
"letter": "P",
"longitude": "115.041299",
"latitude": "35.768234"
},
{
"name": "齐齐哈尔市",
"letter": "Q",
"longitude": "123.957920",
"latitude": "47.342081"
},
{
"name": "七台河市",
"letter": "Q",
"longitude": "131.015584",
"latitude": "45.771266"
},
{
"name": "黔东南苗族侗族自治州",
"letter": "Q",
"longitude": "107.977488",
"latitude": "26.583352"
},
{
"name": "潜江市",
"letter": "Q",
"longitude": "112.896866",
"latitude": "30.421215"
},
{
"name": "黔南布依族苗族自治州",
"letter": "Q",
"longitude": "107.517156",
"latitude": "26.258219"
},
{
"name": "黔西南布依族苗族自治州",
"letter": "Q",
"longitude": "104.897971",
"latitude": "25.088120"
},
{
"name": "秦皇岛市",
"letter": "Q",
"longitude": "119.586579",
"latitude": "39.942531"
},
{
"name": "钦州市",
"letter": "Q",
"longitude": "108.624175",
"latitude": "21.967127"
},
{
"name": "青岛市",
"letter": "Q",
"longitude": "120.324447",
"latitude": "36.064594"
},
{
"name": "庆阳市",
"letter": "Q",
"longitude": "107.638372",
"latitude": "35.734218"
},
{
"name": "清远市",
"letter": "Q",
"longitude": "113.051227",
"latitude": "23.685022"
},
{
"name": "琼海市",
"letter": "Q",
"longitude": "110.466785",
"latitude": "19.246011"
},
{
"name": "琼中黎族苗族自治县",
"letter": "Q",
"longitude": "109.838389",
"latitude": "19.033369"
},
{
"name": "曲靖市",
"letter": "Q",
"longitude": "103.797851",
"latitude": "25.501557"
},
{
"name": "衢州市",
"letter": "Q",
"longitude": "118.872630",
"latitude": "28.941708"
},
{
"name": "泉州市",
"letter": "Q",
"longitude": "118.675847",
"latitude": "24.874350"
},
{
"name": "日喀则市",
"letter": "R",
"longitude": "88.885148",
"latitude": "29.267519"
},
{
"name": "日照市",
"letter": "R",
"longitude": "119.461208",
"latitude": "35.428588"
},
{
"name": "三门峡市",
"letter": "S",
"longitude": "111.194099",
"latitude": "34.777338"
},
{
"name": "三明市",
"letter": "S",
"longitude": "117.635001",
"latitude": "26.265444"
},
{
"name": "三沙市",
"letter": "S",
"longitude": "112.338651",
"latitude": "16.831004"
},
{
"name": "三亚市",
"letter": "S",
"longitude": "109.508268",
"latitude": "18.247872"
},
{
"name": "山南市",
"letter": "S",
"longitude": "91.773134",
"latitude": "29.237137"
},
{
"name": "汕头市",
"letter": "S",
"longitude": "116.708463",
"latitude": "23.371020"
},
{
"name": "汕尾市",
"letter": "S",
"longitude": "115.364238",
"latitude": "22.774485"
},
{
"name": "上海市",
"letter": "S",
"longitude": "121.473701",
"latitude": "31.230416"
},
{
"name": "商洛市",
"letter": "S",
"longitude": "109.918561",
"latitude": "33.872706"
},
{
"name": "商丘市",
"letter": "S",
"longitude": "115.650497",
"latitude": "34.437054"
},
{
"name": "上饶市",
"letter": "S",
"longitude": "117.971185",
"latitude": "28.444420"
},
{
"name": "韶关市",
"letter": "S",
"longitude": "113.597313",
"latitude": "24.811094"
},
{
"name": "绍兴市",
"letter": "S",
"longitude": "120.582112",
"latitude": "29.997117"
},
{
"name": "邵阳市",
"letter": "S",
"longitude": "111.469230",
"latitude": "27.237842"
},
{
"name": "深圳市",
"letter": "S",
"longitude": "114.085947",
"latitude": "22.547000"
},
{
"name": "沈阳市",
"letter": "S",
"longitude": "123.465009",
"latitude": "41.677287"
},
{
"name": "石河子市",
"letter": "S",
"longitude": "86.041075",
"latitude": "44.305886"
},
{
"name": "石家庄市",
"letter": "S",
"longitude": "114.514793",
"latitude": "38.042225"
},
{
"name": "十堰市",
"letter": "S",
"longitude": "110.798657",
"latitude": "32.629034"
},
{
"name": "石嘴山市",
"letter": "S",
"longitude": "106.376173",
"latitude": "39.013330"
},
{
"name": "双河市",
"letter": "S",
"longitude": "82.353656",
"latitude": "44.840524"
},
{
"name": "双鸭山市",
"letter": "S",
"longitude": "131.157304",
"latitude": "46.643442"
},
{
"name": "朔州市",
"letter": "S",
"longitude": "112.433387",
"latitude": "39.331261"
},
{
"name": "四平市",
"letter": "S",
"longitude": "124.370785",
"latitude": "43.170344"
},
{
"name": "松原市",
"letter": "S",
"longitude": "124.823608",
"latitude": "45.118243"
},
{
"name": "宿迁市",
"letter": "S",
"longitude": "118.275162",
"latitude": "33.963008"
},
{
"name": "宿州市",
"letter": "S",
"longitude": "116.984084",
"latitude": "33.633891"
},
{
"name": "苏州市",
"letter": "S",
"longitude": "120.619585",
"latitude": "31.299379"
},
{
"name": "绥化市",
"letter": "S",
"longitude": "126.992930",
"latitude": "46.637393"
},
{
"name": "遂宁市",
"letter": "S",
"longitude": "105.571331",
"latitude": "30.513311"
},
{
"name": "随州市",
"letter": "S",
"longitude": "113.382477",
"latitude": "31.690187"
},
{
"name": "塔城",
"letter": "T",
"longitude": "82.985732",
"latitude": "46.746301"
},
{
"name": "泰安市",
"letter": "T",
"longitude": "117.129063",
"latitude": "36.194968"
},
{
"name": "太原市",
"letter": "T",
"longitude": "112.549717",
"latitude": "37.87046"
},
{
"name": "台州市",
"letter": "T",
"longitude": "121.428599",
"latitude": "28.661378"
},
{
"name": "泰州市",
"letter": "T",
"longitude": "119.915176",
"latitude": "32.484882"
},
{
"name": "唐山市",
"letter": "T",
"longitude": "118.175393",
"latitude": "39.635113"
},
{
"name": "天津市",
"letter": "T",
"longitude": "117.200983",
"latitude": "39.084158"
},
{
"name": "天门市",
"letter": "T",
"longitude": "113.165862",
"latitude": "30.653061"
},
{
"name": "天水市",
"letter": "T",
"longitude": "105.724998",
"latitude": "34.578529"
},
{
"name": "铁岭市",
"letter": "T",
"longitude": "123.844279",
"latitude": "42.290585"
},
{
"name": "铁门关市",
"letter": "T",
"longitude": "85.501218",
"latitude": "41.827251"
},
{
"name": "铜川市",
"letter": "T",
"longitude": "108.979608",
"latitude": "34.916582"
},
{
"name": "通化市",
"letter": "T",
"longitude": "125.936501",
"latitude": "41.721177"
},
{
"name": "通辽市",
"letter": "T",
"longitude": "122.263119",
"latitude": "43.617429"
},
{
"name": "铜陵市",
"letter": "T",
"longitude": "117.816576",
"latitude": "30.929935"
},
{
"name": "铜仁市",
"letter": "T",
"longitude": "109.191555",
"latitude": "27.718346"
},
{
"name": "吐鲁番市",
"letter": "T",
"longitude": "89.189537",
"latitude": "42.951227"
},
{
"name": "图木舒克市",
"letter": "T",
"longitude": "79.077978",
"latitude": "39.867316"
},
{
"name": "屯昌县",
"letter": "T",
"longitude": "110.103415",
"latitude": "19.351766"
},
{
"name": "万宁市",
"letter": "W",
"longitude": "110.388793",
"latitude": "18.796216"
},
{
"name": "潍坊市",
"letter": "W",
"longitude": "119.107078",
"latitude": "36.709250"
},
{
"name": "威海市",
"letter": "W",
"longitude": "122.116394",
"latitude": "37.509691"
},
{
"name": "渭南市",
"letter": "W",
"longitude": "109.502882",
"latitude": "34.499381"
},
{
"name": "文昌市",
"letter": "W",
"longitude": "110.753975",
"latitude": "19.612986"
},
{
"name": "文山壮族苗族自治州",
"letter": "W",
"longitude": "104.244010",
"latitude": "23.369510"
},
{
"name": "温州市",
"letter": "W",
"longitude": "120.672111",
"latitude": "28.000575"
},
{
"name": "乌海市",
"letter": "W",
"longitude": "106.825563",
"latitude": "39.673734"
},
{
"name": "武汉市",
"letter": "W",
"longitude": "114.305215",
"latitude": "30.592935"
},
{
"name": "芜湖市",
"letter": "W",
"longitude": "118.376451",
"latitude": "31.326319"
},
{
"name": "五家渠市",
"letter": "W",
"longitude": "87.543240",
"latitude": "44.166757"
},
{
"name": "乌兰察布市",
"letter": "W",
"longitude": "113.114543",
"latitude": "41.034126"
},
{
"name": "乌鲁木齐市",
"letter": "W",
"longitude": "87.616842",
"latitude": "43.82539"
},
{
"name": "武威市",
"letter": "W",
"longitude": "102.634697",
"latitude": "37.929996"
},
{
"name": "无锡市",
"letter": "W",
"longitude": "120.301663",
"latitude": "31.574729"
},
{
"name": "五指山市",
"letter": "W",
"longitude": "109.516925",
"latitude": "18.775147"
},
{
"name": "吴忠市",
"letter": "W",
"longitude": "106.199409",
"latitude": "37.986165"
},
{
"name": "梧州市",
"letter": "W",
"longitude": "111.297604",
"latitude": "23.474803"
},
{
"name": "西安市",
"letter": "X",
"longitude": "108.939621",
"latitude": "34.343147"
},
{
"name": "锡林郭勒盟",
"letter": "X",
"longitude": "116.090996",
"latitude": "43.944018"
},
{
"name": "西宁市",
"letter": "X",
"longitude": "101.778112",
"latitude": "36.617042"
},
{
"name": "西双版纳傣族自治州",
"letter": "X",
"longitude": "100.797941",
"latitude": "22.001724"
},
{
"name": "厦门市",
"letter": "X",
"longitude": "118.110221",
"latitude": "24.490474"
},
{
"name": "咸宁市",
"letter": "X",
"longitude": "114.328963",
"latitude": "29.832798"
},
{
"name": "仙桃市",
"letter": "X",
"longitude": "113.453974",
"latitude": "30.364953"
},
{
"name": "咸阳市",
"letter": "X",
"longitude": "108.705117",
"latitude": "34.333439"
},
{
"name": "湘潭市",
"letter": "X",
"longitude": "112.944052",
"latitude": "27.829730"
},
{
"name": "湘西土家族苗族自治州",
"letter": "X",
"longitude": "109.738783",
"latitude": "28.311994"
},
{
"name": "襄阳市",
"letter": "X",
"longitude": "112.144146",
"latitude": "32.042426"
},
{
"name": "孝感市",
"letter": "X",
"longitude": "113.926656",
"latitude": "30.926423"
},
{
"name": "新乡市",
"letter": "X",
"longitude": "113.883991",
"latitude": "35.302616"
},
{
"name": "信阳市",
"letter": "X",
"longitude": "114.075031",
"latitude": "32.123274"
},
{
"name": "新余市",
"letter": "X",
"longitude": "114.930835",
"latitude": "27.810835"
},
{
"name": "忻州市",
"letter": "X",
"longitude": "112.733538",
"latitude": "38.417690"
},
{
"name": "兴安盟",
"letter": "X",
"longitude": "122.070317",
"latitude": "46.076268"
},
{
"name": "邢台市",
"letter": "X",
"longitude": "114.508851",
"latitude": "37.068200"
},
{
"name": "许昌市",
"letter": "X",
"longitude": "113.826063",
"latitude": "34.022956"
},
{
"name": "徐州市",
"letter": "X",
"longitude": "117.184811",
"latitude": "34.261792"
},
{
"name": "宣城市",
"letter": "X",
"longitude": "118.757995",
"latitude": "30.945667"
},
{
"name": "雅安市",
"letter": "Y",
"longitude": "103.001033",
"latitude": "29.987722"
},
{
"name": "延安市",
"letter": "Y",
"longitude": "109.490810",
"latitude": "36.596537"
},
{
"name": "延边朝鲜族自治州",
"letter": "Y",
"longitude": "129.513228",
"latitude": "42.904823"
},
{
"name": "盐城市",
"letter": "Y",
"longitude": "120.139998",
"latitude": "33.377631"
},
{
"name": "烟台市",
"letter": "Y",
"longitude": "121.391382",
"latitude": "37.539297"
},
{
"name": "阳江市",
"letter": "Y",
"longitude": "111.982697",
"latitude": "21.857415"
},
{
"name": "阳泉市",
"letter": "Y",
"longitude": "113.583285",
"latitude": "37.861188"
},
{
"name": "扬州市",
"letter": "Y",
"longitude": "119.421003",
"latitude": "32.393159"
},
{
"name": "宜宾市",
"letter": "Y",
"longitude": "104.630825",
"latitude": "28.760189"
},
{
"name": "宜昌市",
"letter": "Y",
"longitude": "111.286451",
"latitude": "30.69187"
},
{
"name": "宜春市",
"letter": "Y",
"longitude": "114.391137",
"latitude": "27.804300"
},
{
"name": "伊春市",
"letter": "Y",
"longitude": "128.899396",
"latitude": "47.724775"
},
{
"name": "伊犁哈萨克自治州",
"letter": "Y",
"longitude": "81.317946",
"latitude": "43.921860"
},
{
"name": "益阳市",
"letter": "Y",
"longitude": "112.355042",
"latitude": "28.570066"
},
{
"name": "银川市",
"letter": "Y",
"longitude": "106.230909",
"latitude": "38.487193"
},
{
"name": "营口市",
"letter": "Y",
"longitude": "122.235152",
"latitude": "40.667432"
},
{
"name": "鹰潭市",
"letter": "Y",
"longitude": "117.033838",
"latitude": "28.238638"
},
{
"name": "永州市",
"letter": "Y",
"longitude": "111.608019",
"latitude": "26.434516"
},
{
"name": "玉林市",
"letter": "Y",
"longitude": "110.180962",
"latitude": "22.653889"
},
{
"name": "榆林市",
"letter": "Y",
"longitude": "109.741193",
"latitude": "38.290162"
},
{
"name": "玉树藏族自治州",
"letter": "Y",
"longitude": "97.008522",
"latitude": "33.004049"
},
{
"name": "玉溪市",
"letter": "Y",
"longitude": "102.543907",
"latitude": "24.350461"
},
{
"name": "岳阳市",
"letter": "Y",
"longitude": "113.132855",
"latitude": "29.370290"
},
{
"name": "运城市",
"letter": "Y",
"longitude": "111.003957",
"latitude": "35.022778"
},
{
"name": "云浮市",
"letter": "Y",
"longitude": "112.044439",
"latitude": "22.929801"
},
{
"name": "枣庄市",
"letter": "Z",
"longitude": "117.557964",
"latitude": "34.856424"
},
{
"name": "湛江市",
"letter": "Z",
"longitude": "110.364977",
"latitude": "21.274898"
},
{
"name": "张家界市",
"letter": "Z",
"longitude": "110.479921",
"latitude": "29.127401"
},
{
"name": "张家口市",
"letter": "Z",
"longitude": "114.884091",
"latitude": "40.811901"
},
{
"name": "张掖市",
"letter": "Z",
"longitude": "100.455472",
"latitude": "38.932897"
},
{
"name": "漳州市",
"letter": "Z",
"longitude": "117.661801",
"latitude": "24.510897"
},
{
"name": "肇庆市",
"letter": "Z",
"longitude": "112.472529",
"latitude": "23.051546"
},
{
"name": "昭通市",
"letter": "Z",
"longitude": "103.717216",
"latitude": "27.336999"
},
{
"name": "镇江市",
"letter": "Z",
"longitude": "119.452753",
"latitude": "32.204402"
},
{
"name": "郑州市",
"letter": "Z",
"longitude": "113.823666",
"latitude": "34.753349"
},
{
"name": "中山市",
"letter": "Z",
"longitude": "113.382391",
"latitude": "22.521113"
},
{
"name": "中卫市",
"letter": "Z",
"longitude": "105.189568",
"latitude": "37.514951"
},
{
"name": "周口市",
"letter": "Z",
"longitude": "114.649653",
"latitude": "33.620357"
},
{
"name": "舟山市",
"letter": "Z",
"longitude": "122.106863",
"latitude": "30.016028"
},
{
"name": "珠海市",
"letter": "Z",
"longitude": "113.553986",
"latitude": "22.224979"
},
{
"name": "驻马店市",
"letter": "Z",
"longitude": "114.024736",
"latitude": "32.980169"
},
{
"name": "株洲市",
"letter": "Z",
"longitude": "113.151737",
"latitude": "27.835806"
},
{
"name": "淄博市",
"letter": "Z",
"longitude": "118.047649",
"latitude": "36.814939"
},
{
"name": "自贡市",
"letter": "Z",
"longitude": "104.773447",
"latitude": "29.352765"
},
{
"name": "资阳市",
"letter": "Z",
"longitude": "104.641917",
"latitude": "30.122211"
},
{
"name": "遵义市",
"letter": "Z",
"longitude": "106.937265",
"latitude": "27.706626"
}
]
import Taro from '@tarojs/taro';
import {View, Input, Image, ScrollView, Block} from '@tarojs/components';
import {connect} from '@tarojs/redux';
import {setUserInfo} from '@/actions/user';
import BaseComponent from '@/helper/baseComponent';
import {throttle} from '@/util/base';
import cityList from './city'
import NavBar from '@/components/NavBar'
// const citySimple = cityList.map(item => {
// return {name: item.name, letter: item.letter};
// })
import './index.scss';
const letterMap = {};
const letterList = [];
cityList.forEach(city => {
if (!letterMap[city.letter]) {
letterMap[city.letter] = true;
letterList.push(city.letter);
}
})
@connect(({ user }) => ({
user
}), (dispatch) => ({
setUserInfo (data) {
dispatch(setUserInfo(data || {}))
}
}))
class CitySelect extends BaseComponent {
config = {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#FFFFFF',
navigationBarTitleText: '城市选择',
navigationBarTextStyle: 'black',
pullRefresh: false
}
state = {
cityList: cityList,
letterList: letterList,
curLetter: '',
showSearch: false,
keyword: '',
searchList: [],
page: 1
}
constructor(props) {
super(props);
this.search = throttle(this.search, 500).bind(this);
}
scrollToLetter = (letter) => {
this.setState({
curLetter: `city_${letter}`
})
}
//文本框获取焦点
handleFocus = () => {
this.setState({
showSearch: true
})
}
search = () => {
}
handleInput = (e) => {
// console.log(e.target.value);
let value = e.target.value;
let searchList = [];
if (value) {
searchList = cityList.filter(city => city.name.indexOf(value) > -1);
}
this.setState({keyword: value, searchList});
}
//清空文本框
clearInput = () => {
this.setState({keyword: '', searchList: []})
}
//选择城市
selectCity = (item) => {
const user = this.props.user;
this.props.setUserInfo({
// prevLongitude: user.longitude,
// prevLatitude: user.latitude,
longitude: item.longitude,
latitude: item.latitude,
city: item.name
});
// my.navigateBack();
Taro.navigateBack();
// eventCenter.trigger('selectCity', item);
}
//取消搜索
cancelSearch = () => {
this.setState({showSearch: false})
}
handleLoadMore = () => {
// let page = this.state.page + 1;
// let arr = cityList.slice((page - 1) * pageSize, page * pageSize);
// let obj = arr.reduce((result, item, index) => {
// result[`cityList[${(page - 1) * pageSize + index}]`] = item;
// return result;
// }, {});
// console.log('obj....', obj, this);
// obj.page = page;
// this.state.page = page;
// this.state.cityList.push(...arr);
// this.$scope.setData(obj);
}
reLocation = () => {
const user = this.props.user;
let currentLoc = user && user.current;
if (currentLoc && currentLoc.city && currentLoc.latitude && currentLoc.longitude) {
this.selectCity({
name: currentLoc.city,
longitude: currentLoc.longitude,
latitude: currentLoc.latitude
})
} else {
this.fetchLocation();
}
}
render() {
const {
cityList,
letterList,
curLetter,
showSearch,
keyword,
searchList
} = this.state;
const user = this.props.user;
let scrollStyle = ``
return (
<View>
<NavBar pageName='我是标题' bgColor='#fff' showNav></NavBar>
<View className={`header${showSearch ? ' searching': ''}`}>
<View className='search'>
<View className='input-wrapper'>
<Image className='search-icon' src='http://hh-oss-picture.miyapay.com/box/9e4db125e6a4908a305904fbe531ba6b.png' />
<Input value={keyword} onInput={this.handleInput} placeholder='请输入城市名称进行搜索' onFocus={this.handleFocus} />
{ showSearch && keyword && <Image onClick={this.clearInput} className='clear-icon' src='http://hh-oss-picture.miyapay.com/box/eeb1d09d119af463e73fd768f6ef656b.png' />}
</View>
{ showSearch && <View className='cancel' onClick={this.cancelSearch}>取消</View> }
</View>
{ !showSearch && <View className='current-city'>
<Text className='cur-city-label'>当前城市定位</Text>
<View className='city-name-wrapper' onClick={this.reLocation}>
<Image className='loc-icon' src='http://hh-oss-picture.miyapay.com/box/45648a57e4c6d309cb438757a2029ba5.png' />
<Text className='city-name' className=''>{user.current && user.current.city || '未获取定位'}</Text>
</View>
</View>}
</View>
<Block>
<scroll-view onScrollToLower={this.handleLoadMore} style={`height: ${showSearch ? 0: 'auto'}`} scrollY className='city-list' scroll-into-view={curLetter}>
{cityList.map((item, index) => {
return (
<Block className='city-item' key={index}>
{ (index == 0 || cityList[index - 1] && item.letter !== cityList[index - 1].letter) && <View className='section' id={`city_${item.letter}`}>{item.letter}</View>}
<View
className={`city-name${cityList[index + 1] && cityList[index + 1].letter !== item.letter ? ' no-border' : ''}`}
onClick={this.selectCity.bind(this, item)}
>{item.name}</View>
</Block>
)
})}
</scroll-view>
{ !showSearch && <View className='letter-list'>
{letterList.map((item, index) => {
return <View key={index} className='letter' onClick={this.scrollToLetter.bind(this, item)}>{item}</View>
})}
</View>}
</Block>
<ScrollView style={{height: showSearch ? '100%':0}} scrollY className='search-list'>
{searchList.map((item, index) => {
return <View onClick={this.selectCity.bind(this, item)} key={index} className='city-name'>{item.name}</View>
})}
</ScrollView>
</View>
)
}
}
export default CitySelect
\ No newline at end of file
@import '@/assets/variable';
page {
background-color: #fff;
}
.header {
position: absolute;
width: 100%;
box-sizing: border-box;
padding: 18px 30px 0;
z-index: 20;
background-color: #fff;
&.searching {
padding-bottom: 20px;
border-bottom: 1px solid #F6F6F6;
}
}
.search {
display: flex;
align-items: center;
.input-wrapper {
display: flex;
align-items: center;
flex: 1;
height: 80px;
padding: 0 30px 0 20px;
border-radius: 8px;
background-color: #F6F6F6;
}
input {
flex: 1;
font-size: 28px;
background-color: transparent;
}
&-icon {
width: 38px;
height: 36px;
}
.clear-icon {
width: 30px;
height: 30px;
margin-left: 10px;
}
.cancel {
font-size: 28px;
color: $BASE-COLOR;
margin-left: 30px;
}
}
.city-list {
position: absolute;
top: 200px;
left: 0;
bottom: 0;
width: 100%;
box-sizing: border-box;
}
.current-city {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28px;
height: 102px;
padding-right: 10px;
.cur-city-label {
font-weight: 500;
}
.city-name-wrapper {
display: flex;
align-items: center;
}
.loc-icon {
width: 36px;
height: 36px;
margin-right: 8px;
}
}
.section {
height: 60px;
padding-left: 30px;
line-height: 60px;
font-size: 28px;
font-weight: 500;
background-color: #F9F9F9;
}
.city-name {
height: 100px;
line-height: 100px;
margin-left: 40px;
font-size: 28px;
color: #666666;
border-bottom: 1px solid #ECECEC;
&.no-border {
border-width: 0;
}
}
.letter-list {
position: fixed;
top: 420px;
right: 0px;
width: 50px;
font-size: 24px;
line-height: 34px;
color: #999999;
z-index: 30;
}
.search-list {
position: absolute;
height: 100%;
width: 100%;
box-sizing: border-box;
padding-top: 118px;
}
import Taro from '@tarojs/taro'
import BaseComponent from '@/helper/baseComponent';
import { View, Image, Text, Button } from '@tarojs/components'
import { connect } from '@tarojs/redux'
import { setUserInfo } from '@/actions/user'
import NavBar from '@/components/NavBar'
import './index.scss'
@connect(({ user, nav }) => ({
user, nav
}), (dispatch) => ({
setUserInfo (data) {
dispatch(setUserInfo(data || {}))
},
}))
class Index extends BaseComponent {
config = {
navigationBarTitleText: '首页'
}
state = {
located: false
}
componentWillReceiveProps (nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount () { }
componentDidMount() {
this.handleLocation();
}
componentDidShow () { }
componentDidHide () { }
// 获取地址权限
handleLocation() {
this.fetchLocation().then(res => {
this.setState({located: true})
}).catch(err => {
this.setState({located: true})
})
}
selectCity(){
Taro.navigateTo({
url: '/pages/citySelect/index'
})
}
bindgetuserinfo (e) {
console.log(e)
}
render () {
const {nav} = this.props
const titleTop = nav.globalData.navHeight - nav.globalData.navTop
const {located} = this.state;
const user = this.props.user;
console.log('user', user)
// const noLocation = located && (!user.longitude || !user.latitude);
const noLoc = (!user || !user.longitude || !user.latitude);
return (
<View>
<NavBar pageName='我是标题' bgColor='#fff' showNav={false}>
<View
style={`left:${nav.globalData.navRight}px;top:${titleTop}px;background-color:rgba(255,255,255,.6)`}
className='city'
onClick={this.selectCity}
>
<Image className='loc-icon' src='http://hh-oss-picture.miyapay.com/box/8dcd356a4ae1ff0c2c0ac9fd69733ab8.png' />
<Text className={`${noLoc ? 'no-loc' : ''}`}>{noLoc ? '未获取定位' : user.city}</Text>
</View>
</NavBar>
<Button onGetUserInfo={this.bindgetuserinfo} openType='getUserInfo'>获取授权</Button>
</View>
)
}
}
export default Index
.index {
flex-direction: column;
width: 100%;
}
.city {
position: absolute;
display: inline-flex;
align-items: center;
font-size: 32px;
font-weight: 500;
z-index: 11;
color: #333;
.loc-icon {
width: 36px;
height: 36px;
margin-right: 12px;
}
}
\ No newline at end of file
import { ADD, MINUS } from '../constants/counter'
const INITIAL_STATE = {
num: 0
}
export default function counter (state = INITIAL_STATE, action) {
switch (action.type) {
case ADD:
return {
...state,
num: state.num + 1
}
case MINUS:
return {
...state,
num: state.num - 1
}
default:
return state
}
}
import { combineReducers } from 'redux'
import counter from './counter'
import nav from './nav'
import user from './user'
export default combineReducers({
counter,
nav,
user,
})
import { NAV } from '../constants/nav'
const INITIAL_STATE = {
globalData:{}
}
export default function nav (state = INITIAL_STATE, action) {
console.log(action)
switch (action.type) {
case NAV:
return {
...state,
globalData: action.obj,
}
default:
return state
}
}
import {
SET_USER_INFO
} from '@/constants/user'
import Taro from '@tarojs/taro';
const INITIAL_STATE = {
}
export default function userInfo (state = INITIAL_STATE, action) {
console.log('action', action)
switch (action.type) {
case SET_USER_INFO:
// Taro.setStorageSync('user', JSON.stringify(action.payload || {}));
return {
...state,
...action.payload,
prevLongitude: state.longitude || '',
prevLatitude: state.latitude || ''
}
default:
return state
}
}
import { createStore, applyMiddleware, compose } from 'redux'
import thunkMiddleware from 'redux-thunk'
import rootReducer from '../reducers'
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
}) : compose
const middlewares = [
thunkMiddleware
]
if (process.env.NODE_ENV === 'development' && process.env.TARO_ENV !== 'quickapp') {
middlewares.push(require('redux-logger').createLogger())
}
const enhancer = composeEnhancers(
applyMiddleware(...middlewares),
// other store enhancers if any
)
export default function configStore () {
const store = createStore(rootReducer, enhancer)
return store
}
/**
* 节流函数
* @param {*} func
* @param {*} wait
* @param {*} options
*/
export function throttle(func, wait, options) {
var context, args, result;
var timeout = null;
var previous = 0;
if (!options) options = {};
var later = function() {
previous = options.leading === false ? 0 : Date.now();
timeout = null;
result = func.apply(context, args);
if (!timeout) context = args = null;
};
return function() {
var now = Date.now();
if (!previous && options.leading === false) previous = now;
var remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
previous = now;
result = func.apply(context, args);
if (!timeout) context = args = null;
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result;
};
};
//格式化距离
export const formatDistance = (distance) => {
if (!distance) return '';
if (distance < 1000) {
return `${distance}m`;
}
return `${(distance / 1000).toFixed(1)}km`;
}
export const formatTime = (timestamp, fmt = 'yyyy-MM-dd hh:mm:ss', ms = true) => {
const date = new Date()
let fmtResult = fmt
date.setTime(ms ? timestamp : timestamp * 1000)
const o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
'q+': Math.floor((date.getMonth() + 3) / 3),
S: date.getMilliseconds(),
}
if (/(y+)/.test(fmt)) {
fmtResult = fmt.replace(RegExp.$1, `${date.getFullYear()}`.substr(4 - RegExp.$1.length))
}
Object.keys(o).forEach(k => {
if (new RegExp(`(${k})`).test(fmtResult)) {
fmtResult = fmtResult.replace(
RegExp.$1,
RegExp.$1.length === 1 ? o[k] : `00${o[k]}`.substr(`${o[k]}`.length),
)
}
})
return fmtResult
}
export const formatPathQuery = (path) => {
let params = {}
if(!path){
return params;
}
try{
let querys = path.replace(/[^\?]*\?|#.*$/g, '').split('&')
for(let query of querys){
let keys = query.split('=')
params[keys[0]] = keys[1]
}
return params;
}
catch (e) {
return params;
}
}
export const formatMoney = (money) => {
try {
return (+money / 100);
} catch(err) {
console.log('errr', err);
return ''
}
}
import Taro from '@tarojs/taro'
import config from '@/base.config'
import {getStore} from '@tarojs/redux';
import {CHANNEL} from '@/constants/base';
// import {encrypt} from './encrypt';
let systemInfo = Taro.getSystemInfoSync();
let env = Taro.getEnv();
class Request {
constructor() {
this.genRequestMethod();
}
/**
* 处理参数
* @param {*} url
* @param {*} options
* @param {*} data
*/
handleParams(url, options) {
const {header = {}, ...rest} = options;
let userState = getStore().getState().user;
// console.log('userState.....', userState);
const {token} = userState || {};
if (!/http|https/.test(url)) {
url = `${config.httpBaseUrl ? config.httpBaseUrl : ''}${url}`
};
let params = {
url,
timeout: 10 * 1000,
header: {
'Content-Type': 'application/json;charset=UTF-8',
'token': token || '',
...header,
},
...rest
};
if (!token) {
delete params.header.token;
}
return params;
}
/**
* 处理返回结果
* @param {*} res
* @param {*} resolve
* @param {*} reject
*/
handleResult(res, resolve, reject) {
//防止后端返回的是一个字符串
if (typeof res.data === 'string') {
try {
res.data = JSON.parse(res.data);
} catch(err) {
}
}
if (res.statusCode == 200 && res.data.success) {
resolve(res.data);
}
if (res.statusCode == 200 && !res.data.success) {
Taro.showToast({title: res.data.errorMsg, icon: 'none'});
//未登陆
if (res.data.errorCode == 403) {
//如果跳过登录就不跳了
// Taro.navigateTo({url: '/pages/login/index?back=1'})
// })
}
reject(res.data);
}
if (res.statusCode != 200) {
Taro.showToast({title: '服务器异常', icon: 'none'});
reject({
errorCode: '1000000',
errorMsg: '服务器异常'
})
}
}
/**
* 生成请求方法
*/
genRequestMethod() {
['get', 'post', 'delete', 'put'].forEach(methodName => {
this[methodName] = (url, data = {}, options = {}) => {
return new Promise((resolve, reject) => {
let params = this.handleParams(url, options);
params.timeout = 100 * 1000;
params.method = methodName.toUpperCase();
let timeStamp = (new Date()).getTime();
const channel = CHANNEL[env];
params.data = {
appId: channel.id,
batchNo: timeStamp,
timestamp: timeStamp,
charset: 'utf-8',
format: 'JSON',
signType: 'RSA2',
channel: channel.name,
// sign: 'xiaoya',
deviceNo: timeStamp,
...data,
};
// if (url.indexOf('/login') > -1) {
// params.data.appletType = 2;
// }
// let sign = encrypt(params.data);
params.data.sign = 'xiaoya';
// params.data.signType = 'RSA2';
if (methodName === 'post') {
params.data = JSON.stringify(params.data || {});
}
// console.log(params.data);
Taro.request(params)
.then(res => {
// console.log('res....', res);
// try {
this.handleResult(res, resolve, reject);
// } catch(err) {
// console.log('ggggggg', err);
// }
})
.catch(err => {
// console.log('errr.......', err);
reject({
errorCode: '1000000',
errorMsg: '服务器异常'
})
})
})
}
})
}
/**
* 上传文件
*/
upload(url, options = {}) {
if (typeof my !== 'undefined') {
//做一下兼容,支付宝/微信文件名字段不一样
if (options.name) {
options.fileName = options.name;
options.fileType = options.fileType || 'image';
// delete options.name;
}
}
let params = this.handleParams(url, options);
return new Promise((resolve, reject) => {
Taro.uploadFile(params)
.then(res => {
this.handleResult(res, resolve, reject);
})
.catch(err => {
reject({
errorCode: '1000000',
errorMsg: '服务器异常'
})
})
})
}
}
export default new Request();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment