(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';

/****************************************************************************
 Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
  worldwide, royalty-free, non-assignable, revocable and non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
  not use Cocos Creator software for developing other software or tools that's
  used for developing games. You are not granted to publish, distribute,
  sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/

require('./rt-sys.js');
require('./rt_input.js');
require('./rt-loadSubpackage.js');
require('./rt-game.js');
require('./rt-jsb.js');

require('./jsb-node.js');
require('./jsb-audio.js');
require('./jsb-loader.js');
require('./jsb-editbox.js');

},{"./jsb-audio.js":2,"./jsb-editbox.js":3,"./jsb-loader.js":4,"./jsb-node.js":5,"./rt-game.js":6,"./rt-jsb.js":7,"./rt-loadSubpackage.js":8,"./rt-sys.js":9,"./rt_input.js":10}],2:[function(require,module,exports){
'use strict';

/****************************************************************************
 Copyright (c) 2013-2016 Chukong Technologies Inc.
 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
 worldwide, royalty-free, non-assignable, revocable and  non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
 not use Cocos Creator software for developing other software or tools that's
 used for developing games. You are not granted to publish, distribute,
 sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/

cc.Audio = function (src) {
    this.src = src;
    this.volume = 1;
    this.loop = false;
    this.id = -1;
};

var rt = loadRuntime();
jsb.AudioEngine = rt.AudioEngine;

(function (proto, audioEngine) {
    // Using the new audioEngine
    cc.audioEngine = audioEngine;

    audioEngine.setMaxWebAudioSize = function () {};

    cc.Audio.State = audioEngine.AudioState;

    var handleVolume = function handleVolume(volume) {
        if (volume === undefined) {
            // set default volume as 1
            volume = 1;
        } else if (typeof volume === 'string') {
            volume = Number.parseFloat(volume);
        }
        return volume;
    };

    proto.play = function () {
        audioEngine.stop(this.id);
        var clip = this.src;

        if (clip.loaded) {
            this.id = audioEngine.play2d(clip._nativeAsset, this.loop, this.volume);
        } else {
            var self = this;
            cc.loader.load({
                url: clip.nativeUrl,
                // For audio, we should skip loader otherwise it will load a new audioClip.
                skips: ['Loader']
            }, function (err, audioNativeAsset) {
                if (err) {
                    cc.error(err);
                    return;
                }

                if (!clip.loaded) {
                    clip._nativeAsset = audioNativeAsset;
                    self.id = audioEngine.play2d(audioNativeAsset, self.loop, self.volume);
                }
            });
        }
    };

    proto.pause = function () {
        audioEngine.pause(this.id);
    };

    proto.resume = function () {
        audioEngine.resume(this.id);
    };

    proto.stop = function () {
        audioEngine.stop(this.id);
    };

    proto.destroy = function () {};

    proto.setLoop = function (loop) {
        this.loop = loop;
        audioEngine.setLoop(this.id, loop);
    };

    proto.getLoop = function () {
        return this.loop;
    };

    proto.setVolume = function (volume) {
        volume = handleVolume(volume);
        this.volume = volume;
        return audioEngine.setVolume(this.id, volume);
    };

    proto.getVolume = function () {
        return this.volume;
    };

    proto.setCurrentTime = function (time) {
        audioEngine.setCurrentTime(this.id, time);
    };

    proto.getCurrentTime = function () {
        return audioEngine.getCurrentTime(this.id);
    };

    proto.getDuration = function () {
        return audioEngine.getDuration(this.id);
    };

    proto.getState = function () {
        return audioEngine.getState(this.id);
    };

    // polyfill audioEngine

    var _music = {
        id: -1,
        clip: '',
        loop: false,
        volume: 1
    };
    var _effect = {
        volume: 1
    };

    audioEngine.play = function (clip, loop, volume) {
        if (typeof volume !== 'number') {
            volume = 1;
        }
        if (typeof clip === 'string') {
            // backward compatibility since 1.10
            cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
            var path = clip;
            var md5Pipe = cc.loader.md5Pipe;
            if (md5Pipe) {
                path = md5Pipe.transformURL(path);
            }
            return audioEngine.play2d(path, loop, volume);
        } else {
            if (!clip) {
                return;
            }
            if (clip.loaded) {
                return audioEngine.play2d(clip._nativeAsset, loop, volume);
            } else {
                cc.loader.load({
                    url: clip.nativeUrl,
                    // For audio, we should skip loader otherwise it will load a new audioClip.
                    skips: ['Loader']
                }, function (err, audioNativeAsset) {
                    if (err) {
                        cc.error(err);
                        return;
                    }
                    if (!clip.loaded) {
                        clip._nativeAsset = audioNativeAsset;
                        audioEngine.play2d(audioNativeAsset, loop, volume);
                    }
                });
                // Deffered loading return audioID -1
                return -1;
            }
        }
    };
    audioEngine.playMusic = function (clip, loop) {
        audioEngine.stop(_music.id);
        _music.id = audioEngine.play(clip, loop, _music.volume);
        _music.loop = loop;
        _music.clip = clip;
        return _music.id;
    };
    audioEngine.stopMusic = function () {
        audioEngine.stop(_music.id);
    };
    audioEngine.pauseMusic = function () {
        audioEngine.pause(_music.id);
        return _music.id;
    };
    audioEngine.resumeMusic = function () {
        audioEngine.resume(_music.id);
        return _music.id;
    };
    audioEngine.getMusicVolume = function () {
        return _music.volume;
    };
    audioEngine.setMusicVolume = function (volume) {
        _music.volume = handleVolume(volume);
        audioEngine.setVolume(_music.id, _music.volume);
        return volume;
    };
    audioEngine.isMusicPlaying = function () {
        return audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
    };
    audioEngine.playEffect = function (filePath, loop) {
        return audioEngine.play(filePath, loop || false, _effect.volume);
    };
    audioEngine.setEffectsVolume = function (volume) {
        _effect.volume = handleVolume(volume);
    };
    audioEngine.getEffectsVolume = function () {
        return _effect.volume;
    };
    audioEngine.pauseEffect = function (audioID) {
        return audioEngine.pause(audioID);
    };
    audioEngine.pauseAllEffects = function () {
        var musicPlay = audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
        audioEngine.pauseAll();
        if (musicPlay) {
            audioEngine.resume(_music.id);
        }
    };
    audioEngine.resumeEffect = function (id) {
        audioEngine.resume(id);
    };
    audioEngine.resumeAllEffects = function () {
        var musicPaused = audioEngine.getState(_music.id) === audioEngine.AudioState.PAUSED;
        audioEngine.resumeAll();
        if (musicPaused && audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING) {
            audioEngine.pause(_music.id);
        }
    };
    audioEngine.stopEffect = function (id) {
        return audioEngine.stop(id);
    };
    audioEngine.stopAllEffects = function () {
        var musicPlaying = audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
        var currentTime = audioEngine.getCurrentTime(_music.id);
        audioEngine.stopAll();
        if (musicPlaying) {
            _music.id = audioEngine.play(_music.clip, _music.loop);
            audioEngine.setCurrentTime(_music.id, currentTime);
        }
    };

    // incompatible implementation for game pause & resume
    audioEngine._break = audioEngine.pauseAll;
    audioEngine._restore = audioEngine.resumeAll;

    // deprecated

    audioEngine._uncache = audioEngine.uncache;
    audioEngine.uncache = function (clip) {
        var path;
        if (typeof clip === 'string') {
            // backward compatibility since 1.10
            cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
            path = clip;
        } else {
            if (!clip) {
                return;
            }
            path = clip._nativeAsset;
        }
        audioEngine._uncache(path);
    };

    audioEngine._preload = audioEngine.preload;
    audioEngine.preload = function (filePath, callback) {
        cc.warn('`cc.audioEngine.preload` is deprecated, use `cc.loader.loadRes(url, cc.AudioClip)` instead please.');
        audioEngine._preload(filePath, callback);
    };
})(cc.Audio.prototype, jsb.AudioEngine);

},{}],3:[function(require,module,exports){
'use strict';

/****************************************************************************
 Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
  worldwide, royalty-free, non-assignable, revocable and non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
  not use Cocos Creator software for developing other software or tools that's
  used for developing games. You are not granted to publish, distribute,
  sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/

(function () {
	if (!(cc && cc.EditBox)) {
		return;
	}

	var KeyboardReturnType = cc.EditBox.KeyboardReturnType;
	var InputMode = cc.EditBox.InputMode;
	var InputFlag = cc.EditBox.InputFlag;
	var _p = cc.EditBox._EditBoxImpl.prototype;

	function getInputType(type) {
		switch (type) {
			case InputMode.EMAIL_ADDR:
				return 'email';
			case InputMode.NUMERIC:
			case InputMode.DECIMAL:
				return 'number';
			case InputMode.PHONE_NUMBER:
				return 'phone';
			case InputMode.URL:
				return 'url';
			case InputMode.SINGLE_LINE:
			case InputMode.ANY:
			default:
				return 'text';
		}
	}

	function getKeyboardReturnType(type) {
		switch (type) {
			case KeyboardReturnType.DEFAULT:
			case KeyboardReturnType.DONE:
				return 'done';
			case KeyboardReturnType.SEND:
				return 'send';
			case KeyboardReturnType.SEARCH:
				return 'search';
			case KeyboardReturnType.GO:
				return 'go';
			case KeyboardReturnType.NEXT:
				return 'next';
		}
		return 'done';
	}

	function updateLabelsInvisible(editBox) {
		var placeholderLabel = editBox._placeholderLabel;
		var textLabel = editBox._textLabel;
		var displayText = editBox._impl._text;

		placeholderLabel.node.active = displayText === '';
		textLabel.node.active = displayText !== '';
	}

	cc.EditBox.prototype.editBoxEditingDidBegan = function () {
		cc.Component.EventHandler.emitEvents(this.editingDidBegan, this);
		this.node.emit('editing-did-began', this);
	};

	cc.EditBox.prototype.editBoxEditingDidEnded = function () {
		cc.Component.EventHandler.emitEvents(this.editingDidEnded, this);
		this.node.emit('editing-did-ended', this);
	};

	cc.EditBox.prototype._updateStayOnTop = function () {
		// jsb not support
	};

	_p.createInput = function () {
		var editBoxImpl = this;
		editBoxImpl._editing = true;

		var multiline = this._inputMode === InputMode.ANY;
		var inputTypeString = getInputType(editBoxImpl._inputMode);
		if (editBoxImpl._inputFlag === InputFlag.PASSWORD) inputTypeString = 'password';

		var rect = this._getRect();

		jsb.inputBox.show({
			defaultValue: editBoxImpl._text,
			maxLength: editBoxImpl._maxLength,
			multiple: multiline,
			confirmHold: false,
			confirmType: getKeyboardReturnType(editBoxImpl._returnType),
			inputType: inputTypeString,
			originX: rect.x,
			originY: rect.y,
			width: rect.width,
			height: rect.height
		});
		if (this._delegate) {
			var editBox = this._delegate;
			cc.Component.EventHandler.emitEvents(editBox.editingDidBegan, editBox);
			editBox.node.emit('editing-did-began', editBox);
			updateLabelsInvisible(editBox);
		}

		function onConfirm(res) {
			editBoxImpl._delegate && editBoxImpl._delegate.editBoxEditingReturn && editBoxImpl._delegate.editBoxEditingReturn();
		}
		jsb.inputBox.onConfirm(onConfirm);

		function onInput(res) {
			if (res.value.length > editBoxImpl._maxLength) {
				res.value = res.value.slice(0, editBoxImpl._maxLength);
			}
			if (editBoxImpl._delegate && editBoxImpl._delegate.editBoxTextChanged) {
				if (editBoxImpl._text !== res.value) {
					editBoxImpl._text = res.value;
					editBoxImpl._delegate.editBoxTextChanged(editBoxImpl._text);
				}
			}
		}
		jsb.inputBox.onInput(onInput);

		function onComplete(res) {
			editBoxImpl._endEditing();
			jsb.inputBox.offConfirm(onConfirm);
			jsb.inputBox.offInput(onInput);
			jsb.inputBox.offComplete(onComplete);
		}
		jsb.inputBox.onComplete(onComplete);
	};

	_p.setTabIndex = function (index) {
		// jsb not support 
	};

	_p.setFocus = function () {
		this._beginEditing();
	};

	_p.isFocused = function () {
		return this._editing;
	}, _p.stayOnTop = function (flag) {
		// jsb not support 	
	};

	_p._updateMatrix = function () {
		// jsb not support 			
	};

	_p._updateSize = function (newWidth, newHeight) {
		// jsb not support
	};

	_p._getRect = function () {
		var node = this._node,
		    scaleX = cc.view._scaleX,
		    scaleY = cc.view._scaleY;
		var dpr = cc.view._devicePixelRatio;

		var math = cc.vmath;
		var matrix = math.mat4.create();
		node.getWorldMatrix(matrix);
		var contentSize = node._contentSize;
		var vec3 = cc.v3();
		vec3.x = -node._anchorPoint.x * contentSize.width;
		vec3.y = -node._anchorPoint.y * contentSize.height;

		math.mat4.translate(matrix, matrix, vec3);

		scaleX /= dpr;
		scaleY /= dpr;

		var finalScaleX = matrix.m00 * scaleX;
		var finaleScaleY = matrix.m05 * scaleY;

		return {
			x: matrix.m12 * finalScaleX,
			y: matrix.m13 * finaleScaleY,
			width: contentSize.width * finalScaleX,
			height: contentSize.height * finaleScaleY
		};
	};

	_p.setMaxLength = function (maxLength) {
		if (!isNaN(maxLength)) {
			if (maxLength < 0) {
				//we can't set Number.MAX_VALUE to input's maxLength property
				//so we use a magic number here, it should works at most use cases.
				maxLength = 65535;
			}
			this._maxLength = maxLength;
		}
	};

	_p.setString = function (text) {
		this._text = text;
		this._updateInput();
		updateLabelsInvisible(this._delegate);
	};

	_p._updateInput = function () {
		var tmpText = this._text;
		if (this._inputFlag === InputFlag.PASSWORD) {
			tmpText = tmpText.replace(/./g, '*');
		}
		this._delegate._textLabel.string = tmpText;
	};

	_p.setFontSize = function (fontSize) {
		this._edFontSize = fontSize || this._edFontSize;
		this._delegate._textLabel.fontSize = this._edFontSize;
	};

	_p.setFontColor = function (color) {
		this._textColor = color;
		this._delegate._textLabel.fontColor = this._textColor;
	};

	_p.setInputMode = function (inputMode) {
		this._inputMode = inputMode;
	};

	_p.setInputFlag = function (inputFlag) {
		this._inputFlag = inputFlag;
	};

	_p.setReturnType = function (returnType) {
		this._returnType = returnType;
	};

	_p._beginEditing = function () {
		this.createInput();
	};

	_p._endEditing = function () {
		var self = this;
		if (this._editing) {
			self._endEditingOnMobile();
			if (self._delegate && self._delegate.editBoxEditingDidEnded) {
				self._delegate.editBoxEditingDidEnded();
			}
		}
		this._editing = false;
	};

	_p.clear = function () {
		this._node = null;
		this.setDelegate(null);
	};
})();

},{}],4:[function(require,module,exports){
/****************************************************************************
 Copyright (c) 2013-2016 Chukong Technologies Inc.
 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
  worldwide, royalty-free, non-assignable, revocable and  non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
  not use Cocos Creator software for developing other software or tools that's
  used for developing games. You are not granted to publish, distribute,
  sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/
'use strict';

function downloadScript(item, callback) {
    require(item.url);
    return null;
}

function downloadAudio(item) {
    return item.url;
}

function loadAudio(item, callback) {
    var loadByDeserializedAsset = item._owner instanceof cc.AudioClip;
    if (loadByDeserializedAsset) {
        return item.url;
    } else {
        var audioClip = new cc.AudioClip();
        // obtain user url through nativeUrl
        audioClip._setRawAsset(item.rawUrl, false);
        // obtain download url through _nativeAsset
        audioClip._nativeAsset = item.url;
        return audioClip;
    }
}

function downloadImage(item, callback) {
    var img = new Image();
    img.src = item.url;
    img.onload = function (info) {
        callback(null, img);
    };
    // Don't return anything to use async loading.
}

function _getFontFamily(fontHandle) {
    var ttfIndex = fontHandle.lastIndexOf(".ttf");
    if (ttfIndex === -1) return fontHandle;

    var slashPos = fontHandle.lastIndexOf("/");
    var fontFamilyName;
    if (slashPos === -1) {
        fontFamilyName = fontHandle.substring(0, ttfIndex) + "_LABEL";
    } else {
        fontFamilyName = fontHandle.substring(slashPos + 1, ttfIndex) + "_LABEL";
    }
    if (fontFamilyName.indexOf(' ') !== -1) {
        fontFamilyName = '"' + fontFamilyName + '"';
    }
    return fontFamilyName;
}

var downloadBinary = void 0,
    downloadText = void 0,
    loadFont = void 0;
downloadText = function downloadText(item) {
    var url = item.url;

    var result = jsb.fileUtils.getStringFromFile(url);
    if (typeof result === 'string' && result) {
        return result;
    } else {
        return new Error('Download text failed: ' + url);
    }
};

downloadBinary = function downloadBinary(item) {
    var url = item.url;

    var result = jsb.fileUtils.getDataFromFile(url);
    if (result) {
        return result;
    } else {
        return new Error('Download binary file failed: ' + url);
    }
};

loadFont = function loadFont(item) {
    var url = item.url;
    var fontFamilyName = _getFontFamily(url);

    // load from local font
    var localPath = "url('" + url + "')";
    jsb.loadFont(fontFamilyName, localPath);
    return fontFamilyName;
};

cc.loader.addDownloadHandlers({
    // JS
    'js': downloadScript,
    'jsc': downloadScript,

    // Images
    'png': downloadImage,
    'jpg': downloadImage,
    'bmp': downloadImage,
    'jpeg': downloadImage,
    'gif': downloadImage,
    'ico': downloadImage,
    'tiff': downloadImage,
    'webp': downloadImage,
    'image': downloadImage,
    'pvr': downloadImage,
    'etc': downloadImage,

    // Audio
    'mp3': downloadAudio,
    'ogg': downloadAudio,
    'wav': downloadAudio,
    'mp4': downloadAudio,
    'm4a': downloadAudio,

    // Text
    'txt': downloadText,
    'xml': downloadText,
    'vsh': downloadText,
    'fsh': downloadText,
    'atlas': downloadText,

    'tmx': downloadText,
    'tsx': downloadText,

    'json': downloadText,
    'ExportJson': downloadText,
    'plist': downloadText,

    'fnt': downloadText,

    'binary': downloadBinary,
    'bin': downloadBinary,

    'default': downloadText
});

cc.loader.addLoadHandlers({
    // Font
    'font': loadFont,
    'eot': loadFont,
    'ttf': loadFont,
    'woff': loadFont,
    'svg': loadFont,
    'ttc': loadFont,

    // Audio
    'mp3': loadAudio,
    'ogg': loadAudio,
    'wav': loadAudio,
    'mp4': loadAudio,
    'm4a': loadAudio
});

},{}],5:[function(require,module,exports){
/****************************************************************************
 Copyright (c) 2013-2016 Chukong Technologies Inc.
 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
  worldwide, royalty-free, non-assignable, revocable and  non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
  not use Cocos Creator software for developing other software or tools that's
  used for developing games. You are not granted to publish, distribute,
  sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/
'use strict';

var math = cc.vmath;

var _typedArray_temp = new Float32Array(16);
var _mat4_temp = math.mat4.create();

function _mat4ToArray(typedArray, mat4) {
  typedArray[0] = mat4.m00;
  typedArray[1] = mat4.m01;
  typedArray[2] = mat4.m02;
  typedArray[3] = mat4.m03;
  typedArray[4] = mat4.m04;
  typedArray[5] = mat4.m05;
  typedArray[6] = mat4.m06;
  typedArray[7] = mat4.m07;
  typedArray[8] = mat4.m08;
  typedArray[9] = mat4.m09;
  typedArray[10] = mat4.m10;
  typedArray[11] = mat4.m11;
  typedArray[12] = mat4.m12;
  typedArray[13] = mat4.m13;
  typedArray[14] = mat4.m14;
  typedArray[15] = mat4.m15;
}

cc.Node.prototype.getWorldRTInAB = function () {
  this.getWorldRT(_mat4_temp);
  _mat4ToArray(_typedArray_temp, _mat4_temp);
  return _typedArray_temp;
};

cc.Node.prototype.getWorldMatrixInAB = function () {
  this._updateWorldMatrix();
  _mat4ToArray(_typedArray_temp, this._worldMatrix);
  return _typedArray_temp;
};

},{}],6:[function(require,module,exports){
"use strict";

cc.game.restart = function () {
    cc.sys.restartVM();
};

loadRuntime().onHide(function () {
    cc.game.emit(cc.game.EVENT_HIDE);
});

loadRuntime().onShow(function () {
    cc.game.emit(cc.game.EVENT_SHOW);
});

},{}],7:[function(require,module,exports){
/****************************************************************************
 Copyright (c) 2013-2016 Chukong Technologies Inc.
 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
  worldwide, royalty-free, non-assignable, revocable and  non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
  not use Cocos Creator software for developing other software or tools that's
  used for developing games. You are not granted to publish, distribute,
  sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/
'use strict';

var rt = loadRuntime();
jsb.fileUtils = {
    getStringFromFile: function getStringFromFile(url) {
        var result;
        try {
            result = rt.getFileSystemManager().readFileSync(url, "utf8");
        } catch (error) {
            cc.error(error);
        }
        return result;
    },

    getDataFromFile: function getDataFromFile(url) {
        var result;
        try {
            result = rt.getFileSystemManager().readFileSync(url);
        } catch (error) {
            cc.error(error);
        }
        return result;
    },

    getWritablePath: function getWritablePath() {
        return rt.env.USER_DATA_PATH + "/";
    },

    writeToFile: function writeToFile(map, url) {
        var str = JSON.stringify(map);
        var result = false;
        try {
            rt.getFileSystemManager().writeFileSync(url, str, "utf8");
            result = true;
        } catch (error) {
            cc.error(error);
        }
        return result;
    },

    getValueMapFromFile: function getValueMapFromFile(url) {
        var map_object = {};
        var read;
        try {
            read = rt.getFileSystemManager().readFileSync(url, "utf8");
        } catch (error) {
            cc.error(error);
        }
        if (!read) {
            return map_object;
        }
        map_object = JSON.parse(read);
        return map_object;
    }
};

if (typeof jsb.saveImageData === 'undefined') {
    jsb.saveImageData = function (data, width, height, filePath) {
        var index = filePath.lastIndexOf(".");
        if (index === -1) {
            return false;
        }
        var fileType = filePath.substr(index + 1);
        var tempFilePath = rt.saveImageTempSync({
            'data': data,
            'width': width,
            'height': height,
            'fileType': fileType
        });
        if (tempFilePath === '') {
            return false;
        }
        var savedFilePath = rt.getFileSystemManager().saveFileSync(tempFilePath, filePath);
        if (savedFilePath === filePath) {
            return true;
        }
        return false;
    };
}

if (typeof jsb.setPreferredFramesPerSecond === 'undefined' && typeof rt.setPreferredFramesPerSecond !== 'undefined') {
    jsb.setPreferredFramesPerSecond = rt.setPreferredFramesPerSecond;
} else {
    jsb.setPreferredFramesPerSecond = function () {
        console.error("The jsb.setPreferredFramesPerSecond is not define!");
    };
}

var _motionEnabled = false;
if (!jsb.device.setMotionEnabled) {
    jsb.device.setMotionEnabled = function (enabled) {
        if (_motionEnabled === enabled) return;
        if (enabled) {
            qg.startAccelerometer({
                interval: "game",
                success: function success(res) {
                    qg.onAccelerometerChange(function (obj) {
                        var event = new DeviceMotionEvent();
                        event._accelerationIncludingGravity.x = obj.x;
                        event._accelerationIncludingGravity.y = obj.y;
                        event._accelerationIncludingGravity.z = obj.z;
                        jsb.device.dispatchDeviceMotionEvent(event);
                    });
                }
            });
        } else {
            qg.stopAccelerometer();
        }
        _motionEnabled = enabled;
    };
}

},{}],8:[function(require,module,exports){
"use strict";

cc.loader.downloader.loadSubpackage = function (name, completeCallback) {
    var rt = loadRuntime();
    rt.loadSubpackage({
        name: name, //fileName,
        success: function success() {
            if (completeCallback) completeCallback();
        },
        fail: function fail() {
            if (completeCallback) completeCallback(new Error("Failed to load subpackage " + name));
        }
    });
};

},{}],9:[function(require,module,exports){
/****************************************************************************
 Copyright (c) 2013-2016 Chukong Technologies Inc.
 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
  worldwide, royalty-free, non-assignable, revocable and  non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
  not use Cocos Creator software for developing other software or tools that's
  used for developing games. You are not granted to publish, distribute,
  sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/
'use strict';

var sys = cc.sys;

if (typeof loadRuntime === 'function') {
    var rt = loadRuntime();
    sys.getNetworkType = rt.getNetworkType;
    sys.getBatteryLevel = rt.getBatteryLevel;
    sys.garbageCollect = rt.triggerGC;
}
if (typeof __restartVM !== 'undefined') {
    sys.restartVM = __restartVM;
} else {
    sys.restartVM = function () {
        console.error("The restartVM is not define!");
    };
}
if (typeof __isObjectValid !== 'undefined') {
    sys.isObjectValid = __isObjectValid;
} else {
    sys.isObjectValid = function () {
        console.error("The sys.isObjectValid is not define!");
    };
}

},{}],10:[function(require,module,exports){
"use strict";

/****************************************************************************
 Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.

 http://www.cocos.com

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated engine source code (the "Software"), a limited,
  worldwide, royalty-free, non-assignable, revocable and non-exclusive license
 to use Cocos Creator solely to develop games on your target platforms. You shall
  not use Cocos Creator software for developing other software or tools that's
  used for developing games. You are not granted to publish, distribute,
  sublicense, and/or sell copies of Cocos Creator.

 The software or tools in this License Agreement are licensed, not sold.
 Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/
var rt = loadRuntime();

jsb.inputBox = {
  onConfirm: function onConfirm(cb) {
    rt.onKeyboardConfirm(cb);
  },
  offConfirm: function offConfirm(cb) {
    rt.offKeyboardConfirm(cb);
  },

  onComplete: function onComplete(cb) {
    rt.onKeyboardComplete(cb);
  },
  offComplete: function offComplete(cb) {
    rt.offKeyboardComplete(cb);
  },

  onInput: function onInput(cb) {
    rt.onKeyboardInput(cb);
  },
  offInput: function offInput(cb) {
    rt.offKeyboardInput(cb);
  },

  /**
   * @param {string}		options.defaultValue
   * @param {number}		options.maxLength
   * @param {bool}        options.multiple
   * @param {bool}        options.confirmHold
   * @param {string}      options.confirmType
   * @param {string}      options.inputType
   * 
   * Values of options.confirmType can be [done|next|search|go|send].
   * Values of options.inputType can be [text|email|number|phone|password].
   */
  show: function show(options) {
    rt.showKeyboard(options);
  },
  hide: function hide() {
    rt.hideKeyboard();
  }
};

},{}]},{},[1]);
