1 Star 1 Fork 3

邓广元/MiniTES

forked from 锅巴汉化/MiniTES 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
kongregate_api.js 66.98 KB
一键复制 编辑 原始数据 按行查看 历史
zhaolinxu 提交于 2019-03-07 18:00 . 源码
var Kongregate=Kongregate||{};Kongregate.Utils=Kongregate.Utils||{};Kongregate.Utils.isKlient=function(){return/klient|kartridge\//.test(navigator.userAgent.toLowerCase())};Kongregate.Utils.findKongregateWindow=function(){if(!Kongregate.Utils.isKlient())return top;for(var a=window,c=window.parent;c!==top;)a=c,c=a.parent;return a};
Kongregate.Utils.catchErrors=function(a,c,b){return function(){try{return a.apply(c,arguments)}catch(d){return Kongregate.Log.error("catchErrors caught unhandled exception",d),b}}};
(function(){function a(a,b,d){Kongregate.Log[a]=function(){try{"undefined"!==typeof active_user&&void 0===Kongregate.Log.debugLevel&&(Kongregate.Log.debugLevel=active_user.debugLevel()),Kongregate.Log.debugLevel>=b&&(console[d]?Function.prototype.apply.call(console[d],console,arguments):console.log(arguments))}catch(a){}}}Kongregate.Log={};a("spam",5,"log");a("debug",4,"log");a("info",3,"info");a("warn",2,"warn");a("error",1,"error")})();
KonduitEvent={INIT:"init",CONNECT:"connect",CONNECTED:"connected",DISCONNECT:"disconnect",LOGIN:"login",SWITCH_USER:"switch_user",JOIN_ROOM:"join_room",LEAVE_ROOM:"leave_room",USER_JOIN:"user_join",USER_DEPARTURE:"user_departure",USER_CHANGED:"user_changed",ROOM_MESSAGE:"room_message",SYSTEM_MESSAGE:"system_message",PRIVATE_MESSAGE:"private_message",ADMIN_MESSAGE:"admin_message",MESSAGE_ERROR:"message_error",SET_PRESENCE:"set_presence",GUEST_COUNT:"guest_count",ROOM_NOT_FOUND:"room_not_found",ROOM_FULL:"room_full",
REQUEST_CHAT_ROOM:"request_chat_room",CREATE_PRIVATE_ROOM:"create_private_room",DESTROY_PRIVATE_ROOM:"destroy_private_room",PRIVATE_ROOM_INVITATION:"private_room_invitation",PRIVATE_ROOM_KICK:"private_room_kick",PRIVATE_ROOM_INVITATION_SENT:"private_room_invitation_sent",JOIN_GUILD_ROOM:"join_guild_room",SILENCED:"silenced",PARTICIPATE:"participate",AMNESTY:"amnesty",API_INITIALIZED:"api_initialized",ADD_STATISTICS:"add_statistics",STATISTIC_UPDATED:"statistic_updated",STATISTIC_SUBMISSION:"statistic_submission",
STATISTICS_FLUSH:"statistics_flush",STATISTICS_FORCE_FLUSH:"statistics_force_flush",SET_ACCOMPLISHMENT_PROGRESS:"set_accomplishment_progress",NEW_HIGH_SCORE:"new_high_score",DISPLAY_SHOUT_BOX:"display_shout_box",DISPLAY_INVITATION_BOX:"display_invitation_box",SEND_PRIVATE_MESSAGE:"send_private_message",DISPLAY_FEED_POST_BOX:"display_feed_post_box",DISPLAY_SIGN_IN_LIGHTBOX:"display_sign_in_lightbox",DISPLAY_REGISTRATION_LIGHTBOX:"display_registration_lightbox",LIGHTBOX_OPENED:"lightbox_opened",LIGHTBOX_CLOSED:"lightbox_closed",
ACCOMPLISHMENT_TASK_PROGRESS:"accomplishment_task_progress",ACCOMPLISHMENT_COMPLETE:"accomplishment_complete",RESIZE_GAME:"resize_game",HANDLE_ITEM_CHECKOUT_REQUEST:"handle_item_checkout_request",KONDUIT_MESSAGE:"konduit_message",ANALYTICS_PAYLOAD:"analytics_payload",OP_EXTERNAL_MESSAGE:"ext.msg",OP_CONNECTED:"connected",OP_HELLO:"hello",OP_USER_INFO:"user.info",OP_SIGN_IN:"sign_in",PARAM_USER:"user",PARAM_USER_ID:"user_id",PARAM_GAME_AUTH_TOKEN:"auth_token",PURCHASE_RESULT:"purchase_result",PARAM_LOCALCONNECTION_ONLY:"localconnection_only",
CUSTOM_TAB_MESSAGE:"custom_tab_message",CUSTOM_TAB_SHOW:"custom_tab_show",CUSTOM_TAB_CLOSE:"custom_tab_close",CUSTOM_TAB_SHOWN:"custom_tab_shown",CUSTOM_TAB_CLEAR_MESSAGES:"custom_tab_clear_messages",OP_CHAT_TAB:"chat.tab",OP_CHAT_CLEAR_DIALOG:"chat.dlg.clear",OP_CHAT_DISPLAY:"chat.disp",OP_CHAT_MSG:"chat.msg",OP_CHAT_CANVAS_ELEMENT:"chat.elm",OP_CHAT_PRIVATE_MESSAGE:"chat.privateMessage",OP_CHAT_RESIZE_GAME:"chat.resizeGame",OP_CHAT_DISPLAY_INVITATION_BOX:"chat.invite",OP_CHAT_DISPLAY_FEED_POST_BOX:"chat.feedpost",
OP_CHAT_DISPLAY_REGISTRATION:"chat.registration",OP_CHAT_DISPLAY_SHOUT_BOX:"chat.shoutbox",PARAM_SHOUT_MESSAGE:"shout_message",PARAM_CANVAS_SIZE:"chat.canvas.size",PARAM_RESIZE_GAME_WIDTH:"chat.resizeGame.width",PARAM_RESIZE_GAME_HEIGHT:"chat.resizeGame.height",PARAM_INVITATION_MESSAGE:"invitation_message",PARAM_FRIEND_FILTER:"filter",PARAM_IMAGE_URI:"image_uri",PARAM_KV_PARAMS:"kv_params",PARAM_NAME:"name",PARAM_DESCRIPTION:"desc",PARAM_DATA:"data",OP_SHOUT_CALLBACK:"ext.shout_callback",PARAM_MESSAGE_TYPE:"ext.message_type",
PARAM_MESSAGE_RECIPIENTS:"ext.message_recipients",PARAM_ERROR:"error",PARAM_SUCCESS:"success",PARAM_REQUEST_ID:"req.id",OP_STATS_SUBMIT:"stat.submit",PARAM_STATS:"stats",ITEM_LIST:"mtx.item_list",ITEM_CHECKOUT:"mtx.checkout",PURCHASE_KREDS:"mtx.kred_purchase",ITEM_INSTANCES:"mtx.item_instances",USE_ITEM_INSTANCE:"mtx.use_item_instance",PARAM_PURCHASE_METHOD:"purchase_method",PARAM_ITEM_TAGS:"item_tags",PARAM_ITEMS:"items",PARAM_ORDER_INFO:"order_info",PARAM_ID:"id",ADS_INITIALIZE:"ads.initialize",
ADS_AVAILABLE:"ads.available",ADS_UNAVAILABLE:"ads.unavailable",ADS_SHOW_INCENTIVIZED:"ads.show_incentivized",AD_OPENED:"ads.ad_opened",AD_COMPLETED:"ads.ad_completed",AD_ABANDONED:"ads.ad_abandoned",PROCESSING_SAVE_SHARED_CONTENT:"processing_save_shared_content",SAVE_SHARED_CONTENT:"save_shared_content",SAVE_SHARED_CONTENT_COMPLETE:"shared_content_save_complete",LOAD_SHARED_CONTENT:"load_shared_content",BROWSE_SHARED_CONTENT:"browse_shared_content",OP_SAVE_SHARED_CONTENT:"save_shared_content",OP_BROWSE_SHARED_CONTENT:"browse_shared_content",
OP_LOAD_SHARED_CONTENT:"load_shared_content",OP_SHARED_CONTENT_SAVE_COMPLETE:"shared_content_save_complete",PARAM_CONTENT_TYPE:"content_type",PARAM_LABEL:"label",PARAM_IMAGE:"image",PARAM_PERMALINK:"permalink",OP_IMAGE_AVATAR_SUBMIT:"avatar.submit",OP_IMAGE_AVATAR_FINISHED:"avatar.finished",IMAGE_AVATAR_SUBMIT:"image_avatar_submit",IMAGE_AVATAR_COMPLETE:"image_avatar_complete",OP_ANALYTICS_PAYLOAD:"analytics.payload",HOLODECK_DATA:"holodeck_data",PARAM_HOLODECK_TYPE:"holodeck_type",FETCH_HISTORY:"fetch_history",
HISTORY_RECEIVED:"history_received",FAYE_DISCONNECT:"faye_disconnect"};KonduitChatErrorMessage={MESSAGE_TOO_LONG:"error_msg_too_long",RATE_LIMITED:"error_msg_rate_limit"};KonduitPresenceType={CHAT:"chat",AWAY:"away"};
Kongregate.polyfillJSON=function(){window.JSON||(window.JSON={parse:function(a){return eval("("+a+")")},stringify:function(){var a=Object.prototype.toString,c=Array.isArray||function(c){return"[object Array]"===a.call(c)},b={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},d=function(a){return b[a]||"\\u"+(a.charCodeAt(0)+65536).toString(16).substr(1)},k=/[\\"\u0000-\u001F\u2028\u2029]/g;return function h(b){if(null==b)return"null";if("number"===typeof b)return isFinite(b)?
b.toString():"null";if("boolean"===typeof b)return b.toString();if("object"===typeof b){if("function"===typeof b.toJSON)return h(b.toJSON());if(c(b)){for(var m="[",n=0;n<b.length;n++)m+=(n?", ":"")+h(b[n]);return m+"]"}if("[object Object]"===a.call(b)){m=[];for(n in b)Object.prototype.hasOwnProperty.call(b,n)&&m.push(h(n)+": "+h(b[n]));return"{"+m.join(", ")+"}"}}return'"'+b.toString().replace(k,d)+'"'}}()})};
Kongregate.contentLoaded=function(a){var c=window,b=!1,d=!0,k=c.document,l=k.documentElement,h=k.addEventListener,f=h?"addEventListener":"attachEvent",m=h?"removeEventListener":"detachEvent",n=h?"":"on",p=function(d){if(!("readystatechange"==d.type&&"complete"!=k.readyState)&&(("load"==d.type?c:k)[m](n+d.type,p,!1),!b&&(b=!0)))a.call(c,d.type||d)},s=function(){try{l.doScroll("left")}catch(a){setTimeout(s,50);return}p("poll")};if("complete"==k.readyState)a.call(c,"lazy");else{if(!h&&l.doScroll){try{d=
!c.frameElement}catch(r){}d&&s()}k[f](n+"DOMContentLoaded",p,!1);k[f](n+"readystatechange",p,!1);c[f](n+"load",p,!1)}};
(function(){var a;Kongregate.MessageConnection=function(a){this.initialize(a)};Kongregate.MessageConnection.MESSAGE_EVENT="kongregate:api:message";Kongregate.MessageConnection.prototype={initialize:function(c){a=c.channel_id;this._window=c.window||window;this._targetOrigin=c.target_origin;this._targetWindows=c.target_window?[c.target_window]:[];this._sendListener=c.send_listener;this._retryConnection=c.retry_connection||!1;this._messageListeners=[];this._supportsObjects=Kongregate.PostMessage.supportsObjects();
this._client="string"===typeof this._targetOrigin;this._connected=this._handleMessages=!1},addMessageListener:function(a){this._messageListeners.push(a)},isSupported:function(){return!this.supportsObjects()&&"undefined"===typeof this._window.JSON?!1:"undefined"!==typeof(this._targetWindows[0]||window).postMessage},connected:function(){return this._connected},isClient:function(){return this._client},supportsObjects:function(){return this._supportsObjects},logPrefix:function(){return this._client?"[Game:JS]":
"[Konduit]"},listen:function(){if(this.isSupported()&&!this._listening){this._listening=!0;var a=this;Kongregate.PostMessage.addMessageListener(this._window,function(b){a.onMessageReceived.call(a,b)})}},parseMessage:function(a){try{var b=Kongregate.PostMessage.parseMessage(a);if(b&&b.kongregate_type===Kongregate.MessageConnection.MESSAGE_EVENT)return{opcode:b.opcode,params:b.params}}catch(d){Kongregate.Log.warn(this.logPrefix(),"Error parsing message",a,d)}return null},onMessageReceived:function(a){var b=
a.origin||a.originalEvent.origin;this._targetOrigin&&b!==this._targetOrigin?Kongregate.Log.debug(this.logPrefix(),"Ignoring message from "+b):(b=this.parseMessage(a.data))&&this.processMessage(b,a)},processMessage:function(a,b){Kongregate.Log.debug(this.logPrefix(),"Message received:",a);switch(a.opcode){case KonduitEvent.CONNECT:this.onClientConnected(a.params,b.source);break;case KonduitEvent.CONNECTED:this.onConnectedToServer()}for(var d=0;d<this._messageListeners.length;d++)this._messageListeners[d](a.opcode,
a.params)},sendMessage:function(a,b){this.removeMissingWindows();if(!this.connected()&&a!==KonduitEvent.CONNECT&&a!==KonduitEvent.CONNECTED)Kongregate.Log.debug(this.logPrefix(),"Not sending "+a+", not connected");else{var d={kongregate_type:Kongregate.MessageConnection.MESSAGE_EVENT,opcode:a,params:"string"===typeof b?JSON.parse(b):b};this.supportsObjects()||(d=JSON.stringify(d));for(var k=this._targetOrigin||"*",l=0;l<this._targetWindows.length;l++)this._targetWindows[l].postMessage(d,k);this._sendListener&&
this._sendListener(a,b)}},connect:function(){this.connected()||(this.listen(),Kongregate.Log.debug("Attempting to connect to Kongregate API"),this.sendMessage(KonduitEvent.CONNECT,{chnl:a}),this._retryConnection&&this.retryConnection())},retryConnection:function(){var a=this;setTimeout(function(){a.connect()},5E3)},onClientConnected:function(c,b){c.chnl!==a?Kongregate.Log.warn(this.logPrefix(),"Channel ID mismatch, ignoring connect"):(Kongregate.Log.debug(this.logPrefix(),"API connection established!"),
this.acceptClientConnection(b))},onConnectedToServer:function(){this.connected()||(Kongregate.Log.debug(this.logPrefix(),"API connection established!"),this._connected=!0)},acceptClientConnection:function(a){for(var b=!1,d=this._targetWindows,k=0;k<this._targetWindows.length;k++)if(this._targetWindows[k]===a){Kongregate.Log.warn("Re-initializing duplicate connection");b=!0;break}this._targetWindows=[a];this.sendMessage(KonduitEvent.CONNECTED,{});this._targetWindows=d;b||this._targetWindows.push(a);
this.removeMissingWindows()},removeMissingWindows:function(a){if(!this._client){for(i=this._targetWindows.length-1;0<=i;i--)this._targetWindows[i].top||this._targetWindows.splice(i,1);this._connected=0<this._targetWindows.length}}}})();
Kongregate.PostMessage={addMessageListener:function(a,c){if(a.document.addEventListener)try{a.document.addEventListener.call(a,"message",c,!1)}catch(b){Kongregate.Log.debug("addEventListener failed, using iframe addEventListener: "+b),Kongregate.PostMessage.createIframeEventListener(a,c)}else a.attachEvent?a.attachEvent("onmessage",c):Kongregate.Log.error("Could not add event listener, neither addEventListener or attachEvent found!");return c},removeMessageListener:function(a,c){a.removeEventListener?
a.removeEventListener("message",c):a.detachEvent&&a.detachEvent("onmessage",c)},supportsObjects:function(){var a=document.createElement("iframe"),c=!0;a.src="about:blank";document.body.appendChild(a);try{a.contentWindow.postMessage({toString:function(){c=!1;return""}},"*")}catch(b){}document.body.removeChild(a);return c},parseMessage:function(a){return"string"===typeof a&&"{"===a.charAt(0)?JSON.parse(a):"object"===typeof a?a:null},createIframeEventListener:function(a,c){var b=document.createElement("iframe");
b.src="about:blank";document.head.appendChild(b);b.contentWindow.addEventListener.call(a,"message",c,!1);document.head.removeChild(b)}};
(function(){Kongregate.Utils.merge=function(a,b){if(!a||!b)return a;for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);return a};Kongregate.Utils.toW3CDTF=function(a){function b(a){return 10>a?"0"+a:a}return!(a instanceof Date)?"":a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+(a.getUTCMilliseconds()/1E3).toFixed(3).slice(2,5)+"-00:00"};Kongregate.Utils.parseW3CDTF=function(c,b){var d;try{var k,l=0,h=[1,4,
5,6,7,10,11];if(k=a.exec(c)){for(var f=0,m;m=h[f];++f)k[m]=+k[m]||0;k[2]=(+k[2]||1)-1;k[3]=+k[3]||1;"Z"!==k[8]&&void 0!==k[9]&&(l=60*k[10]+k[11],"+"===k[9]&&(l=0-l));d=new Date(Date.UTC(k[1],k[2],k[3],k[4],k[5]+l,k[6],k[7]))}if(!d||"Invalid Date"===d.toString())throw Error("This date does not conform to W3CDTF.");}catch(n){return d="Unable to parse the string ["+c+"] into a date. "+("The internal error was: "+n.toString()),Kongregate.Log.error(d),b}return d};Kongregate.Utils.indexOf=function(a,b){if(!a)return-1;
if("function"===typeof a.indexOf)return a.indexOf(b);for(var d=0;d<a.length;d++)if(a[d]===b)return d;return-1};var a=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/})();
(function(){Kongregate.AnalyticsClient=function(a){this.initialize(a)};var a=Kongregate.AnalyticsClient,c=["auto_event","retry_count"];Kongregate.AnalyticsClient.prototype={initialize:function(a){this._type="kong";this._applicationId=a.application_id;this._apiKey=a.api_key;this._eventQueue=a.event_queue||[];this._url=a.url;this._requestHeaders=a.request_headers||{};this._submitting=!1},enqueueEvent:function(a){this._filterEvent(a)&&this._eventQueue.push(a)},sendEvents:function(a){var b=new XMLHttpRequest,
c=this._eventQueue,h=c.length,f=this;if(!this._submitting&&h){this._submitting=!0;var m=function(b){f._submitting=!1;f._onError(c,h,b,a)};Kongregate.Log.debug("Flushing "+this._type+" event queue");b.open("POST",this._url);b.setRequestHeader("Content-Type","application/json; charset=utf-8");for(var n in this._requestHeaders)this._requestHeaders.hasOwnProperty(n)&&b.setRequestHeader(n,this._requestHeaders[n]);b.onerror=b.onabort=m;b.onload=function(){f._submitting=!1;f._onBatchResponse(b,c,h,a,m)};
"undefined"!==typeof b.timeout&&(b.timeout=3E4,b.ontimeout=m);b.send(JSON.stringify(this._createPayload(c)))}},_filterEvent:function(a){return 0!==a.name.indexOf(b.SWRVE_EVENT_IDENTIFIER)},_validateResponse:function(a){return!0},_onBatchResponse:function(a,b,c,h,f){var m=!1,n=a.status||0;if(200===n||202===n)m=this._validateResponse(a.responseText);m?(Kongregate.Log.debug(this._type+" submission complete, "+c+" event(s)"),b.splice(0,c),h&&h({success:!0})):(a=500>n,Kongregate.Log.error("Error submitting "+
this._type+" httpStatus: "+n+", numEvents: "+c+", fatal: "+a),f(a))},_onError:function(a,b,c,h){for(var f=0;f<b&&f<a.length;f++){var m=a[f];if(m){var n=(m.event.retry_count||0)+(c?this._maxRetries()+1:1);m.event.retry_count=n}}this._pruneEvents(a);h&&h({success:!1})},_createPayload:function(a){for(var b=[],c={events:b},h=0;h<a.length;h++){var f=a[h],m=f.name,f=Kongregate.Utils.merge({},f.event);this._removeTransientProperties(f);b.push({event_type:m,payload:f})}return c},_pruneEvents:function(a){for(var b=
a.length-1;0<=b;b--)a[b].event&&a[b].event.retry_count>this._maxRetries()&&(Kongregate.Log.debug("Event "+a[b].name+" is over max retry count, deleting it"),a.splice(b,1));b=this._maxBacklogSize();a&&a.length>b&&a.splice(0,a.length-b)},_removeTransientProperties:function(a){for(var b=0;b<c.length;b++){var l=c[b];void 0!==a[l]&&delete a[l]}},_maxRetries:function(){return 2},_maxBacklogSize:function(){return 100},_getDate:function(){return new Date},_getTime:function(a){var b=this._getDate();a.event&&
a.event[Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME]&&(b=Kongregate.Utils.parseW3CDTF(a.event[Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME],this._getDate()));return Math.floor(b.getTime()/1E3)}};Kongregate.SwrveClient=function(a){this.initialize(a)};var b=Kongregate.SwrveClient;b.prototype=Kongregate.Utils.merge({},a.prototype);Kongregate.Utils.merge(b.prototype,{initialize:function(b){a.prototype.initialize.call(this,b);this._type="swrve";this._playerId=b.player_id;this._clientVersion=
b.client_version},_filterEvent:function(a){return!0},_validateResponse:function(a){var b=0===a.length;b||(b=200===JSON.parse(a).code);return b},_createPayload:function(a){for(var c=[],l={app_version:this._clientVersion,session_token:this._createSessionToken(),user:this._playerId,data:c},h=0;h<a.length;h++){var f=a[h],m=f.name,n=this._getTime(f),f=Kongregate.Utils.merge({},f.event);this._removeTransientProperties(f);b.SWRVE_SESSION_START_IDENTIFIER===m?c.push({type:"session_start",time:n}):b.SWRVE_USER_IDENTIFIER===
m?c.push({type:"user",time:n,attributes:f}):b.SWRVE_IAP_IDENTIFIER===m?c.push(Kongregate.Utils.merge({type:"iap",time:n},f)):0===m.indexOf(b.SWRVE_EVENT_IDENTIFIER)?(m=m.replace(b.SWRVE_EVENT_IDENTIFIER,"Kongregate."),c.push({type:"event",name:m,time:n,payload:f})):(m="Kongregate.RawData."+m,c.push({type:"event",name:m,time:n,payload:{data:JSON.stringify(f)}}))}return l},_createSessionToken:function(){var a=Math.floor(this._getDate().getTime()/1E3);return this._applicationId+"="+this._playerId+"="+
String(a)+"="+Kongregate.Utils.md5(this._playerId+String(a)+this._apiKey)}});b.SWRVE_EVENT_IDENTIFIER="swrve.";b.SWRVE_BARE_EVENT_IDENTIFIER=b.SWRVE_EVENT_IDENTIFIER+"__bare_";b.SWRVE_SESSION_START_IDENTIFIER=b.SWRVE_BARE_EVENT_IDENTIFIER+"session_start";b.SWRVE_USER_IDENTIFIER=b.SWRVE_BARE_EVENT_IDENTIFIER+"user";b.SWRVE_IAP_IDENTIFIER=b.SWRVE_BARE_EVENT_IDENTIFIER+"iap"})();
(function(){Kongregate.AnalyticsServices=function(a){this.initialize(a)};Kongregate.AnalyticsServices.prototype={initialize:function(a){var b=this;this._heartbeatInterval=a.heartbeat_interval||15E3;this._services=a.services;this._clients=a.clients||{};this._mtx=a.mtx;this._kongVars=a.kongregate_variables;this._staticVars={};this._persistentStore=a.persistent_store||{};this._heartbeatCount=0;this._enablePersistence=a.enable_persistence&&!a.persistent_store;this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE,
function(a){b._onIncomingMessage(a.opcode,a.params)});a.start&&this._setup()},addEvent:function(a,b){this._enabled&&(!this._autoAnalyticsDisabled()&&0<=Kongregate.Utils.indexOf(ga,a)?Kongregate.Log.warn("Ignoring analytics event: "+a+" since it is a kong-automatic event."):this._addEventInternal(a,this._objectify(b)))},addFilterType:function(a){if(this._enabled&&a){var b=/^[a-zA-Z0-9_]+$/;!a||!b.test(a)?Kongregate.Log.warn("Invalid filterType: "+a+", must be alpha_numeric"):(b=(b=this._savedData[B])?
b.split(","):[],0>Kongregate.Utils.indexOf(b,a)&&(b.push(a),b.sort(),this._savedData[B]=b.join(","),this._flushPersistentStore(),Kongregate.Log.info("Filter type added: "+a)))}},setCommonPropsCallback:function(a){this._enabled&&(this._commonPropsCallback=a,this.updateCommonProperties())},setCommonProperties:function(a){a=this._objectify(a);this.setCommonPropsCallback(function(){return a})},updateCommonProperties:function(){try{"function"===typeof this._commonPropsCallback&&(this._commonProperties=
this._objectify(this._commonPropsCallback()),this._savedData[ha]=this._commonProperties,this._commonProperties[P]&&!this._savedData[C]&&(this._savedData[C]=this._commonProperties[P]))}catch(a){Kongregate.Log.error("Error updating common properties: "+a)}},getAutoLongProperty:function(a){return this.getAutoIntProperty(a)},getAutoLongLongProperty:function(a){return this.getAutoLongProperty(a)},getAutoStringProperty:function(a){if(!this._enabled)return null;var b=this._getKongAutomaticVariables();if("string"===
typeof b[a])return b[a];Kongregate.Log.warn("Property is not a string: "+a);return null},getAutoBoolProperty:function(a){return!this._enabled?!1:!!this._getKongAutomaticVariables()[a]},getAutoDoubleProperty:function(a){if(!this._enabled)return NaN;var b=this._getKongAutomaticVariables();return Number(b[a])},getAutoIntProperty:function(a){return!this._enabled?NaN:Math.floor(this.getAutoDoubleProperty(a))},getAutoUTCProperty:function(a){return this.getAutoStringProperty(a)},getAutoPropertiesJSON:function(){if(!this._enabled)return"{}";
this._buildKongAutomaticVariables();return"function"===typeof JSON.stringify?JSON.stringify(this._automaticVars):"{}"},startPurchase:function(a,b){if(!this._autoAnalyticsDisabled()){var c=this._getProductId(a);c?(this._priceUSD=this._getUSDPrice(c,b),this._iapID&&Kongregate.Log.warn("startPurchase: invoked before active transaction finished. iap_ids may mismatch."),Kongregate.Log.debug("IAP FLOW STEP: startPurchase(): "+c),this._iapID=this._uuid(),this._productId=c,this._addIAPEvent(null,this._objectify(b),
D)):Kongregate.Log.warn("startPurchase: Can't start purchase with null productId, param was: "+a)}},finishPurchase:function(a,b,c){this._autoAnalyticsDisabled()||(Kongregate.Log.debug("IAP FLOW STEP: finishPurchase(): "+this._productId+", transactionId: "+b+", resultCode: "+a),ia===a?(this._numPurchases++,this._totalSpentUSD+=this._priceUSD,this._addIAPEvent(b,this._objectify(c),E)):this._addIAPFailEvent(b,this._objectify(c)))},setAutomaticVariablesListener:function(a){this._enabled&&(this._automaticVarsListener=
a,this._getKongAutomaticVariables())},start:function(){},_setup:function(){if(!this._savedData){var b=this._services.isKongregate();this._mode=b?this._kongVars.kongregate_analytics_mode:null;this._enabled=null!==this._mode&&void 0!==this._mode&&this._checkBrowserSupport();Kongregate.Log.debug("Initializing Analytics API, mode: "+this._mode);if(this._enabled){this._enablePersistence&&this._hasLocalStorage()&&this._loadPersistentStore();this._clientVersion=b?this._kongVars.kongregate_game_version:"1";
this._pendingEvents=this._persistentStore.pending_events=this._persistentStore.pending_events||[];this._eventQueues=this._persistentStore.event_queues=this._persistentStore.event_queues||{};this._eventQueues.swrve=this._eventQueues.swrve||[];this._eventQueues.kong=this._eventQueues.kong||[];this._savedData=this._persistentStore.saved_data=this._persistentStore.saved_data||{};this._items=this._persistentStore.items=this._persistentStore.items||[];this._commonProperties=this._savedData.common_properties=
this._savedData.common_properties||{};this._bundleId=this._savedData[h];this._autoAnalyticsDisabled()?Kongregate.Log.debug("Auto analytics disabled"):this._autoAnalyticsExcludesServer()?Kongregate.Log.debug("Game has a server, only tracking a subset of analytics automatically"):Kongregate.Log.debug("Automatic analytics enabled");b&&this._requestItems();var b=this._getDate(),c=!this._savedData[u];this._setInitialSavedData(u,this._toW3CDTF(b));this._setInitialSavedData(F,a);this._setInitialSavedData(G,
this._clientVersion);this._setInitialSavedData(v,this._timeZoneOffset());c&&(Kongregate.Log.debug("Analytics: First play"),this._installEvent());this._startSession();this._buildKongStaticVars()}else Kongregate.Log.debug("Analytics API not enabled")}},_enqueueEvent:function(a,b){if(!this._initialized){if(!this._autoAnalyticsDisabled()||!b[H])Kongregate.Log.debug("Queueing pending event: "+a),this._pendingEvents.push({name:a,event:b});return!0}return!1},_addEventInternal:function(a,b,c){var q=0===a.indexOf(Kongregate.SwrveClient.SWRVE_EVENT_IDENTIFIER);
!q&&!b[Q]&&(b=this._merge(this._buildEventSpecificVariables(),b));if(!this._enqueueEvent(a,b)&&this._enabled){R===a&&this._refreshPlayerInfoFields(b);var y=this._getKongAutomaticVariables(),e={};q?e=b:(this._merge(e,this._objectify(this._commonProperties)),b[H]?(this._merge(e,y),this._merge(e,b)):(this._merge(e,b),this._merge(e,y)));Kongregate.SwrveClient.SWRVE_SESSION_START_IDENTIFIER===a&&(c=!0);Kongregate.Log.debug("Adding event: "+a+", flush="+c);this._forEachClient(function(b){return b.enqueueEvent({name:a,
event:e})});this._flushQueue();c&&this._flushPersistentStore()}},_forEachClient:function(a){for(var b in this._clients)this._clients.hasOwnProperty(b)&&a(this._clients[b])},_flushQueue:function(){var a=this;this._forEachClient(function(b){b.sendEvents(function(b){a._flushPersistentStore();a._flushQueueDelayed(b.success?1E3:1E4)})})},_flushQueueDelayed:function(a){var b=this;setTimeout(function(){b._flushQueue()},a)},_persistentStoreName:function(){return Kongregate.AnalyticsServices.persistentStoreName(this._kongVars.kongregate_game_id)},
_loadPersistentStore:function(){var a;try{var b=localStorage.getItem(this._persistentStoreName())||"{}";a=JSON.parse(b)}catch(c){Kongregate.Log.warn("Error loading persistent store: "+c)}this._persistentStore=a||{}},_flushPersistentStore:function(){try{var a=JSON.stringify(this._persistentStore);localStorage.setItem(this._persistentStoreName(),a)}catch(b){Kongregate.Log.warn("Error flushing persistent store: "+b)}},_destroyPersistentStore:function(){localStorage.removeItem(this._persistentStoreName())},
_buildEventSpecificVariables:function(){var a={};a[Q]=0;if(this._autoAnalyticsDisabled())return a;a[q]=this._uuid();a[g]=this._toW3CDTF(this._getDate());a[ja]=this._timeZoneOffset();return a},_refreshPlayerInfoFields:function(a){a[I]=this._savedData[I];a[J]=this._savedData[J];for(var b=0;b<S.length;b++){var c=S[b];a[c]?this._savedData[c]=a[c]:a[c]=this._savedData[c]?this._savedData[c]:null}},_addAutoEvent:function(a,b){this._autoAnalyticsDisabled()||(b=this._objectify(b),b[H]=!0,this._addEventInternal(a,
b))},_addIAPEvent:function(a,b,c){var q={};this._merge(q,this._objectify(b));q[K]=this._priceUSD;q[ka]=this._productId;q[T]=this._iapID;D!=c&&(q[U]=a||V);this._services.isKongregate()?(q[L]=this._getKredPrice(this._productId),q[M]="KRED"):(q[L]=b[L]||this._priceUSD,q[M]=b[M]||"USD");E===c&&(this._sendSwrveIAPEvent(this._productId,this._priceUSD,b),this._productId=this._iapID=null,this._priceUSD=0);this._addEventInternal(c,q)},_addIAPFailEvent:function(a,b){var c={};this._merge(c,this._objectify(b));
c[la]="SKErrorPaymentCancelled";c[U]=a||V;c[T]=this._iapID;this._productId=this._iapID=null;this._priceUSD=0;this._addEventInternal(W,c)},_sendSwrveUserEvent:function(){if(!this._autoAnalyticsDisabled()){for(var a=this._getKongAutomaticVariables(),b={},c=0;c<X.length;c++){var q=X[c];b["kong."+q]=a[q]}this._addAutoEvent(Kongregate.SwrveClient.SWRVE_USER_IDENTIFIER,b)}},_sendSwrveIAPEvent:function(a,b,c){b={product_id:a,quantity:1,local_cost:b,local_currency:"USD",app_store:"unknown_store"};var q={};
q[a]={type:"item",amount:1};c.soft_currency_change&&(q.soft_currency_change={type:"currency",amount:c.soft_currency_change});c.hard_currency_change&&(q.hard_currency_change={type:"currency",amount:c.hard_currency_change});c.type&&(q[c.type]={type:"item",amount:1});b.rewards=q;this.addEvent(Kongregate.SwrveClient.SWRVE_IAP_IDENTIFIER,b)},_onIncomingMessage:function(a,b){a===KonduitEvent.OP_ANALYTICS_PAYLOAD&&this._processAnalyticsPayload(b.data.info,b.data.payload)},_setInitialSavedData:function(a,
b){this._savedData[a]||(this._savedData[a]=b)},_autoAnalyticsDisabled:function(){return!this._enabled||this._mode===b},_autoAnalyticsAllEnabled:function(){return this._enabled&&this._mode===d},_autoAnalyticsExcludesServer:function(){return this._enabled&&this._mode===k},_getProductId:function(a){try{if("string"===typeof a)return a;if(Number(parseFloat(a))==a)return a.toString();if("[object Array]"===Object.prototype.toString.call(a)){if(0<a.length)return this._getProductId(a[0])}else if("string"===
typeof a.identifier)return a.identifier}catch(b){Kongregate.Log.error("Error calculating product ID:",b)}Kongregate.Log.warn("Couldn't get product ID from: "+a+", type="+typeof a);return null},_getUSDPrice:function(a,b){if(this._services.isKongregate()){var c=this._getKredPrice(a);if(0!==c)return Math.floor(100*c*this._kredExchangeRate)/100}else if(b&&b[K])return b[K];if((c=a.match(/^.*t([0-9][0-9])_.*$/))&&2===c.length)if(c=parseInt(c[1],10),0<c&&c<=Y.length)return Y[c-1];Kongregate.Log.warn("Couldn't calculate USD price for identifier: "+
a);return 0},_getKredPrice:function(a){for(var b=0;b<this._items.length;b++){var c=this._items[b];if(a===c.identifier)return c.price}Kongregate.Log.warn("Couldn't get kred price for identifier: "+a);return 0},_requestItems:function(a){a=a||0;if(5<a)Kongregate.Log.error("Giving up on retrieving item list");else{var b=this;this._mtx.requestItemList(null,function(c){c.success?b._items=b._persistentStore.items=c.data:b._retryRequestItems(a+1)})}},_retryRequestItems:function(a){var b=this;Kongregate.Log.warn("Retrying item list request, retry #"+
a);setTimeout(function(){b.requestItems(a)},15E3*a)},_processAnalyticsPayload:function(a,b){Kongregate.Log.info("Analytics payload received");if(this._enabled)if(this._checkBrowserSupport(b)){this._config=a;var c=this._config.swrve,q=this._config.kong;this._svid=b.site_visitor_uid;b.kger&&(this._kredExchangeRate=b.kger);this._updateKongStaticVars(b);this._initialized||(this._initialized=!0,!this._clients.swrve&&(c&&c.application_id&&c.key)&&(Kongregate.Log.debug("Swrve initialized"),this._clients.swrve=
new Kongregate.SwrveClient({application_id:c.application_id,api_key:c.key,url:c.url,player_id:this._services.isKongregate()?this._svid:this._savedData[N],client_version:this._clientVersion,event_queue:this._eventQueues.swrve})),!this._clients.kong&&(q&&q.application_id&&q.key)&&(Kongregate.Log.debug("Kong analytics initialized"),this._clients.kong=new Kongregate.AnalyticsClient({application_id:q.application_id,api_key:q.key,url:q.url,event_queue:this._eventQueues.kong,request_headers:{"X-Api-Key":q.key}})),
!this._clients.swrve&&!this._clients.kong?(Kongregate.Log.debug("Analytics not initialized, no services configured"),this._enabled=!1):(this._submitLock=!1,this._startHeartbeatTimer(),this._flushPendingEvents(),this._sendSwrveUserEvent(),this.addEvent(R,{}),this._flushQueue()))}else this._enabled=!1},_checkBrowserSupport:function(a){try{if(a&&"safari"===a.browser.browser.toLowerCase())Kongregate.Log.warn("Analytics disabled on Safari");else{if(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest)return!0;
Kongregate.Log.warn("Analytics disabled due to lack of XHR/CORS support")}}catch(b){Kongregate.Log.warn("Error while checking browser support: "+b)}return!1},_hasLocalStorage:function(){try{var a="kong-"+this._getDate().getTime();localStorage.setItem(a,a);localStorage.removeItem(a);return!0}catch(b){return!1}},_startHeartbeatTimer:function(){if(this._heartbeatInterval){var a=this;setInterval(function(){a._onHeartbeatInterval()},this._heartbeatInterval)}},_onHeartbeatInterval:function(){this._heartbeatCount+=
1;this._session.active=this._getDate().getTime();4==this._heartbeatCount&&(this._heartbeatCount=0,this.addEvent(ma,{}))},_flushPendingEvents:function(){if(0<this._pendingEvents.length){Kongregate.Log.debug("Flushing "+this._pendingEvents.length+" pending event(s)");for(var a=0;a<this._pendingEvents.length;a++){var b=this._pendingEvents[a];this._addEventInternal(b.name,b.event,!1)}this._pendingEvents.length=0}},_buildKongStaticVars:function(){if(!this._autoAnalyticsDisabled()){var b=this._services.isKongregate();
this._staticVars[h]=this._bundleId;this._staticVars[Z]=this._services.getUsername();this._staticVars[na]=this._services.getUserId();this._staticVars[oa]=b?this._svid:"";this._staticVars[O]=this._session.id;this._staticVars[pa]=a;this._staticVars[z]=this._numSessions();this._staticVars[r]=this._clientVersion;this._staticVars[t]=this._clientVersion;this._staticVars[G]=this._savedData[G];this._staticVars[C]=this._savedData[C]||null;this._staticVars[qa]="kongregate_web";this._autoAnalyticsExcludesServer()||
(this._staticVars[N]=b?this._svid:this._savedData[N]);this._staticVars[y]="browser";this._staticVars[ra]=null;this._staticVars[u]=this._savedData[u];this._staticVars[F]=this._savedData[F];this._staticVars[v]=this._savedData[v];this._staticVars[sa]=this._kongVars.kongregate_language||(window.navigator.userLanguage||window.navigator.language).split("-")[0];this._staticVars[aa]=null;this._staticVars[ba]=null;this._staticVars[ta]=null;this._staticVars[ua]=null;this._staticVars[l]=!1;this._staticVars[A]=
"wifi";this._staticVars[n]=null;this._staticVars[va]=null;this._staticVars[wa]=null;this._staticVars[xa]=!0;this._staticVars[ya]="web"}},_buildKongAutomaticVariables:function(){if(this._autoAnalyticsDisabled())this._automaticVars={};else{var a={};a[B]=this._savedData[B]||"";a[za]=this._numPurchases;a[x]=this._daysRetained();this._autoAnalyticsExcludesServer()||(a[ca]=this._totalSpentUSD);this._automaticVars=this._merge(a,this._staticVars)}},_updateKongStaticVars:function(a){if(!this._autoAnalyticsDisabled()){this._bundleId=
"com.kongregate.web."+a.game_permalink;this._services.isExternal()&&(this._bundleId+=".external");this._savedData[h]=this._bundleId;this._buildKongStaticVars();var b=this._parseOS(a.browser.os);this._staticVars[p]=b.type;this._staticVars[s]=b.version;this._staticVars[Aa]=a.premium;this._staticVars[Ba]=a.powerup_rewards_tier;this._savedData[I]=a.pur_link_date||null;this._savedData[J]=a.join_date||null;this._staticVars[Ca]=Number(a.spent_on_kreds);this._totalSpentUSD=a.spent_usd;this._numPurchases=
a.num_purchases;this._staticVars[f]=a.browser.browser;this._staticVars[m]=a.browser.version;this._staticVars[Da]=a.ip_address;this._staticVars[e]=a.ip_address;b=this._getDate();b=Math.abs(b.getTime()-this._parseW3CDTF(a.server_time,b).getTime())/1E3;this._staticVars[Ea]=Math.floor(b);this._savedData[Fa]=a.server_time;this._staticVars[w]=a.country_code;this._getKongAutomaticVariables()}},_getKongAutomaticVariables:function(){if(!this._enabled)return{};this.updateCommonProperties();this._buildKongAutomaticVariables();
this._automaticVarsListener&&this._automaticVarsListener(this._automaticVars);return this._automaticVars},_startSession:function(){var a=this._getDate(),b=(this._previousSession=this._savedData.current_session)?(a.getTime()-this._previousSession.active)/1E3:0,q=this._previousSession?(a.getTime()-this._previousSession.start)/1E3:0;b>c?(Kongregate.Log.debug("Terminating previous session ("+this._previousSession.id+"), inactiveFor="+b+", length="+q),b={},b[O]=this._previousSession.id,b[z]=this._numSessions(),
b[Ga]=this._toW3CDTF(this._previousSession.active),b[Ha]=q,b[Ia]=!1,this._addAutoEvent(da,b)):this._previousSession&&(this._session=this._previousSession,Kongregate.Log.debug("Reopening previous session ("+this._previousSession.id+"), inactiveFor="+b+", length="+q));this._session||(this._session={id:this._uuid(),start:a.getTime(),active:a.getTime()},this._savedData.current_session=this._session,a=this._savedData[z]?this._numSessions()+1:1,this._savedData[z]=a,Kongregate.Log.debug("Created new session: "+
this._session.id));this._session!=this._previousSession&&(this.addEvent(Kongregate.SwrveClient.SWRVE_SESSION_START_IDENTIFIER,{}),a={},a[Ja]=!1,this._addAutoEvent(ea,a))},_installEvent:function(){if(this._autoAnalyticsAllEnabled()){var a={};a[Ka]=null;a[La]=null;a[Ma]=null;a[Na]=null;a[Oa]=null;a[Pa]=null;this._addAutoEvent(fa,a)}else Kongregate.Log.debug("Not firing installs event since analytics mode is not all")},_parseOS:function(a){var b="Unknown",c="Unknown";try{var q=a.split(" ");if(2>q.length)throw Error("Not enough segments in OS string");
b=q.shift();"OS"===b&&(b="MacOS",q.shift());c=q.join(" ")}catch(y){Kongregate.Log.error("Error parsing OS version ("+a+"): "+y.toString())}return{type:b,version:c}},_numSessions:function(){return this._savedData[z]||1},_timeZoneOffset:function(){return this._getDate().getTimezoneOffset()/-60},_daysRetained:function(){var a=this._getDate(),b=this._timeZoneOffset(),c=this._staticVars[u];c&&(a=this._parseW3CDTF(c,null),null===a&&(Kongregate.Log.warn("Failed to parse first play date: "+c+", resetting"),
a=this._getDate(),this._savedData[u]=this._toW3CDTF(a),this._flushPersistentStore()));this._staticVars[v]&&(b=this._staticVars[v]);return this._daysSince(a,b)},_dayOfEra:function(a,b){return Math.floor((a+3600*b)/86400)},_daysSince:function(a,b){var c=Math.floor(this._getDate()/1E3),q=Math.floor(a.getTime()/1E3);return this._dayOfEra(c,this._timeZoneOffset())-this._dayOfEra(q,b)},_objectify:function(a){if("string"===typeof a){if(0===a.length||"function"!==typeof JSON.parse)return{};try{return JSON.parse(a)||
{}}catch(b){return Kongregate.Log.warn("Failed to parse JSON: "+a+", error: "+b),{}}}return a},_toW3CDTF:function(a){return Kongregate.Utils.toW3CDTF(a)},_parseW3CDTF:function(a,b){return Kongregate.Utils.parseW3CDTF(a,b)},_uuid:function(){var a=this._getDate().getTime();window.performance&&"function"===typeof window.performance.now&&(a+=performance.now());return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var c=(a+16*Math.random())%16|0;a=Math.floor(a/16);return("x"==b?c:c&
3|8).toString(16)})},_merge:function(a,b){return Kongregate.Utils.merge(a,b)},_getDate:function(){return new Date}};var a="2.0.0",c=300,b="none",d="all",k="cloud",l="ad_tracking",h="bundle_id",f="browser",m="browser_version",n="carrier",p="client_os_type",s="client_os_version",r="client_version",w="country_code",A="data_connection_type",x="days_retained",t="dev_client_version",q="device_event_id",y="device_type",g="event_time",e="external_ip_address",B="filter_type",G="first_client_version",v="first_play_time_offset",
u="first_play_time",F="first_sdk_version",C="first_server_version",va="gamecenter_id",wa="gamecenter_alias",Ba="pur_tier",aa="idfa",ba="idfv",ua="imei",ta="android_id",Da="ip_address",xa="is_valid",na="kong_user_id",Z="kong_username",Aa="kong_plus",sa="lang_code",Fa="last_skew_refresh_time",za="num_purchases",z="num_sessions",ra="mac_address",N="player_id",pa="sdk_version",P="server_version",O="session_id",Ea="time_skew",ca="total_spent_in_usd",ja="event_time_offset",oa="site_visitor_id",Ca="usd_spent_on_kreds",
qa="platform",ya="pkg_src",Q="retry_count",H="auto_event",ea="session_starts",Ja="is_from_background",da="session_ends",Ha="session_length_seconds",Ga="session_end_time",Ia="did_crash",fa="installs",Ka="stub_field",La="utm_source",Ma="utm_medium",Na="utm_term",Oa="utm_content",Pa="utm_campaign",D="iap_attempts",E="iap_transactions",W="iap_fails",K="usd_cost",ka="product_id",T="iap_id",la="fail_reason",U="receipt_id",M="local_currency_type",L="local_currency_cost",ia="SUCCESS",V="none",R="player_info",
J="kong_join_date",I="pur_link_date",ga=[fa,ea,da,"foreground_visits","background_visits",D,W,E,"invalid_states"],S=["twitter_id","fb_user_id","fb_username","fb_email","email"],X=[ca,u,z,x,y,p,s,w,Z,O,aa,ba,r],ma="swrve.heartbeat",Y=[0.99,1.99,2.99,3.99,4.99,5.99,6.99,7.99,8.99,9.99,10.99,11.99,12.99,13.99,14.99,15.99,16.99,17.99,18.99,19.99,20.99,21.99,22.99,23.99,24.99,25.99,26.99,27.99,28.99,29.99,30.99,31.99,32.99,33.99,34.99,35.99,36.99,37.99,38.99,39.99,40.99,41.99,42.99,43.99,44.99,45.99,46.99,
47.99,48.99,49.99,54.99,59.99,64.99,69.99,74.99,79.99,84.99,89.99,94.99,99.99,109.99,119.99,124.99,129.99,139.99,149.99,159.99,169.99,174.99,179.99,189.99,199.99,209.99,219.99,229.99,239.99,249.99,299.99,349.99,399.99,449.99,499.99,599.99,699.99,799.99,899.99,999.99],ha="common_properties";Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME=g;Kongregate.AnalyticsServices.persistentStoreName=function(a){return"kong-game-analytics-"+a}})();Kongregate.ApiServices=function(a){this.initialize(a)};
Kongregate.ApiServices.prototype={initialize:function(a){this._kongVars=a.kongregate_variables||{};this._messageConnection=a.message_connection;this._eventListeners={};this._requestHandlers={};this._messageQueue=[];this._requestId=0;this._initializeKongVars(this._kongVars);this.initializeEventListeners()},initializeEventListeners:function(){var a=this;this._messageConnection.addMessageListener(function(c,b){a._onIncomingMessage(c,b)})},_initializeKongVars:function(a){a=a||{};this._kongregate="true"===
String(a.kongregate);this._username=a.kongregate_username||"Guest";this._authToken=a.kongregate_game_auth_token;this._userId=parseInt(a.kongregate_user_id,10)||0;this._gameId=parseInt(a.kongregate_game_id,10)||0},addEventListener:function(a,c){this._eventListeners[a]||(this._eventListeners[a]=[]);this._eventListeners[a].push(c)},_dispatchEvent:function(a,c){for(var b=this._eventListeners[a]||[],d=0;d<b.length;d++)b[d](c||{})},connect:function(){},connectExternal:function(){Kongregate.Log.warn("The Kongregate externally hosted API is not available")},
isExternal:function(){return!this.isKongregate()},isKongregate:function(){return this._kongregate},getUsername:function(){return this._username},getGameAuthToken:function(){return this._authToken},getUserId:function(){return this._userId},getUserID:function(){return this.getUserId()},getGameId:function(){return this._gameId},getGameID:function(){return this.getGameId()},isGuest:function(){return 0===this.getUserId()},isConnected:function(){return this._messageConnection.connected()&&!this._messageQueue},
sendMessage:function(a){this.isConnected()?this._messageConnection.sendMessage(a.opcode,a.params):(Kongregate.Log.debug("Queueing message "+a.opcode+" since API is not yet connected!"),this._messageQueue.push(a))},_flushMessageQueue:function(){if(this._messageQueue){var a=this._messageQueue;this._messageQueue=null;Kongregate.Log.debug("Flushing message queue",a);for(var c=0;c<a.length;c++)this.sendMessage(a[c])}},_onIncomingMessage:function(a,c){switch(a){case KonduitEvent.OP_CONNECTED:this.sendMessage({opcode:KonduitEvent.OP_HELLO,
params:{}});this._flushMessageQueue();break;case KonduitEvent.OP_EXTERNAL_MESSAGE:this._onIncomingMessage(c.opcode,c.data);break;case KonduitEvent.OP_SHOUT_CALLBACK:this._onShoutResponse(c);break;case KonduitEvent.OP_USER_INFO:this._onUserInfo(c)}this._dispatchEvent(KonduitEvent.KONDUIT_MESSAGE,{opcode:a,params:c})},_onShoutResponse:function(a){this._completeRequest(a,{type:a[KonduitEvent.PARAM_MESSAGE_TYPE],recipients:a[KonduitEvent.PARAM_MESSAGE_RECIPIENTS],success:a.success,error:a.error})},_onUserInfo:function(a){var c=
a[KonduitEvent.PARAM_USER_ID];if(0!==c){var b=this.isGuest();this._username=a[KonduitEvent.PARAM_USER];this._authToken=a[KonduitEvent.PARAM_GAME_AUTH_TOKEN];this._userId=c;b&&this._dispatchEvent(KonduitEvent.LOGIN)}},privateMessage:function(a,c){if(this._ensureKongregate(c)){var b={shout_message:("string"===typeof a?a:a.content)||""};this._enqueueRequest(b,c);this.sendMessage({opcode:KonduitEvent.OP_CHAT_PRIVATE_MESSAGE,params:b})}},resizeGame:function(a,c){if(this._ensureKongregate()){var b={};b[KonduitEvent.PARAM_RESIZE_GAME_WIDTH]=
a;b[KonduitEvent.PARAM_RESIZE_GAME_HEIGHT]=c;this.sendMessage({opcode:KonduitEvent.OP_CHAT_RESIZE_GAME,params:b})}},showInvitationBox:function(a,c){if(this._ensureKongregate()){var b={};a="string"===typeof a?{content:a}:a;b[KonduitEvent.PARAM_INVITATION_MESSAGE]=a.content||"";b[KonduitEvent.PARAM_FRIEND_FILTER]=a.filter||"";b[KonduitEvent.PARAM_KV_PARAMS]=a.kv_params||{};this._enqueueRequest(b,c);this.sendMessage({opcode:KonduitEvent.OP_CHAT_DISPLAY_INVITATION_BOX,params:b})}},showFeedPostBox:function(a,
c){if(this._ensureKongregate()){var b={};a="string"===typeof a?{content:a}:a;b[KonduitEvent.PARAM_SHOUT_MESSAGE]=a.content||"";b[KonduitEvent.PARAM_KV_PARAMS]=a.kv_params||{};a.image_uri&&(b[KonduitEvent.PARAM_IMAGE_URI]=a.image_uri);this._enqueueRequest(b,c);this.sendMessage({opcode:KonduitEvent.OP_CHAT_DISPLAY_FEED_POST_BOX,params:b})}},showSignInBox:function(){this.showRegistrationBox()},showRegistrationBox:function(){this._ensureKongregate()&&this.isGuest()&&this.sendMessage({opcode:KonduitEvent.OP_CHAT_DISPLAY_REGISTRATION,
params:{}})},showShoutBox:function(a,c){if(this._ensureKongregate()){var b={};b[KonduitEvent.PARAM_SHOUT_MESSAGE]=("string"===typeof a?a:a.content)||"";this._enqueueRequest(b,c);this.sendMessage({opcode:KonduitEvent.OP_CHAT_DISPLAY_SHOUT_BOX,params:b})}},_ensureKongregate:function(a){return!this.isKongregate()?(a&&a({success:!1}),!1):!0},_enqueueRequest:function(a,c){var b=this._nextRequestId();a[KonduitEvent.PARAM_REQUEST_ID]=b;"function"===typeof c&&(this._requestHandlers[b]=c)},_completeRequest:function(a,
c){var b=a[KonduitEvent.PARAM_REQUEST_ID],d=this._requestHandlers[b];"function"===typeof d&&(d(c||a),delete this._requestHandlers[b])},_nextRequestId:function(){return this._requestId+=1}};Kongregate.ChatServices=function(a){this.initialize(a)};Kongregate.ChatServices.DEFAULT_TAB="Default";
Kongregate.ChatServices.prototype={initialize:function(a){var c=this;this._services=a.services;this._eventCallbacks=[];this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE,function(a){c._onIncomingMessage(a.opcode,a.params)})},showTab:function(a,c,b){var d={};d[KonduitEvent.PARAM_NAME]=a;d[KonduitEvent.PARAM_DESCRIPTION]=c;b&&b.size&&(d[KonduitEvent.PARAM_CANVAS_SIZE]=b.size);this._services.sendMessage({opcode:KonduitEvent.OP_CHAT_TAB,params:d})},closeTab:function(){this.showTab(Kongregate.ChatServices.DEFAULT_TAB)},
displayMessage:function(a,c){var b={};b[KonduitEvent.PARAM_DATA]=a;b[KonduitEvent.PARAM_USER]=c;this._services.sendMessage({opcode:KonduitEvent.OP_CHAT_DISPLAY,params:b})},clearMessages:function(){this._services.sendMessage({opcode:KonduitEvent.OP_CHAT_CLEAR_DIALOG})},displayCanvasImage:function(a,c,b){var d={};d[KonduitEvent.PARAM_DATA]={type:"image",name:a,url:c,position:b};this._services.sendMessage({opcode:KonduitEvent.OP_CHAT_CANVAS_ELEMENT,params:d})},displayCanvasText:function(a,c,b,d){var k=
{};k[KonduitEvent.PARAM_DATA]={type:"text",name:a,text:c,position:b,options:d};this._services.sendMessage({opcode:KonduitEvent.OP_CHAT_CANVAS_ELEMENT,params:k})},drawCanvasObject:function(a,c){var b={};b[KonduitEvent.PARAM_DATA]={type:"draw",name:a,commands:c};this._services.sendMessage({opcode:KonduitEvent.OP_CHAT_CANVAS_ELEMENT,params:b})},removeCanvasObject:function(a){var c={};c[KonduitEvent.PARAM_DATA]={type:"remove",name:a};this._services.sendMessage({opcode:KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
params:c})},_onIncomingMessage:function(a,c){switch(a){case KonduitEvent.OP_CHAT_MSG:this._handleChatEvent("message",c);break;case KonduitEvent.OP_CHAT_ROOM_MESSAGE:this._handleChatEvent("room.message",c);break;case KonduitEvent.OP_CHAT_TAB:this._handleChatEvent("tab_visible",c)}},addEventListener:function(a,c){"function"!==typeof c?Kongregate.Log.error("addEventListener requires a callback function"):(this._eventCallbacks[a]||(this._eventCallbacks[a]=[]),this._eventCallbacks[a].push(c))},_handleChatEvent:function(a,
c){var b=this._eventCallbacks[a];if(b)for(var d=0;d<b.length;d++)b[d](c)}};Kongregate.ImageServices=function(a){this.initialize(a)};
Kongregate.ImageServices.prototype={initialize:function(a){var c=this;this._services=a.services;this._submitting=!1;this._callback=null;this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE,function(a){c._onIncomingMessage(a.opcode,a.params)})},submitAvatar:function(a,c){this._submitting?(Kongregate.Log.warn("Another avatar submission is active, ignoring"),c&&c({success:!1})):(this._submitting=!0,this._callback=c,this._services.sendMessage({opcode:KonduitEvent.OP_IMAGE_AVATAR_SUBMIT,params:{image:a}}))},
_onIncomingMessage:function(a,c){KonduitEvent.OP_IMAGE_AVATAR_FINISHED===a&&(this._submitting=!1,this._callback&&this._callback(c.success))}};function KongregateAPI(){this._initialize()}
KongregateAPI.prototype={unityElementId:null,_initialize:function(){this._flashVarsString="";this._flashVarsObject={};this._services={};this._postMessageParams=void 0;this._loaded=this._paramsReceived=!1;this._klient=Kongregate.Utils.isKlient();this._queuedMessages=[];this._loadCallbacks=[];this._processParentKongregateParams();this._processParams(location.search.split("?")[1]);this._updateDebugLevel();this._kongWindow=Kongregate.Utils.findKongregateWindow();if(this._postMessageParams=!this.flashVarsObject().kongregate_username&&
top!=window){var a=this;Kongregate.polyfillJSON();Kongregate.PostMessage.addMessageListener(window,function(c){a._messageOriginIsKongregate(c)&&(c=Kongregate.PostMessage.parseMessage(c.data))&&"params"===c.type&&a._handleParamsMessage(c.data)});this._kongWindow.postMessage("kongregate_request_params","*")}else this._paramsReceived=!0;setTimeout(this._hijackUnityErrorHandler,0)},flashVarsString:function(){return this._flashVarsString},flashVarsObject:function(){return this._flashVarsObject},getVariable:function(a){return this._flashVarsObject[a]},
loadAPI:function(a){!this._postMessageParams||this._paramsReceived?this._doLoadAPI(a):this._loadCallbacks.push(a)},getAPI:function(){return this._services},embedFrame:function(a,c){try{console.warn("KONGREGATE WARNING: The Kongregate Shell and embedFrame method are deprecated, and it is very unlikely that this functionality is really needed. See the note on the documentation page: https://docs.kongregate.com/v1.0/docs/concepts-kongregate-shell")}catch(b){}var d=document.getElementById(c?c:"contentdiv"),
k;k="<iframe id='content' frameborder='0' style='position:relative;top:0px;left:0px;"+("border:0px none;padding:0px;width:"+d.offsetWidth+"px;height:"+d.offsetHeight+"px;'");k+="src='"+a+"'></iframe>";d.innerHTML=k},_forwardToKlient:function(a,c){this._klient&&top.postMessage({type:"kongregate:api-message:"+c,message:a},"*")},_setGameSwf:function(a){var c=this.flashVarsObject(),b=this,d=this._findSwf(a);d?(this._gameSwf=d,this.messageConnection=this.messageConnection||this._createMessageConnection(c),
this.messageConnection.isSupported()?setTimeout(function(){b._gameSwf.setConnectionObject("kongregateAPI.messageConnection")?b.messageConnection.connect():Kongregate.Log.warn("setConnectionObject returned false, not connecting")},1):(Kongregate.Log.debug("MessageConnection isSupported was false"),setTimeout(function(){b._gameSwf.setConnectionObject(null)},1))):Kongregate.Log.debug("Kongregate game SWF element does not appear to be a swf: "+a)},_isSwf:function(a){return a&&"undefined"!==typeof a.Play&&
"undefined"!==typeof a.setConnectionObject},_findSwf:function(a){var c=document.getElementById(a),b=this,d=function(a){for(var d=0;d<a.length;d++)if(c=a[d],b._isSwf(c))return c};return this._isSwf(c)?c:c=d(document.getElementsByName(a))||d(document.querySelectorAll("[id='"+a+"']"))||d(document.getElementsByTagName("object"))||d(document.getElementsByTagName("embed"))},_updateDebugLevel:function(){Kongregate.Log.debugLevel=this._flashVarsObject.kongregate_debug_level||2},_processParentKongregateParams:function(a){try{for(var c=
window.parent;c!==top;){try{c.kongregateAPI&&this._processParams(c.kongregateAPI.flashVarsString())}catch(b){}c=c.parent}}catch(d){}},_handleParamsMessage:function(a){if(!this._paramsReceived){for(var c in a)this._processParam(c,a[c]);this._paramsReceived=!0;this._updateDebugLevel();this._hijackUnityErrorHandler();0<this._loadCallbacks.length&&this._doLoadAPI()}},_fireLoadCallbacks:function(){var a=this._loadCallbacks.length;Kongregate.Log.debug("Kongregate API: Firing "+a+" load callback(s)");for(var c=
0;c<a;c++){var b=this._loadCallbacks[c];"function"===typeof b&&setTimeout(b,0)}this._loadCallbacks=[]},_checkAlreadyLoaded:function(){this._loaded&&this._fireLoadCallbacks();return this._loaded},_doLoadAPI:function(a){var c=this;Kongregate.contentLoaded(function(){c._loadCallbacks.push(a);c._checkAlreadyLoaded()||(c._loaded=!0,Kongregate.polyfillJSON(),c._hijackUnityErrorHandler(),c.messageConnection=c._createMessageConnection(),c._createJavascriptApi(),c._fireLoadCallbacks())})},_processParams:function(a){if(a){a=
a.split("&");for(var c=0;c<a.length;c++){var b=a[c].split("=");b&&2==b.length&&this._processParam(b[0],b[1])}}},_processParam:function(a,c){0===a.indexOf("kongregate")&&(this._flashVarsObject[a]=c,this._flashVarsString+=a+"="+c+"&")},_messageOriginIsKongregate:function(a){var c=decodeURIComponent(this._flashVarsObject.kongregate_host||"");a=a.origin;return c&&(a===c||a=="http://"+c||a=="https://"+c)},_createJavascriptApi:function(){var a=this;this._services.services=new Kongregate.ApiServices({kongregate_variables:this.flashVarsObject(),
message_connection:this.messageConnection});this._services.stats=new Kongregate.StatisticServices({services:this._services.services});this._services.sharedContent=new Kongregate.SharedContentServices({services:this._services.services});this._services.images=new Kongregate.ImageServices({services:this._services.services});this._services.mtx=new Kongregate.MicrotransactionServices({services:this._services.services});this._services.chat=new Kongregate.ChatServices({services:this._services.services});
this._services.analytics=new Kongregate.AnalyticsServices({services:this._services.services,mtx:this._services.mtx,kongregate_variables:this.flashVarsObject(),enable_persistence:!0,start:!0});setTimeout(function(){a.messageConnection.connect()},0)},_createMessageConnection:function(){var a=this,c=this.flashVarsObject(),c={target_window:this._kongWindow,target_origin:decodeURIComponent(c.kongregate_host),channel_id:c.kongregate_channel_id,retry_connection:!0};this._klient&&(c.send_listener=function(b,
c){a._forwardToKlient({opcode:b,params:c},"out")});c=new Kongregate.MessageConnection(c);c.isSupported()&&c.addMessageListener(function(b,c){var k=a._gameSwf,l={opcode:b,params:c};k&&"function"===typeof k.handleMessageConnectionEvent&&k.handleMessageConnectionEvent(JSON.stringify(l))});return c},_hijackUnityErrorHandler:function(){try{kongregateUnitySupport.hijackUnityErrorHandler()}catch(a){}}};kongregateAPI=new KongregateAPI;
!function(a){function c(a){for(var b=16;b--;){var c=b<<2;m[b]=a.charCodeAt(c)+(a.charCodeAt(c+1)<<8)+(a.charCodeAt(c+2)<<16)+(a.charCodeAt(c+3)<<24)}}function b(a,b,c,e,d,f,h){b+=a+e+h;return(b<<d|b>>>f)+c<<0}function d(a){l(0,0,0,0,a);r[0]=t[0]+1732584193<<0;r[1]=t[1]-271733879<<0;r[2]=t[2]-1732584194<<0;r[3]=t[3]+271733878<<0}function k(a){l(r[0],r[1],r[2],r[3],a);r[0]=t[0]+r[0]<<0;r[1]=t[1]+r[1]<<0;r[2]=t[2]+r[2]<<0;r[3]=t[3]+r[3]<<0}function l(a,c,g,e,d){var f;w?(a=b((g^e)&c^e,a,c,d[0],7,25,-680876936),
e=b((c^g)&a^g,e,a,d[1],12,20,-389564586),g=b((a^c)&e^c,g,e,d[2],17,15,606105819),c=b((e^a)&g^a,c,g,d[3],22,10,-1044525330)):(a=d[0]-680876937,a=(a<<7|a>>>25)-271733879<<0,e=d[1]-117830708+(2004318071&a^-1732584194),e=(e<<12|e>>>20)+a<<0,g=d[2]-1126478375+((a^-271733879)&e^-271733879),g=(g<<17|g>>>15)+e<<0,c=d[3]-1316259209+((e^a)&g^a),c=(c<<22|c>>>10)+g<<0);a=b((g^e)&c^e,a,c,d[4],7,25,-176418897);e=b((c^g)&a^g,e,a,d[5],12,20,1200080426);g=b((a^c)&e^c,g,e,d[6],17,15,-1473231341);c=b((e^a)&g^a,c,g,
d[7],22,10,-45705983);a=b((g^e)&c^e,a,c,d[8],7,25,1770035416);e=b((c^g)&a^g,e,a,d[9],12,20,-1958414417);g=b((a^c)&e^c,g,e,d[10],17,15,-42063);c=b((e^a)&g^a,c,g,d[11],22,10,-1990404162);a=b((g^e)&c^e,a,c,d[12],7,25,1804603682);e=b((c^g)&a^g,e,a,d[13],12,20,-40341101);g=b((a^c)&e^c,g,e,d[14],17,15,-1502002290);c=b((e^a)&g^a,c,g,d[15],22,10,1236535329);a=b((c^g)&e^g,a,c,d[1],5,27,-165796510);e=b((a^c)&g^c,e,a,d[6],9,23,-1069501632);g=b((e^a)&c^a,g,e,d[11],14,18,643717713);c=b((g^e)&a^e,c,g,d[0],20,12,
-373897302);a=b((c^g)&e^g,a,c,d[5],5,27,-701558691);e=b((a^c)&g^c,e,a,d[10],9,23,38016083);g=b((e^a)&c^a,g,e,d[15],14,18,-660478335);c=b((g^e)&a^e,c,g,d[4],20,12,-405537848);a=b((c^g)&e^g,a,c,d[9],5,27,568446438);e=b((a^c)&g^c,e,a,d[14],9,23,-1019803690);g=b((e^a)&c^a,g,e,d[3],14,18,-187363961);c=b((g^e)&a^e,c,g,d[8],20,12,1163531501);a=b((c^g)&e^g,a,c,d[13],5,27,-1444681467);e=b((a^c)&g^c,e,a,d[2],9,23,-51403784);g=b((e^a)&c^a,g,e,d[7],14,18,1735328473);c=b((g^e)&a^e,c,g,d[12],20,12,-1926607734);
f=c^g;a=b(f^e,a,c,d[5],4,28,-378558);e=b(f^a,e,a,d[8],11,21,-2022574463);f=e^a;g=b(f^c,g,e,d[11],16,16,1839030562);c=b(f^g,c,g,d[14],23,9,-35309556);f=c^g;a=b(f^e,a,c,d[1],4,28,-1530992060);e=b(f^a,e,a,d[4],11,21,1272893353);f=e^a;g=b(f^c,g,e,d[7],16,16,-155497632);c=b(f^g,c,g,d[10],23,9,-1094730640);f=c^g;a=b(f^e,a,c,d[13],4,28,681279174);e=b(f^a,e,a,d[0],11,21,-358537222);f=e^a;g=b(f^c,g,e,d[3],16,16,-722521979);c=b(f^g,c,g,d[6],23,9,76029189);f=c^g;a=b(f^e,a,c,d[9],4,28,-640364487);e=b(f^a,e,a,
d[12],11,21,-421815835);f=e^a;g=b(f^c,g,e,d[15],16,16,530742520);c=b(f^g,c,g,d[2],23,9,-995338651);a=b(g^(c|~e),a,c,d[0],6,26,-198630844);e=b(c^(a|~g),e,a,d[7],10,22,1126891415);g=b(a^(e|~c),g,e,d[14],15,17,-1416354905);c=b(e^(g|~a),c,g,d[5],21,11,-57434055);a=b(g^(c|~e),a,c,d[12],6,26,1700485571);e=b(c^(a|~g),e,a,d[3],10,22,-1894986606);g=b(a^(e|~c),g,e,d[10],15,17,-1051523);c=b(e^(g|~a),c,g,d[1],21,11,-2054922799);a=b(g^(c|~e),a,c,d[8],6,26,1873313359);e=b(c^(a|~g),e,a,d[15],10,22,-30611744);g=
b(a^(e|~c),g,e,d[6],15,17,-1560198380);c=b(e^(g|~a),c,g,d[13],21,11,1309151649);a=b(g^(c|~e),a,c,d[4],6,26,-145523070);e=b(c^(a|~g),e,a,d[11],10,22,-1120210379);g=b(a^(e|~c),g,e,d[2],15,17,718787259);c=b(e^(g|~a),c,g,d[9],21,11,-343485551);t[0]=a;t[1]=c;t[2]=g;t[3]=e}var h=[],f=[],m=[],n=[],p="0123456789abcdef".split(""),s=[],r=[],w=!1,A=0,x=0,t=[];if(a.Int32Array)f=new Int32Array(16),m=new Int32Array(16),n=new Int32Array(4),s=new Int32Array(4),r=new Int32Array(4),t=new Int32Array(4);else{for(a=0;16>
a;a++)f[a]=m[a]=0;for(a=0;4>a;a++)n[a]=s[a]=r[a]=t[a]=0}n[0]=128;n[1]=32768;n[2]=8388608;n[3]=-2147483648;s[0]=0;s[1]=8;s[2]=16;s[3]=24;Kongregate.Utils.md5=function(a,b,g){if(!b){for(var e=b="",l=0,t=0,v=0,u=a.length;v<u;v++)e=a.charCodeAt(v),128>e?t++:(e=2048>e?String.fromCharCode(e>>6|192,e&63|128):String.fromCharCode(e>>12|224,e>>6&63|128,e&63|128),t>l&&(b+=a.slice(l,t)),b+=e,l=t=v+1);t>l&&(b+=a.slice(l,u));a=b}a+="";w=!1;A=x=a.length;if(63<x){c(a.substring(0,64));d(m);w=!0;for(b=128;b<=x;b+=
64)c(a.substring(b-64,b)),k(m);a=a.substring(b-64);x=a.length}for(b=f[0]=f[1]=f[2]=f[3]=f[4]=f[5]=f[6]=f[7]=f[8]=f[9]=f[10]=f[11]=f[12]=f[13]=f[14]=f[15]=0;b<x;b++)l=b&3,f[b>>2]=0===l?a.charCodeAt(b):f[b>>2]|a.charCodeAt(b)<<s[l];f[b>>2]|=n[b&3];55<b?(w?k(f):(d(f),w=!0),k([0,0,0,0,0,0,0,0,0,0,0,0,0,0,A<<3,0])):(f[14]=A<<3,w?k(f):d(f));a=r[0];h[1]=p[a&15];h[0]=p[(a>>=4)&15];h[3]=p[(a>>=4)&15];h[2]=p[(a>>=4)&15];h[5]=p[(a>>=4)&15];h[4]=p[(a>>=4)&15];h[7]=p[(a>>=4)&15];h[6]=p[a>>4&15];a=r[1];h[9]=p[a&
15];h[8]=p[(a>>=4)&15];h[11]=p[(a>>=4)&15];h[10]=p[(a>>=4)&15];h[13]=p[(a>>=4)&15];h[12]=p[(a>>=4)&15];h[15]=p[(a>>=4)&15];h[14]=p[a>>4&15];a=r[2];h[17]=p[a&15];h[16]=p[(a>>=4)&15];h[19]=p[(a>>=4)&15];h[18]=p[(a>>=4)&15];h[21]=p[(a>>=4)&15];h[20]=p[(a>>=4)&15];h[23]=p[(a>>=4)&15];h[22]=p[a>>4&15];a=r[3];h[25]=p[a&15];h[24]=p[(a>>=4)&15];h[27]=p[(a>>=4)&15];h[26]=p[(a>>=4)&15];h[29]=p[(a>>=4)&15];h[28]=p[(a>>=4)&15];h[31]=p[(a>>=4)&15];h[30]=p[a>>4&15];return g?h:h.join("")}}("undefined"===typeof global?
window:global);Kongregate.MicrotransactionServices=function(a){this.initialize(a)};
Kongregate.MicrotransactionServices.prototype={initialize:function(a){var c=this;this._services=a.services;this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE,function(a){c._onIncomingMessage(a.opcode,a.params)});this._adCallbacks=[]},requestItemList:function(a,c){Kongregate.Log.info("MicrotransactionServices.requestItemList("+a+")");var b={};a&&0<a.length&&(b[KonduitEvent.PARAM_ITEM_TAGS]=a);this._services._enqueueRequest(b,c);this._services.sendMessage({opcode:KonduitEvent.ITEM_LIST,params:b})},
requestUserItemList:function(a,c){Kongregate.Log.info("MicrotransactionServices.requestUserItemList("+a+")");var b={};b[KonduitEvent.PARAM_USER]=a||this._services.getUsername();this._services._enqueueRequest(b,c);this._services.sendMessage({opcode:KonduitEvent.ITEM_INSTANCES,params:b})},purchaseItems:function(a,c){Kongregate.Log.info("MicrotransactionServices.purchaseItems("+a+")");var b={};a&&0<a.length?(this._purchaseItemsCallback=c,b[KonduitEvent.PARAM_ITEMS]=a,this._services.sendMessage({opcode:KonduitEvent.ITEM_CHECKOUT,
params:b})):(Kongregate.Log.error("purchaseItems requires a non-empty item identifier array"),c&&c({success:!1}))},purchaseItemsRemote:function(a,c){Kongregate.Log.info("MicrotransactionServices.purchaseItemsRemote("+a+")");var b={};a&&0<String(a).length?(this._purchaseItemsCallback=c,b[KonduitEvent.PARAM_ORDER_INFO]=String(a),this._services.sendMessage({opcode:KonduitEvent.ITEM_CHECKOUT,params:b})):(Kongregate.Log.error("purchaseItemsRemote requires an orderInformation string"),c&&c({success:!1}))},
useItemInstance:function(a,c){Kongregate.Log.info("MicrotransactionServices.useItemInstance("+a+")");var b={};a?(b[KonduitEvent.PARAM_ID]=a,this._services._enqueueRequest(b,c),this._services.sendMessage({opcode:KonduitEvent.USE_ITEM_INSTANCE,params:b})):(Kongregate.Log.error("useItemInstance requires an itemInstanceId"),c&&c({success:!1}))},showKredPurchaseDialog:function(a){var c={};c[KonduitEvent.PARAM_PURCHASE_METHOD]=a;this._services.sendMessage({opcode:KonduitEvent.PURCHASE_KREDS,params:c})},
initializeIncentivizedAds:function(){this._services.sendMessage({opcode:KonduitEvent.ADS_INITIALIZE})},showIncentivizedAd:function(){this._services.sendMessage({opcode:KonduitEvent.ADS_SHOW_INCENTIVIZED})},addEventListener:function(a,c){"function"!==typeof c?Kongregate.Log.error("addEventListener requires a callback function"):(this._adCallbacks[a]||(this._adCallbacks[a]=[]),this._adCallbacks[a].push(c))},_onIncomingMessage:function(a,c){switch(a){case KonduitEvent.ITEM_INSTANCES:case KonduitEvent.ITEM_LIST:case KonduitEvent.USE_ITEM_INSTANCE:this._services._completeRequest(c);
break;case KonduitEvent.PURCHASE_RESULT:this._onPurchaseResultResponse(c);break;case KonduitEvent.ADS_AVAILABLE:this._handleAdEvent("adsAvailable",c);break;case KonduitEvent.ADS_UNAVAILABLE:this._handleAdEvent("adsUnavailable",c);break;case KonduitEvent.AD_OPENED:this._handleAdEvent("adOpened",c);break;case KonduitEvent.AD_COMPLETED:this._handleAdEvent("adCompleted",c);break;case KonduitEvent.AD_ABANDONED:this._handleAdEvent("adAbandoned",c)}},_onPurchaseResultResponse:function(a){this._purchaseItemsCallback&&
(this._purchaseItemsCallback(a),this._purchaseItemsCallback=null)},_handleAdEvent:function(a,c){var b=this._adCallbacks[a];if(b)for(var d=0;d<b.length;d++)b[d](c)}};Kongregate.SharedContentServices=function(a){this.initialize(a)};Kongregate.SharedContentServices.CONTENT_TYPE_LIMIT=12;
Kongregate.SharedContentServices.prototype={initialize:function(a){var c=this;this._services=a.services;this._loadListeners={};this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE,function(a){c._onIncomingMessage(a.opcode,a.params)})},browse:function(a,c,b){var d={};d[KonduitEvent.PARAM_CONTENT_TYPE]=a;b&&(d[KonduitEvent.PARAM_LABEL]=b);c&&(d[KonduitEvent.PARAM_SORT]=c);this._services.sendMessage({opcode:KonduitEvent.OP_BROWSE_SHARED_CONTENT,params:d})},save:function(a,c,b,d,k){if(this._saving||
a.length>Kongregate.SharedContentServices.CONTENT_TYPE_LIMIT)b&&b({success:!1});else{var l={};l[KonduitEvent.PARAM_CONTENT_TYPE]=a;l[KonduitEvent.PARAM_LABEL]=k;l[KonduitEvent.PARAM_DATA]=c;l[KonduitEvent.PARAM_IMAGE]=d;this._services.sendMessage({opcode:KonduitEvent.OP_SAVE_SHARED_CONTENT,params:l});this._saving=!0;this._saveCallback=b}},addLoadListener:function(a,c){this._loadListeners[a]||(this._loadListeners[a]=[]);this._loadListeners[a].push(c)},_onIncomingMessage:function(a,c){switch(a){case KonduitEvent.OP_SHARED_CONTENT_SAVE_COMPLETE:this._onSaveContentComplete(c);
break;case KonduitEvent.OP_LOAD_SHARED_CONTENT:this._onLoadSharedContent(c)}},_onSaveContentComplete:function(a){this._saving=!1;this._saveCallback&&(this._saveCallback({id:a[KonduitEvent.PARAM_ID],success:a[KonduitEvent.PARAM_SUCCESS],name:a[KonduitEvent.PARAM_NAME],permalink:a[KonduitEvent.PARAM_PERMALINK],content:a[KonduitEvent.PARAM_DATA],label:a[KonduitEvent.PARAM_LABEL]}),this._saveCallback=null)},_onLoadSharedContent:function(a){var c=a[KonduitEvent.PARAM_CONTENT_TYPE];a={id:a[KonduitEvent.PARAM_ID],
name:a[KonduitEvent.PARAM_NAME],permalink:a[KonduitEvent.PARAM_PERMALINK],content:a[KonduitEvent.PARAM_DATA],label:a[KonduitEvent.PARAM_LABEL]};Kongregate.Log.info({loadContent:a});for(var c=this._loadListeners[c]||[],b=0;b<c.length;b++)c[b](a)}};Kongregate.StatisticServices=function(a){this.initialize(a)};
Kongregate.StatisticServices.prototype={initialize:function(a){this._services=a.services},submit:function(a,c){Kongregate.Log.info("StatServices.submit("+a+","+c+")");!a||null===c||void 0===c||isNaN(c)?Kongregate.Log.warn("Invalid stat name or value:",a,c):this._services.sendMessage({opcode:KonduitEvent.OP_STATS_SUBMIT,params:{stats:[{name:a,value:c}]}})},submitArray:function(a){if(a&&a.length)for(var c=0;c<a.length;c++)this.submit(a[c].name,a[c].value)}};
"undefined"==typeof kongregateUnitySupport&&(kongregateUnitySupport=function(){function a(a){a=h.getElementById(a);if(!a)return null;var b;s.win&&s.ie?(a=a.getElementsByTagName("object")[0])&&"OBJECT"==a.nodeName&&(b=a):(a=a.getElementsByTagName("embed")[0])&&"EMBED"==a.nodeName&&(b=a);return b&&typeof b.GetPluginVersion==k?null:b}function c(){var b=typeof kongregateAPI!=k&&kongregateAPI.unityGameInstance?kongregateAPI.unityGameInstance:"function"===typeof window.SendMessage?window:window.gameInstance&&
"function"===typeof window.gameInstance.SendMessage?window.gameInstance:null;if(b)return b;b="kongregateUnityDiv";typeof kongregateAPI!=k&&kongregateAPI.unityElementId&&(b=kongregateAPI.unityElementId);return a(b)||a("unityPlayer")}function b(){return[kongregate.services.getUserId(),kongregate.services.getUsername(),kongregate.services.getGameAuthToken()].join("|")}var d=[],k="undefined",l=navigator,h=document,f=l.userAgent,l=l.platform,m=!1,n=/chrome/i.test(f),p={};/msie/i.test(f)?m=parseFloat(f.replace(/^.*msie ([0-9]+(\.[0-9]+)?).*$/i,
"$1")):/Trident/i.test(f)&&(m=parseFloat(f.replace(/^.*rv:([0-9]+(\.[0-9]+)?).*$/i,"$1")));var s={w3:typeof h.getElementById!=k&&typeof h.getElementsByTagName!=k&&typeof h.createElement!=k,win:l?/win/i.test(l):/win/i.test(f),mac:l?/mac/i.test(l):/mac/i.test(f),ie:m,ff:/firefox/i.test(f),op:/opera/i.test(f),ch:n,ch_v:/chrome/i.test(f)?parseFloat(f.replace(/^.*chrome\/(\d+(\.\d+)?).*$/i,"$1")):!1,sf:/safari/i.test(f)&&!n,wk:/webkit/i.test(f)?parseFloat(f.replace(/^.*webkit\/(\d+(\.\d+)?).*$/i,"$1")):
!1,x64:/win64/i.test(f)&&/x64/i.test(f),moz:/mozilla/i.test(f)?parseFloat(f.replace(/^.*mozilla\/([0-9]+(\.[0-9]+)?).*$/i,"$1")):0,mobile:/ipad/i.test(l)||/iphone/i.test(l)||/ipod/i.test(l)||/android/i.test(f)||/windows phone/i.test(f)};s.clientBrand=s.ch?"ch":s.ff?"ff":s.sf?"sf":s.ie?"ie":s.op?"op":"??";s.clientPlatform=s.win?"win":s.mac?"mac":"???";return{onUnityEmbed:function(a){$("unity_missing")&&(a.success?"missingUnityObject"==a.id?($("missingUnityObject").update(""),$("kongregateUnityDiv").update(""),
top.location.replace(decodeURIComponent(kongregateAPI.getVariable("kongregate_game_url")))):$("unity_missing").remove():$("unity_missing").show())},initAPI:function(a,f){d.push({object:a||"KongregateAPI",callback:f||"OnKongregateAPILoaded"});kongregateAPI.loadAPI(function(){"undefined"===typeof kongregate&&(kongregate=kongregateAPI.getAPI());for(var a=0;a<d.length;a++){var f=d[a];c().SendMessage(f.object,f.callback,b())}d=[]})},getUnityObject:function(){return c()},getUserInfoString:function(){return b()},
hijackUnityErrorHandler:function(){if(!kongregateAPI.disableUnityErrorHandler&&!this.unityErrorHandlerInstalled){var a=function(a){if(a.match(/Permission denied to access property/)){try{console.error("Caught error: "+a)}catch(b){}return!0}try{var c;b:{if("string"===typeof a){if(-1!==a.indexOf("Cannot enlarge memory arrays")){c="UnityWebGL:Memory:WebGL";break b}if(-1!==a.indexOf("out of memory")){c="UnityWebGL:Memory:Browser";break b}}c=void 0}if(c&&!p[c]){var d=decodeURIComponent(kongregateAPI.flashVarsObject().kongregate_host||
"*");p[c]=!0;top.postMessage({kongregateGameError:{type:c}},d)}}catch(e){}};if("undefined"!==typeof UnityLoader&&UnityLoader.Error&&UnityLoader.Error.handler){var b=UnityLoader.Error.handler;UnityLoader.Error.handler=function(c){return a(c.message)?!0:"function"===typeof b&&b.apply(UnityLoader.Error,arguments)};this.unityErrorHandlerInstalled=!0}var c=window.Module;if(c&&c.TOTAL_MEMORY&&c.codeUrl){var d=c.errorhandler;c.errorhandler=function(b,c,f){return a(b)?!0:"function"===typeof d&&d(b,c,f)};
this.unityErrorHandlerInstalled=!0}}}}}());
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/deng-guangyuan/MiniTES.git
[email protected]:deng-guangyuan/MiniTES.git
deng-guangyuan
MiniTES
MiniTES
master

搜索帮助