Advertisement
Guest User

Onshape 3dconnexion javascript client

a guest
Mar 6th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * @license 3DconnexionJS
  3.  *
  4.  * Copyright (c) 2013-2016 3Dconnexion. All rights reserved.
  5.  * License:
  6.  *   This file is licensed under the terms of the "3Dconnexion
  7.  *   Software Development Kit" license agreement:
  8.  *   http://www.3dconnexion.com/service/software-developer/licence-agreement.html
  9.  *   All rights not expressly granted by 3Dconnexion are reserved.
  10.  *
  11.  * $Revision: 13777 $
  12.  */
  13. var _3Dconnexion = function(n) {
  14.         "use strict";
  15.         this.version = "0.4.0";
  16.         this.client = n;
  17.         this.session = null;
  18.         this.defport = 8181;
  19.         this.connected = !1;
  20.         this.connexion = null;
  21.         this._3dcontroller = null;
  22.         this.viewport = null;
  23.         this.host = "127.51.68.120";
  24.         this.nlRpcUri = null;
  25.         this.nlResourceUri = null;
  26.         this._EVENT_TYPEID_RPC = 0;
  27.         this.V3DK_FIT = 31;
  28.         this.V3DK_MENU = 30;
  29.         this.fnUpdate = {
  30.             motion: this.onMotion.bind(this),
  31.             "events.keyPress": this.onKeyPress.bind(this),
  32.             "events.keyRelease": this.onKeyRelease.bind(this)
  33.         };
  34.         this.clientFnRead = {
  35.             "view.affine": n.getViewMatrix,
  36.             "view.constructionPlane": n.getConstructionPlane,
  37.             "view.extents": n.getViewExtents,
  38.             "view.fov": n.getFov,
  39.             "view.frustum": n.getViewFrustum,
  40.             "view.perspective": n.getPerspective,
  41.             "view.target": n.getViewTarget,
  42.             "view.rotatable": n.getViewRotatable,
  43.             "model.extents": n.getModelExtents,
  44.             "pivot.position": n.getPivotPosition,
  45.             "hit.lookat": n.getLookAt,
  46.             "selection.empty": n.getSelectionEmpty,
  47.             "selection.extents": n.getSelectionExtents,
  48.             "pointer.position": n.getPointerPosition,
  49.             coordinateSystem: n.getCoordinateSystem,
  50.             "views.front": n.getFrontView
  51.         };
  52.         this.clientFnUpdate = {
  53.             motion: n.putMoving,
  54.             "view.affine": n.putViewMatrix,
  55.             "view.extents": n.putViewExtents,
  56.             "view.fov": n.putFov,
  57.             "view.target": n.putTarget,
  58.             "commands.activeCommand": n.putActiveCommand,
  59.             "pivot.position": n.putPivotPosition,
  60.             "pivot.visible": n.putPivotVisible,
  61.             "hit.lookfrom": n.putLookFrom,
  62.             "hit.direction": n.putLookDirection,
  63.             "hit.aperture": n.putLookAperture,
  64.             "hit.selectionOnly": n.putSelectionOnly,
  65.             "events.keyPress": n.putKeyPress,
  66.             "events.keyRelease": n.putKeyRelease
  67.         };
  68.         this.debug = !1;
  69.         window.hasOwnProperty("_3DCONNEXION_DEBUG") && (this.debug = window._3DCONNEXION_DEBUG)
  70.     },
  71.     CryptoJS, AUTOBAHNJS_VERSION, global;
  72. _3Dconnexion.prototype.connect = function() {
  73.     "use strict";
  74.     var n = this,
  75.         e = this.client,
  76.         u = 1,
  77.         t = new XMLHttpRequest,
  78.         f, r, i;
  79.     if (!e.onConnect) throw "onConnect handler required!";
  80.     i = "https://" + n.host + ":" + n.defport + "/3dconnexion/nlproxy";
  81.     t.onreadystatechange = function() {
  82.         if (t.readyState === 4 && t.status === 200) {
  83.             n.debug && console.log(t.responseText);
  84.             n.nlRpcUri = "wss://" + n.host + "/3dconnexion#";
  85.             n.nlResourceUri = "wss://" + n.host + "/3dconnexion";
  86.             try {
  87.                 f = JSON.parse(t.responseText).port;
  88.                 r = "wss://" + n.host + ":" + f;
  89.                 n.debug && console.log("Connecting to " + r + " ...");
  90.                 window.hasOwnProperty("AUTOBAHN_DEBUG") && window.AUTOBAHN_DEBUG && window.ab.debug(!0, !0, !0);
  91.                 window.ab.connect(r, function(t) {
  92.                     n.session = t;
  93.                     n.connected = !0;
  94.                     n.debug && console.log("Connected!");
  95.                     t.prefix("3dx_rpc", n.nlRpcUri);
  96.                     t.prefix("3dconnexion", n.nlResourceUri);
  97.                     t.prefix("self", window.location.href);
  98.                     n.client.onConnect()
  99.                 }, function(t, i) {
  100.                     if (n.client.onDisconnect !== undefined) n.client.onDisconnect(i);
  101.                     n.delete3dmouse();
  102.                     n.connected = !1;
  103.                     n.session = null;
  104.                     n.debug && console.log("Socket closed!", i)
  105.                 }, {
  106.                     maxRetries: 3,
  107.                     retryDelay: 500
  108.                 })
  109.             } catch (i) {
  110.                 console.error(i)
  111.             }
  112.         }
  113.     };
  114.     t.onerror = function() {
  115.         n.debug && console.log("_3Dconnexion.connect: No response from local 3dmouse server " + i)
  116.     };
  117.     t.ontimeout = function() {
  118.         n.debug && console.log("_3Dconnexion.connect: Timeout querying local 3dmouse server " + i)
  119.     };
  120.     try {
  121.         t.open("GET", i, !0);
  122.         t.setRequestHeader("Accept", "application/json; charset=utf-8");
  123.         t.msCaching = "disabled";
  124.         t.timeout = 0;
  125.         t.send()
  126.     } catch (o) {
  127.         u = 0;
  128.         console.error(o.toString())
  129.     }
  130.     return u
  131. };
  132. _3Dconnexion.prototype.create3dmouse = function(n, t) {
  133.     "use strict";
  134.     var i = this;
  135.     i.viewport = n;
  136.     i.debug && console.log("create3dmouse " + i.viewport.id);
  137.     $(i.viewport).on("focus", i.focus.bind(i));
  138.     $(i.viewport).on("blur", i.blur.bind(i));
  139.     i.session.call("3dx_rpc:create", "3dconnexion:3dmouse", i.version).then(function(n) {
  140.         i.connexion = n.connexion;
  141.         var r = {
  142.             version: 0,
  143.             name: t
  144.         };
  145.         i.session.call("3dx_rpc:create", "3dconnexion:3dcontroller", i.connexion, r).then(function(n) {
  146.             i._3dcontroller = n.instance;
  147.             i.session.subscribe("3dconnexion:3dcontroller/" + i._3dcontroller, i.onEvent.bind(i));
  148.             document.hasFocus() && (document.activeElement === document.body || document.activeElement === null ? (i.viewport.focus(), window === i.viewport && i.focus()) : (document.activeElement === i.viewport || $(i.viewport).find(document.activeElement).length > 0) && (i.focus(), i.debug && console.log("self.viewport has focus")));
  149.             i.client.on3dmouseCreated && i.client.on3dmouseCreated()
  150.         }, function(n) {
  151.             console.log("3dx_rpc:create 3dconnexion:3dcontroller " + n)
  152.         })
  153.     }, function(n) {
  154.         console.log("3dx_rpc:create " + n)
  155.     })
  156. };
  157. _3Dconnexion.prototype.blur = function() {
  158.     "use strict";
  159.     var n = this;
  160.     n.debug && console.log("blur on ");
  161.     n.session && n._3dcontroller && n.update3dcontroller({
  162.         focus: !1
  163.     })
  164. };
  165. _3Dconnexion.prototype.focus = function() {
  166.     "use strict";
  167.     var n = this;
  168.     n.debug && console.log("focus on ");
  169.     n.session && n._3dcontroller && n.update3dcontroller({
  170.         focus: !0
  171.     })
  172. };
  173. _3Dconnexion.prototype.onKeyPress = function(n) {
  174.     "use strict";
  175.     var t = this;
  176.     t.debug && console.log("onKeyPress " + n)
  177. };
  178. _3Dconnexion.prototype.onKeyRelease = function(n) {
  179.     "use strict";
  180.     var t = this;
  181.     t.debug && console.log("onKeyRelease " + n)
  182. };
  183. _3Dconnexion.prototype.onMotion = function(n) {
  184.     "use strict";
  185.     var t = this;
  186.     n === !0 ? t.client.onStartMotion !== undefined && t.client.onStartMotion() : t.client.onStopMotion !== undefined && t.client.onStopMotion()
  187. };
  188. _3Dconnexion.prototype.onEvent = function(n, t) {
  189.     "use strict";
  190.     var i = this,
  191.         f = null,
  192.         r = null,
  193.         u = null;
  194.     if (i.debug && (console.log(n), console.log(t)), t[0] === window.ab._MESSAGE_TYPEID_CALL) {
  195.         if (t[2] === "self:read")
  196.             if (r = i.clientFnRead[t[4]], r !== undefined) f = r.bind(i.client)();
  197.             else {
  198.                 u = [window.ab._MESSAGE_TYPEID_CALL_ERROR, t[1], t[2] + "#generic", t[4] + " unknown property"];
  199.                 i.session._send(u);
  200.                 return
  201.             }
  202.         else if (t[2] === "self:update")
  203.             if (r = i.fnUpdate[t[4]], r !== undefined) f = r(t[5]);
  204.             else if (r = i.clientFnUpdate[t[4]], r !== undefined) f = r.bind(i.client)(t[5]);
  205.         else {
  206.             u = [window.ab._MESSAGE_TYPEID_CALL_ERROR, t[1], t[2] + "#generic", t[4] + " unknown property"];
  207.             i.session._send(u);
  208.             return
  209.         } else {
  210.             u = [window.ab._MESSAGE_TYPEID_CALL_ERROR, t[1], t[2] + "#generic", "unknown procedure"];
  211.             i.session._send(u);
  212.             return
  213.         }
  214.         u = [window.ab._MESSAGE_TYPEID_CALL_RESULT, t[1], f];
  215.         i.session._send(u)
  216.     }
  217. };
  218. _3Dconnexion.prototype.read3dcontroller = function(n, t) {
  219.     "use strict";
  220.     var i = this;
  221.     i.debug && console.log("read3dcontroller " + i._3dcontroller);
  222.     try {
  223.         i.session.call("3dx_rpc:read", "3dconnexion:3dcontroller/" + i._3dcontroller, n).then(function(n) {
  224.             t && t(n)
  225.         }, function(t) {
  226.             console.log("3dx_rpc:read 3dconnexion:3dcontroller/" + i._3dcontroller + " " + n + " " + t)
  227.         })
  228.     } catch (r) {
  229.         console.error(r)
  230.     }
  231. };
  232. _3Dconnexion.prototype.update3dcontroller = function(n) {
  233.     "use strict";
  234.     var t = this;
  235.     t.debug && console.log("update3dmouse " + t._3dcontroller);
  236.     try {
  237.         if (!t._3dcontroller) throw "exception 3dx_rpc:update: 3dcontroller not initialized";
  238.         t.session.call("3dx_rpc:update", "3dconnexion:3dcontroller/" + t._3dcontroller, n).then(function() {
  239.             return
  240.         }, function(n) {
  241.             console.log("3dx_rpc:update 3dconnexion:3dcontroller/" + t._3dcontroller + " " + n)
  242.         })
  243.     } catch (i) {
  244.         console.error(i)
  245.     }
  246. };
  247. _3Dconnexion.prototype.delete3dmouse = function() {
  248.     "use strict";
  249.     var n = this,
  250.         t = n.connexion;
  251.     n.debug && console.log("delete3dmouse ");
  252.     n.connexion = null;
  253.     n._3dcontroller = null;
  254.     n.viewport !== null && ($(n.viewport).off("focus"), $(n.viewport).off("blur"));
  255.     n.session && n.session.call("3dx_rpc:delete", "3dconnexion:3dmouse/" + t).then(function() {
  256.         n.debug && console.log("deleted connexion " + t)
  257.     }, function(n) {
  258.         console.log("3dx_rpc:delete " + t + " " + n)
  259.     })
  260. };
  261. Object.freeze(_3Dconnexion.SiActionNodeType_t = {
  262.     SI_ACTIONSET_NODE: 0,
  263.     SI_CATEGORY_NODE: 1,
  264.     SI_ACTION_NODE: 2
  265. });
  266. _3Dconnexion.ActionNode = function(n, t, i) {
  267.     return this.id = n, this.label = t || n, this.type = i, this
  268. };
  269. _3Dconnexion.ActionNode.prototype = {
  270.     constructor: _3Dconnexion.ActionNode,
  271.     id: {
  272.         value: null,
  273.         enumerable: !0
  274.     },
  275.     label: {
  276.         value: null,
  277.         writable: !0,
  278.         enumerable: !0
  279.     },
  280.     type: {
  281.         value: null,
  282.         enumerable: !0
  283.     }
  284. };
  285. _3Dconnexion.Action = function(n, t, i) {
  286.     return _3Dconnexion.ActionNode.call(this, n, t, _3Dconnexion.SiActionNodeType_t.SI_ACTION_NODE), this.description = i || "", this
  287. };
  288. _3Dconnexion.Action.prototype = Object.create(_3Dconnexion.ActionNode.prototype, {
  289.     constructor: {
  290.         value: _3Dconnexion.Action
  291.     },
  292.     description: {
  293.         value: "",
  294.         writable: !0,
  295.         enumerable: !0
  296.     }
  297. });
  298. _3Dconnexion.ActionTreeNode = function() {
  299.     return this.nodes = [], this
  300. };
  301. _3Dconnexion.ActionTreeNode.prototype = Object.create(_3Dconnexion.ActionNode.prototype, {
  302.     constructor: {
  303.         value: _3Dconnexion.ActionTreeNode
  304.     },
  305.     nodes: {
  306.         value: null,
  307.         writable: !0,
  308.         enumerable: !0
  309.     },
  310.     push: {
  311.         value: function(n) {
  312.             return this.nodes.push(n), n
  313.         }
  314.     }
  315. });
  316. _3Dconnexion.ActionSet = function(n, t) {
  317.     return _3Dconnexion.ActionNode.call(this, n, t, _3Dconnexion.SiActionNodeType_t.SI_ACTIONSET_NODE), _3Dconnexion.ActionTreeNode.call(this), this
  318. };
  319. _3Dconnexion.ActionSet.prototype = Object.create(_3Dconnexion.ActionTreeNode.prototype, {
  320.     constructor: {
  321.         value: _3Dconnexion.ActionSet
  322.     }
  323. });
  324. _3Dconnexion.Category = function(n, t) {
  325.     return _3Dconnexion.ActionNode.call(this, n, t, _3Dconnexion.SiActionNodeType_t.SI_CATEGORY_NODE), _3Dconnexion.ActionTreeNode.call(this), this
  326. };
  327. _3Dconnexion.Category.prototype = Object.create(_3Dconnexion.ActionTreeNode.prototype, {
  328.     constructor: {
  329.         value: _3Dconnexion.Category
  330.     }
  331. });
  332. _3Dconnexion.ActionTree = function() {
  333.     return this.nodes = [], this
  334. };
  335. _3Dconnexion.ActionTree.prototype = Object.create(null, {
  336.     constructor: {
  337.         value: _3Dconnexion.ActionTree
  338.     },
  339.     nodes: {
  340.         value: null,
  341.         writable: !0,
  342.         enumerable: !0
  343.     },
  344.     push: {
  345.         value: function(n) {
  346.             return this.nodes.push(n), n
  347.         }
  348.     }
  349. });
  350. _3Dconnexion.ImageItem = function() {};
  351. Object.freeze(_3Dconnexion.SiImageType_t = {
  352.     e_none: 0,
  353.     e_image_file: 1,
  354.     e_resource_file: 2,
  355.     e_image: 3
  356. });
  357. _3Dconnexion.ImageItem.prototype = {
  358.     constructor: _3Dconnexion.ImageItem,
  359.     id: {
  360.         value: "",
  361.         writable: !0
  362.     },
  363.     type: {
  364.         value: "e_none",
  365.         enumerable: !0
  366.     }
  367. };
  368. _3Dconnexion.ImageItem.fromImage = function(n, t) {
  369.     var i = new _3Dconnexion.ImageItem;
  370.     return Object.defineProperties(i, {
  371.         id: {
  372.             value: t || "",
  373.             writable: !0,
  374.             enumerable: !0
  375.         },
  376.         type: {
  377.             value: _3Dconnexion.SiImageType_t.e_image,
  378.             enumerable: !0
  379.         },
  380.         index: {
  381.             value: 0,
  382.             writable: !0,
  383.             enumerable: !0
  384.         },
  385.         data: {
  386.             value: _3Dconnexion.ImageItem.base64FromArrayBuffer(n),
  387.             enumerable: !0
  388.         },
  389.         status: {
  390.             value: 200
  391.         }
  392.     })
  393. };
  394. _3Dconnexion.ImageItem.fromURL = function(n, t) {
  395.     var r = new _3Dconnexion.ImageItem,
  396.         i;
  397.     return Object.defineProperties(r, {
  398.         id: {
  399.             value: t || "",
  400.             writable: !0,
  401.             enumerable: !0
  402.         },
  403.         type: {
  404.             value: _3Dconnexion.SiImageType_t.e_image,
  405.             enumerable: !0
  406.         },
  407.         index: {
  408.             value: 0,
  409.             writable: !0,
  410.             enumerable: !0
  411.         },
  412.         buffer: {
  413.             value: null,
  414.             writable: !0
  415.         },
  416.         data: {
  417.             get: function() {
  418.                 return this.buffer
  419.             },
  420.             set: function(n) {
  421.                 r.buffer = n;
  422.                 r.onload()
  423.             },
  424.             enumerable: !0
  425.         },
  426.         status: {
  427.             value: 100,
  428.             writable: !0
  429.         },
  430.         onload: {
  431.             value: function() {},
  432.             writable: !0
  433.         }
  434.     }), i = new XMLHttpRequest, i.overrideMimeType("text/plain; charset=x-user-defined"), i.open("GET", n, !0), i.responseType = "arraybuffer", i.onload = function() {
  435.         if (r.status = i.status, i.status === 200 && i.response !== null) {
  436.             r.data = _3Dconnexion.ImageItem.base64FromArrayBuffer(i.response);
  437.             return
  438.         }
  439.         r.status = 404;
  440.         r.data = null
  441.     }, i.onerror = function() {
  442.         r.status = i.status;
  443.         r.data = null
  444.     }, i.send(null), r
  445. };
  446. _3Dconnexion.ImageItem.base64FromArrayBuffer = function(n) {
  447.     for (var u = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", t = new Uint8Array(n), e = t.length % 3, f = t.length - e, i = "", r = 0; r < f; r += 3) i += u[t[r] >> 2], i += u[(t[r] & 3) << 4 | t[r + 1] >> 4], i += u[(t[r + 1] & 15) << 2 | t[r + 2] >> 6], i += u[t[r + 2] & 63];
  448.     return e !== 0 && (i += u[t[f] >> 2], e === 2 ? (i += u[(t[f] & 3) << 4 | t[f + 1] >> 4], i += u[(t[f + 1] & 15) << 2], i += "=") : (i += u[(t[f] & 3) << 4], i += "==")), i
  449. };
  450. _3Dconnexion.ImageCache = function() {
  451.     this.images = [];
  452.     this.outstanding_requests = 0
  453. };
  454. _3Dconnexion.ImageCache.prototype = {
  455.     constructor: _3Dconnexion.ImageCache,
  456.     images: {
  457.         value: null,
  458.         writable: !0,
  459.         enumerable: !0
  460.     },
  461.     outstanding_requests: {
  462.         value: 0,
  463.         writable: !0
  464.     },
  465.     push: function(n) {
  466.         var t = this;
  467.         if (n.status === 100) ++t.outstanding_requests, n.onload = function() {
  468.             var n = this,
  469.                 i;
  470.             n.onload = function() {};
  471.             n.status !== 200 && (i = t.images.indexOf(n), i > -1 && t.images.splice(i, 1));
  472.             --t.outstanding_requests;
  473.             t.outstanding_requests === 0 && t.onload()
  474.         }.bind(n);
  475.         else if (n.data === null) return;
  476.         t.images.push(n)
  477.     },
  478.     onload: function() {}
  479. };
  480. /** @license AutobahnJS - http://autobahn.ws
  481.  *
  482.  * Copyright (C) 2011-2014 Tavendo GmbH.
  483.  * Licensed under the MIT License.
  484.  * See license text at http://www.opensource.org/licenses/mit-license.php
  485.  *
  486.  * AutobahnJS includes code from:
  487.  *
  488.  * when - http://cujojs.com
  489.  *
  490.  * (c) copyright B Cavalier & J Hann
  491.  * Licensed under the MIT License at:
  492.  * http://www.opensource.org/licenses/mit-license.php
  493.  *
  494.  * Crypto-JS - http://code.google.com/p/crypto-js/
  495.  *
  496.  * (c) 2009-2012 by Jeff Mott. All rights reserved.
  497.  * Licensed under the New BSD License at:
  498.  * http://code.google.com/p/crypto-js/wiki/License
  499.  *
  500.  * console-normalizer - https://github.com/Zenovations/console-normalizer
  501.  *
  502.  * (c) 2012 by Zenovations.
  503.  * Licensed under the MIT License at:
  504.  * http://www.opensource.org/licenses/mit-license.php
  505.  *
  506.  */
  507. window.define || (window.define = function(n) {
  508.         try {
  509.             delete window.define
  510.         } catch (t) {
  511.             window.define = void 0
  512.         }
  513.         window.when = n()
  514.     }, window.define.amd = {}),
  515.     function(n) {
  516.         n || (n = window.console = {
  517.             log: function() {},
  518.             info: function() {},
  519.             warn: function() {},
  520.             error: function() {}
  521.         });
  522.         Function.prototype.bind || (Function.prototype.bind = function(n) {
  523.             var t = this,
  524.                 i = Array.prototype.slice.call(arguments, 1);
  525.             return function() {
  526.                 return t.apply(n, Array.prototype.concat.apply(i, arguments))
  527.             }
  528.         });
  529.         typeof n.log == "object" && (n.log = Function.prototype.call.bind(n.log, n), n.info = Function.prototype.call.bind(n.info, n), n.warn = Function.prototype.call.bind(n.warn, n), n.error = Function.prototype.call.bind(n.error, n));
  530.         "group" in n || (n.group = function(t) {
  531.             n.info("\n--- " + t + " ---\n")
  532.         });
  533.         "groupEnd" in n || (n.groupEnd = function() {
  534.             n.log("\n")
  535.         });
  536.         "time" in n || function() {
  537.             var t = {};
  538.             n.time = function(n) {
  539.                 t[n] = (new Date).getTime()
  540.             };
  541.             n.timeEnd = function(i) {
  542.                 var r = (new Date).getTime(),
  543.                     u = i in t ? r - t[i] : 0;
  544.                 n.info(i + ": " + u + "ms")
  545.             }
  546.         }()
  547.     }(window.console);
  548. /** @license MIT License (c) copyright 2011-2013 original author or authors */
  549. (function(n) {
  550.     "use strict";
  551.     n(function(n) {
  552.         function t(n, t, i, r) {
  553.             return at(n).then(t, i, r)
  554.         }
  555.  
  556.         function e(n) {
  557.             return new f(n, h.PromiseStatus && h.PromiseStatus())
  558.         }
  559.  
  560.         function f(n, t) {
  561.             function c() {
  562.                 return f ? f.inspect() : ii()
  563.             }
  564.  
  565.             function l(n, t, r, u, e) {
  566.                 function o(i) {
  567.                     i._when(n, t, r, u, e)
  568.                 }
  569.                 i ? i.push(o) : y(function() {
  570.                     o(f)
  571.                 })
  572.             }
  573.  
  574.             function o(n) {
  575.                 if (i) {
  576.                     var r = i;
  577.                     i = u;
  578.                     y(function() {
  579.                         f = pt(e, n);
  580.                         t && bt(f, t);
  581.                         w(r, f)
  582.                     })
  583.                 }
  584.             }
  585.  
  586.             function s(n) {
  587.                 o(new r(n))
  588.             }
  589.  
  590.             function a(n) {
  591.                 if (i) {
  592.                     var t = i;
  593.                     y(function() {
  594.                         w(t, new b(n))
  595.                     })
  596.                 }
  597.             }
  598.             var e, f, i = [];
  599.             e = this;
  600.             this._status = t;
  601.             this.inspect = c;
  602.             this._when = l;
  603.             try {
  604.                 n(o, s, a)
  605.             } catch (h) {
  606.                 s(h)
  607.             }
  608.         }
  609.  
  610.         function at(n) {
  611.             return n instanceof f ? n : o(n)
  612.         }
  613.  
  614.         function o(n) {
  615.             return e(function(t) {
  616.                 t(n)
  617.             })
  618.         }
  619.  
  620.         function vt(n) {
  621.             return t(n, function(n) {
  622.                 return new r(n)
  623.             })
  624.         }
  625.  
  626.         function yt() {
  627.             function f(u, f, e) {
  628.                 n.resolve = n.resolver.resolve = function(n) {
  629.                     return t ? o(n) : (t = !0, u(n), i)
  630.                 };
  631.                 n.reject = n.resolver.reject = function(n) {
  632.                     return t ? o(new r(n)) : (t = !0, f(n), i)
  633.                 };
  634.                 n.notify = n.resolver.notify = function(n) {
  635.                     return e(n), n
  636.                 }
  637.             }
  638.             var n, i, t;
  639.             return n = {
  640.                 promise: u,
  641.                 resolve: u,
  642.                 reject: u,
  643.                 notify: u,
  644.                 resolver: {
  645.                     resolve: u,
  646.                     reject: u,
  647.                     notify: u
  648.                 }
  649.             }, n.promise = i = e(f), n
  650.         }
  651.  
  652.         function w(n, t) {
  653.             for (var i = 0; i < n.length; i++) n[i](t)
  654.         }
  655.  
  656.         function pt(n, t) {
  657.             if (t === n) return new r(new TypeError);
  658.             if (t instanceof f) return t;
  659.             try {
  660.                 var i = t === Object(t) && t.then;
  661.                 return typeof i == "function" ? wt(i, t) : new c(t)
  662.             } catch (u) {
  663.                 return new r(u)
  664.             }
  665.         }
  666.  
  667.         function wt(n, t) {
  668.             return e(function(i, r) {
  669.                 d(n, t, i, r)
  670.             })
  671.         }
  672.  
  673.         function c(n) {
  674.             this.value = n
  675.         }
  676.  
  677.         function r(n) {
  678.             this.value = n
  679.         }
  680.  
  681.         function b(n) {
  682.             this.value = n
  683.         }
  684.  
  685.         function bt(n, t) {
  686.             function i() {
  687.                 t.fulfilled()
  688.             }
  689.  
  690.             function r(n) {
  691.                 t.rejected(n)
  692.             }
  693.             n.then(i, r)
  694.         }
  695.  
  696.         function rt(n) {
  697.             return n && typeof n.then == "function"
  698.         }
  699.  
  700.         function ut(n, i, r, u, f) {
  701.             return t(n, function(n) {
  702.                 function o(r, u, f) {
  703.                     function y(n) {
  704.                         c(n)
  705.                     }
  706.  
  707.                     function w(n) {
  708.                         h(n)
  709.                     }
  710.                     var o, v, s, a, h, c, l, e;
  711.                     if (l = n.length >>> 0, o = Math.max(0, Math.min(i, l)), s = [], v = l - o + 1, a = [], o)
  712.                         for (c = function(n) {
  713.                                 a.push(n);
  714.                                 --v || (h = c = p, u(a))
  715.                             }, h = function(n) {
  716.                                 s.push(n);
  717.                                 --o || (h = c = p, r(s))
  718.                             }, e = 0; e < l; ++e) e in n && t(n[e], w, y, f);
  719.                     else r(s)
  720.                 }
  721.                 return e(o).then(r, u, f)
  722.             })
  723.         }
  724.  
  725.         function kt(n, t, i, r) {
  726.             function u(n) {
  727.                 return t ? t(n[0]) : n[0]
  728.             }
  729.             return ut(n, 1, u, i, r)
  730.         }
  731.  
  732.         function ft(n, t, i, r) {
  733.             return l(n, p).then(t, i, r)
  734.         }
  735.  
  736.         function dt() {
  737.             return l(arguments, p)
  738.         }
  739.  
  740.         function gt(n) {
  741.             return l(n, et, ot)
  742.         }
  743.  
  744.         function ni(n, t) {
  745.             return l(n, t)
  746.         }
  747.  
  748.         function l(n, i, r) {
  749.             return t(n, function(n) {
  750.                 function u(u, f, e) {
  751.                     function l(n, o) {
  752.                         t(n, i, r).then(function(n) {
  753.                             s[o] = n;
  754.                             --h || u(s)
  755.                         }, f, e)
  756.                     }
  757.                     var s, c, h, o;
  758.                     if (h = c = n.length >>> 0, s = [], !h) {
  759.                         u(s);
  760.                         return
  761.                     }
  762.                     for (o = 0; o < c; o++) o in n ? l(n[o], o) : --h
  763.                 }
  764.                 return new f(u)
  765.             })
  766.         }
  767.  
  768.         function ti(n, i) {
  769.             var r = d(k, arguments, 1);
  770.             return t(n, function(n) {
  771.                 var u;
  772.                 return u = n.length, r[0] = function(n, r, f) {
  773.                     return t(n, function(n) {
  774.                         return t(r, function(t) {
  775.                             return i(n, t, f, u)
  776.                         })
  777.                     })
  778.                 }, st.apply(n, r)
  779.             })
  780.         }
  781.  
  782.         function et(n) {
  783.             return {
  784.                 state: "fulfilled",
  785.                 value: n
  786.             }
  787.         }
  788.  
  789.         function ot(n) {
  790.             return {
  791.                 state: "rejected",
  792.                 reason: n
  793.             }
  794.         }
  795.  
  796.         function ii() {
  797.             return {
  798.                 state: "pending"
  799.             }
  800.         }
  801.  
  802.         function y(n) {
  803.             v.push(n) === 1 && s(lt)
  804.         }
  805.  
  806.         function lt() {
  807.             w(v);
  808.             v = []
  809.         }
  810.  
  811.         function p(n) {
  812.             return n
  813.         }
  814.  
  815.         function ri(n) {
  816.             typeof h.reportUnhandled == "function" ? h.reportUnhandled() : y(function() {
  817.                 throw n;
  818.             });
  819.             throw n;
  820.         }
  821.         t.promise = e;
  822.         t.resolve = o;
  823.         t.reject = vt;
  824.         t.defer = yt;
  825.         t.join = dt;
  826.         t.all = ft;
  827.         t.map = ni;
  828.         t.reduce = ti;
  829.         t.settle = gt;
  830.         t.any = kt;
  831.         t.some = ut;
  832.         t.isPromise = rt;
  833.         t.isPromiseLike = rt;
  834.         i = f.prototype;
  835.         i.then = function(n, t, i) {
  836.             var r = this;
  837.             return new f(function(u, f, e) {
  838.                 r._when(u, e, n, t, i)
  839.             }, this._status && this._status.observed())
  840.         };
  841.         i["catch"] = i.otherwise = function(n) {
  842.             return this.then(u, n)
  843.         };
  844.         i["finally"] = i.ensure = function(n) {
  845.             function t() {
  846.                 return o(n())
  847.             }
  848.             return typeof n == "function" ? this.then(t, t)["yield"](this) : this
  849.         };
  850.         i.done = function(n, t) {
  851.             this.then(n, t)["catch"](ri)
  852.         };
  853.         i["yield"] = function(n) {
  854.             return this.then(function() {
  855.                 return n
  856.             })
  857.         };
  858.         i.tap = function(n) {
  859.             return this.then(n)["yield"](this)
  860.         };
  861.         i.spread = function(n) {
  862.             return this.then(function(t) {
  863.                 return ft(t, function(t) {
  864.                     return n.apply(u, t)
  865.                 })
  866.             })
  867.         };
  868.         i.always = function(n, t) {
  869.             return this.then(n, n, t)
  870.         };
  871.         a = Object.create || function(n) {
  872.             function t() {}
  873.             return t.prototype = n, new t
  874.         };
  875.         c.prototype = a(i);
  876.         c.prototype.inspect = function() {
  877.             return et(this.value)
  878.         };
  879.         c.prototype._when = function(n, t, i) {
  880.             try {
  881.                 n(typeof i == "function" ? i(this.value) : this.value)
  882.             } catch (u) {
  883.                 n(new r(u))
  884.             }
  885.         };
  886.         r.prototype = a(i);
  887.         r.prototype.inspect = function() {
  888.             return ot(this.value)
  889.         };
  890.         r.prototype._when = function(n, t, i, u) {
  891.             try {
  892.                 n(typeof u == "function" ? u(this.value) : this)
  893.             } catch (f) {
  894.                 n(new r(f))
  895.             }
  896.         };
  897.         b.prototype = a(i);
  898.         b.prototype._when = function(n, t, i, r, u) {
  899.             try {
  900.                 t(typeof u == "function" ? u(this.value) : this.value)
  901.             } catch (f) {
  902.                 t(f)
  903.             }
  904.         };
  905.         var i, a, st, k, d, s, v, g, nt, tt, h, ht, it, ct, u;
  906.         if (it = n, v = [], h = typeof console != "undefined" ? console : t, typeof process == "object" && process.nextTick) s = process.nextTick;
  907.         else if (ct = typeof MutationObserver == "function" && MutationObserver || typeof WebKitMutationObserver == "function" && WebKitMutationObserver) s = function(n, t, i) {
  908.             var r = n.createElement("div");
  909.             return new t(i).observe(r, {
  910.                     attributes: !0
  911.                 }),
  912.                 function() {
  913.                     r.setAttribute("x", "x")
  914.                 }
  915.         }(document, ct, lt);
  916.         else try {
  917.             s = it("vertx").runOnLoop || it("vertx").runOnContext
  918.         } catch (ui) {
  919.             ht = setTimeout;
  920.             s = function(n) {
  921.                 ht(n, 0)
  922.             }
  923.         }
  924.         return g = Function.prototype, nt = g.call, d = g.bind ? nt.bind(nt) : function(n, t) {
  925.             return n.apply(t, k.call(arguments, 2))
  926.         }, tt = [], k = tt.slice, st = tt.reduce || function(n) {
  927.             var i, u, r, f, t;
  928.             if (t = 0, i = Object(this), f = i.length >>> 0, u = arguments, u.length <= 1)
  929.                 for (;;) {
  930.                     if (t in i) {
  931.                         r = i[t++];
  932.                         break
  933.                     }
  934.                     if (++t >= f) throw new TypeError;
  935.                 } else r = u[1];
  936.             for (; t < f; ++t) t in i && (r = n(r, i[t], t, i));
  937.             return r
  938.         }, t
  939.     })
  940. })(typeof define == "function" && define.amd ? define : function(n) {
  941.     module.exports = n(require)
  942. });
  943. CryptoJS = CryptoJS || function(n, t) {
  944.         var u = {},
  945.             f = u.lib = {},
  946.             i = f.Base = function() {
  947.                 function n() {}
  948.                 return {
  949.                     extend: function(t) {
  950.                         n.prototype = this;
  951.                         var i = new n;
  952.                         return t && i.mixIn(t), i.hasOwnProperty("init") || (i.init = function() {
  953.                             i.$super.init.apply(this, arguments)
  954.                         }), i.init.prototype = i, i.$super = this, i
  955.                     },
  956.                     create: function() {
  957.                         var n = this.extend();
  958.                         return n.init.apply(n, arguments), n
  959.                     },
  960.                     init: function() {},
  961.                     mixIn: function(n) {
  962.                         for (var t in n) n.hasOwnProperty(t) && (this[t] = n[t]);
  963.                         n.hasOwnProperty("toString") && (this.toString = n.toString)
  964.                     },
  965.                     clone: function() {
  966.                         return this.init.prototype.extend(this)
  967.                     }
  968.                 }
  969.             }(),
  970.             r = f.WordArray = i.extend({
  971.                 init: function(n, i) {
  972.                     n = this.words = n || [];
  973.                     this.sigBytes = i != t ? i : n.length * 4
  974.                 },
  975.                 toString: function(n) {
  976.                     return (n || h).stringify(this)
  977.                 },
  978.                 concat: function(n) {
  979.                     var i = this.words,
  980.                         r = n.words,
  981.                         u = this.sigBytes,
  982.                         f = n.sigBytes,
  983.                         e, t;
  984.                     if (this.clamp(), u % 4)
  985.                         for (t = 0; t < f; t++) e = r[t >>> 2] >>> 24 - t % 4 * 8 & 255, i[u + t >>> 2] |= e << 24 - (u + t) % 4 * 8;
  986.                     else if (r.length > 65535)
  987.                         for (t = 0; t < f; t += 4) i[u + t >>> 2] = r[t >>> 2];
  988.                     else i.push.apply(i, r);
  989.                     return this.sigBytes += f, this
  990.                 },
  991.                 clamp: function() {
  992.                     var i = this.words,
  993.                         t = this.sigBytes;
  994.                     i[t >>> 2] &= 4294967295 << 32 - t % 4 * 8;
  995.                     i.length = n.ceil(t / 4)
  996.                 },
  997.                 clone: function() {
  998.                     var n = i.clone.call(this);
  999.                     return n.words = this.words.slice(0), n
  1000.                 },
  1001.                 random: function(t) {
  1002.                     for (var i = [], u = 0; u < t; u += 4) i.push(n.random() * 4294967296 | 0);
  1003.                     return new r.init(i, t)
  1004.                 }
  1005.             }),
  1006.             e = u.enc = {},
  1007.             h = e.Hex = {
  1008.                 stringify: function(n) {
  1009.                     for (var r, u = n.words, f = n.sigBytes, i = [], t = 0; t < f; t++) r = u[t >>> 2] >>> 24 - t % 4 * 8 & 255, i.push((r >>> 4).toString(16)), i.push((r & 15).toString(16));
  1010.                     return i.join("")
  1011.                 },
  1012.                 parse: function(n) {
  1013.                     for (var i = n.length, u = [], t = 0; t < i; t += 2) u[t >>> 3] |= parseInt(n.substr(t, 2), 16) << 24 - t % 8 * 4;
  1014.                     return new r.init(u, i / 2)
  1015.                 }
  1016.             },
  1017.             o = e.Latin1 = {
  1018.                 stringify: function(n) {
  1019.                     for (var r, u = n.words, f = n.sigBytes, i = [], t = 0; t < f; t++) r = u[t >>> 2] >>> 24 - t % 4 * 8 & 255, i.push(String.fromCharCode(r));
  1020.                     return i.join("")
  1021.                 },
  1022.                 parse: function(n) {
  1023.                     for (var i = n.length, u = [], t = 0; t < i; t++) u[t >>> 2] |= (n.charCodeAt(t) & 255) << 24 - t % 4 * 8;
  1024.                     return new r.init(u, i)
  1025.                 }
  1026.             },
  1027.             c = e.Utf8 = {
  1028.                 stringify: function(n) {
  1029.                     try {
  1030.                         return decodeURIComponent(escape(o.stringify(n)))
  1031.                     } catch (t) {
  1032.                         throw new Error("Malformed UTF-8 data");
  1033.                     }
  1034.                 },
  1035.                 parse: function(n) {
  1036.                     return o.parse(unescape(encodeURIComponent(n)))
  1037.                 }
  1038.             },
  1039.             s = f.BufferedBlockAlgorithm = i.extend({
  1040.                 reset: function() {
  1041.                     this._data = new r.init;
  1042.                     this._nDataBytes = 0
  1043.                 },
  1044.                 _append: function(n) {
  1045.                     typeof n == "string" && (n = c.parse(n));
  1046.                     this._data.concat(n);
  1047.                     this._nDataBytes += n.sigBytes
  1048.                 },
  1049.                 _process: function(t) {
  1050.                     var e = this._data,
  1051.                         h = e.words,
  1052.                         c = e.sigBytes,
  1053.                         o = this.blockSize,
  1054.                         a = o * 4,
  1055.                         u = c / a,
  1056.                         i, s, f, l;
  1057.                     if (u = t ? n.ceil(u) : n.max((u | 0) - this._minBufferSize, 0), i = u * o, s = n.min(i * 4, c), i) {
  1058.                         for (f = 0; f < i; f += o) this._doProcessBlock(h, f);
  1059.                         l = h.splice(0, i);
  1060.                         e.sigBytes -= s
  1061.                     }
  1062.                     return new r.init(l, s)
  1063.                 },
  1064.                 clone: function() {
  1065.                     var n = i.clone.call(this);
  1066.                     return n._data = this._data.clone(), n
  1067.                 },
  1068.                 _minBufferSize: 0
  1069.             }),
  1070.             a = f.Hasher = s.extend({
  1071.                 cfg: i.extend(),
  1072.                 init: function(n) {
  1073.                     this.cfg = this.cfg.extend(n);
  1074.                     this.reset()
  1075.                 },
  1076.                 reset: function() {
  1077.                     s.reset.call(this);
  1078.                     this._doReset()
  1079.                 },
  1080.                 update: function(n) {
  1081.                     return this._append(n), this._process(), this
  1082.                 },
  1083.                 finalize: function(n) {
  1084.                     n && this._append(n);
  1085.                     return this._doFinalize()
  1086.                 },
  1087.                 blockSize: 16,
  1088.                 _createHelper: function(n) {
  1089.                     return function(t, i) {
  1090.                         return new n.init(i).finalize(t)
  1091.                     }
  1092.                 },
  1093.                 _createHmacHelper: function(n) {
  1094.                     return function(t, i) {
  1095.                         return new l.HMAC.init(n, i).finalize(t)
  1096.                     }
  1097.                 }
  1098.             }),
  1099.             l = u.algo = {};
  1100.         return u
  1101.     }(Math),
  1102.     function() {
  1103.         var n = CryptoJS,
  1104.             t = n.lib,
  1105.             i = t.WordArray,
  1106.             r = n.enc,
  1107.             u = r.Base64 = {
  1108.                 stringify: function(n) {
  1109.                     var u = n.words,
  1110.                         e = n.sigBytes,
  1111.                         o = this._map,
  1112.                         i, t, r, f;
  1113.                     for (n.clamp(), i = [], t = 0; t < e; t += 3) {
  1114.                         var s = u[t >>> 2] >>> 24 - t % 4 * 8 & 255,
  1115.                             h = u[t + 1 >>> 2] >>> 24 - (t + 1) % 4 * 8 & 255,
  1116.                             c = u[t + 2 >>> 2] >>> 24 - (t + 2) % 4 * 8 & 255,
  1117.                             l = s << 16 | h << 8 | c;
  1118.                         for (r = 0; r < 4 && t + r * .75 < e; r++) i.push(o.charAt(l >>> 6 * (3 - r) & 63))
  1119.                     }
  1120.                     if (f = o.charAt(64), f)
  1121.                         while (i.length % 4) i.push(f);
  1122.                     return i.join("")
  1123.                 },
  1124.                 parse: function(n) {
  1125.                     var o = n.length,
  1126.                         u = this._map,
  1127.                         s = u.charAt(64),
  1128.                         f, e, r, t, h, c;
  1129.                     for (s && (f = n.indexOf(s), f != -1 && (o = f)), e = [], r = 0, t = 0; t < o; t++) t % 4 && (h = u.indexOf(n.charAt(t - 1)) << t % 4 * 2, c = u.indexOf(n.charAt(t)) >>> 6 - t % 4 * 2, e[r >>> 2] |= (h | c) << 24 - r % 4 * 8, r++);
  1130.                     return i.create(e, r)
  1131.                 },
  1132.                 _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  1133.             }
  1134.     }(),
  1135.     function() {
  1136.         var n = CryptoJS,
  1137.             t = n.lib,
  1138.             i = t.Base,
  1139.             r = n.enc,
  1140.             u = r.Utf8,
  1141.             f = n.algo,
  1142.             e = f.HMAC = i.extend({
  1143.                 init: function(n, t) {
  1144.                     var r, f, i;
  1145.                     n = this._hasher = new n.init;
  1146.                     typeof t == "string" && (t = u.parse(t));
  1147.                     r = n.blockSize;
  1148.                     f = r * 4;
  1149.                     t.sigBytes > f && (t = n.finalize(t));
  1150.                     t.clamp();
  1151.                     var e = this._oKey = t.clone(),
  1152.                         o = this._iKey = t.clone(),
  1153.                         s = e.words,
  1154.                         h = o.words;
  1155.                     for (i = 0; i < r; i++) s[i] ^= 1549556828, h[i] ^= 909522486;
  1156.                     e.sigBytes = o.sigBytes = f;
  1157.                     this.reset()
  1158.                 },
  1159.                 reset: function() {
  1160.                     var n = this._hasher;
  1161.                     n.reset();
  1162.                     n.update(this._iKey)
  1163.                 },
  1164.                 update: function(n) {
  1165.                     return this._hasher.update(n), this
  1166.                 },
  1167.                 finalize: function(n) {
  1168.                     var t = this._hasher,
  1169.                         i = t.finalize(n);
  1170.                     return t.reset(), t.finalize(this._oKey.clone().concat(i))
  1171.                 }
  1172.             })
  1173.     }(),
  1174.     function(n) {
  1175.         var i = CryptoJS,
  1176.             f = i.lib,
  1177.             s = f.WordArray,
  1178.             r = f.Hasher,
  1179.             h = i.algo,
  1180.             e = [],
  1181.             o = [],
  1182.             t, u;
  1183.         (function() {
  1184.             function u(t) {
  1185.                 for (var r = n.sqrt(t), i = 2; i <= r; i++)
  1186.                     if (!(t % i)) return !1;
  1187.                 return !0
  1188.             }
  1189.  
  1190.             function r(n) {
  1191.                 return (n - (n | 0)) * 4294967296 | 0
  1192.             }
  1193.             for (var i = 2, t = 0; t < 64;) u(i) && (t < 8 && (e[t] = r(n.pow(i, 1 / 2))), o[t] = r(n.pow(i, 1 / 3)), t++), i++
  1194.         })();
  1195.         t = [];
  1196.         u = h.SHA256 = r.extend({
  1197.             _doReset: function() {
  1198.                 this._hash = new s.init(e.slice(0))
  1199.             },
  1200.             _doProcessBlock: function(n, i) {
  1201.                 for (var r = this._hash.words, f = r[0], s = r[1], h = r[2], y = r[3], e = r[4], a = r[5], v = r[6], p = r[7], u = 0; u < 64; u++) {
  1202.                     if (u < 16) t[u] = n[i + u] | 0;
  1203.                     else {
  1204.                         var c = t[u - 15],
  1205.                             b = (c << 25 | c >>> 7) ^ (c << 14 | c >>> 18) ^ c >>> 3,
  1206.                             l = t[u - 2],
  1207.                             k = (l << 15 | l >>> 17) ^ (l << 13 | l >>> 19) ^ l >>> 10;
  1208.                         t[u] = b + t[u - 7] + k + t[u - 16]
  1209.                     }
  1210.                     var d = e & a ^ ~e & v,
  1211.                         g = f & s ^ f & h ^ s & h,
  1212.                         nt = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22),
  1213.                         tt = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25),
  1214.                         w = p + tt + d + o[u] + t[u],
  1215.                         it = nt + g;
  1216.                     p = v;
  1217.                     v = a;
  1218.                     a = e;
  1219.                     e = y + w | 0;
  1220.                     y = h;
  1221.                     h = s;
  1222.                     s = f;
  1223.                     f = w + it | 0
  1224.                 }
  1225.                 r[0] = r[0] + f | 0;
  1226.                 r[1] = r[1] + s | 0;
  1227.                 r[2] = r[2] + h | 0;
  1228.                 r[3] = r[3] + y | 0;
  1229.                 r[4] = r[4] + e | 0;
  1230.                 r[5] = r[5] + a | 0;
  1231.                 r[6] = r[6] + v | 0;
  1232.                 r[7] = r[7] + p | 0
  1233.             },
  1234.             _doFinalize: function() {
  1235.                 var r = this._data,
  1236.                     t = r.words,
  1237.                     u = this._nDataBytes * 8,
  1238.                     i = r.sigBytes * 8;
  1239.                 return t[i >>> 5] |= 128 << 24 - i % 32, t[(i + 64 >>> 9 << 4) + 14] = n.floor(u / 4294967296), t[(i + 64 >>> 9 << 4) + 15] = u, r.sigBytes = t.length * 4, this._process(), this._hash
  1240.             },
  1241.             clone: function() {
  1242.                 var n = r.clone.call(this);
  1243.                 return n._hash = this._hash.clone(), n
  1244.             }
  1245.         });
  1246.         i.SHA256 = r._createHelper(u);
  1247.         i.HmacSHA256 = r._createHmacHelper(u)
  1248.     }(Math),
  1249.     function() {
  1250.         var n = CryptoJS,
  1251.             i = n.lib,
  1252.             r = i.Base,
  1253.             u = i.WordArray,
  1254.             t = n.algo,
  1255.             f = t.SHA1,
  1256.             e = t.HMAC,
  1257.             o = t.PBKDF2 = r.extend({
  1258.                 cfg: r.extend({
  1259.                     keySize: 4,
  1260.                     hasher: f,
  1261.                     iterations: 1
  1262.                 }),
  1263.                 init: function(n) {
  1264.                     this.cfg = this.cfg.extend(n)
  1265.                 },
  1266.                 compute: function(n, t) {
  1267.                     for (var s = this.cfg, r = e.create(s.hasher, n), f = u.create(), l = u.create([1]), p = f.words, w = l.words, a = s.keySize, b = s.iterations, o, c, y, i; p.length < a;) {
  1268.                         o = r.update(t).finalize(l);
  1269.                         r.reset();
  1270.                         var v = o.words,
  1271.                             k = v.length,
  1272.                             h = o;
  1273.                         for (c = 1; c < b; c++)
  1274.                             for (h = r.finalize(h), r.reset(), y = h.words, i = 0; i < k; i++) v[i] ^= y[i];
  1275.                         f.concat(o);
  1276.                         w[0]++
  1277.                     }
  1278.                     return f.sigBytes = a * 4, f
  1279.                 }
  1280.             });
  1281.         n.PBKDF2 = function(n, t, i) {
  1282.             return o.create(i).compute(n, t)
  1283.         }
  1284.     }();
  1285. /** @license MIT License (c) 2011-2013 Copyright Tavendo GmbH. */
  1286. AUTOBAHNJS_VERSION = "?.?.?";
  1287. global = this,
  1288.     function(n, t) {
  1289.         typeof define == "function" && define.amd ? define(["when"], function(i) {
  1290.             return n.ab = t(n, i)
  1291.         }) : typeof exports != "undefined" ? typeof module != "undefined" && module.exports && (exports = module.exports = t(n, n.when)) : n.ab = t(n, n.when)
  1292.     }(global, function(n, t) {
  1293.         "use strict";
  1294.         var i = {};
  1295.         return i._version = AUTOBAHNJS_VERSION,
  1296.             function() {
  1297.                 Array.prototype.indexOf || (Array.prototype.indexOf = function(n) {
  1298.                     var u, r, t, i;
  1299.                     if (this === null) throw new TypeError;
  1300.                     if ((u = new Object(this), r = u.length >>> 0, r === 0) || (t = 0, arguments.length > 0 && (t = Number(arguments[1]), t !== t ? t = 0 : t !== 0 && t !== Infinity && t !== -Infinity && (t = (t > 0 || -1) * Math.floor(Math.abs(t)))), t >= r)) return -1;
  1301.                     for (i = t >= 0 ? t : Math.max(r - Math.abs(t), 0); i < r; i++)
  1302.                         if (i in u && u[i] === n) return i;
  1303.                     return -1
  1304.                 });
  1305.                 Array.prototype.forEach || (Array.prototype.forEach = function(n, t) {
  1306.                     var u, i, r, f, e;
  1307.                     if (this === null) throw new TypeError(" this is null or not defined");
  1308.                     if (r = new Object(this), f = r.length >>> 0, {}.toString.call(n) !== "[object Function]") throw new TypeError(n + " is not a function");
  1309.                     for (t && (u = t), i = 0; i < f;) i in r && (e = r[i], n.call(u, e, i, r)), i++
  1310.                 })
  1311.             }(), i._sliceUserAgent = function(n, t, i) {
  1312.                 var s = [],
  1313.                     r = navigator.userAgent,
  1314.                     h = r.indexOf(n),
  1315.                     f = r.indexOf(t, h),
  1316.                     e, o, u;
  1317.                 for (f < 0 && (f = r.length), e = r.slice(h, f).split(i), o = e[1].split("."), u = 0; u < o.length; ++u) s.push(parseInt(o[u], 10));
  1318.                 return {
  1319.                     name: e[0],
  1320.                     version: s
  1321.                 }
  1322.             }, i.getBrowser = function() {
  1323.                 var n = navigator.userAgent;
  1324.                 return n.indexOf("Chrome") > -1 ? i._sliceUserAgent("Chrome", " ", "/") : n.indexOf("Safari") > -1 ? i._sliceUserAgent("Safari", " ", "/") : n.indexOf("Firefox") > -1 ? i._sliceUserAgent("Firefox", " ", "/") : n.indexOf("MSIE") > -1 ? i._sliceUserAgent("MSIE", ";", " ") : null
  1325.             }, i.getServerUrl = function(t, i) {
  1326.                 if (n.location.protocol === "file:") return i ? i : "ws://127.0.0.1/ws";
  1327.                 var r = n.location.protocol === "https:" ? "wss://" : "ws://",
  1328.                     u = n.location.port !== "" ? ":" + n.location.port : "",
  1329.                     f = t ? t : "ws";
  1330.                 return r + n.location.hostname + u + "/" + f
  1331.             }, i.browserNotSupportedMessage = "Browser does not support WebSockets (RFC6455)", i.deriveKey = function(n, t) {
  1332.                 if (t && t.salt) {
  1333.                     var i = t.salt,
  1334.                         r = t.keylen || 32,
  1335.                         u = t.iterations || 1e4,
  1336.                         f = CryptoJS.PBKDF2(n, i, {
  1337.                             keySize: r / 4,
  1338.                             iterations: u,
  1339.                             hasher: CryptoJS.algo.SHA256
  1340.                         });
  1341.                     return f.toString(CryptoJS.enc.Base64)
  1342.                 }
  1343.                 return n
  1344.             }, i._idchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", i._idlen = 16, i._subprotocol = "wamp", i._newid = function() {
  1345.                 for (var n = "", t = 0; t < i._idlen; t += 1) n += i._idchars.charAt(Math.floor(Math.random() * i._idchars.length));
  1346.                 return n
  1347.             }, i._newidFast = function() {
  1348.                 return Math.random().toString(36)
  1349.             }, i.log = function() {
  1350.                 if (arguments.length > 1) {
  1351.                     console.group("Log Item");
  1352.                     for (var n = 0; n < arguments.length; n += 1) console.log(arguments[n]);
  1353.                     console.groupEnd()
  1354.                 } else console.log(arguments[0])
  1355.             }, i._debugrpc = !1, i._debugpubsub = !1, i._debugws = !1, i._debugconnect = !1, i.debug = function(t, r, u) {
  1356.                 if ("console" in n) i._debugrpc = t, i._debugpubsub = t, i._debugws = r, i._debugconnect = u;
  1357.                 else throw "browser does not support console object";
  1358.             }, i.version = function() {
  1359.                 return i._version
  1360.             }, i.PrefixMap = function() {
  1361.                 var n = this;
  1362.                 n._index = {};
  1363.                 n._rindex = {}
  1364.             }, i.PrefixMap.prototype.get = function(n) {
  1365.                 var t = this;
  1366.                 return t._index[n]
  1367.             }, i.PrefixMap.prototype.set = function(n, t) {
  1368.                 var i = this;
  1369.                 i._index[n] = t;
  1370.                 i._rindex[t] = n
  1371.             }, i.PrefixMap.prototype.setDefault = function(n) {
  1372.                 var t = this;
  1373.                 t._index[""] = n;
  1374.                 t._rindex[n] = ""
  1375.             }, i.PrefixMap.prototype.remove = function(n) {
  1376.                 var t = this,
  1377.                     i = t._index[n];
  1378.                 i && (delete t._index[n], delete t._rindex[i])
  1379.             }, i.PrefixMap.prototype.resolve = function(n, t) {
  1380.                 var u = this,
  1381.                     i = n.indexOf(":"),
  1382.                     r;
  1383.                 return i >= 0 && (r = n.substring(0, i), u._index[r]) ? u._index[r] + n.substring(i + 1) : t === !0 ? n : null
  1384.             }, i.PrefixMap.prototype.shrink = function(n, t) {
  1385.                 for (var u, r, f = this, i = n.length; i > 0; i -= 1)
  1386.                     if (u = n.substring(0, i), r = f._rindex[u], r) return r + ":" + n.substring(i);
  1387.                 return t === !0 ? n : null
  1388.             }, i._MESSAGE_TYPEID_WELCOME = 0, i._MESSAGE_TYPEID_PREFIX = 1, i._MESSAGE_TYPEID_CALL = 2, i._MESSAGE_TYPEID_CALL_RESULT = 3, i._MESSAGE_TYPEID_CALL_ERROR = 4, i._MESSAGE_TYPEID_SUBSCRIBE = 5, i._MESSAGE_TYPEID_UNSUBSCRIBE = 6, i._MESSAGE_TYPEID_PUBLISH = 7, i._MESSAGE_TYPEID_EVENT = 8, i.CONNECTION_CLOSED = 0, i.CONNECTION_LOST = 1, i.CONNECTION_RETRIES_EXCEEDED = 2, i.CONNECTION_UNREACHABLE = 3, i.CONNECTION_UNSUPPORTED = 4, i.CONNECTION_UNREACHABLE_SCHEDULED_RECONNECT = 5, i.CONNECTION_LOST_SCHEDULED_RECONNECT = 6, i.Deferred = t.defer, i._construct = function(t, i) {
  1389.                 return "WebSocket" in n ? i ? new WebSocket(t, i) : new WebSocket(t) : "MozWebSocket" in n ? i ? new MozWebSocket(t, i) : new MozWebSocket(t) : null
  1390.             }, i.Session = function(n, t, r, u) {
  1391.                 var f = this;
  1392.                 if (f._wsuri = n, f._options = u, f._websocket_onopen = t, f._websocket_onclose = r, f._websocket = null, f._websocket_connected = !1, f._session_id = null, f._wamp_version = null, f._server = null, f._calls = {}, f._subscriptions = {}, f._prefixes = new i.PrefixMap, f._txcnt = 0, f._rxcnt = 0, f._websocket = f._options && f._options.skipSubprotocolAnnounce ? i._construct(f._wsuri) : i._construct(f._wsuri, [i._subprotocol]), !f._websocket) {
  1393.                     if (r !== undefined) {
  1394.                         r(i.CONNECTION_UNSUPPORTED);
  1395.                         return
  1396.                     }
  1397.                     throw i.browserNotSupportedMessage;
  1398.                 }
  1399.                 f._websocket.onmessage = function(n) {
  1400.                     var t, r, h, e, c, s, v, y, p, w;
  1401.                     if (i._debugws && (f._rxcnt += 1, console.group("WS Receive"), console.info(f._wsuri + "  [" + f._session_id + "]"), console.log(f._rxcnt), console.log(n.data), console.groupEnd()), t = JSON.parse(n.data), t[1] in f._calls) {
  1402.                         if (t[0] === i._MESSAGE_TYPEID_CALL_RESULT) {
  1403.                             if (r = f._calls[t[1]], h = t[2], i._debugrpc && r._ab_callobj !== undefined) {
  1404.                                 for (console.group("WAMP Call", r._ab_callobj[2]), console.timeEnd(r._ab_tid), console.group("Arguments"), e = 3; e < r._ab_callobj.length; e += 1)
  1405.                                     if (c = r._ab_callobj[e], c !== undefined) console.log(c);
  1406.                                     else break;
  1407.                                 console.groupEnd();
  1408.                                 console.group("Result");
  1409.                                 console.log(h);
  1410.                                 console.groupEnd();
  1411.                                 console.groupEnd()
  1412.                             }
  1413.                             r.resolve(h)
  1414.                         } else if (t[0] === i._MESSAGE_TYPEID_CALL_ERROR) {
  1415.                             var u = f._calls[t[1]],
  1416.                                 l = t[2],
  1417.                                 a = t[3],
  1418.                                 o = t[4];
  1419.                             if (i._debugrpc && u._ab_callobj !== undefined) {
  1420.                                 for (console.group("WAMP Call", u._ab_callobj[2]), console.timeEnd(u._ab_tid), console.group("Arguments"), s = 3; s < u._ab_callobj.length; s += 1)
  1421.                                     if (v = u._ab_callobj[s], v !== undefined) console.log(v);
  1422.                                     else break;
  1423.                                 console.groupEnd();
  1424.                                 console.group("Error");
  1425.                                 console.log(l);
  1426.                                 console.log(a);
  1427.                                 o !== undefined && console.log(o);
  1428.                                 console.groupEnd();
  1429.                                 console.groupEnd()
  1430.                             }
  1431.                             o !== undefined ? u.reject({
  1432.                                 uri: l,
  1433.                                 desc: a,
  1434.                                 detail: o
  1435.                             }) : u.reject({
  1436.                                 uri: l,
  1437.                                 desc: a
  1438.                             })
  1439.                         }
  1440.                         delete f._calls[t[1]]
  1441.                     } else if (t[0] === i._MESSAGE_TYPEID_EVENT) y = f._prefixes.resolve(t[1], !0), y in f._subscriptions && (p = t[1], w = t[2], i._debugpubsub && (console.group("WAMP Event"), console.info(f._wsuri + "  [" + f._session_id + "]"), console.log(p), console.log(w), console.groupEnd()), f._subscriptions[y].forEach(function(n) {
  1442.                         n(p, w)
  1443.                     }));
  1444.                     else if (t[0] === i._MESSAGE_TYPEID_WELCOME)
  1445.                         if (f._session_id === null) f._session_id = t[1], f._wamp_version = t[2], f._server = t[3], (i._debugrpc || i._debugpubsub) && (console.group("WAMP Welcome"), console.info(f._wsuri + "  [" + f._session_id + "]"), console.log(f._wamp_version), console.log(f._server), console.groupEnd()), f._websocket_onopen !== null && f._websocket_onopen();
  1446.                         else throw "protocol error (welcome message received more than once)";
  1447.                 };
  1448.                 f._websocket.onopen = function() {
  1449.                     if (f._websocket.protocol !== i._subprotocol)
  1450.                         if (typeof f._websocket.protocol == "undefined") i._debugws && (console.group("WS Warning"), console.info(f._wsuri), console.log("WebSocket object has no protocol attribute: WAMP subprotocol check skipped!"), console.groupEnd());
  1451.                         else if (f._options && f._options.skipSubprotocolCheck) i._debugws && (console.group("WS Warning"), console.info(f._wsuri), console.log("Server does not speak WAMP, but subprotocol check disabled by option!"), console.log(f._websocket.protocol), console.groupEnd());
  1452.                     else {
  1453.                         f._websocket.close(1e3, "server does not speak WAMP");
  1454.                         throw "server does not speak WAMP (but '" + f._websocket.protocol + "' !)";
  1455.                     }
  1456.                     i._debugws && (console.group("WAMP Connect"), console.info(f._wsuri), console.log(f._websocket.protocol), console.groupEnd());
  1457.                     f._websocket_connected = !0
  1458.                 };
  1459.                 f._websocket.onerror = function() {};
  1460.                 f._websocket.onclose = function(n) {
  1461.                     i._debugws && (f._websocket_connected ? console.log("Autobahn connection to " + f._wsuri + " lost (code " + n.code + ", reason '" + n.reason + "', wasClean " + n.wasClean + ").") : console.log("Autobahn could not connect to " + f._wsuri + " (code " + n.code + ", reason '" + n.reason + "', wasClean " + n.wasClean + ")."));
  1462.                     f._websocket_onclose !== undefined && (f._websocket_connected ? n.wasClean ? f._websocket_onclose(i.CONNECTION_CLOSED, "WS-" + n.code + ": " + n.reason) : f._websocket_onclose(i.CONNECTION_LOST) : f._websocket_onclose(i.CONNECTION_UNREACHABLE));
  1463.                     f._websocket_connected = !1;
  1464.                     f._wsuri = null;
  1465.                     f._websocket_onopen = null;
  1466.                     f._websocket_onclose = null;
  1467.                     f._websocket = null
  1468.                 };
  1469.                 f.log = function() {
  1470.                     f._options && "sessionIdent" in f._options ? console.group("WAMP Session '" + f._options.sessionIdent + "' [" + f._session_id + "]") : console.group("WAMP Session [" + f._session_id + "]");
  1471.                     for (var n = 0; n < arguments.length; ++n) console.log(arguments[n]);
  1472.                     console.groupEnd()
  1473.                 }
  1474.             }, i.Session.prototype._send = function(t) {
  1475.                 var r = this,
  1476.                     u;
  1477.                 if (!r._websocket_connected) throw "Autobahn not connected";
  1478.                 switch (!0) {
  1479.                     case n.Prototype && typeof top.root.__prototype_deleted == "undefined":
  1480.                     case typeof t.toJSON == "function":
  1481.                         u = t.toJSON();
  1482.                         break;
  1483.                     default:
  1484.                         u = JSON.stringify(t)
  1485.                 }
  1486.                 r._websocket.send(u);
  1487.                 r._txcnt += 1;
  1488.                 i._debugws && (console.group("WS Send"), console.info(r._wsuri + "  [" + r._session_id + "]"), console.log(r._txcnt), console.log(u), console.groupEnd())
  1489.             }, i.Session.prototype.close = function() {
  1490.                 var n = this;
  1491.                 n._websocket_connected && n._websocket.close()
  1492.             }, i.Session.prototype.sessionid = function() {
  1493.                 var n = this;
  1494.                 return n._session_id
  1495.             }, i.Session.prototype.wsuri = function() {
  1496.                 var n = this;
  1497.                 return n._wsuri
  1498.             }, i.Session.prototype.shrink = function(n, t) {
  1499.                 var i = this;
  1500.                 return t === undefined && (t = !0), i._prefixes.shrink(n, t)
  1501.             }, i.Session.prototype.resolve = function(n, t) {
  1502.                 var i = this;
  1503.                 return t === undefined && (t = !0), i._prefixes.resolve(n, t)
  1504.             }, i.Session.prototype.prefix = function(n, t) {
  1505.                 var r = this,
  1506.                     u;
  1507.                 r._prefixes.set(n, t);
  1508.                 (i._debugrpc || i._debugpubsub) && (console.group("WAMP Prefix"), console.info(r._wsuri + "  [" + r._session_id + "]"), console.log(n), console.log(t), console.groupEnd());
  1509.                 u = [i._MESSAGE_TYPEID_PREFIX, n, t];
  1510.                 r._send(u)
  1511.             }, i.Session.prototype.call = function() {
  1512.                 for (var t = this, n = new i.Deferred, r, e, u, f;;)
  1513.                     if (r = i._newidFast(), !(r in t._calls)) break;
  1514.                 for (t._calls[r] = n, e = t._prefixes.shrink(arguments[0], !0), u = [i._MESSAGE_TYPEID_CALL, r, e], f = 1; f < arguments.length; f += 1) u.push(arguments[f]);
  1515.                 return t._send(u), i._debugrpc && (n._ab_callobj = u, n._ab_tid = t._wsuri + "  [" + t._session_id + "][" + r + "]", console.time(n._ab_tid), console.info()), n.promise.then ? n.promise : n
  1516.             }, i.Session.prototype.subscribe = function(n, t) {
  1517.                 var r = this,
  1518.                     u = r._prefixes.resolve(n, !0),
  1519.                     f, e;
  1520.                 if (u in r._subscriptions || (i._debugpubsub && (console.group("WAMP Subscribe"), console.info(r._wsuri + "  [" + r._session_id + "]"), console.log(n), console.log(t), console.groupEnd()), f = [i._MESSAGE_TYPEID_SUBSCRIBE, n], r._send(f), r._subscriptions[u] = []), e = r._subscriptions[u].indexOf(t), e === -1) r._subscriptions[u].push(t);
  1521.                 else throw "callback " + t + " already subscribed for topic " + u;
  1522.             }, i.Session.prototype.unsubscribe = function(n, t) {
  1523.                 var r = this,
  1524.                     u = r._prefixes.resolve(n, !0),
  1525.                     f, e, o;
  1526.                 if (u in r._subscriptions) {
  1527.                     if (t !== undefined)
  1528.                         if (e = r._subscriptions[u].indexOf(t), e !== -1) f = t, r._subscriptions[u].splice(e, 1);
  1529.                         else throw "no callback " + t + " subscribed on topic " + u;
  1530.                     else f = r._subscriptions[u].slice(), r._subscriptions[u] = [];
  1531.                     r._subscriptions[u].length === 0 && (delete r._subscriptions[u], i._debugpubsub && (console.group("WAMP Unsubscribe"), console.info(r._wsuri + "  [" + r._session_id + "]"), console.log(n), console.log(f), console.groupEnd()), o = [i._MESSAGE_TYPEID_UNSUBSCRIBE, n], r._send(o))
  1532.                 } else throw "not subscribed to topic " + u;
  1533.             }, i.Session.prototype.publish = function() {
  1534.                 var o = this,
  1535.                     t = arguments[0],
  1536.                     r = arguments[1],
  1537.                     f = null,
  1538.                     n = null,
  1539.                     e = null,
  1540.                     u = null;
  1541.                 if (arguments.length > 3) {
  1542.                     if (!(arguments[2] instanceof Array)) throw "invalid argument type(s)";
  1543.                     if (!(arguments[3] instanceof Array)) throw "invalid argument type(s)";
  1544.                     n = arguments[2];
  1545.                     e = arguments[3];
  1546.                     u = [i._MESSAGE_TYPEID_PUBLISH, t, r, n, e]
  1547.                 } else if (arguments.length > 2)
  1548.                     if (typeof arguments[2] == "boolean") f = arguments[2], u = [i._MESSAGE_TYPEID_PUBLISH, t, r, f];
  1549.                     else if (arguments[2] instanceof Array) n = arguments[2], u = [i._MESSAGE_TYPEID_PUBLISH, t, r, n];
  1550.                 else throw "invalid argument type(s)";
  1551.                 else u = [i._MESSAGE_TYPEID_PUBLISH, t, r];
  1552.                 i._debugpubsub && (console.group("WAMP Publish"), console.info(o._wsuri + "  [" + o._session_id + "]"), console.log(t), console.log(r), f !== null ? console.log(f) : n !== null && (console.log(n), e !== null && console.log(e)), console.groupEnd());
  1553.                 o._send(u)
  1554.             }, i.Session.prototype.authreq = function(n, t) {
  1555.                 return this.call("http://api.wamp.ws/procedure#authreq", n, t)
  1556.             }, i.Session.prototype.authsign = function(n, t) {
  1557.                 return t || (t = ""), CryptoJS.HmacSHA256(n, t).toString(CryptoJS.enc.Base64)
  1558.             }, i.Session.prototype.auth = function(n) {
  1559.                 return this.call("http://api.wamp.ws/procedure#auth", n)
  1560.             }, i._connect = function(t) {
  1561.                 var r = new i.Session(t.wsuri, function() {
  1562.                     t.connects += 1;
  1563.                     t.retryCount = 0;
  1564.                     t.onConnect(r)
  1565.                 }, function(r, u) {
  1566.                     var f = null;
  1567.                     switch (r) {
  1568.                         case i.CONNECTION_CLOSED:
  1569.                             t.onHangup(r, "Connection was closed properly [" + u + "]");
  1570.                             break;
  1571.                         case i.CONNECTION_UNSUPPORTED:
  1572.                             t.onHangup(r, "Browser does not support WebSocket.");
  1573.                             break;
  1574.                         case i.CONNECTION_UNREACHABLE:
  1575.                             if (t.retryCount += 1, t.connects === 0) t.onHangup(r, "Connection could not be established.");
  1576.                             else if (t.retryCount <= t.options.maxRetries)
  1577.                                 if (f = t.onHangup(i.CONNECTION_UNREACHABLE_SCHEDULED_RECONNECT, "Connection unreachable - scheduled reconnect to occur in " + t.options.retryDelay / 1e3 + " second(s) - attempt " + t.retryCount + " of " + t.options.maxRetries + ".", {
  1578.                                         delay: t.options.retryDelay,
  1579.                                         retries: t.retryCount,
  1580.                                         maxretries: t.options.maxRetries
  1581.                                     }), f) {
  1582.                                     i._debugconnect && console.log("Connection unreachable - retrying stopped by app");
  1583.                                     t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Number of connection retries exceeded.")
  1584.                                 } else i._debugconnect && console.log("Connection unreachable - retrying (" + t.retryCount + ") .."), n.setTimeout(function() {
  1585.                                     i._connect(t)
  1586.                                 }, t.options.retryDelay);
  1587.                             else t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Number of connection retries exceeded.");
  1588.                             break;
  1589.                         case i.CONNECTION_LOST:
  1590.                             if (t.retryCount += 1, t.retryCount <= t.options.maxRetries)
  1591.                                 if (f = t.onHangup(i.CONNECTION_LOST_SCHEDULED_RECONNECT, "Connection lost - scheduled " + t.retryCount + "th reconnect to occur in " + t.options.retryDelay / 1e3 + " second(s).", {
  1592.                                         delay: t.options.retryDelay,
  1593.                                         retries: t.retryCount,
  1594.                                         maxretries: t.options.maxRetries
  1595.                                     }), f) {
  1596.                                     i._debugconnect && console.log("Connection lost - retrying stopped by app");
  1597.                                     t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Connection lost.")
  1598.                                 } else i._debugconnect && console.log("Connection lost - retrying (" + t.retryCount + ") .."), n.setTimeout(function() {
  1599.                                     i._connect(t)
  1600.                                 }, t.options.retryDelay);
  1601.                             else t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Connection lost.");
  1602.                             break;
  1603.                         default:
  1604.                             throw "unhandled close code in ab._connect";
  1605.                     }
  1606.                 }, t.options)
  1607.             }, i.connect = function(n, t, r, u) {
  1608.                 var f = {};
  1609.                 if (f.wsuri = n, f.options = u ? u : {}, f.options.retryDelay === undefined && (f.options.retryDelay = 5e3), f.options.maxRetries === undefined && (f.options.maxRetries = 10), f.options.skipSubprotocolCheck === undefined && (f.options.skipSubprotocolCheck = !1), f.options.skipSubprotocolAnnounce === undefined && (f.options.skipSubprotocolAnnounce = !1), t) f.onConnect = t;
  1610.                 else throw "onConnect handler required!";
  1611.                 f.onHangup = r ? r : function(n, t, r) {
  1612.                     i._debugconnect && console.log(n, t, r)
  1613.                 };
  1614.                 f.connects = 0;
  1615.                 f.retryCount = 0;
  1616.                 i._connect(f)
  1617.             }, i.launch = function(n, t, r) {
  1618.                 i.connect(n.wsuri, function(r) {
  1619.                     n.appkey && n.appkey !== "" ? r.authreq(n.appkey, n.appextra).then(function(u) {
  1620.                         var f = null,
  1621.                             e;
  1622.                         typeof n.appsecret == "function" ? f = n.appsecret(u) : (e = i.deriveKey(n.appsecret, JSON.parse(u).authextra), f = r.authsign(u, e));
  1623.                         r.auth(f).then(function() {
  1624.                             t ? t(r) : i._debugconnect && r.log("Session opened.")
  1625.                         }, r.log)
  1626.                     }, r.log) : r.authreq().then(function() {
  1627.                         r.auth().then(function() {
  1628.                             t ? t(r) : i._debugconnect && r.log("Session opened.")
  1629.                         }, r.log)
  1630.                     }, r.log)
  1631.                 }, function(n, t, u) {
  1632.                     r ? r(n, t, u) : i._debugconnect && i.log("Session closed.", n, t, u)
  1633.                 }, n.sessionConfig)
  1634.             }, i
  1635.     });
  1636. ab._UA_FIREFOX = new RegExp(".*Firefox/([0-9+]*).*");
  1637. ab._UA_CHROME = new RegExp(".*Chrome/([0-9+]*).*");
  1638. ab._UA_CHROMEFRAME = new RegExp(".*chromeframe/([0-9]*).*");
  1639. ab._UA_WEBKIT = new RegExp(".*AppleWebKit/([0-9+.]*)w*.*");
  1640. ab._UA_WEBOS = new RegExp(".*webOS/([0-9+.]*)w*.*");
  1641. ab._matchRegex = function(n, t) {
  1642.     var i = t.exec(n);
  1643.     return i ? i[1] : i
  1644. };
  1645. ab.lookupWsSupport = function() {
  1646.     var n = navigator.userAgent,
  1647.         t;
  1648.     return n.indexOf("MSIE") > -1 ? n.indexOf("MSIE 10") > -1 ? [!0, !0, !0] : n.indexOf("chromeframe") > -1 ? (t = parseInt(ab._matchRegex(n, ab._UA_CHROMEFRAME)), t >= 14) ? [!0, !1, !0] : [!1, !1, !1] : n.indexOf("MSIE 8") > -1 || n.indexOf("MSIE 9") > -1 ? [!0, !0, !0] : [!1, !1, !1] : n.indexOf("Firefox") > -1 ? (t = parseInt(ab._matchRegex(n, ab._UA_FIREFOX)), t) ? t >= 7 ? [!0, !1, !0] : t >= 3 ? [!0, !0, !0] : [!1, !1, !0] : [!1, !1, !0] : n.indexOf("Safari") > -1 && n.indexOf("Chrome") == -1 ? (t = ab._matchRegex(n, ab._UA_WEBKIT), t) ? n.indexOf("Windows") > -1 && t == "534+" ? [!0, !1, !0] : n.indexOf("Macintosh") > -1 && (t = t.replace("+", "").split("."), parseInt(t[0]) == 535 && parseInt(t[1]) >= 24 || parseInt(t[0]) > 535) ? [!0, !1, !0] : n.indexOf("webOS") > -1 ? (t = ab._matchRegex(n, ab._UA_WEBOS).split("."), parseInt(t[0]) == 2) ? [!1, !0, !0] : [!1, !1, !1] : [!0, !0, !0] : [!1, !1, !1] : n.indexOf("Chrome") > -1 ? (t = parseInt(ab._matchRegex(n, ab._UA_CHROME)), t) ? t >= 14 ? [!0, !1, !0] : t >= 4 ? [!0, !0, !0] : [!1, !1, !0] : [!1, !1, !1] : n.indexOf("Android") > -1 ? n.indexOf("Firefox") > -1 ? [!0, !1, !0] : n.indexOf("CrMo") > -1 ? [!0, !1, !0] : n.indexOf("Opera") > -1 ? [!1, !1, !0] : n.indexOf("CrMo") > -1 ? [!0, !0, !0] : [!1, !1, !1] : n.indexOf("iPhone") > -1 || n.indexOf("iPad") > -1 || n.indexOf("iPod") > -1 ? [!1, !1, !0] : [!1, !1, !1]
  1649. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement