/*
    JSXGraph 0.97.0

    Copyright 2008-2013
        Matthias Ehmann,
        Michael Gerhaeuser,
        Carsten Miller,
        Bianca Valentin,
        Alfred Wassermann,
        Peter Wilfahrt

    This file is part of JSXGraph.

    JSXGraph is free software dual licensed under the GNU LGPL or MIT License.

    You can redistribute it and/or modify it under the terms of the

      * GNU Lesser General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version
      OR
      * MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT

    JSXGraph is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License and
    the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/>
    and <http://opensource.org/licenses/MIT/>.
*/

/**
 * almond 0.2.5 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/jrburke/almond for details
 */(function(){var requirejs,require,define;(function(t){function e(t,e){return g.call(t,e)}function r(t,e){var r,i,s,o,n,a,h,c,l,d,u=e&&e.split("/"),p=b.map,f=p&&p["*"]||{};if(t&&"."===t.charAt(0))if(e){for(u=u.slice(0,u.length-1),t=u.concat(t.split("/")),c=0;t.length>c;c+=1)if(d=t[c],"."===d)t.splice(c,1),c-=1;else if(".."===d){if(1===c&&(".."===t[2]||".."===t[0]))break;c>0&&(t.splice(c-1,2),c-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((u||f)&&p){for(r=t.split("/"),c=r.length;c>0;c-=1){if(i=r.slice(0,c).join("/"),u)for(l=u.length;l>0;l-=1)if(s=p[u.slice(0,l).join("/")],s&&(s=s[i])){o=s,n=c;break}if(o)break;!a&&f&&f[i]&&(a=f[i],h=c)}!o&&a&&(o=a,n=h),o&&(r.splice(0,n,o),t=r.join("/"))}return t}function i(e,r){return function(){return l.apply(t,v.call(arguments,0).concat([e,r]))}}function s(t){return function(e){return r(e,t)}}function o(t){return function(e){p[t]=e}}function n(r){if(e(f,r)){var i=f[r];delete f[r],m[r]=!0,c.apply(t,i)}if(!e(p,r)&&!e(m,r))throw Error("No "+r);return p[r]}function a(t){var e,r=t?t.indexOf("!"):-1;return r>-1&&(e=t.substring(0,r),t=t.substring(r+1,t.length)),[e,t]}function h(t){return function(){return b&&b.config&&b.config[t]||{}}}var c,l,d,u,p={},f={},b={},m={},g=Object.prototype.hasOwnProperty,v=[].slice;d=function(t,e){var i,o=a(t),h=o[0];return t=o[1],h&&(h=r(h,e),i=n(h)),h?t=i&&i.normalize?i.normalize(t,s(e)):r(t,e):(t=r(t,e),o=a(t),h=o[0],t=o[1],h&&(i=n(h))),{f:h?h+"!"+t:t,n:t,pr:h,p:i}},u={require:function(t){return i(t)},exports:function(t){var e=p[t];return e!==void 0?e:p[t]={}},module:function(t){return{id:t,uri:"",exports:p[t],config:h(t)}}},c=function(r,s,a,h){var c,l,b,g,v,C,y=[];if(h=h||r,"function"==typeof a){for(s=!s.length&&a.length?["require","exports","module"]:s,v=0;s.length>v;v+=1)if(g=d(s[v],h),l=g.f,"require"===l)y[v]=u.require(r);else if("exports"===l)y[v]=u.exports(r),C=!0;else if("module"===l)c=y[v]=u.module(r);else if(e(p,l)||e(f,l)||e(m,l))y[v]=n(l);else{if(!g.p)throw Error(r+" missing "+l);g.p.load(g.n,i(h,!0),o(l),{}),y[v]=p[l]}b=a.apply(p[r],y),r&&(c&&c.exports!==t&&c.exports!==p[r]?p[r]=c.exports:b===t&&C||(p[r]=b))}else r&&(p[r]=a)},requirejs=require=l=function(e,r,i,s,o){return"string"==typeof e?u[e]?u[e](r):n(d(e,r).f):(e.splice||(b=e,r.splice?(e=r,r=i,i=null):e=t),r=r||function(){},"function"==typeof i&&(i=s,s=o),s?c(t,e,r,i):setTimeout(function(){c(t,e,r,i)},4),l)},l.config=function(t){return b=t,b.deps&&l(b.deps,b.callback),l},define=function(t,r,i){r.splice||(i=r,r=[]),e(p,t)||e(f,t)||(f[t]=[t,r,i])},define.amd={jQuery:!0}})(),define("../node_modules/almond/almond",function(){}),define("jxg",[],function(){var t={};return"object"!=typeof JXG||JXG.extend||(t=JXG),t.extend=function(t,e,r,i){var s,o;r=r||!1,i=i||!1;for(s in e)(!r||r&&e.hasOwnProperty(s))&&(o=i?s.toLowerCase():s,t[o]=e[s])},t.extend(t,{boards:{},readers:{},elements:{},registerElement:function(t,e){t=t.toLowerCase(),this.elements[t]=e},registerReader:function(t,e){var r,i;for(r=0;e.length>r;r++)i=e[r].toLowerCase(),"function"!=typeof this.readers[i]&&(this.readers[i]=t)},shortcut:function(t,e){return function(){return t[e].apply(this,arguments)}},getRef:function(t,e){return t.select(e)},getReference:function(t,e){return t.select(e)},debugInt:function(){var t,e;for(t=0;arguments.length>t;t++)e=arguments[t],"object"==typeof window&&window.console&&console.log?console.log(e):"object"==typeof document&&document.getElementById("debug")&&(document.getElementById("debug").innerHTML+=e+"<br/>")},debugWST:function(){var e=Error();t.debugInt.apply(this,arguments),e&&e.stack&&(t.debugInt("stacktrace"),t.debugInt(e.stack.split("\n").slice(1).join("\n")))},debugLine:function(){var e=Error();t.debugInt.apply(this,arguments),e&&e.stack&&t.debugInt("Called from",e.stack.split("\n").slice(2,3).join("\n"))},debug:function(){t.debugInt.apply(this,arguments)}}),t}),define("base/constants",["jxg"],function(t){var e;return e={version:"0.97.0",licenseText:"JSXGraph v0.97 Copyright (C) see http://jsxgraph.org",COORDS_BY_USER:1,COORDS_BY_SCREEN:2,OBJECT_TYPE_ARC:1,OBJECT_TYPE_ARROW:2,OBJECT_TYPE_AXIS:3,OBJECT_TYPE_AXISPOINT:4,OBJECT_TYPE_TICKS:5,OBJECT_TYPE_CIRCLE:6,OBJECT_TYPE_CONIC:7,OBJECT_TYPE_CURVE:8,OBJECT_TYPE_GLIDER:9,OBJECT_TYPE_IMAGE:10,OBJECT_TYPE_LINE:11,OBJECT_TYPE_POINT:12,OBJECT_TYPE_SLIDER:13,OBJECT_TYPE_CAS:14,OBJECT_TYPE_GXTCAS:15,OBJECT_TYPE_POLYGON:16,OBJECT_TYPE_SECTOR:17,OBJECT_TYPE_TEXT:18,OBJECT_TYPE_ANGLE:19,OBJECT_TYPE_INTERSECTION:20,OBJECT_TYPE_TURTLE:21,OBJECT_TYPE_VECTOR:22,OBJECT_TYPE_OPROJECT:23,OBJECT_TYPE_GRID:24,OBJECT_CLASS_POINT:1,OBJECT_CLASS_LINE:2,OBJECT_CLASS_CIRCLE:3,OBJECT_CLASS_CURVE:4,OBJECT_CLASS_AREA:5,OBJECT_CLASS_OTHER:6,GENTYPE_ABC:1,GENTYPE_AXIS:2,GENTYPE_MID:3,GENTYPE_REFLECTION:4,GENTYPE_MIRRORPOINT:5,GENTYPE_TANGENT:6,GENTYPE_PARALLEL:7,GENTYPE_BISECTORLINES:8,GENTYPE_BISECTOR:10,GENTYPE_NORMAL:11,GENTYPE_POINT:12,GENTYPE_GLIDER:13,GENTYPE_INTERSECTION:14,GENTYPE_CIRCLE:15,GENTYPE_CIRCLE2POINTS:16,GENTYPE_LINE:17,GENTYPE_TRIANGLE:18,GENTYPE_QUADRILATERAL:19,GENTYPE_TEXT:20,GENTYPE_POLYGON:21,GENTYPE_REGULARPOLYGON:22,GENTYPE_SECTOR:23,GENTYPE_ANGLE:24,GENTYPE_PLOT:25,GENTYPE_SLIDER:26,GENTYPE_XYZ:27,GENTYPE_JCODE:28,GENTYPE_MOVEMENT:29,GENTYPE_COMBINED:30,GENTYPE_RULER:31,GENTYPE_GRID:33,GENTYPE_DELETE:41,GENTYPE_COPY:42,GENTYPE_MIRROR:43,GENTYPE_ROTATE:44,GENTYPE_ABLATION:45,GENTYPE_MIGRATE:46,GENTYPE_CTX_TYPE_G:51,GENTYPE_CTX_TYPE_P:52,GENTYPE_CTX_TRACE:53,GENTYPE_CTX_VISIBILITY:54,GENTYPE_CTX_CCVISIBILITY:55,GENTYPE_CTX_MPVISIBILITY:56,GENTYPE_CTX_WITHLABEL:57,GENTYPE_CTX_SETLABEL:58,GENTYPE_CTX_SETFIXED:59,GENTYPE_CTX_STROKEWIDTH:60,GENTYPE_CTX_LABELSIZE:61,GENTYPE_CTX_SIZE:62,GENTYPE_CTX_FACE:63,GENTYPE_CTX_STRAIGHT:64,GENTYPE_CTX_ARROW:65,GENTYPE_CTX_COLOR:66,GENTYPE_CTX_RADIUS:67,GENTYPE_CTX_COORDS:68,GENTYPE_CTX_TEXT:69,GENTYPE_CTX_ANGLERADIUS:70,GENTYPE_CTX_DOTVISIBILITY:71,GENTYPE_CTX_FILLOPACITY:72},t.extend(t,e),e}),define("utils/type",["jxg","base/constants"],function(t,e){return t.extend(t,{isId:function(t,e){return"string"==typeof e&&!!t.objects[e]},isName:function(t,e){return"string"==typeof e&&!!t.elementsByName[e]},isGroup:function(t,e){return"string"==typeof e&&!!t.groups[e]},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isFunction:function(t){return"function"==typeof t},isArray:function(t){var e;return e=Array.isArray?Array.isArray(t):null!==t&&"object"==typeof t&&"function"==typeof t.splice&&"function"==typeof t.join},isObject:function(e){return"object"==typeof e&&!t.isArray(e)},isPoint:function(t){return"object"==typeof t?t.elementClass===e.OBJECT_CLASS_POINT:!1},exists:function(t){return function(e){return!(e===t||null===e)}}(),def:function(e,r){return t.exists(e)?e:r},str2Bool:function(e){return t.exists(e)?"boolean"==typeof e?e:t.isString(e)?"true"===e.toLowerCase():!1:!0},createEvalFunction:function(e,r,i){var s,o=[];for(s=0;i>s;s++)o[s]=t.createFunction(r[s],e,"",!0);return function(t){return o[t]()}},createFunction:function(e,r,i,s){var o=null;return t.exists(s)&&!s||!t.isString(e)?t.isFunction(e)?o=e:t.isNumber(e)?o=function(){return e}:t.isString(e)&&(o=function(){return e}):o=r.jc.snippet(e,!0,i,!0),null!==o&&(o.origin=e),o},bind:function(t,e){return function(){return t.apply(e,arguments)}},evaluate:function(e){return t.isFunction(e)?e():e},indexOf:function(e,r,i){var s,o=t.exists(i);if(Array.indexOf&&!o)return e.indexOf(r);for(s=0;e.length>s;s++)if(o&&e[s][i]===r||!o&&e[s]===r)return s;return-1},eliminateDuplicates:function(t){var e,r=t.length,i=[],s={};for(e=0;r>e;e++)s[t[e]]=0;for(e in s)s.hasOwnProperty(e)&&i.push(e);return i},swap:function(t,e,r){var i;return i=t[e],t[e]=t[r],t[r]=i,t},uniqueArray:function(e){var r,i,s,o=[];if(0===e.length)return[];for(r=0;e.length>r;r++)for(s=t.isArray(e[r]),i=r+1;e.length>i;i++)s&&t.cmpArrays(e[r],e[i])?e[r]=[]:s||e[r]!==e[i]||(e[r]="");for(i=0,r=0;e.length>r;r++)s=t.isArray(e[r]),s||""===e[r]?s&&0!==e[r].length&&(o[i]=e[r].slice(0),i+=1):(o[i]=e[r],i+=1);return e=o,o},isInArray:function(e,r){return t.indexOf(e,r)>-1},cmpArrays:function(t,e){var r;if(t===e)return!0;if(t.length!==e.length)return!1;for(r=0;t.length>r;r++)if(t[r]!==e[r])return!1;return!0},removeElementFromArray:function(t,e){var r;for(r=0;t.length>r;r++)if(t[r]===e)return t.splice(r,1),t;return t},trunc:function(e,r){return r=t.def(r,0),0===r?(e=~e,e=~e):e=e.toFixed(r),e},autoDigits:function(t){var e=Math.abs(t);return e=e>.1?t.toFixed(2):e>=.01?t.toFixed(4):e>=1e-4?t.toFixed(6):t},keys:function(t,e){var r,i=[];for(r in t)e?t.hasOwnProperty(r)&&i.push(r):i.push(r);return i},clone:function(t){var e={};return e.prototype=t,e},cloneAndCopy:function(t,e){var r,i=function(){};i.prototype=t;for(r in e)i[r]=e[r];return i},merge:function(t,e){var r,i;for(r in e)if(e.hasOwnProperty(r))if(this.isArray(e[r]))for(t[r]||(t[r]=[]),i=0;e[r].length>i;i++)t[r][i]="object"==typeof e[r][i]?this.merge(t[r][i],e[r][i]):e[r][i];else"object"==typeof e[r]?(t[r]||(t[r]={}),t[r]=this.merge(t[r],e[r])):t[r]=e[r];return t},deepCopy:function(e,r,i){var s,o,n,a;if(i=i||!1,"object"!=typeof e||null===e)return e;if(this.isArray(e))for(s=[],o=0;e.length>o;o++)n=e[o],s[o]="object"==typeof n?this.deepCopy(n):n;else{s={};for(o in e)a=i?o.toLowerCase():o,n=e[o],s[a]="object"==typeof n?this.deepCopy(n):n;for(o in r)a=i?o.toLowerCase():o,n=r[o],s[a]="object"==typeof n?t.isArray(n)||!t.exists(s[a])?this.deepCopy(n):this.deepCopy(s[a],n,i):n}return s},copyAttributes:function(e,r,i){var s,o,n,a,h,c={circle:1,curve:1,image:1,line:1,point:1,polygon:1,text:1,ticks:1,integral:1};for(n=arguments.length,s=3>n||c[i]?t.deepCopy(r.elements,null,!0):{},4>n&&this.exists(i)&&this.exists(r.layer[i])&&(s.layer=r.layer[i]),a=r,h=!0,o=2;n>o;o++){if(!t.exists(a[arguments[o]])){h=!1;break}a=a[arguments[o]]}for(h&&(s=t.deepCopy(s,a,!0)),a=e,h=!0,o=3;n>o;o++){if(!t.exists(a[arguments[o]])){h=!1;break}a=a[arguments[o]]}for(h&&this.extend(s,a,null,!0),a=r,h=!0,o=2;n>o;o++){if(!t.exists(a[arguments[o]])){h=!1;break}a=a[arguments[o]]}return h&&t.exists(a.label)&&(s.label=t.deepCopy(a.label,s.label)),s.label=t.deepCopy(r.label,s.label),s},toJSON:function(e,r){var i,s,o,n,a;if(r=t.def(r,!1),JSON.stringify&&!r)try{return n=JSON.stringify(e)}catch(h){}switch(typeof e){case"object":if(e){if(i=[],t.isArray(e)){for(o=0;e.length>o;o++)i.push(t.toJSON(e[o],r));return"["+i.join(",")+"]"}for(s in e)if(e.hasOwnProperty(s)){try{a=t.toJSON(e[s],r)}catch(c){a=""}r?i.push(s+":"+a):i.push('"'+s+'":'+a)}return"{"+i.join(",")+"} "}return"null";case"string":return"'"+e.replace(/(["'])/g,"\\$1")+"'";case"number":case"boolean":return""+e}return"0"},clearVisPropOld:function(t){return t.visPropOld={strokecolor:"",strokeopacity:"",strokewidth:"",fillcolor:"",fillopacity:"",shadow:!1,firstarrow:!1,lastarrow:!1,cssclass:"",fontsize:-1,left:-1e5,right:1e5,top:-1e5},t},isInObject:function(t,e){var r;for(r in t)if(t.hasOwnProperty(r)&&t[r]===e)return!0;return!1},escapeHTML:function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},unescapeHTML:function(t){return t.replace(/<\/?[^>]+>/gi,"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")},capitalize:function(t){return t.charAt(0).toUpperCase()+t.substring(1).toLowerCase()},trimNumber:function(t){return t=t.replace(/^0+/,""),t=t.replace(/0+$/,""),("."===t[t.length-1]||","===t[t.length-1])&&(t=t.slice(0,-1)),("."===t[0]||","===t[0])&&(t="0"+t),t},trim:function(t){return t=t.replace(/^\s+/,""),t=t.replace(/\s+$/,"")},sanitizeHTML:function(t,e){return"function"==typeof html_sanitize&&e?html_sanitize(t,function(){},function(t){return t}):t.replace(/</g,"&lt;").replace(/>/g,"&gt;")},evalSlider:function(t){return t.type===e.OBJECT_TYPE_GLIDER&&"function"==typeof t.Value&&(t=t.Value()),t}}),t}),define("utils/env",["jxg","utils/type"],function(t,e){return t.extend(t,{touchProperty:"touches",isBrowser:"object"==typeof window&&"object"==typeof document,supportsVML:function(){return this.isBrowser&&!!document.namespaces},supportsSVG:function(){return this.isBrowser&&document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")},supportsCanvas:function(){var t,e=!1;if(this.isNode())try{t="object"==typeof module?module.require("canvas"):require("canvas"),e=!0}catch(r){}return e||this.isBrowser&&!!document.createElement("canvas").getContext},isNode:function(){return!this.isBrowser&&("object"==typeof module&&!!module.exports||"object"==typeof global&&global.requirejsVars&&!global.requirejsVars.isBrowser)},isWebWorker:function(){return!this.isBrowser&&"object"==typeof self&&"function"==typeof self.postMessage},supportsPointerEvents:function(){return t.isBrowser&&window.navigator&&(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)},isTouchDevice:function(){return this.isBrowser&&document.documentElement.hasOwnProperty("ontouchstart")},isAndroid:function(){return e.exists(navigator)&&navigator.userAgent.toLowerCase().indexOf("android")>-1},isWebkitAndroid:function(){return this.isAndroid()&&navigator.userAgent.indexOf(" AppleWebKit/")>-1},isApple:function(){return e.exists(navigator)&&(navigator.userAgent.indexOf("iPad")>-1||navigator.userAgent.indexOf("iPhone")>-1)},isWebkitApple:function(){return this.isApple()&&navigator.userAgent.search(/Mobile\/[0-9A-Za-z\.]*Safari/)>-1},isMetroApp:function(){return"object"==typeof window&&window.clientInformation&&window.clientInformation.appName&&window.clientInformation.appName.indexOf("MSAppHost")>-1},ieVersion:function(){var t,e,r,i=3;if("object"!=typeof document)return 0;e=document.createElement("div"),r=e.getElementsByTagName("i");do e.innerHTML="<!--[if gt IE "+ ++i+"]><"+"i><"+"/i><![endif]-->";while(r[0]);return i>4?i:t}(),getDimensions:function(r){var i,s,o,n,a,h,c,l;if(!t.isBrowser||null===r)return{width:500,height:500};if(i=document.getElementById(r),!e.exists(i))throw Error("\nJSXGraph: HTML container element '"+r+"' not found.");return s=i.style.display,"none"!==s&&null!==s?{width:i.offsetWidth,height:i.offsetHeight}:(o=i.style,n=o.visibility,a=o.position,h=o.display,o.visibility="hidden",o.position="absolute",o.display="block",c=i.clientWidth,l=i.clientHeight,o.display=h,o.position=a,o.visibility=n,{width:c,height:l})},addEvent:function(t,r,i,s){var o=function(){return i.apply(s,arguments)};o.origin=i,s["x_internal"+r]=s["x_internal"+r]||[],s["x_internal"+r].push(o),e.exists(t)&&e.exists(t.addEventListener)&&t.addEventListener(r,o,!1),e.exists(t)&&e.exists(t.attachEvent)&&t.attachEvent("on"+r,o)},removeEvent:function(r,i,s,o){var n;if(!e.exists(o))return t.debug("no such owner"),void 0;if(!e.exists(o["x_internal"+i]))return t.debug("no such type: "+i),void 0;if(!e.isArray(o["x_internal"+i]))return t.debug("owner[x_internal + "+i+"] is not an array"),void 0;if(n=e.indexOf(o["x_internal"+i],s,"origin"),-1===n)return t.debug("no such event function in internal list: "+s),void 0;try{e.exists(r)&&e.exists(r.removeEventListener)&&r.removeEventListener(i,o["x_internal"+i][n],!1),e.exists(r)&&e.exists(r.detachEvent)&&r.detachEvent("on"+i,o["x_internal"+i][n])}catch(a){t.debug("event not registered in browser: ("+i+" -- "+s+")")}o["x_internal"+i].splice(n,1)},removeAllEvents:function(e,r,i){var s,o;if(i["x_internal"+r]){for(o=i["x_internal"+r].length,s=o-1;s>=0;s--)t.removeEvent(e,r,i["x_internal"+r][s].origin,i);i["x_internal"+r].length>0&&t.debug("removeAllEvents: Not all events could be removed.")}},getPosition:function(r,i){var s,o,n,a=0,h=0;if(r||(r=window.event),n=r[t.touchProperty],e.exists(i))if(-1===i){for(o=n.length,s=0;o>s;s++)if(n[s]){r=n[s];break}}else r=n[i];return r.pageX||r.pageY?(a=r.pageX,h=r.pageY):(r.clientX||r.clientY)&&(a=r.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h=r.clientY+document.body.scrollTop+document.documentElement.scrollTop),[a,h]},getOffset:function(t){var e,r=t,i=t,s=r.offsetLeft-r.scrollLeft,o=r.offsetTop-r.scrollTop;for(e=this.getCSSTransform([s,o],r),s=e[0],o=e[1],r=r.offsetParent;r;){for(s+=r.offsetLeft,o+=r.offsetTop,r.offsetParent&&(s+=r.clientLeft-r.scrollLeft,o+=r.clientTop-r.scrollTop),e=this.getCSSTransform([s,o],r),s=e[0],o=e[1],i=i.parentNode;i!==r;)s+=i.clientLeft-i.scrollLeft,o+=i.clientTop-i.scrollTop,e=this.getCSSTransform([s,o],i),s=e[0],o=e[1],i=i.parentNode;r=r.offsetParent}return[s,o]},getStyle:function(e,r){var i;return window.getComputedStyle?i=document.defaultView.getComputedStyle(e,null).getPropertyValue(r):e.currentStyle&&t.ieVersion>=9?i=e.currentStyle[r]:e.style&&(r=r.replace(/-([a-z]|[0-9])/gi,function(t,e){return e.toUpperCase()}),i=e.style[r]),i},getCSSTransform:function(t,r){var i,s,o,n,a,h,c,l,d=["transform","webkitTransform","MozTransform","msTransform","oTransform"];for(h=d.length,i=0,o="";h>i;i++)if(e.exists(r.style[d[i]])){o=r.style[d[i]];break}if(""!==o&&(a=o.indexOf("("),a>0)){for(h=o.length,n=o.substring(a+1,h-1),l=n.split(","),s=0,c=l.length;c>s;s++)l[s]=parseFloat(l[s]);0===o.indexOf("matrix")?(t[0]+=l[4],t[1]+=l[5]):0===o.indexOf("translateX")?t[0]+=l[0]:0===o.indexOf("translateY")?t[1]+=l[0]:0===o.indexOf("translate")&&(t[0]+=l[0],t[1]+=l[1])}return t},getCSSTransformMatrix:function(t){var r,i,s,o,n,a,h,c,l=["transform","webkitTransform","MozTransform","msTransform","oTransform"],d=[[1,0,0],[0,1,0],[0,0,1]];for(a=l.length,r=0,s="";a>r;r++)if(e.exists(t.style[l[r]])){s=t.style[l[r]];break}if(""!==s&&(n=s.indexOf("("),n>0)){for(a=s.length,o=s.substring(n+1,a-1),c=o.split(","),i=0,h=c.length;h>i;i++)c[i]=parseFloat(c[i]);0===s.indexOf("matrix")?d=[[1,0,0],[0,c[0],c[1]],[0,c[2],c[3]]]:0===s.indexOf("scaleX")?d[1][1]=c[0]:0===s.indexOf("scaleY")?d[2][2]=c[0]:0===s.indexOf("scale")&&(d[1][1]=c[0],d[2][2]=c[1])}return d},timedChunk:function(t,e,r,i){var s=t.concat(),o=function(){var n=+new Date;do e.call(r,s.shift());while(s.length>0&&300>+new Date-n);s.length>0?window.setTimeout(o,1):i(t)};window.setTimeout(o,1)}}),t}),define("utils/xml",["jxg","utils/type"],function(t,e){return t.XML={cleanWhitespace:function(t){for(var r=t.firstChild;e.exists(r);)3!==r.nodeType||/\S/.test(r.nodeValue)?1===r.nodeType&&this.cleanWhitespace(r):t.removeChild(r),r=r.nextSibling},parse:function(t){var e,r,i;return i="function"==typeof DOMParser||"object"==typeof DOMParser?DOMParser:function(){this.parseFromString=function(t){var e;return"function"==typeof ActiveXObject&&(e=new ActiveXObject("MSXML.DomDocument"),e.loadXML(t)),e}},e=new i,r=e.parseFromString(t,"text/xml"),this.cleanWhitespace(r),r}},t.XML}),define("utils/event",["jxg","utils/type"],function(t,e){return t.EventEmitter={eventHandlers:{},suspended:{},trigger:function(t,e){var r,i,s,o,n,a;for(n=t.length,i=0;n>i;i++)if(o=this.eventHandlers[t[i]],!this.suspended[t[i]]){if(this.suspended[t[i]]=!0,o)for(a=o.length,r=0;a>r;r++)s=o[r],s.handler.apply(s.context,e);this.suspended[t[i]]=!1}return this},on:function(t,r,i){return e.isArray(this.eventHandlers[t])||(this.eventHandlers[t]=[]),i=e.def(i,this),this.eventHandlers[t].push({handler:r,context:i}),this},off:function(t,r){var i;return t&&e.isArray(this.eventHandlers[t])?(r?(i=e.indexOf(this.eventHandlers[t],r,"handler"),i>-1&&this.eventHandlers[t].splice(i,1),0===this.eventHandlers[t].length&&delete this.eventHandlers[t]):delete this.eventHandlers[t],this):this},eventify:function(t){t.eventHandlers={},t.on=this.on,t.off=this.off,t.triggerEventHandlers=this.trigger,t.trigger=this.trigger,t.suspended={}}},t.EventEmitter}),define("math/math",["jxg"],function(t){var e,r=function(t){var r,i;return t.memo?t.memo:(r={},i=Array.prototype.join,t.memo=function(){var s=i.call(arguments);return r[s]!==e?r[s]:r[s]=t.apply(this,arguments)},t.memo)};return t.Math={eps:1e-6,mod:function(t,e){return t-Math.floor(t/e)*e},vector:function(t,e){var r,i;for(e=e||0,r=[],i=0;t>i;i++)r[i]=e;return r},matrix:function(t,e,r){var i,s,o;for(r=r||0,e=e||t,i=[],s=0;t>s;s++)for(i[s]=[],o=0;e>o;o++)i[s][o]=r;return i},identity:function(t,r){var i,s;for(r===e&&"number"!=typeof r&&(r=t),i=this.matrix(t,r),s=0;Math.min(t,r)>s;s++)i[s][s]=1;return i},frustum:function(t,e,r,i,s,o){var n=this.matrix(4,4);return n[0][0]=2*s/(e-t),n[0][1]=0,n[0][2]=(e+t)/(e-t),n[0][3]=0,n[1][0]=0,n[1][1]=2*s/(i-r),n[1][2]=(i+r)/(i-r),n[1][3]=0,n[2][0]=0,n[2][1]=0,n[2][2]=-(o+s)/(o-s),n[2][3]=-(2*o*s)/(o-s),n[3][0]=0,n[3][1]=0,n[3][2]=-1,n[3][3]=0,n},projection:function(t,e,r,i){var s=r*Math.tan(t/2),o=s*e;return this.frustum(-o,o,-s,s,r,i)},matVecMult:function(t,e){var r,i,s,o=t.length,n=e.length,a=[];if(3===n)for(r=0;o>r;r++)a[r]=t[r][0]*e[0]+t[r][1]*e[1]+t[r][2]*e[2];else for(r=0;o>r;r++){for(i=0,s=0;n>s;s++)i+=t[r][s]*e[s];a[r]=i}return a},matMatMult:function(t,e){var r,i,s,o,n=t.length,a=n>0?e[0].length:0,h=e.length,c=this.matrix(n,a);for(r=0;n>r;r++)for(i=0;a>i;i++){for(s=0,o=0;h>o;o++)s+=t[r][o]*e[o][i];c[r][i]=s}return c},transpose:function(t){var e,r,i,s,o;for(s=t.length,o=t.length>0?t[0].length:0,e=this.matrix(o,s),r=0;o>r;r++)for(i=0;s>i;i++)e[r][i]=t[i][r];return e},inverse:function(t){var e,r,i,s,o,n,a,h=t.length,c=[],l=[],d=[];for(e=0;h>e;e++){for(c[e]=[],r=0;h>r;r++)c[e][r]=t[e][r];l[e]=e}for(r=0;h>r;r++){for(o=Math.abs(c[r][r]),n=r,e=r+1;h>e;e++)Math.abs(c[e][r])>o&&(o=Math.abs(c[e][r]),n=e);if(this.eps>=o)return[];if(n>r){for(i=0;h>i;i++)a=c[r][i],c[r][i]=c[n][i],c[n][i]=a;a=l[r],l[r]=l[n],l[n]=a}for(s=1/c[r][r],e=0;h>e;e++)c[e][r]*=s;for(c[r][r]=s,i=0;h>i;i++)if(i!==r){for(e=0;h>e;e++)e!==r&&(c[e][i]-=c[e][r]*c[r][i]);c[r][i]=-s*c[r][i]}}for(e=0;h>e;e++){for(i=0;h>i;i++)d[l[i]]=c[e][i];for(i=0;h>i;i++)c[e][i]=d[i]}return c},innerProduct:function(t,r,i){var s,o=0;for((i===e||"number"!=typeof i)&&(i=t.length),s=0;i>s;s++)o+=t[s]*r[s];return o},crossProduct:function(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]},factorial:r(function(t){return 0>t?0/0:(t=Math.floor(t),0===t||1===t?1:t*this.factorial(t-1))}),binomial:r(function(t,e){var r,i;if(e>t||0>e)return 0/0;if(e=Math.round(e),t=Math.round(t),0===e||e===t)return 1;for(r=1,i=0;e>i;i++)r*=t-i,r/=i+1;return r}),cosh:function(t){return.5*(Math.exp(t)+Math.exp(-t))},sinh:function(t){return.5*(Math.exp(t)-Math.exp(-t))},pow:function(t,e){return 0===t?0===e?1:0:Math.floor(e)===e?Math.pow(t,e):t>0?Math.exp(e*Math.log(Math.abs(t))):0/0},squampow:function(t,e){var r;if(Math.floor(e)===e){for(r=1,0>e&&(t=1/t,e*=-1);0!==e;)1&e&&(r*=t),e>>=1,t*=t;return r}return this.pow(t,e)},normalize:function(t){var e,r,i=2*t[3],s=t[4]/i;return t[5]=s,t[6]=-t[1]/i,t[7]=-t[2]/i,1/0===s||isNaN(s)?(e=Math.sqrt(t[1]*t[1]+t[2]*t[2]),t[0]/=e,t[1]/=e,t[2]/=e,t[3]=0,t[4]=1):Math.abs(s)>=1?(t[0]=(t[6]*t[6]+t[7]*t[7]-s*s)/(2*s),t[1]=-t[6]/s,t[2]=-t[7]/s,t[3]=1/(2*s),t[4]=1):(r=0>=s?-1:1,t[0]=.5*r*(t[6]*t[6]+t[7]*t[7]-s*s),t[1]=-r*t[6],t[2]=-r*t[7],t[3]=r/2,t[4]=r*s),t},toGL:function(t){var e,r,i;if(e="function"==typeof Float32Array?new Float32Array(16):Array(16),4!==t.length&&4!==t[0].length)return e;for(r=0;4>r;r++)for(i=0;4>i;i++)e[r+4*i]=t[r][i];return e}},t.Math}),define("base/coords",["jxg","base/constants","utils/event","math/math"],function(t,e,r,i){return t.Coords=function(t,e,i){this.board=i,this.usrCoords=[],this.scrCoords=[],r.eventify(this),this.setCoordinates(t,e)},t.extend(t.Coords.prototype,{normalizeUsrCoords:function(){var t=i.eps;Math.abs(this.usrCoords[0])>t&&(this.usrCoords[1]/=this.usrCoords[0],this.usrCoords[2]/=this.usrCoords[0],this.usrCoords[0]=1)},usr2screen:function(t){var e=Math.round,r=this.board,i=this.usrCoords,s=r.origin.scrCoords;null===t||t?(this.scrCoords[0]=e(i[0]),this.scrCoords[1]=e(i[0]*s[1]+i[1]*r.unitX),this.scrCoords[2]=e(i[0]*s[2]-i[2]*r.unitY)):(this.scrCoords[0]=i[0],this.scrCoords[1]=i[0]*s[1]+i[1]*r.unitX,this.scrCoords[2]=i[0]*s[2]-i[2]*r.unitY)},screen2usr:function(){var t=this.board.origin.scrCoords,e=this.scrCoords,r=this.board;this.usrCoords[0]=1,this.usrCoords[1]=(e[1]-t[1])/r.unitX,this.usrCoords[2]=(t[2]-e[2])/r.unitY},distance:function(t,r){var s,o,n=0,a=this.usrCoords,h=this.scrCoords;if(t===e.COORDS_BY_USER){if(s=r.usrCoords,o=a[0]-s[0],n=o*o,n>i.eps)return Number.POSITIVE_INFINITY;o=a[1]-s[1],n+=o*o,o=a[2]-s[2],n+=o*o}else s=r.scrCoords,o=h[1]-s[1],n+=o*o,o=h[2]-s[2],n+=o*o;return Math.sqrt(n)},setCoordinates:function(t,r,i){var s=this.usrCoords,o=this.scrCoords,n=[s[0],s[1],s[2]],a=[o[0],o[1],o[2]];return t===e.COORDS_BY_USER?(2===r.length?(s[0]=1,s[1]=r[0],s[2]=r[1]):(s[0]=r[0],s[1]=r[1],s[2]=r[2],this.normalizeUsrCoords()),this.usr2screen(i)):(o[1]=r[0],o[2]=r[1],this.screen2usr()),(a[1]!==o[1]||a[2]!==o[2])&&this.triggerEventHandlers(["update"],[n,a]),this},__evt__update:function(){},__evt:function(){}}),t.Coords}),define("utils/color",["jxg","utils/type","math/math"],function(t,e,r){var i={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},s=[{re:/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([\d\.]{1,3})\s*\)\s*$/,example:["rgba(123, 234, 45, 0.5)","rgba(255,234,245,1.0)"],process:function(t){return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}},{re:/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}];return t.rgbParser=function(t,r,o){var n,a,h,c,l,d,u,p,f,b=t,m=!1;if(!e.exists(t))return[];if(e.exists(r)&&e.exists(o)&&(b=[t,r,o]),n=b,e.isArray(n)){for(d=0;3>d;d++)m=m||/\./.test(""+b[d]);for(d=0;3>d;d++)m=m&&b[d]>=0&&1>=b[d];return m?[Math.ceil(255*b[0]),Math.ceil(255*b[1]),Math.ceil(255*b[2])]:b}for("string"==typeof b&&(n=b),"#"===n.charAt(0)&&(n=n.substr(1,6)),n=n.replace(/ /g,"").toLowerCase(),n=i[n]||n,d=0;s.length>d;d++)h=s[d].re,c=s[d].process,l=h.exec(n),l&&(a=c(l),u=a[0],p=a[1],f=a[2]);return isNaN(u)||isNaN(p)||isNaN(f)?[]:(u=0>u||isNaN(u)?0:u>255?255:u,p=0>p||isNaN(p)?0:p>255?255:p,f=0>f||isNaN(f)?0:f>255?255:f,[u,p,f])},t.rgb2css=function(e,r,i){var s;return s=t.rgbParser(e,r,i),"rgb("+s[0]+", "+s[1]+", "+s[2]+")"},t.rgb2hex=function(e,r,i){var s,o,n;return s=t.rgbParser(e,r,i),o=s[1],n=s[2],s=s[0],s=s.toString(16),o=o.toString(16),n=n.toString(16),1===s.length&&(s="0"+s),1===o.length&&(o="0"+o),1===n.length&&(n="0"+n),"#"+s+o+n},t.hex2rgb=function(e){var r;return r=t.rgbParser(e),"rgb("+r[0]+", "+r[1]+", "+r[2]+")"},t.hsv2rgb=function(t,e,i){var s,o,n,a,h,c,l,d,u;if(t=(t%360+360)%360,0===e){if(!(isNaN(t)||r.eps>t))return"#ffffff";s=i,o=i,n=i}else switch(c=t>=360?0:t,c/=60,h=Math.floor(c),a=c-h,l=i*(1-e),d=i*(1-e*a),u=i*(1-e*(1-a)),h){case 0:s=i,o=u,n=l;break;case 1:s=d,o=i,n=l;break;case 2:s=l,o=i,n=u;break;case 3:s=l,o=d,n=i;break;case 4:s=u,o=l,n=i;break;case 5:s=i,o=l,n=d}return s=Math.round(255*s).toString(16),s=2===s.length?s:1===s.length?"0"+s:"00",o=Math.round(255*o).toString(16),o=2===o.length?o:1===o.length?"0"+o:"00",n=Math.round(255*n).toString(16),n=2===n.length?n:1===n.length?"0"+n:"00",["#",s,o,n].join("")},t.rgb2hsv=function(e,r,i){var s,o,n,a,h,c,l,d,u,p,f,b,m;return s=t.rgbParser(e,r,i),o=s[1],n=s[2],s=s[0],a=s/255,h=o/255,c=n/255,b=Math.max(s,o,n),m=Math.min(s,o,n),l=b/255,d=m/255,f=l,p=0,f>0&&(p=(f-d)/f),u=1/(l-d),p>0&&(u=b===s?(h-c)*u:b===o?2+(c-a)*u:4+(a-h)*u),u*=60,0>u&&(u+=360),b===m&&(u=0),[u,p,f]},t.rgb2LMS=function(e,r,i){var s,o,n,a,h,c,l,d=[[.05059983,.08585369,.0095242],[.01893033,.08925308,.01370054],[.00292202,.00975732,.07145979]];return s=t.rgbParser(e,r,i),o=s[1],n=s[2],s=s[0],s=Math.pow(s,.476190476),o=Math.pow(o,.476190476),n=Math.pow(n,.476190476),a=s*d[0][0]+o*d[0][1]+n*d[0][2],h=s*d[1][0]+o*d[1][1]+n*d[1][2],c=s*d[2][0]+o*d[2][1]+n*d[2][2],l=[a,h,c],l.l=a,l.m=h,l.s=c,l},t.LMS2rgb=function(t,e,r){var i,s,o,n,a=[[30.830854,-29.832659,1.610474],[-6.481468,17.715578,-2.532642],[-.37569,-1.199062,14.273846]],h=function(t){for(var e=127,r=64;r>0;){if(Math.pow(e,.476190476)>t)e-=r;else{if(Math.pow(e+1,.476190476)>t)return e;e+=r}r/=2}return 254===e&&t>13.994955247?255:e};return i=t*a[0][0]+e*a[0][1]+r*a[0][2],s=t*a[1][0]+e*a[1][1]+r*a[1][2],o=t*a[2][0]+e*a[2][1]+r*a[2][2],i=h(i),s=h(s),o=h(o),n=[i,s,o],n.r=i,n.g=s,n.b=o,n},t.rgba2rgbo=function(t){var e;return 9===t.length&&"#"===t.charAt(0)?(e=parseInt(t.substr(7,2).toUpperCase(),16)/255,t=t.substr(0,7)):e=1,[t,e]},t.rgbo2rgba=function(t,e){var r;return"none"===t?t:(r=Math.round(255*e).toString(16),1===r.length&&(r="0"+r),t+r)},t.rgb2bw=function(e){var r,i,s,o="0123456789ABCDEF";return"none"===e?e:(s=t.rgbParser(e),r=Math.floor(.3*s[0]+.59*s[1]+.11*s[2]),i=o.charAt(15&r>>4)+o.charAt(15&r),e="#"+i+i+i)},t.rgb2cb=function(e,r){var i,s,o,n,a,h,c,l,d,u,p,f,b,m="0123456789ABCDEF";if("none"===e)return e;switch(a=t.rgb2LMS(e),s=a[0],o=a[1],n=a[2],r=r.toLowerCase()){case"protanopia":c=-.06150039994295001,l=.08277001656812001,d=-.013200141220000003,u=.05858939668799999,p=-.07934519995360001,f=.013289415272000003,b=.6903216543277437,h=n/o,s=b>h?-(l*o+d*n)/c:-(p*o+f*n)/u;break;case"tritanopia":c=-.00058973116217,l=.007690316482,d=-.01011703519052,u=.025495080838999994,p=-.0422740347,f=.017005316784,b=.8349489908460004,h=o/s,n=b>h?-(c*s+l*o)/d:-(u*s+p*o)/f;break;default:c=-.06150039994295001,l=.08277001656812001,d=-.013200141220000003,u=.05858939668799999,p=-.07934519995360001,f=.013289415272000003,b=.5763833686400911,h=n/s,o=b>h?-(c*s+d*n)/l:-(u*s+f*n)/p
}return i=t.LMS2rgb(s,o,n),h=m.charAt(15&i[0]>>4)+m.charAt(15&i[0]),e="#"+h,h=m.charAt(15&i[1]>>4)+m.charAt(15&i[1]),e+=h,h=m.charAt(15&i[2]>>4)+m.charAt(15&i[2]),e+=h},t}),define("options",["jxg","base/constants","math/math","utils/color","utils/type"],function(t,e,r,i,s){return t.Options={jc:{enabled:!0,compile:!0},board:{boundingBox:[-5,5,5,-5],zoomFactor:1,zoomX:1,zoomY:1,showCopyright:!0,axis:!1,showNavigation:!0,keepAspectRatio:!1,takeFirst:!1,takeSizeFromFile:!1,renderer:"svg",animationDelay:35,registerEvents:!0,zoom:{factorX:1.25,factorY:1.25,wheel:!1,needshift:!1,eps:.1},pan:{needShift:!0,needTwoFingers:!0,enabled:!0}},navbar:{strokeColor:"#aaaaaa",fillColor:"#f5f5f5",padding:"2px",position:"absolute",fontSize:"10px",cursor:"pointer",zIndex:"100",right:"5px",bottom:"5px"},elements:{strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",fillColor:"red",highlightFillColor:"none",strokeOpacity:1,highlightStrokeOpacity:1,fillOpacity:1,highlightFillOpacity:1,strokeWidth:2,highlightStrokeWidth:2,fixed:!1,frozen:!1,withLabel:!1,visible:!0,priv:!1,layer:0,dash:0,shadow:!1,trace:!1,traceAttributes:{},highlight:!0,needsRegularUpdate:!0,snapToGrid:!1,scalable:!0,draft:{draft:!1,strokeColor:"#565656",fillColor:"#565656",strokeOpacity:.8,fillOpacity:.8,strokeWidth:1},isLabel:!1},ticks:{drawLabels:!1,label:{},anchor:"left",drawZero:!1,insertTicks:!1,minTicksDistance:50,minorHeight:4,majorHeight:10,tickEndings:[1,1],minorTicks:4,scale:1,scaleSymbol:"",labels:[],ticksDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"black",highlightStrokeColor:"#888888"},hash:{drawLabels:!1,drawZero:!0,majorHeight:20,anchor:"middle",strokeWidth:2,strokeColor:"blue",ticksDistance:.2},precision:{touch:30,touchMax:100,mouse:4,epsilon:1e-4,hasPoint:4},layer:{numlayers:20,text:9,point:9,glider:9,arc:8,line:7,circle:6,curve:5,turtle:5,polygon:3,sector:3,angle:3,integral:3,axis:2,grid:1,image:0,trace:0},angle:{withLabel:!0,radius:.5,type:"sector",orthoType:"square",orthoSensitivity:1,fillColor:"#FF7F00",highlightFillColor:"#FF7F00",strokeColor:"#FF7F00",fillOpacity:.3,highlightFillOpacity:.3,radiuspoint:{withLabel:!1,visible:!1,name:""},pointsquare:{withLabel:!1,visible:!1,name:""},dot:{visible:!1,strokeColor:"none",fillColor:"black",size:2,face:"o",withLabel:!1,name:""},label:{position:"top",offset:[0,0],strokeColor:"#0000FF"}},arc:{label:{},firstArrow:!1,lastArrow:!1,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",useDirection:!1},axis:{name:"",needsRegularUpdate:!1,strokeWidth:1,strokeColor:"#666666",highlightStrokeWidth:1,highlightStrokeColor:"#888888",withTicks:!0,straightFirst:!0,straightLast:!0,lastArrow:!0,withLabel:!1,scalable:!1,ticks:{label:{offset:[4,-9],parse:!1},needsRegularUpdate:!1,strokeWidth:1,strokeColor:"#666666",highlightStrokeColor:"#888888",drawLabels:!0,drawZero:!1,insertTicks:!0,minTicksDistance:10,minorHeight:10,majorHeight:-1,tickEndings:[0,1],minorTicks:4,ticksDistance:1,strokeOpacity:.25},point1:{needsRegularUpdate:!1},point2:{needsRegularUpdate:!1},label:{position:"lft",offset:[10,-20]}},bisector:{strokeColor:"#000000",point:{visible:!1,fixed:!1,withLabel:!1,name:""}},bisectorlines:{line1:{strokeColor:"black"},line2:{strokeColor:"black"}},chart:{chartStyle:"line",colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"],highlightcolors:null,fillcolor:null,highlightonsector:!1,highlightbysize:!1,label:{}},circle:{hasInnerPoints:!1,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:!1,withLabel:!1,fixed:!1,name:""},label:{position:"urt"}},circumcircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:!1,fixed:!1,withLabel:!1,name:""}},circumcirclearc:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:!1,withLabel:!1,fixed:!1,name:""}},circumcirclesector:{useDirection:!0,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:.3,highlightFillOpacity:.3,strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",point:{visible:!1,fixed:!1,withLabel:!1,name:""}},conic:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",foci:{fixed:!1,visible:!1,withLabel:!1,name:""}},curve:{strokeWidth:1,strokeColor:"#0000ff",fillColor:"none",fixed:!0,handDrawing:!1,curveType:null,RDPsmoothing:!1,numberPointsHigh:1600,numberPointsLow:400,doAdvancedPlot:!0,label:{position:"lft"}},glider:{label:{}},grid:{needsRegularUpdate:!1,hasGrid:!1,gridX:1,gridY:1,strokeColor:"#C0C0C0",strokeOpacity:.5,strokeWidth:1,dash:0,snapToGrid:!1,snapSizeX:10,snapSizeY:10},image:{imageString:null,fillOpacity:1,cssClass:"JXGimage",highlightCssClass:"JXGimageHighlight",rotate:0},incircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:!1,fixed:!1,withLabel:!1,name:""}},inequality:{fillColor:"red",fillOpacity:.2,strokeColor:"none",inverse:!1},infobox:{fontSize:12,isLabel:!1,strokeColor:"#bbbbbb",display:"html",anchorX:"left",anchorY:"middle",cssClass:"JXGinfobox",rotate:0,visible:!0,parse:!1},integral:{withLabel:!0,strokeWidth:0,strokeOpacity:0,fillOpacity:.8,curveLeft:{visible:!0,layer:9},baseLeft:{visible:!1,fixed:!1,withLabel:!1,name:""},curveRight:{visible:!0,layer:9},baseRight:{visible:!1,fixed:!1,withLabel:!1,name:""},label:{fontSize:20}},intersection:{alwaysIntersect:!0},label:{strokeColor:"black",highlightStrokeOpacity:1,highlightStrokeColor:"#C3D9FF",fixed:!0,position:"urt",offset:[10,10]},legend:{style:"vertical",labels:["1","2","3","4","5","6","7","8"],colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"]},line:{firstArrow:!1,lastArrow:!1,straightFirst:!0,straightLast:!0,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#888888",withTicks:!1,point1:{visible:!1,withLabel:!1,fixed:!1,name:""},point2:{visible:!1,withLabel:!1,fixed:!1,name:""},ticks:{drawLabels:!0,label:{offset:[4,-9]},drawZero:!1,insertTicks:!1,minTicksDistance:50,maxTicksDistance:300,minorHeight:4,majorHeight:-1,minorTicks:4,defaultDistance:1,strokeOpacity:.3},label:{position:"llft"},snapToGrid:!1,snapSizeX:1,snapSizeY:1},locus:{translateToOrigin:!1,translateTo10:!1,stretch:!1,toOrigin:null,to10:null},normal:{strokeColor:"#000000",point:{visible:!1,fixed:!1,withLabel:!1,name:""}},orthogonalprojection:{},parallel:{strokeColor:"#000000",point:{visible:!1,fixed:!1,withLabel:!1,name:""}},perpendicular:{strokeColor:"#000000",straightFirst:!0,straightLast:!0},perpendicularsegment:{strokeColor:"#000000",straightFirst:!1,straightLast:!1,point:{visible:!1,fixed:!0,withLabel:!1,name:""}},point:{withLabel:!0,label:{},style:5,face:"o",size:3,fillColor:"#ff0000",highlightFillColor:"#EEEEEE",strokeWidth:2,strokeColor:"#ff0000",highlightStrokeColor:"#C3D9FF",zoom:!1,showInfobox:!0,infoboxDigits:"auto",draft:!1,attractors:[],attractorDistance:0,snatchDistance:0,snapToGrid:!1,snapSizeX:1,snapSizeY:1,snapToPoints:!1},polygon:{hasInnerPoints:!1,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:.3,highlightFillOpacity:.3,withLines:!0,borders:{withLabel:!1,strokeWidth:1,highlightStrokeWidth:1,layer:5,label:{position:"top"}},vertices:{withLabel:!0,strokeColor:"#ff0000",fillColor:"#ff0000",fixed:!0},label:{offset:[0,0]}},prescribedangle:{anglepoint:{size:2,visible:!1,withLabel:!1}},riemannsum:{withLabel:!1,fillOpacity:.3,fillColor:"#ffff00"},sector:{fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:.3,highlightFillOpacity:.3,radiuspoint:{visible:!1,withLabel:!1},center:{visible:!1,withLabel:!1},anglepoint:{visible:!1,withLabel:!1},label:{offset:[0,0]}},segment:{label:{position:"top"}},semicircle:{midpoint:{visible:!1,withLabel:!1,fixed:!1,name:""}},slider:{snapWidth:-1,precision:2,firstArrow:!1,lastArrow:!1,withTicks:!0,withLabel:!0,layer:9,showInfobox:!1,name:"",visible:!0,strokeColor:"#000000",highlightStrokeColor:"#888888",fillColor:"#ffffff",highlightFillColor:"none",size:6,point1:{needsRegularUpdate:!1,showInfobox:!1,withLabel:!1,visible:!1,fixed:!0,name:""},point2:{needsRegularUpdate:!1,showInfobox:!1,withLabel:!1,visible:!1,fixed:!0,name:""},baseline:{needsRegularUpdate:!1,name:"",strokeWidth:1,strokeColor:"#000000",highlightStrokeColor:"#888888"},ticks:{needsRegularUpdate:!1,drawLabels:!1,drawZero:!0,insertTicks:!0,minorHeight:4,majorHeight:10,minorTicks:0,defaultDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"#000000"},highline:{strokeWidth:3,name:"",strokeColor:"#000000",highlightStrokeColor:"#888888"},label:{strokeColor:"#000000"}},tapemeasure:{strokeColor:"#000000",strokeWidth:2,highlightStrokeColor:"#000000",withTicks:!0,withLabel:!0,precision:2,point1:{strokeColor:"#000000",fillColor:"#ffffff",fillOpacity:0,highlightFillOpacity:.1,size:6,snapToPoints:!0,attractorDistance:.1,showInfobox:!1,withLabel:!1,name:""},point2:{strokeColor:"#000000",fillColor:"#ffffff",fillOpacity:0,highlightFillOpacity:.1,size:6,snapToPoints:!0,attractorDistance:.1,showInfobox:!1,withLabel:!1,name:""},ticks:{drawLabels:!1,drawZero:!0,insertTicks:!0,minorHeight:8,majorHeight:16,minorTicks:4,tickEndings:[0,1],defaultDistance:.1,strokeOpacity:1,strokeWidth:1,strokeColor:"#000000"},label:{position:"top"}},text:{fontSize:12,digits:2,parse:!0,useCaja:!1,isLabel:!1,strokeColor:"black",useASCIIMathML:!1,useMathJax:!1,display:"html",anchorX:"left",anchorY:"middle",cssClass:"JXGtext",highlightCssClass:"JXGtext",withLabel:!1,rotate:0,visible:!0},tracecurve:{strokeColor:"#000000",fillColor:"none",numberPoints:100},turtle:{strokeWidth:1,fillColor:"none",strokeColor:"#000000",arrow:{strokeWidth:2,withLabel:!1,strokeColor:"#ff0000"}},shortcuts:{color:["strokeColor","fillColor"],opacity:["strokeOpacity","fillOpacity"],highlightColor:["highlightStrokeColor","highlightFillColor"],highlightOpacity:["highlightStrokeOpacity","highlightFillOpacity"],strokeWidth:["strokeWidth","highlightStrokeWidth"]}},t.Validator=function(){var e,i=function(t){return/^[0-9]+px$/.test(t)},o=function(t){return"html"===t||"internal"===t},n=function(t){return s.isString(t)},a=function(e){return s.exists(t.normalizePointFace(e))},h=function(t){return Math.abs(t-Math.round(t))<r.eps},c=function(t){return h(t)&&t>0},l=function(t){return"vml"===t||"svg"===t||"canvas"===t||"no"===t},d=function(t){return t>0},u=function(t){return t>=0},p={},f={attractorDistance:u,color:n,defaultDistance:s.isNumber,display:o,doAdvancedPlot:!1,draft:!1,drawLabels:!1,drawZero:!1,face:a,factor:s.isNumber,fillColor:n,fillOpacity:s.isNumber,firstArrow:!1,fontSize:h,dash:h,gridX:s.isNumber,gridY:s.isNumber,hasGrid:!1,highlightFillColor:n,highlightFillOpacity:s.isNumber,highlightStrokeColor:n,highlightStrokeOpacity:s.isNumber,insertTicks:!1,lastArrow:!1,majorHeight:h,maxTicksDistance:c,minorHeight:h,minorTicks:c,minTicksDistance:c,numberPointsHigh:c,numberPointsLow:c,opacity:s.isNumber,radius:s.isNumber,RDPsmoothing:!1,renderer:l,right:i,showCopyright:!1,showInfobox:!1,showNavigation:!1,size:h,snapSizeX:d,snapSizeY:d,snapWidth:s.isNumber,snapToGrid:!1,snatchDistance:u,straightFirst:!1,straightLast:!1,stretch:!1,strokeColor:n,strokeOpacity:s.isNumber,strokeWidth:h,takeFirst:!1,takeSizeFromFile:!1,to10:!1,toOrigin:!1,translateTo10:!1,translateToOrigin:!1,useASCIIMathML:!1,useDirection:!1,useMathJax:!1,withLabel:!1,withTicks:!1,zoom:!1};for(e in f)f.hasOwnProperty(e)&&(p[e.toLowerCase()]=f[e]);return p}(),t.normalizePointFace=function(t){var e={cross:"x",x:"x",circle:"o",o:"o",square:"[]","[]":"[]",plus:"+","+":"+",diamond:"<>","<>":"<>",triangleup:"^",a:"^","^":"^",triangledown:"v",v:"v",triangleleft:"<","<":"<",triangleright:">",">":">"};return e[t]},t.useStandardOptions=function(r){var i,s,o,n,a=t.Options,h=r.hasGrid;r.options.grid.hasGrid=a.grid.hasGrid,r.options.grid.gridX=a.grid.gridX,r.options.grid.gridY=a.grid.gridY,r.options.grid.gridColor=a.grid.gridColor,r.options.grid.gridOpacity=a.grid.gridOpacity,r.options.grid.gridDash=a.grid.gridDash,r.options.grid.snapToGrid=a.grid.snapToGrid,r.options.grid.snapSizeX=a.grid.SnapSizeX,r.options.grid.snapSizeY=a.grid.SnapSizeY,r.takeSizeFromFile=a.takeSizeFromFile,n=function(t,e){t.visProp.fillcolor=e.fillColor,t.visProp.highlightfillcolor=e.highlightFillColor,t.visProp.strokecolor=e.strokeColor,t.visProp.highlightstrokecolor=e.highlightStrokeColor};for(i in r.objects)if(r.objects.hasOwnProperty(i))if(o=r.objects[i],o.elementClass===e.OBJECT_CLASS_POINT)n(o,a.point);else if(o.elementClass===e.OBJECT_CLASS_LINE)for(n(o,a.line),s=0;o.ticks.length>s;s++)o.ticks[s].majorTicks=a.line.ticks.majorTicks,o.ticks[s].minTicksDistance=a.line.ticks.minTicksDistance,o.ticks[s].visProp.minorheight=a.line.ticks.minorHeight,o.ticks[s].visProp.majorheight=a.line.ticks.majorHeight;else o.elementClass===e.OBJECT_CLASS_CIRCLE?n(o,a.circle):o.type===e.OBJECT_TYPE_ANGLE?n(o,a.angle):o.type===e.OBJECT_TYPE_ARC?n(o,a.arc):o.type===e.OBJECT_TYPE_POLYGON?n(o,a.polygon):o.type===e.OBJECT_TYPE_CONIC?n(o,a.conic):o.type===e.OBJECT_TYPE_CURVE?n(o,a.curve):o.type===e.OBJECT_TYPE_SECTOR&&(o.arc.visProp.fillcolor=a.sector.fillColor,o.arc.visProp.highlightfillcolor=a.sector.highlightFillColor,o.arc.visProp.fillopacity=a.sector.fillOpacity,o.arc.visProp.highlightfillopacity=a.sector.highlightFillOpacity);r.fullUpdate(),h&&!r.hasGrid?r.removeGrids(r):!h&&r.hasGrid&&r.create("grid",[])},t.useBlackWhiteOptions=function(e){var r=t.Options;r.point.fillColor=i.rgb2bw(r.point.fillColor),r.point.highlightFillColor=i.rgb2bw(r.point.highlightFillColor),r.point.strokeColor=i.rgb2bw(r.point.strokeColor),r.point.highlightStrokeColor=i.rgb2bw(r.point.highlightStrokeColor),r.line.fillColor=i.rgb2bw(r.line.fillColor),r.line.highlightFillColor=i.rgb2bw(r.line.highlightFillColor),r.line.strokeColor=i.rgb2bw(r.line.strokeColor),r.line.highlightStrokeColor=i.rgb2bw(r.line.highlightStrokeColor),r.circle.fillColor=i.rgb2bw(r.circle.fillColor),r.circle.highlightFillColor=i.rgb2bw(r.circle.highlightFillColor),r.circle.strokeColor=i.rgb2bw(r.circle.strokeColor),r.circle.highlightStrokeColor=i.rgb2bw(r.circle.highlightStrokeColor),r.arc.fillColor=i.rgb2bw(r.arc.fillColor),r.arc.highlightFillColor=i.rgb2bw(r.arc.highlightFillColor),r.arc.strokeColor=i.rgb2bw(r.arc.strokeColor),r.arc.highlightStrokeColor=i.rgb2bw(r.arc.highlightStrokeColor),r.polygon.fillColor=i.rgb2bw(r.polygon.fillColor),r.polygon.highlightFillColor=i.rgb2bw(r.polygon.highlightFillColor),r.sector.fillColor=i.rgb2bw(r.sector.fillColor),r.sector.highlightFillColor=i.rgb2bw(r.sector.highlightFillColor),r.curve.strokeColor=i.rgb2bw(r.curve.strokeColor),r.grid.gridColor=i.rgb2bw(r.grid.gridColor),t.useStandardOptions(e)},t.Options.normalizePointFace=t.normalizePointFace,t.Options}),define("math/numerics",["utils/type","math/math"],function(t,e){var r={rk4:{s:4,A:[[0,0,0,0],[.5,0,0,0],[0,.5,0,0],[0,0,1,0]],b:[1/6,1/3,1/3,1/6],c:[0,.5,.5,1]},heun:{s:2,A:[[0,0],[1,0]],b:[.5,.5],c:[0,1]},euler:{s:1,A:[[0]],b:[1],c:[0]}};return e.Numerics={Gauss:function(r,i){var s,o,n,a,h,c=e.eps,l=r.length>0?r[0].length:0;if(l!==i.length||l!==r.length)throw Error("JXG.Math.Numerics.Gauss: Dimensions don't match. A must be a square matrix and b must be of the same length as A.");for(a=[],h=i.slice(0,l),s=0;l>s;s++)a[s]=r[s].slice(0,l);for(o=0;l>o;o++){for(s=l-1;s>o;s--)if(Math.abs(a[s][o])>c)if(c>Math.abs(a[o][o]))t.swap(a,s,o),t.swap(h,s,o);else for(a[s][o]/=a[o][o],h[s]-=a[s][o]*h[o],n=o+1;l>n;n++)a[s][n]-=a[s][o]*a[o][n];if(c>Math.abs(a[o][o]))throw Error("JXG.Math.Numerics.Gauss(): The given matrix seems to be singular.")}return this.backwardSolve(a,h,!0),h},backwardSolve:function(t,e,r){var i,s,o,n,a;for(i=r?e:e.slice(0,e.length),s=t.length,o=t.length>0?t[0].length:0,n=s-1;n>=0;n--){for(a=o-1;a>n;a--)i[n]-=t[n][a]*i[a];i[n]/=t[n][n]}return i},gaussBareiss:function(t){var r,i,s,o,n,a,h,c,l,d=e.eps;if(h=t.length,0>=h)return 0;for(h>t[0].length&&(h=t[0].length),c=[],o=0;h>o;o++)c[o]=t[o].slice(0,h);for(i=1,s=1,r=0;h-1>r;r++){if(a=c[r][r],d>Math.abs(a)){for(o=0;h>o&&!(Math.abs(c[o][r])>=d);o++);if(o===h)return 0;for(n=r;h>n;n++)l=c[o][n],c[o][n]=c[r][n],c[r][n]=l;s=-s,a=c[r][r]}for(o=r+1;h>o;o++)for(n=r+1;h>n;n++)l=a*c[o][n]-c[o][r]*c[r][n],c[o][n]=l/i;i=a}return s*c[h-1][h-1]},det:function(t){var e=t.length;return 2===e&&2===t[0].length?t[0][0]*t[1][1]-t[1][0]*t[0][1]:this.gaussBareiss(t)},Jacobi:function(t){var r,i,s,o,n,a,h,c,l,d=e.eps,u=0,p=t.length,f=[[0,0,0],[0,0,0],[0,0,0]],b=[[0,0,0],[0,0,0],[0,0,0]],m=0;for(r=0;p>r;r++){for(i=0;p>i;i++)f[r][i]=0,b[r][i]=t[r][i],u+=Math.abs(b[r][i]);f[r][r]=1}if(1===p)return[b,f];if(0>=u)return[b,f];u/=p*p;do{for(c=0,l=0,i=1;p>i;i++)for(r=0;i>r;r++)if(o=Math.abs(b[r][i]),o>l&&(l=o),c+=o,o>=d){for(o=.5*Math.atan2(2*b[r][i],b[r][r]-b[i][i]),n=Math.sin(o),a=Math.cos(o),s=0;p>s;s++)h=b[s][r],b[s][r]=a*h+n*b[s][i],b[s][i]=-n*h+a*b[s][i],h=f[s][r],f[s][r]=a*h+n*f[s][i],f[s][i]=-n*h+a*f[s][i];for(b[r][r]=a*b[r][r]+n*b[i][r],b[i][i]=-n*b[r][i]+a*b[i][i],b[r][i]=0,s=0;p>s;s++)b[r][s]=b[s][r],b[i][s]=b[s][i]}m+=1}while(Math.abs(c)/u>d&&2e3>m);return[b,f]},NewtonCotes:function(t,e,r){var i,s,o,n=0,a=r&&"number"==typeof r.number_of_nodes?r.number_of_nodes:28,h={trapez:!0,simpson:!0,milne:!0},c=r&&r.integration_type&&h.hasOwnProperty(r.integration_type)&&h[r.integration_type]?r.integration_type:"milne",l=(t[1]-t[0])/a;switch(c){case"trapez":for(n=.5*(e(t[0])+e(t[1])),i=t[0],s=0;a-1>s;s++)i+=l,n+=e(i);n*=l;break;case"simpson":if(a%2>0)throw Error("JSXGraph:  INT_SIMPSON requires config.number_of_nodes dividable by 2.");for(o=a/2,n=e(t[0])+e(t[1]),i=t[0],s=0;o-1>s;s++)i+=2*l,n+=2*e(i);for(i=t[0]-l,s=0;o>s;s++)i+=2*l,n+=4*e(i);n*=l/3;break;default:if(a%4>0)throw Error("JSXGraph: Error in INT_MILNE: config.number_of_nodes must be a multiple of 4");for(o=.25*a,n=7*(e(t[0])+e(t[1])),i=t[0],s=0;o-1>s;s++)i+=4*l,n+=14*e(i);for(i=t[0]-3*l,s=0;o>s;s++)i+=4*l,n+=32*(e(i)+e(i+2*l));for(i=t[0]-2*l,s=0;o>s;s++)i+=4*l,n+=12*e(i);n*=2*l/45}return n},I:function(t,e){return this.NewtonCotes(t,e,{number_of_nodes:16,integration_type:"milne"})},Newton:function(r,i,s){var o,n=0,a=e.eps,h=r.apply(s,[i]),c=1;for(t.isArray(i)&&(i=i[0]);50>n&&Math.abs(h)>a;)o=this.D(r,s)(i),c+=2,Math.abs(o)>a?i-=h/o:i+=.2*Math.random()-1,h=r.apply(s,[i]),c+=1,n+=1;return i},root:function(t,e,r){return this.fzero(t,e,r)},generalizedNewton:function(t,r,i,s){var o,n,a,h,c,l,d,u,p,f,b,m,g,v,C=0;for(this.generalizedNewton.t1memo?(o=this.generalizedNewton.t1memo,n=this.generalizedNewton.t2memo):(o=i,n=s),u=t.X(o)-r.X(n),p=t.Y(o)-r.Y(n),f=u*u+p*p,b=this.D(t.X,t),m=this.D(r.X,r),g=this.D(t.Y,t),v=this.D(r.Y,r);f>e.eps&&10>C;)a=b(o),h=-m(n),c=g(o),l=-v(n),d=a*l-h*c,o-=(l*u-h*p)/d,n-=(a*p-c*u)/d,u=t.X(o)-r.X(n),p=t.Y(o)-r.Y(n),f=u*u+p*p,C+=1;return this.generalizedNewton.t1memo=o,this.generalizedNewton.t2memo=n,Math.abs(o)<Math.abs(n)?[t.X(o),t.Y(o)]:[r.X(n),r.Y(n)]},Neville:function(t){var r=[],i=function(i){return function(s,o){var n,a,h,c=e.binomial,l=t.length,d=l-1,u=0,p=0;if(!o)for(h=1,n=0;l>n;n++)r[n]=c(d,n)*h,h*=-1;for(a=s,n=0;l>n;n++){if(0===a)return t[n][i]();h=r[n]/a,a-=1,u+=t[n][i]()*h,p+=h}return u/p}},s=i("X"),o=i("Y");return[s,o,0,function(){return t.length-1}]},splineDef:function(t,e){var r,i,s,o=Math.min(t.length,e.length),n=[],a=[],h=[],c=[],l=[],d=[];if(2===o)return[0,0];for(i=0;o>i;i++)r={X:t[i],Y:e[i]},h.push(r);for(h.sort(function(t,e){return t.X-e.X}),i=0;o>i;i++)t[i]=h[i].X,e[i]=h[i].Y;for(i=0;o-1>i;i++)c.push(t[i+1]-t[i]);for(i=0;o-2>i;i++)l.push(6*(e[i+2]-e[i+1])/c[i+1]-6*(e[i+1]-e[i])/c[i]);for(n.push(2*(c[0]+c[1])),a.push(l[0]),i=0;o-3>i;i++)s=c[i+1]/n[i],n.push(2*(c[i+1]+c[i+2])-s*c[i+1]),a.push(l[i+1]-s*a[i]);for(d[o-3]=a[o-3]/n[o-3],i=o-4;i>=0;i--)d[i]=(a[i]-c[i+1]*d[i+1])/n[i];for(i=o-3;i>=0;i--)d[i+1]=d[i];return d[0]=0,d[o-1]=0,d},splineEval:function(e,r,i,s){var o,n,a,h,c,l,d,u=Math.min(r.length,i.length),p=1,f=!1,b=[];for(t.isArray(e)?(p=e.length,f=!0):e=[e],o=0;p>o;o++){if(e[o]<r[0]||r[o]>r[u-1])return 0/0;for(n=1;u>n&&!(e[o]<=r[n]);n++);n-=1,a=i[n],h=(i[n+1]-i[n])/(r[n+1]-r[n])-(r[n+1]-r[n])/6*(s[n+1]+2*s[n]),c=s[n]/2,l=(s[n+1]-s[n])/(6*(r[n+1]-r[n])),d=e[o]-r[n],b.push(a+(h+(c+l*d)*d)*d)}return f?b:b[0]},generatePolynomialTerm:function(t,e,r,i){var s,o=[];for(s=e;s>=0;s--)o=o.concat(["(",t[s].toPrecision(i),")"]),s>1?o=o.concat(["*",r,"<sup>",s,"<","/sup> + "]):1===s&&(o=o.concat(["*",r," + "]));return o.join("")},lagrangePolynomial:function(t){var e=[],r=function(r,i){var s,o,n,a,h,c,l=t.length,d=0,u=0;if(!i){for(s=0;l>s;s++){for(e[s]=1,a=t[s].X(),n=0;l>n;n++)n!==s&&(e[s]*=a-t[n].X());e[s]=1/e[s]}for(c=[],o=0;l>o;o++)c.push([1])}for(s=0;l>s;s++){if(a=t[s].X(),r===a)return t[s].Y();h=e[s]/(r-a),u+=h,d+=h*t[s].Y()}return d/u};return r.getTerm=function(){return""},r},CatmullRomSpline:function(t){var e,r=[],i={},s={},o=function(o){return function(n,a){var h,c,l=t.length;if(2>l)return 0/0;if(!a)for(i[o]=function(){return 2*t[0][o]()-t[1][o]()},s[o]=function(){return 2*t[l-1][o]()-t[l-2][o]()},e=[i].concat(t,[s]),r[o]=[],h=0;l-1>h;h++)r[o][h]=[2*e[h+1][o](),-e[h][o]()+e[h+2][o](),2*e[h][o]()-5*e[h+1][o]()+4*e[h+2][o]()-e[h+3][o](),-e[h][o]()+3*e[h+1][o]()-3*e[h+2][o]()+e[h+3][o]()];return l+=2,isNaN(n)?0/0:0>n?e[1][o]():n>=l-3?e[l-2][o]():(h=Math.floor(n),h===n?e[h][o]():(n-=h,c=r[o][h],.5*(((c[3]*n+c[2])*n+c[1])*n+c[0])))}};return[o("X"),o("Y"),0,function(){return t.length-1}]},regressionPolynomial:function(r,i,s){var o,n,a,h,c,l,d="";if(t.isPoint(r)&&"function"==typeof r.Value)n=function(){return r.Value()};else if(t.isFunction(r))n=r;else{if(!t.isNumber(r))throw Error("JSXGraph: Can't create regressionPolynomial from degree of type'"+typeof r+"'.");n=function(){return r}}if(3===arguments.length&&t.isArray(i)&&t.isArray(s))c=0;else if(2===arguments.length&&t.isArray(i)&&i.length>0&&t.isPoint(i[0]))c=1;else{if(!(2===arguments.length&&t.isArray(i)&&i.length>0&&i[0].usrCoords&&i[0].scrCoords))throw Error("JSXGraph: Can't create regressionPolynomial. Wrong parameters.");c=2}return l=function(r,l){var u,p,f,b,m,g,v,C,y,P=i.length;if(y=Math.floor(n()),!l){if(1===c)for(a=[],h=[],u=0;P>u;u++)a[u]=i[u].X(),h[u]=i[u].Y();if(2===c)for(a=[],h=[],u=0;P>u;u++)a[u]=i[u].usrCoords[1],h[u]=i[u].usrCoords[2];if(0===c)for(a=[],h=[],u=0;P>u;u++)t.isFunction(i[u])?a.push(i[u]()):a.push(i[u]),t.isFunction(s[u])?h.push(s[u]()):h.push(s[u]);for(f=[],p=0;P>p;p++)f.push([1]);for(u=1;y>=u;u++)for(p=0;P>p;p++)f[p][u]=f[p][u-1]*a[p];m=h,b=e.transpose(f),g=e.matMatMult(b,f),v=e.matVecMult(b,m),o=e.Numerics.Gauss(g,v),d=e.Numerics.generatePolynomialTerm(o,y,"x",3)}for(C=o[y],u=y-1;u>=0;u--)C=C*r+o[u];return C},l.getTerm=function(){return d},l},bezier:function(t){var e,r,i=function(i){return function(s,o){var n=3*Math.floor(s),a=s%1,h=1-a;return o||(r=3*Math.floor((t.length-1)/3),e=Math.floor(r/3)),0>s?t[0][i]():s>=e?t[r][i]():isNaN(s)?0/0:h*h*(h*t[n][i]()+3*a*t[n+1][i]())+(3*h*t[n+2][i]()+a*t[n+3][i]())*a*a}};return[i("X"),i("Y"),0,function(){return Math.floor(t.length/3)}]},bspline:function(t,e){var r,i=[],s=function(t,e){var r,i=[];for(r=0;t+e+1>r;r++)i[r]=e>r?0:t>=r?r-e+1:t-e+2;return i},o=function(t,e,r,i,s){var o,n,a,h,c,l=[];for(l[s]=t>=e[s]&&e[s+1]>t?1:0,o=2;i>=o;o++)for(n=s-o+1;s>=n;n++)a=s-o+1>=n||0>n?0:l[n],h=n>=s?0:l[n+1],c=e[n+o-1]-e[n],l[n]=0===c?0:(t-e[n])/c*a,c=e[n+o]-e[n+1],0!==c&&(l[n]+=(e[n+o]-t)/c*h);return l},n=function(n){return function(a){var h,c,l,d=t.length,u=d-1,p=e;if(0>=u)return 0/0;if(p>=u+2&&(p=u+1),0>=a)return t[0][n]();if(a>=u-p+2)return t[u][n]();for(l=Math.floor(a)+p-1,r=s(u,p),i=o(a,r,u,p,l),h=0,c=l-p+1;l>=c;c++)d>c&&c>=0&&(h+=t[c][n]()*i[c]);return h}};return[n("X"),n("Y"),0,function(){return t.length-1}]},D:function(e,r){var i=1e-5,s=1/(2*i);return t.exists(r)?function(t,o){return(e.apply(r,[t+i,o])-e.apply(r,[t-i,o]))*s}:function(t,r){return(e(t+i,r)-e(t-i,r))*s}},riemann:function(t,e,r,i,s){var o,n,a,h,c,l,d=[],u=[],p=0,f=i,b=0;if(e=Math.round(e),d[p]=f,u[p]=0,e>0)for(c=(s-i)/e,h=.01*c,o=0;e>o;o++){if("right"===r)l=t(f+c);else if("middle"===r)l=t(f+.5*c);else if("left"===r||"trapezodial"===r)l=t(f);else if("lower"===r)for(l=t(f),n=f+h;f+c>=n;n+=h)a=t(n),l>a&&(l=a);else if("upper"===r)for(l=t(f),n=f+h;f+c>=n;n+=h)a=t(n),a>l&&(l=a);else l=t(f+c*Math.random());p+=1,d[p]=f,u[p]=l,p+=1,f+=c,"trapezodial"===r&&(l=t(f)),d[p]=f,u[p]=l,p+=1,d[p]=f,u[p]=0,b+=l*c}return[d,u,b]},riemannsum:function(t,e,r,i,s){var o,n,a,h,c,l,d=0,u=i;if(e=Math.floor(e),e>0)for(c=(s-i)/e,h=.01*c,o=0;e>o;o++){if("right"===r)l=t(u+c);else if("middle"===r)l=t(u+.5*c);else if("trapezodial"===r)l=.5*(t(u+c)+t(u));else if("left"===r)l=t(u);else if("lower"===r)for(l=t(u),n=u+h;u+c>=n;n+=h)a=t(n),l>a&&(l=a);else if("upper"===r)for(l=t(u),n=u+h;u+c>=n;n+=h)a=t(n),a>l&&(l=a);else l=t(u+c*Math.random());d+=c*l,u+=c}return d},rungeKutta:function(e,i,s,o,n){var a,h,c,l,d,u,p=[],f=[],b=(s[1]-s[0])/o,m=s[0],g=i.length,v=[],C=0;for(t.isString(e)&&(e=r[e]||r.euler),u=e.s,a=0;g>a;a++)p[a]=i[a];for(h=0;o>h;h++){for(v[C]=[],a=0;g>a;a++)v[C][a]=p[a];for(C+=1,l=[],c=0;u>c;c++){for(a=0;g>a;a++)f[a]=0;for(d=0;c>d;d++)for(a=0;g>a;a++)f[a]+=e.A[c][d]*b*l[d][a];for(a=0;g>a;a++)f[a]+=p[a];l.push(n(m+e.c[c]*b,f))}for(a=0;g>a;a++)f[a]=0;for(d=0;u>d;d++)for(a=0;g>a;a++)f[a]+=e.b[d]*l[d][a];for(a=0;g>a;a++)p[a]=p[a]+b*f[a];m+=b}return v},maxIterationsRoot:80,maxIterationsMinimize:500,fzero:function(r,i,s){var o,n,a,h,c,l,d,u,p,f,b,m,g,v,C,y,P,_,E,S,O=e.eps,T=this.maxIterationsRoot,x=0,w=0;if(t.isArray(i)){if(2>i.length)throw Error("JXG.Math.Numerics.fzero: length of array x0 has to be at least two.");o=i[0],h=r.call(s,o),w+=1,n=i[1],c=r.call(s,n),w+=1}else{for(o=i,h=r.call(s,o),w+=1,d=0===o?1:o,u=[.9*d,1.1*d,d-1,d+1,.5*d,1.5*d,-d,2*d,-10*d,10*d],f=u.length,p=0;f>p&&(n=u[p],c=r.call(s,n),w+=1,!(0>=h*c));p++);o>n&&(b=o,o=n,n=b,m=h,h=c,c=m)}if(h*c>0)return t.isArray(i)?this.fminbr(r,[o,n],s):this.Newton(r,o,s);for(a=o,l=h;T>x;){if(g=n-o,Math.abs(l)<Math.abs(c)&&(o=n,n=a,a=o,h=c,c=l,l=h),P=2*O*Math.abs(n)+.5*O,S=.5*(a-n),P>=Math.abs(S)&&O>=Math.abs(c))return n;Math.abs(g)>=P&&Math.abs(h)>Math.abs(c)&&(C=a-n,o===a?(v=c/h,_=C*v,E=1-v):(E=h/l,v=c/l,y=c/h,_=y*(C*E*(E-v)-(n-o)*(v-1)),E=(E-1)*(v-1)*(y-1)),_>0?E=-E:_=-_,.75*C*E-.5*Math.abs(P*E)>_&&Math.abs(.5*g*E)>_&&(S=_/E)),P>Math.abs(S)&&(S=S>0?P:-P),o=n,h=c,n+=S,c=r.call(s,n),w+=1,(c>0&&l>0||0>c&&0>l)&&(a=o,l=h),x++}return n},fminbr:function(r,i,s){var o,n,a,h,c,l,d,u,p,f,b,m,g,v,C,y,P=.5*(3-Math.sqrt(5)),_=e.eps,E=e.eps,S=this.maxIterationsMinimize,O=0,T=0;if(!t.isArray(i)||2>i.length)throw Error("JXG.Math.Numerics.fminbr: length of array x0 has to be at least two.");for(o=i[0],n=i[1],h=o+P*(n-o),d=r.call(s,h),T+=1,a=h,c=h,l=d,u=d;S>O;){if(p=n-o,f=.5*(o+n),b=E*Math.abs(a)+_/3,2*b>=Math.abs(a-f)+.5*p)return a;m=P*(f>a?n-a:o-a),Math.abs(a-c)>=b&&(C=(a-c)*(l-d),v=(a-h)*(l-u),g=(a-h)*v-(a-c)*C,v=2*(v-C),v>0?g=-g:v=-v,Math.abs(g)<Math.abs(m*v)&&g>v*(o-a+2*b)&&v*(n-a-2*b)>g&&(m=g/v)),b>Math.abs(m)&&(m=m>0?b:-b),C=a+m,y=r.call(s,C),T+=1,l>=y?(a>C?n=a:o=a,h=c,c=a,a=C,d=u,u=l,l=y):(a>C?o=C:n=C,u>=y||c===a?(h=c,c=C,d=u,u=y):(d>=y||h===a||h===c)&&(h=C,d=y)),O+=1}return a},RamerDouglasPeuker:function(t,r){var i,s,o,n=[],a=function(t,r,i){var s,o,n,a,h,c,l,d,u,p,f,b=0,m=r;if(2>i-r)return[-1,0];if(n=t[r].scrCoords,a=t[i].scrCoords,isNaN(n[1]+n[2]+a[1]+a[2]))return[0/0,i];for(o=r+1;i>o;o++)h=t[o].scrCoords,c=h[1]-n[1],l=h[2]-n[2],d=a[1]-n[1],u=a[2]-n[2],p=d*d+u*u,p>=e.eps?(f=(c*d+l*u)/p,0>f?f=0:f>1&&(f=1),c-=f*d,l-=f*u,s=c*c+l*l):(f=0,s=c*c+l*l),s>b&&(b=s,m=o);return[Math.sqrt(b),m]},h=function(t,e,r,i,s){var o=a(t,e,r);o[0]>i?(h(t,e,o[1],i,s),h(t,o[1],r,i,s)):s.push(t[r])};for(o=t.length,i=0;o>i&&isNaN(t[i].scrCoords[1]+t[i].scrCoords[2]);)i+=1;for(s=o-1;s>i&&isNaN(t[s].scrCoords[1]+t[s].scrCoords[2]);)s-=1;return i>s||i===o||(n[0]=t[i],h(t,i,s,r,n)),n}},e.Numerics}),define("math/geometry",["jxg","base/constants","base/coords","math/math","math/numerics","utils/type","utils/expect"],function(t,e,r,i,s,o,n){return i.Geometry={},t.extend(i.Geometry,{angle:function(t,e,r){var i,s,o,n,a=[],h=[],c=[];return t.coords?(a[0]=t.coords.usrCoords[1],a[1]=t.coords.usrCoords[2]):(a[0]=t[0],a[1]=t[1]),e.coords?(h[0]=e.coords.usrCoords[1],h[1]=e.coords.usrCoords[2]):(h[0]=e[0],h[1]=e[1]),r.coords?(c[0]=r.coords.usrCoords[1],c[1]=r.coords.usrCoords[2]):(c[0]=r[0],c[1]=r[1]),i=a[0]-h[0],s=a[1]-h[1],o=c[0]-h[0],n=c[1]-h[1],Math.atan2(i*n-s*o,i*o+s*n)},trueAngle:function(t,e,r){return 57.29577951308232*this.rad(t,e,r)},rad:function(t,e,r){var i,s,o,n,a,h,c;return t.coords?(i=t.coords.usrCoords[1],s=t.coords.usrCoords[2]):(i=t[0],s=t[1]),e.coords?(o=e.coords.usrCoords[1],n=e.coords.usrCoords[2]):(o=e[0],n=e[1]),r.coords?(a=r.coords.usrCoords[1],h=r.coords.usrCoords[2]):(a=r[0],h=r[1]),c=Math.atan2(h-n,a-o)-Math.atan2(s-n,i-o),0>c&&(c+=6.283185307179586),c},angleBisector:function(t,i,s,n){var a,h,c,l=t.coords.usrCoords,d=i.coords.usrCoords,u=s.coords.usrCoords,p=l[1]-d[1],f=l[2]-d[2],b=Math.sqrt(p*p+f*f);return o.exists(n)||(n=t.board),p/=b,f/=b,a=Math.acos(p),0>f&&(a*=-1),0>a&&(a+=2*Math.PI),p=u[1]-d[1],f=u[2]-d[2],b=Math.sqrt(p*p+f*f),p/=b,f/=b,h=Math.acos(p),0>f&&(h*=-1),0>h&&(h+=2*Math.PI),c=.5*(a+h),a>h&&(c+=Math.PI),p=Math.cos(c)+d[1],f=Math.sin(c)+d[2],new r(e.COORDS_BY_USER,[p,f],n)},reflection:function(t,i,s){var n,a,h,c,l,d,u,p=i.coords.usrCoords,f=t.point1.coords.usrCoords,b=t.point2.coords.usrCoords;return o.exists(s)||(s=i.board),l=b[1]-f[1],d=b[2]-f[2],n=p[1]-f[1],a=p[2]-f[2],u=(l*a-d*n)/(l*l+d*d),h=p[1]+2*u*d,c=p[2]-2*u*l,new r(e.COORDS_BY_USER,[h,c],s)},rotation:function(t,i,s,n){var a,h,c,l,d,u,p=i.coords.usrCoords,f=t.coords.usrCoords;return o.exists(n)||(n=i.board),a=p[1]-f[1],h=p[2]-f[2],c=Math.cos(s),l=Math.sin(s),d=a*c-h*l+f[1],u=a*l+h*c+f[2],new r(e.COORDS_BY_USER,[d,u],n)},perpendicular:function(t,e,s){var n,a,h,c,l,d,u,p,f=t.point1.coords.usrCoords,b=t.point2.coords.usrCoords,m=e.coords.usrCoords;return o.exists(s)||(s=e.board),e===t.point1?(n=f[1]+b[2]-f[2],a=f[2]-b[1]+f[1],h=!0):e===t.point2?(n=b[1]+f[2]-b[2],a=b[2]-f[1]+b[1],h=!1):Math.abs(f[1]-b[1])>i.eps&&Math.abs(m[2]-(f[2]-b[2])*(m[1]-f[1])/(f[1]-b[1])-f[2])<i.eps||Math.abs(f[1]-b[1])<=i.eps&&Math.abs(f[1]-m[1])<i.eps?(n=m[1]+b[2]-m[2],a=m[2]-b[1]+m[1],h=!0,Math.abs(n-m[1])<i.eps&&Math.abs(a-m[2])<i.eps&&(n=m[1]+f[2]-m[2],a=m[2]-f[1]+m[1],h=!1)):(c=f[2]-b[2],l=f[1]-b[1],d=b[1]*c-b[2]*l,u=m[1]*l+m[2]*c,p=c*c+l*l,Math.abs(p)<i.eps&&(p=i.eps),n=(d*c+u*l)/p,a=(u*c-d*l)/p,h=!0),[new r(o.COORDS_BY_USER,[n,a],s),h]},circumcenterMidpoint:t.shortcut(i.Geometry,"circumcenter"),circumcenter:function(t,s,n,a){var h,c,l,d,u=t.coords.usrCoords,p=s.coords.usrCoords,f=n.coords.usrCoords;return o.exists(a)||(a=t.board),h=[p[0]-u[0],-p[2]+u[2],p[1]-u[1]],c=[.5*(u[0]+p[0]),.5*(u[1]+p[1]),.5*(u[2]+p[2])],l=i.crossProduct(h,c),h=[f[0]-p[0],-f[2]+p[2],f[1]-p[1]],c=[.5*(p[0]+f[0]),.5*(p[1]+f[1]),.5*(p[2]+f[2])],d=i.crossProduct(h,c),new r(e.COORDS_BY_USER,i.crossProduct(l,d),a)},distance:function(t,e,r){var i,s=0;for(r||(r=Math.min(t.length,e.length)),i=0;r>i;i++)s+=(t[i]-e[i])*(t[i]-e[i]);return Math.sqrt(s)},affineDistance:function(t,e,r){var s;return s=this.distance(t,e,r),s>i.eps&&(Math.abs(t[0])<i.eps||Math.abs(e[0])<i.eps)?1/0:s},sortVertices:function(t){var e,r,s=n.each(t,n.coordsArray),a=s.length;for(e=1;a>e;e++)(s[e][2]<s[0][2]||Math.abs(s[e][2]-s[0][2])<i.eps&&s[e][1]<s[0][1])&&(s=o.swap(s,e,0));return r=s.shift(),s.sort(function(t,e){var i=Math.atan2(t[2]-r[2],t[1]-r[1]),s=Math.atan2(e[2]-r[2],e[1]-r[1]);return i-s}),s.unshift(r),s.unshift(s[s.length-1]),s},signedTriangle:function(t,e,r){var i=n.coordsArray(t),s=n.coordsArray(e),o=n.coordsArray(r);return.5*((s[1]-i[1])*(o[2]-i[2])-(s[2]-i[2])*(o[1]-i[1]))},signedPolygon:function(t,e){var r,i,s=0,o=n.each(t,n.coordsArray);for(e?o.unshift(o[o.length-1]):o=this.sortVertices(o),i=o.length,r=1;i>r;r++)s+=o[r-1][1]*o[r][2]-o[r][1]*o[r-1][2];return.5*s},GrahamScan:function(t){var e,r=1,i=n.each(t,n.coordsArray),s=i.length;for(i=this.sortVertices(i),s=i.length,e=2;s>e;e++){for(;0>=this.signedTriangle(i[r-1],i[r],i[e]);)if(r>1)r-=1;
else{if(e===s-1)break;e+=1}r+=1,i=o.swap(i,r,e)}return i.slice(0,r)},calcStraight:function(t,s,n,a){var h,c,l,d,u,p,f,b,m,g,v,C;if(o.exists(a)||(a=10),u=t.visProp.straightfirst,p=t.visProp.straightlast,Math.abs(s.scrCoords[0])<i.eps&&(u=!0),Math.abs(n.scrCoords[0])<i.eps&&(p=!0),(u||p)&&(f=[],f[0]=t.stdform[0]-t.stdform[1]*t.board.origin.scrCoords[1]/t.board.unitX+t.stdform[2]*t.board.origin.scrCoords[2]/t.board.unitY,f[1]=t.stdform[1]/t.board.unitX,f[2]=-t.stdform[2]/t.board.unitY,!isNaN(f[0]+f[1]+f[2]))){for(b=[],b[0]=i.crossProduct(f,[a,0,1]),b[1]=i.crossProduct(f,[a,1,0]),b[2]=i.crossProduct(f,[-a-t.board.canvasHeight,0,1]),b[3]=i.crossProduct(f,[-a-t.board.canvasWidth,1,0]),m=0;4>m;m++)if(Math.abs(b[m][0])>i.eps){for(g=2;g>0;g--)b[m][g]/=b[m][0];b[m][0]=1}if(h=!1,c=!1,h=!u&&Math.abs(s.usrCoords[0])>=i.eps&&s.scrCoords[1]>=0&&s.scrCoords[1]<=t.board.canvasWidth&&s.scrCoords[2]>=0&&s.scrCoords[2]<=t.board.canvasHeight,c=!p&&Math.abs(n.usrCoords[0])>=i.eps&&n.scrCoords[1]>=0&&n.scrCoords[1]<=t.board.canvasWidth&&n.scrCoords[2]>=0&&n.scrCoords[2]<=t.board.canvasHeight,Math.abs(b[1][0])<i.eps?(l=b[0],d=b[2]):Math.abs(b[0][0])<i.eps?(l=b[1],d=b[3]):0>b[1][2]?(l=b[0],d=b[3][2]>t.board.canvasHeight?b[2]:b[3]):b[1][2]>t.board.canvasHeight?(l=b[2],d=0>b[3][2]?b[0]:b[3]):(l=b[1],d=0>b[3][2]?b[0]:b[3][2]>t.board.canvasHeight?b[2]:b[3]),l=new r(e.COORDS_BY_SCREEN,l.slice(1),t.board),d=new r(e.COORDS_BY_SCREEN,d.slice(1),t.board),!h&&!c){if(!u&&p&&!this.isSameDirection(s,n,l)&&!this.isSameDirection(s,n,d))return;if(u&&!p&&!this.isSameDirection(n,s,l)&&!this.isSameDirection(n,s,d))return}h?c||(C=this.isSameDir(s,n,l,d)?d:l):c?v=this.isSameDir(s,n,l,d)?l:d:this.isSameDir(s,n,l,d)?(v=l,C=d):(C=l,v=d),v&&s.setCoordinates(e.COORDS_BY_USER,v.usrCoords.slice(1)),C&&n.setCoordinates(e.COORDS_BY_USER,C.usrCoords.slice(1))}},isSameDir:function(t,e,r,s){var o=e.usrCoords[1]-t.usrCoords[1],n=e.usrCoords[2]-t.usrCoords[2],a=s.usrCoords[1]-r.usrCoords[1],h=s.usrCoords[2]-r.usrCoords[2];return Math.abs(e.usrCoords[0])<i.eps&&(o=e.usrCoords[1],n=e.usrCoords[2]),Math.abs(t.usrCoords[0])<i.eps&&(o=-t.usrCoords[1],n=-t.usrCoords[2]),o*a+n*h>=0},isSameDirection:function(t,e,r){var s,o,n,a,h=!1;return s=e.usrCoords[1]-t.usrCoords[1],o=e.usrCoords[2]-t.usrCoords[2],n=r.usrCoords[1]-t.usrCoords[1],a=r.usrCoords[2]-t.usrCoords[2],Math.abs(s)<i.eps&&(s=0),Math.abs(o)<i.eps&&(o=0),Math.abs(n)<i.eps&&(n=0),Math.abs(a)<i.eps&&(a=0),s>=0&&n>=0?h=o>=0&&a>=0||0>=o&&0>=a:0>=s&&0>=n&&(h=o>=0&&a>=0||0>=o&&0>=a),h},meet:function(t,e,r,s){var o,n=i.eps;return o=n>Math.abs(t[3])&&n>Math.abs(e[3])?this.meetLineLine(t,e,r,s):Math.abs(t[3])>=n&&n>Math.abs(e[3])?this.meetLineCircle(e,t,r,s):n>Math.abs(t[3])&&Math.abs(e[3])>=n?this.meetLineCircle(t,e,r,s):this.meetCircleCircle(t,e,r,s)},meetLineLine:function(t,s,o,n){var a=i.crossProduct(t,s);return Math.abs(a[0])>i.eps&&(a[1]/=a[0],a[2]/=a[0],a[0]=1),new r(e.COORDS_BY_USER,a,n)},meetLineCircle:function(t,s,o,n){var a,h,c,l,d,u,p,f,b,m;return s[4]<i.eps?Math.abs(i.innerProduct([1,s[6],s[7]],t,3))<i.eps?new r(e.COORDS_BY_USER,s.slice(6,8),n):new r(e.COORDS_BY_USER,[0/0,0/0],n):(c=s[0],h=s.slice(1,3),a=s[3],l=t[0],d=t.slice(1,3),u=a,p=h[0]*d[1]-h[1]*d[0],f=a*l*l-(h[0]*d[0]+h[1]*d[1])*l+c,b=p*p-4*u*f,b>=0?(b=Math.sqrt(b),m=[(-p+b)/(2*u),(-p-b)/(2*u)],0===o?new r(e.COORDS_BY_USER,[-m[0]*-d[1]-l*d[0],-m[0]*d[0]-l*d[1]],n):new r(e.COORDS_BY_USER,[-m[1]*-d[1]-l*d[0],-m[1]*d[0]-l*d[1]],n)):new r(e.COORDS_BY_USER,[0,0,0],n))},meetCircleCircle:function(t,s,o,n){var a;return t[4]<i.eps?Math.abs(this.distance(t.slice(6,2),s.slice(6,8))-s[4])<i.eps?new r(e.COORDS_BY_USER,t.slice(6,8),n):new r(e.COORDS_BY_USER,[0,0,0],n):s[4]<i.eps?Math.abs(this.distance(s.slice(6,2),t.slice(6,8))-t[4])<i.eps?new r(e.COORDS_BY_USER,s.slice(6,8),n):new r(e.COORDS_BY_USER,[0,0,0],n):(a=[s[3]*t[0]-t[3]*s[0],s[3]*t[1]-t[3]*s[1],s[3]*t[2]-t[3]*s[2],0,1,1/0,1/0,1/0],a=i.normalize(a),this.meetLineCircle(a,t,o,n))},meetCurveCurve:function(t,i,n,a,h,c){var l;return l=o.exists(c)&&"newton"===c?s.generalizedNewton(t,i,n,a):3===t.bezierDegree&&3===i.bezierDegree?this.meetBezierCurveRedBlueSegments(t,i,n):this.meetCurveRedBlueSegments(t,i,n),new r(e.COORDS_BY_USER,l,h)},meetCurveLine:function(t,r,i,s,n){var a,h,c=[0,0/0,0/0];return o.exists(s)||(s=t.board),t.elementClass===e.OBJECT_CLASS_CURVE?(a=t,h=r):(a=r,h=t),c="plot"===a.visProp.curvetype?this.meetCurveLineDiscrete(a,h,i,s,n):this.meetCurveLineContinuous(a,h,i,s)},meetCurveLineContinuous:function(t,o,n,a){var h,c,l,d,u,p,f,b,m,g,v,C;if(d=function(e){return o.stdform[0]+o.stdform[1]*t.X(e)+o.stdform[2]*t.Y(e)},this.meetCurveLineContinuous.t1memo?(m=this.meetCurveLineContinuous.t1memo,h=s.root(d,m)):(m=t.minX(),g=t.maxX(),h=s.root(d,[m,g])),this.meetCurveLineContinuous.t1memo=h,v=t.X(h),C=t.Y(h),1===n){if(this.meetCurveLineContinuous.t2memo&&(m=this.meetCurveLineContinuous.t2memo,c=s.root(d,m)),!(Math.abs(c-h)>.1&&Math.abs(v-t.X(c))>.1&&Math.abs(C-t.Y(c))>.1))for(f=20,b=(t.maxX()-t.minX())/f,p=t.minX(),l=0;f>l&&(c=s.root(d,[p,p+b]),!(Math.abs(c-h)>.1&&Math.abs(v-t.X(c))>.1&&Math.abs(C-t.Y(c))>.1));l++)p+=b;h=c,this.meetCurveLineContinuous.t2memo=h}return u=Math.abs(d(h))>i.eps?0/0:1,new r(e.COORDS_BY_USER,[u,t.X(h),t.Y(h)],a)},meetCurveLineDiscrete:function(t,s,o,n,a){var h,c,l,d,u,p,f,b,m=0,g=t.numberPoints;for(u=new r(e.COORDS_BY_USER,[0,0/0,0/0],n),d=t.points[0].usrCoords,h=1;g>h;h++)if(l=d.slice(0),d=t.points[h].usrCoords,p=this.distance(l,d),p>i.eps)for(3===t.bezierDegree?(f=this.meetBeziersegmentBeziersegment([t.points[h-1].usrCoords.slice(1),t.points[h].usrCoords.slice(1),t.points[h+1].usrCoords.slice(1),t.points[h+2].usrCoords.slice(1)],[s.point1.coords.usrCoords.slice(1),s.point2.coords.usrCoords.slice(1)]),h+=2):f=[this.meetSegmentSegment(l,d,s.point1.coords.usrCoords,s.point2.coords.usrCoords)],c=0;f.length>c;c++)if(b=f[c],b[1]>=0&&1>=b[1]){if(m===o)return a&&(!s.visProp.straightfirst&&0>b[2]||!s.visProp.straightlast&&b[2]>1)?u:u=new r(e.COORDS_BY_USER,b[0],n);m+=1}return u},meetCurveRedBlueSegments:function(t,e,r){var i,s,o,n,a,h,c,l,d,u=0,p=e.points.length,f=t.points.length;if(1>=p||1>=f)return[0,0/0,0/0];for(i=1;f>i;i++)for(o=t.points[i-1].usrCoords,n=t.points[i].usrCoords,l=Math.min(o[1],n[1]),d=Math.max(o[1],n[1]),h=e.points[0].usrCoords,s=1;p>s;s++)if(a=h,h=e.points[s].usrCoords,d>Math.min(a[1],h[1])&&Math.max(a[1],h[1])>l&&(c=this.meetSegmentSegment(o,n,a,h),c[1]>=0&&c[2]>=0&&(1>c[1]&&1>c[2]||i===f-1&&1===c[1]||s===p-1&&1===c[2]))){if(u===r)return c[0];u++}return[0,0/0,0/0]},meetSegmentSegment:function(t,e,r,s){var o,n,a,h=i.crossProduct(t,e),c=i.crossProduct(r,s),l=i.crossProduct(h,c),d=l[0];return Math.abs(d)<i.eps?[l,1/0,1/0]:(a=[r[1]-t[1],r[2]-t[2]],o=(a[0]*(s[2]-r[2])-a[1]*(s[1]-r[1]))/d,n=(a[0]*(e[2]-t[2])-a[1]*(e[1]-t[1]))/d,[l,o,n])},_bezierSplit:function(t){var e,r,i,s,o,n;return e=[.5*(t[0][0]+t[1][0]),.5*(t[0][1]+t[1][1])],r=[.5*(t[1][0]+t[2][0]),.5*(t[1][1]+t[2][1])],i=[.5*(t[2][0]+t[3][0]),.5*(t[2][1]+t[3][1])],s=[.5*(e[0]+r[0]),.5*(e[1]+r[1])],o=[.5*(r[0]+i[0]),.5*(r[1]+i[1])],n=[.5*(s[0]+o[0]),.5*(s[1]+o[1])],[[t[0],e,s,n],[n,o,i,t[3]]]},_bezierBbox:function(t){var e=[];return 4===t.length?(e[0]=Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),e[1]=Math.max(t[0][1],t[1][1],t[2][1],t[3][1]),e[2]=Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),e[3]=Math.min(t[0][1],t[1][1],t[2][1],t[3][1])):(e[0]=Math.min(t[0][0],t[1][0]),e[1]=Math.max(t[0][1],t[1][1]),e[2]=Math.max(t[0][0],t[1][0]),e[3]=Math.min(t[0][1],t[1][1])),e},_bezierOverlap:function(t,e){return t[2]>=e[0]&&t[0]<=e[2]&&t[1]>=e[3]&&t[3]<=e[1]},_bezierListConcat:function(t,e,r,i){var s,n=o.exists(i),a=0,h=e.length,c=t.length;for(c>0&&(1===t[c-1][1]&&0===e[0][1]||n&&1===t[c-1][2]&&0===e[0][2])&&(a=1),s=a;h>s;s++)n&&(e[s][2]*=.5,e[s][2]+=i),e[s][1]*=.5,e[s][1]+=r,t.push(e[s])},_bezierMeetSubdivision:function(t,e,r){var i,s,o,n,a,h,c,l,d,u,p,f,b=[],m=5;return s=this._bezierBbox(e),i=this._bezierBbox(t),this._bezierOverlap(s,i)?m>r?(o=this._bezierSplit(t),h=o[0],c=o[1],o=this._bezierSplit(e),n=o[0],a=o[1],this._bezierListConcat(b,this._bezierMeetSubdivision(h,n,r+1),0,0),this._bezierListConcat(b,this._bezierMeetSubdivision(h,a,r+1),0,.5),this._bezierListConcat(b,this._bezierMeetSubdivision(c,n,r+1),.5,0),this._bezierListConcat(b,this._bezierMeetSubdivision(c,a,r+1),.5,.5),b):(p=[1].concat(t[0]),f=[1].concat(t[3]),d=[1].concat(e[0]),u=[1].concat(e[3]),l=this.meetSegmentSegment(p,f,d,u),l[1]>=0&&l[2]>=0&&1>=l[1]&&1>=l[2]?[l]:[]):[]},_bezierLineMeetSubdivision:function(t,e,r){var i,s,o,n,a,h,c,l,d,u,p=[],f=5;return i=this._bezierBbox(e),s=this._bezierBbox(t),this._bezierOverlap(s,i)?f>r?(o=this._bezierSplit(t),n=o[0],a=o[1],this._bezierListConcat(p,this._bezierLineMeetSubdivision(n,e,r+1),0),this._bezierListConcat(p,this._bezierLineMeetSubdivision(a,e,r+1),.5),p):(d=[1].concat(t[0]),u=[1].concat(t[3]),c=[1].concat(e[0]),l=[1].concat(e[1]),h=this.meetSegmentSegment(d,u,c,l),h[1]>=0&&h[2]>=0&&1>=h[1]&&1>=h[2]?[h]:[]):[]},meetBeziersegmentBeziersegment:function(t,e){var r,i,s;for(r=4===t.length&&4===e.length?this._bezierMeetSubdivision(t,e,0):this._bezierLineMeetSubdivision(t,e,0),r.sort(function(t,e){return 1e7*(t[1]-e[1])+(t[2]-e[2])}),i=[],s=0;r.length>s;s++)(0===s||r[s][1]!==r[s-1][1]||r[s][2]!==r[s-1][2])&&i.push(r[s]);return i},meetBezierCurveRedBlueSegments:function(t,e,r){var i,s,o,n,a,h,c,l=e.points.length,d=t.points.length,u=[];if(4>l||4>d)return[0,0/0,0/0];for(s=0;d-3>s;s+=3)for(i=t.points,n=[[i[s].usrCoords[1],i[s].usrCoords[2]],[i[s+1].usrCoords[1],i[s+1].usrCoords[2]],[i[s+2].usrCoords[1],i[s+2].usrCoords[2]],[i[s+3].usrCoords[1],i[s+3].usrCoords[2]]],h=this._bezierBbox(n),o=0;l-3>o;o+=3)if(i=e.points,a=[[i[o].usrCoords[1],i[o].usrCoords[2]],[i[o+1].usrCoords[1],i[o+1].usrCoords[2]],[i[o+2].usrCoords[1],i[o+2].usrCoords[2]],[i[o+3].usrCoords[1],i[o+3].usrCoords[2]]],c=this._bezierBbox(a),this._bezierOverlap(h,c)&&(u=u.concat(this.meetBeziersegmentBeziersegment(n,a)),u.length>r))return u[r][0];return u.length>r?u[r][0]:[0,0/0,0/0]},bezierSegmentEval:function(t,e){var r,i,s,o=1-t;return i=0,s=0,r=o*o*o,i+=r*e[0][0],s+=r*e[0][1],r=3*t*o*o,i+=r*e[1][0],s+=r*e[1][1],r=3*t*t*o,i+=r*e[2][0],s+=r*e[2][1],r=t*t*t,i+=r*e[3][0],s+=r*e[3][1],[1,i,s]},projectPointToCircle:function(t,s,n){var a,h,c,l,d,u=s.center.coords.usrCoords;return o.exists(n)||(n=t.board),o.isPoint(t)?(a=t.coords.distance(e.COORDS_BY_USER,s.center.coords),h=t.coords.usrCoords):(a=t.distance(e.COORDS_BY_USER,s.center.coords),h=t.usrCoords),Math.abs(a)<i.eps&&(a=i.eps),d=s.Radius()/a,c=u[1]+d*(h[1]-u[1]),l=u[2]+d*(h[2]-u[2]),new r(e.COORDS_BY_USER,[c,l],n)},projectPointToLine:function(t,e,r){var s=[0,e.stdform[1],e.stdform[2]];return o.exists(r)||(r=t.board),s=i.crossProduct(s,t.coords.usrCoords),this.meetLineLine(s,e.stdform,0,r)},projectCoordsToSegment:function(t,e,r){var s,o,n=[r[1]-e[1],r[2]-e[2]],a=[t[1]-e[1],t[2]-e[2]];return Math.abs(n[0])<i.eps&&Math.abs(n[1])<i.eps?e:(s=i.innerProduct(a,n),o=i.innerProduct(n,n),s/=o,[[1,s*n[0]+e[1],s*n[1]+e[2]],s])},projectCoordsToBeziersegment:function(e,r,i){var s,o=function(t){var s=[1,r.X(i+t),r.Y(i+t)];return s[1]-=e[1],s[2]-=e[2],s[1]*s[1]+s[2]*s[2]};return s=t.Math.Numerics.fminbr(o,[0,1]),[[1,r.X(s+i),r.Y(s+i)],s]},projectPointToCurve:function(t,e,r){o.exists(r)||(r=t.board);var i=t.X(),s=t.Y(),n=t.position||0,a=this.projectCoordsToCurve(i,s,n,e,r);return t.position=a[1],a[0]},projectCoordsToCurve:function(t,i,n,a,h){var c,l,d,u,p,f,b,m,g,v,C,y,P,_,E,S,O,T=Number.POSITIVE_INFINITY;if(o.exists(h)||(h=a.board),"plot"===a.visProp.curvetype){if(n=0,d=T,c=0===a.numberPoints?[0,1,1]:[a.Z(0),a.X(0),a.Y(0)],a.numberPoints>1)for(g=[a.Z(0),a.X(0),a.Y(0)],l=0;a.numberPoints-1>l;l++)v=[a.Z(l+1),a.X(l+1),a.Y(l+1)],f=[1,t,i],C=this.projectCoordsToSegment(f,g,v),p=C[1],b=C[0],p>=0&&1>=p?(u=this.distance(b,f),m=l+p):0>p?(b=g,u=this.distance(g,f),m=l):p>1&&l===a.numberPoints-2&&(b=v,u=this.distance(b,f),m=a.numberPoints-1),d>u&&(d=u,n=m,c=b),g=v;c=new r(e.COORDS_BY_USER,c,h)}else{for(y=function(e){var r=t-a.X(e),s=i-a.Y(e);return r*r+s*s},E=y(n),O=50,S=(a.maxX()-a.minX())/O,P=a.minX(),l=0;O>l;l++)_=y(P),E>_&&(n=P,E=_),P+=S;n=s.fminbr(y,[n-S,n+S]),a.minX()>n&&(n=a.maxX()+n-a.minX()),n>a.maxX()&&(n=a.minX()+n-a.maxX()),c=new r(e.COORDS_BY_USER,[a.X(n),a.Y(n)],h)}return[a.updateTransform(c),n]},projectPointToTurtle:function(t,i,s){var n,a,h,c,l,d,u,p,f=0,b=0,m=Number.POSITIVE_INFINITY,g=i.objects.length;for(o.exists(s)||(s=t.board),l=0;g>l;l++)u=i.objects[l],u.elementClass===e.OBJECT_CLASS_CURVE&&(n=this.projectPointToCurve(t,u),d=this.distance(n.usrCoords,t.coords.usrCoords),m>d&&(h=n.usrCoords[1],c=n.usrCoords[2],a=t.position,m=d,p=u,b=f),f+=u.numberPoints);return n=new r(e.COORDS_BY_USER,[h,c],s),t.position=a+b,p.updateTransform(n)},projectPointToPoint:function(t,e){return e.coords},projectPointToBoard:function(t,e){var r,s,o,n=e||t.board,a=[[1,1,0,0,3,0,1],[-1,2,1,0,1,2,1],[-1,1,2,2,1,2,3],[1,2,3,0,3,2,3]],h=t.coords||t,c=n.getBoundingBox();for(r=0;4>r;r++)o=a[r],o[0]*h.usrCoords[o[1]]<o[0]*c[o[2]]&&(s=i.crossProduct([1,c[o[3]],c[o[4]]],[1,c[o[5]],c[o[6]]]),s[3]=0,s=i.normalize(s),h=this.projectPointToLine({coords:h,board:n},{stdform:s}));return h},distPointLine:function(t,e){var r,s=e[1],o=e[2],n=e[0];return Math.abs(s)+Math.abs(o)<i.eps?Number.POSITIVE_INFINITY:(r=s*t[1]+o*t[2]+n,s*=s,o*=o,Math.abs(r)/Math.sqrt(s+o))},reuleauxPolygon:function(t,e){var r,s=2*Math.PI,o=s/e,n=(e-1)/2,a=0,h=function(h,c){return function(l,d){var u=(l%s+s)%s,p=Math.floor(u/o)%e;return d||(a=t[0].Dist(t[n]),r=i.Geometry.rad([t[0].X()+1,t[0].Y()],t[0],t[n%e])),isNaN(p)?p:(u=.5*u+.5*p*o+r,t[p][h]()+a*Math[c](u))}};return[h("X","cos"),h("Y","sin"),0,s]}}),i.Geometry}),define("parser/geonext",["jxg","base/constants","utils/type"],function(t,e,r){return t.GeonextParser={replacePow:function(t){var e,r,i,s,o,n,a,h,c,l,d;for(t=t.replace(/(\s*)\^(\s*)/g,"^"),c=t.indexOf("^");c>=0;){if(h=t.slice(0,c),l=t.slice(c+1),")"===h.charAt(h.length-1)){for(e=1,r=h.length-2;r>=0&&e>0;)i=h.charAt(r),")"===i?e++:"("===i&&(e-=1),r-=1;if(0!==e)throw Error("JSXGraph: Missing '(' in expression");for(s="",n=h.substring(0,r+1),a=r;a>=0&&n.substr(a,1).match(/([\w\.]+)/);)s=RegExp.$1+s,a-=1;s+=h.substring(r+1,h.length),s=s.replace(/([\(\)\+\*\%\^\-\/\]\[])/g,"\\$1")}else s="[\\w\\.]+";if(l.match(/^([\w\.]*\()/)){for(e=1,r=RegExp.$1.length;l.length>r&&e>0;)i=l.charAt(r),")"===i?e-=1:"("===i&&(e+=1),r+=1;if(0!==e)throw Error("JSXGraph: Missing ')' in expression");o=l.substring(0,r),o=o.replace(/([\(\)\+\*\%\^\-\/\[\]])/g,"\\$1")}else o="[\\w\\.]+";d=RegExp("("+s+")\\^("+o+")"),t=t.replace(d,"pow($1,$2)"),c=t.indexOf("^")}return t},replaceIf:function(t){var e,r,i,s,o,n,a,h,c,l="",d=null,u=null,p=null;if(i=t.indexOf("If("),0>i)return t;for(t=t.replace(/""/g,"0");i>=0;){for(e=t.slice(0,i),r=t.slice(i+3),o=1,s=0,n=-1,a=-1;r.length>s&&o>0;)h=r.charAt(s),")"===h?o-=1:"("===h?o+=1:","===h&&1===o&&(0>n?n=s:a=s),s+=1;if(c=r.slice(0,s-1),r=r.slice(s),0>n)return"";if(0>a)return"";d=c.slice(0,n),u=c.slice(n+1,a),p=c.slice(a+1),d=this.replaceIf(d),u=this.replaceIf(u),p=this.replaceIf(p),l+=e+"(("+d+")?"+"("+u+"):("+p+"))",t=r,d=null,u=null,i=t.indexOf("If(")}return l+=r},replaceNameById:function(t,e,r){var i,s,o,n,a=0,h=["X","Y","L","V"],c=function(t){return r?"$('"+t+"')":t};for(n=0;h.length>n;n++)for(a=t.indexOf(h[n]+"(");a>=0;)a>=0&&(i=t.indexOf(")",a+2),i>=0&&(s=t.slice(a+2,i),s=s.replace(/\\(['"])?/g,"$1"),o=e.elementsByName[s],o&&(t=t.slice(0,a+2)+(r?"$('":"")+c(o.id)+t.slice(i)))),i=t.indexOf(")",a+2),a=t.indexOf(h[n]+"(",i);for(a=t.indexOf("Dist(");a>=0;)a>=0&&(i=t.indexOf(",",a+5),i>=0&&(s=t.slice(a+5,i),s=s.replace(/\\(['"])?/g,"$1"),o=e.elementsByName[s],o&&(t=t.slice(0,a+5)+c(o.id)+t.slice(i)))),i=t.indexOf(",",a+5),a=t.indexOf(",",i),i=t.indexOf(")",a+1),i>=0&&(s=t.slice(a+1,i),s=s.replace(/\\(['"])?/g,"$1"),o=e.elementsByName[s],o&&(t=t.slice(0,a+1)+c(o.id)+t.slice(i))),i=t.indexOf(")",a+1),a=t.indexOf("Dist(",i);for(h=["Deg","Rad"],n=0;h.length>n;n++)for(a=t.indexOf(h[n]+"(");a>=0;)a>=0&&(i=t.indexOf(",",a+4),i>=0&&(s=t.slice(a+4,i),s=s.replace(/\\(['"])?/g,"$1"),o=e.elementsByName[s],o&&(t=t.slice(0,a+4)+c(o.id)+t.slice(i)))),i=t.indexOf(",",a+4),a=t.indexOf(",",i),i=t.indexOf(",",a+1),i>=0&&(s=t.slice(a+1,i),s=s.replace(/\\(['"])?/g,"$1"),o=e.elementsByName[s],o&&(t=t.slice(0,a+1)+c(o.id)+t.slice(i))),i=t.indexOf(",",a+1),a=t.indexOf(",",i),i=t.indexOf(")",a+1),i>=0&&(s=t.slice(a+1,i),s=s.replace(/\\(['"])?/g,"$1"),o=e.elementsByName[s],o&&(t=t.slice(0,a+1)+c(o.id)+t.slice(i))),i=t.indexOf(")",a+1),a=t.indexOf(h[n]+"(",i);return t},replaceIdByObj:function(t){var e=/(X|Y|L)\(([\w_]+)\)/g;return t=t.replace(e,"$('$2').$1()"),e=/(V)\(([\w_]+)\)/g,t=t.replace(e,"$('$2').Value()"),e=/(Dist)\(([\w_]+),([\w_]+)\)/g,t=t.replace(e,"dist($('$2'), $('$3'))"),e=/(Deg)\(([\w_]+),([ \w\[\w_]+),([\w_]+)\)/g,t=t.replace(e,"deg($('$2'),$('$3'),$('$4'))"),e=/Rad\(([\w_]+),([\w_]+),([\w_]+)\)/g,t=t.replace(e,"rad($('$1'),$('$2'),$('$3'))"),e=/N\((.+)\)/g,t=t.replace(e,"($1)")},geonext2JS:function(t,e){var r,i,s,o=["Abs","ACos","ASin","ATan","Ceil","Cos","Exp","Factorial","Floor","Log","Max","Min","Random","Round","Sin","Sqrt","Tan","Trunc"],n=["abs","acos","asin","atan","ceil","cos","exp","factorial","floor","log","max","min","random","round","sin","sqrt","tan","ceil"];for(t=t.replace(/&lt;/g,"<"),t=t.replace(/&gt;/g,">"),t=t.replace(/&amp;/g,"&"),i=t,i=this.replaceNameById(i,e),i=this.replaceIf(i),i=this.replacePow(i),i=this.replaceIdByObj(i),s=0;o.length>s;s++)r=RegExp(["(\\W|^)(",o[s],")"].join(""),"ig"),i=i.replace(r,["$1",n[s]].join(""));return i=i.replace(/True/g,"true"),i=i.replace(/False/g,"false"),i=i.replace(/fasle/g,"false"),i=i.replace(/Pi/g,"PI"),i=i.replace(/"/g,"'")},findDependencies:function(t,i,s){var o,n,a,h;r.exists(s)||(s=t.board),o=s.elementsByName;for(n in o)o.hasOwnProperty(n)&&n!==t.name&&(o[n].type===e.OBJECT_TYPE_TEXT?o[n].visProp.islabel||(h=n.replace(/\[/g,"\\["),h=h.replace(/\]/g,"\\]"),a=RegExp("\\(([\\w\\[\\]'_ ]+,)*("+h+")(,[\\w\\[\\]'_ ]+)*\\)","g"),i.search(a)>=0&&o[n].addChild(t)):(h=n.replace(/\[/g,"\\["),h=h.replace(/\]/g,"\\]"),a=RegExp("\\(([\\w\\[\\]'_ ]+,)*("+h+")(,[\\w\\[\\]'_ ]+)*\\)","g"),i.search(a)>=0&&o[n].addChild(t)))},gxt2jc:function(t,e){var r;return t=t.replace(/&lt;/g,"<"),t=t.replace(/&gt;/g,">"),t=t.replace(/&amp;/g,"&"),r=t,r=this.replaceNameById(r,e,!0),r=r.replace(/True/g,"true"),r=r.replace(/False/g,"false"),r=r.replace(/fasle/g,"false")}},t.GeonextParser}),define("base/element",["jxg","base/constants","base/coords","math/math","options","parser/geonext","utils/event","utils/color","utils/type"],function(t,e,r,i,s,o,n,a,h){return t.GeometryElement=function(t,r,i,s){var o,a,c;if(this.needsUpdate=!0,this.isDraggable=!1,this.isReal=!0,this.childElements={},this.hasLabel=!1,this.highlighted=!1,this.notExistingParents={},this.traces={},this.numTraces=0,this.transformations=[],this.baseElement=null,this.descendants={},this.ancestors={},this.symbolic={},this.rendNode=null,this.elType="",this.dump=!0,this.subs={},this._pos=-1,this.stdform=[1,0,0,0,1,1,0,0],this.methodMap={setLabel:"setLabelText",getName:"getName",addTransform:"addTransform",setProperty:"setAttribute",setAttribute:"setAttribute",animate:"animate",on:"on",off:"off",trigger:"trigger"},this.quadraticform=[[1,0,0],[0,1,0],[0,0,1]],this.visProp={},n.eventify(this),this.mouseover=!1,arguments.length>0){this.board=t,this.type=i,this.elementClass=s||e.OBJECT_CLASS_OTHER,this.id=r.id,o=r.name,h.exists(o)||(o=this.board.generateName(this)),this.board.elementsByName[o]=this,this.name=o,this.needsRegularUpdate=r.needsregularupdate,h.clearVisPropOld(this),c=this.resolveShortcuts(r);for(a in c)c.hasOwnProperty(a)&&this._set(a,c[a]);this.visProp.draft=c.draft&&c.draft.draft,this.visProp.gradientangle="270",this.visProp.gradientsecondopacity=this.visProp.fillopacity,this.visProp.gradientpositionx=.5,this.visProp.gradientpositiony=.5}},t.extend(t.GeometryElement.prototype,{addChild:function(t){var e,r;this.childElements[t.id]=t,this.addDescendants(t),t.ancestors[this.id]=this;for(e in this.descendants)if(this.descendants.hasOwnProperty(e)){this.descendants[e].ancestors[this.id]=this;for(r in this.ancestors)this.ancestors.hasOwnProperty(r)&&(this.descendants[e].ancestors[this.ancestors[r].id]=this.ancestors[r])}for(e in this.ancestors)if(this.ancestors.hasOwnProperty(e))for(r in this.descendants)this.descendants.hasOwnProperty(r)&&(this.ancestors[e].descendants[this.descendants[r].id]=this.descendants[r]);return this},addDescendants:function(t){var e;this.descendants[t.id]=t;for(e in t.childElements)t.childElements.hasOwnProperty(e)&&this.addDescendants(t.childElements[e]);return this},countChildren:function(){var t,e,r=0;e=this.childElements;for(t in e)e.hasOwnProperty(t)&&0>t.indexOf("Label")&&r++;return r},getName:function(){return this.name},addTransform:function(){return this},draggable:function(){return this.isDraggable&&!this.visProp.fixed&&!this.visProp.frozen&&this.type!==e.OBJECT_TYPE_GLIDER},generatePolynomial:function(){return[]},animate:function(t,r,i){i=i||{};var s,o,n,h=this.board.attr.animationdelay,c=Math.ceil(r/h),l=this,d=function(t,e,r){var i,s,o,h,d;for(i=a.rgb2hsv(t),s=a.rgb2hsv(e),o=(s[0]-i[0])/c,h=(s[1]-i[1])/c,d=(s[2]-i[2])/c,l.animationData[r]=[],n=0;c>n;n++)l.animationData[r][c-n-1]=a.hsv2rgb(i[0]+(n+1)*o,i[1]+(n+1)*h,i[2]+(n+1)*d)},u=function(t,e,r,i){var s,o;if(t=parseFloat(t),e=parseFloat(e),!isNaN(t)&&!isNaN(e))for(o=(e-t)/c,l.animationData[r]=[],n=0;c>n;n++)s=t+(n+1)*o,l.animationData[r][c-n-1]=i?Math.floor(s):s};this.animationData={};for(s in t)if(t.hasOwnProperty(s))switch(o=s.toLowerCase()){case"strokecolor":case"fillcolor":d(this.visProp[o],t[s],o);break;case"size":if(this.elementClass!==e.OBJECT_CLASS_POINT)break;u(this.visProp[o],t[s],o,!0);break;case"strokeopacity":case"strokewidth":case"fillopacity":u(this.visProp[o],t[s],o,!1)}return this.animationCallback=i.callback,this.board.addAnimation(this),this},update:function(){return this.visProp.trace&&this.cloneToBackground(),this},updateRenderer:function(){return this},hideElement:function(){return this.visProp.visible=!1,this.board.renderer.hide(this),h.exists(this.label)&&this.hasLabel&&(this.label.hiddenByParent=!0,this.label.content.visProp.visible&&this.label.content.hideElement()),this},showElement:function(){return this.visProp.visible=!0,this.board.renderer.show(this),h.exists(this.label)&&this.hasLabel&&this.label.hiddenByParent&&(this.label.hiddenByParent=!1,this.label.content.visProp.visible||this.label.content.showElement().updateRenderer()),this},_set:function(t,e){t=t.toLocaleLowerCase(),this.visProp.hasOwnProperty(t)&&t.indexOf("color")>=0&&h.isString(e)&&9===e.length&&"#"===e.charAt(0)?(e=a.rgba2rgbo(e),this.visProp[t]=e[0],this.visProp[t.replace("color","opacity")]=e[1]):this.visProp[t]=e},resolveShortcuts:function(t){var e,r;for(e in s.shortcuts)if(s.shortcuts.hasOwnProperty(e)&&h.exists(t[e]))for(r=0;s.shortcuts[e].length>r;r++)h.exists(t[s.shortcuts[e][r]])||(t[s.shortcuts[e][r]]=t[e]);return t},setLabelText:function(t){return t=t.replace(/</g,"&lt;").replace(/>/g,"&gt;"),null!==this.label&&this.label.content.setText(t),this},setProperty:t.shortcut(t.GeometryElement.prototype,"setAttribute"),setAttribute:function(){var r,i,s,o,n,c,l,d={},u=function(t){return function(){return t}};for(r=0;arguments.length>r;r++)o=arguments[r],h.isString(o)?(c=o.split(":"),d[h.trim(c[0])]=h.trim(c[1])):h.isArray(o)?d[o[0]]=o[1]:t.extend(d,o);d=this.resolveShortcuts(d);for(r in d)if(d.hasOwnProperty(r)){switch(i=r.replace(/\s+/g,"").toLowerCase(),s=d[r],l=this.visProp[i],i){case"name":delete this.board.elementsByName[this.name],this.name=s,this.board.elementsByName[this.name]=this;break;case"needsregularupdate":this.needsRegularUpdate=!("false"===s||s===!1),this.board.renderer.setBuffering(this,this.needsRegularUpdate?"auto":"static");break;case"labelcolor":s=a.rgba2rgbo(s),n=s[1],s=s[0],0===n&&h.exists(this.label)&&this.hasLabel&&this.label.content.hideElement(),h.exists(this.label)&&this.hasLabel&&(this.label.color=s,this.board.renderer.setObjectStrokeColor(this.label.content,s,n)),this.type===e.OBJECT_TYPE_TEXT&&(this.visProp.strokecolor=s,this.visProp.strokeopacity=n,this.board.renderer.setObjectStrokeColor(this,this.visProp.strokecolor,this.visProp.strokeopacity));break;case"infoboxtext":this.infoboxText="string"==typeof s?s:!1;break;case"visible":"false"===s||s===!1?(this.visProp.visible=!1,this.hideElement()):("true"===s||s===!0)&&(this.visProp.visible=!0,this.showElement());break;case"face":this.elementClass===e.OBJECT_CLASS_POINT&&(this.visProp.face=s,this.board.renderer.changePointStyle(this));break;case"trace":"false"===s||s===!1?(this.clearTrace(),this.visProp.trace=!1):this.visProp.trace=!0;break;case"gradient":this.visProp.gradient=s,this.board.renderer.setGradient(this);break;case"gradientsecondcolor":s=a.rgba2rgbo(s),this.visProp.gradientsecondcolor=s[0],this.visProp.gradientsecondopacity=s[1],this.board.renderer.updateGradient(this);break;case"gradientsecondopacity":this.visProp.gradientsecondopacity=s,this.board.renderer.updateGradient(this);break;case"withlabel":this.visProp.withlabel=s,s?this.label&&this.label.content?this.visProp.visible&&this.label.content.showElement():(this.createLabel(),this.visProp.visible||this.label.content.hideElement()):this.label&&this.label.content&&this.hasLabel&&this.label.content.hideElement(),this.hasLabel=s;break;case"rotate":(this.type===e.OBJECT_TYPE_TEXT&&"internal"===this.visProp.display||this.type===e.OBJECT_TYPE_IMAGE)&&this.addRotation(s);break;case"ticksdistance":this.type===e.OBJECT_TYPE_TICKS&&"number"==typeof s&&(this.ticksFunction=u(s));break;case"generatelabelvalue":this.type===e.OBJECT_TYPE_TICKS&&"function"==typeof s&&(this.generateLabelValue=s);break;case"onpolygon":this.type===e.OBJECT_TYPE_GLIDER&&(this.onPolygon=!!s);break;default:h.exists(this.visProp[i])&&(!t.Validator[i]||t.Validator[i]&&t.Validator[i](s)||t.Validator[i]&&h.isFunction(s)&&t.Validator[i](s()))&&(s=s.toLowerCase&&"false"===s.toLowerCase()?!1:s,this._set(i,s))}this.triggerEventHandlers(["attribute:"+i],[l])}return this.triggerEventHandlers(["attribute"],[d]),this.visProp.needsregularupdate?this.board.update(this):this.board.fullUpdate(),this},getProperty:t.shortcut(t.GeometryElement.prototype,"getAttribute"),getAttribute:function(t){var e;switch(t=t.toLowerCase()){case"needsregularupdate":e=this.needsRegularUpdate;break;case"labelcolor":e=this.label.color;break;case"infoboxtext":e=this.infoboxText;break;case"withlabel":e=this.hasLabel;break;default:e=this.visProp[t]}return e},setDash:function(t){return this.setAttribute({dash:t}),this},prepareUpdate:function(){return this.needsUpdate=!0,this},remove:function(){return this.board.renderer.remove(this.board.renderer.getElementById(this.id)),this.hasLabel&&this.board.renderer.remove(this.board.renderer.getElementById(this.label.content.id)),this},getTextAnchor:function(){return new r(e.COORDS_BY_USER,[0,0],this.board)},getLabelAnchor:function(){return new r(e.COORDS_BY_USER,[0,0],this.board)},setArrow:function(t,e){return this.visProp.firstarrow=t,this.visProp.lastarrow=e,this.prepareUpdate().update(),this},createGradient:function(){("linear"===this.visProp.gradient||"radial"===this.visProp.gradient)&&this.board.renderer.setGradient(this)},createLabel:function(){var e;return t.elements.text?(e=h.deepCopy(this.visProp.label,null),e.id=this.id+"Label",e.isLabel=!0,e.visible=this.visProp.visible,e.anchor=this,e.priv=this.visProp.priv,this.label={},this.visProp.withlabel&&(this.label.relativeCoords=[0,0],this.label.content=t.elements.text(this.board,[this.label.relativeCoords[0],-this.label.relativeCoords[1],this.name],e),this.label.content.needsUpdate=!0,this.label.content.update(),this.label.content.dump=!1,this.label.color=this.label.content.visProp.strokecolor,this.visProp.visible||(this.label.hiddenByParent=!0,this.label.content.visProp.visible=!1),this.hasLabel=!0)):t.debug("JSXGraph: Can't create label: text element is not available. Make sure you include base/text"),this},highlight:function(t){return t=h.def(t,!1),!this.visProp.highlight||this.highlighted&&!t||(this.highlighted=!0,this.board.highlightedObjects[this.id]=this,this.board.renderer.highlight(this)),this},noHighlight:function(){return this.highlighted&&(this.highlighted=!1,delete this.board.highlightedObjects[this.id],this.board.renderer.noHighlight(this)),this},clearTrace:function(){var t;for(t in this.traces)this.traces.hasOwnProperty(t)&&this.board.renderer.remove(this.traces[t]);return this.numTraces=0,this},cloneToBackground:function(){return this},bounds:function(){return[0,0,0,0]},normalize:function(){return this.stdform=i.normalize(this.stdform),this},toJSON:function(){var t,e,r=['{"name":',this.name];r.push(', "id":'+this.id),t=[];for(e in this.visProp)this.visProp.hasOwnProperty(e)&&h.exists(this.visProp[e])&&t.push('"'+e+'":'+this.visProp[e]);return r.push(', "visProp":{'+(""+t)+"}"),r.push("}"),r.join("")},addRotation:function(t){var r,i,s,o,n,a=this;return(this.type===e.OBJECT_TYPE_TEXT&&"internal"===this.visProp.display||this.type===e.OBJECT_TYPE_IMAGE)&&0!==t&&(r=this.board.create("transform",[function(){return-a.X()},function(){return-a.Y()}],{type:"translate"}),i=this.board.create("transform",[function(){return a.X()},function(){return a.Y()}],{type:"translate"}),s=this.board.create("transform",[function(){return a.board.unitX/a.board.unitY},function(){return 1}],{type:"scale"}),o=this.board.create("transform",[function(){return a.board.unitY/a.board.unitX},function(){return 1}],{type:"scale"}),n=this.board.create("transform",[t*Math.PI/180],{type:"rotate"}),r.bindTo(this),s.bindTo(this),n.bindTo(this),o.bindTo(this),i.bindTo(this)),this},highlightStrokeColor:function(t){return this.setAttribute({highlightStrokeColor:t}),this},strokeColor:function(t){return this.setAttribute({strokeColor:t}),this},strokeWidth:function(t){return this.setAttribute({strokeWidth:t}),this},fillColor:function(t){return this.setAttribute({fillColor:t}),this},highlightFillColor:function(t){return this.setAttribute({highlightFillColor:t}),this},labelColor:function(t){return this.setAttribute({labelColor:t}),this},dash:function(t){return this.setAttribute({dash:t}),this},visible:function(t){return this.setAttribute({visible:t}),this},shadow:function(t){return this.setAttribute({shadow:t}),this},getType:function(){return this.elType},getParents:function(){return this.parents},snapToGrid:function(){return this},getAttributes:function(){var t,e=h.deepCopy(this.visProp),r=["attractors","snatchdistance","traceattributes","frozen","shadow","gradientangle","gradientsecondopacity","gradientpositionx","gradientpositiony","needsregularupdate","zoom","layer","offset"];for(e.id=this.id,e.name=this.name,t=0;r.length>t;t++)delete e[r[t]];return e},hasPoint:function(){return!1},addEvent:t.shortcut(t.GeometryElement.prototype,"on"),removeEvent:t.shortcut(t.GeometryElement.prototype,"off"),__evt__over:function(){},__evt__mouseover:function(){},__evt__out:function(){},__evt__mouseout:function(){},__evt__move:function(){},__evt__mousemove:function(){},__evt__drag:function(){},__evt__mousedrag:function(){},__evt__touchdrag:function(){},__evt__down:function(){},__evt__mousedown:function(){},__evt__touchdown:function(){},__evt__up:function(){},__evt__mouseup:function(){},__evt__touchup:function(){},__evt__attribute:function(){},__evt__attribute_:function(){},__evt:function(){}}),t.GeometryElement}),define("base/transformation",["jxg","base/constants","math/math","utils/type"],function(t,e,r,i){return t.Transformation=function(t,r,i){this.elementClass=e.OBJECT_CLASS_OTHER,this.matrix=[[1,0,0],[0,1,0],[0,0,1]],this.board=t,this.isNumericMatrix=!1,this.setMatrix(t,r,i),this.methodMap={apply:"apply",applyOnce:"applyOnce",bindTo:"bindTo",bind:"bind",melt:"melt"}},t.Transformation.prototype={},t.extend(t.Transformation.prototype,{update:function(){return this},setMatrix:function(t,e,s){var o;
for(this.isNumericMatrix=!0,o=0;s.length>o;o++)if("number"!=typeof s[o]){this.isNumericMatrix=!1;break}"translate"===e?(this.evalParam=i.createEvalFunction(t,s,2),this.update=function(){this.matrix[1][0]=this.evalParam(0),this.matrix[2][0]=this.evalParam(1)}):"scale"===e?(this.evalParam=i.createEvalFunction(t,s,2),this.update=function(){this.matrix[1][1]=this.evalParam(0),this.matrix[2][2]=this.evalParam(1)}):"reflect"===e?(4>s.length&&(s[0]=t.select(s[0])),2===s.length&&(s[1]=t.select(s[1])),4===s.length&&(this.evalParam=i.createEvalFunction(t,s,4)),this.update=function(){var t,e,i,o,n,a,h,c;1===s.length?h=s[0].stdform:2===s.length?h=r.crossProduct(s[1].coords.usrCoords,s[0].coords.usrCoords):4===s.length&&(h=r.crossProduct([1,this.evalParam(2),this.evalParam(3)],[1,this.evalParam(0),this.evalParam(1)])),t=h[1],e=h[2],i=h[0],c=[-i*t,-i*e,t*t+e*e],a=c[2],o=c[0]/c[2],n=c[1]/c[2],t=-h[2],e=h[1],this.matrix[1][1]=(t*t-e*e)/a,this.matrix[1][2]=2*t*e/a,this.matrix[2][1]=this.matrix[1][2],this.matrix[2][2]=-this.matrix[1][1],this.matrix[1][0]=o*(1-this.matrix[1][1])-n*this.matrix[1][2],this.matrix[2][0]=n*(1-this.matrix[2][2])-o*this.matrix[2][1]}):"rotate"===e?(3===s.length?this.evalParam=i.createEvalFunction(t,s,3):2>=s.length&&(this.evalParam=i.createEvalFunction(t,s,1),2===s.length&&(s[1]=t.select(s[1]))),this.update=function(){var t,e,r=this.evalParam(0),i=Math.cos(r),o=Math.sin(r);this.matrix[1][1]=i,this.matrix[1][2]=-o,this.matrix[2][1]=o,this.matrix[2][2]=i,s.length>1&&(3===s.length?(t=this.evalParam(1),e=this.evalParam(2)):(t=s[1].X(),e=s[1].Y()),this.matrix[1][0]=t*(1-i)+e*o,this.matrix[2][0]=e*(1-i)-t*o)}):"shear"===e?(this.evalParam=i.createEvalFunction(t,s,1),this.update=function(){var t=this.evalParam(0);this.matrix[1][1]=Math.tan(t)}):"generic"===e&&(this.evalParam=i.createEvalFunction(t,s,9),this.update=function(){this.matrix[0][0]=this.evalParam(0),this.matrix[0][1]=this.evalParam(1),this.matrix[0][2]=this.evalParam(2),this.matrix[1][0]=this.evalParam(3),this.matrix[1][1]=this.evalParam(4),this.matrix[1][2]=this.evalParam(5),this.matrix[2][0]=this.evalParam(6),this.matrix[2][1]=this.evalParam(7),this.matrix[2][2]=this.evalParam(8)})},apply:function(t,e){return this.update(),i.exists(e)?r.matVecMult(this.matrix,t.initialCoords.usrCoords):r.matVecMult(this.matrix,t.coords.usrCoords)},applyOnce:function(t){var s,o,n;for(i.isArray(t)||(t=[t]),o=t.length,n=0;o>n;n++)this.update(),s=r.matVecMult(this.matrix,t[n].coords.usrCoords),t[n].coords.setCoordinates(e.COORDS_BY_USER,s)},bindTo:function(t){var e,r;if(i.isArray(t))for(r=t.length,e=0;r>e;e++)t[e].transformations.push(this);else t.transformations.push(this)},setProperty:function(){},setAttribute:function(){},melt:function(t){var e,r,i,s,o,n,a=[];for(r=t.matrix.length,i=this.matrix[0].length,e=0;r>e;e++)a[e]=[];for(this.update(),t.update(),e=0;r>e;e++)for(n=0;i>n;n++){for(o=0,s=0;r>s;s++)o+=t.matrix[e][s]*this.matrix[s][n];a[e][n]=o}return this.update=function(){var t=this.matrix.length,r=this.matrix[0].length;for(e=0;t>e;e++)for(n=0;r>n;n++)this.matrix[e][n]=a[e][n]},this}}),t.createTransform=function(e,r,i){return new t.Transformation(e,i.type,r)},t.registerElement("transform",t.createTransform),{Transformation:t.Transformation,createTransform:t.createTransform}}),define("base/point",["jxg","options","math/math","math/geometry","math/numerics","base/coords","base/constants","base/element","parser/geonext","utils/type","base/transformation"],function(t,e,r,i,s,o,n,a,h,c){return t.Point=function(t,e,r){this.constructor(t,r,n.OBJECT_TYPE_POINT,n.OBJECT_CLASS_POINT),c.exists(e)||(e=[0,0]),this.coords=new o(n.COORDS_BY_USER,e,this.board),this.initialCoords=new o(n.COORDS_BY_USER,e,this.board),this.position=null,this.onPolygon=!1,this.slideObject=null,this.needsUpdateFromParent=!0,this.Xjc=null,this.Yjc=null,this.methodMap=c.deepCopy(this.methodMap,{move:"moveTo",moveTo:"moveTo",moveAlong:"moveAlong",visit:"visit",glide:"makeGlider",makeGlider:"makeGlider",X:"X",Y:"Y",free:"free",setPosition:"setGliderPosition",setGliderPosition:"setGliderPosition",addConstraint:"addConstraint",dist:"Dist",onPolygon:"onPolygon"}),this.group=[],this.elType="point",this.id=this.board.setId(this,"P"),this.board.renderer.drawPoint(this),this.board.finalizeAdding(this),this.createLabel()},t.Point.prototype=new a,t.extend(t.Point.prototype,{hasPoint:function(t,e){var r,i=this.coords.scrCoords;return r=parseFloat(this.visProp.size)+.5*parseFloat(this.visProp.strokewidth),this.board.options.precision.hasPoint>r&&(r=this.board.options.precision.hasPoint),r+2>Math.abs(i[1]-t)&&r+2>Math.abs(i[2]-e)},updateConstraint:function(){return this},update:function(t){return this.needsUpdate?(c.exists(t)||(t=!1),this.type===n.OBJECT_TYPE_GLIDER&&(t?this.updateGliderFromParent():this.updateGlider()),(this.type===n.OBJECT_TYPE_CAS||this.type===n.OBJECT_TYPE_INTERSECTION||this.type===n.OBJECT_TYPE_AXISPOINT)&&this.updateConstraint(),this.updateTransform(),this.visProp.trace&&this.cloneToBackground(!0),this):this},updateGlider:function(){var t,e,s,a,h,c,l,d,u,p,f,b,m,g,v,C,y,P=!1,_=this.slideObject;if(this.needsUpdateFromParent=!1,_.elementClass===n.OBJECT_CLASS_CIRCLE)C=i.projectPointToCircle(this,_,this.board),y=i.rad([_.center.X()+1,_.center.Y()],_.center,this);else if(_.elementClass===n.OBJECT_CLASS_LINE){if(this.onPolygon){if(e=_.point1.coords.usrCoords,s=_.point2.coords.usrCoords,t=1,a=s[t]-e[t],Math.abs(a)<r.eps&&(t=2,a=s[t]-e[t]),l=i.projectPointToLine(this,_,this.board),d=(l.usrCoords[t]-e[t])/a,c=_.parentPolygon,0>d){for(t=0;c.borders.length>t;t++)if(_===c.borders[t]){_=c.borders[(t-1+c.borders.length)%c.borders.length];break}}else if(d>1)for(t=0;c.borders.length>t;t++)if(_===c.borders[t]){_=c.borders[(t+1+c.borders.length)%c.borders.length];break}_.id!==this.slideObject.id&&(this.slideObject=_)}e=_.point1.coords,s=_.point2.coords,a=e.distance(n.COORDS_BY_USER,s),r.eps>a?(C=e,P=!0,y=0):(C=i.projectPointToLine(this,_,this.board),e=e.usrCoords.slice(0),s=s.usrCoords.slice(0),Math.abs(s[0])<r.eps?(t=1,a=s[t],Math.abs(a)<r.eps&&(t=2,a=s[t]),a=(C.usrCoords[t]-e[t])/a,u=a>=0?1:-1,a=Math.abs(a),y=u*a/(a+1)):Math.abs(e[0])<r.eps?(t=1,a=e[t],Math.abs(a)<r.eps&&(t=2,a=e[t]),a=(C.usrCoords[t]-s[t])/a,y=0>a?(1-2*a)/(1-a):1/(a+1)):(t=1,a=s[t]-e[t],Math.abs(a)<r.eps&&(t=2,a=s[t]-e[t]),y=(C.usrCoords[t]-e[t])/a)),this.visProp.snapwidth>0&&Math.abs(this._smax-this._smin)>=r.eps&&(y=Math.max(Math.min(y,1),0),h=y*(this._smax-this._smin)+this._smin,h=Math.round(h/this.visProp.snapwidth)*this.visProp.snapwidth,y=(h-this._smin)/(this._smax-this._smin),this.update(!0)),e=_.point1.coords,!_.visProp.straightfirst&&Math.abs(e.usrCoords[0])>r.eps&&0>y&&(C=e,P=!0,y=0),s=_.point2.coords,!_.visProp.straightlast&&Math.abs(s.usrCoords[0])>r.eps&&y>1&&(C=s,P=!0,y=1)}else _.type===n.OBJECT_TYPE_TURTLE?(this.updateConstraint(),C=i.projectPointToTurtle(this,_,this.board),y=this.position):_.elementClass===n.OBJECT_CLASS_CURVE?_.type===n.OBJECT_TYPE_ARC||_.type===n.OBJECT_TYPE_SECTOR?(C=i.projectPointToCircle(this,_,this.board),b=i.rad(_.radiuspoint,_.center,this),p=0,f=i.rad(_.radiuspoint,_.center,_.anglepoint),y=b,("minor"===_.visProp.type&&f>Math.PI||"major"===_.visProp.type&&Math.PI>f)&&(p=f,f=2*Math.PI),(p>b||b>f)&&(y=f,(p>b&&b>.5*p||b>f&&b>.5*f+Math.PI)&&(y=p),this.updateGliderFromParent())):(this.updateConstraint(),_.transformations.length>0?(_.updateTransformMatrix(),v=r.inverse(_.transformMat),g=r.matVecMult(v,this.coords.usrCoords),m=new o(n.COORDS_BY_USER,g,this.board).usrCoords,g=i.projectCoordsToCurve(m[1],m[2],this.position||0,_,this.board),C=g[0],y=g[1]):(C=i.projectPointToCurve(this,_,this.board),y=this.position)):_.elementClass===n.OBJECT_CLASS_POINT&&(C=i.projectPointToPoint(this,_,this.board),y=this.position);this.coords.setCoordinates(n.COORDS_BY_USER,C.usrCoords,P),this.position=y},updateGliderFromParent:function(){var t,e,s,o,a,h,c=this.slideObject;return this.needsUpdateFromParent?(c.elementClass===n.OBJECT_CLASS_CIRCLE?(s=c.Radius(),a=[c.center.X()+s*Math.cos(this.position),c.center.Y()+s*Math.sin(this.position)]):c.elementClass===n.OBJECT_CLASS_LINE?(t=c.point1.coords.usrCoords,e=c.point2.coords.usrCoords,Math.abs(e[0])<r.eps?(o=Math.min(Math.abs(this.position),1-r.eps),o/=1-o,0>this.position&&(o=-o),a=[t[0]+o*e[0],t[1]+o*e[1],t[2]+o*e[2]]):Math.abs(t[0])<r.eps?(o=Math.max(this.position,r.eps),o=Math.min(o,2-r.eps),o=o>1?(o-1)/(o-2):(1-o)/o,a=[e[0]+o*t[0],e[1]+o*t[1],e[2]+o*t[2]]):(o=this.position,a=[t[0]+o*(e[0]-t[0]),t[1]+o*(e[1]-t[1]),t[2]+o*(e[2]-t[2])])):c.type===n.OBJECT_TYPE_TURTLE?(this.coords.setCoordinates(n.COORDS_BY_USER,[c.Z(this.position),c.X(this.position),c.Y(this.position)]),this.updateConstraint(),a=i.projectPointToTurtle(this,c,this.board).usrCoords):c.elementClass===n.OBJECT_CLASS_CURVE?(this.coords.setCoordinates(n.COORDS_BY_USER,[c.Z(this.position),c.X(this.position),c.Y(this.position)]),c.type===n.OBJECT_TYPE_ARC||c.type===n.OBJECT_TYPE_SECTOR?(h=i.rad([c.center.X()+1,c.center.Y()],c.center,c.radiuspoint),s=c.Radius(),a=[c.center.X()+s*Math.cos(this.position+h),c.center.Y()+s*Math.sin(this.position+h)]):(this.updateConstraint(),a=i.projectPointToCurve(this,c,this.board).usrCoords)):c.elementClass===n.OBJECT_CLASS_POINT&&(a=i.projectPointToPoint(this,c,this.board).usrCoords),this.coords.setCoordinates(n.COORDS_BY_USER,a,!1),void 0):(this.needsUpdateFromParent=!0,void 0)},updateRenderer:function(){var t;return this.needsUpdate?(this.visProp.visible&&this.visProp.size>0&&(t=this.isReal,this.isReal=!isNaN(this.coords.usrCoords[1]+this.coords.usrCoords[2]),this.isReal=Math.abs(this.coords.usrCoords[0])>r.eps?this.isReal:!1,this.isReal?(t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.show(this.label.content)),this.board.renderer.updatePoint(this)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.hide(this.label.content))),this.hasLabel&&this.visProp.visible&&this.label.content&&this.label.content.visProp.visible&&this.isReal&&(this.label.content.update(),this.board.renderer.updateText(this.label.content)),this.needsUpdate=!1,this):this},X:function(){return this.coords.usrCoords[1]},Y:function(){return this.coords.usrCoords[2]},Z:function(){return this.coords.usrCoords[0]},XEval:function(){return this.coords.usrCoords[1]},YEval:function(){return this.coords.usrCoords[2]},ZEval:function(){return this.coords.usrCoords[0]},bounds:function(){return this.coords.usrCoords.slice(1).concat(this.coords.usrCoords.slice(1))},Dist:function(t){var e,r,i=0/0,s=t.coords.usrCoords,o=this.coords.usrCoords;return this.isReal&&t.isReal&&(r=o[0]-s[0],e=r*r,r=o[1]-s[1],e+=r*r,r=o[2]-s[2],e+=r*r,i=Math.sqrt(e)),i},snapToGrid:function(){return this.handleSnapToGrid()},handleSnapToGrid:function(){var t,e,r=this.visProp.snapsizex,i=this.visProp.snapsizey;return this.visProp.snaptogrid&&(t=this.coords.usrCoords[1],e=this.coords.usrCoords[2],0>=r&&this.board.defaultAxes&&this.board.defaultAxes.x.defaultTicks&&(r=this.board.defaultAxes.x.defaultTicks.ticksDelta*(this.board.defaultAxes.x.defaultTicks.visProp.minorticks+1)),0>=i&&this.board.defaultAxes&&this.board.defaultAxes.y.defaultTicks&&(i=this.board.defaultAxes.y.defaultTicks.ticksDelta*(this.board.defaultAxes.y.defaultTicks.visProp.minorticks+1)),r>0&&i>0&&this.coords.setCoordinates(n.COORDS_BY_USER,[Math.round(t/r)*r,Math.round(e/i)*i])),this},handleSnapToPoints:function(){var t,e,r,s=0,o=1/0,a=null;if(this.visProp.snaptopoints){for(t=0;this.board.objectsList.length>t;t++)e=this.board.objectsList[t],e.elementClass===n.OBJECT_CLASS_POINT&&e!==this&&e.visProp.visible&&(r=i.projectPointToPoint(this,e,this.board),s=r.distance(n.COORDS_BY_USER,this.coords),this.visProp.attractordistance>s&&o>s&&(o=s,a=r));null!==a&&this.coords.setCoordinates(n.COORDS_BY_USER,a.usrCoords)}return this},handleAttractors:function(){var t,e,r,s=0,o=this.visProp.attractors.length;if(0!==this.visProp.attractordistance){for(t=0;o>t;t++)if(e=this.board.select(this.visProp.attractors[t]),c.exists(e)&&e!==this){if(e.elementClass===n.OBJECT_CLASS_POINT?r=i.projectPointToPoint(this,e,this.board):e.elementClass===n.OBJECT_CLASS_LINE?r=i.projectPointToLine(this,e,this.board):e.elementClass===n.OBJECT_CLASS_CIRCLE?r=i.projectPointToCircle(this,e,this.board):e.elementClass===n.OBJECT_CLASS_CURVE?r=i.projectPointToCurve(this,e,this.board):e.type===n.OBJECT_TYPE_TURTLE&&(r=i.projectPointToTurtle(this,e,this.board)),s=r.distance(n.COORDS_BY_USER,this.coords),this.visProp.attractordistance>s){(this.type!==n.OBJECT_TYPE_GLIDER||this.slideObject!==e)&&this.makeGlider(e);break}e===this.slideObject&&s>=this.visProp.snatchdistance&&(this.type=n.OBJECT_TYPE_POINT)}return this}},setPositionDirectly:function(t,e){var i,s;if(this.coords,this.coords.setCoordinates(t,e),this.handleSnapToGrid(),this.handleSnapToPoints(),this.handleAttractors(),0===this.group.length){for(i=this.transformations.length-1;i>=0;i--)t===n.COORDS_BY_SCREEN?s=new o(t,e,this.board).usrCoords:(2===e.length&&(e=[1].concat(e)),s=e),this.initialCoords.setCoordinates(n.COORDS_BY_USER,r.matVecMult(r.inverse(this.transformations[i].matrix),s));this.update()}return this.board.isSuspendedUpdate&&this.type===n.OBJECT_TYPE_GLIDER&&this.updateGlider(),e},setPositionByTransform:function(t,e){var r;return e=new o(t,e,this.board),r=this.board.create("transform",e.usrCoords.slice(1),{type:"translate"}),this.transformations.length>0&&this.transformations[this.transformations.length-1].isNumericMatrix?this.transformations[this.transformations.length-1].melt(r):this.addTransform(this,r),this.update(),this},setPosition:function(t,e){return this.setPositionDirectly(t,e)},setGliderPosition:function(t){return this.type===n.OBJECT_TYPE_GLIDER&&(this.position=t,this.board.update()),this},makeGlider:function(t){return this.slideObject=this.board.select(t),this.type=n.OBJECT_TYPE_GLIDER,this.elType="glider",this.visProp.snapwidth=-1,this.slideObject.addChild(this),this.isDraggable=!0,this.generatePolynomial=function(){return this.slideObject.generatePolynomial(this)},this.updateGlider(),this},free:function(){var t,e;if(this.type!==n.OBJECT_TYPE_GLIDER){if(this.isDraggable)return;this.isDraggable=!0,this.type=n.OBJECT_TYPE_POINT,this.XEval=function(){return this.coords.usrCoords[1]},this.YEval=function(){return this.coords.usrCoords[2]},this.ZEval=function(){return this.coords.usrCoords[0]},this.Xjc=null,this.Yjc=null}for(t in this.board.objects)this.board.objects.hasOwnProperty(t)&&(e=this.board.objects[t],e.descendants&&(delete e.descendants[this.id],delete e.childElements[this.id],this.hasLabel&&(delete e.descendants[this.label.content.id],delete e.childElements[this.label.content.id])));this.ancestors={},this.slideObject=null,this.elType="point",this.type=n.OBJECT_TYPE_POINT},addConstraint:function(t){var e,r,i=[],s=["X","Y"],o=function(t){return function(){return t}},a=function(t){return function(){return t.Value()}};for(this.type=n.OBJECT_TYPE_CAS,this.isDraggable=!1,e=0;t.length>e;e++)r=t[e],"string"==typeof r?(i[e]=this.board.jc.snippet(r,!0,null,!0),2===t.length&&(this[s[e]+"jc"]=t[e])):"function"==typeof r?i[e]=r:"number"==typeof r?i[e]=o(r):"object"==typeof r&&"function"==typeof r.Value&&(i[e]=a(r)),i[e].origin=r;return 1===t.length?this.updateConstraint=function(){var t=i[0]();c.isArray(t)?this.coords.setCoordinates(n.COORDS_BY_USER,t):this.coords=t}:2===t.length?(this.XEval=i[0],this.YEval=i[1],this.parents=[i[0].origin,i[1].origin],this.updateConstraint=function(){this.coords.setCoordinates(n.COORDS_BY_USER,[this.XEval(),this.YEval()])}):(this.ZEval=i[0],this.XEval=i[1],this.YEval=i[2],this.parents=[i[0].origin,i[1].origin,i[2].origin],this.updateConstraint=function(){this.coords.setCoordinates(n.COORDS_BY_USER,[this.ZEval(),this.XEval(),this.YEval()])}),this.board.isSuspendedUpdate||this.prepareUpdate().update().updateRenderer(),this},updateTransform:function(){var t,e;if(0===this.transformations.length||null===this.baseElement)return this;for(t=this===this.baseElement?this.transformations[0].apply(this.baseElement,"self"):this.transformations[0].apply(this.baseElement),this.coords.setCoordinates(n.COORDS_BY_USER,t),e=1;this.transformations.length>e;e++)this.coords.setCoordinates(n.COORDS_BY_USER,this.transformations[e].apply(this));return this},addTransform:function(t,e){var r,i=c.isArray(e)?e:[e],s=i.length;for(0===this.transformations.length&&(this.baseElement=t),r=0;s>r;r++)this.transformations.push(i[r]);return this},startAnimation:function(t,e){var r=this;return this.type!==n.OBJECT_TYPE_GLIDER||c.exists(this.intervalCode)||(this.intervalCode=window.setInterval(function(){r._anim(t,e)},250),c.exists(this.intervalCount)||(this.intervalCount=0)),this},stopAnimation:function(){return c.exists(this.intervalCode)&&(window.clearInterval(this.intervalCode),delete this.intervalCode),this},moveAlong:function(t,e,r){r=r||{};var i,o,a=[],h=[],l=this.board.attr.animationdelay,d=e/l,u=function(e,r){return function(){return t[e][r]}};if(c.isArray(t)){for(i=0;t.length>i;i++)h[i]=c.isPoint(t[i])?t[i]:{elementClass:n.OBJECT_CLASS_POINT,X:u(i,0),Y:u(i,1)};if(e=e||0,0===e)return this.setPosition(n.COORDS_BY_USER,[h[h.length-1].X(),h[h.length-1].Y()]),this.board.update(this);if(!c.exists(r.interpolate)||r.interpolate)for(o=s.Neville(h),i=0;d>i;i++)a[i]=[],a[i][0]=o[0]((d-i)/d*o[3]()),a[i][1]=o[1]((d-i)/d*o[3]());else for(i=0;d>i;i++)a[i]=[],a[i][0]=t[Math.floor((d-i)/d*(t.length-1))][0],a[i][1]=t[Math.floor((d-i)/d*(t.length-1))][1];this.animationPath=a}else c.isFunction(t)&&(this.animationPath=t,this.animationStart=(new Date).getTime());return this.animationCallback=r.callback,this.board.addAnimation(this),this},moveTo:function(t,e,i){i=i||{},t=new o(n.COORDS_BY_USER,t,this.board);var s,a=this.board.attr.animationdelay,h=Math.ceil(e/a),l=[],d=this.coords.usrCoords[1],u=this.coords.usrCoords[2],p=t.usrCoords[1]-d,f=t.usrCoords[2]-u,b=function(t){return i.effect&&"<>"===i.effect?Math.pow(Math.sin(t/h*Math.PI/2),2):t/h};if(!c.exists(e)||0===e||Math.abs(t.usrCoords[0]-this.coords.usrCoords[0])>r.eps)return this.setPosition(n.COORDS_BY_USER,t.usrCoords),this.board.update(this);if(Math.abs(p)<r.eps&&Math.abs(f)<r.eps)return this;for(s=h;s>=0;s--)l[h-s]=[t.usrCoords[0],d+p*b(s),u+f*b(s)];return this.animationPath=l,this.animationCallback=i.callback,this.board.addAnimation(this),this},visit:function(t,e,r){t=new o(n.COORDS_BY_USER,t,this.board);var i,s,a,h=this.board.attr.animationdelay,l=[],d=this.coords.usrCoords[1],u=this.coords.usrCoords[2],p=t.usrCoords[1]-d,f=t.usrCoords[2]-u,b=function(t){var e=a/2>t?2*t/a:2*(a-t)/a;return r.effect&&"<>"===r.effect?Math.pow(Math.sin(e*Math.PI/2),2):e};for("number"==typeof r?r={repeat:r}:(r=r||{},c.exists(r.repeat)||(r.repeat=1)),a=Math.ceil(e/(h*r.repeat)),s=0;r.repeat>s;s++)for(i=a;i>=0;i--)l[s*(a+1)+a-i]=[t.usrCoords[0],d+p*b(i),u+f*b(i)];return this.animationPath=l,this.animationCallback=r.callback,this.board.addAnimation(this),this},_anim:function(t,e){var r,s,o,a,h,c,l,d,u=1;return this.intervalCount+=1,this.intervalCount>e&&(this.intervalCount=0),this.slideObject.elementClass===n.OBJECT_CLASS_LINE?(r=this.slideObject.point1.coords.distance(n.COORDS_BY_SCREEN,this.slideObject.point2.coords),s=this.slideObject.getSlope(),1/0!==s?(h=Math.atan(s),o=Math.round(this.intervalCount/e*r*Math.cos(h)),a=Math.round(this.intervalCount/e*r*Math.sin(h))):(o=0,a=Math.round(this.intervalCount/e*r)),0>t?(c=this.slideObject.point2,this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]>0?u=-1:0===this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]&&this.slideObject.point2.coords.scrCoords[2]-this.slideObject.point1.coords.scrCoords[2]>0&&(u=-1)):(c=this.slideObject.point1,this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]>0?u=-1:0===this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]&&this.slideObject.point1.coords.scrCoords[2]-this.slideObject.point2.coords.scrCoords[2]>0&&(u=-1)),this.coords.setCoordinates(n.COORDS_BY_SCREEN,[c.coords.scrCoords[1]+u*o,c.coords.scrCoords[2]+u*a])):this.slideObject.elementClass===n.OBJECT_CLASS_CURVE?(l=t>0?Math.round(this.intervalCount/e*this.board.canvasWidth):Math.round((e-this.intervalCount)/e*this.board.canvasWidth),this.coords.setCoordinates(n.COORDS_BY_SCREEN,[l,0]),this.coords=i.projectPointToCurve(this,this.slideObject,this.board)):this.slideObject.elementClass===n.OBJECT_CLASS_CIRCLE&&(h=0>t?2*(this.intervalCount/e)*Math.PI:2*((e-this.intervalCount)/e)*Math.PI,d=this.slideObject.Radius(),this.coords.setCoordinates(n.COORDS_BY_USER,[this.slideObject.center.coords.usrCoords[1]+d*Math.cos(h),this.slideObject.center.coords.usrCoords[2]+d*Math.sin(h)])),this.board.update(this),this},setStyle:function(t){var e=["cross","cross","cross","circle","circle","circle","circle","square","square","square","plus","plus","plus"],r=[2,3,4,1,2,3,4,2,3,4,2,3,4];return this.visProp.face=e[t],this.visProp.size=r[t],this.board.renderer.changePointStyle(this),this},normalizeFace:function(t){return e.normalizePointFace(t)},remove:function(){this.hasLabel&&this.board.renderer.remove(this.board.renderer.getElementById(this.label.content.id)),this.board.renderer.remove(this.board.renderer.getElementById(this.id))},getTextAnchor:function(){return this.coords},getLabelAnchor:function(){return this.coords},face:function(t){this.setAttribute({face:t})},size:function(t){this.setAttribute({size:t})},cloneToBackground:function(){var t={};return t.id=this.id+"T"+this.numTraces,this.numTraces+=1,t.coords=this.coords,t.visProp=c.deepCopy(this.visProp,this.visProp.traceattributes,!0),t.visProp.layer=this.board.options.layer.trace,t.elementClass=n.OBJECT_CLASS_POINT,t.board=this.board,c.clearVisPropOld(t),this.board.renderer.drawPoint(t),this.traces[t.id]=t.rendNode,this},getParents:function(){var t=[this.Z(),this.X(),this.Y()];return this.parents&&(t=this.parents),this.type===n.OBJECT_TYPE_GLIDER&&(t=[this.X(),this.Y(),this.slideObject.id]),t}}),t.createPoint=function(e,r,i){var s,o,n,a=!1;for(n=c.copyAttributes(i,e.options,"point"),o=0;r.length>o;o++)("function"==typeof r[o]||"string"==typeof r[o])&&(a=!0);if(a)s=new t.Point(e,[0/0,0/0],n),s.addConstraint(r);else if(c.isNumber(r[0])&&c.isNumber(r[1]))s=new t.Point(e,r,n),c.exists(n.slideobject)?s.makeGlider(n.slideobject):s.baseElement=s,s.isDraggable=!0;else{if("object"!=typeof r[0]||"object"!=typeof r[1])throw Error("JSXGraph: Can't create point with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [x,y], [z,x,y], [point,transformation]");s=new t.Point(e,[0,0],n),s.addTransform(r[0],r[1]),s.isDraggable=!1,s.parents=[r[0].id]}return e.isSuspendedUpdate||(s.handleSnapToGrid(),s.handleSnapToPoints(),s.handleAttractors()),s},t.createGlider=function(t,e,r){var i,s=c.copyAttributes(r,t.options,"glider");return i=1===e.length?t.create("point",[0,0],s):t.create("point",e.slice(0,2),s),i.makeGlider(e[e.length-1]),i},t.createIntersectionPoint=function(t,e,r){var s,a,h,l,d,u,p=c.copyAttributes(r,t.options,"intersection");e.push(0,0),s=t.create("point",[0,0,0],p),a=t.select(e[0]),h=t.select(e[1]),d=e[2],u=e[3],l=a.elementClass===n.OBJECT_CLASS_CURVE&&h.elementClass===n.OBJECT_CLASS_CURVE?function(){return i.meetCurveCurve(a,h,d,u,a.board)}:a.elementClass===n.OBJECT_CLASS_CURVE&&h.elementClass===n.OBJECT_CLASS_LINE||h.elementClass===n.OBJECT_CLASS_CURVE&&a.elementClass===n.OBJECT_CLASS_LINE?function(){return i.meetCurveLine(a,h,d,a.board,s.visProp.alwaysintersect)}:a.elementClass===n.OBJECT_CLASS_LINE&&h.elementClass===n.OBJECT_CLASS_LINE?function(){var t,e,r=a.visProp.straightfirst,c=h.visProp.straightfirst,l=a.visProp.straightlast,u=h.visProp.straightlast;return s.visProp.alwaysintersect||r&&l&&c&&u?i.meet(a.stdform,h.stdform,d,a.board):(t=i.meetSegmentSegment(a.point1.coords.usrCoords,a.point2.coords.usrCoords,h.point1.coords.usrCoords,h.point2.coords.usrCoords,a.board),e=!r&&0>t[1]||!l&&t[1]>1||!c&&0>t[2]||!u&&t[2]>1?[0,0/0,0/0]:t[0],new o(n.COORDS_BY_USER,e,a.board))}:function(){return i.meet(a.stdform,h.stdform,d,a.board)},s.addConstraint([l]);try{a.addChild(s),h.addChild(s)}catch(f){throw Error("JSXGraph: Can't create 'intersection' with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'.")}return s.type=n.OBJECT_TYPE_INTERSECTION,s.elType="intersection",s.parents=[a.id,h.id,d,u],s.generatePolynomial=function(){var t=a.generatePolynomial(s),e=h.generatePolynomial(s);return 0===t.length||0===e.length?[]:[t[0],e[0]]},s},t.createOtherIntersectionPoint=function(t,e,s){var o,a,h,l;if(3!==e.length||!c.isPoint(e[2])||e[0].elementClass!==n.OBJECT_CLASS_LINE&&e[0].elementClass!==n.OBJECT_CLASS_CIRCLE||e[1].elementClass!==n.OBJECT_CLASS_LINE&&e[1].elementClass!==n.OBJECT_CLASS_CIRCLE)throw Error("JSXGraph: Can't create 'other intersection point' with parent types '"+typeof e[0]+"',  '"+typeof e[1]+"'and  '"+typeof e[2]+"'."+"\nPossible parent types: [circle|line,circle|line,point]");return a=t.select(e[0]),h=t.select(e[1]),l=t.select(e[2]),o=t.create("point",[function(){var t=i.meet(a.stdform,h.stdform,0,a.board);return Math.abs(l.X()-t.usrCoords[1])>r.eps||Math.abs(l.Y()-t.usrCoords[2])>r.eps||Math.abs(l.Z()-t.usrCoords[0])>r.eps?t:i.meet(a.stdform,h.stdform,1,a.board)}],s),o.type=n.OBJECT_TYPE_INTERSECTION,o.elType="otherintersection",o.parents=[a.id,h.id,l],a.addChild(o),h.addChild(o),o.generatePolynomial=function(){var t=a.generatePolynomial(o),e=h.generatePolynomial(o);return 0===t.length||0===e.length?[]:[t[0],e[0]]},o},t.registerElement("point",t.createPoint),t.registerElement("glider",t.createGlider),t.registerElement("intersection",t.createIntersectionPoint),t.registerElement("otherintersection",t.createOtherIntersectionPoint),{Point:t.Point,createPoint:t.createPoint,createGlider:t.createGlider,createIntersection:t.createIntersectionPoint,createOtherIntersection:t.createOtherIntersectionPoint}}),define("utils/expect",["jxg","utils/type","base/constants","base/coords","base/point"],function(t,e,r,i){var s={each:function(t,e,r){var i,s=[];for(i=0;t.length>i;i++)s.push(e.call(this,t[i],r));return s},coords:function(t,e){var s=t;return t&&t.elementClass===r.OBJECT_CLASS_POINT?s=t.coords:t.usrCoords&&t.scrCoords&&t.usr2screen&&(s=t),e&&(s=new i(r.COORDS_BY_USER,s.usrCoords,s.board)),s},coordsArray:function(t,r){var i;return i=e.isArray(t)?t:this.coords(t).usrCoords,3>i.length&&i.unshift(1),r&&(i=[i[0],i[1],i[2]]),i}};return t.Expect=s,s}),define("math/statistics",["jxg","base/constants","math/math","utils/type"],function(t,e,r,i){return r.Statistics={sum:function(t){var e,r=t.length,i=0;for(e=0;r>e;e++)i+=t[e];return i},prod:function(t){var e,r=t.length,i=1;for(e=0;r>e;e++)i*=t[e];return i},mean:function(t){return t.length>0?this.sum(t)/t.length:0},median:function(t){var e,r;return t.length>0?(e=t.slice(0),e.sort(function(t,e){return t-e}),r=e.length,1===r%2?e[parseInt(.5*r,10)]:.5*(e[.5*r-1]+e[.5*r])):0},variance:function(t){var e,r,i,s=t.length;if(s>1){for(e=this.mean(t),r=0,i=0;s>i;i++)r+=(t[i]-e)*(t[i]-e);return r/(t.length-1)}return 0},sd:function(t){return Math.sqrt(this.variance(t))},weightedMean:function(t,e){if(t.length!==e.length)throw Error("JSXGraph error (Math.Statistics.weightedMean): Array dimension mismatch.");return t.length>0?this.mean(this.multiply(t,e)):0},max:function(t){return Math.max.apply(this,t)},min:function(t){return Math.min.apply(this,t)},range:function(t){return[this.min(t),this.max(t)]},abs:function(t){var e,r,s;if(i.isArray(t))for(r=t.length,s=[],e=0;r>e;e++)s[e]=Math.abs(t[e]);else s=Math.abs(t);return s},add:function(t,e){var r,s,o=[];if(t=i.evalSlider(t),e=i.evalSlider(e),i.isArray(t)&&i.isNumber(e))for(s=t.length,r=0;s>r;r++)o[r]=t[r]+e;else if(i.isNumber(t)&&i.isArray(e))for(s=e.length,r=0;s>r;r++)o[r]=t+e[r];else if(i.isArray(t)&&i.isArray(e))for(s=Math.min(t.length,e.length),r=0;s>r;r++)o[r]=t[r]+e[r];else o=t+e;return o},div:function(t,e){var r,s,o=[];if(t=i.evalSlider(t),e=i.evalSlider(e),i.isArray(t)&&i.isNumber(e))for(s=t.length,r=0;s>r;r++)o[r]=t[r]/e;else if(i.isNumber(t)&&i.isArray(e))for(s=e.length,r=0;s>r;r++)o[r]=t/e[r];else if(i.isArray(t)&&i.isArray(e))for(s=Math.min(t.length,e.length),r=0;s>r;r++)o[r]=t[r]/e[r];else o=t/e;return o},divide:t.shortcut(r.Statistics,"div"),mod:function(t,e,s){var o,n,a=[],h=function(t,e){return t%e};if(s=i.def(s,!1),s&&(h=r.mod),t=i.evalSlider(t),e=i.evalSlider(e),i.isArray(t)&&i.isNumber(e))for(n=t.length,o=0;n>o;o++)a[o]=h(t[o],e);else if(i.isNumber(t)&&i.isArray(e))for(n=e.length,o=0;n>o;o++)a[o]=h(t,e[o]);else if(i.isArray(t)&&i.isArray(e))for(n=Math.min(t.length,e.length),o=0;n>o;o++)a[o]=h(t[o],e[o]);else a=h(t,e);return a},multiply:function(t,e){var r,s,o=[];if(t=i.evalSlider(t),e=i.evalSlider(e),i.isArray(t)&&i.isNumber(e))for(s=t.length,r=0;s>r;r++)o[r]=t[r]*e;else if(i.isNumber(t)&&i.isArray(e))for(s=e.length,r=0;s>r;r++)o[r]=t*e[r];else if(i.isArray(t)&&i.isArray(e))for(s=Math.min(t.length,e.length),r=0;s>r;r++)o[r]=t[r]*e[r];else o=t*e;return o},subtract:function(t,e){var r,s,o=[];if(t=i.evalSlider(t),e=i.evalSlider(e),i.isArray(t)&&i.isNumber(e))for(s=t.length,r=0;s>r;r++)o[r]=t[r]-e;else if(i.isNumber(t)&&i.isArray(e))for(s=e.length,r=0;s>r;r++)o[r]=t-e[r];else if(i.isArray(t)&&i.isArray(e))for(s=Math.min(t.length,e.length),r=0;s>r;r++)o[r]=t[r]-e[r];else o=t-e;return o},TheilSenRegression:function(t){var e,i,s=[],o=[],n=[];for(e=0;t.length>e;e++){for(o.length=0,i=0;t.length>i;i++)Math.abs(t[i].usrCoords[1]-t[e].usrCoords[1])>r.eps&&(o[i]=(t[i].usrCoords[2]-t[e].usrCoords[2])/(t[i].usrCoords[1]-t[e].usrCoords[1]));s[e]=this.median(o),n.push(t[e].usrCoords[2]-s[e]*t[e].usrCoords[1])}return[this.median(n),this.median(s),-1]}},r.Statistics}),define("utils/zip",["jxg"],function(t){var e=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],o=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],n=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],a=256;return t.Util=t.Util||{},t.Util.Unzip=function(h){function c(){return j+=8,L>Y?h[Y++]:-1}function l(){B=1}function d(){var t;return j++,t=1&B,B>>=1,0===B&&(B=c(),t=1&B,B=128|B>>1),t}function u(t){for(var r=0,i=t;i--;)r=r<<1|d();return t&&(r=e[r]>>8-t),r}function p(){N=0}function f(t){E++,M[N++]=t,w.push(String.fromCharCode(t)),32768===N&&(N=0)}function b(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1}function m(){for(;;){if(U[G]>=T)return-1;if(O[U[G]]===G)return U[G]++;U[G]++}}function g(){var t,e=J[I];if(17===G)return-1;if(I++,G++,t=m(),t>=0)e.b0=t;else if(e.b0=32768,g())return-1;if(t=m(),t>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=J[I],e.jumppos=I,g())return-1;return G--,0}function v(t,e,r){var i;for(J=t,I=0,O=r,T=e,i=0;17>i;i++)U[i]=0;return G=0,g()?-1:0}function C(t){for(var e,r,i,s=0,o=t[s];;)if(i=d()){if(!(32768&o.b1))return o.b1;
for(o=o.jump,e=t.length,r=0;e>r;r++)if(t[r]===o){s=r;break}}else{if(!(32768&o.b0))return o.b0;s++,o=t[s]}}function y(){var a,h,m,g,y,P,_,E,S,O,T,x,w,k,A,R,L;do if(a=d(),m=u(2),0===m)for(l(),O=c(),O|=c()<<8,x=c(),x|=c()<<8,65535&(O^~x)&&t.debug("BlockLen checksum mismatch\n");O--;)h=c(),f(h);else if(1===m)for(;;)if(y=e[u(7)]>>1,y>23?(y=y<<1|d(),y>199?(y-=128,y=y<<1|d()):(y-=48,y>143&&(y+=136))):y+=256,256>y)f(y);else{if(256===y)break;for(y-=257,S=u(i[y])+r[y],y=e[u(5)]>>3,o[y]>8?(T=u(8),T|=u(o[y]-8)<<8):T=u(o[y]),T+=s[y],y=0;S>y;y++)h=M[32767&N-T],f(h)}else if(2===m){for(_=Array(320),k=257+u(5),A=1+u(5),R=4+u(4),y=0;19>y;y++)_[y]=0;for(y=0;R>y;y++)_[n[y]]=u(3);for(S=X.length,g=0;S>g;g++)X[g]=new b;if(v(X,19,_,0))return p(),1;for(w=k+A,g=0,L=-1;w>g;)if(L++,y=C(X),16>y)_[g++]=y;else if(16===y){if(y=3+u(2),g+y>w)return p(),1;for(P=g?_[g-1]:0;y--;)_[g++]=P}else{if(y=17===y?3+u(3):11+u(7),g+y>w)return p(),1;for(;y--;)_[g++]=0}for(S=D.length,g=0;S>g;g++)D[g]=new b;if(v(D,k,_,0))return p(),1;for(S=D.length,g=0;S>g;g++)X[g]=new b;for(E=[],g=k;_.length>g;g++)E[g-k]=_[g];if(v(X,A,E,0))return p(),1;for(;;)if(y=C(D),y>=256){if(y-=256,0===y)break;for(y-=1,S=u(i[y])+r[y],y=C(X),o[y]>8?(T=u(8),T|=u(o[y]-8)<<8):T=u(o[y]),T+=s[y];S--;)h=M[32767&N-T],f(h)}else f(y)}while(!a);return p(),l(),0}function P(){var t,e,r,i,s,o,n,h,l=[];if(w=[],R=!1,l[0]=c(),l[1]=c(),120===l[0]&&218===l[1]&&(y(),A[k]=[w.join(""),"geonext.gxt"],k++),31===l[0]&&139===l[1]&&(x(),A[k]=[w.join(""),"file"],k++),80===l[0]&&75===l[1]&&(R=!0,l[2]=c(),l[3]=c(),3===l[2]&&4===l[3])){for(l[0]=c(),l[1]=c(),_=c(),_|=c()<<8,h=c(),h|=c()<<8,c(),c(),c(),c(),n=c(),n|=c()<<8,n|=c()<<16,n|=c()<<24,o=c(),o|=c()<<8,o|=c()<<16,o|=c()<<24,s=c(),s|=c()<<8,s|=c()<<16,s|=c()<<24,i=c(),i|=c()<<8,r=c(),r|=c()<<8,t=0,F=[];i--;)e=c(),"/"===e|":"===e?t=0:a-1>t&&(F[t++]=String.fromCharCode(e));for(S||(S=F),t=0;r>t;)e=c(),t++;E=0,8===h&&(y(),A[k]=Array(2),A[k][0]=w.join(""),A[k][1]=F.join(""),k++),x()}}var _,E,S,O,T,x,w=[],k=0,A=[],M=Array(32768),N=0,R=!1,L=h.length,Y=0,B=1,j=0,D=Array(288),X=Array(32),I=0,J=null,G=(Array(64),Array(64),0),U=Array(17),F=[];U[0]=0,x=function(){var t,e,r,i,s,o,n=[];if(8&_&&(n[0]=c(),n[1]=c(),n[2]=c(),n[3]=c(),80===n[0]&&75===n[1]&&7===n[2]&&8===n[3]?(t=c(),t|=c()<<8,t|=c()<<16,t|=c()<<24):t=n[0]|n[1]<<8|n[2]<<16|n[3]<<24,e=c(),e|=c()<<8,e|=c()<<16,e|=c()<<24,r=c(),r|=c()<<8,r|=c()<<16,r|=c()<<24),R&&P(),n[0]=c(),8===n[0]){if(_=c(),c(),c(),c(),c(),c(),i=c(),4&_)for(n[0]=c(),n[2]=c(),G=n[0]+256*n[1],s=0;G>s;s++)c();if(8&_)for(s=0,F=[],o=c();o;)("7"===o||":"===o)&&(s=0),a-1>s&&(F[s++]=o),o=c();if(16&_)for(o=c();o;)o=c();2&_&&(c(),c()),y(),t=c(),t|=c()<<8,t|=c()<<16,t|=c()<<24,r=c(),r|=c()<<8,r|=c()<<16,r|=c()<<24,R&&P()}},t.Util.Unzip.prototype.unzipFile=function(t){var e;for(this.unzip(),e=0;A.length>e;e++)if(A[e][1]===t)return A[e][0];return""},t.Util.Unzip.prototype.unzip=function(){return P(),A}},t.Util}),define("utils/encoding",["jxg"],function(t){return t.Util=t.Util||{},t.Util.UTF8={encode:function(t){var e,r,i="",s=t.length;for(t=t.replace(/\r\n/g,"\n"),e=0;s>e;e++)r=t.charCodeAt(e),128>r?i+=String.fromCharCode(r):r>127&&2048>r?(i+=String.fromCharCode(192|r>>6),i+=String.fromCharCode(128|63&r)):(i+=String.fromCharCode(224|r>>12),i+=String.fromCharCode(128|63&r>>6),i+=String.fromCharCode(128|63&r));return i},decode:function(t){for(var e=[],r=0,i=0,s=0,o=0,n=t.length;n>r;)i=t.charCodeAt(r),128>i?(e.push(String.fromCharCode(i)),r++):i>191&&224>i?(s=t.charCodeAt(r+1),e.push(String.fromCharCode((31&i)<<6|63&s)),r+=2):(s=t.charCodeAt(r+1),o=t.charCodeAt(r+2),e.push(String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)),r+=3);return e.join("")},asciiCharCodeAt:function(t,e){var r=t.charCodeAt(e);if(r>255)switch(r){case 8364:r=128;break;case 8218:r=130;break;case 402:r=131;break;case 8222:r=132;break;case 8230:r=133;break;case 8224:r=134;break;case 8225:r=135;break;case 710:r=136;break;case 8240:r=137;break;case 352:r=138;break;case 8249:r=139;break;case 338:r=140;break;case 381:r=142;break;case 8216:r=145;break;case 8217:r=146;break;case 8220:r=147;break;case 8221:r=148;break;case 8226:r=149;break;case 8211:r=150;break;case 8212:r=151;break;case 732:r=152;break;case 8482:r=153;break;case 353:r=154;break;case 8250:r=155;break;case 339:r=156;break;case 382:r=158;break;case 376:r=159;break;default:}return r}},t.Util.UTF8}),define("utils/base64",["jxg","utils/encoding"],function(t,e){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return t.Util=t.Util||{},t.Util.Base64={encode:function(t){var i,s,o,n,a,h,c,l=[],d=0;for(t=e.encode(t);t.length>d;)i=t.charCodeAt(d++),s=t.charCodeAt(d++),o=t.charCodeAt(d++),n=i>>2,a=(3&i)<<4|s>>4,h=(15&s)<<2|o>>6,c=63&o,isNaN(s)?h=c=64:isNaN(o)&&(c=64),l.push([r.charAt(n),r.charAt(a),r.charAt(h),r.charAt(c)].join(""));return l.join("")},decode:function(t,i){var s,o,n,a,h,c,l,d=[],u=0,p=t.length;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");p>u;)a=r.indexOf(t.charAt(u++)),h=r.indexOf(t.charAt(u++)),c=r.indexOf(t.charAt(u++)),l=r.indexOf(t.charAt(u++)),s=a<<2|h>>4,o=(15&h)<<4|c>>2,n=(3&c)<<6|l,d.push(String.fromCharCode(s)),64!==c&&d.push(String.fromCharCode(o)),64!==l&&d.push(String.fromCharCode(n));return d=d.join(""),i&&(d=e.decode(d)),d},decodeAsArray:function(t){var e,r=this.decode(t),i=[],s=r.length;for(e=0;s>e;e++)i[e]=r.charCodeAt(e);return i}},t.Util.Base64}),define("server/server",["jxg","utils/zip","utils/base64","utils/type"],function(t,e,r,i){return t.Server={modules:{},runningCalls:{},handleError:function(e){t.debug("error occured, server says: "+e.message)},callServer:function(s,o,n,a){var h,c,l,d,u,p,f;a=a||!1,d="";for(f in n)n.hasOwnProperty(f)&&(d+="&"+escape(f)+"="+escape(n[f]));p=i.toJSON(n);do u=s+Math.floor(4096*Math.random());while(i.exists(this.runningCalls[u]));return this.runningCalls[u]={action:s},i.exists(n.module)&&(this.runningCalls[u].module=n.module),h=t.serverBase+"JXGServer.py",c="action="+escape(s)+"&id="+u+"&dataJSON="+escape(r.encode(p)),this.cbp=function(t){var s,n,a,h,c,l,d,u;if(s=new e.Unzip(r.decodeAsArray(t)).unzip(),i.isArray(s)&&s.length>0&&(s=s[0][0]),i.exists(s))if(n=window.JSON&&window.JSON.parse?window.JSON.parse(s):Function("return "+s)(),"error"===n.type)this.handleError(n);else if("response"===n.type){for(l=n.id,d=0;n.fields.length>d;d++)a=n.fields[d],h=a.namespace+("object"==typeof Function("return "+a.namespace)()?".":".prototype.")+a.name+" = "+a.value,Function(h)();for(d=0;n.handler.length>d;d++){for(a=n.handler[d],c=[],u=0;a.parameters.length>u;u++)c[u]='"'+a.parameters[u]+'": '+a.parameters[u];h="if(typeof JXG.Server.modules."+this.runningCalls[l].module+' == "undefined")'+"JXG.Server.modules."+this.runningCalls[l].module+" = {};",h+="JXG.Server.modules."+this.runningCalls[l].module+"."+a.name+"_cb = "+a.callback+";",h+="JXG.Server.modules."+this.runningCalls[l].module+"."+a.name+" = function ("+a.parameters.join(",")+", __JXGSERVER_CB__, __JXGSERVER_SYNC) {"+'if(typeof __JXGSERVER_CB__ == "undefined") __JXGSERVER_CB__ = JXG.Server.modules.'+this.runningCalls[l].module+"."+a.name+"_cb;"+"var __JXGSERVER_PAR__ = {"+c.join(",")+', "module": "'+this.runningCalls[l].module+'", "handler": "'+a.name+'" };'+'JXG.Server.callServer("exec", __JXGSERVER_CB__, __JXGSERVER_PAR__, __JXGSERVER_SYNC);'+"};",Function(h)()}delete this.runningCalls[l],o(n.data)}},this.cb=t.bind(this.cbp,this),window.XMLHttpRequest?(l=new XMLHttpRequest,l.overrideMimeType("text/plain; charset=iso-8859-1")):l=new ActiveXObject("Microsoft.XMLHTTP"),l&&(l.open("POST",h,!a),l.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a||(l.onreadystatechange=function(t){return function(){return 4===l.readyState&&200===l.status?(t(l.responseText),!0):!1}}(this.cb)),l.send(c),a)?(this.cb(l.responseText),!0):!1},loadModule_cb:function(e){var r;for(r=0;e.length>r;r++)t.debug(e[r].name+": "+e[r].value)},loadModule:function(e){return t.Server.callServer("load",t.Server.loadModule_cb,{module:e},!0)}},t.Server.load=t.Server.loadModule,t.Server}),define("math/symbolic",["jxg","base/constants","base/coords","math/math","math/geometry","server/server","utils/type"],function(t,e,r,i,s,o,n){var a;return i.Symbolic={generateSymbolicCoordinatesPartial:function(t,e,r,i){var s,o,a,h=e.ancestors,c=0,l=function(t){var e;return e="underscore"===i?r+"_{"+t+"}":"brace"===i?r+"["+t+"]":r+t};t.listOfFreePoints=[],t.listOfDependantPoints=[];for(o in h)if(h.hasOwnProperty(o)&&(s=0,n.isPoint(h[o]))){for(a in h[o].ancestors)h[o].ancestors.hasOwnProperty(a)&&s++;0===s?(h[o].symbolic.x=h[o].coords.usrCoords[1],h[o].symbolic.y=h[o].coords.usrCoords[2],t.listOfFreePoints.push(h[o])):(c+=1,h[o].symbolic.x=l(c),c+=1,h[o].symbolic.y=l(c),t.listOfDependantPoints.push(h[o]))}return n.isPoint(e)&&(e.symbolic.x="x",e.symbolic.y="y"),c},clearSymbolicCoordinates:function(t){var e=function(t){var e,r=t&&t.length||0;for(e=0;r>e;e++)n.isPoint(t[e])&&(t[e].symbolic.x="",t[e].symbolic.y="")};e(t.listOfFreePoints),e(t.listOfDependantPoints),delete t.listOfFreePoints,delete t.listOfDependantPoints},generatePolynomials:function(t,e,r){var i,s,o,a,h=e.ancestors,c=[],l=[];r&&this.generateSymbolicCoordinatesPartial(t,e,"u","brace"),h[e.id]=e;for(i in h)if(h.hasOwnProperty(i)&&(a=0,c=[],n.isPoint(h[i]))){for(s in h[i].ancestors)h[i].ancestors.hasOwnProperty(s)&&a++;if(a>0)for(c=h[i].generatePolynomial(),o=0;c.length>o;o++)l.push(c[o])}return r&&this.clearSymbolicCoordinates(t),l},geometricLocusByGroebnerBase:function(t,h){var c,l,d,u,p,f,b,m,g,v,C,y,P,_=t.options.locus,E={},S=this.generateSymbolicCoordinatesPartial(t,h,"u","brace"),O=new r(e.COORDS_BY_USR,[0,0],t),T=new r(e.COORDS_BY_USR,[t.canvasWidth,t.canvasHeight],t),x=1,w=0,k=0,A=0;if(o.modules.geoloci===a&&o.loadModule("geoloci"),o.modules.geoloci===a)throw Error("JSXGraph: Unable to load JXG.Server module 'geoloci.py'.");if(b=O.usrCoords[1],m=T.usrCoords[1],g=T.usrCoords[2],v=O.usrCoords[2],_.translateToOrigin&&t.listOfFreePoints.length>0){for(u=_.toOrigin!==a&&null!==_.toOrigin&&n.isInArray(t.listOfFreePoints,_.toOrigin.id)?_.toOrigin:t.listOfFreePoints[0],w=u.symbolic.x,k=u.symbolic.y,f=0;t.listOfFreePoints.length>f;f++)t.listOfFreePoints[f].symbolic.x-=w,t.listOfFreePoints[f].symbolic.y-=k;if(b-=w,m-=w,g-=k,v-=k,_.translateTo10&&t.listOfFreePoints.length>1){for(p=_.to10!==a&&null!==_.to10&&_.to10.id!==_.toOrigin.id&&n.isInArray(t.listOfFreePoints,_.to10.id)?_.to10:t.listOfFreePoints[0].id===u.id?t.listOfFreePoints[1]:t.listOfFreePoints[0],A=s.rad([1,0],[0,0],[p.symbolic.x,p.symbolic.y]),C=Math.cos(-A),y=Math.sin(-A),f=0;t.listOfFreePoints.length>f;f++)P=t.listOfFreePoints[f].symbolic.x,t.listOfFreePoints[f].symbolic.x=C*t.listOfFreePoints[f].symbolic.x-y*t.listOfFreePoints[f].symbolic.y,t.listOfFreePoints[f].symbolic.y=y*P+C*t.listOfFreePoints[f].symbolic.y;if(p.symbolic.y=0,P=b,b=C*b-y*g,g=y*P+C*g,P=m,m=C*m-y*v,v=y*P+C*v,_.stretch&&Math.abs(p.symbolic.x)>i.eps){for(x=p.symbolic.x,f=0;t.listOfFreePoints.length>f;f++)t.listOfFreePoints[f].symbolic.x/=x,t.listOfFreePoints[f].symbolic.y/=x;for(f=0;t.objectsList.length>f;f++)t.objectsList[f].elementClass===e.OBJECT_CLASS_CIRCLE&&"pointRadius"===t.objectsList[f].method&&(E[f]=t.objectsList[f].radius,t.objectsList[f].radius/=x);b/=x,m/=x,g/=x,v/=x,p.symbolic.x=1}}for(f=0;t.listOfFreePoints.length>f;f++)P=t.listOfFreePoints[f].symbolic.x,Math.abs(P)<i.eps&&(t.listOfFreePoints[f].symbolic.x=0),Math.abs(P-Math.round(P))<i.eps&&(t.listOfFreePoints[f].symbolic.x=Math.round(P)),P=t.listOfFreePoints[f].symbolic.y,Math.abs(P)<i.eps&&(t.listOfFreePoints[f].symbolic.y=0),Math.abs(P-Math.round(P))<i.eps&&(t.listOfFreePoints[f].symbolic.y=Math.round(P))}c=this.generatePolynomials(t,h),l=c.join(","),this.cbp=function(t){d=t},this.cb=n.bind(this.cbp,this),o.modules.geoloci.lociCoCoA(b,m,g,v,S,l,x,A,w,k,this.cb,!0),this.clearSymbolicCoordinates(t);for(f in E)E.hasOwnProperty(f)&&(t.objects[f].radius=E[f]);return d}},i.Symbolic}),define("math/poly",["jxg","math/math","utils/type"],function(t,e,r){return e.Poly={},e.Poly.Ring=function(t){this.vars=t},t.extend(e.Poly.Ring.prototype,{}),e.Poly.Monomial=function(t,e,i){var s;if(!r.exists(t))throw Error("JSXGraph error: In JXG.Math.Poly.monomial missing parameter 'ring'.");for(r.isArray(i)||(i=[]),i=i.slice(0,t.vars.length),s=i.length;t.vars.length>s;s++)i.push(0);this.ring=t,this.coefficient=e||0,this.exponents=r.deepCopy(i)},t.extend(e.Poly.Monomial.prototype,{copy:function(){return new e.Poly.Monomial(this.ring,this.coefficient,this.exponents)},print:function(){var t,e=[];for(t=0;this.ring.vars.length>t;t++)e.push(this.ring.vars[t]+"^"+this.exponents[t]);return this.coefficient+"*"+e.join("*")}}),e.Poly.Polynomial=function(t,e){var i,s=function(){};if(!r.exists(t))throw Error("JSXGraph error: In JXG.Math.Poly.polynomial missing parameter 'ring'.");i=r.exists(e)&&"string"==typeof e?s(e):[],this.ring=t,this.monomials=i},t.extend(e.Poly.Polynomial.prototype,{findSignature:function(t){var e;for(e=0;this.monomials.length>e;e++)if(r.cmpArrays(this.monomials[e].exponents,t))return e;return-1},addSubMonomial:function(t,e){var r;r=this.findSignature(t.exponents),r>-1?this.monomials[r].coefficient+=e*t.coefficient:(t.coefficient*=e,this.monomials.push(t))},add:function(t){var e;if(!r.exists(t)||t.ring!==this.ring)throw Error("JSXGraph error: In JXG.Math.Poly.polynomial.add either summand is undefined or rings don't match.");if(r.isArray(t.exponents))this.addSubMonomial(t,1);else for(e=0;t.monomials.length>e;e++)this.addSubMonomial(t.monomials[e],1)},sub:function(t){var e;if(!r.exists(t)||t.ring!==this.ring)throw Error("JSXGraph error: In JXG.Math.Poly.polynomial.sub either summand is undefined or rings don't match.");if(r.isArray(t.exponents))this.addSubMonomial(t,-1);else for(e=0;t.monomials.length>e;e++)this.addSubMonomial(t.monomials[e],-1)},copy:function(){var t,r;for(r=new e.Poly.Polynomial(this.ring),t=0;this.monomials.length>t;t++)r.monomials.push(this.monomials[t].copy());return r},print:function(){var t,e=[];for(t=0;this.monomials.length>t;t++)e.push("("+this.monomials[t].print()+")");return e.join("+")}}),e.Poly}),define("math/complex",["jxg","math/math"],function(t){return t.Complex=function(t,e){this.isComplex=!0,t&&t.isComplex&&(e=t.imaginary,t=t.real),this.real=t||0,this.imaginary=e||0,this.absval=0,this.angle=0},t.extend(t.Complex.prototype,{toString:function(){return this.real+" + "+this.imaginary+"i"},add:function(t){return"number"==typeof t?this.real+=t:(this.real+=t.real,this.imaginary+=t.imaginary),this},sub:function(t){return"number"==typeof t?this.real-=t:(this.real-=t.real,this.imaginary-=t.imaginary),this},mult:function(t){var e,r;return"number"==typeof t?(this.real*=t,this.imaginary*=t):(e=this.real,r=this.imaginary,this.real=e*t.real-r*t.imaginary,this.imaginary=e*t.imaginary+r*t.real),this},div:function(t){var e,r,i;if("number"==typeof t){if(Math.abs(t)<Math.eps)return this.real=1/0,this.imaginary=1/0,this;this.real/=t,this.imaginary/=t}else{if(Math.abs(t.real)<Math.eps&&Math.abs(t.imaginary)<Math.eps)return this.real=1/0,this.imaginary=1/0,this;e=t.real*t.real+t.imaginary*t.imaginary,i=this.real,r=this.imaginary,this.real=(i*t.real+r*t.imaginary)/e,this.imaginary=(r*t.real-i*t.imaginary)/e}return this},conj:function(){return this.imaginary*=-1,this}}),t.C={},t.C.add=function(e,r){var i=new t.Complex(e);return i.add(r),i},t.C.sub=function(e,r){var i=new t.Complex(e);return i.sub(r),i},t.C.mult=function(e,r){var i=new t.Complex(e);return i.mult(r),i},t.C.div=function(e,r){var i=new t.Complex(e);return i.div(r),i},t.C.conj=function(e){var r=new t.Complex(e);return r.conj(),r},t.C.abs=function(e){var r=new t.Complex(e);return r.conj(),r.mult(e),Math.sqrt(r.real)},t.Complex.C=t.C,t.Complex}),define("renderer/abstract",["jxg","options","base/coords","base/constants","math/math","math/geometry","utils/type","utils/env"],function(t,e,r,i,s,o,n,a){return t.AbstractRenderer=function(){this.vOffsetText=0,this.enhancedRendering=!0,this.container=null,this.type=""},t.extend(t.AbstractRenderer.prototype,{_updateVisual:function(t,e,r){(r||this.enhancedRendering)&&(e=e||{},t.visProp.draft?this.setDraft(t):(e.stroke||(this.setObjectStrokeWidth(t,t.visProp.strokewidth),this.setObjectStrokeColor(t,t.visProp.strokecolor,t.visProp.strokeopacity)),e.fill||this.setObjectFillColor(t,t.visProp.fillcolor,t.visProp.fillopacity),e.dash||this.setDashStyle(t,t.visProp),e.shadow||this.setShadow(t),e.gradient||this.setShadow(t)))},drawPoint:function(t){var r,i=e.normalizePointFace(t.visProp.face);r="o"===i?"ellipse":"[]"===i?"rect":"path",this.appendChildPrim(this.createPrim(r,t.id),t.visProp.layer),this.appendNodesToElement(t,r),this._updateVisual(t,{dash:!0,shadow:!0},!0),this.updatePoint(t)},updatePoint:function(t){var r=t.visProp.size,i=e.normalizePointFace(t.visProp.face);isNaN(t.coords.scrCoords[2]+t.coords.scrCoords[1])||(this._updateVisual(t,{dash:!1,shadow:!1}),r*=t.board&&t.board.options.point.zoom?Math.sqrt(t.board.zoomX*t.board.zoomY):1,"o"===i?this.updateEllipsePrim(t.rendNode,t.coords.scrCoords[1],t.coords.scrCoords[2],r+1,r+1):"[]"===i?this.updateRectPrim(t.rendNode,t.coords.scrCoords[1]-r,t.coords.scrCoords[2]-r,2*r,2*r):this.updatePathPrim(t.rendNode,this.updatePathStringPoint(t,r,i),t.board),this.setShadow(t))},changePointStyle:function(t){var e=this.getElementById(t.id);n.exists(e)&&this.remove(e),this.drawPoint(t),n.clearVisPropOld(t),t.visProp.visible||this.hide(t),t.visProp.draft&&this.setDraft(t)},drawLine:function(t){this.appendChildPrim(this.createPrim("line",t.id),t.visProp.layer),this.appendNodesToElement(t,"lines"),this.updateLine(t)},updateLine:function(t){var e=new r(i.COORDS_BY_USER,t.point1.coords.usrCoords,t.board),s=new r(i.COORDS_BY_USER,t.point2.coords.usrCoords,t.board),n=null;(t.visProp.firstarrow||t.visProp.lastarrow)&&(n=-4),o.calcStraight(t,e,s,n),this.updateLinePrim(t.rendNode,e.scrCoords[1],e.scrCoords[2],s.scrCoords[1],s.scrCoords[2],t.board),this.makeArrows(t),this._updateVisual(t,{fill:!0})},drawTicks:function(t){var e=this.createPrim("path",t.id);this.appendChildPrim(e,t.visProp.layer),this.appendNodesToElement(t,"path")},updateTicks:function(){},drawCurve:function(t){this.appendChildPrim(this.createPrim("path",t.id),t.visProp.layer),this.appendNodesToElement(t,"path"),this._updateVisual(t,{shadow:!0},!0),this.updateCurve(t)},updateCurve:function(t){this._updateVisual(t),t.visProp.handdrawing?this.updatePathPrim(t.rendNode,this.updatePathStringBezierPrim(t),t.board):this.updatePathPrim(t.rendNode,this.updatePathStringPrim(t),t.board),t.numberPoints>1&&this.makeArrows(t)},drawEllipse:function(t){this.appendChildPrim(this.createPrim("ellipse",t.id),t.visProp.layer),this.appendNodesToElement(t,"ellipse"),this.updateEllipse(t)},updateEllipse:function(t){this._updateVisual(t);var e=t.Radius();e>0&&Math.abs(t.center.coords.usrCoords[0])>s.eps&&!isNaN(e+t.center.coords.scrCoords[1]+t.center.coords.scrCoords[2])&&2e6>e*t.board.unitX&&this.updateEllipsePrim(t.rendNode,t.center.coords.scrCoords[1],t.center.coords.scrCoords[2],e*t.board.unitX,e*t.board.unitY)},drawPolygon:function(t){this.appendChildPrim(this.createPrim("polygon",t.id),t.visProp.layer),this.appendNodesToElement(t,"polygon"),this.updatePolygon(t)},updatePolygon:function(t){this._updateVisual(t,{stroke:!0,dash:!0}),this.updatePolygonPrim(t.rendNode,t)},displayCopyright:function(){},drawInternalText:function(){},updateInternalText:function(){},drawText:function(t){var e,r;"html"===t.visProp.display&&a.isBrowser?(e=this.container.ownerDocument.createElement("div"),e.style.position="absolute",e.className=t.visProp.cssclass,r=""===this.container.style.zIndex?0:parseInt(this.container.style.zIndex,10),e.style.zIndex=r+t.board.options.layer.text,this.container.appendChild(e),e.setAttribute("id",this.container.id+"_"+t.id)):e=this.drawInternalText(t),t.rendNode=e,t.htmlStr="",this.updateText(t)},updateText:function(t){var e,r=t.plaintext;t.visProp.visible&&(this.updateTextStyle(t,!1),"html"===t.visProp.display?(isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])||("right"===t.visProp.anchorx?(e=Math.floor(t.board.canvasWidth-t.coords.scrCoords[1]),t.visPropOld.right!==e&&(t.rendNode.style.right=e+"px",t.rendNode.style.left="auto",t.visPropOld.right=e)):"middle"===t.visProp.anchorx?(e=Math.floor(t.coords.scrCoords[1]-.5*t.size[0]),t.visPropOld.left!==e&&(t.rendNode.style.left=e+"px",t.rendNode.style.right="auto",t.visPropOld.left=e)):(e=Math.floor(t.coords.scrCoords[1]),t.visPropOld.left!==e&&(t.rendNode.style.left=e+"px",t.rendNode.style.right="auto",t.visPropOld.left=e)),e="top"===t.visProp.anchory?Math.floor(t.coords.scrCoords[2]+this.vOffsetText):"middle"===t.visProp.anchory?Math.floor(t.coords.scrCoords[2]-.5*t.size[1]+this.vOffsetText):Math.floor(t.coords.scrCoords[2]-t.size[1]+this.vOffsetText),t.visPropOld.top!==e&&(t.rendNode.style.top=e+"px",t.visPropOld.top=e)),t.htmlStr!==r&&(t.rendNode.innerHTML=r,t.htmlStr=r,t.visProp.usemathjax?MathJax.Hub.Queue(["Typeset",MathJax.Hub,t.rendNode]):t.visProp.useasciimathml&&AMprocessNode(t.rendNode,!1)),this.transformImage(t,t.transformations)):this.updateInternalText(t))},updateTextStyle:function(t,e){var r,i,s,o,h=t.visProp,c=a.isBrowser?h.display:"internal";if(e?(s=h.highlightstrokecolor,i=h.highlightstrokeopacity,o=h.highlightcssclass):(s=h.strokecolor,i=h.strokeopacity,o=h.cssclass),("html"===c||"canvas"!==this.type&&"no"!==this.type)&&(r=n.evaluate(t.visProp.fontsize),t.visPropOld.fontsize!==r)){try{t.rendNode.style.fontSize=r+"px"}catch(l){t.rendNode.style.fontSize=r}t.visPropOld.fontsize=r}return"html"===c?(t.visPropOld.cssclass!==o&&(t.rendNode.className=o,t.visPropOld.cssclass=o),this.setObjectStrokeColor(t,s,i)):this.updateInternalTextStyle(t,s,i),this},updateInternalTextStyle:function(t,e,r){this.setObjectStrokeColor(t,e,r)},drawImage:function(){},updateImage:function(t){this.updateRectPrim(t.rendNode,t.coords.scrCoords[1],t.coords.scrCoords[2]-t.size[1],t.size[0],t.size[1]),this.updateImageURL(t),this.transformImage(t,t.transformations),this._updateVisual(t,{stroke:!0,dash:!0},!0)},joinTransforms:function(t,e){var r,i=[[1,0,0],[0,1,0],[0,0,1]],o=t.board.origin.scrCoords[1],n=t.board.origin.scrCoords[2],a=t.board.unitX,h=t.board.unitY,c=[[1,0,0],[-o,1,0],[-n,0,1]],l=[[1,0,0],[0,1/a,0],[0,0,-1/h]],d=[[1,0,0],[0,a,0],[0,0,-h]],u=[[1,0,0],[o,1,0],[n,0,1]],p=e.length;for(r=0;p>r;r++)i=s.matMatMult(c,i),i=s.matMatMult(l,i),i=s.matMatMult(e[r].matrix,i),i=s.matMatMult(d,i),i=s.matMatMult(u,i);return i},transformImage:function(){},updateImageURL:function(){},updateImageStyle:function(t,e){t.rendNode.className=e?t.visProp.highlightcssclass:t.visProp.cssclass},appendChildPrim:function(){},appendNodesToElement:function(){},createPrim:function(){return null},remove:function(){},makeArrows:function(){},updateEllipsePrim:function(){},updateLinePrim:function(){},updatePathPrim:function(){},updatePathStringPoint:function(){},updatePathStringPrim:function(){},updatePathStringBezierPrim:function(){},updatePolygonPrim:function(){},updateRectPrim:function(){},setPropertyPrim:function(){},show:function(){},hide:function(){},setBuffering:function(){},setDashStyle:function(){},setDraft:function(t){if(t.visProp.draft){var e=t.board.options.elements.draft.color,r=t.board.options.elements.draft.opacity;t.type===i.OBJECT_TYPE_POLYGON?this.setObjectFillColor(t,e,r):(t.elementClass===i.OBJECT_CLASS_POINT?this.setObjectFillColor(t,e,r):this.setObjectFillColor(t,"none",0),this.setObjectStrokeColor(t,e,r),this.setObjectStrokeWidth(t,t.board.options.elements.draft.strokeWidth))}},removeDraft:function(t){t.type===i.OBJECT_TYPE_POLYGON?this.setObjectFillColor(t,t.visProp.fillcolor,t.visProp.fillopacity):(t.type===i.OBJECT_CLASS_POINT&&this.setObjectFillColor(t,t.visProp.fillcolor,t.visProp.fillopacity),this.setObjectStrokeColor(t,t.visProp.strokecolor,t.visProp.strokeopacity),this.setObjectStrokeWidth(t,t.visProp.strokewidth))},setGradient:function(){},updateGradient:function(){},setObjectFillColor:function(){},setObjectStrokeColor:function(){},setObjectStrokeWidth:function(){},setShadow:function(){},highlight:function(t){var e,r=t.visProp;if(!r.draft){if(t.type===i.OBJECT_TYPE_POLYGON)for(this.setObjectFillColor(t,r.highlightfillcolor,r.highlightfillopacity),e=0;t.borders.length>e;e++)this.setObjectStrokeColor(t.borders[e],t.borders[e].visProp.highlightstrokecolor,t.borders[e].visProp.highlightstrokeopacity);else t.type===i.OBJECT_TYPE_TEXT?this.updateTextStyle(t,!0):t.type===i.OBJECT_TYPE_IMAGE?this.updateImageStyle(t,!0):(this.setObjectStrokeColor(t,r.highlightstrokecolor,r.highlightstrokeopacity),this.setObjectFillColor(t,r.highlightfillcolor,r.highlightfillopacity));r.highlightstrokewidth&&this.setObjectStrokeWidth(t,Math.max(r.highlightstrokewidth,r.strokewidth))}return this},noHighlight:function(t){var e,r=t.visProp;if(!t.visProp.draft){if(t.type===i.OBJECT_TYPE_POLYGON)for(this.setObjectFillColor(t,r.fillcolor,r.fillopacity),e=0;t.borders.length>e;e++)this.setObjectStrokeColor(t.borders[e],t.borders[e].visProp.strokecolor,t.borders[e].visProp.strokeopacity);else t.type===i.OBJECT_TYPE_TEXT?this.updateTextStyle(t,!1):t.type===i.OBJECT_TYPE_IMAGE?this.updateImageStyle(t,!1):(this.setObjectStrokeColor(t,r.strokecolor,r.strokeopacity),this.setObjectFillColor(t,r.fillcolor,r.fillopacity));this.setObjectStrokeWidth(t,r.strokewidth)}return this},suspendRedraw:function(){},unsuspendRedraw:function(){},drawZoomBar:function(t){var e,r,i=function(t){t||(t=window.event),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0},s=function(s,o){var n;n=e.createElement("span"),r.appendChild(n),n.appendChild(document.createTextNode(s)),a.addEvent(n,"click",o,t),a.addEvent(n,"mouseup",i,t),a.addEvent(n,"mousedown",i,t),a.addEvent(n,"touchend",i,t),a.addEvent(n,"touchstart",i,t)};a.isBrowser&&(e=t.containerObj.ownerDocument,r=e.createElement("div"),r.setAttribute("id",t.containerObj.id+"_navigationbar"),r.style.color=t.options.navbar.strokeColor,r.style.backgroundColor=t.options.navbar.fillColor,r.style.padding=t.options.navbar.padding,r.style.position=t.options.navbar.position,r.style.fontSize=t.options.navbar.fontSize,r.style.cursor=t.options.navbar.cursor,r.style.zIndex=t.options.navbar.zIndex,t.containerObj.appendChild(r),r.style.right=t.options.navbar.right,r.style.bottom=t.options.navbar.bottom,s(" – ",t.zoomOut),s(" o ",t.zoom100),s(" + ",t.zoomIn),s(" ← ",t.clickLeftArrow),s(" ↓ ",t.clickUpArrow),s(" ↑ ",t.clickDownArrow),s(" → ",t.clickRightArrow))},getElementById:function(t){return document.getElementById(this.container.id+"_"+t)},resize:function(){},createTouchpoints:function(){},showTouchpoint:function(){},hideTouchpoint:function(){},updateTouchpoint:function(){}}),t.AbstractRenderer}),define("renderer/no",["jxg","renderer/abstract"],function(t,e){return t.NoRenderer=function(){this.enhancedRendering=!1,this.type="no"},t.extend(t.NoRenderer.prototype,{drawPoint:function(){},updatePoint:function(){},changePointStyle:function(){},drawLine:function(){},updateLine:function(){},drawTicks:function(){},updateTicks:function(){},drawCurve:function(){},updateCurve:function(){},drawEllipse:function(){},updateEllipse:function(){},drawPolygon:function(){},updatePolygon:function(){},displayCopyright:function(){},drawInternalText:function(){},updateInternalText:function(){},drawText:function(){},updateText:function(){},updateTextStyle:function(){},updateInternalTextStyle:function(){},drawImage:function(){},updateImage:function(){},transformImage:function(){},updateImageURL:function(){},appendChildPrim:function(){},appendNodesToElement:function(){},createPrim:function(){return null},remove:function(){},makeArrows:function(){},updateEllipsePrim:function(){},updateLinePrim:function(){},updatePathPrim:function(){},updatePathStringPoint:function(){},updatePathStringPrim:function(){},updatePathStringBezierPrim:function(){},updatePolygonPrim:function(){},updateRectPrim:function(){},setPropertyPrim:function(){},show:function(){},hide:function(){},setBuffering:function(){},setDashStyle:function(){},setDraft:function(){},removeDraft:function(){},setGradient:function(){},updateGradient:function(){},setObjectFillColor:function(){},setObjectStrokeColor:function(){},setObjectStrokeWidth:function(){},setShadow:function(){},highlight:function(){},noHighlight:function(){},suspendRedraw:function(){},unsuspendRedraw:function(){},drawZoomBar:function(){},getElementById:function(){return null},resize:function(){}}),t.NoRenderer.prototype=new e,t.NoRenderer}),define("reader/file",["jxg","utils/env","utils/type","utils/encoding","utils/base64"],function(t,e,r,i,s){return t.FileReader={parseFileContent:function(e,o,n,a,h){var c=!1;r.exists(a)||(a=!0);try{c=new XMLHttpRequest,"raw"===n.toLowerCase()?c.overrideMimeType("text/plain; charset=iso-8859-1"):c.overrideMimeType("text/xml; charset=iso-8859-1")}catch(l){try{c=new ActiveXObject("Msxml2.XMLHTTP")}catch(d){try{c=new ActiveXObject("Microsoft.XMLHTTP")}catch(u){c=!1}}}if(!c)return t.debug("AJAX not activated!"),void 0;c.open("GET",e,a),this.cbp="raw"===n.toLowerCase()?function(){var t=c;4===t.readyState&&o(t.responseText)}:function(){var t=c,e="";4===t.readyState&&(e=!r.exists(t.responseStream)||"PK"!==t.responseText.slice(0,2)&&31!==i.asciiCharCodeAt(t.responseText.slice(0,1),0)?t.responseText:s.decode(jxgBinFileReader(t)),this.parseString(e,o,n,h))},this.cb=r.bind(this.cbp,this),c.onreadystatechange=this.cb;try{c.send(null)}catch(p){throw Error("JSXGraph: A problem occurred while trying to read '"+e+"'.")}},parseString:function(e,i,s,o){var n,a;if(s=s.toLowerCase(),n=t.readers[s],!r.exists(n))throw Error("JSXGraph: There is no reader available for '"+s+"'.");a=new n(i,e),a.read(),"function"==typeof o&&o(i)}},!e.isMetroApp()&&e.isBrowser&&"object"==typeof navigator&&/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)&&document&&document.write&&document.write('<script type="text/vbscript">\nFunction Base64Encode(inData)\n  Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"\n  Dim cOut, sOut, I\n  For I = 1 To LenB(inData) Step 3\n    Dim nGroup, pOut, sGroup\n    nGroup = &H10000 * AscB(MidB(inData, I, 1)) + _\n      &H100 * MyASC(MidB(inData, I + 1, 1)) + MyASC(MidB(inData, I + 2, 1))\n    nGroup = Oct(nGroup)\n    nGroup = String(8 - Len(nGroup), "0") & nGroup\n    pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _\n      Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _\n      Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _\n      Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)\n    sOut = sOut + pOut\n  Next\n  Select Case LenB(inData) Mod 3\n    Case 1: \'8 bit final\n      sOut = Left(sOut, Len(sOut) - 2) + "=="\n    Case 2: \'16 bit final\n      sOut = Left(sOut, Len(sOut) - 1) + "="\n  End Select\n  Base64Encode = sOut\nEnd Function\n\nFunction MyASC(OneChar)\n  If OneChar = "" Then MyASC = 0 Else MyASC = AscB(OneChar)\nEnd Function\n\nFunction jxgBinFileReader(xhr)\n    Dim byteString\n    Dim b64String\n    Dim i\n    byteString = xhr.responseBody\n    ReDim byteArray(LenB(byteString))\n    For i = 1 To LenB(byteString)\n        byteArray(i-1) = AscB(MidB(byteString, i, 1))\n    Next\n    b64String = Base64Encode(byteString)\n    jxgBinFileReader = b64String\nEnd Function\n</script>\n'),t.FileReader}),define("base/text",["jxg","base/constants","base/coords","base/element","parser/geonext","math/statistics","utils/env","utils/type"],function(t,e,r,i,s,o,n,a){return t.Text=function(t,i,s,o){return this.constructor(t,o,e.OBJECT_TYPE_TEXT,e.OBJECT_CLASS_OTHER),this.content="",this.plaintext="",this.isDraggable=!1,this.needsSizeUpdate=!1,this.element=this.board.select(o.anchor),this.element?(this.relativeCoords=this.visProp.islabel?new r(e.COORDS_BY_SCREEN,[parseFloat(s[0]),parseFloat(s[1])],this.board):new r(e.COORDS_BY_USER,[parseFloat(s[0]),parseFloat(s[1])],this.board),this.element.addChild(this),this.X=function(){var t,i,s;return this.visProp.islabel?(t=parseFloat(this.visProp.offset[0]),s=this.element.getLabelAnchor(),i=new r(e.COORDS_BY_SCREEN,[t+this.relativeCoords.scrCoords[1]+s.scrCoords[1],0],this.board),i.usrCoords[1]):(s=this.element.getTextAnchor(),this.relativeCoords.usrCoords[1]+s.usrCoords[1])
},this.Y=function(){var t,i,s;return this.visProp.islabel?(t=-parseFloat(this.visProp.offset[1]),s=this.element.getLabelAnchor(),i=new r(e.COORDS_BY_SCREEN,[0,t+this.relativeCoords.scrCoords[2]+s.scrCoords[2]],this.board),i.usrCoords[2]):(s=this.element.getTextAnchor(),this.relativeCoords.usrCoords[2]+s.usrCoords[2])},this.coords=new r(e.COORDS_BY_SCREEN,[0,0],this.board),this.isDraggable=!0):(a.isNumber(s[0])&&a.isNumber(s[1])&&(this.isDraggable=!0),this.X=a.createFunction(s[0],this.board,null,!0),this.Y=a.createFunction(s[1],this.board,null,!0),this.coords=new r(e.COORDS_BY_USER,[this.X(),this.Y()],this.board)),this.Z=a.createFunction(1,this.board,""),this.size=[1,1],this.id=this.board.setId(this,"T"),this.board.renderer.drawText(this),this.setText(i),this.updateSize(),this.visProp.visible||this.board.renderer.hide(this),"string"==typeof this.content&&this.notifyParents(this.content),this.elType="text",this.methodMap=a.deepCopy(this.methodMap,{setText:"setTextJessieCode",free:"free",move:"setCoords"}),this},t.Text.prototype=new i,t.extend(t.Text.prototype,{hasPoint:function(t,e){var r,i,s,o,n=this.board.options.precision.hasPoint;return r="right"===this.visProp.anchorx?this.coords.scrCoords[1]-this.size[0]:"middle"===this.visProp.anchorx?this.coords.scrCoords[1]-.5*this.size[0]:this.coords.scrCoords[1],i=r+this.size[0],o="top"===this.visProp.anchory?this.coords.scrCoords[2]+this.size[1]:"middle"===this.visProp.anchorx?this.coords.scrCoords[2]+.5*this.size[1]:this.coords.scrCoords[2],s=o-this.size[1],e>=s-n&&o+n>=e&&(t>=r-n&&r+2*n>=t||t>=i-2*n&&i+n>=t)},_setText:function(t){var e;return this.needsSizeUpdate=!1,"function"==typeof t?(this.updateText=function(){this.plaintext=t()},this.needsSizeUpdate=!0):a.isString(t)&&!this.visProp.parse?(this.updateText=function(){this.plaintext=t},this.needsSizeUpdate=!0):(a.isNumber(t)?this.content=t.toFixed(this.visProp.digits):this.visProp.useasciimathml?(this.content="'`"+t+"`'",this.needsSizeUpdate=!0):this.content=this.generateTerm(t),e=this.board.jc.snippet(this.content,!0,"",!1),this.updateText=function(){this.plaintext=e()}),this.updateText(),this.prepareUpdate().update().updateRenderer(),this},setTextJessieCode:function(t){var e;return this.visProp.castext=t,e="function"==typeof t?function(){return a.sanitizeHTML(t())}:a.isNumber(t)?t:a.sanitizeHTML(t),this._setText(e)},setText:function(t){return this._setText(t)},updateSize:function(){var t;if(!n.isBrowser)return this;if("html"===this.visProp.display&&"vml"!==this.board.renderer.type&&"no"!==this.board.renderer.type)this.size=[this.rendNode.offsetWidth,this.rendNode.offsetHeight];else if("internal"===this.visProp.display&&"svg"===this.board.renderer.type)try{t=this.rendNode.getBBox(),this.size=[t.width,t.height]}catch(e){}else("vml"===this.board.renderer.type||"internal"===this.visProp.display&&"canvas"===this.board.renderer.type)&&(this.size=[.45*parseFloat(this.visProp.fontsize)*this.plaintext.length,.9*parseFloat(this.visProp.fontsize)]);return this},utf8_decode:function(t){return t.replace(/&#x(\w+);/g,function(t,e){return String.fromCharCode(parseInt(e,16))})},replaceSub:function(t){if(!t.indexOf)return t;for(var e,r=t.indexOf("_{");r>=0;)t=t.substr(0,r)+t.substr(r).replace(/_\{/,"<sub>"),e=t.substr(r).indexOf("}"),e>=0&&(t=t.substr(0,e)+t.substr(e).replace(/\}/,"</sub>")),r=t.indexOf("_{");for(r=t.indexOf("_");r>=0;)t=t.substr(0,r)+t.substr(r).replace(/_(.?)/,"<sub>$1</sub>"),r=t.indexOf("_");return t},replaceSup:function(t){if(!t.indexOf)return t;for(var e,r=t.indexOf("^{");r>=0;)t=t.substr(0,r)+t.substr(r).replace(/\^\{/,"<sup>"),e=t.substr(r).indexOf("}"),e>=0&&(t=t.substr(0,e)+t.substr(e).replace(/\}/,"</sup>")),r=t.indexOf("^{");for(r=t.indexOf("^");r>=0;)t=t.substr(0,r)+t.substr(r).replace(/\^(.?)/,"<sup>$1</sup>"),r=t.indexOf("^");return t},getSize:function(){return this.size},setCoords:function(t,r){return a.isArray(t)&&t.length>1&&(r=t[1],t=t[0]),this.X=function(){return t},this.Y=function(){return r},this.coords.setCoordinates(e.COORDS_BY_USER,[t,r]),this.prepareUpdate().update().updateRenderer(),this},free:function(){this.X=a.createFunction(this.X(),this.board,""),this.Y=a.createFunction(this.Y(),this.board,""),this.isDraggable=!0},update:function(){return this.needsUpdate&&(this.visProp.frozen||this.updateCoords(),this.updateText(),"internal"===this.visProp.display&&(this.plaintext=this.utf8_decode(this.plaintext)),this.needsSizeUpdate&&this.updateSize(),this.updateTransform()),this},updateCoords:function(){this.coords.setCoordinates(e.COORDS_BY_USER,[this.X(),this.Y()])},updateRenderer:function(){return this.needsUpdate&&(this.board.renderer.updateText(this),this.needsUpdate=!1),this},updateTransform:function(){var t;if(0===this.transformations.length)return this;for(t=0;this.transformations.length>t;t++)this.transformations[t].update();return this},generateTerm:function(t){var e,r,i,o,n='""';if(t=t||"",t=t.replace(/\r/g,""),t=t.replace(/\n/g,""),t=t.replace(/\"/g,"'"),t=t.replace(/\'/g,"\\'"),t=t.replace(/&amp;arc;/g,"&ang;"),t=t.replace(/<arc\s*\/>/g,"&ang;"),t=t.replace(/&lt;arc\s*\/&gt;/g,"&ang;"),t=t.replace(/&lt;sqrt\s*\/&gt;/g,"&radic;"),t=t.replace(/&lt;value&gt;/g,"<value>"),t=t.replace(/&lt;\/value&gt;/g,"</value>"),i=t.indexOf("<value>"),o=t.indexOf("</value>"),i>=0)for(this.needsSizeUpdate=!0;i>=0;)n+=' + "'+this.replaceSub(this.replaceSup(t.slice(0,i)))+'"',r=t.slice(i+7,o),e=s.geonext2JS(r,this.board),e=e.replace(/\\"/g,"'"),e=e.replace(/\\'/g,"'"),n+=0>e.indexOf("toFixed")?a.isNumber(a.bind(this.board.jc.snippet(e,!0,"",!1),this)())?"+("+e+").toFixed("+this.visProp.digits+")":"+("+e+")":"+("+e+")",t=t.slice(o+8),i=t.indexOf("<value>"),o=t.indexOf("</value>");return n+=' + "'+this.replaceSub(this.replaceSup(t))+'"',n=n.replace(/<overline>/g,"<span style=text-decoration:overline>"),n=n.replace(/&lt;overline&lt;/g,"<span style=text-decoration:overline>"),n=n.replace(/<\/overline>/g,"</span>"),n=n.replace(/&lt;\/overline&gt;/g,"</span>"),n=n.replace(/<arrow>/g,"<span style=text-decoration:overline>"),n=n.replace(/&lt;arrow&gt;/g,"<span style=text-decoration:overline>"),n=n.replace(/<\/arrow>/g,"</span>"),n=n.replace(/&lt;\/arrow&gt;/g,"</span>"),n=n.replace(/&amp;/g,"&"),n=n.replace(/"/g,"'")},notifyParents:function(t){var e,r=null;t=t.replace(/&lt;value&gt;/g,"<value>"),t=t.replace(/&lt;\/value&gt;/g,"</value>");do e=/<value>([\w\s\*\/\^\-\+\(\)\[\],<>=!]+)<\/value>/,r=e.exec(t),null!==r&&(s.findDependencies(this,r[1],this.board),t=t.substr(r.index),t=t.replace(e,""));while(null!==r);return this},bounds:function(){var t=this.coords.usrCoords;return this.visProp.islabel?[0,0,0,0]:[t[1],t[2]+this.size[1],t[1]+this.size[0],t[2]]},setPositionDirectly:function(t,e,i){var s,n,h=new r(t,e,this.board),c=new r(t,i,this.board);return this.relativeCoords?this.visProp.islabel?(s=o.subtract(h.scrCoords,c.scrCoords),this.relativeCoords.scrCoords[1]+=s[1],this.relativeCoords.scrCoords[2]+=s[2]):(s=o.subtract(h.usrCoords,c.usrCoords),this.relativeCoords.usrCoords[1]+=s[1],this.relativeCoords.usrCoords[2]+=s[2]):(s=o.subtract(h.usrCoords,c.usrCoords),n=[this.Z(),this.X(),this.Y()],this.X=a.createFunction(n[1]+s[1],this.board,""),this.Y=a.createFunction(n[2]+s[2],this.board,"")),this}}),t.createText=function(e,r,i){var s,o=a.copyAttributes(i,e.options,"text");return o.anchor=o.parent||o.anchor,s=new t.Text(e,r[r.length-1],r,o),"function"!=typeof r[r.length-1]&&(s.parents=r),0!==a.evaluate(o.rotate)&&"internal"===o.display&&s.addRotation(a.evaluate(o.rotate)),s},t.registerElement("text",t.createText),{Text:t.Text,createText:t.createText}}),define("utils/uuid",["jxg"],function(t){var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",r=e.split("");return t.Util=t.Util||{},t.Util.genUUID=function(){var t,e,i=[],s=0;for(e=0;36>e;e++)8===e||13===e||18===e||23===e?i[e]="-":14===e?i[e]="4":(2>=s&&(s=0|33554432+16777216*Math.random()),t=15&s,s>>=4,i[e]=r[19===e?8|3&t:t]);return i.join("")},t.Util}),define("parser/jessiecode",["jxg","base/constants","base/text","math/math","math/geometry","math/statistics","utils/type","utils/uuid","utils/env"],function(JXG,Const,Text,Mat,Geometry,Statistics,Type,UUID,Env){return JXG.JessieCode=function(t,e){this.sstack=[{}],this.scope=0,this.pstack=[[]],this.dpstack=[[]],this.pscope=0,this.propstack=[{}],this.propscope=0,this.propobj=0,this.lhs=[],this.isLHS=!1,this.warnLog="jcwarn",this.$log=[],this.builtIn=this.defineBuiltIn(),this.board=null,this.lineToElement={},this.countLines=!0,this.parCurLine=1,this.parCurColumn=0,this.line=1,this.col=1,this.code="","string"==typeof t&&this.parse(t,e)},JXG.extend(JXG.JessieCode.prototype,{node:function(t,e,r){return{type:t,value:e,children:r}},createNode:function(t,e){var r,i=this.node(t,e,[]);for(r=2;arguments.length>r;r++)i.children.push(arguments[r]);return i.line=this.parCurLine,i.col=this.parCurColumn,i},getElementById:function(t){return this.board.objects[t]},log:function(){this.$log.push(arguments),"object"==typeof console&&console.log&&console.log.apply(console,arguments)},creator:function(){var t,e={};return t=function(t){var r;return"function"==typeof e[this.board.id+t]?r=e[this.board.id+t]:(r=function(e){return function(r,i){var s;return s=Type.exists(i)?i:{name:0!==e.lhs[e.scope]?e.lhs[e.scope]:""},e.board.create(t,r,s)}}(this),r.creator=!0,e[this.board.id+t]=r),r},t.clearCache=function(){e={}},t}(),letvar:function(t,e){this.builtIn[t]&&this._warn('"'+t+'" is a predefined value.'),this.sstack[this.scope][t]=e},isLocalVariable:function(t){var e;for(e=this.scope;e>-1;e--)if(Type.exists(this.sstack[e][t]))return e;return-1},isCreator:function(t){return!!JXG.elements[t]},isMathMethod:function(t){return"E"!==t&&!!Math[t]},isBuiltIn:function(t){return!!this.builtIn[t]},getvar:function(t,e){var r,i;return e=Type.def(e,!1),r=this.isLocalVariable(t),r>-1?this.sstack[r][t]:this.isCreator(t)?this.creator(t):this.isMathMethod(t)?Math[t]:this.isBuiltIn(t)?this.builtIn[t]:e||(r=this.board.select(t),r===t)?i:r},getvarJS:function(t,e,r){var i,s="";return e=Type.def(e,!1),r=Type.def(r,!1),Type.indexOf(this.pstack[this.pscope],t)>-1?t:(i=this.isLocalVariable(t),i>-1&&!r?"$jc$.sstack["+i+"]['"+t+"']":this.isCreator(t)?"(function () { var a = Array.prototype.slice.call(arguments, 0), props = "+(r?"a.pop()":"{}")+"; return $jc$.board.create.apply($jc$.board, ['"+t+"'].concat([a, props])); })":(r&&this._error("Syntax error (attribute values are allowed with element creators only)"),this.isMathMethod(t)?"Math."+t:this.isBuiltIn(t)?this.builtIn[t].src||this.builtIn[t]:e?"":(Type.isId(this.board,t)?s="$jc$.board.objects['"+t+"']":Type.isName(this.board,t)?s="$jc$.board.elementsByName['"+t+"']":Type.isGroup(this.board,t)&&(s="$jc$.board.groups['"+t+"']"),s)))},mergeAttributes:function(){var t,e={};for(t=0;arguments.length>t;t++)e=Type.deepCopy(e,arguments[t],!0);return e},setProp:function(t,e,r){var i,s,o={};t.elementClass!==Const.OBJECT_CLASS_POINT||"X"!==e&&"Y"!==e?t.type!==Const.OBJECT_TYPE_TEXT||"X"!==e&&"Y"!==e?t.type&&t.elementClass&&t.visProp?(o[e]=r,t.setProperty(o)):t[e]=r:("number"==typeof r?t[e]=function(){return r}:"function"==typeof r?(t.isDraggable=!1,t[e]=r):"string"==typeof r&&(t.isDraggable=!1,t[e]=Type.createFunction(r,this.board,null,!0),t[e+"jc"]=r),t[e].origin=r,this.board.update()):(e=e.toLowerCase(),t.isDraggable&&"number"==typeof r?(i="x"===e?r:t.X(),s="y"===e?r:t.Y(),t.setPosition(Const.COORDS_BY_USER,[i,s])):!t.isDraggable||"function"!=typeof r&&"string"!=typeof r?t.isDraggable||(i="x"===e?r:t.XEval.origin,s="y"===e?r:t.YEval.origin,t.addConstraint([i,s])):(i="x"===e?r:t.coords.usrCoords[1],s="y"===e?r:t.coords.usrCoords[2],t.addConstraint([i,s])),this.board.update())},utf8_encode:function(t){var e,r,i=[];for(e=0;t.length>e;e++)r=t.charCodeAt(e),128>r?i.push(String.fromCharCode(r)):i.push("&#x"+r.toString(16)+";");return i.join("")},parse:function(t,e,r){var i,s,o=0,n=[],a=[],h=t.replace(/\r\n/g,"\n").split("\n"),c=[];r||(this.code+=t+"\n"),Text&&(s=Text.Text.prototype.setText,Text.Text.prototype.setText=Text.Text.prototype.setTextJessieCode);try{for(Type.exists(e)||(e=!1),i=0;h.length>i;i++)"/"!==Type.trim(h[i])[0]||"/"!==Type.trim(h[i])[1]?(e&&(h[i]=JXG.GeonextParser.geonext2JS(h[i],this.board)),c.push(h[i])):c.push("");if(t=c.join("\n"),t=this.utf8_encode(t),(o=this.genTree(t,n,a))>0)for(i=0;o>i;i++)this.line=n[i].line,this._error("Parse error in line "+n[i].line+" near >"+t.substr(n[i].offset,30)+'<, expecting "'+a[i].join()+'"')}finally{Text&&(Text.Text.prototype.setText=s)}},snippet:function(t,e,r,i){var s,o,n,a;return s="jxg__tmp__intern_"+UUID.genUUID().replace(/\-/g,""),Type.exists(e)||(e=!0),Type.exists(r)||(r=""),Type.exists(i)||(i=!1),n=this.sstack[0][s],this.countLines=!1,o=s+" = "+(e?" function ("+r+") { return ":"")+t+(e?"; }":"")+";",this.parse(o,i,!0),a=this.sstack[0][s],Type.exists(n)?this.sstack[0][s]=n:delete this.sstack[0][s],this.countLines=!0,a},replaceIDs:function(t){var e,r;if(t.replaced&&(r=this.board.objects[t.children[1].children[0].value],Type.exists(r)&&""!==r.name&&(t.type="node_var",t.value=r.name,t.children.length=0,delete t.replaced)),t.children)for(e=t.children.length;e>0;e--)Type.exists(t.children[e-1])&&(t.children[e-1]=this.replaceIDs(t.children[e-1]));return t},replaceNames:function(t){var e,r;if(r=t.value,"node_op"===t.type&&"op_lhs"===r&&1===t.children.length?this.isLHS=!0:"node_var"===t.type&&(this.isLHS?this.letvar(r,!0):!Type.exists(this.getvar(r,!0))&&Type.exists(this.board.elementsByName[r])&&(t=this.createReplacementNode(t))),t.children)for(e=t.children.length;e>0;e--)Type.exists(t.children[e-1])&&(t.children[e-1]=this.replaceNames(t.children[e-1]));return"node_op"===t.type&&"op_lhs"===t.value&&1===t.children.length&&(this.isLHS=!1),t},createReplacementNode:function(t){var e=t.value,r=this.board.elementsByName[e];return t=this.createNode("node_op","op_execfun",this.createNode("node_var","$"),this.createNode("node_op","op_param",this.createNode("node_str",r.id))),t.replaced=!0,t},collectDependencies:function(t,e){var r,i,s;if(i=t.value,"node_var"===t.type&&(s=this.getvar(i),s&&s.visProp&&s.type&&s.elementClass&&s.id&&(e[s.id]=s)),"node_op"===t.type&&"op_execfun"===t.value&&t.children.length>1&&"$"===t.children[0].value&&t.children[1].children.length>0&&(s=t.children[1].children[0].value,e[s]=this.board.objects[s]),t.children)for(r=t.children.length;r>0;r--)Type.exists(t.children[r-1])&&this.collectDependencies(t.children[r-1],e)},resolveProperty:function(t,e,r){return r=Type.def(r,!1),t&&t.methodMap&&("label"===e?(t=t.label,e="content"):Type.exists(t.subs)&&Type.exists(t.subs[e])?t=t.subs:Type.exists(t.methodMap[e])?e=t.methodMap[e]:(t=t.visProp,e=e.toLowerCase())),Type.exists(t)||this._error(t+" is not an object"),Type.exists(t[e])||this._error("unknown property "+e),r&&"function"==typeof t[e]?function(){return t[e].apply(t,arguments)}:t[e]},execute:function(node){var ret,v,i,e,l,undef,parents=[],fun,attr,sc,b,found=!1;if(ret=0,!node)return ret;switch(this.line=node.line,this.col=node.col,node.type){case"node_op":switch(node.value){case"op_none":node.children[0]&&this.execute(node.children[0]),node.children[1]&&(ret=this.execute(node.children[1]));break;case"op_assign":v=this.execute(node.children[0]),this.lhs[this.scope]=v[1],v[0].type&&v[0].elementClass&&v[0].methodMap&&"label"===v[1]&&this._error("Left-hand side of assignment is read-only."),v[0]!==this.sstack[this.scope]||Type.isArray(v[0])&&"number"==typeof v[1]?this.setProp(v[0],v[1],this.execute(node.children[1])):this.letvar(v[1],this.execute(node.children[1])),this.lhs[this.scope]=0;break;case"op_noassign":ret=this.execute(node.children[0]);break;case"op_if":this.execute(node.children[0])&&(ret=this.execute(node.children[1]));break;case"op_conditional":case"op_if_else":ret=this.execute(node.children[0])?this.execute(node.children[1]):this.execute(node.children[2]);break;case"op_while":for(;this.execute(node.children[0]);)this.execute(node.children[1]);break;case"op_do":do this.execute(node.children[0]);while(this.execute(node.children[1]));break;case"op_for":for(this.execute(node.children[0]);this.execute(node.children[1]);this.execute(node.children[2]))this.execute(node.children[3]);break;case"op_param":node.children[1]&&this.execute(node.children[1]),ret=node.children[0],this.pstack[this.pscope].push(ret),this.dpstack[this.pscope]&&this.dpstack[this.pscope].push({line:node.children[0].line,col:node.children[0].col});break;case"op_paramdef":node.children[1]&&this.execute(node.children[1]),ret=node.children[0],this.pstack[this.pscope].push(ret);break;case"op_proplst":node.children[0]&&this.execute(node.children[0]),node.children[1]&&this.execute(node.children[1]);break;case"op_proplst_val":this.propstack.push({}),this.propscope++,this.execute(node.children[0]),ret=this.propstack[this.propscope],this.propstack.pop(),this.propscope--;break;case"op_prop":this.propstack[this.propscope][node.children[0]]=this.execute(node.children[1]);break;case"op_array":for(this.pstack.push([]),this.pscope++,this.execute(node.children[0]),ret=[],l=this.pstack[this.pscope].length,i=0;l>i;i++)ret.push(this.execute(this.pstack[this.pscope][i]));this.pstack.pop(),this.pscope--;break;case"op_extvalue":ret=this.execute(node.children[0]),i=this.execute(node.children[1]),ret="number"==typeof i&&Math.abs(Math.round(i)-i)<Mat.eps?ret[i]:undef;break;case"op_return":if(0!==this.scope)return this.execute(node.children[0]);this._error("Unexpected return.");break;case"op_function":if(this.pstack.push([]),this.pscope++,this.execute(node.children[0]),this.board.options.jc.compile){for(this.sstack.push({}),this.scope++,this.isLHS=!1,i=0;this.pstack[this.pscope].length>i;i++)this.sstack[this.scope][this.pstack[this.pscope][i]]=this.pstack[this.pscope][i];this.replaceNames(node.children[1]),fun=function($jc$){var fun,p=$jc$.pstack[$jc$.pscope].join(", "),str="var f = function ("+p+") {\n$jc$.sstack.push([]);\n$jc$.scope++;\nvar r = (function () {\n"+$jc$.compile(node.children[1],!0)+"})();\n$jc$.sstack.pop();\n$jc$.scope--;\nreturn r;\n}; f;";try{return fun=eval(str)}catch(e){return function(){}}}(this),this.sstack.pop(),this.scope--}else fun=function(t,e){return function(){var r;for(e.sstack.push({}),e.scope++,r=0;t.length>r;r++)e.sstack[e.scope][t[r]]=arguments[r];return r=e.execute(node.children[1]),e.sstack.pop(),e.scope--,r}}(this.pstack[this.pscope],this);fun.node=node,fun.toJS=fun.toString,fun.toString=function(t){return function(){return t.compile(t.replaceIDs(Type.deepCopy(node)))}}(this),fun.deps={},this.collectDependencies(node.children[1],fun.deps),this.pstack.pop(),this.pscope--,ret=fun;break;case"op_execfun":if(this.pstack.push([]),this.dpstack.push([]),this.pscope++,this.execute(node.children[1]),Type.exists(node.children[2]))if(node.children[3]){for(this.pstack.push([]),this.dpstack.push([]),this.pscope++,this.execute(node.children[2]),attr={},i=0;this.pstack[this.pscope].length>i;i++)attr=Type.deepCopy(attr,this.execute(this.pstack[this.pscope][i]),!0);this.pscope--,this.pstack.pop(),this.dpstack.pop()}else attr=this.execute(node.children[2]);for(fun=this.execute(node.children[0]),sc=fun&&fun.sc?fun.sc:this,!fun.creator&&Type.exists(node.children[2])&&this._error("Unexpected value. Only element creators are allowed to have a value after the function call."),i=0;this.pstack[this.pscope].length>i;i++)parents[i]=this.execute(this.pstack[this.pscope][i]);if("function"!=typeof fun||fun.creator)if("function"==typeof fun&&fun.creator){e=this.line;try{for(ret=fun(parents,attr),ret.jcLineStart=e,ret.jcLineEnd=node.line,i=e;node.line>=i;i++)this.lineToElement[i]=ret;ret.debugParents=this.dpstack[this.pscope]}catch(ex){this._error(""+ex)}}else this._error("Function '"+fun+"' is undefined.");else ret=fun.apply(sc,parents);this.pstack.pop(),this.dpstack.pop(),this.pscope--;break;case"op_property":e=this.execute(node.children[0]),v=node.children[1],ret=this.resolveProperty(e,v,!1),Type.exists(ret)&&(ret.sc=e);break;case"op_lhs":v=node.children[0],v.children&&v.type&&v.value&&(v=this.execute(v)),1===node.children.length?e=this.sstack[this.scope]:(e=this.execute(node.children[1]),e.type&&e.elementClass&&v.toLowerCase&&"x"!==v.toLowerCase()&&"y"!==v.toLowerCase()&&(v=v.toLowerCase())),ret=[e,v];break;case"op_use":found=!1;for(b in JXG.boards)JXG.boards.hasOwnProperty(b)&&JXG.boards[b].container===""+node.children[0]&&(this.use(JXG.boards[b]),found=!0);found||this._error("Board '"+(""+node.children[0])+"' not found!");break;case"op_delete":v=this.getvar(node.children[0]),"object"==typeof v&&JXG.exists(v.type)&&JXG.exists(v.elementClass)&&this.board.removeObject(v);break;case"op_equ":ret=this.execute(node.children[0])==this.execute(node.children[1]);break;case"op_neq":ret=this.execute(node.children[0])!=this.execute(node.children[1]);break;case"op_approx":ret=Math.abs(this.execute(node.children[0])-this.execute(node.children[1]))<Mat.eps;break;case"op_grt":ret=this.execute(node.children[0])>this.execute(node.children[1]);break;case"op_lot":ret=this.execute(node.children[0])<this.execute(node.children[1]);break;case"op_gre":ret=this.execute(node.children[0])>=this.execute(node.children[1]);break;case"op_loe":ret=this.execute(node.children[0])<=this.execute(node.children[1]);break;case"op_or":ret=this.execute(node.children[0])||this.execute(node.children[1]);break;case"op_and":ret=this.execute(node.children[0])&&this.execute(node.children[1]);break;case"op_not":ret=!this.execute(node.children[0]);break;case"op_add":ret=Statistics.add(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_sub":ret=Statistics.subtract(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_div":ret=Statistics.div(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_mod":ret=Statistics.mod(this.execute(node.children[0]),this.execute(node.children[1]),!0);break;case"op_mul":ret=this.mul(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_exp":ret=this.pow(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_neg":ret=-1*this.execute(node.children[0])}break;case"node_var":ret=this.getvar(node.value);break;case"node_const":ret=Number(node.value);break;case"node_const_bool":ret="false"!==node.value.toLowerCase();break;case"node_str":ret=node.value}return ret},compile:function(t,e){var r,i="";if(Type.exists(e)||(e=!1),!t)return i;switch(t.type){case"node_op":switch(t.value){case"op_none":t.children[0]&&(i=this.compile(t.children[0],e)),t.children[1]&&(i+=this.compile(t.children[1],e));break;case"op_assign":r=this.compile(t.children[0],e),e?Type.isArray(r)?i="$jc$.setProp("+r[0]+", '"+r[1]+"', "+this.compile(t.children[1],e)+");\n":(this.isLocalVariable(r)!==this.scope&&(this.sstack[this.scope][r]=!0),i="$jc$.sstack["+this.scope+"]['"+r+"'] = "+this.compile(t.children[1],e)+";\n"):i=r+" = "+this.compile(t.children[1],e)+";\n";break;case"op_noassign":i=this.compile(t.children[0],e)+";\n";break;case"op_if":i=" if ("+this.compile(t.children[0],e)+") "+this.compile(t.children[1],e);break;case"op_if_else":i=" if ("+this.compile(t.children[0],e)+")"+this.compile(t.children[1],e),i+=" else "+this.compile(t.children[2],e);break;case"op_conditional":i="(("+this.compile(t.children[0],e)+")?("+this.compile(t.children[1],e),i+="):("+this.compile(t.children[2],e)+"))";break;case"op_while":i=" while ("+this.compile(t.children[0],e)+") {\n"+this.compile(t.children[1],e)+"}\n";break;case"op_do":i=" do {\n"+this.compile(t.children[0],e)+"} while ("+this.compile(t.children[1],e)+");\n";break;case"op_for":i=" for ("+this.compile(t.children[0],e)+"; "+this.compile(t.children[1],e)+"; "+this.compile(t.children[2],e)+") {\n"+this.compile(t.children[3],e)+"\n}\n";break;case"op_param":t.children[1]&&(i=this.compile(t.children[1],e)+", "),i+=this.compile(t.children[0],e);break;case"op_paramdef":t.children[1]&&(i=this.compile(t.children[1],e)+", "),i+=t.children[0];break;case"op_proplst":t.children[0]&&(i=this.compile(t.children[0],e)+", "),i+=this.compile(t.children[1],e);break;case"op_prop":i=t.children[0]+": "+this.compile(t.children[1],e);break;case"op_proplst_val":i=this.compile(t.children[0],e);break;case"op_array":i="["+this.compile(t.children[0],e)+"]";break;case"op_extvalue":i=this.compile(t.children[0],e)+"["+this.compile(t.children[1],e)+"]";break;case"op_return":i=" return "+this.compile(t.children[0],e)+";\n";break;case"op_function":i=" function ("+this.compile(t.children[0],e)+") {\n"+this.compile(t.children[1],e)+"}";break;case"op_execfun":t.children[2]&&(r=this.compile(t.children[2],e),e&&(r="$jc$.mergeAttributes("+r+")")),t.children[0].withProps=!!t.children[2],i=this.compile(t.children[0],e)+"("+this.compile(t.children[1],e)+(t.children[2]&&e?", "+r:"")+")"+(t.children[2]&&!e?r:""),e&&"$"===t.children[0].value&&(i="$jc$.board.objects["+this.compile(t.children[1],e)+"]");break;case"op_property":i=e&&"X"!==t.children[1]&&"Y"!==t.children[1]?"$jc$.resolveProperty("+this.compile(t.children[0],e)+", '"+t.children[1]+"', true)":this.compile(t.children[0],e)+"."+t.children[1];break;case"op_lhs":1===t.children.length?i=t.children[0]:"dot"===t.children[2]?i=e?[this.compile(t.children[1],e),t.children[0]]:this.compile(t.children[1],e)+"."+t.children[0]:"bracket"===t.children[2]&&(i=e?[this.compile(t.children[1],e),this.compile(t.children[0],e)]:this.compile(t.children[1],e)+"["+this.compile(t.children[0],e)+"]");break;case"op_use":i=e?"$jc$.use(JXG.boards['"+t.children[0]+"'])":"use "+t.children[0]+";";break;case"op_delete":i="delete "+t.children[0];break;case"op_equ":i="("+this.compile(t.children[0],e)+" == "+this.compile(t.children[1],e)+")";break;case"op_neq":i="("+this.compile(t.children[0],e)+" != "+this.compile(t.children[1],e)+")";break;case"op_approx":i="("+this.compile(t.children[0],e)+" ~= "+this.compile(t.children[1],e)+")";break;case"op_grt":i="("+this.compile(t.children[0],e)+" > "+this.compile(t.children[1],e)+")";break;case"op_lot":i="("+this.compile(t.children[0],e)+" < "+this.compile(t.children[1],e)+")";break;case"op_gre":i="("+this.compile(t.children[0],e)+" >= "+this.compile(t.children[1],e)+")";break;case"op_loe":i="("+this.compile(t.children[0],e)+" <= "+this.compile(t.children[1],e)+")";break;case"op_or":i="("+this.compile(t.children[0],e)+" || "+this.compile(t.children[1],e)+")";break;case"op_and":i="("+this.compile(t.children[0],e)+" && "+this.compile(t.children[1],e)+")";break;case"op_not":i="!("+this.compile(t.children[0],e)+")";break;case"op_add":i=e?"JXG.Math.Statistics.add("+this.compile(t.children[0],e)+", "+this.compile(t.children[1],e)+")":"("+this.compile(t.children[0],e)+" + "+this.compile(t.children[1],e)+")";break;case"op_sub":i=e?"JXG.Math.Statistics.subtract("+this.compile(t.children[0],e)+", "+this.compile(t.children[1],e)+")":"("+this.compile(t.children[0],e)+" - "+this.compile(t.children[1],e)+")";break;case"op_div":i=e?"JXG.Math.Statistics.div("+this.compile(t.children[0],e)+", "+this.compile(t.children[1],e)+")":"("+this.compile(t.children[0],e)+" / "+this.compile(t.children[1],e)+")";break;case"op_mod":i=e?"JXG.Math.mod("+this.compile(t.children[0],e)+", "+this.compile(t.children[1],e)+", true)":"("+this.compile(t.children[0],e)+" % "+this.compile(t.children[1],e)+")";break;case"op_mul":i=e?"$jc$.mul("+this.compile(t.children[0],e)+", "+this.compile(t.children[1],e)+")":"("+this.compile(t.children[0],e)+" * "+this.compile(t.children[1],e)+")";break;case"op_exp":i=e?"$jc$.pow("+this.compile(t.children[0],e)+", "+this.compile(t.children[1],e)+")":"("+this.compile(t.children[0],e)+"^"+this.compile(t.children[1],e)+")";break;case"op_neg":i="(-"+this.compile(t.children[0],e)+")"}break;case"node_var":i=e?this.getvarJS(t.value,!1,t.withProps):t.value;break;case"node_const":i=t.value;break;case"node_const_bool":i=t.value;break;case"node_str":i="'"+t.value.replace(/'/g,"\\'")+"'"}return t.needsBrackets&&(i="{\n"+i+"}\n"),i},X:function(t){return t.X()},Y:function(t){return t.Y()},V:function(t){return t.Value()},L:function(t){return t.L()},dist:function(t,e){return Type.exists(t)&&Type.exists(t.Dist)||this._error("Error: Can't calculate distance."),t.Dist(e)},mul:function(t,e){return Type.isArray(t)*Type.isArray(e)?Mat.innerProduct(t,e,Math.min(t.length,e.length)):Statistics.multiply(t,e)},pow:function(t,e){return t=Type.evalSlider(t),e=Type.evalSlider(e),Math.pow(t,e)},ifthen:function(t,e,r){return t?e:r},use:function(t){this.board=t,this.builtIn.$board=t,this.builtIn.$board.src="$jc$.board"},findSymbol:function(t,e){var r,i;for(e=Type.def(e,-1),-1===e&&(e=this.scope),r=e;r>=0;r--)for(i in this.sstack[r])if(this.sstack[r].hasOwnProperty(i)&&this.sstack[r][i]===t)return[i,r];return[]},defineBuiltIn:function(){var t=this,e={PI:Math.PI,EULER:Math.E,X:t.X,Y:t.Y,V:t.V,L:t.L,dist:t.dist,rad:Geometry.rad,deg:Geometry.trueAngle,factorial:Mat.factorial,trunc:Type.trunc,IfThen:t.ifthen,$:t.getElementById,$board:t.board,$log:t.log};return e.rad.sc=Geometry,e.deg.sc=Geometry,e.factorial.sc=Mat,e.X.src="$jc$.X",e.Y.src="$jc$.Y",e.V.src="$jc$.V",e.L.src="$jc$.L",e.dist.src="$jc$.dist",e.rad.src="JXG.Math.Geometry.rad",e.deg.src="JXG.Math.Geometry.trueAngle",e.factorial.src="JXG.Math.factorial",e.trunc.src="JXG.trunc",e.IfThen.src="$jc$.ifthen",e.$.src="(function (n) { return $jc$.board.select(n); })",e.$board&&(e.$board.src="$jc$.board"),e.$log.src="$jc$.log",e},_debug:function(t){"object"==typeof console?console.log(t):Env.isBrowser&&document&&null!==document.getElementById("debug")&&(document.getElementById("debug").innerHTML+=t+"<br />")},_error:function(t){var e=Error("Error("+this.line+"): "+t);throw e.line=this.line,e},_warn:function(t){"object"==typeof console?console.log("Warning("+this.line+"): "+t):Env.isBrowser&&document&&null!==document.getElementById(this.warnLog)&&(document.getElementById(this.warnLog).innerHTML+="Warning("+this.line+"): "+t+"<br />")},_log:function(t){"object"!=typeof window&&"object"==typeof self&&self.postMessage?self.postMessage({type:"log",msg:"Log: "+(""+t)}):console.log("Log: ",arguments)}}),JXG.extend(JXG.JessieCode.prototype,{lex:function(t){var e,r,i,s,o,n;e=0,r=-1,i=0,s=0,o=t.offset+1+(i-s);do{if(o-=1,e=0,r=-2,s=o,s>=t.src.length)return 69;do{switch(n=t.src.charCodeAt(o),e){case 0:e=n>=9&&10>=n||13===n||32===n?1:33===n?2:35===n?3:36===n||n>=65&&67>=n||n>=71&&72>=n||n>=74&&77>=n||n>=79&&81>=n||83===n||86===n||n>=88&&90>=n||95===n||n>=97&&99>=n||n>=103&&104>=n||n>=106&&113>=n||115===n||118===n||n>=120&&122>=n?4:37===n?5:40===n?6:41===n?7:42===n?8:43===n?9:44===n?10:45===n?11:46===n?12:47===n?13:n>=48&&57>=n?14:58===n?15:59===n?16:60===n?17:61===n?18:62===n?19:63===n?20:91===n?21:93===n?22:94===n?23:123===n?24:124===n?25:125===n?26:38===n?50:68===n||100===n?51:39===n?53:73===n||105===n?54:126===n?55:70===n||102===n?67:78===n?68:85===n||117===n?69:69===n||101===n?77:84===n||116===n?78:87===n||119===n?84:82===n||114===n?88:-1;break;case 1:e=-1,r=2,i=o;break;case 2:e=61===n?27:-1,r=31,i=o;break;case 3:e=-1,r=41,i=o;break;case 4:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=47,i=o;break;case 5:e=-1,r=35,i=o;break;case 6:e=-1,r=38,i=o;break;case 7:e=-1,r=39,i=o;break;case 8:e=-1,r=36,i=o;break;case 9:e=-1,r=32,i=o;break;case 10:e=-1,r=40,i=o;break;case 11:e=-1,r=33,i=o;break;case 12:e=n>=48&&57>=n?30:-1,r=45,i=o;break;case 13:e=-1,r=34,i=o;break;case 14:e=n>=48&&57>=n?14:46===n?30:-1,r=49,i=o;break;case 15:e=-1,r=43,i=o;break;case 16:e=-1,r=20,i=o;break;case 17:e=60===n?31:61===n?32:-1,r=28,i=o;break;case 18:e=61===n?33:-1,r=21,i=o;break;case 19:e=61===n?34:62===n?35:-1,r=27,i=o;break;case 20:e=-1,r=42,i=o;break;case 21:e=-1,r=16,i=o;break;case 22:e=-1,r=17,i=o;break;case 23:e=-1,r=37,i=o;break;case 24:e=-1,r=18,i=o;break;case 25:e=124===n?38:-1,r=44,i=o;break;case 26:e=-1,r=19,i=o;break;case 27:e=-1,r=23,i=o;break;case 28:e=-1,r=30,i=o;break;case 29:e=-1,r=48,i=o;break;case 30:e=n>=48&&57>=n?30:-1,r=50,i=o;break;case 31:e=-1,r=14,i=o;break;case 32:e=-1,r=25,i=o;break;case 33:e=-1,r=22,i=o;
break;case 34:e=-1,r=26,i=o;break;case 35:e=-1,r=15,i=o;break;case 36:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=6,i=o;break;case 37:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=3,i=o;break;case 38:e=-1,r=29,i=o;break;case 39:e=-1,r=24,i=o;break;case 40:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=7,i=o;break;case 41:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=46,i=o;break;case 42:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=9,i=o;break;case 43:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=4,i=o;break;case 44:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=12,i=o;break;case 45:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=13,i=o;break;case 46:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=5,i=o;break;case 47:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=11,i=o;break;case 48:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=10,i=o;break;case 49:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=97&&122>=n?4:-1,r=8,i=o;break;case 50:e=38===n?28:-1;break;case 51:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&78>=n||n>=80&&90>=n||95===n||n>=97&&100>=n||n>=102&&110>=n||n>=112&&122>=n?4:79===n||111===n?36:69===n||101===n?85:-1,r=47,i=o;break;case 52:e=39===n?29:n>=0&&38>=n||n>=40&&91>=n||n>=93&&254>=n?53:92===n?57:-1,r=48,i=o;break;case 53:e=39===n?29:n>=0&&38>=n||n>=40&&91>=n||n>=93&&254>=n?53:92===n?57:-1;break;case 54:e=n>=48&&57>=n||n>=65&&69>=n||n>=71&&90>=n||95===n||n>=97&&101>=n||n>=103&&122>=n?4:70===n||102===n?37:-1,r=47,i=o;break;case 55:e=61===n?39:-1;break;case 56:e=n>=48&&57>=n||n>=65&&81>=n||n>=83&&90>=n||95===n||n>=97&&113>=n||n>=115&&122>=n?4:82===n||114===n?40:-1,r=47,i=o;break;case 57:e=39===n?52:n>=0&&38>=n||n>=40&&91>=n||n>=93&&254>=n?53:92===n?57:-1;break;case 58:e=n>=48&&57>=n||n>=65&&77>=n||n>=79&&90>=n||95===n||n>=97&&122>=n?4:78===n?41:-1,r=47,i=o;break;case 59:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?42:-1,r=47,i=o;break;case 60:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?43:-1,r=47,i=o;break;case 61:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?44:-1,r=47,i=o;break;case 62:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?45:-1,r=47,i=o;break;case 63:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?46:-1,r=47,i=o;break;case 64:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?47:-1,r=47,i=o;break;case 65:e=n>=48&&57>=n||n>=65&&77>=n||n>=79&&90>=n||95===n||n>=97&&109>=n||n>=111&&122>=n?4:78===n||110===n?48:-1,r=47,i=o;break;case 66:e=n>=48&&57>=n||n>=65&&77>=n||n>=79&&90>=n||95===n||n>=97&&109>=n||n>=111&&122>=n?4:78===n||110===n?49:-1,r=47,i=o;break;case 67:e=n>=48&&57>=n||n>=66&&78>=n||n>=80&&84>=n||n>=86&&90>=n||95===n||n>=98&&110>=n||n>=112&&116>=n||n>=118&&122>=n?4:79===n||111===n?56:65===n||97===n?79:85===n||117===n?90:-1,r=47,i=o;break;case 68:e=n>=48&&57>=n||n>=65&&90>=n||95===n||n>=98&&122>=n?4:97===n?58:-1,r=47,i=o;break;case 69:e=n>=48&&57>=n||n>=65&&82>=n||n>=84&&90>=n||95===n||n>=97&&114>=n||n>=116&&122>=n?4:83===n||115===n?59:-1,r=47,i=o;break;case 70:e=n>=48&&57>=n||n>=65&&82>=n||n>=84&&90>=n||95===n||n>=97&&114>=n||n>=116&&122>=n?4:83===n||115===n?60:-1,r=47,i=o;break;case 71:e=n>=48&&57>=n||n>=65&&84>=n||n>=86&&90>=n||95===n||n>=97&&116>=n||n>=118&&122>=n?4:85===n||117===n?61:-1,r=47,i=o;break;case 72:e=n>=48&&57>=n||n>=65&&82>=n||n>=84&&90>=n||95===n||n>=97&&114>=n||n>=116&&122>=n?4:83===n||115===n?62:-1,r=47,i=o;break;case 73:e=n>=48&&57>=n||n>=65&&75>=n||n>=77&&90>=n||95===n||n>=97&&107>=n||n>=109&&122>=n?4:76===n||108===n?63:-1,r=47,i=o;break;case 74:e=n>=48&&57>=n||n>=65&&83>=n||n>=85&&90>=n||95===n||n>=97&&115>=n||n>=117&&122>=n?4:84===n||116===n?64:-1,r=47,i=o;break;case 75:e=n>=48&&57>=n||n>=65&&81>=n||n>=83&&90>=n||95===n||n>=97&&113>=n||n>=115&&122>=n?4:82===n||114===n?65:-1,r=47,i=o;break;case 76:e=n>=48&&57>=n||n>=65&&78>=n||n>=80&&90>=n||95===n||n>=97&&110>=n||n>=112&&122>=n?4:79===n||111===n?66:-1,r=47,i=o;break;case 77:e=n>=48&&57>=n||n>=65&&75>=n||n>=77&&90>=n||95===n||n>=97&&107>=n||n>=109&&122>=n?4:76===n||108===n?70:-1,r=47,i=o;break;case 78:e=n>=48&&57>=n||n>=65&&81>=n||n>=83&&90>=n||95===n||n>=97&&113>=n||n>=115&&122>=n?4:82===n||114===n?71:-1,r=47,i=o;break;case 79:e=n>=48&&57>=n||n>=65&&75>=n||n>=77&&90>=n||95===n||n>=97&&107>=n||n>=109&&122>=n?4:76===n||108===n?72:-1,r=47,i=o;break;case 80:e=n>=48&&57>=n||n>=65&&72>=n||n>=74&&90>=n||95===n||n>=97&&104>=n||n>=106&&122>=n?4:73===n||105===n?73:-1,r=47,i=o;break;case 81:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?74:-1,r=47,i=o;break;case 82:e=n>=48&&57>=n||n>=65&&84>=n||n>=86&&90>=n||95===n||n>=97&&116>=n||n>=118&&122>=n?4:85===n||117===n?75:-1,r=47,i=o;break;case 83:e=n>=48&&57>=n||n>=65&&72>=n||n>=74&&90>=n||95===n||n>=97&&104>=n||n>=106&&122>=n?4:73===n||105===n?76:-1,r=47,i=o;break;case 84:e=n>=48&&57>=n||n>=65&&71>=n||n>=73&&90>=n||95===n||n>=97&&103>=n||n>=105&&122>=n?4:72===n||104===n?80:-1,r=47,i=o;break;case 85:e=n>=48&&57>=n||n>=65&&75>=n||n>=77&&90>=n||95===n||n>=97&&107>=n||n>=109&&122>=n?4:76===n||108===n?81:-1,r=47,i=o;break;case 86:e=n>=48&&57>=n||n>=65&&83>=n||n>=85&&90>=n||95===n||n>=97&&115>=n||n>=117&&122>=n?4:84===n||116===n?82:-1,r=47,i=o;break;case 87:e=n>=48&&57>=n||n>=65&&83>=n||n>=85&&90>=n||95===n||n>=97&&115>=n||n>=117&&122>=n?4:84===n||116===n?83:-1,r=47,i=o;break;case 88:e=n>=48&&57>=n||n>=65&&68>=n||n>=70&&90>=n||95===n||n>=97&&100>=n||n>=102&&122>=n?4:69===n||101===n?86:-1,r=47,i=o;break;case 89:e=n>=48&&57>=n||n>=65&&66>=n||n>=68&&90>=n||95===n||n>=97&&98>=n||n>=100&&122>=n?4:67===n||99===n?87:-1,r=47,i=o;break;case 90:e=n>=48&&57>=n||n>=65&&77>=n||n>=79&&90>=n||95===n||n>=97&&109>=n||n>=111&&122>=n?4:78===n||110===n?89:-1,r=47,i=o}e>-1&&(10===n&&(t.line+=1,t.column=0,this.countLines&&(this.parCurLine=t.line)),t.column+=1,this.countLines&&(this.parCurColumn=t.column)),o+=1}while(e>-1)}while(2===r);return r>-1?(t.att=t.src.substr(s,i-s),t.offset=i,48===r&&(t.att=t.att.substr(1,t.att.length-2),t.att=t.att.replace(/\\\'/g,"'"))):(t.att="",r=-1),r},genTree:function(t,e,r){var i,s,o,n,a,h,c,l,d,u=[],p=[],f=0,b={la:0,act:0,offset:0,src:t,att:"",line:1,column:1,error_step:0};for(a=[[0,1],[51,2],[51,0],[53,2],[53,0],[54,3],[54,1],[54,0],[56,3],[56,1],[56,0],[57,3],[58,3],[58,1],[58,0],[59,3],[59,1],[62,3],[52,3],[52,5],[52,3],[52,5],[52,9],[52,3],[52,2],[52,2],[52,2],[52,2],[52,3],[52,1],[61,3],[61,4],[61,1],[55,3],[55,3],[55,3],[55,3],[55,3],[55,3],[55,3],[55,5],[55,1],[64,3],[64,3],[64,2],[64,1],[63,3],[63,3],[63,1],[66,3],[66,3],[66,3],[66,1],[68,3],[68,1],[67,2],[67,2],[67,1],[60,4],[60,7],[60,4],[60,5],[60,3],[60,1],[65,1],[65,1],[65,1],[65,3],[65,1],[65,7],[65,3],[65,3],[65,1],[65,1],[65,1]],h=[[],[3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[38,41],[47,42],[47,43],[3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[20,45],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53,20,54],[],[],[21,56],[30,57,29,58],[45,59,38,60,16,61,37,62],[21,-32],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[32,64,33,65],[],[35,66,34,67,36,68],[],[],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[],[38,70],[47,73],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[],[],[],[],[49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[45,79,38,60,16,80,37,62],[],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[5,82],[47,17,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[20,85],[],[],[],[49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[],[19,94,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[47,99],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[30,57,29,58],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[39,108,42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53],[47,110],[15,111,40,112],[],[43,113],[17,114,40,115],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53],[],[],[4,116],[47,117],[33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[20,120],[45,59,38,60,16,61],[],[43,121],[30,57,29,58],[30,57,29,58],[30,57,29,58],[30,57,29,58],[30,57,29,58],[30,57,29,58],[30,57,29,58],[],[],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53],[32,64,33,65],[32,64,33,65],[21,-30],[39,122,40,115],[17,123,32,64,33,65],[],[35,66,34,67,36,68],[35,66,34,67,36,68],[],[],[],[],[39,124,40,125],[],[],[47,73],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[],[17,130,32,64,33,65],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53,20,131],[31,18,33,33,32,34,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[16,135,49,22,50,23,47,38,38,24,48,25,8,26,14,27,12,29,13,30,46,31],[21,-31],[18,137],[47,138],[],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53],[],[],[],[42,46,24,47,23,48,26,49,25,50,27,51,28,52,22,53,20,139],[],[40,140],[33,33,32,34,31,18,49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[45,79,38,60,16,80],[],[],[47,17,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[49,22,50,23,47,38,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31],[17,145,32,64,33,65],[19,146,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[39,147],[45,79,38,60,16,80],[],[],[3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,47,17,31,18,49,22,50,23,38,24,48,25,8,26,14,27,16,28,12,29,13,30,46,31,33,33,32,34],[]],c=[[51,1],[52,2,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[],[55,36,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[55,39,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[52,40,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[],[],[],[52,44,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[],[],[53,55],[],[],[],[],[],[64,63,63,19,66,21,67,32,68,35,60,37,65,20],[],[],[],[],[],[55,69,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[],[],[56,71,57,72],[54,74,55,75,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[],[],[],[],[68,76,60,37,65,20],[68,77,60,37,65,20],[],[52,78,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[],[],[52,81,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[],[62,83,61,14,60,84,65,20],[],[],[],[],[65,86],[64,87,63,19,66,21,67,32,68,35,60,37,65,20],[64,88,63,19,66,21,67,32,68,35,60,37,65,20],[64,89,63,19,66,21,67,32,68,35,60,37,65,20],[64,90,63,19,66,21,67,32,68,35,60,37,65,20],[64,91,63,19,66,21,67,32,68,35,60,37,65,20],[64,92,63,19,66,21,67,32,68,35,60,37,65,20],[64,93,63,19,66,21,67,32,68,35,60,37,65,20],[],[52,95,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[55,96,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[63,97,66,21,67,32,68,35,60,37,65,20],[63,98,66,21,67,32,68,35,60,37,65,20],[],[54,100,55,75,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[63,101,66,21,67,32,68,35,60,37,65,20],[68,102,60,37,65,20],[],[66,103,67,32,68,35,60,37,65,20],[66,104,67,32,68,35,60,37,65,20],[67,105,68,35,60,37,65,20],[67,106,68,35,60,37,65,20],[67,107,68,35,60,37,65,20],[],[58,109],[],[],[],[],[],[],[],[],[],[63,118,66,21,67,32,68,35,60,37,65,20],[],[55,119,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[57,126],[55,127,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[],[55,128,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[52,129,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[],[],[],[55,132,64,15,63,19,66,21,67,32,68,35,60,37,65,20],[65,133],[59,134,60,136,65,20],[],[],[],[],[],[],[],[],[],[],[],[],[54,74,63,141,66,21,55,75,67,32,64,15,68,35,60,37,65,20],[],[53,142],[],[62,143,61,14,60,84,65,20],[60,144,65,20],[],[52,95,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[],[],[],[],[52,148,62,10,55,11,61,14,64,15,60,16,63,19,65,20,66,21,67,32,68,35],[]],l=[2,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,29,-1,41,54,66,-1,45,63,48,64,65,-1,68,-1,10,7,72,73,74,52,-1,-1,57,-1,54,66,-1,-1,-1,-1,24,25,26,-1,-1,-1,-1,-1,-1,-1,-1,27,-1,-1,-1,-1,-1,7,-1,-1,44,-1,-1,-1,-1,-1,-1,14,-1,9,-1,-1,6,55,56,18,-1,-1,20,-1,-1,-1,23,-1,39,38,37,36,35,34,33,28,3,17,43,42,62,-1,-1,53,47,46,51,50,49,67,-1,13,70,-1,-1,71,-1,-1,62,-1,-1,-1,-1,60,58,-1,-1,8,11,5,19,58,21,-1,40,61,7,16,4,12,-1,-1,45,-1,-1,15,59,69,-1,22],d=["Program'","ERROR_RESYNC","WHITESPACE","IF","ELSE","WHILE","DO","FOR","FUNCTION","USE","RETURN","DELETE","TRUE","FALSE","<<",">>","[","]","{","}",";","=","==","!=","~=","<=",">=",">","<","||","&&","!","+","-","/","%","*","^","(",")",",","#","?",":","|",".","NaN","Identifier","String","Integer","Float","Program","Stmt","Stmt_List","Param_List","Expression","Prop_List","Prop","Param_Def_List","Attr_List","ExtValue","Lhs","Assign","AddSubExp","LogExp","Value","MulDivExp","NegExp","ExpExp","$"],e||(e=[]),r||(r=[]),u.push(0),p.push(0),b.la=this.lex(b);;){for(b.act=150,n=0;h[u[u.length-1]].length>n;n+=2)if(h[u[u.length-1]][n]===b.la){b.act=h[u[u.length-1]][n+1];break}if(150===b.act&&(0>(b.act=l[u[u.length-1]])?b.act=150:b.act*=-1),150===b.act){if(0===b.error_step)for(f+=1,e.push({offset:b.offset-b.att.length,line:b.line}),r.push([]),n=0;h[u[u.length-1]].length>n;n+=2)r[r.length-1].push(d[h[u[u.length-1]][n]]);for(;u.length>1&&150===b.act;)for(u.pop(),p.pop(),n=0;h[u[u.length-1]].length>n;n+=2)if(1===h[u[u.length-1]][n]){b.act=h[u[u.length-1]][n+1],u.push(b.act),p.push("");break}if(u.length>1&&150!==b.act)for(;69!==b.la;){for(b.act=150,n=0;h[u[u.length-1]].length>n;n+=2)if(h[u[u.length-1]][n]===b.la){b.act=h[u[u.length-1]][n+1];break}if(150!==b.act)break;for(;0>(b.la=this.lex(b));)b.offset+=1}if(150===b.act||69===b.la)break;b.error_step=3}if(b.act>0)u.push(b.act),p.push(b.att),b.la=this.lex(b),b.error_step>0&&(b.error_step-=1);else{switch(i=-b.act,o=s,i){case 0:o=p[p.length-1];break;case 1:this.execute(p[p.length-1]);break;case 2:o=p[p.length];break;case 3:o=this.createNode("node_op","op_none",p[p.length-2],p[p.length-1]);break;case 4:o=p[p.length];break;case 5:o=this.createNode("node_op","op_param",p[p.length-1],p[p.length-3]);break;case 6:o=this.createNode("node_op","op_param",p[p.length-1]);break;case 7:o=p[p.length];break;case 8:o=this.createNode("node_op","op_proplst",p[p.length-3],p[p.length-1]);break;case 9:o=p[p.length-1];break;case 10:o=p[p.length];break;case 11:o=this.createNode("node_op","op_prop",p[p.length-3],p[p.length-1]);break;case 12:o=this.createNode("node_op","op_paramdef",p[p.length-1],p[p.length-3]);break;case 13:o=this.createNode("node_op","op_paramdef",p[p.length-1]);break;case 14:o=p[p.length];break;case 15:o=this.createNode("node_op","op_param",p[p.length-1],p[p.length-3]);break;case 16:o=this.createNode("node_op","op_param",p[p.length-1]);break;case 17:o=this.createNode("node_op","op_assign",p[p.length-3],p[p.length-1]);break;case 18:o=this.createNode("node_op","op_if",p[p.length-2],p[p.length-1]);break;case 19:o=this.createNode("node_op","op_if_else",p[p.length-4],p[p.length-3],p[p.length-1]);break;case 20:o=this.createNode("node_op","op_while",p[p.length-2],p[p.length-1]);break;case 21:o=this.createNode("node_op","op_do",p[p.length-4],p[p.length-2]);break;case 22:o=this.createNode("node_op","op_for",p[p.length-7],p[p.length-5],p[p.length-3],p[p.length-1]);break;case 23:o=this.createNode("node_op","op_use",p[p.length-2]);break;case 24:o=this.createNode("node_op","op_delete",p[p.length-1]);break;case 25:o=this.createNode("node_op","op_return",p[p.length-1]);break;case 26:o=p[p.length-2];break;case 27:o=this.createNode("node_op","op_noassign",p[p.length-2]);break;case 28:o=p[p.length-2],o.needsBrackets=!0;break;case 29:o=this.createNode("node_op","op_none");break;case 30:o=this.createNode("node_op","op_lhs",p[p.length-1],p[p.length-3],"dot");break;case 31:o=this.createNode("node_op","op_lhs",p[p.length-2],p[p.length-4],"bracket");break;case 32:o=this.createNode("node_op","op_lhs",p[p.length-1]);break;case 33:o=this.createNode("node_op","op_equ",p[p.length-3],p[p.length-1]);break;case 34:o=this.createNode("node_op","op_lot",p[p.length-3],p[p.length-1]);break;case 35:o=this.createNode("node_op","op_grt",p[p.length-3],p[p.length-1]);break;case 36:o=this.createNode("node_op","op_loe",p[p.length-3],p[p.length-1]);break;case 37:o=this.createNode("node_op","op_gre",p[p.length-3],p[p.length-1]);break;case 38:o=this.createNode("node_op","op_neq",p[p.length-3],p[p.length-1]);break;case 39:o=this.createNode("node_op","op_approx",p[p.length-3],p[p.length-1]);break;case 40:o=this.createNode("node_op","op_conditional",p[p.length-5],p[p.length-3],p[p.length-1]);break;case 41:o=p[p.length-1];break;case 42:o=this.createNode("node_op","op_or",p[p.length-3],p[p.length-1]);break;case 43:o=this.createNode("node_op","op_and",p[p.length-3],p[p.length-1]);break;case 44:o=this.createNode("node_op","op_not",p[p.length-1]);break;case 45:o=p[p.length-1];break;case 46:o=this.createNode("node_op","op_sub",p[p.length-3],p[p.length-1]);break;case 47:o=this.createNode("node_op","op_add",p[p.length-3],p[p.length-1]);break;case 48:o=p[p.length-1];break;case 49:o=this.createNode("node_op","op_mul",p[p.length-3],p[p.length-1]);break;case 50:o=this.createNode("node_op","op_div",p[p.length-3],p[p.length-1]);break;case 51:o=this.createNode("node_op","op_mod",p[p.length-3],p[p.length-1]);break;case 52:o=p[p.length-1];break;case 53:o=this.createNode("node_op","op_exp",p[p.length-3],p[p.length-1]);break;case 54:o=p[p.length-1];break;case 55:o=this.createNode("node_op","op_neg",p[p.length-1]);break;case 56:o=p[p.length-1];break;case 57:o=p[p.length-1];break;case 58:o=this.createNode("node_op","op_extvalue",p[p.length-4],p[p.length-2]);break;case 59:o=this.createNode("node_op","op_extvalue",this.createNode("node_op","op_execfun",p[p.length-7],p[p.length-5]),p[p.length-2]);break;case 60:o=this.createNode("node_op","op_execfun",p[p.length-4],p[p.length-2]);break;case 61:o=this.createNode("node_op","op_execfun",p[p.length-5],p[p.length-3],p[p.length-1],!0);break;case 62:o=this.createNode("node_op","op_property",p[p.length-3],p[p.length-1]);break;case 63:o=p[p.length-1];break;case 64:o=this.createNode("node_const",p[p.length-1]);break;case 65:o=this.createNode("node_const",p[p.length-1]);break;case 66:o=this.createNode("node_var",p[p.length-1]);break;case 67:o=p[p.length-2];break;case 68:o=this.createNode("node_str",p[p.length-1]);break;case 69:o=this.createNode("node_op","op_function",p[p.length-5],p[p.length-2]);break;case 70:o=this.createNode("node_op","op_proplst_val",p[p.length-2]);break;case 71:o=this.createNode("node_op","op_array",p[p.length-2]);break;case 72:o=this.createNode("node_const_bool",p[p.length-1]);break;case 73:o=this.createNode("node_const_bool",p[p.length-1]);break;case 74:o=this.createNode("node_const",0/0)}for(n=0;a[i][1]>n;n++)u.pop(),p.pop();for(b.act=150,n=0;c[u[u.length-1]].length>n;n+=2)if(c[u[u.length-1]][n]===a[i][0]){b.act=c[u[u.length-1]][n+1];break}if(0===i)break;u.push(b.act),p.push(o)}}return f}}),JXG.JessieCode}),define("base/ticks",["jxg","math/math","math/geometry","base/constants","base/element","base/coords","utils/type","base/text"],function(t,e,r,i,s,o,n,a){return t.Ticks=function(t,r,s){if(this.constructor(t.board,s,i.OBJECT_TYPE_TICKS,i.OBJECT_CLASS_OTHER),this.line=t,this.board=this.line.board,this.ticksFunction=null,this.fixedTicks=null,this.equidistant=!1,n.isFunction(r))throw this.ticksFunction=r,Error("Function arguments are no longer supported.");n.isArray(r)?this.fixedTicks=r:(Math.abs(r)<e.eps&&(r=s.defaultdistance),this.ticksFunction=function(){return r},this.equidistant=!0),this.minTicksDistance=s.minticksdistance,this.maxTicksDistance=s.maxticksdistance,this.labels=[],this.id=this.line.addTicks(this),this.board.setId(this,"Ti")},t.Ticks.prototype=new s,t.extend(t.Ticks.prototype,{hasPoint:function(t,r){var s,o,n=this.ticks&&this.ticks.length||0,a=this.board.options.precision.hasPoint;if(!this.line.visProp.scalable)return!1;if(0!==this.line.stdform[1]&&0!==this.line.stdform[2]&&this.line.type!==i.OBJECT_TYPE_AXIS)return!1;for(s=0;n>s;s++)if(o=this.ticks[s],o[2]&&!(0===this.line.stdform[1]&&Math.abs(o[0][0]-this.line.point1.coords.scrCoords[1])<e.eps||0===this.line.stdform[2]&&Math.abs(o[1][0]-this.line.point1.coords.scrCoords[2])<e.eps)&&(Math.abs(o[0][0]-o[0][1])>=1||Math.abs(o[1][0]-o[1][1])>=1))if(0===this.line.stdform[1]){if(2*a>Math.abs(r-.5*(o[1][0]+o[1][1]))&&t>o[0][0]-a&&o[0][1]+a>t)return!0}else if(0===this.line.stdform[2]&&2*a>Math.abs(t-.5*(o[0][0]+o[0][1]))&&r>o[1][0]-a&&o[1][1]+a>r)return!0;return!1},generateLabelValue:function(t,s){var o=this.visProp.anchor,n=-1,a=this.line.point1,h=this.line.point2;return"left"===o&&Math.abs(a.coords.usrCoords[2]-h.coords.usrCoords[2])<e.eps?t.usrCoords[1]:"left"===o&&Math.abs(a.coords.usrCoords[1]-h.coords.usrCoords[1])<e.eps?t.usrCoords[2]:(("right"===this.visProp.anchor&&!r.isSameDirection(h.coords,a.coords,t)||"right"!==this.visProp.anchor&&r.isSameDirection(a.coords,h.coords,t))&&(n=1),n*s.distance(i.COORDS_BY_USER,t))},setPositionDirectly:function(t,r,i){var s,n,a=new o(t,r,this.board),h=new o(t,i,this.board),c=this.board.getBoundingBox();return this.line.visProp.scalable?(Math.abs(this.line.stdform[1])<e.eps&&Math.abs(a.usrCoords[1]*h.usrCoords[1])>e.eps?(s=h.usrCoords[1]/a.usrCoords[1],c[0]*=s,c[2]*=s,this.board.setBoundingBox(c,!1)):Math.abs(this.line.stdform[2])<e.eps&&Math.abs(a.usrCoords[2]*h.usrCoords[2])>e.eps&&(n=h.usrCoords[2]/a.usrCoords[2],c[3]*=n,c[1]*=n,this.board.setBoundingBox(c,!1)),this):this},calculateTicksCoordinates:function(){var r,s,n,a,h,c,l,d,u,p,f,b,m,g,v,C,y,P,_,E,S,O,T,x,w=this.line.point1,k=this.line.point2,A=w.Dist(k),M=(k.coords.usrCoords[1]-w.coords.usrCoords[1])/A,N=(k.coords.usrCoords[2]-w.coords.usrCoords[2])/A,R=w.coords.distance(i.COORDS_BY_SCREEN,new o(i.COORDS_BY_USER,[w.coords.usrCoords[1]+M,w.coords.usrCoords[2]+N],this.board)),L=this.equidistant?this.ticksFunction(1):1,Y=5,B=0,j=0,D=2,X=-1,I=e.eps,J=.5*this.visProp.majorheight,G=.5*this.visProp.minorheight;if(0!==this.board.canvasWidth&&0!==this.board.canvasHeight&&(this.minStyle=0>this.visProp.minorheight?"infinite":"finite",this.majStyle=0>this.visProp.majorheight?"infinite":"finite",h="right"===this.visProp.anchor?k.coords:"middle"===this.visProp.anchor?new o(t.COORDS_BY_USER,[(w.coords.usrCoords[1]+k.coords.usrCoords[1])/2,(w.coords.usrCoords[2]+k.coords.usrCoords[2])/2],this.board):w.coords,y=this.line.visProp.straightfirst?Number.NEGATIVE_INFINITY:"middle"===this.visProp.anchor?-A/2+I:"right"===this.visProp.anchor?-A+I:I,P=this.line.visProp.straightlast?Number.POSITIVE_INFINITY:"middle"===this.visProp.anchor?A/2-I:"right"===this.visProp.anchor?-I:A-I,_=this.line.stdform[1],E=this.line.stdform[2],S=_,O=E,T=_,x=E,s=Math.sqrt(_*_*this.board.unitX*this.board.unitX+E*E*this.board.unitY*this.board.unitY),_*=J/s*this.board.unitX,E*=J/s*this.board.unitY,S*=G/s*this.board.unitX,O*=G/s*this.board.unitY,this.removeTickLabels(),!(Math.abs(T)<e.eps&&Math.abs(x)<e.eps)))if(this.ticks=[],this.labels=[],this.equidistant){c=L,L*=this.visProp.scale,this.visProp.insertticks&&this.minTicksDistance>e.eps&&(l=this._adjustTickDistance(L,R,Y,h,M,N),L*=l,c*=l),this.visProp.insertticks||(L/=this.visProp.minorticks+1,c/=this.visProp.minorticks+1),this.ticksDelta=L,n=this.board.getBoundingBox(),B=.5*(n[0]+n[2]),j=.5*(n[1]+n[3]),a=[B*this.line.stdform[2]-j*this.line.stdform[1],-this.line.stdform[2],this.line.stdform[1]],r=e.crossProduct(this.line.stdform,a),r[1]/=r[0],r[2]/=r[0],r[0]=1,d=new o(i.COORDS_BY_USER,r,this.board),s=h.distance(i.COORDS_BY_USER,d),(0>(k.X()-w.X())*(r[1]-w.X())||0>(k.Y()-w.Y())*(r[2]-w.Y()))&&(s*=-1),m=Math.round(s/L)*L,Math.abs(m)>e.eps&&(X=Math.abs(m)/m),r[1]=h.usrCoords[1]+M*m,r[2]=h.usrCoords[2]+N*m,u=m,m=0,g=0,p=u/this.visProp.scale,B=r[1],j=r[2],f=0,b=0;do d=new o(i.COORDS_BY_USER,[B,j],this.board),d.major=0===Math.round((X*m+u)/L)%(this.visProp.minorticks+1),v=this._tickEndings(d,T,x,_,E,S,O,d.major),3===v.length?(C=X*g+p,(Math.abs(C)>=I||this.visProp.drawzero)&&C>y&&P>C&&(this.ticks.push(v),d.major?this.labels.push(this._makeLabel(C,d,this.board,this.visProp.drawlabels,this.id,f,h)):this.labels.push(null),f++),2===D&&(X*=-1),(0===b%2||1===D)&&(m+=L,g+=c)):(X*=-1,D-=1),b++,B=r[1]+X*M*m,j=r[2]+X*N*m;while(D>0);this.needsUpdate=!0,this.updateRenderer()}else for(f=0;this.fixedTicks.length>f;f++)B=h.usrCoords[1]+this.fixedTicks[f]*M,j=h.usrCoords[2]+this.fixedTicks[f]*N,d=new o(i.COORDS_BY_USER,[B,j],this.board),v=this._tickEndings(d,T,x,_,E,S,O,!0),3===v.length&&this.fixedTicks[f]>=y&&P>this.fixedTicks[f]&&this.ticks.push(v),this.labels.push(this._makeLabel(this.visProp.labels[f]||this.fixedTicks[f],d,this.board,this.visProp.drawlabels,this.id,f,h))},_adjustTickDistance:function(t,e,r,s,n,a){for(var h,c,l=1;e>4*this.minTicksDistance;)l/=10,h=s.usrCoords[1]+n*t*l,c=s.usrCoords[2]+a*t*l,e=s.distance(i.COORDS_BY_SCREEN,new o(i.COORDS_BY_USER,[h,c],this.board));for(;this.minTicksDistance>e;)l*=r,r=5===r?2:5,h=s.usrCoords[1]+n*t*l,c=s.usrCoords[2]+a*t*l,e=s.distance(i.COORDS_BY_SCREEN,new o(i.COORDS_BY_USER,[h,c],this.board));return l},_tickEndings:function(t,r,i,s,o,n,a,h){var c,l,d,u,p,f=this.board.canvasWidth,b=this.board.canvasHeight,m=[-1e3*f,-1e3*b],g=[-1e3*f,-1e3*b],v=0,C=!1;return c=t.scrCoords,h?(l=s,d=o,p=this.majStyle):(l=n,d=a,p=this.minStyle),Math.abs(r)<e.eps?(m[0]=c[1],m[1]=c[1],g[0]=0,g[1]=b):Math.abs(i)<e.eps?(m[0]=0,m[1]=f,g[0]=c[2],g[1]=c[2]):(v=0,u=e.crossProduct([0,0,1],[-d*c[1]-l*c[2],d,l]),u[1]/=u[0],u[1]>=0&&f>=u[1]&&(m[v]=u[1],g[v]=0,v++),u=e.crossProduct([0,1,0],[-d*c[1]-l*c[2],d,l]),u[2]/=u[0],u[2]>=0&&b>=u[2]&&(m[v]=0,g[v]=u[2],v++),2>v&&(u=e.crossProduct([b*b,0,-b],[-d*c[1]-l*c[2],d,l]),u[1]/=u[0],u[1]>=0&&f>=u[1]&&(m[v]=u[1],g[v]=b,v++)),2>v&&(u=e.crossProduct([f*f,-f,0],[-d*c[1]-l*c[2],d,l]),u[2]/=u[0],u[2]>=0&&b>=u[2]&&(m[v]=f,g[v]=u[2]))),C=m[0]>=0&&f>=m[0]&&g[0]>=0&&b>=g[0]||m[1]>=0&&f>=m[1]&&g[1]>=0&&b>=g[1],"finite"===p&&(m[0]=c[1]+l*this.visProp.tickendings[0],g[0]=c[2]-d*this.visProp.tickendings[0],m[1]=c[1]-l*this.visProp.tickendings[1],g[1]=c[2]+d*this.visProp.tickendings[1]),C?[m,g,h]:[]},_makeLabel:function(t,r,s,o,h,c,l){var d,u,p,f="number"==typeof t;return o?(t=this.generateLabelValue(r,l),d=""+t,r.distance(i.COORDS_BY_USER,l)<e.eps&&(d="0"),f&&(d.length>5||-1!==d.indexOf("e"))&&(d=""+t.toPrecision(3)),f&&d.indexOf(".")>-1&&-1===d.indexOf("e")&&(d=d.replace(/0+$/,""),d=d.replace(/\.$/,"")),this.visProp.scalesymbol.length>0&&"1"===d?d=this.visProp.scalesymbol:this.visProp.scalesymbol.length>0&&"0"===d?d="0":d+=this.visProp.scalesymbol,p={id:h+c+"Label",isLabel:!0,layer:s.options.layer.line,highlightStrokeColor:s.options.text.strokeColor,highlightStrokeWidth:s.options.text.strokeWidth,highlightStrokeOpacity:s.options.text.strokeOpacity,visible:this.visProp.visible,priv:this.visProp.priv},p=n.deepCopy(p,this.visProp.label),u=a.createText(s,[r.usrCoords[1],r.usrCoords[2],d],p),u.isDraggable=!1,u.dump=!1,u.distanceX=this.visProp.label.offset[0],u.distanceY=this.visProp.label.offset[1],u.setCoords(r.usrCoords[1]+u.distanceX/s.unitX,r.usrCoords[2]+u.distanceY/s.unitY),u.visProp.visible=o,u):null},removeTickLabels:function(){var t;if(n.exists(this.labels)&&(this.board.needsFullUpdate||this.needsRegularUpdate||this.needsUpdate)&&("canvas"!==this.board.renderer.type||"internal"!==this.board.options.text.display))for(t=0;this.labels.length>t;t++)n.exists(this.labels[t])&&this.board.removeObject(this.labels[t])},update:function(){return this.needsUpdate&&this.calculateTicksCoordinates(),this},updateRenderer:function(){return this.needsUpdate&&(this.ticks&&this.board.renderer.updateTicks(this,this.dxMaj,this.dyMaj,this.dxMin,this.dyMin,this.minStyle,this.majStyle),this.needsUpdate=!1),this},hideElement:function(){var t;for(this.visProp.visible=!1,this.board.renderer.hide(this),t=0;this.labels.length>t;t++)n.exists(this.labels[t])&&this.labels[t].hideElement();return this},showElement:function(){var t;for(this.visProp.visible=!0,this.board.renderer.show(this),t=0;this.labels.length>t;t++)n.exists(this.labels[t])&&this.labels[t].showElement();return this}}),t.createTicks=function(e,r,s){var o,a,h=n.copyAttributes(s,e.options,"ticks");if(a=2>r.length?h.ticksdistance:r[1],r[0].elementClass!==i.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create Ticks with parent types '"+typeof r[0]+"'.");return o=new t.Ticks(r[0],a,h),"function"==typeof h.generatelabelvalue&&(o.generateLabelValue=h.generatelabelvalue),o.isDraggable=!0,o},t.createHashmark=function(t,e,r){var s,o,a,h,c,l=[],d=n.copyAttributes(r,t.options,"hash");if(e[0].elementClass!==i.OBJECT_CLASS_LINE||"number"!=typeof e[1])throw Error("JSXGraph: Can't create Hash with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'.");for(s=e[1],h=d.ticksdistance,c=(s-1)*h,a=-c/2,o=0;s>o;o++)l[o]=a+o*h;return t.create("ticks",[e[0],l],d)},t.registerElement("ticks",t.createTicks),t.registerElement("hash",t.createHashmark),{Ticks:t.Ticks,createTicks:t.createTicks,createHashmark:t.createHashmark}}),define("base/line",["jxg","math/math","math/geometry","math/numerics","math/statistics","base/constants","base/coords","base/element","utils/type","base/transformation","base/point","base/ticks"],function(t,e,r,i,s,o,n,a,h,c,l){return t.Line=function(e,r,i,s){this.constructor(e,s,o.OBJECT_TYPE_LINE,o.OBJECT_CLASS_LINE),this.point1=this.board.select(r),this.point2=this.board.select(i),this.ticks=[],this.defaultTicks=null,this.parentPolygon=null,this.id=this.board.setId(this,"L"),this.board.renderer.drawLine(this),this.board.finalizeAdding(this),this.elType="line",this.point1.addChild(this),this.point2.addChild(this),this.updateStdform(),this.createLabel(),this.methodMap=t.deepCopy(this.methodMap,{point1:"point1",point2:"point2",getSlope:"getSlope",getRise:"getRise",getYIntersect:"getRise",getAngle:"getAngle",L:"L",length:"L",addTicks:"addTicks",removeTicks:"removeTicks",removeAllTicks:"removeAllTicks"})
},t.Line.prototype=new a,t.extend(t.Line.prototype,{hasPoint:function(t,i){var s,a,h,c,l,d,u,p=[],f=[1,t,i];return p[0]=this.stdform[0]-this.stdform[1]*this.board.origin.scrCoords[1]/this.board.unitX+this.stdform[2]*this.board.origin.scrCoords[2]/this.board.unitY,p[1]=this.stdform[1]/this.board.unitX,p[2]=this.stdform[2]/-this.board.unitY,s=r.distPointLine(f,p),isNaN(s)||s>this.board.options.precision.hasPoint?!1:this.visProp.straightfirst&&this.visProp.straightlast?!0:(h=this.point1.coords,c=this.point2.coords,a=[0,p[1],p[2]],a=e.crossProduct(a,f),a=e.crossProduct(a,p),a[1]/=a[0],a[2]/=a[0],a[0]=1,a=new n(o.COORDS_BY_SCREEN,a.slice(1),this.board).usrCoords,l=h.distance(o.COORDS_BY_USER,c),h=h.usrCoords.slice(0),c=c.usrCoords.slice(0),e.eps>l?d=0:(l===Number.POSITIVE_INFINITY&&(l=1/e.eps,Math.abs(c[0])<e.eps?(l/=r.distance([0,0,0],c),c=[1,h[1]+c[1]*l,h[2]+c[2]*l]):(l/=r.distance([0,0,0],h),h=[1,c[1]+h[1]*l,c[2]+h[2]*l])),u=1,l=c[u]-h[u],Math.abs(l)<e.eps&&(u=2,l=c[u]-h[u]),d=(a[u]-h[u])/l),!this.visProp.straightfirst&&0>d?!1:!this.visProp.straightlast&&d>1?!1:!0)},update:function(){var t;return this.needsUpdate?(this.constrained&&("function"==typeof this.funps?(t=this.funps(),t&&t.length&&2===t.length&&(this.point1=t[0],this.point2=t[1])):("function"==typeof this.funp1&&(t=this.funp1(),h.isPoint(t)?this.point1=t:t&&t.length&&2===t.length&&this.point1.setPositionDirectly(o.COORDS_BY_USER,t)),"function"==typeof this.funp2&&(t=this.funp2(),h.isPoint(t)?this.point2=t:t&&t.length&&2===t.length&&this.point2.setPositionDirectly(o.COORDS_BY_USER,t)))),this.updateSegmentFixedLength(),this.updateStdform(),this.visProp.trace&&this.cloneToBackground(!0),this):this},updateSegmentFixedLength:function(){var t,r,i,s,n,a,h,c;return this.hasFixedLength?(t=this.point1.Dist(this.point2),r=this.fixedLength(),i=this.fixedLengthOldCoords[0].distance(o.COORDS_BY_USER,this.point1.coords),s=this.fixedLengthOldCoords[1].distance(o.COORDS_BY_USER,this.point2.coords),(i>e.eps||s>e.eps||t!==r)&&(n=this.point1.isDraggable&&this.point1.type!==o.OBJECT_TYPE_GLIDER&&!this.point1.visProp.fixed,a=this.point2.isDraggable&&this.point2.type!==o.OBJECT_TYPE_GLIDER&&!this.point2.visProp.fixed,t>e.eps?i>s&&a||s>=i&&a&&!n?(this.point2.setPositionDirectly(o.COORDS_BY_USER,[this.point1.X()+(this.point2.X()-this.point1.X())*r/t,this.point1.Y()+(this.point2.Y()-this.point1.Y())*r/t]),this.point2.prepareUpdate().updateRenderer()):(s>=i&&n||i>s&&n&&!a)&&(this.point1.setPositionDirectly(o.COORDS_BY_USER,[this.point2.X()+(this.point1.X()-this.point2.X())*r/t,this.point2.Y()+(this.point1.Y()-this.point2.Y())*r/t]),this.point1.prepareUpdate().updateRenderer()):(h=Math.random()-.5,c=Math.random()-.5,t=Math.sqrt(h*h+c*c),a?(this.point2.setPositionDirectly(o.COORDS_BY_USER,[this.point1.X()+h*r/t,this.point1.Y()+c*r/t]),this.point2.prepareUpdate().updateRenderer()):n&&(this.point1.setPositionDirectly(o.COORDS_BY_USER,[this.point2.X()+h*r/t,this.point2.Y()+c*r/t]),this.point1.prepareUpdate().updateRenderer())),this.fixedLengthOldCoords[0].setCoordinates(o.COORDS_BY_USER,this.point1.coords.usrCoords),this.fixedLengthOldCoords[1].setCoordinates(o.COORDS_BY_USER,this.point2.coords.usrCoords)),this):this},updateStdform:function(){var t=e.crossProduct(this.point1.coords.usrCoords,this.point2.coords.usrCoords);this.stdform[0]=t[0],this.stdform[1]=t[1],this.stdform[2]=t[2],this.stdform[3]=0,this.normalize()},updateRenderer:function(){var t;return this.needsUpdate&&this.visProp.visible&&(t=this.isReal,this.isReal=!isNaN(this.point1.coords.usrCoords[1]+this.point1.coords.usrCoords[2]+this.point2.coords.usrCoords[1]+this.point2.coords.usrCoords[2])&&e.innerProduct(this.stdform,this.stdform,3)>=e.eps*e.eps,this.isReal?(t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.show(this.label.content)),this.board.renderer.updateLine(this)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.hide(this.label.content)),this.needsUpdate=!1),this.hasLabel&&this.label.content.visProp.visible&&this.isReal&&(this.label.content.update(),this.board.renderer.updateText(this.label.content)),this},generatePolynomial:function(t){var e=this.point1.symbolic.x,r=this.point1.symbolic.y,i=this.point2.symbolic.x,s=this.point2.symbolic.y,o=t.symbolic.x,n=t.symbolic.y;return[["(",r,")*(",o,")-(",r,")*(",i,")+(",n,")*(",i,")-(",e,")*(",n,")+(",e,")*(",s,")-(",o,")*(",s,")"].join("")]},getRise:function(){return Math.abs(this.stdform[2])>=e.eps?-this.stdform[0]/this.stdform[2]:1/0},getSlope:function(){return Math.abs(this.stdform[2])>=e.eps?-this.stdform[1]/this.stdform[2]:1/0},getAngle:function(){return Math.atan2(-this.stdform[1],this.stdform[2])},setStraight:function(t,e){return this.visProp.straightfirst=t,this.visProp.straightlast=e,this.board.renderer.updateLine(this),this},getTextAnchor:function(){return new n(o.COORDS_BY_USER,[.5*(this.point2.X()+this.point1.X()),.5*(this.point2.Y()+this.point1.Y())],this.board)},setLabelRelativeCoords:function(t){h.exists(this.label.content)&&(this.label.content.relativeCoords=new n(o.COORDS_BY_SCREEN,[t[0],-t[1]],this.board))},getLabelAnchor:function(){var t,i,s=0,a=0,c=0,l=new n(o.COORDS_BY_USER,this.point1.coords.usrCoords,this.board),d=new n(o.COORDS_BY_USER,this.point2.coords.usrCoords,this.board);if((this.visProp.straightfirst||this.visProp.straightlast)&&r.calcStraight(this,l,d,0),l=l.scrCoords,d=d.scrCoords,!h.exists(this.label.content))return new n(o.COORDS_BY_SCREEN,[0/0,0/0],this.board);switch(this.label.content.visProp.position){case"lft":case"llft":case"ulft":l[1]<=d[1]?(t=l[1],i=l[2]):(t=d[1],i=d[2]);break;case"rt":case"lrt":case"urt":l[1]>d[1]?(t=l[1],i=l[2]):(t=d[1],i=d[2]);break;default:t=.5*(l[1]+d[1]),i=.5*(l[2]+d[2])}return(this.visProp.straightfirst||this.visProp.straightlast)&&(h.exists(this.label.content)&&(a=parseFloat(this.label.content.visProp.offset[0]),c=parseFloat(this.label.content.visProp.offset[1]),s=this.label.content.visProp.fontsize),Math.abs(t)<e.eps?t=a:this.board.canvasWidth+e.eps>t&&t>this.board.canvasWidth-s-e.eps&&(t=this.board.canvasWidth-a-s),e.eps+s>i&&i>-e.eps?i=c+s:this.board.canvasHeight+e.eps>i&&i>this.board.canvasHeight-s-e.eps&&(i=this.board.canvasHeight-c)),new n(o.COORDS_BY_SCREEN,[t,i],this.board)},cloneToBackground:function(){var t,e,r,i={};return i.id=this.id+"T"+this.numTraces,i.elementClass=o.OBJECT_CLASS_LINE,this.numTraces++,i.point1=this.point1,i.point2=this.point2,i.stdform=this.stdform,i.board=this.board,i.visProp=h.deepCopy(this.visProp,this.visProp.traceattributes,!0),i.visProp.layer=this.board.options.layer.trace,h.clearVisPropOld(i),e=this.getSlope(),t=this.getRise(),i.getSlope=function(){return e},i.getRise=function(){return t},r=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawLine(i),this.board.renderer.enhancedRendering=r,this.traces[i.id]=i.rendNode,this},addTransform:function(t){var e,r=h.isArray(t)?t:[t],i=r.length;for(e=0;i>e;e++)this.point1.transformations.push(r[e]),this.point2.transformations.push(r[e]);return this},setPosition:function(t,e){var r;return e=new n(t,e,this.board),r=this.board.create("transform",e.usrCoords.slice(1),{type:"translate"}),this.point1.transformations.length>0&&this.point1.transformations[this.point1.transformations.length-1].isNumericMatrix?this.point1.transformations[this.point1.transformations.length-1].melt(r):this.point1.addTransform(this.point1,r),this.point2.transformations.length>0&&this.point2.transformations[this.point2.transformations.length-1].isNumericMatrix?this.point2.transformations[this.point2.transformations.length-1].melt(r):this.point2.addTransform(this.point2,r),this},setPositionDirectly:function(t,e,r){var i,o,a=new n(t,e,this.board),h=new n(t,r,this.board);return this.point1.draggable()&&this.point2.draggable()?(i=s.subtract(a.usrCoords,h.usrCoords),o=this.board.create("transform",i.slice(1),{type:"translate"}),o.applyOnce([this.point1,this.point2]),this):this},snapToGrid:function(t){var i,a,h,c,l,d,u,p,f;return this.visProp.snaptogrid&&(this.point1.visProp.snaptogrid||this.point2.visProp.snaptogrid?(this.point1.snapToGrid(),this.point2.snapToGrid()):(p=this.visProp.snapsizex,f=this.visProp.snapsizey,i=new n(o.COORDS_BY_SCREEN,[t.Xprev,t.Yprev],this.board),d=i.usrCoords[1],u=i.usrCoords[2],0>=p&&this.board.defaultAxes&&this.board.defaultAxes.x.defaultTicks&&(p=this.board.defaultAxes.x.defaultTicks.ticksDelta*(this.board.defaultAxes.x.defaultTicks.visProp.minorticks+1)),0>=f&&this.board.defaultAxes&&this.board.defaultAxes.y.defaultTicks&&(f=this.board.defaultAxes.y.defaultTicks.ticksDelta*(this.board.defaultAxes.y.defaultTicks.visProp.minorticks+1)),p>0&&f>0&&(l=[0,this.stdform[1],this.stdform[2]],l=e.crossProduct(l,i.usrCoords),a=r.meetLineLine(l,this.stdform,0,this.board),h=s.subtract([1,Math.round(d/p)*p,Math.round(u/f)*f],a.usrCoords),c=this.board.create("transform",h.slice(1),{type:"translate"}),c.applyOnce([this.point1,this.point2])))),this},X:function(t){var r,i=this.stdform[2];return r=Math.abs(this.point1.coords.usrCoords[0])>e.eps?this.point1.coords.usrCoords[1]:this.point2.coords.usrCoords[1],t=2*(t-.5),(1-Math.abs(t))*r-t*i},Y:function(t){var r,i=this.stdform[1];return r=Math.abs(this.point1.coords.usrCoords[0])>e.eps?this.point1.coords.usrCoords[2]:this.point2.coords.usrCoords[2],t=2*(t-.5),(1-Math.abs(t))*r+t*i},Z:function(t){var r=Math.abs(this.point1.coords.usrCoords[0])>e.eps?this.point1.coords.usrCoords[0]:this.point2.coords.usrCoords[0];return t=2*(t-.5),(1-Math.abs(t))*r},L:function(){return this.point1.Dist(this.point2)},minX:function(){return 0},maxX:function(){return 1},bounds:function(){var t=this.point1.coords.usrCoords,e=this.point2.coords.usrCoords;return[Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[1],e[1]),Math.min(t[2],e[2])]},addTicks:function(t){return""!==t.id&&h.exists(t.id)||(t.id=this.id+"_ticks_"+(this.ticks.length+1)),this.board.renderer.drawTicks(t),this.ticks.push(t),t.id},remove:function(){this.removeAllTicks(),a.prototype.remove.call(this)},removeAllTicks:function(){var t;for(t=this.ticks.length;t>0;t--)this.removeTicks(this.ticks[t-1]);this.ticks=[],this.board.update()},removeTicks:function(t){var e,r;for(h.exists(this.defaultTicks)&&this.defaultTicks===t&&(this.defaultTicks=null),e=this.ticks.length;e>0;e--)if(this.ticks[e-1]===t){if(this.board.removeObject(this.ticks[e-1]),this.ticks[e-1].ticks)for(r=0;this.ticks[e-1].ticks.length>r;r++)h.exists(this.ticks[e-1].labels[r])&&this.board.removeObject(this.ticks[e-1].labels[r]);delete this.ticks[e-1];break}},hideElement:function(){var t;for(a.prototype.hideElement.call(this),t=0;this.ticks.length>t;t++)this.ticks[t].hideElement()},showElement:function(){var t;for(a.prototype.showElement.call(this),t=0;this.ticks.length>t;t++)this.ticks[t].showElement()}}),t.createLine=function(e,r,i){var s,n,a,c,d,u,p,f=[],b=!1;if(2===r.length){if(h.isArray(r[0])&&r[0].length>1)u=h.copyAttributes(i,e.options,"line","point1"),a=e.create("point",r[0],u);else if(h.isString(r[0])||r[0].elementClass===o.OBJECT_CLASS_POINT)a=e.select(r[0]);else if("function"==typeof r[0]&&r[0]().elementClass===o.OBJECT_CLASS_POINT)a=r[0](),b=!0;else{if("function"!=typeof r[0]||!r[0]().length||2!==r[0]().length)throw Error("JSXGraph: Can't create line with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]");u=h.copyAttributes(i,e.options,"line","point1"),a=l.createPoint(e,r[0](),u),b=!0}if(h.isArray(r[1])&&r[1].length>1)u=h.copyAttributes(i,e.options,"line","point2"),c=e.create("point",r[1],u);else if(h.isString(r[1])||r[1].elementClass===o.OBJECT_CLASS_POINT)c=e.select(r[1]);else if("function"==typeof r[1]&&r[1]().elementClass===o.OBJECT_CLASS_POINT)c=r[1](),b=!0;else{if("function"!=typeof r[1]||!r[1]().length||2!==r[1]().length)throw Error("JSXGraph: Can't create line with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]");u=h.copyAttributes(i,e.options,"line","point2"),c=l.createPoint(e,r[1](),u),b=!0}u=h.copyAttributes(i,e.options,"line"),n=new t.Line(e,a,c,u),b?(n.constrained=!0,n.funp1=r[0],n.funp2=r[1]):n.isDraggable=!0,n.constrained||(n.parents=[a.id,c.id])}else if(3===r.length){for(p=!0,d=0;3>d;d++)if("number"==typeof r[d])f[d]=h.createFunction(r[d]);else{if("function"!=typeof r[d])throw Error("JSXGraph: Can't create line with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"' and '"+typeof r[2]+"'."+"\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]");f[d]=r[d],p=!1}u=h.copyAttributes(i,e.options,"line","point1"),a=p?e.create("point",[f[2]()*f[2]()+f[1]()*f[1](),f[2]()-f[1]()*f[0]()+f[2](),-f[1]()-f[2]()*f[0]()-f[1]()],u):e.create("point",[function(){return.5*(f[2]()*f[2]()+f[1]()*f[1]())},function(){return.5*(f[2]()-f[1]()*f[0]()+f[2]())},function(){return.5*(-f[1]()-f[2]()*f[0]()-f[1]())}],u),u=h.copyAttributes(i,e.options,"line","point2"),c=p?e.create("point",[f[2]()*f[2]()+f[1]()*f[1](),-f[1]()*f[0]()+f[2](),-f[2]()*f[0]()-f[1]()],u):e.create("point",[function(){return f[2]()*f[2]()+f[1]()*f[1]()},function(){return-f[1]()*f[0]()+f[2]()},function(){return-f[2]()*f[0]()-f[1]()}],u),a.prepareUpdate().update(),c.prepareUpdate().update(),u=h.copyAttributes(i,e.options,"line"),n=new t.Line(e,a,c,u),n.isDraggable=p,p&&(n.parents=[f[0](),f[1](),f[2]()])}else if(1===r.length&&"function"==typeof r[0]&&2===r[0]().length&&r[0]()[0].elementClass===o.OBJECT_CLASS_POINT&&r[0]()[1].elementClass===o.OBJECT_CLASS_POINT)s=r[0](),u=h.copyAttributes(i,e.options,"line"),n=new t.Line(e,s[0],s[1],u),n.constrained=!0,n.funps=r[0];else{if(1!==r.length||"function"!=typeof r[0]||3!==r[0]().length||"number"!=typeof r[0]()[0]||"number"!=typeof r[0]()[1]||"number"!=typeof r[0]()[2])throw Error("JSXGraph: Can't create line with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]");s=r[0],u=h.copyAttributes(i,e.options,"line","point1"),a=e.create("point",[function(){var t=s();return[.5*(t[2]*t[2]+t[1]*t[1]),.5*(t[2]-t[1]*t[0]+t[2]),.5*(-t[1]-t[2]*t[0]-t[1])]}],u),u=h.copyAttributes(i,e.options,"line","point2"),c=e.create("point",[function(){var t=s();return[t[2]*t[2]+t[1]*t[1],-t[1]*t[0]+t[2],-t[2]*t[0]-t[1]]}],u),u=h.copyAttributes(i,e.options,"line"),n=new t.Line(e,a,c,u),n.constrained=!0,n.funps=r[0]}return n},t.registerElement("line",t.createLine),t.createSegment=function(t,e,r){var i,s;if(r.straightFirst=!1,r.straightLast=!1,s=h.copyAttributes(r,t.options,"segment"),i=t.create("line",e.slice(0,2),s),3===e.length){if(i.hasFixedLength=!0,h.isNumber(e[2]))i.fixedLength=function(){return e[2]};else{if(!h.isFunction(e[2]))throw Error("JSXGraph: Can't create segment with third parent type '"+typeof e[2]+"'."+"\nPossible third parent types: number or function");i.fixedLength=e[2]}i.fixedLengthOldCoords=[],i.fixedLengthOldCoords[0]=new n(o.COORDS_BY_USER,i.point1.coords.usrCoords.slice(1,3),t),i.fixedLengthOldCoords[1]=new n(o.COORDS_BY_USER,i.point2.coords.usrCoords.slice(1,3),t)}return i.elType="segment",i},t.registerElement("segment",t.createSegment),t.createArrow=function(t,e,r){var i;return r.firstArrow=!1,r.lastArrow=!0,i=t.create("line",e,r).setStraight(!1,!1),i.type=o.OBJECT_TYPE_VECTOR,i.elType="arrow",i},t.registerElement("arrow",t.createArrow),t.createAxis=function(t,e,r){var i,s,n,a;if(!h.isArray(e[0])&&!h.isPoint(e[0])||!h.isArray(e[1])&&!h.isPoint(e[1]))throw Error("JSXGraph: Can't create axis with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [point,point], [[x1,y1],[x2,y2]]");i=h.copyAttributes(r,t.options,"axis"),s=t.create("line",e,i),s.type=o.OBJECT_TYPE_AXIS,s.isDraggable=!1,s.point1.isDraggable=!1,s.point2.isDraggable=!1;for(n in s.ancestors)s.ancestors.hasOwnProperty(n)&&(s.ancestors[n].type=o.OBJECT_TYPE_AXISPOINT);return i=h.copyAttributes(r,t.options,"axis","ticks"),a=h.exists(i.ticksdistance)?i.ticksdistance:h.isArray(i.ticks)?i.ticks:1,s.defaultTicks=t.create("ticks",[s,a],i),s.defaultTicks.dump=!1,s.elType="axis",s.subs={ticks:s.defaultTicks},s},t.registerElement("axis",t.createAxis),t.createTangent=function(t,r,s){var n,a,c,l,d,u,p,f;if(1===r.length)n=r[0],a=n.slideObject;else{if(2!==r.length)throw Error("JSXGraph: Can't create tangent with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [glider], [point,line|curve|circle|conic]");if(h.isPoint(r[0]))n=r[0],a=r[1];else{if(!h.isPoint(r[1]))throw Error("JSXGraph: Can't create tangent with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [glider], [point,line|curve|circle|conic]");a=r[0],n=r[1]}}if(a.elementClass===o.OBJECT_CLASS_LINE?f=t.create("line",[a.point1,a.point2],s):a.elementClass===o.OBJECT_CLASS_CURVE&&a.type!==o.OBJECT_TYPE_CONIC?"plot"!==a.visProp.curvetype?(c=a.X,l=a.Y,f=t.create("line",[function(){return-n.X()*i.D(l)(n.position)+n.Y()*i.D(c)(n.position)},function(){return i.D(l)(n.position)},function(){return-i.D(c)(n.position)}],s),n.addChild(f),f.glider=n):(f=t.create("line",[function(){var t=Math.floor(n.position);return t===a.numberPoints-1&&t--,0>t?1:a.Y(t)*a.X(t+1)-a.X(t)*a.Y(t+1)},function(){var t=Math.floor(n.position);return t===a.numberPoints-1&&t--,0>t?0:a.Y(t+1)-a.Y(t)},function(){var t=Math.floor(n.position);return t===a.numberPoints-1&&t--,0>t?0:a.X(t)-a.X(t+1)}],s),n.addChild(f),f.glider=n):a.type===o.OBJECT_TYPE_TURTLE?(f=t.create("line",[function(){var t=Math.floor(n.position);for(u=0;a.objects.length>u;u++)if(p=a.objects[u],p.type===o.OBJECT_TYPE_CURVE){if(p.numberPoints>t)break;t-=p.numberPoints}return t===p.numberPoints-1&&t--,0>t?1:p.Y(t)*p.X(t+1)-p.X(t)*p.Y(t+1)},function(){var t=Math.floor(n.position);for(u=0;a.objects.length>u;u++)if(p=a.objects[u],p.type===o.OBJECT_TYPE_CURVE){if(p.numberPoints>t)break;t-=p.numberPoints}return t===p.numberPoints-1&&t--,0>t?0:p.Y(t+1)-p.Y(t)},function(){var t=Math.floor(n.position);for(u=0;a.objects.length>u;u++)if(p=a.objects[u],p.type===o.OBJECT_TYPE_CURVE){if(p.numberPoints>t)break;t-=p.numberPoints}return t===p.numberPoints-1&&t--,0>t?0:p.X(t)-p.X(t+1)}],s),n.addChild(f),f.glider=n):(a.elementClass===o.OBJECT_CLASS_CIRCLE||a.type===o.OBJECT_TYPE_CONIC)&&(f=t.create("line",[function(){return e.matVecMult(a.quadraticform,n.coords.usrCoords)[0]},function(){return e.matVecMult(a.quadraticform,n.coords.usrCoords)[1]},function(){return e.matVecMult(a.quadraticform,n.coords.usrCoords)[2]}],s),n.addChild(f),f.glider=n),!h.exists(f))throw Error("JSXGraph: Couldn't create tangent with the given parents.");for(f.elType="tangent",f.parents=[],d=0;r.length>d;d++)f.parents.push(r[d].id);return f},t.registerElement("tangent",t.createTangent),t.registerElement("polar",t.createTangent),{Line:t.Line,createLine:t.createLine,createTangent:t.createTangent,createPolar:t.createTangent,createSegment:t.createSegment,createAxis:t.createAxis,createArrow:t.createArrow}}),define("base/circle",["jxg","base/element","base/coords","base/constants","parser/geonext","math/geometry","math/statistics","utils/type","base/transformation","base/point"],function(t,e,r,i,s,o,n,a){return t.Circle=function(t,e,r,s,o){this.constructor(t,o,i.OBJECT_TYPE_CIRCLE,i.OBJECT_CLASS_CIRCLE),this.method=e,this.midpoint=this.board.select(r),this.center=this.board.select(r),this.point2=null,this.radius=0,this.line=null,this.circle=null,"twoPoints"===e?(this.point2=t.select(s),this.radius=this.Radius()):"pointRadius"===e?(this.gxtterm=s,this.updateRadius=a.createFunction(s,this.board,null,!0),this.updateRadius()):"pointLine"===e?(this.line=t.select(s),this.radius=this.line.point1.coords.distance(i.COORDS_BY_USER,this.line.point2.coords)):"pointCircle"===e&&(this.circle=t.select(s),this.radius=this.circle.Radius()),this.id=this.board.setId(this,"C"),this.board.renderer.drawEllipse(this),this.board.finalizeAdding(this),this.createGradient(),this.elType="circle",this.createLabel(),this.center.addChild(this),"pointRadius"===e?this.notifyParents(s):"pointLine"===e?this.line.addChild(this):"pointCircle"===e?this.circle.addChild(this):"twoPoints"===e&&this.point2.addChild(this),this.methodMap=a.deepCopy(this.methodMap,{setRadius:"setRadius",getRadius:"getRadius",radius:"Radius",center:"center",line:"line",point2:"point2"})},t.Circle.prototype=new e,t.extend(t.Circle.prototype,{hasPoint:function(t,e){var s=this.board.options.precision.hasPoint/this.board.unitX,o=this.center.coords.usrCoords,n=new r(i.COORDS_BY_SCREEN,[t,e],this.board),a=this.Radius(),h=Math.sqrt((o[1]-n.usrCoords[1])*(o[1]-n.usrCoords[1])+(o[2]-n.usrCoords[2])*(o[2]-n.usrCoords[2]));return this.visProp.hasinnerpoints?a+s>h:s>Math.abs(h-a)},generatePolynomial:function(t){var e=this.center.symbolic.x,r=this.center.symbolic.y,i=t.symbolic.x,s=t.symbolic.y,o=this.generateRadiusSquared();return""===o?[]:["(("+i+")-("+e+"))^2 + (("+s+")-("+r+"))^2 - ("+o+")"]},generateRadiusSquared:function(){var t,e,r,i,s,o,n="";return"twoPoints"===this.method?(t=this.center.symbolic.x,e=this.center.symbolic.y,r=this.point2.symbolic.x,i=this.point2.symbolic.y,n="(("+r+")-("+t+"))^2 + (("+i+")-("+e+"))^2"):"pointRadius"===this.method?"number"==typeof this.radius&&(n=""+this.radius*this.radius):"pointLine"===this.method?(r=this.line.point1.symbolic.x,i=this.line.point1.symbolic.y,s=this.line.point2.symbolic.x,o=this.line.point2.symbolic.y,n="(("+r+")-("+s+"))^2 + (("+i+")-("+o+"))^2"):"pointCircle"===this.method&&(n=this.circle.Radius()),n},update:function(){return this.needsUpdate&&(this.visProp.trace&&this.cloneToBackground(!0),"pointLine"===this.method?this.radius=this.line.point1.coords.distance(i.COORDS_BY_USER,this.line.point2.coords):"pointCircle"===this.method?this.radius=this.circle.Radius():"pointRadius"===this.method&&(this.radius=this.updateRadius()),this.updateStdform(),this.updateQuadraticform()),this},updateQuadraticform:function(){var t=this.center,e=t.X(),r=t.Y(),i=this.Radius();this.quadraticform=[[e*e+r*r-i*i,-e,-r],[-e,1,0],[-r,0,1]]},updateStdform:function(){this.stdform[3]=.5,this.stdform[4]=this.Radius(),this.stdform[1]=-this.center.coords.usrCoords[1],this.stdform[2]=-this.center.coords.usrCoords[2],this.normalize()},updateRenderer:function(){var t;this.needsUpdate&&this.visProp.visible&&(t=this.isReal,this.isReal=!isNaN(this.center.coords.usrCoords[1]+this.center.coords.usrCoords[2]+this.Radius())&&this.center.isReal,this.isReal?(t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.show(this.label.content)),this.board.renderer.updateEllipse(this)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.hide(this.label.content)),this.needsUpdate=!1),this.hasLabel&&this.label.content.visProp.visible&&this.isReal&&(this.label.content.update(),this.board.renderer.updateText(this.label.content))},notifyParents:function(t){"string"==typeof t&&s.findDependencies(this,t,this.board)},setRadius:function(t){return this.updateRadius=a.createFunction(t,this.board,null,!0),this.board.update(),this},Radius:function(t){return a.exists(t)?(this.setRadius(t),this.Radius()):"twoPoints"===this.method?0===o.distance(this.point2.coords.usrCoords,[0,0,0])||0===o.distance(this.center.coords.usrCoords,[0,0,0])?0/0:this.center.Dist(this.point2):"pointLine"===this.method||"pointCircle"===this.method?this.radius:"pointRadius"===this.method?this.updateRadius():0/0},getRadius:function(){return this.Radius()},getTextAnchor:function(){return this.center.coords},getLabelAnchor:function(){var t,e,s=this.Radius(),o=this.center.coords.usrCoords;switch(this.visProp.label.position){case"lft":t=o[1]-s,e=o[2];break;case"llft":t=o[1]-Math.sqrt(.5)*s,e=o[2]-Math.sqrt(.5)*s;break;case"rt":t=o[1]+s,e=o[2];break;case"lrt":t=o[1]+Math.sqrt(.5)*s,e=o[2]-Math.sqrt(.5)*s;break;case"urt":t=o[1]+Math.sqrt(.5)*s,e=o[2]+Math.sqrt(.5)*s;break;case"top":t=o[1],e=o[2]+s;break;case"bot":t=o[1],e=o[2]-s;break;default:t=o[1]-Math.sqrt(.5)*s,e=o[2]+Math.sqrt(.5)*s}return new r(i.COORDS_BY_USER,[t,e],this.board)},cloneToBackground:function(){var t,e=this.Radius(),r={id:this.id+"T"+this.numTraces,elementClass:i.OBJECT_CLASS_CIRCLE,center:{coords:this.center.coords},Radius:function(){return e},getRadius:function(){return e},board:this.board,visProp:a.deepCopy(this.visProp,this.visProp.traceattributes,!0)};return r.visProp.layer=this.board.options.layer.trace,this.numTraces++,a.clearVisPropOld.call(r),t=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawEllipse(r),this.board.renderer.enhancedRendering=t,this.traces[r.id]=r.rendNode,this},addTransform:function(t){var e,r=a.isArray(t)?t:[t],i=r.length;for(e=0;i>e;e++)this.center.transformations.push(r[e]),"twoPoints"===this.method&&this.point2.transformations.push(r[e]);return this},snapToGrid:function(){return this.visProp.snaptogrid&&(this.center.snapToGrid(),"twoPoints"===this.method&&this.point2.snapToGrid()),this},setPosition:function(t,e){var i;return e=new r(t,e,this.board),i=this.board.create("transform",e.usrCoords.slice(1),{type:"translate"}),this.addTransform(i),this},setPositionDirectly:function(t,e,s){var o,a,h,c=this.parents.length;for(e=new r(t,e,this.board),s=new r(t,s,this.board),h=n.subtract(e.usrCoords,s.usrCoords),o=0;c>o;o++)if(!this.board.select(this.parents[o]).draggable())return this;for(o=0;c>o;o++)a=this.board.select(this.parents[o]),a.coords.setCoordinates(i.COORDS_BY_USER,n.add(a.coords.usrCoords,h));return this.update(),this},X:function(t){return this.Radius()*Math.cos(2*t*Math.PI)+this.center.coords.usrCoords[1]},Y:function(t){return this.Radius()*Math.sin(2*t*Math.PI)+this.center.coords.usrCoords[2]},Z:function(){return 1},minX:function(){return 0},maxX:function(){return 1},Area:function(){var t=this.Radius();return t*t*Math.PI},bounds:function(){var t=this.center.coords.usrCoords,e=this.Radius();return[t[1]-e,t[2]+e,t[1]+e,t[2]-e]}}),t.createCircle=function(e,r,s){var o,n,h,c,l=!0;for(n=[],h=0;r.length>h;h++)a.isPoint(r[h])?n[h]=r[h]:a.isArray(r[h])&&r[h].length>1?(c=a.copyAttributes(s,e.options,"circle","center"),n[h]=e.create("point",r[h],c)):n[h]=r[h];if(c=a.copyAttributes(s,e.options,"circle"),2===r.length&&a.isPoint(n[0])&&a.isPoint(n[1]))o=new t.Circle(e,"twoPoints",n[0],n[1],c);else if((a.isNumber(n[0])||a.isFunction(n[0])||a.isString(n[0]))&&a.isPoint(n[1]))o=new t.Circle(e,"pointRadius",n[1],n[0],c);else if((a.isNumber(n[1])||a.isFunction(n[1])||a.isString(n[1]))&&a.isPoint(n[0]))o=new t.Circle(e,"pointRadius",n[0],n[1],c);else if(n[0].elementClass===i.OBJECT_CLASS_CIRCLE&&a.isPoint(n[1]))o=new t.Circle(e,"pointCircle",n[1],n[0],c);else if(n[1].elementClass===i.OBJECT_CLASS_CIRCLE&&a.isPoint(n[0]))o=new t.Circle(e,"pointCircle",n[0],n[1],c);else if(n[0].elementClass===i.OBJECT_CLASS_LINE&&a.isPoint(n[1]))o=new t.Circle(e,"pointLine",n[1],n[0],c);else if(n[1].elementClass===i.OBJECT_CLASS_LINE&&a.isPoint(n[0]))o=new t.Circle(e,"pointLine",n[0],n[1],c);else{if(!(3===r.length&&a.isPoint(n[0])&&a.isPoint(n[1])&&a.isPoint(n[2])))throw Error("JSXGraph: Can't create circle with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,point], [point,number], [point,function], [point,circle], [point,point,point]");if(!t.elements.circumcircle)throw Error("JSXGraph: Can't create circle with three points. Please include the circumcircle element (element/composition).");o=t.elements.circumcircle(e,n,c)}for(o.isDraggable=l,o.parents=[],h=0;r.length>h;h++)r[h].id&&o.parents.push(r[h].id);return o.elType="circle",o},t.registerElement("circle",t.createCircle),{Circle:t.Circle,createCircle:t.createCircle}}),define("base/composition",["jxg","utils/type"],function(t,e){return t.Composition=function(t){var r,i=this,s=["setAttribute","prepareUpdate","updateRenderer","update","highlight","noHighlight"],o=function(t){return function(){var r;for(r in i.elements)i.elements.hasOwnProperty(r)&&e.exists(i.elements[r][t])&&i.elements[r][t].apply(i.elements[r],arguments);return i}};for(r=0;s.length>r;r++)this[s[r]]=o(s[r]);this.elements={},this.methodMap={setAttribute:"setAttribute",setProperty:"setAttribute",add:"add",remove:"remove"};for(r in t)t.hasOwnProperty(r)&&this.add(r,t[r]);this.dump=!0,this.subs={}},t.extend(t.Composition.prototype,{add:function(t,r){return!e.exists(this[t])&&e.exists(r)?(e.exists(r.id)?this.elements[r.id]=r:this.elements[t]=r,this[t]=r,this.methodMap[t]=r,!0):!1},remove:function(t){var e,r=!1;for(e in this.elements)if(this.elements.hasOwnProperty(e)&&this.elements[e].id===this[t].id){r=!0;break}return r&&(delete this.elements[this[t].id],delete this[t]),r},getParents:function(){return this.parents},getType:function(){return this.elType},getAttributes:function(){var t,e={};for(t in this.subs)this.subs.hasOwnProperty(t)&&(e[t]=this.subs[t].visProp);return this.attr}}),t.Composition}),define("base/curve",["jxg","base/constants","base/coords","base/element","math/math","math/statistics","math/numerics","math/geometry","parser/geonext","utils/type","base/transformation"],function(t,e,r,i,s,o,n,a,h,c){return t.Curve=function(t,r,i){this.constructor(t,i,e.OBJECT_TYPE_CURVE,e.OBJECT_CLASS_CURVE),this.points=[],this.numberPoints=this.visProp.numberpointshigh,this.bezierDegree=1,this.dataX=null,this.dataY=null,this.varname=c.exists(r[0])?r[0]:"x",this.xterm=r[1],this.yterm=r[2],this.generateTerm(this.varname,this.xterm,this.yterm,r[3],r[4]),this.updateCurve(),this.id=this.board.setId(this,"G"),this.board.renderer.drawCurve(this),this.board.finalizeAdding(this),this.createGradient(),this.elType="curve",this.createLabel(),"string"==typeof this.xterm&&this.notifyParents(this.xterm),"string"==typeof this.yterm&&this.notifyParents(this.yterm),this.methodMap=c.deepCopy(this.methodMap,{generateTerm:"generateTerm",setTerm:"generateTerm"})},t.Curve.prototype=new i,t.extend(t.Curve.prototype,{minX:function(){var t;return"polar"===this.visProp.curvetype?0:(t=new r(e.COORDS_BY_SCREEN,[0,0],this.board),t.usrCoords[1])},maxX:function(){var t;return"polar"===this.visProp.curvetype?2*Math.PI:(t=new r(e.COORDS_BY_SCREEN,[this.board.canvasWidth,0],this.board),t.usrCoords[1])},Z:function(){return 1},hasPoint:function(t,i,o){var n,h,l,d,u,p,f,b,m,g=this.visProp.numberpointslow,v=(this.maxX()-this.minX())/g,C=this.board.options.precision.hasPoint/this.board.unitX,y=1/0,P=!0;if(h=new r(e.COORDS_BY_SCREEN,[t,i],this.board),t=h.usrCoords[1],i=h.usrCoords[2],this.transformations.length>0&&(this.updateTransformMatrix(),d=s.inverse(this.transformMat),u=s.matVecMult(d,[1,t,i]),t=u[1],i=u[2]),"parameter"===this.visProp.curvetype||"polar"===this.visProp.curvetype||"functiongraph"===this.visProp.curvetype)for(C*=C,p=0,n=this.minX();g>p;p++){if(f=this.X(n,P),b=this.Y(n,P),y=(t-f)*(t-f)+(i-b)*(i-b),C>y)return!0;n+=v}else if("plot"===this.visProp.curvetype){for((!c.exists(o)||0>o)&&(o=0),l=this.numberPoints,p=o;l-1>p;p++)if(m=3===this.bezierDegree?a.projectCoordsToBeziersegment([1,t,i],this,p):a.projectCoordsToSegment([1,t,i],[1,this.X(p),this.Y(p)],[1,this.X(p+1),this.Y(p+1)]),m[1]>=0&&1>=m[1]&&C>=a.distance([1,t,i],m[0],3))return!0;return!1}return C>y},allocatePoints:function(){var t,i;if(i=this.numberPoints,this.points.length<this.numberPoints)for(t=this.points.length;i>t;t++)this.points[t]=new r(e.COORDS_BY_USER,[0,0],this.board)},update:function(){return this.needsUpdate&&(this.visProp.trace&&this.cloneToBackground(!0),this.updateCurve()),this},updateRenderer:function(){var t;return this.needsUpdate&&this.visProp.visible&&(t=this.isReal,this.checkReal(),this.isReal?(t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.show(this.label.content)),this.board.renderer.updateCurve(this)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.content.visProp.visible&&this.board.renderer.hide(this.label.content)),this.hasLabel&&this.label.content.visProp.visible&&(this.label.content.update(),this.board.renderer.updateText(this.label.content))),this
},updateDataArray:function(){},updateCurve:function(){var t,r,i,s,o,n,a=!1;if(this.updateTransformMatrix(),this.updateDataArray(),r=this.minX(),i=this.maxX(),c.exists(this.dataX))for(this.numberPoints=this.dataX.length,t=this.numberPoints,this.allocatePoints(),n=0;t>n;n++)s=n,c.exists(this.dataY)?(o=n,this.points[n].setCoordinates(e.COORDS_BY_USER,[this.dataX[n],this.dataY[n]],!1)):(o=this.X(s),this.points[n].setCoordinates(e.COORDS_BY_USER,[this.dataX[n],this.Y(o,a)],!1)),this.updateTransform(this.points[n]),a=!0;else for(this.visProp.doadvancedplot?this.updateParametricCurve(r,i,t):(this.numberPoints=this.board.updateQuality===this.board.BOARD_QUALITY_HIGH?this.visProp.numberpointshigh:this.visProp.numberpointslow,this.allocatePoints(),this.updateParametricCurveNaive(r,i,this.numberPoints)),t=this.numberPoints,n=0;t>n;n++)this.updateTransform(this.points[n]);return this},updateTransformMatrix:function(){var t,e,r=this.transformations.length;for(this.transformMat=[[1,0,0],[0,1,0],[0,0,1]],e=0;r>e;e++)t=this.transformations[e],t.update(),this.transformMat=s.matMatMult(t.matrix,this.transformMat);return this},checkReal:function(){var t,e,r=!1,i=this.numberPoints;for(t=0;i>t;t++)if(e=this.points[t].usrCoords,!isNaN(e[1])&&!isNaN(e[2])&&Math.abs(e[0])>s.eps){r=!0;break}this.isReal=r},updateParametricCurveNaive:function(t,r,i){var s,o,n=!1,a=(r-t)/i;for(s=0;i>s;s++)o=t+s*a,this.points[s].setCoordinates(e.COORDS_BY_USER,[this.X(o,n),this.Y(o,n)],!1),n=!0;return this},updateParametricCurve:function(t,i){var o,n,a,h,c,l,d,u,p,f,b,m,g,v=!1,C=new r(e.COORDS_BY_USER,[0,0],this.board),y=[],P=[],_=[],E=[],S=!1,O=0,T=function(t,e,r){var i,o,n=r[1]-t[1],a=r[2]-t[2],h=e[0]-t[1],c=e[1]-t[2],l=h*h+c*c;return l>=s.eps&&(i=(n*h+a*c)/l,i>0&&(1>=i?(n-=i*h,a-=i*c):(n-=h,a-=c))),o=n*n+a*a,Math.sqrt(o)};for(this.board.updateQuality===this.board.BOARD_QUALITY_LOW?(b=15,m=10,g=10):(b=21,m=.7,g=.7),E[0]=i-t,o=1;b>o;o++)E[o]=.5*E[o-1];o=1,y[0]=1,P[0]=0,n=t,C.setCoordinates(e.COORDS_BY_USER,[this.X(n,v),this.Y(n,v)],!1),v=!0,d=C.scrCoords[1],u=C.scrCoords[2],a=n,n=i,C.setCoordinates(e.COORDS_BY_USER,[this.X(n,v),this.Y(n,v)],!1),c=C.scrCoords[1],l=C.scrCoords[2],_[0]=[c,l],p=1,f=0,this.points=[],this.points[O++]=new r(e.COORDS_BY_SCREEN,[d,u],this.board);do{for(S=this.isDistOK(c-d,l-u,m,g)||this.isSegmentOutside(d,u,c,l);b>f&&(!S||6>f)&&(7>=f||this.isSegmentDefined(d,u,c,l));)y[p]=o,P[p]=f,_[p]=[c,l],p+=1,o=2*o-1,f++,n=t+o*E[f],C.setCoordinates(e.COORDS_BY_USER,[this.X(n,v),this.Y(n,v)],!1),c=C.scrCoords[1],l=C.scrCoords[2],S=this.isDistOK(c-d,l-u,m,g)||this.isSegmentOutside(d,u,c,l);O>1&&(h=T(this.points[O-2].scrCoords,[c,l],this.points[O-1].scrCoords),.015>h&&(O-=1)),this.points[O]=new r(e.COORDS_BY_SCREEN,[c,l],this.board),O+=1,d=c,u=l,a=n,p-=1,c=_[p][0],l=_[p][1],f=P[p]+1,o=2*y[p]}while(p>0&&5e5>O);return this.numberPoints=this.points.length,this},isSegmentOutside:function(t,e,r,i){return 0>e&&0>i||e>this.board.canvasHeight&&i>this.board.canvasHeight||0>t&&0>r||t>this.board.canvasWidth&&r>this.board.canvasWidth},isDistOK:function(t,e,r,i){return r>Math.abs(t)&&i>Math.abs(e)&&!isNaN(t+e)},isSegmentDefined:function(t,e,r,i){return!(isNaN(t+e)&&isNaN(r+i))},updateTransform:function(t){var r,i=this.transformations.length;return i>0&&(r=s.matVecMult(this.transformMat,t.usrCoords),t.setPosition(e.COORDS_BY_USER,[r[1],r[2]])),t},addTransform:function(t){var e,r=c.isArray(t)?t:[t],i=r.length;for(e=0;i>e;e++)this.transformations.push(r[e]);return this},setPosition:function(t,e){var i,s,o,n=0;for(c.exists(this.parents)&&(n=this.parents.length),o=0;n>o;o++)if(s=this.board.select(this.parents[o]),!s.draggable())return this;if(e=new r(t,e,this.board),i=this.board.create("transform",e.usrCoords.slice(1),{type:"translate"}),n>0)for(o=0;n>o;o++)s=this.board.select(this.parents[o]),i.applyOnce(s);else this.transformations.length>0&&this.transformations[this.transformations.length-1].isNumericMatrix?this.transformations[this.transformations.length-1].melt(i):this.addTransform(i);return this},setPositionDirectly:function(t,i,s){var n=new r(t,i,this.board),a=new r(t,s,this.board),h=o.subtract(n.usrCoords,a.usrCoords);return this.setPosition(e.COORDS_BY_USER,h),this},interpolationFunctionFromArray:function(t){var e="data"+t;return function(t){var r,i,s,o,n=this[e],a=n.length,h=[];if(isNaN(t))return 0/0;if(0>t)return c.isFunction(n[0])?n[0]():n[0];if(3===this.bezierDegree){if(a/=3,t>=a)return c.isFunction(n[n.length-1])?n[n.length-1]():n[n.length-1];for(r=3*Math.floor(t),s=t%1,o=1-s,i=0;4>i;i++)h[i]=c.isFunction(n[r+i])?n[r+i]():n[r+i];return o*o*(o*h[0]+3*s*h[1])+(3*o*h[2]+s*h[3])*s*s}if(r=t>a-2?a-2:parseInt(Math.floor(t),10),r===t)return c.isFunction(n[r])?n[r]():n[r];for(i=0;2>i;i++)h[i]=c.isFunction(n[r+i])?n[r+i]():n[r+i];return h[0]+(h[1]-h[0])*(t-r)}},generateTerm:function(t,e,r,i,s){var o,n;c.isArray(e)?(this.dataX=e,this.numberPoints=this.dataX.length,this.X=this.interpolationFunctionFromArray("X"),this.visProp.curvetype="plot",this.isDraggable=!0):(this.X=c.createFunction(e,this.board,t),c.isString(e)?this.visProp.curvetype="functiongraph":(c.isFunction(e)||c.isNumber(e))&&(this.visProp.curvetype="parameter"),this.isDraggable=!0),c.isArray(r)?(this.dataY=r,this.Y=this.interpolationFunctionFromArray("Y")):this.Y=c.createFunction(r,this.board,t),c.isFunction(e)&&c.isArray(r)&&(o=c.createFunction(r[0],this.board,""),n=c.createFunction(r[1],this.board,""),this.X=function(t){return e(t)*Math.cos(t)+o()},this.Y=function(t){return e(t)*Math.sin(t)+n()},this.visProp.curvetype="polar"),c.exists(i)&&(this.minX=c.createFunction(i,this.board,"")),c.exists(s)&&(this.maxX=c.createFunction(s,this.board,""))},notifyParents:function(t){h.findDependencies(this,t,this.board)},getLabelAnchor:function(){var t,i,s,o=.05*this.board.canvasWidth,n=.05*this.board.canvasHeight,h=.95*this.board.canvasWidth,c=.95*this.board.canvasHeight;switch(this.visProp.label.position){case"ulft":i=o,s=n;break;case"llft":i=o,s=c;break;case"rt":i=h,s=.5*c;break;case"lrt":i=h,s=c;break;case"urt":i=h,s=n;break;case"top":i=.5*h,s=n;break;case"bot":i=.5*h,s=c;break;default:i=o,s=.5*c}return t=new r(e.COORDS_BY_SCREEN,[i,s],this.board),a.projectCoordsToCurve(t.usrCoords[1],t.usrCoords[2],0,this,this.board)[0]},cloneToBackground:function(){var t,r={id:this.id+"T"+this.numTraces,elementClass:e.OBJECT_CLASS_CURVE,points:this.points.slice(0),bezierDegree:this.bezierDegree,numberPoints:this.numberPoints,board:this.board,visProp:c.deepCopy(this.visProp,this.visProp.traceattributes,!0)};return r.visProp.layer=this.board.options.layer.trace,r.visProp.curvetype=this.visProp.curvetype,this.numTraces++,c.clearVisPropOld(r),t=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawCurve(r),this.board.renderer.enhancedRendering=t,this.traces[r.id]=r.rendNode,this},bounds:function(){var t,e=1/0,r=-1/0,i=1/0,s=-1/0,o=this.points.length;for(t=0;o>t;t++)e>this.points[t].usrCoords[1]&&(e=this.points[t].usrCoords[1]),this.points[t].usrCoords[1]>r&&(r=this.points[t].usrCoords[1]),i>this.points[t].usrCoords[2]&&(i=this.points[t].usrCoords[2]),this.points[t].usrCoords[2]>s&&(s=this.points[t].usrCoords[2]);return[e,s,r,i]}}),t.createCurve=function(e,r,i){var s=c.copyAttributes(i,e.options,"curve");return new t.Curve(e,["x"].concat(r),s)},t.registerElement("curve",t.createCurve),t.createFunctiongraph=function(e,r,i){var s,o=["x","x"].concat(r);return s=c.copyAttributes(i,e.options,"curve"),s.curvetype="functiongraph",new t.Curve(e,o,s)},t.registerElement("functiongraph",t.createFunctiongraph),t.registerElement("plot",t.createFunctiongraph),t.createSpline=function(t,e,r){var i;return i=function(){var t,r=[],i=[];return function(s,o){var a;if(!o){if(r=[],i=[],2===e.length&&c.isArray(e[0])&&c.isArray(e[1])&&e[0].length===e[1].length)for(a=0;e[0].length>a;a++)"function"==typeof e[0][a]?r.push(e[0][a]()):r.push(e[0][a]),"function"==typeof e[1][a]?i.push(e[1][a]()):i.push(e[1][a]);else for(a=0;e.length>a;a++)if(c.isPoint(e[a]))r.push(e[a].X()),i.push(e[a].Y());else if(c.isArray(e[a])&&2===e[a].length)for(a=0;e.length>a;a++)"function"==typeof e[a][0]?r.push(e[a][0]()):r.push(e[a][0]),"function"==typeof e[a][1]?i.push(e[a][1]()):i.push(e[a][1]);t=n.splineDef(r,i)}return n.splineEval(s,r,i,t)}},t.create("curve",["x",i()],r)},t.registerElement("spline",t.createSpline),t.createRiemannsum=function(t,e,r){var i,s,o,a,h,l;if(l=c.copyAttributes(r,t.options,"riemannsum"),l.curvetype="plot",o=e[0],i=c.createFunction(e[1],t,""),!c.exists(i))throw Error("JSXGraph: JXG.createRiemannsum: argument '2' n has to be number or function.\nPossible parent types: [function,n:number|function,type,start:number|function,end:number|function]");if(s=c.createFunction(e[2],t,"",!1),!c.exists(s))throw Error("JSXGraph: JXG.createRiemannsum: argument 3 'type' has to be string or function.\nPossible parent types: [function,n:number|function,type,start:number|function,end:number|function]");return a=[[0],[0]].concat(e.slice(3)),h=t.create("curve",a,l),h.sum=0,h.Value=function(){return this.sum},h.updateDataArray=function(){var t=n.riemann(o,i(),s(),this.minX(),this.maxX());this.dataX=t[0],this.dataY=t[1],this.sum=t[2]},h},t.registerElement("riemannsum",t.createRiemannsum),t.createTracecurve=function(t,r,i){var s,o,n,a;if(2!==r.length)throw Error("JSXGraph: Can't create trace curve with given parent'\nPossible parent types: [glider, point]");if(o=t.select(r[0]),n=t.select(r[1]),o.type!==e.OBJECT_TYPE_GLIDER||!c.isPoint(n))throw Error("JSXGraph: Can't create trace curve with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [glider, point]");return a=c.copyAttributes(i,t.options,"tracecurve"),a.curvetype="plot",s=t.create("curve",[[0],[0]],a),s.updateDataArray=function(){var t,r,i,s,h,c,l,d,u,p=a.numberpoints,f=o.position,b=o.slideObject,m=b.minX(),g=b.maxX();for(r=(g-m)/p,this.dataX=[],this.dataY=[],b.elementClass!==e.OBJECT_CLASS_CURVE&&p++,t=0;p>t;t++){i=m+t*r,c=b.X(i)/b.Z(i),l=b.Y(i)/b.Z(i),o.setPositionDirectly(e.COORDS_BY_USER,[c,l]),d=!1;for(s in this.board.objects)if(this.board.objects.hasOwnProperty(s)&&(h=this.board.objects[s],h===o&&(d=!0),d&&h.needsRegularUpdate&&(u=h.visProp.trace,h.visProp.trace=!1,h.needsUpdate=!0,h.update(!0),h.visProp.trace=u,h===n)))break;this.dataX[t]=n.X(),this.dataY[t]=n.Y()}o.position=f,d=!1;for(s in this.board.objects)if(this.board.objects.hasOwnProperty(s)&&(h=this.board.objects[s],h===o&&(d=!0),d&&h.needsRegularUpdate&&(u=h.visProp.trace,h.visProp.trace=!1,h.needsUpdate=!0,h.update(!0),h.visProp.trace=u,h===n)))break},s},t.registerElement("tracecurve",t.createTracecurve),{Curve:t.Curve,createCurve:t.createCurve,createFunctiongraph:t.createFunctiongraph,createPlot:t.createPlot,createSpline:t.createSpline,createRiemannsum:t.createRiemannsum,createTracecurve:t.createTracecurve}}),define("element/composition",["jxg","math/math","math/geometry","math/numerics","math/statistics","base/coords","utils/type","base/constants","base/point","base/line","base/circle","base/transformation","base/composition","base/curve","base/text"],function(t,e,r,i,s,o,n,a,h,c,l,d,u){return t.createOrthogonalProjection=function(t,e,i){var s,o,h,c;if(n.isPoint(e[0])&&e[1].elementClass===a.OBJECT_CLASS_LINE)o=e[0],s=e[1];else{if(!n.isPoint(e[1])||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create perpendicular point with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [point,line]");o=e[1],s=e[0]}return c=n.copyAttributes(i,t.options,"orthogonalprojection"),h=t.create("point",[function(){return r.projectPointToLine(o,s,t)}],c),o.addChild(h),s.addChild(h),h.elType="orthogonalprojection",h.parents=[o.id,h.id],h.update(),h.generatePolynomial=function(){var t=s.point1.symbolic.x,e=s.point1.symbolic.y,r=s.point2.symbolic.x,i=s.point2.symbolic.y,n=o.symbolic.x,a=o.symbolic.y,c=h.symbolic.x,l=h.symbolic.y,d="("+e+")*("+c+")-("+e+")*("+r+")+("+l+")*("+r+")-("+t+")*("+l+")+("+t+")*("+i+")-("+c+")*("+i+")",u="("+a+")*("+e+")-("+a+")*("+i+")-("+l+")*("+e+")+("+l+")*("+i+")+("+n+")*("+t+")-("+n+")*("+r+")-("+c+")*("+t+")+("+c+")*("+r+")";return[d,u]},h},t.createPerpendicular=function(t,e,r){var i,s,o,h;if(e[0]=t.select(e[0]),e[1]=t.select(e[1]),n.isPoint(e[0])&&e[1].elementClass===a.OBJECT_CLASS_LINE)s=e[1],i=e[0];else{if(!n.isPoint(e[1])||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create perpendicular with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [line,point]");s=e[0],i=e[1]}return h=n.copyAttributes(r,t.options,"perpendicular"),o=c.createLine(t,[function(){return s.stdform[2]*i.X()-s.stdform[1]*i.Y()},function(){return-s.stdform[2]*i.Z()},function(){return s.stdform[1]*i.Z()}],h),o.elType="perpendicular",o.parents=[s.id,i.id],o},t.createPerpendicularPoint=function(t,e,i){var s,o,h;if(n.isPoint(e[0])&&e[1].elementClass===a.OBJECT_CLASS_LINE)o=e[0],s=e[1];else{if(!n.isPoint(e[1])||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create perpendicular point with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [point,line]");o=e[1],s=e[0]}return h=t.create("point",[function(){return r.perpendicular(s,o,t)[0]}],i),o.addChild(h),s.addChild(h),h.elType="perpendicularpoint",h.parents=[o.id,s.id],h.update(),h.generatePolynomial=function(){var t=s.point1.symbolic.x,e=s.point1.symbolic.y,r=s.point2.symbolic.x,i=s.point2.symbolic.y,n=o.symbolic.x,a=o.symbolic.y,c=h.symbolic.x,l=h.symbolic.y,d="("+e+")*("+c+")-("+e+")*("+r+")+("+l+")*("+r+")-("+t+")*("+l+")+("+t+")*("+i+")-("+c+")*("+i+")",u="("+a+")*("+e+")-("+a+")*("+i+")-("+l+")*("+e+")+("+l+")*("+i+")+("+n+")*("+t+")-("+n+")*("+r+")-("+c+")*("+t+")+("+c+")*("+r+")";return[d,u]},h},t.createPerpendicularSegment=function(e,i,s){var o,h,l,d,u;if(i[0]=e.select(i[0]),i[1]=e.select(i[1]),n.isPoint(i[0])&&i[1].elementClass===a.OBJECT_CLASS_LINE)h=i[1],o=i[0];else{if(!n.isPoint(i[1])||i[0].elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create perpendicular with parent types '"+typeof i[0]+"' and '"+typeof i[1]+"'."+"\nPossible parent types: [line,point]");h=i[0],o=i[1]}return u=n.copyAttributes(s,e.options,"perpendicularsegment","point"),d=t.createPerpendicularPoint(e,[h,o],u),d.dump=!1,n.exists(s.layer)||(s.layer=e.options.layer.line),u=n.copyAttributes(s,e.options,"perpendicularsegment"),l=c.createLine(e,[function(){return r.perpendicular(h,o,e)[1]?[d,o]:[o,d]}],u),l.point=d,l.elType="perpendicularsegment",l.parents=[o.id,h.id],l.subs={point:d},l},t.createMidpoint=function(t,r,i){var s,o,h;if(2===r.length&&n.isPoint(r[0])&&n.isPoint(r[1]))s=r[0],o=r[1];else{if(1!==r.length||r[0].elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create midpoint.\nPossible parent types: [point,point], [line]");s=r[0].point1,o=r[0].point2}return h=t.create("point",[function(){var t=s.coords.usrCoords[1]+o.coords.usrCoords[1];return isNaN(t)||Math.abs(s.coords.usrCoords[0])<e.eps||Math.abs(o.coords.usrCoords[0])<e.eps?0/0:.5*t},function(){var t=s.coords.usrCoords[2]+o.coords.usrCoords[2];return isNaN(t)||Math.abs(s.coords.usrCoords[0])<e.eps||Math.abs(o.coords.usrCoords[0])<e.eps?0/0:.5*t}],i),s.addChild(h),o.addChild(h),h.elType="midpoint",h.parents=[s.id,o.id],h.prepareUpdate().update(),h.generatePolynomial=function(){var t=s.symbolic.x,e=s.symbolic.y,r=o.symbolic.x,i=o.symbolic.y,n=h.symbolic.x,a=h.symbolic.y,c="("+e+")*("+n+")-("+e+")*("+r+")+("+a+")*("+r+")-("+t+")*("+a+")+("+t+")*("+i+")-("+n+")*("+i+")",l="("+t+")^2 - 2*("+t+")*("+n+")+("+e+")^2-2*("+e+")*("+a+")-("+r+")^2+2*("+r+")*("+n+")-("+i+")^2+2*("+i+")*("+a+")";return[c,l]},h},t.createParallelPoint=function(t,e,r){var i,s,o,n;if(3===e.length&&e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_POINT&&e[2].elementClass===a.OBJECT_CLASS_POINT)i=e[0],s=e[1],o=e[2];else if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_LINE)o=e[0],i=e[1].point1,s=e[1].point2;else{if(e[1].elementClass!==a.OBJECT_CLASS_POINT||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create parallel point with parent types '"+typeof e[0]+"', '"+typeof e[1]+"' and '"+typeof e[2]+"'."+"\nPossible parent types: [line,point], [point,point,point]");o=e[1],i=e[0].point1,s=e[0].point2}return n=t.create("point",[function(){return o.coords.usrCoords[1]+s.coords.usrCoords[1]-i.coords.usrCoords[1]},function(){return o.coords.usrCoords[2]+s.coords.usrCoords[2]-i.coords.usrCoords[2]}],r),i.addChild(n),s.addChild(n),o.addChild(n),n.elType="parallelpoint",n.parents=[i.id,s.id,o.id],n.prepareUpdate().update(),n.generatePolynomial=function(){var t=i.symbolic.x,e=i.symbolic.y,r=s.symbolic.x,a=s.symbolic.y,h=o.symbolic.x,c=o.symbolic.y,l=n.symbolic.x,d=n.symbolic.y,u="("+a+")*("+l+")-("+a+")*("+h+")-("+e+")*("+l+")+("+e+")*("+h+")-("+d+")*("+r+")+("+d+")*("+t+")+("+c+")*("+r+")-("+c+")*("+t+")",p="("+d+")*("+t+")-("+d+")*("+h+")-("+a+")*("+t+")+("+a+")*("+h+")-("+l+")*("+e+")+("+l+")*("+c+")+("+r+")*("+e+")-("+r+")*("+c+")";return[u,p]},n},t.createParallel=function(t,r,i){var s,o,h,c,l;return s=null,3===r.length?(s=r[2],c=function(){return e.crossProduct(r[0].coords.usrCoords,r[1].coords.usrCoords)}):r[0].elementClass===a.OBJECT_CLASS_POINT?(s=r[0],c=function(){return r[1].stdform}):r[1].elementClass===a.OBJECT_CLASS_POINT&&(s=r[1],c=function(){return r[0].stdform}),n.exists(i.layer)||(i.layer=t.options.layer.line),l=n.copyAttributes(i,t.options,"parallel","point"),o=t.create("point",[function(){return e.crossProduct([1,0,0],c())}],l),o.isDraggable=!0,l=n.copyAttributes(i,t.options,"parallel"),h=t.create("line",[s,o],l),h.elType="parallel",h.parents=[r[0].id,r[1].id],3===r.length&&h.parents.push(r[2].id),h.point=o,h},t.createArrowParallel=function(e,r,i){var s;try{return i.firstArrow=!1,i.lastArrow=!0,s=t.createParallel(e,r,i).setAttribute({straightFirst:!1,straightLast:!1}),s.elType="arrowparallel",s}catch(o){throw Error("JSXGraph: Can't create arrowparallel with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [line,point], [point,point,point]")}},t.createNormal=function(t,r,s){var o,h,c,l,d,u,p,f,b;if(1===r.length)o=r[0],h=o.slideObject;else{if(2!==r.length)throw Error("JSXGraph: Can't create normal with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,line], [point,circle], [glider]");if(n.isPoint(r[0]))o=r[0],h=r[1];else{if(!n.isPoint(r[1]))throw Error("JSXGraph: Can't create normal with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,line], [point,circle], [glider]");h=r[0],o=r[1]}}if(p=n.copyAttributes(s,t.options,"normal"),h.elementClass===a.OBJECT_CLASS_LINE)b=n.copyAttributes(s,t.options,"normal","point"),f=t.create("point",[function(){var t=e.crossProduct([1,0,0],h.stdform);return[t[0],-t[2],t[1]]}],b),f.isDraggable=!0,c=t.create("line",[o,f],p),c.point=f;else if(h.elementClass===a.OBJECT_CLASS_CIRCLE)c=t.create("line",[h.midpoint,o],p);else if(h.elementClass===a.OBJECT_CLASS_CURVE)"plot"!==h.visProp.curvetype?(d=h.X,u=h.Y,c=t.create("line",[function(){return-o.X()*i.D(d)(o.position)-o.Y()*i.D(u)(o.position)},function(){return i.D(d)(o.position)},function(){return i.D(u)(o.position)}],p)):c=t.create("line",[function(){var t=Math.floor(o.position),e=o.position-t;return t===h.numberPoints-1&&(t-=1,e=1),0>t?1:(h.Y(t)+e*(h.Y(t+1)-h.Y(t)))*(h.Y(t)-h.Y(t+1))-(h.X(t)+e*(h.X(t+1)-h.X(t)))*(h.X(t+1)-h.X(t))},function(){var t=Math.floor(o.position);return t===h.numberPoints-1&&(t-=1),0>t?0:h.X(t+1)-h.X(t)},function(){var t=Math.floor(o.position);return t===h.numberPoints-1&&(t-=1),0>t?0:h.Y(t+1)-h.Y(t)}],p);else{if(h.type!==a.OBJECT_TYPE_TURTLE)throw Error("JSXGraph: Can't create normal with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,line], [point,circle], [glider]");c=t.create("line",[function(){var t,e,r=Math.floor(o.position),i=o.position-r;for(e=0;h.objects.length>e;e++)if(t=h.objects[e],t.type===a.OBJECT_TYPE_CURVE){if(t.numberPoints>r)break;r-=t.numberPoints}return r===t.numberPoints-1&&(r-=1,i=1),0>r?1:(t.Y(r)+i*(t.Y(r+1)-t.Y(r)))*(t.Y(r)-t.Y(r+1))-(t.X(r)+i*(t.X(r+1)-t.X(r)))*(t.X(r+1)-t.X(r))},function(){var t,e,r=Math.floor(o.position);for(e=0;h.objects.length>e;e++)if(t=h.objects[e],t.type===a.OBJECT_TYPE_CURVE){if(t.numberPoints>r)break;r-=t.numberPoints}return r===t.numberPoints-1&&(r-=1),0>r?0:t.X(r+1)-t.X(r)},function(){var t,e,r=Math.floor(o.position);for(e=0;h.objects.length>e;e++)if(t=h.objects[e],t.type===a.OBJECT_TYPE_CURVE){if(t.numberPoints>r)break;r-=t.numberPoints}return r===t.numberPoints-1&&(r-=1),0>r?0:t.Y(r+1)-t.Y(r)}],p)}for(c.parents=[],l=0;r.length>l;l++)c.parents.push(r[l].id);return c.elType="normal",c},t.createBisector=function(t,e,i){var s,o,h,l;if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_POINT&&e[2].elementClass===a.OBJECT_CLASS_POINT){for(l=n.copyAttributes(i,t.options,"bisector","point"),s=t.create("point",[function(){return r.angleBisector(e[0],e[1],e[2],t)}],l),s.dump=!1,h=0;3>h;h++)e[h].addChild(s);return n.exists(i.layer)||(i.layer=t.options.layer.line),l=n.copyAttributes(i,t.options,"bisector"),o=c.createLine(t,[e[1],s],l),o.point=s,o.elType="bisector",o.parents=[e[0].id,e[1].id,e[2].id],o.subs={point:s},o}throw Error("JSXGraph: Can't create angle bisector with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [point,point,point]")},t.createAngularBisectorsOfTwoLines=function(t,e,r){var i,s,o,h,c=t.select(e[0]),l=t.select(e[1]);if(c.elementClass!==a.OBJECT_CLASS_LINE||l.elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create angle bisectors of two lines with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [line,line]");return n.exists(r.layer)||(r.layer=t.options.layer.line),o=n.copyAttributes(r,t.options,"bisectorlines","line1"),i=t.create("line",[function(){var t=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]),e=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]);return c.stdform[0]/t-l.stdform[0]/e},function(){var t=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]),e=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]);return c.stdform[1]/t-l.stdform[1]/e},function(){var t=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]),e=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]);return c.stdform[2]/t-l.stdform[2]/e}],o),n.exists(r.layer)||(r.layer=t.options.layer.line),o=n.copyAttributes(r,t.options,"bisectorlines","line2"),s=t.create("line",[function(){var t=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]),e=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]);return c.stdform[0]/t+l.stdform[0]/e},function(){var t=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]),e=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]);return c.stdform[1]/t+l.stdform[1]/e},function(){var t=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]),e=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]);return c.stdform[2]/t+l.stdform[2]/e}],o),h=new u({line1:i,line2:s}),i.dump=!1,s.dump=!1,h.elType="bisectorlines",h.parents=[c.id,l.id],h.subs={line1:i,line2:s},h},t.createCircumcenter=function(t,e,i){var s,o,n,c,l;if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_POINT&&e[2].elementClass===a.OBJECT_CLASS_POINT){for(n=e[0],c=e[1],l=e[2],s=h.createPoint(t,[function(){return r.circumcenterMidpoint(n,c,l,t)}],i),o=0;3>o;o++)e[o].addChild(s);return s.elType="circumcenter",s.parents=[n.id,c.id,l.id],s.generatePolynomial=function(){var t=n.symbolic.x,e=n.symbolic.y,r=c.symbolic.x,i=c.symbolic.y,o=l.symbolic.x,a=l.symbolic.y,h=s.symbolic.x,d=s.symbolic.y,u=["((",h,")-(",t,"))^2+((",d,")-(",e,"))^2-((",h,")-(",r,"))^2-((",d,")-(",i,"))^2"].join(""),p=["((",h,")-(",t,"))^2+((",d,")-(",e,"))^2-((",h,")-(",o,"))^2-((",d,")-(",a,"))^2"].join("");return[u,p]},s}throw Error("JSXGraph: Can't create circumcircle midpoint with parent types '"+typeof e[0]+"', '"+typeof e[1]+"' and '"+typeof e[2]+"'."+"\nPossible parent types: [point,point,point]")},t.createIncenter=function(t,e,r){var i,s,h,c;if(!(e.length>=3&&n.isPoint(e[0])&&n.isPoint(e[1])&&n.isPoint(e[2])))throw Error("JSXGraph: Can't create incenter with parent types '"+typeof e[0]+"', '"+typeof e[1]+"' and '"+typeof e[2]+"'."+"\nPossible parent types: [point,point,point]");return s=e[0],h=e[1],c=e[2],i=t.create("point",[function(){var e,r,i;return e=Math.sqrt((h.X()-c.X())*(h.X()-c.X())+(h.Y()-c.Y())*(h.Y()-c.Y())),r=Math.sqrt((s.X()-c.X())*(s.X()-c.X())+(s.Y()-c.Y())*(s.Y()-c.Y())),i=Math.sqrt((h.X()-s.X())*(h.X()-s.X())+(h.Y()-s.Y())*(h.Y()-s.Y())),new o(a.COORDS_BY_USER,[(e*s.X()+r*h.X()+i*c.X())/(e+r+i),(e*s.Y()+r*h.Y()+i*c.Y())/(e+r+i)],t)}],r),i.elType="incenter",i.parents=[e[0].id,e[1].id,e[2].id],i},t.createCircumcircle=function(e,r,i){var s,o,a;try{a=n.copyAttributes(i,e.options,"circumcircle","center"),s=t.createCircumcenter(e,r,a),s.dump=!1,n.exists(i.layer)||(i.layer=e.options.layer.circle),a=n.copyAttributes(i,e.options,"circumcircle"),o=l.createCircle(e,[s,r[0]],a),o.elType="circumcircle",o.parents=[r[0].id,r[1].id,r[2].id],o.subs={center:s}}catch(h){throw Error("JSXGraph: Can't create circumcircle with parent types '"+typeof r[0]+"', '"+typeof r[1]+"' and '"+typeof r[2]+"'."+"\nPossible parent types: [point,point,point]")}return o},t.createIncircle=function(e,r,i){var s,o,a;try{a=n.copyAttributes(i,e.options,"incircle","center"),s=t.createIncenter(e,r,a),s.dump=!1,n.exists(i.layer)||(i.layer=e.options.layer.circle),a=n.copyAttributes(i,e.options,"incircle"),o=l.createCircle(e,[s,function(){var t=Math.sqrt((r[1].X()-r[2].X())*(r[1].X()-r[2].X())+(r[1].Y()-r[2].Y())*(r[1].Y()-r[2].Y())),e=Math.sqrt((r[0].X()-r[2].X())*(r[0].X()-r[2].X())+(r[0].Y()-r[2].Y())*(r[0].Y()-r[2].Y())),i=Math.sqrt((r[1].X()-r[0].X())*(r[1].X()-r[0].X())+(r[1].Y()-r[0].Y())*(r[1].Y()-r[0].Y())),s=(t+e+i)/2;return Math.sqrt((s-t)*(s-e)*(s-i)/s)}],a),o.elType="incircle",o.parents=[r[0].id,r[1].id,r[2].id],o.center=s,o.subs={center:s}}catch(h){throw Error("JSXGraph: Can't create circumcircle with parent types '"+typeof r[0]+"', '"+typeof r[1]+"' and '"+typeof r[2]+"'."+"\nPossible parent types: [point,point,point]")}return o},t.createReflection=function(t,e,r){var i,s,o,n;if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_LINE)s=e[0],i=e[1];else{if(e[1].elementClass!==a.OBJECT_CLASS_POINT||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw Error("JSXGraph: Can't create reflection point with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [line,point]");s=e[1],i=e[0]}return n=d.createTransform(t,[i],{type:"reflect"}),o=h.createPoint(t,[s,n],r),s.addChild(o),i.addChild(o),o.elType="reflection",o.parents=[e[0].id,e[1].id],o.prepareUpdate().update(),o.generatePolynomial=function(){var t=i.point1.symbolic.x,e=i.point1.symbolic.y,r=i.point2.symbolic.x,n=i.point2.symbolic.y,a=s.symbolic.x,h=s.symbolic.y,c=o.symbolic.x,l=o.symbolic.y,d=["((",l,")-(",h,"))*((",e,")-(",n,"))+((",t,")-(",r,"))*((",c,")-(",a,"))"].join(""),u=["((",c,")-(",t,"))^2+((",l,")-(",e,"))^2-((",a,")-(",t,"))^2-((",h,")-(",e,"))^2"].join("");return[d,u]},o},t.createMirrorPoint=function(t,e,i){var s,o;if(!n.isPoint(e[0])||!n.isPoint(e[1]))throw Error("JSXGraph: Can't create mirror point with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [point,point]");for(s=h.createPoint(t,[function(){return r.rotation(e[0],e[1],Math.PI,t)}],i),o=0;2>o;o++)e[o].addChild(s);return s.elType="mirrorpoint",s.parents=[e[0].id,e[1].id],s.prepareUpdate().update(),s},t.createIntegral=function(e,r,s){var o,h,c,l,d,u,p,f,b,m,g,v,C,y,P;if(n.isArray(r[0])&&r[1].elementClass===a.OBJECT_CLASS_CURVE)o=r[0],h=r[1];else{if(!n.isArray(r[1])||r[0].elementClass!==a.OBJECT_CLASS_CURVE)throw Error("JSXGraph: Can't create integral with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [[number|function,number|function],curve]");o=r[1],h=r[0]}return l=o[0],d=o[1],n.isFunction(l)?(u=l,p=function(){return h.Y(u())},l=u()):(u=l,p=h.Y(l)),n.isFunction(l)?(f=d,b=function(){return h.Y(f())},d=f()):(f=d,b=h.Y(d)),c=n.copyAttributes(s,e.options,"integral","curveLeft"),m=e.create("glider",[u,p,h],c),n.isFunction(u)&&m.hideElement(),c=n.copyAttributes(s,e.options,"integral","baseLeft"),g=e.create("point",[function(){return m.X()},0],c),c=n.copyAttributes(s,e.options,"integral","curveRight"),v=e.create("glider",[f,b,h],c),n.isFunction(f)&&v.hideElement(),c=n.copyAttributes(s,e.options,"integral","baseRight"),C=e.create("point",[function(){return v.X()},0],c),c=n.copyAttributes(s,e.options,"integral"),c.withLabel!==!1&&(c=n.copyAttributes(s,e.options,"integral","label"),y=e.create("text",[function(){return v.X()+.2},function(){return v.Y()-.8},function(){var t=i.I([g.X(),C.X()],h.Y);return"&int; = "+t.toFixed(4)}],c),y.dump=!1,m.addChild(y),v.addChild(y)),c=n.copyAttributes(s,e.options,"integral"),P=e.create("curve",[[0],[0]],c),m.dump=!1,g.dump=!1,v.dump=!1,C.dump=!1,P.elType="integral",P.parents=[h.id,o],P.subs={curveLeft:m,baseLeft:g,curveRight:v,baseRight:C},c.withLabel&&(P.subs.label=y),P.Value=function(){return i.I([g.X(),C.X()],h.Y)},P.updateDataArray=function(){var t,e,r,i,s;for(g.X()<C.X()?(i=g.X(),s=C.X()):(i=C.X(),s=g.X()),t=[i,i],e=[0,h.Y(i)],r=0;h.numberPoints>r;r++)h.points[r].usrCoords[1]>=i&&s>=h.points[r].usrCoords[1]&&(t.push(h.points[r].usrCoords[1]),e.push(h.points[r].usrCoords[2]));t.push(s),e.push(h.Y(s)),t.push(s),e.push(0),t.push(i),e.push(0),this.dataX=t,this.dataY=e},m.addChild(P),v.addChild(P),P.baseLeft=g,P.baseRight=C,P.curveLeft=m,P.curveRight=v,P.methodMap=t.deepCopy(P.methodMap,{curveLeft:"curveLeft",baseLeft:"baseLeft",curveRight:"curveRight",baseRight:"baseRight",Value:"Value"}),P.label={content:y},P},t.createGrid=function(t,e,r){var i,s;return s=n.copyAttributes(r,t.options,"grid"),i=t.create("curve",[[null],[null]],s),i.elType="grid",i.parents=[],i.type=a.OBJECT_TYPE_GRID,i.updateDataArray=function(){var e,r,s,n=this.visProp.gridx,h=this.visProp.gridy,c=new o(a.COORDS_BY_SCREEN,[0,0],t),l=new o(a.COORDS_BY_SCREEN,[t.canvasWidth,t.canvasHeight],t);for(t.options.grid.hasGrid=!0,c.setCoordinates(a.COORDS_BY_USER,[Math.floor(c.usrCoords[1]/n)*n,Math.ceil(c.usrCoords[2]/h)*h]),l.setCoordinates(a.COORDS_BY_USER,[Math.ceil(l.usrCoords[1]/n)*n,Math.floor(l.usrCoords[2]/h)*h]),i.dataX=[],i.dataY=[],e=c.usrCoords[2],r=l.usrCoords[2],c.usrCoords[2]<l.usrCoords[2]&&(e=l.usrCoords[2],r=c.usrCoords[2]),s=e;s>r-h;s-=h)i.dataX.push(c.usrCoords[1],l.usrCoords[1],0/0),i.dataY.push(s,s,0/0);for(e=c.usrCoords[1],r=l.usrCoords[1],c.usrCoords[1]>l.usrCoords[1]&&(e=l.usrCoords[1],r=c.usrCoords[1]),s=e;r+n>s;s+=n)i.dataX.push(s,s,0/0),i.dataY.push(c.usrCoords[2],l.usrCoords[2],0/0)},i.hasPoint=function(){return!1},t.grids.push(i),i},t.createInequality=function(t,e,i){var o,h,c;if(c=n.copyAttributes(i,t.options,"inequality"),e[0].elementClass===a.OBJECT_CLASS_LINE)h=t.create("curve",[[],[]],c),h.hasPoint=function(){return!1},h.updateDataArray=function(){var i,o,n,h=t.getBoundingBox(),l=c.inverse?-1:1,d=1.5,u=d*Math.max(h[2]-h[0],h[1]-h[3]),p={coords:{usrCoords:[1,(h[0]+h[2])/2,c.inverse?h[1]:h[3]]}},f=e[0].stdform.slice(1),b=f;f[1]>0&&(f=s.multiply(f,-1),b=f),n=d*Math.max(r.perpendicular(e[0],p,t)[0].distance(a.COORDS_BY_USER,p.coords),u),n*=l,p={coords:{usrCoords:[1,(h[0]+h[2])/2,(h[1]+h[3])/2]}},p=r.perpendicular(e[0],p,t)[0].usrCoords,i=[1,p[1]+f[1]*u,p[2]-f[0]*u],o=[1,p[1]-b[1]*u,p[2]+b[0]*u],this.dataX=[i[1],i[1]+f[0]*n,o[1]+b[0]*n,o[1],i[1]],this.dataY=[i[2],i[2]+f[1]*n,o[2]+b[1]*n,o[2],i[2]]};else if(o=n.createFunction(e[0]),!n.exists(o))throw Error("JSXGraph: Can't create area with the given parents.\nPossible parent types: [line], [function]");
return h},t.registerElement("arrowparallel",t.createArrowParallel),t.registerElement("bisector",t.createBisector),t.registerElement("bisectorlines",t.createAngularBisectorsOfTwoLines),t.registerElement("circumcircle",t.createCircumcircle),t.registerElement("circumcirclemidpoint",t.createCircumcenter),t.registerElement("circumcenter",t.createCircumcenter),t.registerElement("incenter",t.createIncenter),t.registerElement("incircle",t.createIncircle),t.registerElement("integral",t.createIntegral),t.registerElement("midpoint",t.createMidpoint),t.registerElement("mirrorpoint",t.createMirrorPoint),t.registerElement("normal",t.createNormal),t.registerElement("orthogonalprojection",t.createOrthogonalProjection),t.registerElement("parallel",t.createParallel),t.registerElement("parallelpoint",t.createParallelPoint),t.registerElement("perpendicular",t.createPerpendicular),t.registerElement("perpendicularpoint",t.createPerpendicularPoint),t.registerElement("perpendicularsegment",t.createPerpendicularSegment),t.registerElement("reflection",t.createReflection),t.registerElement("grid",t.createGrid),t.registerElement("inequality",t.createInequality),{createArrowParallel:t.createArrowParallel,createBisector:t.createBisector,createAngularBisectorOfTwoLines:t.createAngularBisectorsOfTwoLines,createCircumcircle:t.createCircumcircle,createCircumcenter:t.createCircumcenter,createIncenter:t.createIncenter,createIncircle:t.createIncircle,createIntegral:t.createIntegral,createMidpoint:t.createMidpoint,createMirrorPoint:t.createMirrorPoint,createNormal:t.createNormal,createOrthogonalProjection:t.createOrthogonalProjection,createParallel:t.createParallel,createParallelPoint:t.createParallelPoint,createPerpendicular:t.createPerpendicular,createPerpendicularPoint:t.createPerpendicularPoint,createPerpendicularSegmen:t.createPerpendicularSegment,createReflection:t.createReflection,createGrid:t.createGrid,createInequality:t.createInequality}}),define("base/board",["jxg","base/constants","base/coords","options","math/numerics","math/math","math/geometry","math/complex","parser/jessiecode","parser/geonext","utils/color","utils/type","utils/event","utils/env","base/transformation","base/point","base/line","base/text","element/composition"],function(t,e,r,i,s,o,n,a,h,c,l,d,u,p){return t.Board=function(t,r,s,o,n,a,c,l,f,b,m){if(this.BOARD_MODE_NONE=0,this.BOARD_MODE_DRAG=1,this.BOARD_MODE_MOVE_ORIGIN=2,this.BOARD_QUALITY_LOW=1,this.BOARD_QUALITY_HIGH=2,this.BOARD_MODE_ZOOM=17,this.container=t,this.containerObj=p.isBrowser?document.getElementById(this.container):null,p.isBrowser&&null===this.containerObj)throw Error("\nJSXGraph: HTML container element '"+t+"' not found.");this.renderer=r,this.grids=[],this.options=d.deepCopy(i),this.attr=m,this.dimension=2,this.jc=new h,this.jc.use(this),this.origin={},this.origin.usrCoords=[1,0,0],this.origin.scrCoords=[1,o[0],o[1]],this.zoomX=n,this.zoomY=a,this.unitX=c*this.zoomX,this.unitY=l*this.zoomY,this.canvasWidth=f,this.canvasHeight=b,this.id=d.exists(s)&&""!==s&&p.isBrowser&&!d.exists(document.getElementById(s))?s:this.generateId(),u.eventify(this),this.hooks=[],this.dependentBoards=[],this.inUpdate=!1,this.objects={},this.objectsList=[],this.groups={},this.animationObjects={},this.highlightedObjects={},this.numObjects=0,this.elementsByName={},this.mode=this.BOARD_MODE_NONE,this.updateQuality=this.BOARD_QUALITY_HIGH,this.isSuspendedRedraw=!1,this.calculateSnapSizes(),this.drag_dx=0,this.drag_dy=0,this.mouse={},this.touches=[],this.xmlString="",this.cPos=[],this.touchMoveLast=0,this.downObjects=[],this.attr.showcopyright&&this.renderer.displayCopyright(e.licenseText,parseInt(this.options.text.fontSize,10)),this.needsFullUpdate=!1,this.reducedUpdate=!1,this.currentCBDef="none",this.geonextCompatibilityMode=!1,this.options.text.useASCIIMathML&&translateASCIIMath?init():this.options.text.useASCIIMathML=!1,this.hasMouseHandlers=!1,this.hasTouchHandlers=!1,this.hasPointerHandlers=!1,this.hasMouseUp=!1,this.hasTouchEnd=!1,this.hasPointerUp=!1,this.attr.registerevents&&this.addEventHandlers(),this.methodMap={update:"update",on:"on",off:"off",trigger:"trigger",setView:"setBoundingBox",setBoundingBox:"setBoundingBox",migratePoint:"migratePoint",colorblind:"emulateColorblindness",suspendUpdate:"suspendUpdate",unsuspendUpdate:"unsuspendUpdate",clearTraces:"clearTraces",left:"clickLeftArrow",right:"clickRightArrow",up:"clickUpArrow",down:"clickDownArrow",zoomIn:"zoomIn",zoomOut:"zoomOut",zoom100:"zoom100",zoomElements:"zoomElements"}},t.extend(t.Board.prototype,{generateName:function(t){var r,i,s=2,o="",n="",a=[],h="";if(t.type===e.OBJECT_TYPE_TICKS)return"";for(r=t.elementClass===e.OBJECT_CLASS_POINT?["","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]:t.type===e.OBJECT_TYPE_ANGLE?["","&alpha;","&beta;","&gamma;","&delta;","&epsilon;","&zeta;","&eta;","&theta;","&iota;","&kappa;","&lambda;","&mu;","&nu;","&xi;","&omicron;","&pi;","&rho;","&sigma;","&tau;","&upsilon;","&phi;","&chi;","&psi;","&omega;"]:["","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],t.elementClass!==e.OBJECT_CLASS_POINT&&t.elementClass!==e.OBJECT_CLASS_LINE&&t.type!==e.OBJECT_TYPE_ANGLE&&(o=t.type===e.OBJECT_TYPE_POLYGON?"P_{":t.elementClass===e.OBJECT_CLASS_CIRCLE?"k_{":t.type===e.OBJECT_TYPE_TEXT?"t_{":"s_{",n="}"),i=0;s>i;i++)a[i]=0;for(;a[s-1]<r.length;){for(a[0]=1;a[0]<r.length;a[0]++){for(h=o,i=s;i>0;i--)h+=r[a[i-1]];if(!d.exists(this.elementsByName[h+n]))return h+n}for(a[0]=r.length,i=1;s>i;i++)a[i-1]===r.length&&(a[i-1]=1,a[i]+=1)}return""},generateId:function(){for(var e=1;d.exists(t.boards["jxgBoard"+e]);)e=Math.round(65535*Math.random());return"jxgBoard"+e},setId:function(t,e){var r=this.numObjects,i=t.id;return this.numObjects+=1,""!==i&&d.exists(i)||(i=this.id+e+r),t.id=i,this.objects[i]=t,t._pos=this.objectsList.length,this.objectsList[this.objectsList.length]=t,i},finalizeAdding:function(t){t.visProp.visible||this.renderer.hide(t)},finalizeLabel:function(t){!t.hasLabel||t.label.content.visProp.islabel||t.label.content.visProp.visible||this.renderer.hide(t.label.content)},getCoordsTopLeftCorner:function(){var t=this.containerObj,r=p.getOffset(t),i=document.documentElement.ownerDocument,s=function(e){var r=parseInt(p.getStyle(t,e),10);return isNaN(r)?0:r};return this.cPos.length>0&&(this.mode===e.BOARD_MODE_DRAG||this.mode===e.BOARD_MODE_MOVE_ORIGIN)?this.cPos:(!t.currentStyle&&i.defaultView&&(t=document.documentElement,r[0]+=s("margin-left"),r[1]+=s("margin-top"),r[0]+=s("border-left-width"),r[1]+=s("border-top-width"),r[0]+=s("padding-left"),r[1]+=s("padding-top"),t=this.containerObj),document.body&&(t=document.body,r[0]+=s("left"),r[1]+=s("top")),"object"==typeof google&&google.translate&&(r[0]+=10,r[1]+=25),r[0]+=s("border-left-width"),r[1]+=s("border-top-width"),"vml"!==this.renderer.type&&(r[0]+=s("padding-left"),r[1]+=s("padding-top")),this.cPos=r,r)},getMousePosition:function(t,e){var r,i,s=this.getCoordsTopLeftCorner();return r=p.getPosition(t,e),d.exists(this.cssTransMat)||this.updateCSSTransforms(),i=[1,r[0]-s[0],r[1]-s[1]],i=o.matVecMult(this.cssTransMat,i),i[1]/=i[0],i[2]/=i[0],[i[1],i[2]]},initMoveOrigin:function(t,e){this.drag_dx=t-this.origin.scrCoords[1],this.drag_dy=e-this.origin.scrCoords[2],this.mode=this.BOARD_MODE_MOVE_ORIGIN},initMoveObject:function(t,r,i,s){var o,n,a,h=[],c=this.objectsList.length,l={visProp:{layer:-1e4}};for(n=0;c>n;n++)o=this.objectsList[n],a=o.hasPoint&&o.hasPoint(t,r),o.visProp.visible&&a&&(o.triggerEventHandlers([s+"down","down"],[i]),this.downObjects.push(o)),(!this.geonextCompatibilityMode||o.elementClass!==e.OBJECT_CLASS_POINT&&o.type!==e.OBJECT_TYPE_TEXT)&&this.geonextCompatibilityMode||!o.isDraggable||!o.visProp.visible||o.visProp.fixed||o.visProp.frozen||!a||o.visProp.layer>=l.visProp.layer&&(d.exists(l.label)&&o===l.label.content||(l=o,h[0]=l));return h.length>0&&(this.mode=this.BOARD_MODE_DRAG),this.attr.takefirst&&(h.length=1),h},moveObject:function(t,i,s,o,a){var h,c=new r(e.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(t,i),this),l=s.obj;l.type!==e.OBJECT_TYPE_GLIDER?(isNaN(s.targets[0].Xprev+s.targets[0].Yprev)||l.setPositionDirectly(e.COORDS_BY_SCREEN,c.scrCoords.slice(1),[s.targets[0].Xprev,s.targets[0].Yprev]),s.targets[0].Xprev=c.scrCoords[1],s.targets[0].Yprev=c.scrCoords[2],l.prepareUpdate().update(!1).updateRenderer()):l.type===e.OBJECT_TYPE_GLIDER&&(h=l.coords,l.setPositionDirectly(e.COORDS_BY_USER,c.usrCoords.slice(1)),0!==l.group.length?(l.slideObject.elementClass===e.OBJECT_CLASS_CIRCLE?l.coords.setCoordinates(e.COORDS_BY_USER,n.projectPointToCircle(l,l.slideObject,this).usrCoords,!1):l.slideObject.elementClass===e.OBJECT_CLASS_LINE&&l.coords.setCoordinates(e.COORDS_BY_USER,n.projectPointToLine(l,l.slideObject,this).usrCoords,!1),l.group[l.group.length-1].dX=l.coords.scrCoords[1]-h.scrCoords[1],l.group[l.group.length-1].dY=l.coords.scrCoords[2]-h.scrCoords[2],l.group[l.group.length-1].update(this)):l.prepareUpdate().update(!1).updateRenderer()),l.triggerEventHandlers([a+"drag","drag"],[o]),this.updateInfobox(l),this.update(),l.highlight(!0)},twoFingerMove:function(t,i,s,o){var n,a,h;d.exists(s)&&d.exists(s.obj)&&(h=s.obj,n=new r(e.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(t[0],t[1]),this),a=new r(e.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(i[0],i[1]),this),h.elementClass===e.OBJECT_CLASS_LINE||h.type===e.OBJECT_TYPE_POLYGON?this.twoFingerTouchObject(n,a,s,h):h.elementClass===e.OBJECT_CLASS_CIRCLE&&this.twoFingerTouchCircle(n,a,s,h),h.triggerEventHandlers(["touchdrag","drag"],[o]),s.targets[0].Xprev=n.scrCoords[1],s.targets[0].Yprev=n.scrCoords[2],s.targets[1].Xprev=a.scrCoords[1],s.targets[1].Yprev=a.scrCoords[2])},twoFingerTouchObject:function(t,i,s,a){var h,c,l,u,p,f,b,m,g,v,C,y,P,_,E,S;if(d.exists(s.targets[0])&&d.exists(s.targets[1])&&!isNaN(s.targets[0].Xprev+s.targets[0].Yprev+s.targets[1].Xprev+s.targets[1].Yprev)){if(h=t.usrCoords,c=i.usrCoords,l=new r(e.COORDS_BY_SCREEN,[s.targets[0].Xprev,s.targets[0].Yprev],this).usrCoords,u=new r(e.COORDS_BY_SCREEN,[s.targets[1].Xprev,s.targets[1].Yprev],this).usrCoords,f=[1,.5*(l[1]+u[1]),.5*(l[2]+u[2])],p=[1,.5*(h[1]+c[1]),.5*(h[2]+c[2])],m=o.crossProduct(l,u),b=o.crossProduct(h,c),v=o.crossProduct(m,b),Math.abs(v[0])<o.eps)return;v[1]/=v[0],v[2]/=v[0],C=n.rad(f.slice(1),v.slice(1),p.slice(1)),y=this.create("transform",[C,v[1],v[2]],{type:"rotate"}),y.update(),f=o.matVecMult(y.matrix,f),f[1]/=f[0],f[2]/=f[0],P=this.create("transform",[p[1]-f[1],p[2]-f[2]],{type:"translate"}),P.update(),y.melt(P),a.visProp.scalable&&(g=n.distance(h,c)/n.distance(l,u),_=this.create("transform",[-p[1],-p[2]],{type:"translate"}),E=this.create("transform",[g,g],{type:"scale"}),S=this.create("transform",[p[1],p[2]],{type:"translate"}),y.melt(_).melt(E).melt(S)),a.elementClass===e.OBJECT_CLASS_LINE?y.applyOnce([a.point1,a.point2]):a.type===e.OBJECT_TYPE_POLYGON&&y.applyOnce(a.vertices.slice(0,-1)),this.update(),a.highlight(!0)}},twoFingerTouchCircle:function(t,i,s,o){var a,h,c,l,u,p,f,b,m,g,v;"pointCircle"!==o.method&&"pointLine"!==o.method&&d.exists(s.targets[0])&&d.exists(s.targets[1])&&!isNaN(s.targets[0].Xprev+s.targets[0].Yprev+s.targets[1].Xprev+s.targets[1].Yprev)&&(a=t.usrCoords,h=i.usrCoords,c=new r(e.COORDS_BY_SCREEN,[s.targets[0].Xprev,s.targets[0].Yprev],this).usrCoords,l=new r(e.COORDS_BY_SCREEN,[s.targets[1].Xprev,s.targets[1].Yprev],this).usrCoords,f=this.create("transform",[a[1]-c[1],a[2]-c[2]],{type:"translate"}),p=n.rad(l.slice(1),a.slice(1),h.slice(1)),b=this.create("transform",[-a[1],-a[2]],{type:"translate"}),m=this.create("transform",[p],{type:"rotate"}),f.melt(b).melt(m),o.visProp.scalable&&(u=n.distance(a,h)/n.distance(c,l),g=this.create("transform",[u,u],{type:"scale"}),f.melt(g)),v=this.create("transform",[a[1],a[2]],{type:"translate"}),f.melt(v),f.applyOnce([o.center]),"twoPoints"===o.method?f.applyOnce([o.point2]):"pointRadius"===o.method&&d.isNumber(o.updateRadius.origin)&&o.setRadius(o.radius*u),this.update(o.center),o.highlight(!0))},highlightElements:function(t,e,r,i){var s,o,n,a={},h=this.objectsList.length;for(s=0;h>s;s++)o=this.objectsList[s],n=o.id,d.exists(o.hasPoint)&&o.visProp.visible&&o.hasPoint(t,e)&&(this.updateInfobox(o),d.exists(this.highlightedObjects[n])||(a[n]=o,o.highlight(),this.triggerEventHandlers(["mousehit","hit"],[r,o,i])),o.mouseover?o.triggerEventHandlers(["mousemove","move"],[r]):(o.triggerEventHandlers(["mouseover","over"],[r]),o.mouseover=!0));for(s=0;h>s;s++)o=this.objectsList[s],n=o.id,o.mouseover&&(a[n]||(o.triggerEventHandlers(["mouseout","out"],[r]),o.mouseover=!1))},saveStartPos:function(r,i){var s,o,n=[];if(r.type===e.OBJECT_TYPE_TICKS)n.push([1,0/0,0/0]);else if(r.elementClass===e.OBJECT_CLASS_LINE)n.push(r.point1.coords.usrCoords),n.push(r.point2.coords.usrCoords);else if(r.elementClass===e.OBJECT_CLASS_CIRCLE)n.push(r.center.coords.usrCoords);else if(r.type===e.OBJECT_TYPE_POLYGON)for(o=r.vertices.length-1,s=0;o>s;s++)n.push(r.vertices[s].coords.usrCoords);else if(r.elementClass===e.OBJECT_CLASS_POINT||r.type===e.OBJECT_TYPE_GLIDER)n.push(r.coords.usrCoords);else try{n.push(r.coords.usrCoords)}catch(a){t.debug("JSXGraph+ saveStartPos: obj.coords.usrCoords not available: "+a)}for(o=n.length,s=0;o>s;s++)i.Zstart.push(n[s][0]),i.Xstart.push(n[s][1]),i.Ystart.push(n[s][2])},mouseOriginMoveStart:function(t){var e,r=this.attr.pan.enabled&&(!this.attr.pan.needshift||t.shiftKey);return r&&(e=this.getMousePosition(t),this.initMoveOrigin(e[0],e[1])),r},mouseOriginMove:function(t){var e,r=this.mode===this.BOARD_MODE_MOVE_ORIGIN;return r&&(e=this.getMousePosition(t),this.moveOrigin(e[0],e[1],!0)),r},touchOriginMoveStart:function(e){var r,i=e[t.touchProperty],s=2===i.length&&80>n.distance([i[0].screenX,i[0].screenY],[i[1].screenX,i[1].screenY]),o=this.attr.pan.enabled&&(!this.attr.pan.needtwofingers||s);return o&&(r=this.getMousePosition(e,0),this.initMoveOrigin(r[0],r[1])),o},touchOriginMove:function(t){var e,r=this.mode===this.BOARD_MODE_MOVE_ORIGIN;return r&&(e=this.getMousePosition(t,0),this.moveOrigin(e[0],e[1],!0)),r},originMoveEnd:function(){this.mode=this.BOARD_MODE_NONE},addEventHandlers:function(){p.supportsPointerEvents()?this.addPointerEventHandlers():(this.addMouseEventHandlers(),this.addTouchEventHandlers())},addPointerEventHandlers:function(){!this.hasPointerHandlers&&p.isBrowser&&(p.addEvent(this.containerObj,"MSPointerDown",this.pointerDownListener,this),p.addEvent(this.containerObj,"MSPointerMove",this.pointerMoveListener,this),this.hasPointerHandlers=!0)},addMouseEventHandlers:function(){!this.hasMouseHandlers&&p.isBrowser&&(p.addEvent(this.containerObj,"mousedown",this.mouseDownListener,this),p.addEvent(this.containerObj,"mousemove",this.mouseMoveListener,this),p.addEvent(this.containerObj,"mousewheel",this.mouseWheelListener,this),p.addEvent(this.containerObj,"DOMMouseScroll",this.mouseWheelListener,this),this.hasMouseHandlers=!0,this.containerObj.oncontextmenu=function(t){return d.exists(t)&&t.preventDefault(),!1})},addTouchEventHandlers:function(){!this.hasTouchHandlers&&p.isBrowser&&(p.addEvent(this.containerObj,"touchstart",this.touchStartListener,this),p.addEvent(this.containerObj,"touchmove",this.touchMoveListener,this),p.addEvent(this.containerObj,"gesturestart",this.gestureStartListener,this),p.addEvent(this.containerObj,"gesturechange",this.gestureChangeListener,this),this.hasTouchHandlers=!0)},removePointerEventHandlers:function(){this.hasPointerHandlers&&p.isBrowser&&(p.removeEvent(this.containerObj,"MSPointerDown",this.pointerDownListener,this),p.removeEvent(this.containerObj,"MSPointerMove",this.pointerMoveListener,this),this.hasPointerUp&&p.removeEvent(this.containerObj,"MSPointerUp",this.pointerUpListener,this),this.hasPointerHandlers=!1)},removeMouseEventHandlers:function(){this.hasMouseHandlers&&p.isBrowser&&(p.removeEvent(this.containerObj,"mousedown",this.mouseDownListener,this),p.removeEvent(this.containerObj,"mousemove",this.mouseMoveListener,this),this.hasMouseUp&&(p.removeEvent(document,"mouseup",this.mouseUpListener,this),this.hasMouseUp=!1),p.removeEvent(this.containerObj,"mousewheel",this.mouseWheelListener,this),p.removeEvent(this.containerObj,"DOMMouseScroll",this.mouseWheelListener,this),this.hasMouseHandlers=!1)},removeTouchEventHandlers:function(){this.hasTouchHandlers&&p.isBrowser&&(p.removeEvent(this.containerObj,"touchstart",this.touchStartListener,this),p.removeEvent(this.containerObj,"touchmove",this.touchMoveListener,this),this.hasTouchEnd&&(p.removeEvent(document,"touchend",this.touchEndListener,this),this.hasTouchEnd=!1),p.removeEvent(this.containerObj,"gesturestart",this.gestureStartListener,this),p.removeEvent(this.containerObj,"gesturechange",this.gestureChangeListener,this),this.hasTouchHandlers=!1)},removeEventHandlers:function(){this.removeMouseEventHandlers(),this.removeTouchEventHandlers(),this.removePointerEventHandlers()},clickLeftArrow:function(){return this.moveOrigin(this.origin.scrCoords[1]+.1*this.canvasWidth,this.origin.scrCoords[2]),!1},clickRightArrow:function(){return this.moveOrigin(this.origin.scrCoords[1]-.1*this.canvasWidth,this.origin.scrCoords[2]),!1},clickUpArrow:function(){return this.moveOrigin(this.origin.scrCoords[1],this.origin.scrCoords[2]-.1*this.canvasHeight),!1},clickDownArrow:function(){return this.moveOrigin(this.origin.scrCoords[1],this.origin.scrCoords[2]+.1*this.canvasHeight),!1},gestureChangeListener:function(t){var i,s=this.attr.zoom.factorx,o=this.attr.zoom.factory;return this.attr.zoom.wheel?(t.preventDefault(),this.mode===this.BOARD_MODE_NONE&&(i=new r(e.COORDS_BY_SCREEN,this.getMousePosition(t),this),this.attr.zoom.factorx=t.scale/this.prevScale,this.attr.zoom.factory=t.scale/this.prevScale,this.zoomIn(i.usrCoords[1],i.usrCoords[2]),this.prevScale=t.scale,this.attr.zoom.factorx=s,this.attr.zoom.factory=o),!1):!0},gestureStartListener:function(t){return this.attr.zoom.wheel?(t.preventDefault(),this.prevScale=1,!1):!0},pointerDownListener:function(t){var e,r,i,s,o,n,a,h,c=this.options.precision.touch;if(this.hasPointerUp||(p.addEvent(document,"MSPointerUp",this.pointerUpListener,this),this.hasPointerUp=!0),this.hasMouseHandlers&&this.removeMouseEventHandlers(),this.hasTouchHandlers&&this.removeTouchEventHandlers(),document.selection&&"function"==typeof document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges(),this.options.precision.hasPoint=c,s=this.getMousePosition(t),o=this.initMoveObject(s[0],s[1],t,"mouse"),o.length>0){for(a=o[o.length-1],n=!1,e=0;this.touches.length>e;e++)if(this.touches[e].obj===a){r=e,i=this.touches[e].targets.push({num:t.pointerId,X:s[0],Y:s[1],Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]})-1,n=!0;break}n||(i=0,r=this.touches.push({obj:a,targets:[{num:t.pointerId,X:s[0],Y:s[1],Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]}]})-1),this.dehighlightAll(),a.highlight(!0),this.saveStartPos(a,this.touches[r].targets[i]),t&&t.preventDefault?t.preventDefault():window.event&&(window.event.returnValue=!1)}return this.touches.length>0&&(t.preventDefault(),t.stopPropagation()),this.mode===this.BOARD_MODE_NONE&&this.mouseOriginMoveStart(t)?(this.triggerEventHandlers(["touchstart","down","MSPointerDown"],[t]),!1):(this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers(["touchstart","down","MSPointerDown"],[t]),h)},pointerMoveListener:function(e){var r,i,s;if(e[t.touchProperty],this.mode!==this.BOARD_MODE_NONE&&(e.preventDefault(),e.stopPropagation()),this.mode!==this.BOARD_MODE_DRAG&&this.renderer.hide(this.infobox),this.options.precision.hasPoint=this.options.precision.touch,!this.mouseOriginMove(e)&&this.mode===this.BOARD_MODE_DRAG)for(r=0;this.touches.length>r;r++)for(i=0;this.touches[r].targets.length>i;i++)if(this.touches[r].targets[i].num===e.pointerId){1===this.touches[r].targets.length?(this.touches[r].targets[i].X=e.pageX,this.touches[r].targets[i].Y=e.pageY,s=this.getMousePosition(e),this.moveObject(s[0],s[1],this.touches[r],e,"touch")):2===this.touches[r].targets.length&&this.touches[r].targets[0].num>-1&&this.touches[r].targets[1].num>-1&&(this.touches[r].targets[i].X=e.pageX,this.touches[r].targets[i].Y=e.pageY,this.twoFingerMove(this.getMousePosition({pageX:this.touches[r].targets[0].X,pageY:this.touches[r].targets[0].Y}),this.getMousePosition({pageX:this.touches[r].targets[1].X,pageY:this.touches[r].targets[1].Y}),this.touches[r],e));break}return this.mode!==this.BOARD_MODE_DRAG&&this.renderer.hide(this.infobox),this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers(["touchmove","move","MSPointerMove"],[e,this.mode]),this.mode===this.BOARD_MODE_NONE},pointerUpListener:function(t){var e,r,i;for(this.options.precision.touch,this.triggerEventHandlers(["touchend","up","MSPointerUp"],[t]),this.renderer.hide(this.infobox),e=0;this.touches.length>e;e++)for(r=0;this.touches[e].targets.length>r;r++)if(this.touches[e].targets[r].num===t.pointerId){this.touches[e].targets.splice(r,1),0===this.touches[e].targets.length&&this.touches.splice(e,1);break}for(e=0;this.downObjects.length>e;e++){for(i=!1,r=0;this.touches.length>r;r++)this.touches[r].obj.id===this.downObjects[e].id&&(i=!0);i||(this.downObjects[e].triggerEventHandlers(["touchend","up","MSPointerUp"],[t]),this.downObjects[e].snapToGrid(),this.downObjects.splice(e,1))}return 0===this.touches.length&&(p.removeEvent(document,"MSPointerUp",this.pointerUpListener,this),this.hasPointerUp=!1,this.dehighlightAll(),this.updateQuality=this.BOARD_QUALITY_HIGH,this.originMoveEnd(),this.update()),!0},touchStartListener:function(r,s){var o,n,a,h,c,l,u,f,b,m,g=this.options.precision.touch,v=r[t.touchProperty];for(this.hasTouchEnd||(p.addEvent(document,"touchend",this.touchEndListener,this),this.hasTouchEnd=!0),this.hasMouseHandlers&&this.removeMouseEventHandlers(),document.selection&&"function"==typeof document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges(),this.options.precision.hasPoint=this.options.precision.touch,o=0;v.length>o;o++)v[o].jxg_isused=!1;for(o=0;this.touches.length>o;o++)for(h=0;this.touches[o].targets.length>h;h++){this.touches[o].targets[h].num=-1,g=this.options.precision.touch;do{for(c=0;v.length>c;c++)if(g*g>Math.abs(Math.pow(v[c].screenX-this.touches[o].targets[h].X,2)+Math.pow(v[c].screenY-this.touches[o].targets[h].Y,2))){this.touches[o].targets[h].num=c,this.touches[o].targets[h].X=v[c].screenX,this.touches[o].targets[h].Y=v[c].screenY,v[c].jxg_isused=!0;break}g*=2}while(-1===this.touches[o].targets[h].num&&this.options.precision.touchMax>g);-1===this.touches[o].targets[h].num&&(t.debug("i couldn't find a targettouches for target no "+h+" on "+this.touches[o].obj.name+" ("+this.touches[o].obj.id+"). Removed the target."),t.debug("eps = "+g+", touchMax = "+i.precision.touchMax),this.touches[o].targets.splice(o,1))}for(o=0;v.length>o;o++)if(s||!v[o].jxg_isused){if(n=this.getMousePosition(r,o),s?(a=[s],this.mode=this.BOARD_MODE_DRAG):a=this.initMoveObject(n[0],n[1],r,"touch"),0!==a.length)if(u=a[a.length-1],d.isPoint(u)||u.type===e.OBJECT_TYPE_TEXT||u.type===e.OBJECT_TYPE_TICKS)b=[{num:o,X:v[o].screenX,Y:v[o].screenY,Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]}],this.saveStartPos(u,b[0]),this.touches.push({obj:u,targets:b}),u.highlight(!0);else if(u.elementClass===e.OBJECT_CLASS_LINE||u.elementClass===e.OBJECT_CLASS_CIRCLE||u.type===e.OBJECT_TYPE_POLYGON){for(f=!1,h=0;this.touches.length>h;h++)u.id===this.touches[h].obj.id&&(f=!0,1===this.touches[h].targets.length&&(m={num:o,X:v[o].screenX,Y:v[o].screenY,Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]},this.saveStartPos(u,m),this.touches[h].targets.push(m)),v[o].jxg_isused=!0);f||(b=[{num:o,X:v[o].screenX,Y:v[o].screenY,Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]}],this.saveStartPos(u,b[0]),this.touches.push({obj:u,targets:b}),u.highlight(!0))}v[o].jxg_isused=!0}return this.touches.length>0&&(r.preventDefault(),r.stopPropagation()),this.mode===this.BOARD_MODE_NONE&&this.touchOriginMoveStart(r)?(this.triggerEventHandlers(["touchstart","down"],[r]),!1):(p.isWebkitAndroid()&&(l=new Date,this.touchMoveLast=l.getTime()-200),this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers(["touchstart","down"],[r]),this.touches.length>0)},touchMoveListener:function(e){var r,i,s,o=e[t.touchProperty];if(this.mode!==this.BOARD_MODE_NONE&&(e.preventDefault(),e.stopPropagation()),p.isWebkitAndroid()){if(s=new Date,s=s.getTime(),80>s-this.touchMoveLast)return this.updateQuality=this.BOARD_QUALITY_HIGH,this.triggerEventHandlers(["touchmove","move"],[e,this.mode]),!1;this.touchMoveLast=s}if(this.mode!==this.BOARD_MODE_DRAG&&this.renderer.hide(this.infobox),this.options.precision.hasPoint=this.options.precision.touch,!this.touchOriginMove(e)&&this.mode===this.BOARD_MODE_DRAG)for(r=0;this.touches.length>r;r++)1===this.touches[r].targets.length?o[this.touches[r].targets[0].num]&&(this.touches[r].targets[0].X=o[this.touches[r].targets[0].num].screenX,this.touches[r].targets[0].Y=o[this.touches[r].targets[0].num].screenY,i=this.getMousePosition(e,this.touches[r].targets[0].num),this.moveObject(i[0],i[1],this.touches[r],e,"touch")):2===this.touches[r].targets.length&&this.touches[r].targets[0].num>-1&&this.touches[r].targets[1].num>-1&&o[this.touches[r].targets[0].num]&&o[this.touches[r].targets[1].num]&&(this.touches[r].targets[0].X=o[this.touches[r].targets[0].num].screenX,this.touches[r].targets[0].Y=o[this.touches[r].targets[0].num].screenY,this.touches[r].targets[1].X=o[this.touches[r].targets[1].num].screenX,this.touches[r].targets[1].Y=o[this.touches[r].targets[1].num].screenY,this.twoFingerMove(this.getMousePosition(e,this.touches[r].targets[0].num),this.getMousePosition(e,this.touches[r].targets[1].num),this.touches[r],e));return this.mode!==this.BOARD_MODE_DRAG&&this.renderer.hide(this.infobox),this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers(["touchmove","move"],[e,this.mode]),this.mode===this.BOARD_MODE_NONE},touchEndListener:function(r){var i,s,o,n,a,h=this.options.precision.touch,c=[],l=r[t.touchProperty];if(this.triggerEventHandlers(["touchend","up"],[r]),this.renderer.hide(this.infobox),l.length>0){for(i=0;this.touches.length>i;i++)c[i]=this.touches[i];for(this.touches.length=0,i=0;l.length>i;i++)l[i].jxg_isused=!1;for(i=0;c.length>i;i++){for(n=!1,a=0,s=0;c[i].targets.length>s;s++)for(c[i].targets[s].found=!1,o=0;l.length>o;o++)if(h*h>Math.abs(Math.pow(l[o].screenX-c[i].targets[s].X,2)+Math.pow(l[o].screenY-c[i].targets[s].Y,2))){c[i].targets[s].found=!0,c[i].targets[s].num=o,c[i].targets[s].X=l[o].screenX,c[i].targets[s].Y=l[o].screenY,a+=1;break}if(d.isPoint(c[i].obj)?n=c[i].targets[0]&&c[i].targets[0].found:c[i].obj.elementClass===e.OBJECT_CLASS_LINE?n=c[i].targets[0]&&c[i].targets[0].found||c[i].targets[1]&&c[i].targets[1].found:c[i].obj.elementClass===e.OBJECT_CLASS_CIRCLE&&(n=1===a||3===a),n)for(this.touches.push({obj:c[i].obj,targets:[]}),s=0;c[i].targets.length>s;s++)c[i].targets[s].found&&this.touches[this.touches.length-1].targets.push({num:c[i].targets[s].num,X:c[i].targets[s].screenX,Y:c[i].targets[s].screenY,Xprev:0/0,Yprev:0/0,Xstart:c[i].targets[s].Xstart,Ystart:c[i].targets[s].Ystart,Zstart:c[i].targets[s].Zstart});else c[i].obj.noHighlight()}}else this.touches.length=0;for(i=0;this.downObjects.length>i;i++){for(n=!1,s=0;this.touches.length>s;s++)this.touches[s].obj.id===this.downObjects[i].id&&(n=!0);n||(this.downObjects[i].type===e.OBJECT_TYPE_GLIDER&&(this.downObjects[i].needsUpdateFromParent=!1),this.downObjects[i].triggerEventHandlers(["touchup","up"],[r]),this.downObjects[i].snapToGrid(),this.downObjects.splice(i,1))}return l&&0!==l.length||(p.removeEvent(document,"touchend",this.touchEndListener,this),this.hasTouchEnd=!1,this.dehighlightAll(),this.updateQuality=this.BOARD_QUALITY_HIGH,this.originMoveEnd(),this.update()),!0},mouseDownListener:function(t,e){var r,i,s;return document.selection&&"function"==typeof document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges(),this.hasMouseUp||(p.addEvent(document,"mouseup",this.mouseUpListener,this),this.hasMouseUp=!0),r=this.getMousePosition(t),e?(i=[e],this.mode=this.BOARD_MODE_DRAG):i=this.initMoveObject(r[0],r[1],t,"mouse"),0===i.length?(this.mode=this.BOARD_MODE_NONE,s=!0):(this.mouse={obj:null,targets:[{X:r[0],Y:r[1],Xprev:0/0,Yprev:0/0}]},this.mouse.obj=i[i.length-1],this.dehighlightAll(),this.mouse.obj.highlight(!0),this.mouse.targets[0].Xstart=[],this.mouse.targets[0].Ystart=[],this.mouse.targets[0].Zstart=[],this.saveStartPos(this.mouse.obj,this.mouse.targets[0]),t&&t.preventDefault?t.preventDefault():window.event&&(window.event.returnValue=!1)),this.mode===this.BOARD_MODE_NONE&&(s=this.mouseOriginMoveStart(t)),e||this.triggerEventHandlers(["mousedown","down"],[t]),s},mouseUpListener:function(t){var r;for(this.triggerEventHandlers(["mouseup","up"],[t]),this.updateQuality=this.BOARD_QUALITY_HIGH,this.mouse&&this.mouse.obj&&this.mouse.obj.snapToGrid(this.mouse.targets[0]),this.mode===this.BOARD_MODE_DRAG&&this.mouse.obj.type===e.OBJECT_TYPE_GLIDER&&(this.mouse.obj.needsUpdateFromParent=!1),this.originMoveEnd(),this.dehighlightAll(),this.update(),r=0;this.downObjects.length>r;r++)this.downObjects[r].triggerEventHandlers(["mouseup","up"],[t]);this.downObjects.length=0,this.hasMouseUp&&(p.removeEvent(document,"mouseup",this.mouseUpListener,this),this.hasMouseUp=!1),this.mouse=null},mouseMoveListener:function(t){var e;e=this.getMousePosition(t),this.updateQuality=this.BOARD_QUALITY_LOW,this.mode!==this.BOARD_MODE_DRAG&&(this.dehighlightAll(),this.renderer.hide(this.infobox)),this.mouseOriginMove(t)||(this.mode===this.BOARD_MODE_DRAG?this.moveObject(e[0],e[1],this.mouse,t,"mouse"):this.highlightElements(e[0],e[1],t,-1)),this.updateQuality=this.BOARD_QUALITY_HIGH,this.triggerEventHandlers(["mousemove","move"],[t,this.mode])},mouseWheelListener:function(t){if(!this.attr.zoom.wheel||this.attr.zoom.needshift&&!t.shiftKey)return!0;t=t||window.event;var i=t.detail?-t.detail:t.wheelDelta/40,s=new r(e.COORDS_BY_SCREEN,this.getMousePosition(t),this);return i>0?this.zoomIn(s.usrCoords[1],s.usrCoords[2]):this.zoomOut(s.usrCoords[1],s.usrCoords[2]),t.preventDefault(),!1},updateInfobox:function(t){var r,i,s,o;return t.visProp.showinfobox?(t.elementClass===e.OBJECT_CLASS_POINT&&(s=t.coords.usrCoords[1],o=t.coords.usrCoords[2],this.infobox.setCoords(s+this.infobox.distanceX/this.unitX,o+this.infobox.distanceY/this.unitY),"string"!=typeof t.infoboxText?("auto"===t.visProp.infoboxdigits?(r=d.autoDigits(s),i=d.autoDigits(o)):d.isNumber(t.visProp.infoboxdigits)?(r=s.toFixed(t.visProp.infoboxdigits),i=o.toFixed(t.visProp.infoboxdigits)):(r=s,i=o),this.highlightInfobox(r,i,t)):this.highlightCustomInfobox(t.infoboxText,t),this.renderer.show(this.infobox)),this):this},highlightCustomInfobox:function(t){return this.infobox.setText(t),this},highlightInfobox:function(t,e,r){return this.highlightCustomInfobox("("+t+", "+e+")",r),this},dehighlightAll:function(){var t,e,r=!1;for(t in this.highlightedObjects)this.highlightedObjects.hasOwnProperty(t)&&(e=this.highlightedObjects[t],this.hasMouseHandlers&&e.noHighlight(),r=!0);return this.highlightedObjects={},"canvas"===this.renderer.type&&r&&(this.prepareUpdate(),this.renderer.suspendRedraw(this),this.updateRenderer(),this.renderer.unsuspendRedraw()),this},getScrCoordsOfMouse:function(t,e){return[t,e]},getUsrCoordsOfMouse:function(t){var i=this.getCoordsTopLeftCorner(),s=p.getPosition(t),o=s[0]-i[0],n=s[1]-i[1],a=new r(e.COORDS_BY_SCREEN,[o,n],this);return a.usrCoords.slice(1)},getAllUnderMouse:function(t){var e=this.getAllObjectsUnderMouse(t);return e.push(this.getUsrCoordsOfMouse(t)),e},getAllObjectsUnderMouse:function(t){var e,r,i=this.getCoordsTopLeftCorner(),s=p.getPosition(t),o=s[0]-i[0],n=s[1]-i[1],a=[],h=this.objectsList.length;
for(e=0;h>e;e++)r=this.objectsList[e],r.visProp.visible&&r.hasPoint&&r.hasPoint(o,n)&&(a[a.length]=r);return a},updateCoords:function(){var t,e,r=this.objectsList.length;for(e=0;r>e;e++)t=this.objectsList[e],d.exists(t.coords)&&(t.visProp.frozen?t.coords.screen2usr():t.coords.usr2screen());return this},moveOrigin:function(t,e,r){return d.exists(t)&&d.exists(e)&&(this.origin.scrCoords[1]=t,this.origin.scrCoords[2]=e,r&&(this.origin.scrCoords[1]-=this.drag_dx,this.origin.scrCoords[2]-=this.drag_dy)),this.updateCoords().clearTraces().fullUpdate(),this.triggerEventHandlers(["boundingbox"]),this},addConditions:function(e){var r,i,s,o,n,a,h,c=[],u="var el, x, y, c, rgbo;\n",p=e.indexOf("<data>"),f=e.indexOf("</data>"),b=function(e,r,i,s){return function(){var o,n;o=e.select(r.id),n=o.coords.usrCoords[s],2===s?o.setPositionDirectly(t.COORDS_BY_USER,[i(),n]):o.setPositionDirectly(t.COORDS_BY_USER,[n,i()]),o.prepareUpdate().update()}},m=function(t,e,r){return function(){var i,s;i=t.select(e.id),s=r(),i.setAttribute({visible:s})}},g=function(t,e,r,i){return function(){var s,o;s=t.select(e.id),o=r(),"strokewidth"===i?s.visProp.strokewidth=o:(o=l.rgba2rgbo(o),s.visProp[i+"color"]=o[0],s.visProp[i+"opacity"]=o[1])}},v=function(t,e,r){return function(){var i=t.select(e.id);i.position=r()}},C=function(t,e,r){return function(){var i=t.select(e.id);i.setStyle(r())}};if(!(0>p)){for(;p>=0;){switch(r=e.slice(p+6,f),i=r.indexOf("="),s=r.slice(0,i),o=r.slice(i+1),i=s.indexOf("."),n=s.slice(0,i),a=this.elementsByName[d.unescapeHTML(n)],h=s.slice(i+1).replace(/\s+/g,"").toLowerCase(),o=d.createFunction(o,this,"",!0),d.exists(this.elementsByName[n])||t.debug("debug conditions: |"+n+"| undefined"),u+='el = this.objects["'+a.id+'"];\n',h){case"x":c.push(b(this,a,o,2));break;case"y":c.push(b(this,a,o,1));break;case"visible":c.push(m(this,a,o));break;case"position":c.push(v(this,a,o));break;case"stroke":c.push(g(this,a,o,"stroke"));break;case"style":c.push(C(this,a,o));break;case"strokewidth":c.push(g(this,a,o,"strokewidth"));break;case"fill":c.push(g(this,a,o,"fill"));break;case"label":break;default:t.debug("property '"+h+"' in conditions not yet implemented:"+o)}e=e.slice(f+7),p=e.indexOf("<data>"),f=e.indexOf("</data>")}this.updateConditions=function(){var t;for(t=0;c.length>t;t++)c[t]();return this.prepareUpdate().updateElements(),!0},this.updateConditions()}},updateConditions:function(){return!1},calculateSnapSizes:function(){var t=new r(e.COORDS_BY_USER,[0,0],this),i=new r(e.COORDS_BY_USER,[this.options.grid.gridX,this.options.grid.gridY],this),s=t.scrCoords[1]-i.scrCoords[1],o=t.scrCoords[2]-i.scrCoords[2];for(this.options.grid.snapSizeX=this.options.grid.gridX;Math.abs(s)>25;)this.options.grid.snapSizeX*=2,s/=2;for(this.options.grid.snapSizeY=this.options.grid.gridY;Math.abs(o)>25;)this.options.grid.snapSizeY*=2,o/=2;return this},applyZoom:function(){return this.updateCoords().calculateSnapSizes().clearTraces().fullUpdate(),this},zoomIn:function(t,e){var r=this.getBoundingBox(),i=this.attr.zoom.factorx,s=this.attr.zoom.factory,o=(r[2]-r[0])*(1-1/i),n=(r[1]-r[3])*(1-1/s),a=.5,h=.5;return"number"==typeof t&&"number"==typeof e&&(a=(t-r[0])/(r[2]-r[0]),h=(r[1]-e)/(r[1]-r[3])),this.setBoundingBox([r[0]+o*a,r[1]-n*h,r[2]-o*(1-a),r[3]+n*(1-h)],!1),this.zoomX*=i,this.zoomY*=s,this.applyZoom(),!1},zoomOut:function(t,e){var r=this.getBoundingBox(),i=this.attr.zoom.factorx,s=this.attr.zoom.factory,o=(r[2]-r[0])*(1-i),n=(r[1]-r[3])*(1-s),a=.5,h=.5;return this.zoomX<this.attr.zoom.eps||this.zoomY<this.attr.zoom.eps?!1:("number"==typeof t&&"number"==typeof e&&(a=(t-r[0])/(r[2]-r[0]),h=(r[1]-e)/(r[1]-r[3])),this.setBoundingBox([r[0]+o*a,r[1]-n*h,r[2]-o*(1-a),r[3]+n*(1-h)],!1),this.zoomX/=i,this.zoomY/=s,this.applyZoom(),!1)},zoom100:function(){var t=this.getBoundingBox(),e=.5*(t[2]-t[0])*(1-this.zoomX),r=.5*(t[1]-t[3])*(1-this.zoomY);return this.setBoundingBox([t[0]+e,t[1]-r,t[2]-e,t[3]+r],!1),this.zoomX=1,this.zoomY=1,this.applyZoom(),!1},zoomAllPoints:function(){var t,e,r,i,s,o=0,n=0,a=0,h=0,c=this.objectsList.length;for(t=0;c>t;t++)s=this.objectsList[t],d.isPoint(s)&&s.visProp.visible&&(o>s.coords.usrCoords[1]?o=s.coords.usrCoords[1]:s.coords.usrCoords[1]>n&&(n=s.coords.usrCoords[1]),s.coords.usrCoords[2]>h?h=s.coords.usrCoords[2]:a>s.coords.usrCoords[2]&&(a=s.coords.usrCoords[2]));return e=50,r=e/this.unitX,i=e/this.unitY,this.zoomX=1,this.zoomY=1,this.setBoundingBox([o-r,h+i,n+r,a-i],!0),this.applyZoom(),this},zoomElements:function(t){var e,r,i,s,o=[0,0,0,0],n=[1,-1,-1,1];if(!d.isArray(t)||0===t.length)return this;for(e=0;t.length>e;e++)if(i=this.select(t[e]),s=i.bounds(),d.isArray(s))if(d.isArray(o))for(r=0;4>r;r++)n[r]*s[r]<n[r]*o[r]&&(o[r]=s[r]);else o=s;if(d.isArray(o)){for(r=0;4>r;r++)o[r]-=n[r];this.zoomX=1,this.zoomY=1,this.setBoundingBox(o,!0)}return this},setZoom:function(t,e){var r=this.attr.zoom.factorx,i=this.attr.zoom.factory;return this.attr.zoom.factorx=t/this.zoomX,this.attr.zoom.factory=e/this.zoomY,this.zoomIn(),this.attr.zoom.factorx=r,this.attr.zoom.factory=i,this},removeObject:function(e){var r,i;if(d.isArray(e)){for(i=0;e.length>i;i++)this.removeObject(e[i]);return this}if(e=this.select(e),!d.exists(e)||d.isString(e))return this;try{for(r in e.childElements)e.childElements.hasOwnProperty(r)&&e.childElements[r].board.removeObject(e.childElements[r]);for(r in this.objects)this.objects.hasOwnProperty(r)&&d.exists(this.objects[r].childElements)&&(delete this.objects[r].childElements[e.id],delete this.objects[r].descendants[e.id]);if(e._pos>-1)for(this.objectsList.splice(e._pos,1),r=e._pos;this.objectsList.length>r;r++)this.objectsList[r]._pos--;else t.debug("object "+e.id+" not found in list.");delete this.objects[e.id],delete this.elementsByName[e.name],e.visProp&&e.visProp.trace&&e.clearTrace(),d.exists(e.remove)&&e.remove()}catch(s){t.debug(e.id+": Could not be removed: "+s)}return this.update(),this},removeAncestors:function(t){var e;for(e in t.ancestors)t.ancestors.hasOwnProperty(e)&&this.removeAncestors(t.ancestors[e]);return this.removeObject(t),this},initGeonextBoard:function(){var t,e,r;return t=this.create("point",[0,0],{id:this.id+"g00e0",name:"Ursprung",withLabel:!1,visible:!1,fixed:!0}),e=this.create("point",[1,0],{id:this.id+"gX0e0",name:"Punkt_1_0",withLabel:!1,visible:!1,fixed:!0}),r=this.create("point",[0,1],{id:this.id+"gY0e0",name:"Punkt_0_1",withLabel:!1,visible:!1,fixed:!0}),this.create("line",[t,e],{id:this.id+"gXLe0",name:"X-Achse",withLabel:!1,visible:!1}),this.create("line",[t,r],{id:this.id+"gYLe0",name:"Y-Achse",withLabel:!1,visible:!1}),this},initInfobox:function(){var t=d.copyAttributes({},this.options,"infobox");return t.id=this.id+"_infobox",this.infobox=this.create("text",[0,0,"0,0"],t),this.infobox.distanceX=-20,this.infobox.distanceY=25,this.infobox.needsUpdateSize=!1,this.infobox.dump=!1,this.renderer.hide(this.infobox),this},resizeContainer:function(t,e,r){return this.canvasWidth=parseFloat(t),this.canvasHeight=parseFloat(e),r||(this.containerObj.style.width=this.canvasWidth+"px",this.containerObj.style.height=this.canvasHeight+"px"),this.renderer.resize(this.canvasWidth,this.canvasHeight),this},showDependencies:function(){var t,e,r,i,s;e="<p>\n";for(t in this.objects)if(this.objects.hasOwnProperty(t)){s=0;for(r in this.objects[t].childElements)this.objects[t].childElements.hasOwnProperty(r)&&(s+=1);s>=0&&(e+="<strong>"+this.objects[t].id+":<"+"/strong> ");for(r in this.objects[t].childElements)this.objects[t].childElements.hasOwnProperty(r)&&(e+=this.objects[t].childElements[r].id+"("+this.objects[t].childElements[r].name+")"+", ");e+="<p>\n"}return e+="</p>\n",i=window.open(),i.document.open(),i.document.write(e),i.document.close(),this},showXML:function(){var t=window.open("");return t.document.open(),t.document.write("<pre>"+d.escapeHTML(this.xmlString)+"<"+"/pre>"),t.document.close(),this},prepareUpdate:function(){var t,e,r=this.objectsList.length;for(t=0;r>t;t++)e=this.objectsList[t],e.needsUpdate=e.needsRegularUpdate||this.needsFullUpdate;return this},updateElements:function(t){var e,r;for(t=this.select(t),e=0;this.objectsList.length>e;e++)r=this.objectsList[e],r.update(!d.exists(t)||r.id!==t.id);for(e in this.groups)this.groups.hasOwnProperty(e)&&this.groups[e].update(t);return this},updateRenderer:function(){var t,e,r=this.objectsList.length;if("canvas"===this.renderer.type)this.updateRendererCanvas();else for(t=0;r>t;t++)e=this.objectsList[t],e.updateRenderer();return this},updateRendererCanvas:function(){var t,e,r,i,s,o=this.objectsList.length,n=this.options.layer,a=this.options.layer.numlayers,h=Number.NEGATIVE_INFINITY;for(r=0;a>r;r++){i=Number.POSITIVE_INFINITY;for(s in n)n.hasOwnProperty(s)&&n[s]>h&&i>n[s]&&(i=n[s]);for(h=i,t=0;o>t;t++)e=this.objectsList[t],e.visProp.layer===i&&e.prepareUpdate().updateRenderer()}return this},addHook:function(t,e,r){return e=d.def(e,"update"),r=d.def(r,this),this.hooks.push([e,t]),this.on(e,t,r),this.hooks.length-1},addEvent:t.shortcut(t.Board.prototype,"on"),removeHook:function(t){return this.hooks[t]&&(this.off(this.hooks[t][0],this.hooks[t][1]),this.hooks[t]=null),this},removeEvent:t.shortcut(t.Board.prototype,"off"),updateHooks:function(){var t=Array.prototype.slice.call(arguments,0);return t[0]=d.def(t[0],"update"),this.triggerEventHandlers([t[0]],arguments),this},addChild:function(t){return d.exists(t)&&d.exists(t.containerObj)&&(this.dependentBoards.push(t),this.update()),this},removeChild:function(t){var e;for(e=this.dependentBoards.length-1;e>=0;e--)this.dependentBoards[e]===t&&this.dependentBoards.splice(e,1);return this},update:function(t){var e,r,i;if(this.inUpdate||this.isSuspendedUpdate)return this;for(this.inUpdate=!0,this.prepareUpdate().updateElements(t).updateConditions(),this.renderer.suspendRedraw(this),this.updateRenderer(),this.renderer.unsuspendRedraw(),this.triggerEventHandlers(["update"],[]),r=this.dependentBoards.length,e=0;r>e;e++)i=this.dependentBoards[e],d.exists(i)&&i!==this&&(i.updateQuality=this.updateQuality,i.prepareUpdate().updateElements().updateConditions(),i.renderer.suspendRedraw(),i.updateRenderer(),i.renderer.unsuspendRedraw(),i.triggerEventHandlers(["update"],[]));return this.inUpdate=!1,this},fullUpdate:function(){return this.needsFullUpdate=!0,this.update(),this.needsFullUpdate=!1,this},addGrid:function(){return this.create("grid",[]),this},removeGrids:function(){var t;for(t=0;this.grids.length>t;t++)this.removeObject(this.grids[t]);return this.grids.length=0,this.update(),this},create:function(e,r,i){var s,o;for(e=e.toLowerCase(),d.exists(r)||(r=[]),d.exists(i)||(i={}),o=0;r.length>o;o++)("text"!==e||2!==o)&&(r[o]=this.select(r[o]));if("function"!=typeof t.elements[e])throw Error("JSXGraph: create: Unknown element type given: "+e);return s=t.elements[e](this,r,i),d.exists(s)?(s.prepareUpdate&&s.update&&s.updateRenderer&&s.prepareUpdate().update().updateRenderer(),s):(t.debug("JSXGraph: create: failure creating "+e),s)},createElement:t.shortcut(t.Board.prototype,"create"),clearTraces:function(){var t;for(t=0;this.objectsList.length>t;t++)this.objectsList[t].clearTrace();return this.numTraces=0,this},suspendUpdate:function(){return this.isSuspendedUpdate=!0,this},unsuspendUpdate:function(){return this.isSuspendedUpdate=!1,this.update(),this},setBoundingBox:function(t,e){var r,i,s=p.getDimensions(this.container);return d.isArray(t)?(this.plainBB=t,this.canvasWidth=parseInt(s.width,10),this.canvasHeight=parseInt(s.height,10),i=this.canvasWidth,r=this.canvasHeight,e?(this.unitX=i/(t[2]-t[0]),this.unitY=r/(t[1]-t[3]),Math.abs(this.unitX)<Math.abs(this.unitY)?this.unitY=Math.abs(this.unitX)*this.unitY/Math.abs(this.unitY):this.unitX=Math.abs(this.unitY)*this.unitX/Math.abs(this.unitX)):(this.unitX=i/(t[2]-t[0]),this.unitY=r/(t[1]-t[3])),this.moveOrigin(-this.unitX*t[0],this.unitY*t[1]),this):this},getBoundingBox:function(){var t=new r(e.COORDS_BY_SCREEN,[0,0],this),i=new r(e.COORDS_BY_SCREEN,[this.canvasWidth,this.canvasHeight],this);return[t.usrCoords[1],t.usrCoords[2],i.usrCoords[1],i.usrCoords[2]]},addAnimation:function(t){var e=this;return this.animationObjects[t.id]=t,this.animationIntervalCode||(this.animationIntervalCode=window.setInterval(function(){e.animate()},t.board.attr.animationdelay)),this},stopAllAnimation:function(){var t;for(t in this.animationObjects)this.animationObjects.hasOwnProperty(t)&&d.exists(this.animationObjects[t])&&(this.animationObjects[t]=null,delete this.animationObjects[t]);return window.clearInterval(this.animationIntervalCode),delete this.animationIntervalCode,this},animate:function(){var t,r,i,s,o,n,a,h,c=0,l=null;for(r in this.animationObjects)if(this.animationObjects.hasOwnProperty(r)&&d.exists(this.animationObjects[r])){if(c+=1,i=this.animationObjects[r],i.animationPath&&(s=d.isFunction(i.animationPath)?i.animationPath((new Date).getTime()-i.animationStart):i.animationPath.pop(),!d.exists(s)||!d.isArray(s)&&isNaN(s)?delete i.animationPath:(i.setPositionDirectly(e.COORDS_BY_USER,s),i.prepareUpdate().update().updateRenderer(),l=i)),i.animationData){a=0;for(o in i.animationData)i.animationData.hasOwnProperty(o)&&(n=i.animationData[o].pop(),d.exists(n)?(a+=1,t={},t[o]=n,i.setAttribute(t)):delete i.animationData[n]);0===a&&delete i.animationData}d.exists(i.animationData)||d.exists(i.animationPath)||(this.animationObjects[r]=null,delete this.animationObjects[r],d.exists(i.animationCallback)&&(h=i.animationCallback,i.animationCallback=null,h()))}return 0===c?(window.clearInterval(this.animationIntervalCode),delete this.animationIntervalCode):this.update(l),this},migratePoint:function(t,e,r){var i,s,o,n,a;t=this.select(t),e=this.select(e),t.label.content&&this.removeObject(t.label.content);for(s in t.childElements)if(t.childElements.hasOwnProperty(s)){i=t.childElements[s],n=!1;for(o in i)i.hasOwnProperty(o)&&i[o]===t&&(i[o]=e,n=!0);for(n&&delete t.childElements[s],a=0;i.parents.length>a;a++)i.parents[a]===t.id&&(i.parents[a]=e.id);e.addChild(i)}return t.label.content&&(delete e.childElements[t.label.content.id],delete e.descendants[t.label.content.id]),r&&(e.label.content&&this.removeObject(e.label.content),delete this.elementsByName[e.name],e.name=t.name),this.removeObject(t),e.createLabel(),this.elementsByName[e.name]=e,this.update(),this},emulateColorblindness:function(e){var r,i;if(d.exists(e)||(e="none"),this.currentCBDef===e)return this;for(r in this.objects)this.objects.hasOwnProperty(r)&&(i=this.objects[r],"none"!==e?("none"===this.currentCBDef&&(i.visPropOriginal={strokecolor:i.visProp.strokecolor,fillcolor:i.visProp.fillcolor,highlightstrokecolor:i.visProp.highlightstrokecolor,highlightfillcolor:i.visProp.highlightfillcolor}),i.setAttribute({strokecolor:l.rgb2cb(i.visPropOriginal.strokecolor,e),fillcolor:l.rgb2cb(i.visPropOriginal.fillcolor,e),highlightstrokecolor:l.rgb2cb(i.visPropOriginal.highlightstrokecolor,e),highlightfillcolor:l.rgb2cb(i.visPropOriginal.highlightfillcolor,e)})):d.exists(i.visPropOriginal)&&t.extend(i.visProp,i.visPropOriginal));return this.currentCBDef=e,this.update(),this},select:function(t){var e=t;return"string"==typeof e&&(d.exists(this.objects[e])?e=this.objects[e]:d.exists(this.elementsByName[e])?e=this.elementsByName[e]:d.exists(this.groups[e])&&(e=this.groups[e])),e},hasPoint:function(e,r){var i=e,s=r,o=this.getBoundingBox();return t.exists(e)&&t.isArray(e.usrCoords)&&(i=e.usrCoords[1],s=e.usrCoords[2]),"number"==typeof i&&"number"==typeof s&&i>o[0]&&o[2]>i&&o[1]>s&&s>o[3]?!0:!1},updateCSSTransforms:function(){var t=this.containerObj,e=t,r=t;for(this.cssTransMat=p.getCSSTransformMatrix(e),e=e.offsetParent;e;){for(this.cssTransMat=o.matMatMult(p.getCSSTransformMatrix(e),this.cssTransMat),r=r.parentNode;r!==e;)this.cssTransMat=o.matMatMult(p.getCSSTransformMatrix(e),this.cssTransMat),r=r.parentNode;e=e.offsetParent}return this.cssTransMat=o.inverse(this.cssTransMat),this},__evt__down:function(){},__evt__mousedown:function(){},__evt__touchstart:function(){},__evt__up:function(){},__evt__mouseup:function(){},__evt__touchend:function(){},__evt__move:function(){},__evt__mousemove:function(){},__evt__touchmove:function(){},__evt__hit:function(){},__evt__mousehit:function(){},__evt__update:function(){},__evt__boundingbox:function(){},__evt:function(){},getPartialConstruction:function(){var t,e=[];for(t=1;arguments.length>t;t++)e.push(arguments[t])},createRoulette:function(t,e,r,i,o,n,h){var c=this,l=function(){var l,d=0,u=0,p=0,f=r,b=s.root(function(r){var i=t.X(f),s=t.Y(f),o=e.X(r),n=e.Y(r);return(i-o)*(i-o)+(s-n)*(s-n)},[0,2*Math.PI]),m=0,g=0,v=c.create("transform",[function(){return d}],{type:"rotate"}),C=c.create("transform",[function(){return d},function(){return t.X(f)},function(){return t.Y(f)}],{type:"rotate"}),y=c.create("transform",[function(){return u},function(){return p}],{type:"translate"}),P=function(t,e,r){var i=s.D(t.X)(e),o=s.D(t.Y)(e),n=s.D(t.X)(r),a=s.D(t.Y)(r),h=s.D(t.X)(.5*(e+r)),c=s.D(t.Y)(.5*(e+r)),l=Math.sqrt(i*i+o*o),d=Math.sqrt(n*n+a*a),u=Math.sqrt(h*h+c*c);return(l+4*u+d)*(r-e)/6},_=function(t){return l-P(e,b,t)},E=Math.PI/18,S=9*E,O=null;return this.rolling=function(){var r,n,O,T,x;m=f+o*i,l=P(t,f,m),g=s.root(_,b),r=new a(t.X(m),t.Y(m)),n=new a(e.X(g),e.Y(g)),O=new a(s.D(t.X)(m),s.D(t.Y)(m)),T=new a(s.D(e.X)(g),s.D(e.Y)(g)),x=a.C.div(O,T),d=Math.atan2(x.imaginary,x.real),x.div(a.C.abs(x)),x.mult(n),u=r.real-x.real,p=r.imaginary-x.imaginary,-E>d&&d>-S?(d=-E,C.applyOnce(h)):d>E&&S>d?(d=E,C.applyOnce(h)):(v.applyOnce(h),y.applyOnce(h),f=m,b=g),c.update()},this.start=function(){return n>0&&(O=window.setInterval(this.rolling,n)),this},this.stop=function(){return window.clearInterval(O),this},this};return new l}}),t.Board}),define("renderer/svg",["jxg","options","renderer/abstract","base/constants","utils/type","utils/env","utils/color","math/numerics"],function(t,e,r,i,s,o,n,a){return t.SVGRenderer=function(t,r){var i;for(this.type="svg",this.svgRoot=null,this.svgNamespace="http://www.w3.org/2000/svg",this.xlinkNamespace="http://www.w3.org/1999/xlink",this.container=t,this.container.style.MozUserSelect="none",this.container.style.overflow="hidden",""===this.container.style.position&&(this.container.style.position="relative"),this.svgRoot=this.container.ownerDocument.createElementNS(this.svgNamespace,"svg"),this.svgRoot.style.overflow="hidden",this.svgRoot.style.width=r.width,this.svgRoot.style.height=r.height,this.container.appendChild(this.svgRoot),this.defs=this.container.ownerDocument.createElementNS(this.svgNamespace,"defs"),this.svgRoot.appendChild(this.defs),this.filter=this.container.ownerDocument.createElementNS(this.svgNamespace,"filter"),this.filter.setAttributeNS(null,"id",this.container.id+"_"+"f1"),this.filter.setAttributeNS(null,"width","300%"),this.filter.setAttributeNS(null,"height","300%"),this.filter.setAttributeNS(null,"filterUnits","userSpaceOnUse"),this.feOffset=this.container.ownerDocument.createElementNS(this.svgNamespace,"feOffset"),this.feOffset.setAttributeNS(null,"result","offOut"),this.feOffset.setAttributeNS(null,"in","SourceAlpha"),this.feOffset.setAttributeNS(null,"dx","5"),this.feOffset.setAttributeNS(null,"dy","5"),this.filter.appendChild(this.feOffset),this.feGaussianBlur=this.container.ownerDocument.createElementNS(this.svgNamespace,"feGaussianBlur"),this.feGaussianBlur.setAttributeNS(null,"result","blurOut"),this.feGaussianBlur.setAttributeNS(null,"in","offOut"),this.feGaussianBlur.setAttributeNS(null,"stdDeviation","3"),this.filter.appendChild(this.feGaussianBlur),this.feBlend=this.container.ownerDocument.createElementNS(this.svgNamespace,"feBlend"),this.feBlend.setAttributeNS(null,"in","SourceGraphic"),this.feBlend.setAttributeNS(null,"in2","blurOut"),this.feBlend.setAttributeNS(null,"mode","normal"),this.filter.appendChild(this.feBlend),this.defs.appendChild(this.filter),this.layer=[],i=0;e.layer.numlayers>i;i++)this.layer[i]=this.container.ownerDocument.createElementNS(this.svgNamespace,"g"),this.svgRoot.appendChild(this.layer[i]);this.dashArray=["2, 2","5, 5","10, 10","20, 20","20, 10, 10, 10","20, 5, 10, 5"]},t.SVGRenderer.prototype=new r,t.extend(t.SVGRenderer.prototype,{_createArrowHead:function(t,e){var r,i,o,n=t.id+"Triangle";return s.exists(e)&&(n+=e),r=this.createPrim("marker",n),r.setAttributeNS(null,"stroke",s.evaluate(t.visProp.strokecolor)),r.setAttributeNS(null,"stroke-opacity",s.evaluate(t.visProp.strokeopacity)),r.setAttributeNS(null,"fill",s.evaluate(t.visProp.strokecolor)),r.setAttributeNS(null,"fill-opacity",s.evaluate(t.visProp.strokeopacity)),r.setAttributeNS(null,"orient","auto"),r.setAttributeNS(null,"markerUnits","strokeWidth"),o=parseInt(t.visProp.strokewidth,10),r.setAttributeNS(null,"viewBox",-o+" "+-o+" "+12*o+" "+12*o),r.setAttributeNS(null,"markerHeight",10),r.setAttributeNS(null,"markerWidth",10),i=this.container.ownerDocument.createElementNS(this.svgNamespace,"path"),"End"===e?(r.setAttributeNS(null,"refY",5),r.setAttributeNS(null,"refX",2),i.setAttributeNS(null,"d","M 10 0 L 0 5 L 10 10 z")):(r.setAttributeNS(null,"refY",5),r.setAttributeNS(null,"refX",8),i.setAttributeNS(null,"d","M 0 0 L 10 5 L 0 10 z")),r.appendChild(i),r},_setArrowAtts:function(t,e,r,i){t&&(t.setAttributeNS(null,"stroke",e),t.setAttributeNS(null,"stroke-opacity",r),t.setAttributeNS(null,"fill",e),t.setAttributeNS(null,"fill-opacity",r),t.setAttributeNS(null,"stroke-width",i))},updateTicks:function(t){var e,r,i,o,n,a="",h=t.ticks.length;for(e=0;h>e;e++)r=t.ticks[e],o=r[0],n=r[1],"number"==typeof o[0]&&"number"==typeof o[1]&&(a+="M "+o[0]+" "+n[0]+" L "+o[1]+" "+n[1]+" ");for(e=0;h>e;e++)r=t.ticks[e].scrCoords,t.ticks[e].major&&(t.board.needsFullUpdate||t.needsRegularUpdate)&&t.labels[e]&&t.labels[e].visProp.visible&&this.updateText(t.labels[e]);i=this.getElementById(t.id),s.exists(i)||(i=this.createPrim("path",t.id),this.appendChildPrim(i,t.visProp.layer),this.appendNodesToElement(t,"path")),i.setAttributeNS(null,"stroke",t.visProp.strokecolor),i.setAttributeNS(null,"stroke-opacity",t.visProp.strokeopacity),i.setAttributeNS(null,"stroke-width",t.visProp.strokewidth),this.updatePathPrim(i,a,t.board)},displayCopyright:function(t,e){var r,i=this.createPrim("text","licenseText");i.setAttributeNS(null,"x","20px"),i.setAttributeNS(null,"y",2+e+"px"),i.setAttributeNS(null,"style","font-family:Arial,Helvetica,sans-serif; font-size:"+e+"px; fill:#356AA0;  opacity:0.3;"),r=document.createTextNode(t),i.appendChild(r),this.appendChildPrim(i,0)},drawInternalText:function(t){var e=this.createPrim("text",t.id);return e.setAttributeNS(null,"class",t.visProp.cssclass),t.rendNodeText=document.createTextNode(""),e.appendChild(t.rendNodeText),this.appendChildPrim(e,t.visProp.layer),e},updateInternalText:function(t){var e,r=t.plaintext;isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])||(e=t.coords.scrCoords[1],t.visPropOld.left!==t.visProp.anchorx+e&&(t.rendNode.setAttributeNS(null,"x",e+"px"),"left"===t.visProp.anchorx?t.rendNode.setAttributeNS(null,"text-anchor","start"):"right"===t.visProp.anchorx?t.rendNode.setAttributeNS(null,"text-anchor","end"):"middle"===t.visProp.anchorx&&t.rendNode.setAttributeNS(null,"text-anchor","middle"),t.visPropOld.left=t.visProp.anchorx+e),e=t.coords.scrCoords[2],t.visPropOld.top!==t.visProp.anchory+e&&(t.rendNode.setAttributeNS(null,"y",t.coords.scrCoords[2]+.5*this.vOffsetText+"px"),"bottom"===t.visProp.anchory?t.rendNode.setAttributeNS(null,"dominant-baseline","text-after-edge"):"top"===t.visProp.anchory?t.rendNode.setAttributeNS(null,"dominant-baseline","text-before-edge"):"middle"===t.visProp.anchory&&t.rendNode.setAttributeNS(null,"dominant-baseline","middle"),t.visPropOld.top=t.visProp.anchory+e)),t.htmlStr!==r&&(t.rendNodeText.data=r,t.htmlStr=r),this.transformImage(t,t.transformations)},updateInternalTextStyle:function(t,e,r){this.setObjectFillColor(t,e,r)},drawImage:function(t){var e=this.createPrim("image",t.id);e.setAttributeNS(null,"preserveAspectRatio","none"),this.appendChildPrim(e,t.visProp.layer),t.rendNode=e,this.updateImage(t)},transformImage:function(t,e){var r,i,s=t.rendNode,o="",n=e.length;n>0&&(i=this.joinTransforms(t,e),r=[i[1][1],i[2][1],i[1][2],i[2][2],i[1][0],i[2][0]].join(","),o+=" matrix("+r+") ",s.setAttributeNS(null,"transform",o))},updateImageURL:function(t){var e=s.evaluate(t.url);t.rendNode.setAttributeNS(this.xlinkNamespace,"xlink:href",e)},updateImageStyle:function(t,e){var r=e?t.visProp.highlightcssclass:t.visProp.cssclass;t.rendNode.setAttributeNS(null,"class",r)},appendChildPrim:function(t,r){s.exists(r)?r>=e.layer.numlayers&&(r=e.layer.numlayers-1):r=0,this.layer[r].appendChild(t)},appendNodesToElement:function(t){t.rendNode=this.getElementById(t.id)},createPrim:function(t,e){var r=this.container.ownerDocument.createElementNS(this.svgNamespace,t);return r.setAttributeNS(null,"id",this.container.id+"_"+e),r.style.position="absolute","path"===t&&(r.setAttributeNS(null,"stroke-linecap","butt"),r.setAttributeNS(null,"stroke-linejoin","round")),r},remove:function(t){s.exists(t)&&s.exists(t.parentNode)&&t.parentNode.removeChild(t)},makeArrows:function(t){var e;(t.visPropOld.firstarrow!==t.visProp.firstarrow||t.visPropOld.lastarrow!==t.visProp.lastarrow)&&(t.visProp.firstarrow?(e=t.rendNodeTriangleStart,s.exists(e)?this.defs.appendChild(e):(e=this._createArrowHead(t,"End"),this.defs.appendChild(e),t.rendNodeTriangleStart=e,t.rendNode.setAttributeNS(null,"marker-start","url(#"+this.container.id+"_"+t.id+"TriangleEnd)"))):(e=t.rendNodeTriangleStart,s.exists(e)&&this.remove(e)),t.visProp.lastarrow?(e=t.rendNodeTriangleEnd,s.exists(e)?this.defs.appendChild(e):(e=this._createArrowHead(t,"Start"),this.defs.appendChild(e),t.rendNodeTriangleEnd=e,t.rendNode.setAttributeNS(null,"marker-end","url(#"+this.container.id+"_"+t.id+"TriangleStart)"))):(e=t.rendNodeTriangleEnd,s.exists(e)&&this.remove(e)),t.visPropOld.firstarrow=t.visProp.firstarrow,t.visPropOld.lastarrow=t.visProp.lastarrow)},updateEllipsePrim:function(t,e,r,i,s){t.setAttributeNS(null,"cx",e),t.setAttributeNS(null,"cy",r),t.setAttributeNS(null,"rx",Math.abs(i)),t.setAttributeNS(null,"ry",Math.abs(s))},updateLinePrim:function(t,e,r,i,s){isNaN(e+r+i+s)||(t.setAttributeNS(null,"x1",e),t.setAttributeNS(null,"y1",r),t.setAttributeNS(null,"x2",i),t.setAttributeNS(null,"y2",s))},updatePathPrim:function(t,e){""===e&&(e="M 0 0"),t.setAttributeNS(null,"d",e)},updatePathStringPoint:function(t,e,r){var i="",s=t.coords.scrCoords,o=.5*e*Math.sqrt(3),n=.5*e;return"x"===r?i=" M "+(s[1]-e)+" "+(s[2]-e)+" L "+(s[1]+e)+" "+(s[2]+e)+" M "+(s[1]+e)+" "+(s[2]-e)+" L "+(s[1]-e)+" "+(s[2]+e):"+"===r?i=" M "+(s[1]-e)+" "+s[2]+" L "+(s[1]+e)+" "+s[2]+" M "+s[1]+" "+(s[2]-e)+" L "+s[1]+" "+(s[2]+e):"<>"===r?i=" M "+(s[1]-e)+" "+s[2]+" L "+s[1]+" "+(s[2]+e)+" L "+(s[1]+e)+" "+s[2]+" L "+s[1]+" "+(s[2]-e)+" Z ":"^"===r?i=" M "+s[1]+" "+(s[2]-e)+" L "+(s[1]-o)+" "+(s[2]+n)+" L "+(s[1]+o)+" "+(s[2]+n)+" Z ":"v"===r?i=" M "+s[1]+" "+(s[2]+e)+" L "+(s[1]-o)+" "+(s[2]-n)+" L "+(s[1]+o)+" "+(s[2]-n)+" Z ":">"===r?i=" M "+(s[1]+e)+" "+s[2]+" L "+(s[1]-n)+" "+(s[2]-o)+" L "+(s[1]-n)+" "+(s[2]+o)+" Z ":"<"===r&&(i=" M "+(s[1]-e)+" "+s[2]+" L "+(s[1]+n)+" "+(s[2]-o)+" L "+(s[1]+n)+" "+(s[2]+o)+" Z "),i},updatePathStringPrim:function(t){var e,r,i,s=" M ",o=" L ",n=" C ",h=s,c=5e3,l="",d="plot"!==t.visProp.curvetype;if(0>=t.numberPoints)return"";if(i=Math.min(t.points.length,t.numberPoints),1===t.bezierDegree)for(d&&t.board.options.curve.RDPsmoothing&&(t.points=a.RamerDouglasPeuker(t.points,.5)),e=0;i>e;e++)r=t.points[e].scrCoords,isNaN(r[1])||isNaN(r[2])?h=s:(r[1]>c?r[1]=c:-c>r[1]&&(r[1]=-c),r[2]>c?r[2]=c:-c>r[2]&&(r[2]=-c),l+=h+r[1]+" "+r[2],h=o);else if(3===t.bezierDegree)for(e=0;i>e;)r=t.points[e].scrCoords,isNaN(r[1])||isNaN(r[2])?h=s:(l+=h+r[1]+" "+r[2],h===n&&(e+=1,r=t.points[e].scrCoords,l+=" "+r[1]+" "+r[2],e+=1,r=t.points[e].scrCoords,l+=" "+r[1]+" "+r[2]),h=n),e+=1;return l},updatePathStringBezierPrim:function(t){var e,r,i,s,o,n,h,c=" M ",l=" C ",d=c,u=5e3,p="",f=t.visProp.strokewidth,b="plot"!==t.visProp.curvetype;if(0>=t.numberPoints)return"";for(b&&t.board.options.curve.RDPsmoothing&&(t.points=a.RamerDouglasPeuker(t.points,.5)),h=Math.min(t.points.length,t.numberPoints),r=1;3>r;r++)for(d=c,e=0;h>e;e++)s=t.points[e].scrCoords,isNaN(s[1])||isNaN(s[2])?d=c:(s[1]>u?s[1]=u:-u>s[1]&&(s[1]=-u),s[2]>u?s[2]=u:-u>s[2]&&(s[2]=-u),d===c?p+=[d,s[1]," ",s[2]].join(""):(i=2*r,p+=[d,o+.333*(s[1]-o)+f*(i*Math.random()-r)," ",n+.333*(s[2]-n)+f*(i*Math.random()-r)," ",o+.666*(s[1]-o)+f*(i*Math.random()-r)," ",n+.666*(s[2]-n)+f*(i*Math.random()-r)," ",s[1]," ",s[2]].join("")),d=l,o=s[1],n=s[2]);return p},updatePolygonPrim:function(t,e){var r,i,s="",o=e.vertices.length;for(t.setAttributeNS(null,"stroke","none"),r=0;o-1>r;r++){if(!e.vertices[r].isReal)return t.setAttributeNS(null,"points",""),void 0;i=e.vertices[r].coords.scrCoords,s=s+i[1]+","+i[2],o-2>r&&(s+=" ")}-1===s.indexOf("NaN")&&t.setAttributeNS(null,"points",s)},updateRectPrim:function(t,e,r,i,s){t.setAttributeNS(null,"x",e),t.setAttributeNS(null,"y",r),t.setAttributeNS(null,"width",i),t.setAttributeNS(null,"height",s)},setPropertyPrim:function(t,e,r){"stroked"!==e&&t.setAttributeNS(null,e,r)},show:function(t){var e;t&&t.rendNode&&(e=t.rendNode,e.setAttributeNS(null,"display","inline"),e.style.visibility="inherit")},hide:function(t){var e;t&&t.rendNode&&(e=t.rendNode,e.setAttributeNS(null,"display","none"),e.style.visibility="hidden")},setBuffering:function(t,e){t.rendNode.setAttribute("buffered-rendering",e)},setDashStyle:function(t){var e=t.visProp.dash,r=t.rendNode;t.visProp.dash>0?r.setAttributeNS(null,"stroke-dasharray",this.dashArray[e-1]):r.hasAttributeNS(null,"stroke-dasharray")&&r.removeAttributeNS(null,"stroke-dasharray")},setGradient:function(t){var e,r,i,o,n,a,h,c,l,d=t.rendNode;r=s.evaluate(t.visProp.fillopacity),r=r>0?r:0,e=s.evaluate(t.visProp.fillcolor),"linear"===t.visProp.gradient?(i=this.createPrim("linearGradient",t.id+"_gradient"),a="0%",h="100%",c="0%",l="0%",i.setAttributeNS(null,"x1",a),i.setAttributeNS(null,"x2",h),i.setAttributeNS(null,"y1",c),i.setAttributeNS(null,"y2",l),o=this.createPrim("stop",t.id+"_gradient1"),o.setAttributeNS(null,"offset","0%"),o.setAttributeNS(null,"style","stop-color:"+e+";stop-opacity:"+r),n=this.createPrim("stop",t.id+"_gradient2"),n.setAttributeNS(null,"offset","100%"),n.setAttributeNS(null,"style","stop-color:"+t.visProp.gradientsecondcolor+";stop-opacity:"+t.visProp.gradientsecondopacity),i.appendChild(o),i.appendChild(n),this.defs.appendChild(i),d.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+t.id+"_gradient)"),t.gradNode1=o,t.gradNode2=n):"radial"===t.visProp.gradient?(i=this.createPrim("radialGradient",t.id+"_gradient"),i.setAttributeNS(null,"cx","50%"),i.setAttributeNS(null,"cy","50%"),i.setAttributeNS(null,"r","50%"),i.setAttributeNS(null,"fx",100*t.visProp.gradientpositionx+"%"),i.setAttributeNS(null,"fy",100*t.visProp.gradientpositiony+"%"),o=this.createPrim("stop",t.id+"_gradient1"),o.setAttributeNS(null,"offset","0%"),o.setAttributeNS(null,"style","stop-color:"+t.visProp.gradientsecondcolor+";stop-opacity:"+t.visProp.gradientsecondopacity),n=this.createPrim("stop",t.id+"_gradient2"),n.setAttributeNS(null,"offset","100%"),n.setAttributeNS(null,"style","stop-color:"+e+";stop-opacity:"+r),i.appendChild(o),i.appendChild(n),this.defs.appendChild(i),d.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+t.id+"_gradient)"),t.gradNode1=o,t.gradNode2=n):d.removeAttributeNS(null,"style")},updateGradient:function(t){var e,r,i=t.gradNode1,o=t.gradNode2;s.exists(i)&&s.exists(o)&&(r=s.evaluate(t.visProp.fillopacity),r=r>0?r:0,e=s.evaluate(t.visProp.fillcolor),"linear"===t.visProp.gradient?(i.setAttributeNS(null,"style","stop-color:"+e+";stop-opacity:"+r),o.setAttributeNS(null,"style","stop-color:"+t.visProp.gradientsecondcolor+";stop-opacity:"+t.visProp.gradientsecondopacity)):"radial"===t.visProp.gradient&&(i.setAttributeNS(null,"style","stop-color:"+t.visProp.gradientsecondcolor+";stop-opacity:"+t.visProp.gradientsecondopacity),o.setAttributeNS(null,"style","stop-color:"+e+";stop-opacity:"+r)))
},setObjectFillColor:function(e,r,i){var o,a,h,c,l=s.evaluate(r),d=s.evaluate(i);d=d>0?d:0,(e.visPropOld.fillcolor!==l||e.visPropOld.fillopacity!==d)&&(s.exists(l)&&l!==!1&&(9!==l.length?(a=l,c=d):(h=n.rgba2rgbo(l),a=h[0],c=d*h[1]),o=e.rendNode,"none"!==a?o.setAttributeNS(null,"fill",a):c=0,e.type===t.OBJECT_TYPE_IMAGE?o.setAttributeNS(null,"opacity",c):o.setAttributeNS(null,"fill-opacity",c),s.exists(e.visProp.gradient)&&this.updateGradient(e)),e.visPropOld.fillcolor=l,e.visPropOld.fillopacity=d)},setObjectStrokeColor:function(t,e,r){var o,a,h,c,l=s.evaluate(e),d=s.evaluate(r);d=d>0?d:0,(t.visPropOld.strokecolor!==l||t.visPropOld.strokeopacity!==d)&&(s.exists(l)&&l!==!1&&(9!==l.length?(o=l,h=d):(a=n.rgba2rgbo(l),o=a[0],h=d*a[1]),c=t.rendNode,t.type===i.OBJECT_TYPE_TEXT?"html"===t.visProp.display?(c.style.color=o,c.style.opacity=h):(c.setAttributeNS(null,"style","fill:"+o),c.setAttributeNS(null,"style","fill-opacity:"+h)):(c.setAttributeNS(null,"stroke",o),c.setAttributeNS(null,"stroke-opacity",h)),t.type===i.OBJECT_TYPE_ARROW?this._setArrowAtts(t.rendNodeTriangle,o,h,t.visProp.strokewidth):(t.elementClass===i.OBJECT_CLASS_CURVE||t.elementClass===i.OBJECT_CLASS_LINE)&&(t.visProp.firstarrow&&this._setArrowAtts(t.rendNodeTriangleStart,o,h,t.visProp.strokewidth),t.visProp.lastarrow&&this._setArrowAtts(t.rendNodeTriangleEnd,o,h,t.visProp.strokewidth))),t.visPropOld.strokecolor=l,t.visPropOld.strokeopacity=d)},setObjectStrokeWidth:function(t,e){var r,o=s.evaluate(e);isNaN(o)||t.visPropOld.strokewidth===o||(r=t.rendNode,this.setPropertyPrim(r,"stroked","true"),s.exists(o)&&(this.setPropertyPrim(r,"stroke-width",o+"px"),t.type===i.OBJECT_TYPE_ARROW?this._setArrowAtts(t.rendNodeTriangle,t.visProp.strokecolor,t.visProp.strokeopacity,o):(t.elementClass===i.OBJECT_CLASS_CURVE||t.elementClass===i.OBJECT_CLASS_LINE)&&(t.visProp.firstarrow&&this._setArrowAtts(t.rendNodeTriangleStart,t.visProp.strokecolor,t.visProp.strokeopacity,o),t.visProp.lastarrow&&this._setArrowAtts(t.rendNodeTriangleEnd,t.visProp.strokecolor,t.visProp.strokeopacity,o))),t.visPropOld.strokewidth=o)},setShadow:function(t){t.visPropOld.shadow!==t.visProp.shadow&&(s.exists(t.rendNode)&&(t.visProp.shadow?t.rendNode.setAttributeNS(null,"filter","url(#"+this.container.id+"_"+"f1)"):t.rendNode.removeAttributeNS(null,"filter")),t.visPropOld.shadow=t.visProp.shadow)},suspendRedraw:function(){},unsuspendRedraw:function(){},resize:function(t,e){this.svgRoot.style.width=parseFloat(t)+"px",this.svgRoot.style.height=parseFloat(e)+"px"},createTouchpoints:function(t){var e,r,i,s;for(this.touchpoints=[],e=0;t>e;e++)r="touchpoint1_"+e,s=this.createPrim("path",r),this.appendChildPrim(s,19),s.setAttributeNS(null,"d","M 0 0"),this.touchpoints.push(s),this.setPropertyPrim(s,"stroked","true"),this.setPropertyPrim(s,"stroke-width","1px"),s.setAttributeNS(null,"stroke","#000000"),s.setAttributeNS(null,"stroke-opacity",1),s.setAttributeNS(null,"display","none"),i="touchpoint2_"+e,s=this.createPrim("ellipse",i),this.appendChildPrim(s,19),this.updateEllipsePrim(s,0,0,0,0),this.touchpoints.push(s),this.setPropertyPrim(s,"stroked","true"),this.setPropertyPrim(s,"stroke-width","1px"),s.setAttributeNS(null,"stroke","#000000"),s.setAttributeNS(null,"stroke-opacity",1),s.setAttributeNS(null,"fill","#ffffff"),s.setAttributeNS(null,"fill-opacity",0),s.setAttributeNS(null,"display","none")},showTouchpoint:function(t){this.touchpoints&&t>=0&&this.touchpoints.length>2*t&&(this.touchpoints[2*t].setAttributeNS(null,"display","inline"),this.touchpoints[2*t+1].setAttributeNS(null,"display","inline"))},hideTouchpoint:function(t){this.touchpoints&&t>=0&&this.touchpoints.length>2*t&&(this.touchpoints[2*t].setAttributeNS(null,"display","none"),this.touchpoints[2*t+1].setAttributeNS(null,"display","none"))},updateTouchpoint:function(t,e){var r,i,s=37;this.touchpoints&&t>=0&&this.touchpoints.length>2*t&&(r=e[0],i=e[1],this.touchpoints[2*t].setAttributeNS(null,"d","M "+(r-s)+" "+i+" "+"L "+(r+s)+" "+i+" "+"M "+r+" "+(i-s)+" "+"L "+r+" "+(i+s)),this.updateEllipsePrim(this.touchpoints[2*t+1],e[0],e[1],25,25))}}),t.SVGRenderer}),define("renderer/vml",["jxg","renderer/abstract","base/constants","utils/type","utils/color","math/math","math/numerics"],function(t,e,r,i,s,o,n){return t.VMLRenderer=function(e){this.type="vml",this.container=e,this.container.style.overflow="hidden",this.container.onselectstart=function(){return!1},this.resolution=10,i.exists(t.vmlStylesheet)||(e.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml"),t.vmlStylesheet=this.container.ownerDocument.createStyleSheet(),t.vmlStylesheet.addRule(".jxgvml","behavior:url(#default#VML)"));try{e.ownerDocument.namespaces.jxgvml||e.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml"),this.createNode=function(t){return e.ownerDocument.createElement("<jxgvml:"+t+' class="jxgvml">')}}catch(r){this.createNode=function(t){return e.ownerDocument.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="jxgvml">')}}this.dashArray=["Solid","1 1","ShortDash","Dash","LongDash","ShortDashDot","LongDashDot"]},t.VMLRenderer.prototype=new e,t.extend(t.VMLRenderer.prototype,{_setAttr:function(e,r,i,s){try{8===document.documentMode?e[r]=i:e.setAttribute(r,i,s)}catch(o){t.debug("_setAttr: "+r+" "+i+"<br>\n")}},updateTicks:function(t){var e,r,s,o,n,a,h=this.resolution,c=[];for(r=t.ticks.length,e=0;r>e;e++)s=t.ticks[e],n=s[0],a=s[1],"number"==typeof n[0]&&"number"==typeof n[1]&&c.push(" m "+Math.round(h*n[0])+", "+Math.round(h*a[0])+" l "+Math.round(h*n[1])+", "+Math.round(h*a[1])+" ");for(e=0;r>e;e++)s=t.ticks[e].scrCoords,t.ticks[e].major&&(t.board.needsFullUpdate||t.needsRegularUpdate)&&t.labels[e]&&t.labels[e].visProp.visible&&this.updateText(t.labels[e]);i.exists(t)||(o=this.createPrim("path",t.id),this.appendChildPrim(o,t.visProp.layer),this.appendNodesToElement(t,"path")),this._setAttr(t.rendNode,"stroked","true"),this._setAttr(t.rendNode,"strokecolor",t.visProp.strokecolor,1),this._setAttr(t.rendNode,"strokeweight",t.visProp.strokewidth),this._setAttr(t.rendNodeStroke,"opacity",100*t.visProp.strokeopacity+"%"),this.updatePathPrim(t.rendNode,c,t.board)},displayCopyright:function(t,e){var r,i;r=this.createNode("textbox"),r.style.position="absolute",this._setAttr(r,"id",this.container.id+"_"+"licenseText"),r.style.left=20,r.style.top=2,r.style.fontSize=e,r.style.color="#356AA0",r.style.fontFamily="Arial,Helvetica,sans-serif",this._setAttr(r,"opacity","30%"),r.style.filter="alpha(opacity = 30)",i=document.createTextNode(t),r.appendChild(i),this.appendChildPrim(r,0)},drawInternalText:function(t){var e;return e=this.createNode("textbox"),e.style.position="absolute",t.rendNodeText=document.createTextNode(""),e.appendChild(t.rendNodeText),this.appendChildPrim(e,9),e},updateInternalText:function(t){var e=t.plaintext;isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])||("right"===t.visProp.anchorx?(t.rendNode.style.right=Math.floor(t.board.canvasWidth-t.coords.scrCoords[1])+"px",t.rendNode.style.left="auto"):"middle"===t.visProp.anchorx?(t.rendNode.style.left=Math.floor(t.coords.scrCoords[1]-.5*t.size[0])+"px",t.rendNode.style.right="auto"):(t.rendNode.style.left=Math.floor(t.coords.scrCoords[1])+"px",t.rendNode.style.right="auto"),t.rendNode.style.top="top"===t.visProp.anchory?Math.floor(t.coords.scrCoords[2]+this.vOffsetText)+"px":"middle"===t.visProp.anchory?Math.floor(t.coords.scrCoords[2]-.5*t.size[1]+this.vOffsetText)+"px":Math.floor(t.coords.scrCoords[2]-t.size[1]+this.vOffsetText)+"px"),t.htmlStr!==e&&(t.rendNodeText.data=e,t.htmlStr=e),this.transformImage(t,t.transformations)},drawImage:function(t){var e;e=this.container.ownerDocument.createElement("img"),e.style.position="absolute",this._setAttr(e,"id",this.container.id+"_"+t.id),this.container.appendChild(e),this.appendChildPrim(e,t.visProp.layer),e.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingMethod='auto expand')",t.rendNode=e,this.updateImage(t)},transformImage:function(t,e){var i,s,n,a,h,c,l,d=t.rendNode,u=[],p=e.length;if(t.type===r.OBJECT_TYPE_TEXT&&t.updateSize(),p>0){for(l=""+t.rendNode.style.filter,l.match(/DXImageTransform/)||(d.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingMethod='auto expand') "+l),i=this.joinTransforms(t,e),u[0]=o.matVecMult(i,t.coords.scrCoords),u[0][1]/=u[0][0],u[0][2]/=u[0][0],u[1]=o.matVecMult(i,[1,t.coords.scrCoords[1]+t.size[0],t.coords.scrCoords[2]]),u[1][1]/=u[1][0],u[1][2]/=u[1][0],u[2]=o.matVecMult(i,[1,t.coords.scrCoords[1]+t.size[0],t.coords.scrCoords[2]-t.size[1]]),u[2][1]/=u[2][0],u[2][2]/=u[2][0],u[3]=o.matVecMult(i,[1,t.coords.scrCoords[1],t.coords.scrCoords[2]-t.size[1]]),u[3][1]/=u[3][0],u[3][2]/=u[3][0],s=u[0][1],a=u[0][1],n=u[0][2],h=u[0][2],c=1;4>c;c++)s=Math.max(s,u[c][1]),a=Math.min(a,u[c][1]),n=Math.max(n,u[c][2]),h=Math.min(h,u[c][2]);d.style.left=Math.floor(a)+"px",d.style.top=Math.floor(h)+"px",d.filters.item(0).M11=i[1][1],d.filters.item(0).M12=i[1][2],d.filters.item(0).M21=i[2][1],d.filters.item(0).M22=i[2][2]}},updateImageURL:function(t){var e=i.evaluate(t.url);this._setAttr(t.rendNode,"src",e)},appendChildPrim:function(t,e){i.exists(e)||(e=0),t.style.zIndex=e,this.container.appendChild(t)},appendNodesToElement:function(t,e){("shape"===e||"path"===e||"polygon"===e)&&(t.rendNodePath=this.getElementById(t.id+"_path")),t.rendNodeFill=this.getElementById(t.id+"_fill"),t.rendNodeStroke=this.getElementById(t.id+"_stroke"),t.rendNodeShadow=this.getElementById(t.id+"_shadow"),t.rendNode=this.getElementById(t.id)},createPrim:function(t,e){var r,i,s=this.createNode("fill"),o=this.createNode("stroke"),n=this.createNode("shadow");return this._setAttr(s,"id",this.container.id+"_"+e+"_fill"),this._setAttr(o,"id",this.container.id+"_"+e+"_stroke"),this._setAttr(n,"id",this.container.id+"_"+e+"_shadow"),"circle"===t||"ellipse"===t?(r=this.createNode("oval"),r.appendChild(s),r.appendChild(o),r.appendChild(n)):"polygon"===t||"path"===t||"shape"===t||"line"===t?(r=this.createNode("shape"),r.appendChild(s),r.appendChild(o),r.appendChild(n),i=this.createNode("path"),this._setAttr(i,"id",this.container.id+"_"+e+"_path"),r.appendChild(i)):(r=this.createNode(t),r.appendChild(s),r.appendChild(o),r.appendChild(n)),r.style.position="absolute",r.style.left="0px",r.style.top="0px",this._setAttr(r,"id",this.container.id+"_"+e),r},remove:function(t){i.exists(t)&&t.removeNode(!0)},makeArrows:function(t){var e;(t.visPropOld.firstarrow!==t.visProp.firstarrow||t.visPropOld.lastarrow!==t.visProp.lastarrow)&&(t.visProp.firstarrow?(e=t.rendNodeStroke,this._setAttr(e,"startarrow","block"),this._setAttr(e,"startarrowlength","long")):(e=t.rendNodeStroke,i.exists(e)&&this._setAttr(e,"startarrow","none")),t.visProp.lastarrow?(e=t.rendNodeStroke,this._setAttr(e,"id",this.container.id+"_"+t.id+"stroke"),this._setAttr(e,"endarrow","block"),this._setAttr(e,"endarrowlength","long")):(e=t.rendNodeStroke,i.exists(e)&&this._setAttr(e,"endarrow","none")),t.visPropOld.firstarrow=t.visProp.firstarrow,t.visPropOld.lastarrow=t.visProp.lastarrow)},updateEllipsePrim:function(t,e,r,i,s){t.style.left=Math.floor(e-i)+"px",t.style.top=Math.floor(r-s)+"px",t.style.width=Math.floor(2*Math.abs(i))+"px",t.style.height=Math.floor(2*Math.abs(s))+"px"},updateLinePrim:function(t,e,r,i,s,o){var n,a=this.resolution;isNaN(e+r+i+s)||(n=["m ",Math.floor(a*e),", ",Math.floor(a*r)," l ",Math.floor(a*i),", ",Math.floor(a*s)],this.updatePathPrim(t,n,o))},updatePathPrim:function(t,e,r){var i=r.canvasWidth,s=r.canvasHeight;0>=e.length&&(e=["m 0,0"]),t.style.width=i,t.style.height=s,this._setAttr(t,"coordsize",[Math.floor(this.resolution*i),Math.floor(this.resolution*s)].join(",")),this._setAttr(t,"path",e.join(""))},updatePathStringPoint:function(t,e,r){var i=[],s=Math.round,o=t.coords.scrCoords,n=.5*e*Math.sqrt(3),a=.5*e,h=this.resolution;return"x"===r?i.push([" m ",s(h*(o[1]-e)),", ",s(h*(o[2]-e))," l ",s(h*(o[1]+e)),", ",s(h*(o[2]+e))," m ",s(h*(o[1]+e)),", ",s(h*(o[2]-e))," l ",s(h*(o[1]-e)),", ",s(h*(o[2]+e))].join("")):"+"===r?i.push([" m ",s(h*(o[1]-e)),", ",s(h*o[2])," l ",s(h*(o[1]+e)),", ",s(h*o[2])," m ",s(h*o[1]),", ",s(h*(o[2]-e))," l ",s(h*o[1]),", ",s(h*(o[2]+e))].join("")):"<>"===r?i.push([" m ",s(h*(o[1]-e)),", ",s(h*o[2])," l ",s(h*o[1]),", ",s(h*(o[2]+e))," l ",s(h*(o[1]+e)),", ",s(h*o[2])," l ",s(h*o[1]),", ",s(h*(o[2]-e))," x e "].join("")):"^"===r?i.push([" m ",s(h*o[1]),", ",s(h*(o[2]-e))," l ",s(h*(o[1]-n)),", ",s(h*(o[2]+a))," l ",s(h*(o[1]+n)),", ",s(h*(o[2]+a))," x e "].join("")):"v"===r?i.push([" m ",s(h*o[1]),", ",s(h*(o[2]+e))," l ",s(h*(o[1]-n)),", ",s(h*(o[2]-a))," l ",s(h*(o[1]+n)),", ",s(h*(o[2]-a))," x e "].join("")):">"===r?i.push([" m ",s(h*(o[1]+e)),", ",s(h*o[2])," l ",s(h*(o[1]-a)),", ",s(h*(o[2]-n))," l ",s(h*(o[1]-a)),", ",s(h*(o[2]+n))," l ",s(h*(o[1]+e)),", ",s(h*o[2])].join("")):"<"===r&&i.push([" m ",s(h*(o[1]-e)),", ",s(h*o[2])," l ",s(h*(o[1]+a)),", ",s(h*(o[2]-n))," l ",s(h*(o[1]+a)),", ",s(h*(o[2]+n))," x e "].join("")),i},updatePathStringPrim:function(t){var e,r,i=[],s=this.resolution,o=Math.round,a=" m ",h=" l ",c=" c ",l=a,d="plot"!==t.visProp.curvetype,u=Math.min(t.numberPoints,8192);if(0>=t.numberPoints)return"";if(u=Math.min(u,t.points.length),1===t.bezierDegree)for(d&&t.board.options.curve.RDPsmoothing&&(t.points=n.RamerDouglasPeuker(t.points,1)),e=0;u>e;e++)r=t.points[e].scrCoords,isNaN(r[1])||isNaN(r[2])?l=a:(r[1]>2e4?r[1]=2e4:-2e4>r[1]&&(r[1]=-2e4),r[2]>2e4?r[2]=2e4:-2e4>r[2]&&(r[2]=-2e4),i.push([l,o(s*r[1]),", ",o(s*r[2])].join("")),l=h);else if(3===t.bezierDegree)for(e=0;u>e;)r=t.points[e].scrCoords,isNaN(r[1])||isNaN(r[2])?l=a:(i.push([l,o(s*r[1]),", ",o(s*r[2])].join("")),l===c&&(e+=1,r=t.points[e].scrCoords,i.push([" ",o(s*r[1]),", ",o(s*r[2])].join("")),e+=1,r=t.points[e].scrCoords,i.push([" ",o(s*r[1]),", ",o(s*r[2])].join(""))),l=c),e+=1;return i.push(" e"),i},updatePathStringBezierPrim:function(t){var e,r,i,s,o,a,h=[],c=t.visProp.strokewidth,l=this.resolution,d=Math.round,u=" m ",p=" c ",f=u,b="plot"!==t.visProp.curvetype,m=Math.min(t.numberPoints,8192);if(0>=t.numberPoints)return"";for(b&&t.board.options.curve.RDPsmoothing&&(t.points=n.RamerDouglasPeuker(t.points,1)),m=Math.min(m,t.points.length),r=1;3>r;r++)for(f=u,e=0;m>e;e++)s=t.points[e].scrCoords,isNaN(s[1])||isNaN(s[2])?f=u:(s[1]>2e4?s[1]=2e4:-2e4>s[1]&&(s[1]=-2e4),s[2]>2e4?s[2]=2e4:-2e4>s[2]&&(s[2]=-2e4),f===u?h.push([f,d(l*s[1])," ",d(l*s[2])].join("")):(i=2*r,h.push([f,d(l*(o+.333*(s[1]-o)+c*(i*Math.random()-r)))," ",d(l*(a+.333*(s[2]-a)+c*(i*Math.random()-r)))," ",d(l*(o+.666*(s[1]-o)+c*(i*Math.random()-r)))," ",d(l*(a+.666*(s[2]-a)+c*(i*Math.random()-r)))," ",d(l*s[1])," ",d(l*s[2])].join(""))),f=p,o=s[1],a=s[2]);return h.push(" e"),h},updatePolygonPrim:function(t,e){var r,i,s=e.vertices.length,o=this.resolution,n=[];if(this._setAttr(t,"stroked","false"),i=e.vertices[0].coords.scrCoords,!isNaN(i[1]+i[2])){for(n.push(["m ",Math.floor(o*i[1]),",",Math.floor(o*i[2])," l "].join("")),r=1;s-1>r;r++){if(!e.vertices[r].isReal)return this.updatePathPrim(t,"",e.board),void 0;if(i=e.vertices[r].coords.scrCoords,isNaN(i[1]+i[2]))return;n.push(Math.floor(o*i[1])+","+Math.floor(o*i[2])),s-2>r&&n.push(", ")}n.push(" x e"),this.updatePathPrim(t,n,e.board)}},updateRectPrim:function(t,e,r,i,s){t.style.left=Math.floor(e)+"px",t.style.top=Math.floor(r)+"px",i>=0&&(t.style.width=i+"px"),s>=0&&(t.style.height=s+"px")},setPropertyPrim:function(t,e,r){var s,o="";switch(e){case"stroke":o="strokecolor";break;case"stroke-width":o="strokeweight";break;case"stroke-dasharray":o="dashstyle"}""!==o&&(s=i.evaluate(r),this._setAttr(t,o,s))},show:function(t){t&&t.rendNode&&(t.rendNode.style.visibility="inherit")},hide:function(t){t&&t.rendNode&&(t.rendNode.style.visibility="hidden")},setDashStyle:function(t,e){var r;e.dash>=0&&(r=t.rendNodeStroke,this._setAttr(r,"dashstyle",this.dashArray[e.dash]))},setGradient:function(t){var e=t.rendNodeFill;"linear"===t.visProp.gradient?(this._setAttr(e,"type","gradient"),this._setAttr(e,"color2",t.visProp.gradientsecondcolor),this._setAttr(e,"opacity2",t.visProp.gradientsecondopacity),this._setAttr(e,"angle",t.visProp.gradientangle)):"radial"===t.visProp.gradient?(this._setAttr(e,"type","gradientradial"),this._setAttr(e,"color2",t.visProp.gradientsecondcolor),this._setAttr(e,"opacity2",t.visProp.gradientsecondopacity),this._setAttr(e,"focusposition",100*t.visProp.gradientpositionx+"%,"+100*t.visProp.gradientpositiony+"%"),this._setAttr(e,"focussize","0,0")):this._setAttr(e,"type","solid")},setObjectFillColor:function(t,e,o){var n,a,h,c,l=i.evaluate(e),d=i.evaluate(o);t.rendNode,d=d>0?d:0,(t.visPropOld.fillcolor!==l||t.visPropOld.fillopacity!==d)&&(i.exists(l)&&l!==!1&&(9!==l.length?(n=l,h=d):(a=s.rgba2rgbo(l),n=a[0],h=d*a[1]),"none"===n||n===!1?this._setAttr(t.rendNode,"filled","false"):(this._setAttr(t.rendNode,"filled","true"),this._setAttr(t.rendNode,"fillcolor",n),i.exists(h)&&t.rendNodeFill&&this._setAttr(t.rendNodeFill,"opacity",100*h+"%")),t.type===r.OBJECT_TYPE_IMAGE&&(c=""+t.rendNode.style.filter,c.match(/alpha/)?t.rendNode.style.filter=c.replace(/alpha\(opacity *= *[0-9\.]+\)/,"alpha(opacity = "+100*h+")"):t.rendNode.style.filter+=" alpha(opacity = "+100*h+")")),t.visPropOld.fillcolor=l,t.visPropOld.fillopacity=d)},setObjectStrokeColor:function(t,e,s){var o,n,a,h,c=i.evaluate(e),l=i.evaluate(s),d=t.rendNode;l=l>0?l:0,(t.visPropOld.strokecolor!==c||t.visPropOld.strokeopacity!==l)&&(i.exists(c)&&c!==!1&&(9!==c.length?(o=c,a=l):(n=e.rgba2rgbo(c),o=n[0],a=l*n[1]),t.type===r.OBJECT_TYPE_TEXT?(a=Math.round(100*a),d.style.filter=" alpha(opacity = "+a+")",d.style.color=o):(o!==!1&&(this._setAttr(d,"stroked","true"),this._setAttr(d,"strokecolor",o)),h=t.rendNodeStroke,i.exists(a)&&t.type!==r.OBJECT_TYPE_IMAGE&&this._setAttr(h,"opacity",100*a+"%"))),t.visPropOld.strokecolor=c,t.visPropOld.strokeopacity=l)},setObjectStrokeWidth:function(t,e){var r,s=i.evaluate(e);isNaN(s)||t.visPropOld.strokewidth===s||(r=t.rendNode,this.setPropertyPrim(r,"stroked","true"),i.exists(s)&&this.setPropertyPrim(r,"stroke-width",s),t.visPropOld.strokewidth=s)},setShadow:function(t){var e=t.rendNodeShadow;e&&t.visPropOld.shadow!==t.visProp.shadow&&(t.visProp.shadow?(this._setAttr(e,"On","True"),this._setAttr(e,"Offset","3pt,3pt"),this._setAttr(e,"Opacity","60%"),this._setAttr(e,"Color","#aaaaaa")):this._setAttr(e,"On","False"),t.visPropOld.shadow=t.visProp.shadow)},suspendRedraw:function(){this.container.style.display="none"},unsuspendRedraw:function(){this.container.style.display=""}}),t.VMLRenderer}),define("renderer/canvas",["jxg","renderer/abstract","base/constants","utils/env","utils/type","utils/uuid","utils/color","base/coords","math/math","math/geometry","math/numerics"],function(t,e,r,i,s,o,n,a,h,c,l){return t.CanvasRenderer=function(t,e){this.type="canvas",this.canvasRoot=null,this.suspendHandle=null,this.canvasId=o.genUUID(),this.canvasNamespace=null,i.isBrowser?(this.container=t,this.container.style.MozUserSelect="none",this.container.style.overflow="hidden",""===this.container.style.position&&(this.container.style.position="relative"),this.container.innerHTML=['<canvas id="',this.canvasId,'" width="',e.width,'" height="',e.height,'"><',"/canvas>"].join(""),this.canvasRoot=document.getElementById(this.canvasId),this.context=this.canvasRoot.getContext("2d")):i.isNode()&&(this.canvasId="object"==typeof module?module.require("canvas"):require("canvas"),this.canvasRoot=new this.canvasId(500,500),this.context=this.canvasRoot.getContext("2d")),this.dashArray=[[2,2],[5,5],[10,10],[20,20],[20,10,10,10],[20,5,10,5]]},t.CanvasRenderer.prototype=new e,t.extend(t.CanvasRenderer.prototype,{_drawFilledPolygon:function(t){var e,r=t.length,i=this.context;if(r>0){for(i.beginPath(),i.moveTo(t[0][0],t[0][1]),e=0;r>e;e++)e>0&&i.lineTo(t[e][0],t[e][1]);i.lineTo(t[0][0],t[0][1]),i.fill()}},_fill:function(t){var e=this.context;e.save(),this._setColor(t,"fill")&&e.fill(),e.restore()},_rotatePoint:function(t,e,r){return[e*Math.cos(t)-r*Math.sin(t),e*Math.sin(t)+r*Math.cos(t)]},_rotateShape:function(t,e){var r,i=[],s=t.length;if(0>=s)return t;for(r=0;s>r;r++)i.push(this._rotatePoint(e,t[r][0],t[r][1]));return i},_setColor:function(t,e,r){var i,o,a,h,c,l,d=!0,u=!1,p=t.visProp;return e=e||"stroke",r=r||e,s.exists(t.board)&&s.exists(t.board.highlightedObjects)||(u=!0),i=!u&&s.exists(t.board.highlightedObjects[t.id])?"highlight":"",o=s.evaluate(p[i+e+"color"]),"none"!==o&&o!==!1?(c=s.evaluate(p[i+e+"opacity"]),c=c>0?c:0,9!==o.length?(h=o,l=c):(a=n.rgba2rgbo(o),h=a[0],l=c*a[1]),this.context.globalAlpha=l,this.context[r+"Style"]=h):d=!1,"stroke"!==e||isNaN(parseFloat(p.strokewidth))||(this.context.lineWidth=parseFloat(p.strokewidth)),d},_stroke:function(t){var e=this.context;e.save(),t.visProp.dash>0?e.setLineDash&&e.setLineDash(this.dashArray[t.visProp.dash]):this.context.lineDashArray=[],this._setColor(t,"stroke")&&e.stroke(),e.restore()},_translateShape:function(t,e,r){var i,s=[],o=t.length;if(0>=o)return t;for(i=0;o>i;i++)s.push([t[i][0]+e,t[i][1]+r]);return s},drawPoint:function(t){var e=t.visProp.face,r=t.visProp.size,i=t.coords.scrCoords,s=.5*r*Math.sqrt(3),o=.5*r,n=parseFloat(t.visProp.strokewidth)/2,a=this.context;switch(e){case"cross":case"x":a.beginPath(),a.moveTo(i[1]-r,i[2]-r),a.lineTo(i[1]+r,i[2]+r),a.moveTo(i[1]+r,i[2]-r),a.lineTo(i[1]-r,i[2]+r),a.closePath(),this._stroke(t);break;case"circle":case"o":a.beginPath(),a.arc(i[1],i[2],r+1+n,0,2*Math.PI,!1),a.closePath(),this._fill(t),this._stroke(t);break;case"square":case"[]":if(0>=r)break;a.save(),this._setColor(t,"stroke","fill")&&a.fillRect(i[1]-r-n,i[2]-r-n,2*r+3*n,2*r+3*n),a.restore(),a.save(),this._setColor(t,"fill"),a.fillRect(i[1]-r+n,i[2]-r+n,2*r-n,2*r-n),a.restore();break;case"plus":case"+":a.beginPath(),a.moveTo(i[1]-r,i[2]),a.lineTo(i[1]+r,i[2]),a.moveTo(i[1],i[2]-r),a.lineTo(i[1],i[2]+r),a.closePath(),this._stroke(t);break;case"diamond":case"<>":a.beginPath(),a.moveTo(i[1]-r,i[2]),a.lineTo(i[1],i[2]+r),a.lineTo(i[1]+r,i[2]),a.lineTo(i[1],i[2]-r),a.closePath(),this._fill(t),this._stroke(t);break;case"triangleup":case"a":case"^":a.beginPath(),a.moveTo(i[1],i[2]-r),a.lineTo(i[1]-s,i[2]+o),a.lineTo(i[1]+s,i[2]+o),a.closePath(),this._fill(t),this._stroke(t);break;case"triangledown":case"v":a.beginPath(),a.moveTo(i[1],i[2]+r),a.lineTo(i[1]-s,i[2]-o),a.lineTo(i[1]+s,i[2]-o),a.closePath(),this._fill(t),this._stroke(t);break;case"triangleleft":case"<":a.beginPath(),a.moveTo(i[1]-r,i[2]),a.lineTo(i[1]+o,i[2]-s),a.lineTo(i[1]+o,i[2]+s),a.closePath(),this.fill(t),this._stroke(t);break;case"triangleright":case">":a.beginPath(),a.moveTo(i[1]+r,i[2]),a.lineTo(i[1]-o,i[2]-s),a.lineTo(i[1]-o,i[2]+s),a.closePath(),this._fill(t),this._stroke(t)}},updatePoint:function(t){this.drawPoint(t)},drawLine:function(t){var e=new a(r.COORDS_BY_USER,t.point1.coords.usrCoords,t.board),i=new a(r.COORDS_BY_USER,t.point2.coords.usrCoords,t.board);c.calcStraight(t,e,i),this.context.beginPath(),this.context.moveTo(e.scrCoords[1],e.scrCoords[2]),this.context.lineTo(i.scrCoords[1],i.scrCoords[2]),this._stroke(t),this.makeArrows(t,e,i)},updateLine:function(t){this.drawLine(t)},drawTicks:function(){},updateTicks:function(t){var e,r,i,s,o=t.ticks.length,n=this.context;for(n.beginPath(),e=0;o>e;e++)r=t.ticks[e],i=r[0],s=r[1],n.moveTo(i[0],s[0]),n.lineTo(i[1],s[1]);for(e=0;o>e;e++)r=t.ticks[e].scrCoords,t.ticks[e].major&&(t.board.needsFullUpdate||t.needsRegularUpdate)&&t.labels[e]&&t.labels[e].visProp.visible&&this.updateText(t.labels[e]);this._stroke(t)},drawCurve:function(t){t.visProp.handdrawing?this.updatePathStringBezierPrim(t):this.updatePathStringPrim(t)},updateCurve:function(t){this.drawCurve(t)},drawEllipse:function(t){var e=t.center.coords.scrCoords[1],r=t.center.coords.scrCoords[2],i=t.board.unitX,s=t.board.unitY,o=2*t.Radius(),n=2*t.Radius(),a=o*i,h=n*s,c=e-a/2,l=r-h/2,d=.5522848*(a/2),u=.5522848*(h/2),p=c+a,f=l+h,b=c+a/2,m=l+h/2,g=this.context;o>0&&n>0&&!isNaN(e+r)&&(g.beginPath(),g.moveTo(c,m),g.bezierCurveTo(c,m-u,b-d,l,b,l),g.bezierCurveTo(b+d,l,p,m-u,p,m),g.bezierCurveTo(p,m+u,b+d,f,b,f),g.bezierCurveTo(b-d,f,c,m+u,c,m),g.closePath(),this._fill(t),this._stroke(t))},updateEllipse:function(t){return this.drawEllipse(t)},displayCopyright:function(t,e){var r=this.context;r.save(),r.font=e+"px Arial",r.fillStyle="#aaa",r.lineWidth=.5,r.fillText(t,10,2+e),r.restore()},drawInternalText:function(t){var e,r=this.context;return r.save(),this._setColor(t,"stroke","fill")&&!isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])&&(t.visProp.fontsize&&("function"==typeof t.visProp.fontsize?(e=t.visProp.fontsize(),r.font=(e>0?e:0)+"px Arial"):r.font=t.visProp.fontsize+"px Arial"),this.transformImage(t,t.transformations),"left"===t.visProp.anchorx?r.textAlign="left":"right"===t.visProp.anchorx?r.textAlign="right":"middle"===t.visProp.anchorx&&(r.textAlign="center"),"bottom"===t.visProp.anchory?r.textBaseline="bottom":"top"===t.visProp.anchory?r.textBaseline="top":"middle"===t.visProp.anchory&&(r.textBaseline="middle"),r.fillText(t.plaintext,t.coords.scrCoords[1],t.coords.scrCoords[2])),r.restore(),null},updateInternalText:function(t){this.drawInternalText(t)},setObjectStrokeColor:function(t,e,i){var o,a,h,c,l=s.evaluate(e),d=s.evaluate(i);d=d>0?d:0,(t.visPropOld.strokecolor!==l||t.visPropOld.strokeopacity!==d)&&(s.exists(l)&&l!==!1&&(9!==l.length?(o=l,h=d):(a=n.rgba2rgbo(l),o=a[0],h=d*a[1]),c=t.rendNode,t.type===r.OBJECT_TYPE_TEXT&&"html"===t.visProp.display&&(c.style.color=o,c.style.opacity=h)),t.visPropOld.strokecolor=l,t.visPropOld.strokeopacity=d)},drawImage:function(t){t.rendNode=new Image,t._src="",this.updateImage(t)},updateImage:function(t){var e=this.context,r=s.evaluate(t.visProp.fillopacity),i=s.bind(function(){t.imgIsLoaded=!0,0>=t.size[0]||0>=t.size[1]||(e.save(),e.globalAlpha=r,this.transformImage(t,t.transformations),e.drawImage(t.rendNode,t.coords.scrCoords[1],t.coords.scrCoords[2]-t.size[1],t.size[0],t.size[1]),e.restore())},this);this.updateImageURL(t)?t.rendNode.onload=i:t.imgIsLoaded&&i()},transformImage:function(t,e){var r,i=e.length,s=this.context;i>0&&(r=this.joinTransforms(t,e),Math.abs(l.det(r))>=h.eps&&s.transform(r[1][1],r[2][1],r[1][2],r[2][2],r[1][0],r[2][0]))},updateImageURL:function(t){var e;return e=s.evaluate(t.url),t._src!==e?(t.imgIsLoaded=!1,t.rendNode.src=e,t._src=e,!0):!1},remove:function(t){s.exists(t)&&s.exists(t.parentNode)&&t.parentNode.removeChild(t)},makeArrows:function(t,e,i){var s,o,n,a,h,c=Math.min(t.visProp.strokewidth/2,3),l=[[2,0],[-10,-4*c],[-10,4*c],[2,0]],d=[[-2,0],[10,-4*c],[10,4*c]],u=this.context;if("none"!==t.visProp.strokecolor&&(t.visProp.lastarrow||t.visProp.firstarrow)){if(t.elementClass!==r.OBJECT_CLASS_LINE)return;s=e.scrCoords[1],o=e.scrCoords[2],n=i.scrCoords[1],a=i.scrCoords[2],u.save(),this._setColor(t,"stroke","fill")&&(h=Math.atan2(a-o,n-s),t.visProp.lastarrow&&this._drawFilledPolygon(this._translateShape(this._rotateShape(l,h),n,a)),t.visProp.firstarrow&&this._drawFilledPolygon(this._translateShape(this._rotateShape(d,h),s,o))),u.restore()}},updatePathStringPrim:function(t){var e,r,i,s,o,n="M",a="L",h="C",c=n,d=5e3,u="plot"!==t.visProp.curvetype,p=this.context;if(!(0>=t.numberPoints)){if(o=Math.min(t.points.length,t.numberPoints),p.beginPath(),1===t.bezierDegree)for(u&&t.board.options.curve.RDPsmoothing&&(t.points=l.RamerDouglasPeuker(t.points,.5)),e=0;o>e;e++)r=t.points[e].scrCoords,isNaN(r[1])||isNaN(r[2])?c=n:(r[1]>d?r[1]=d:-d>r[1]&&(r[1]=-d),r[2]>d?r[2]=d:-d>r[2]&&(r[2]=-d),c===n?p.moveTo(r[1],r[2]):p.lineTo(r[1],r[2]),c=a);else if(3===t.bezierDegree)for(e=0;o>e;)r=t.points[e].scrCoords,isNaN(r[1])||isNaN(r[2])?c=n:(c===n?p.moveTo(r[1],r[2]):(e+=1,i=t.points[e].scrCoords,e+=1,s=t.points[e].scrCoords,p.bezierCurveTo(r[1],r[2],i[1],i[2],s[1],s[2])),c=h),e+=1;this._fill(t),this._stroke(t)}},updatePathStringBezierPrim:function(t){var e,r,i,s,o,n,a,h="M",c="C",d=h,u=5e3,p=t.visProp.strokewidth,f="plot"!==t.visProp.curvetype,b=this.context;if(!(0>=t.numberPoints)){for(f&&t.board.options.curve.RDPsmoothing&&(t.points=l.RamerDouglasPeuker(t.points,.5)),a=Math.min(t.points.length,t.numberPoints),b.beginPath(),r=1;3>r;r++)for(d=h,e=0;a>e;e++)s=t.points[e].scrCoords,isNaN(s[1])||isNaN(s[2])?d=h:(s[1]>u?s[1]=u:-u>s[1]&&(s[1]=-u),s[2]>u?s[2]=u:-u>s[2]&&(s[2]=-u),d===h?b.moveTo(s[1],s[2]):(i=2*r,b.bezierCurveTo(o+.333*(s[1]-o)+p*(i*Math.random()-r),n+.333*(s[2]-n)+p*(i*Math.random()-r),o+.666*(s[1]-o)+p*(i*Math.random()-r),n+.666*(s[2]-n)+p*(i*Math.random()-r),s[1],s[2])),d=c,o=s[1],n=s[2]);this._fill(t),this._stroke(t)}},updatePolygonPrim:function(t,e){var r,i,s,o=e.vertices.length,n=this.context,a=!0;if(!(0>=o)){for(n.beginPath(),i=0;!e.vertices[i].isReal&&o-1>i;)i++,a=!1;for(r=e.vertices[i].coords.scrCoords,n.moveTo(r[1],r[2]),s=i;o-1>s;s++)e.vertices[s].isReal||(a=!1),r=e.vertices[s].coords.scrCoords,n.lineTo(r[1],r[2]);n.closePath(),a&&this._fill(e)}},show:function(t){s.exists(t.rendNode)&&(t.rendNode.style.visibility="inherit")},hide:function(t){s.exists(t.rendNode)&&(t.rendNode.style.visibility="hidden")},setGradient:function(t){var e,r;r=s.evaluate(t.visProp.fillopacity),r=r>0?r:0,e=s.evaluate(t.visProp.fillcolor)},setShadow:function(t){t.visPropOld.shadow!==t.visProp.shadow&&(t.visPropOld.shadow=t.visProp.shadow)},highlight:function(t){return t.type===r.OBJECT_TYPE_TEXT&&"html"===t.visProp.display?this.updateTextStyle(t,!0):(t.board.prepareUpdate(),t.board.renderer.suspendRedraw(t.board),t.board.updateRenderer(),t.board.renderer.unsuspendRedraw()),this},noHighlight:function(t){return t.type===r.OBJECT_TYPE_TEXT&&"html"===t.visProp.display?this.updateTextStyle(t,!1):(t.board.prepareUpdate(),t.board.renderer.suspendRedraw(t.board),t.board.updateRenderer(),t.board.renderer.unsuspendRedraw()),this},suspendRedraw:function(e){this.context.save(),this.context.clearRect(0,0,this.canvasRoot.width,this.canvasRoot.height),e&&e.showCopyright&&this.displayCopyright(t.licenseText,12)},unsuspendRedraw:function(){this.context.restore()},resize:function(t,e){this.container?(this.canvasRoot.style.width=parseFloat(t)+"px",this.canvasRoot.style.height=parseFloat(e)+"px",this.canvasRoot.setAttribute("width",parseFloat(t)+"px"),this.canvasRoot.setAttribute("height",parseFloat(e)+"px")):(this.canvasRoot.width=parseFloat(t),this.canvasRoot.height=parseFloat(e))}}),t.CanvasRenderer}),define("jsxgraph",["jxg","utils/env","utils/type","base/board","reader/file","options","renderer/svg","renderer/vml","renderer/canvas","renderer/no"],function(t,e,r,i,s,o,n,a,h,c){return t.JSXGraph={rendererType:function(){return o.renderer="no",e.supportsVML()&&(o.renderer="vml",document.onmousemove=function(){var t;return document.body&&(t=document.body.scrollLeft,t+=document.body.scrollTop),t}),e.supportsCanvas()&&(o.renderer="canvas"),e.supportsSVG()&&(o.renderer="svg"),e.isNode()&&e.supportsCanvas()&&(o.renderer="canvas"),(e.isNode()||"no"===o.renderer)&&(o.text.display="internal",o.infobox.display="internal"),o.renderer}(),initRenderer:function(t,e){var r,i;return r="object"==typeof document&&null!==t?document.getElementById(t):t,i="svg"===o.renderer?new n(r,e):"vml"===o.renderer?new a(r):"canvas"===o.renderer?new h(r,e):new c},initBoard:function(s,n){var a,h,c,l,d,u,p,f,b,m,g,v;return f=e.getDimensions(s),n=n||{},m=r.copyAttributes(n,o,"board"),m.zoom=r.copyAttributes(m,o,"board","zoom"),m.pan=r.copyAttributes(m,o,"board","pan"),m.unitx||m.unity?(a=r.def(m.originx,150),h=r.def(m.originy,150),c=r.def(m.unitx,50),l=r.def(m.unity,50)):(b=m.boundingbox,u=parseInt(f.width,10),p=parseInt(f.height,10),m.keepaspectratio?(c=u/(b[2]-b[0]),l=p/(b[1]-b[3]),Math.abs(c)<Math.abs(l)?l=Math.abs(c)*l/Math.abs(l):c=Math.abs(l)*c/Math.abs(c)):(c=u/(b[2]-b[0]),l=p/(b[1]-b[3])),a=-c*b[0],h=l*b[1]),d=this.initRenderer(s,f),v=new i(s,d,"",[a,h],m.zoomfactor*m.zoomx,m.zoomfactor*m.zoomy,c,l,f.width,f.height,m),t.boards[v.id]=v,t.boards[v.id]=v,v.resizeContainer(f.width,f.height,!0),v.suspendUpdate(),v.initInfobox(),m.axis&&(g="object"==typeof m.axis?m.axis:{ticks:{drawZero:!0}},v.defaultAxes={},v.defaultAxes.x=v.create("axis",[[0,0],[1,0]],g),v.defaultAxes.y=v.create("axis",[[0,0],[0,1]],g)),m.grid&&v.create("grid",[],"object"==typeof m.grid?m.grid:{}),m.shownavigation&&v.renderer.drawZoomBar(v),v.unsuspendUpdate(),v
},loadBoardFromFile:function(n,a,h,c,l){var d,u,p,f;return f=e.getDimensions(n),u=this.initRenderer(n,f),c=c||{},d=r.copyAttributes(c,o,"board"),d.zoom=r.copyAttributes(c,o,"board","zoom"),d.pan=r.copyAttributes(c,o,"board","pan"),p=new i(n,u,"",[150,150],1,1,50,50,f.width,f.height,d),p.initInfobox(),p.resizeContainer(f.width,f.height,!0),s.parseFileContent(a,p,h,!0,l),p.attr.shownavigation&&p.renderer.drawZoomBar(p),t.boards[p.id]=p,p},loadBoardFromString:function(n,a,h,c,l){var d,u,p,f;return p=e.getDimensions(n),u=this.initRenderer(n,p),c=c||{},d=r.copyAttributes(c,o,"board"),d.zoom=r.copyAttributes(c,o,"board","zoom"),d.pan=r.copyAttributes(c,o,"board","pan"),f=new i(n,u,"",[150,150],1,1,50,50,p.width,p.height,d),f.initInfobox(),f.resizeContainer(p.width,p.height,!0),s.parseString(a,f,h,!0,l),f.attr.shownavigation&&f.renderer.drawZoomBar(f),t.boards[f.id]=f,f},freeBoard:function(e){var r;"string"==typeof e&&(e=t.boards[e]),e.removeEventHandlers(),e.suspendUpdate();for(r in e.objects)e.objects.hasOwnProperty(r)&&e.objects[r].remove();for(;e.containerObj.firstChild;)e.containerObj.removeChild(e.containerObj.firstChild);for(r in e.objects)e.objects.hasOwnProperty(r)&&delete e.objects[r];delete e.renderer,e.jc.creator.clearCache(),delete e.jc,delete t.boards[e.id]},registerElement:function(e,r){t.registerElement(e,r)},unregisterElement:function(){throw Error("Unimplemented")}},e.isBrowser&&"object"==typeof window&&"object"==typeof document&&e.addEvent(window,"load",function(){var e,i,s,o,n,a,h,c,l,d,u,p,f=document.getElementsByTagName("script");for(i=0;f.length>i;i++)if(e=f[i].getAttribute("type",!1),r.exists(e)&&("text/jessiescript"===e.toLowerCase()||"jessiescript"===e.toLowerCase()||"text/jessiecode"===e.toLowerCase()||"jessiecode"===e.toLowerCase())){if(h=f[i].getAttribute("width",!1)||"500px",c=f[i].getAttribute("height",!1)||"500px",l=f[i].getAttribute("boundingbox",!1)||"-5, 5, 5, -5",n=f[i].getAttribute("container",!1),l=l.split(","),4!==l.length)l=[-5,5,5,-5];else for(s=0;l.length>s;s++)l[s]=parseFloat(l[s]);if(d=r.str2Bool(f[i].getAttribute("axis",!1)||"false"),u=r.str2Bool(f[i].getAttribute("grid",!1)||"false"),r.exists(n))o=document.getElementById(n);else{n="jessiescript_autgen_jxg_"+i,o=document.createElement("div"),o.setAttribute("id",n),o.setAttribute("style","width:"+h+"; height:"+c+"; float:left"),o.setAttribute("class","jxgbox");try{document.body.insertBefore(o,f[i])}catch(b){"object"==typeof jQuery&&jQuery(o).insertBefore(f[i])}}if(document.getElementById(n))if(a=t.JSXGraph.initBoard(n,{boundingbox:l,keepaspectratio:!0,grid:u,axis:d}),p=f[i].innerHTML,p=p.replace(/<!\[CDATA\[/g,"").replace(/\]\]>/g,""),f[i].innerHTML=p,e.toLowerCase().indexOf("script")>-1)a.construct(p);else try{a.jc.parse(p)}catch(m){t.debug(m)}else t.debug("JSXGraph: Apparently the div injection failed. Can't create a board, sorry.")}},window),t.JSXGraph}),define("base/group",["jxg","base/constants","base/element","math/math","utils/type"],function(t,e,r,i,s){return t.Group=function(t,r,i,o){var n,a,h,c;for(this.board=t,this.objects={},n=this.board.numObjects,this.board.numObjects+=1,this.id=""!==r&&s.exists(r)?r:this.board.id+"Group"+n,this.board.groups[this.id]=this,this.type=e.OBJECT_TYPE_POINT,this.elementClass=e.OBJECT_CLASS_POINT,this.name=""!==i&&s.exists(i)?i:"group_"+this.board.generateName(this),delete this.type,this.coords={},a=s.isArray(o)?o:Array.prototype.slice.call(arguments,3),h=0;a.length>h;h++)c=this.board.select(a[h]),c.visProp.fixed||c.type!==e.OBJECT_TYPE_POINT&&c.type!==e.OBJECT_TYPE_GLIDER||(0!==c.group.length?this.addGroup(c.group[c.group.length-1]):this.addPoint(c));this.methodMap={ungroup:"ungroup",add:"addPoint",addPoint:"addPoint",addPoints:"addPoints",addGroup:"addGroup",remove:"removePoint",removePoint:"removePoint",setAttribute:"setAttribute",setProperty:"setAttribute"}},t.extend(t.Group.prototype,{ungroup:function(){var t;for(t in this.objects)this.objects.hasOwnProperty(t)&&(s.isArray(this.objects[t].point.group)&&this.objects[t].point.group[this.objects[t].point.group.length-1]===this&&this.objects[t].point.group.pop(),this.removePoint(this.objects[t].point))},update:function(t){var r,o,n,a,h=null;for(r in this.objects)if(this.objects.hasOwnProperty(r)&&(h=this.objects[r].point,h.coords.distance(e.COORDS_BY_USER,this.coords[r])>i.eps)){o=[h.coords.usrCoords[1]-this.coords[h.id].usrCoords[1],h.coords.usrCoords[2]-this.coords[h.id].usrCoords[2]],n=h;break}if(s.exists(n)){for(r in this.objects)this.objects.hasOwnProperty(r)&&(s.exists(this.board.objects[r])?(h=this.objects[r].point,h.id!==n.id&&h.coords.setCoordinates(e.COORDS_BY_USER,[this.coords[r].usrCoords[1]+o[0],this.coords[r].usrCoords[2]+o[1]])):delete this.objects[r],this.coords[h.id]={usrCoords:[h.coords.usrCoords[0],h.coords.usrCoords[1],h.coords.usrCoords[2]]});for(r in this.objects)if(this.objects.hasOwnProperty(r))for(a in this.objects[r].descendants)this.objects[r].descendants.hasOwnProperty(a)&&(this.objects[r].descendants.needsUpdate=this.objects[r].descendants.needsRegularUpdate||this.board.needsFullUpdate);this.board.updateElements(t)}return this},addPoint:function(t){this.objects[t.id]={point:t},this.coords[t.id]={usrCoords:[t.coords.usrCoords[0],t.coords.usrCoords[1],t.coords.usrCoords[2]]}},addPoints:function(t){var e;for(e=0;t.length>e;e++)this.addPoint(t[e])},addGroup:function(t){var e;for(e in t.objects)t.objects.hasOwnProperty(e)&&this.addPoint(t.objects[e].point)},removePoint:function(t){delete this.objects[t.id]},setProperty:t.shortcut(t.Group.prototype,"setAttribute"),setAttribute:function(){var t;for(t in this.objects)this.objects.hasOwnProperty(t)&&this.objects[t].point.setAttribute.apply(this.objects[t].point,arguments)}}),t.createGroup=function(e,r,i){var s,o=new t.Group(e,i.id,i.name,r);for(o.elType="group",o.parents=[],s=0;r.length>s;s++)o.parents.push(r[s].id);return o},t.registerElement("group",t.createGroup),{Group:t.Group,createGroup:t.createGroup}}),define("element/conic",["jxg","base/constants","base/coords","math/math","math/numerics","math/geometry","utils/type","base/point","base/curve"],function(t,e,r,i,s,o,n){return t.createEllipse=function(t,i,s){var o,a,h,c,l,d,u,p=[],f=n.copyAttributes(s,t.options,"conic","foci"),b=n.copyAttributes(s,t.options,"conic");for(d=0;2>d;d++)if(i[d].length>1)p[d]=t.create("point",i[d],f);else if(n.isPoint(i[d]))p[d]=t.select(i[d]);else if("function"==typeof i[d]&&i[d]().elementClass===e.OBJECT_CLASS_POINT)p[d]=i[d]();else{if(!n.isString(i[d]))throw Error("JSXGraph: Can't create Ellipse with parent types '"+typeof i[0]+"' and '"+typeof i[1]+"'."+"\nPossible parent types: [point,point,point], [point,point,number|function]");p[d]=t.select(i[d])}if(n.isNumber(i[2]))l=n.createFunction(i[2],t);else if("function"==typeof i[2]&&n.isNumber(i[2]()))l=i[2];else{if(n.isPoint(i[2]))c=t.select(i[2]);else if(i[2].length>1)c=t.create("point",i[2],f);else if("function"==typeof i[2]&&i[2]().elementClass===e.OBJECT_CLASS_POINT)c=i[2]();else{if(!n.isString(i[2]))throw Error("JSXGraph: Can't create Ellipse with parent types '"+typeof i[0]+"' and '"+typeof i[1]+"' and '"+typeof i[2]+"'."+"\nPossible parent types: [point,point,point], [point,point,number|function]");c=t.select(i[2])}l=function(){return c.Dist(p[0])+c.Dist(p[1])}}for(n.exists(i[4])||(i[4]=2*Math.PI),n.exists(i[3])||(i[3]=0),h=t.create("point",[function(){return.5*(p[0].X()+p[1].X())},function(){return.5*(p[0].Y()+p[1].Y())}],f),a=t.create("curve",[function(){return 0},function(){return 0},i[3],i[4]],b),a.majorAxis=l,u=a.hasPoint,o=function(t,e){var r,i,s,o,n,h,c,d,u;e||(r=l(),i=r*r,s=p[0].X(),o=p[0].Y(),n=p[1].X(),h=p[1].Y(),c=s-n,d=o-h,u=(i-s*s-o*o+n*n+h*h)/(2*r),a.quadraticform=[[u*u-n*n-h*h,u*c/r+n,u*d/r+h],[u*c/r+n,c*c/i-1,c*d/i],[u*d/r+h,c*d/i,d*d/i-1]])},a.X=function(t,e){var r=l(),i=p[1].Dist(p[0]),s=.5*(i*i-r*r)/(i*Math.cos(t)-r),n=Math.atan2(p[1].Y()-p[0].Y(),p[1].X()-p[0].X());return e||o(t,e),p[0].X()+Math.cos(n+t)*s},a.Y=function(t){var e=l(),r=p[1].Dist(p[0]),i=.5*(r*r-e*e)/(r*Math.cos(t)-e),s=Math.atan2(p[1].Y()-p[0].Y(),p[1].X()-p[0].X());return p[0].Y()+Math.sin(s+t)*i},a.midpoint=h,a.type=e.OBJECT_TYPE_CONIC,a.hasPoint=function(t,i){var s,o,n,a,h;return this.visProp.hasinnerpoints?(s=p[0].coords,o=p[1].coords,n=this.majorAxis(),a=new r(e.COORDS_BY_SCREEN,[t,i],this.board),h=a.distance(e.COORDS_BY_USER,s)+a.distance(e.COORDS_BY_USER,o),n>=h):u.apply(this,arguments)},h.addChild(a),d=0;2>d;d++)n.isPoint(p[d])&&p[d].addChild(a);for(n.isPoint(c)&&c.addChild(a),a.parents=[],d=0;i.length>d;d++)i[d].id&&a.parents.push(i[d].id);return a},t.createHyperbola=function(t,r,i){var s,o,a,h,c,l,d=[],u=n.copyAttributes(i,t.options,"conic","foci"),p=n.copyAttributes(i,t.options,"conic");for(l=0;2>l;l++)if(r[l].length>1)d[l]=t.create("point",r[l],u);else if(n.isPoint(r[l]))d[l]=t.select(r[l]);else if("function"==typeof r[l]&&r[l]().elementClass===e.OBJECT_CLASS_POINT)d[l]=r[l]();else{if(!n.isString(r[l]))throw Error("JSXGraph: Can't create Hyperbola with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,point,point], [point,point,number|function]");d[l]=t.select(r[l])}if(n.isNumber(r[2]))c=n.createFunction(r[2],t);else if("function"==typeof r[2]&&n.isNumber(r[2]()))c=r[2];else{if(n.isPoint(r[2]))h=t.select(r[2]);else if(r[2].length>1)h=t.create("point",r[2],u);else if("function"==typeof r[2]&&r[2]().elementClass===e.OBJECT_CLASS_POINT)h=r[2]();else{if(!n.isString(r[2]))throw Error("JSXGraph: Can't create Hyperbola with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"' and '"+typeof r[2]+"'."+"\nPossible parent types: [point,point,point], [point,point,number|function]");h=t.select(r[2])}c=function(){return h.Dist(d[0])-h.Dist(d[1])}}for(n.exists(r[4])||(r[4]=1.0001*Math.PI),n.exists(r[3])||(r[3]=-1.0001*Math.PI),a=t.create("point",[function(){return.5*(d[0].X()+d[1].X())},function(){return.5*(d[0].Y()+d[1].Y())}],u),o=t.create("curve",[function(){return 0},function(){return 0},r[3],r[4]],p),o.majorAxis=c,s=function(t,e){var r,i,s,n,a,h,l,u,p;e||(r=c(),i=r*r,s=d[0].X(),n=d[0].Y(),a=d[1].X(),h=d[1].Y(),l=s-a,u=n-h,p=(i-s*s-n*n+a*a+h*h)/(2*r),o.quadraticform=[[p*p-a*a-h*h,p*l/r+a,p*u/r+h],[p*l/r+a,l*l/i-1,l*u/i],[p*u/r+h,l*u/i,u*u/i-1]])},o.X=function(t,e){var r=this.majorAxis(),i=d[1].Dist(d[0]),o=.5*(i*i-r*r)/(i*Math.cos(t)+r),n=Math.atan2(d[1].Y()-d[0].Y(),d[1].X()-d[0].X());return e||s(t,e),d[0].X()+Math.cos(n+t)*o},o.Y=function(t){var e=this.majorAxis(),r=d[1].Dist(d[0]),i=.5*(r*r-e*e)/(r*Math.cos(t)+e),s=Math.atan2(d[1].Y()-d[0].Y(),d[1].X()-d[0].X());return d[0].Y()+Math.sin(s+t)*i},o.midpoint=a,o.type=e.OBJECT_TYPE_CONIC,a.addChild(o),l=0;2>l;l++)n.isPoint(d[l])&&d[l].addChild(o);for(n.isPoint(h)&&h.addChild(o),o.parents=[],l=0;r.length>l;l++)r[l].id&&o.parents.push(r[l].id);return o},t.createParabola=function(t,r,s){var a,h,c,l,d=r[0],u=r[1],p=n.copyAttributes(s,t.options,"conic","foci"),f=n.copyAttributes(s,t.options,"conic");if(r[0].length>1)d=t.create("point",r[0],p);else if(n.isPoint(r[0]))d=t.select(r[0]);else if("function"==typeof r[0]&&r[0]().elementClass===e.OBJECT_CLASS_POINT)d=r[0]();else{if(!n.isString(r[0]))throw Error("JSXGraph: Can't create Parabola with parent types '"+typeof r[0]+"' and '"+typeof r[1]+"'."+"\nPossible parent types: [point,line]");d=t.select(r[0])}for(n.exists(r[3])||(r[3]=10),n.exists(r[2])||(r[2]=-10),c=t.create("point",[function(){var e=[0,u.stdform[1],u.stdform[2]];return e=i.crossProduct(e,d.coords.usrCoords),o.meetLineLine(e,u.stdform,0,t).usrCoords}],p),h=t.create("curve",[function(){return 0},function(){return 0},r[2],r[3]],f),a=function(t,e){var r,i,s,o,n,a;e||(r=u.stdform[1],i=u.stdform[2],s=u.stdform[0],o=r*r+i*i,n=d.X(),a=d.Y(),h.quadraticform=[[s*s-o*(n*n+a*a),s*r+o*n,s*i+o*a],[s*r+o*n,-i*i,r*i],[s*i+o*a,r*i,-r*r]])},h.X=function(t,e){var r,i,s=u.getAngle(),n=o.distPointLine(d.coords.usrCoords,u.stdform),h=u.point1.coords.usrCoords,c=u.point2.coords.usrCoords,l=d.coords.usrCoords;return i=(c[1]-h[1])*(l[2]-h[2])-(c[2]-h[2])*(l[1]-h[1])>=0?1:-1,r=i*n/(1-Math.sin(t)),e||a(t,e),d.X()+Math.cos(t+s)*r},h.Y=function(t){var e,r,i=u.getAngle(),s=o.distPointLine(d.coords.usrCoords,u.stdform),n=u.point1.coords.usrCoords,a=u.point2.coords.usrCoords,h=d.coords.usrCoords;return r=(a[1]-n[1])*(h[2]-n[2])-(a[2]-n[2])*(h[1]-n[1])>=0?1:-1,e=r*s/(1-Math.sin(t)),d.Y()+Math.sin(t+i)*e},h.type=e.OBJECT_TYPE_CONIC,c.addChild(h),n.isPoint(d)&&d.addChild(h),u.addChild(h),h.parents=[],l=0;r.length>l;l++)r[l].id&&h.parents.push(r[l].id);return h},t.createConic=function(r,o,a){var h,c,l,d,u,p,f,b,m,g,v,C,y,P,_=[[1,0,0],[0,1,0],[0,0,1]],E=[[1,0,0],[0,1,0],[0,0,1]],S=[],O=[],T=n.copyAttributes(a,r.options,"conic","foci"),x=n.copyAttributes(a,r.options,"conic");if(5===o.length)P=!0;else{if(6!==o.length)throw Error("JSXGraph: Can't create generic Conic with "+o.length+" parameters.");P=!1}if(P)for(C=0;5>C;C++)if(o[C].length>1)S[C]=r.create("point",o[C],T);else if(n.isPoint(o[C]))S[C]=r.select(o[C]);else if("function"==typeof o[C]&&o[C]().elementClass===e.OBJECT_CLASS_POINT)S[C]=o[C]();else{if(!n.isString(o[C]))throw Error("JSXGraph: Can't create Conic section with parent types '"+typeof o[C]+"'."+"\nPossible parent types: [point,point,point,point,point], [a00,a11,a22,a01,a02,a12]");S[C]=r.select(o[C])}else y=[[0,0,0],[0,0,0],[0,0,0]],y[0][0]=n.isFunction(o[2])?function(){return o[2]()}:function(){return o[2]},y[0][1]=n.isFunction(o[4])?function(){return o[4]()}:function(){return o[4]},y[0][2]=n.isFunction(o[5])?function(){return o[5]()}:function(){return o[5]},y[1][1]=n.isFunction(o[0])?function(){return o[0]()}:function(){return o[0]},y[1][2]=n.isFunction(o[3])?function(){return o[3]()}:function(){return o[3]},y[2][2]=n.isFunction(o[1])?function(){return o[1]()}:function(){return o[1]};if(u=function(t){var e,r;for(e=0;3>e;e++)for(r=e;3>r;r++)t[e][r]+=t[r][e];for(e=0;3>e;e++)for(r=0;e>r;r++)t[e][r]=t[r][e];return t},d=function(t,e){var r,i,s=[[0,0,0],[0,0,0],[0,0,0]];for(r=0;3>r;r++)for(i=0;3>i;i++)s[r][i]=t[r]*e[i];return u(s)},l=function(t,e,r){var s,o,n,a,h,c=[[0,0,0],[0,0,0],[0,0,0]];for(h=i.matVecMult(e,r),n=i.innerProduct(r,h),h=i.matVecMult(t,r),a=i.innerProduct(r,h),s=0;3>s;s++)for(o=0;3>o;o++)c[s][o]=n*t[s][o]-a*e[s][o];return c},c=r.create("curve",[function(){return 0},function(){return 0},0,2*Math.PI],x),h=function(e,r){var o,n,a,h;if(!r){if(P){for(o=0;5>o;o++)O[o]=S[o].coords.usrCoords;g=d(i.crossProduct(O[0],O[1]),i.crossProduct(O[2],O[3])),v=d(i.crossProduct(O[0],O[2]),i.crossProduct(O[1],O[3])),E=l(g,v,O[4])}else for(o=0;3>o;o++)for(n=o;3>n;n++)E[o][n]=y[o][n](),n>o&&(E[n][o]=E[o][n]);for(c.quadraticform=E,p=s.Jacobi(E),0>p[0][0][0]&&(p[0][0][0]*=-1,p[0][1][1]*=-1,p[0][2][2]*=-1),o=0;3>o;o++){for(a=0,n=0;3>n;n++)a+=p[1][n][o]*p[1][n][o];a=Math.sqrt(a)}_=p[1],m=Math.sqrt(Math.abs(p[0][0][0])),f=Math.sqrt(Math.abs(p[0][1][1])),b=Math.sqrt(Math.abs(p[0][2][2]))}return 0>=p[0][1][1]&&0>=p[0][2][2]?h=i.matVecMult(_,[1/m,Math.cos(e)/f,Math.sin(e)/b]):0>=p[0][1][1]&&p[0][2][2]>0?h=i.matVecMult(_,[Math.cos(e)/m,1/f,Math.sin(e)/b]):0>p[0][2][2]&&(h=i.matVecMult(_,[Math.sin(e)/m,Math.cos(e)/f,1/b])),t.exists(h)?(h[1]/=h[0],h[2]/=h[0],h[0]=1):h=[1,0/0,0/0],h},c.X=function(t,e){return h(t,e)[1]},c.Y=function(t,e){return h(t,e)[2]},c.midpoint=r.create("point",[function(){var t=c.quadraticform;return[t[1][1]*t[2][2]-t[1][2]*t[1][2],t[1][2]*t[0][2]-t[2][2]*t[0][1],t[0][1]*t[1][2]-t[1][1]*t[0][2]]}],T),c.type=e.OBJECT_TYPE_CONIC,P){for(C=0;5>C;C++)n.isPoint(S[C])&&S[C].addChild(c);for(c.parents=[],C=0;o.length>C;C++)o[C].id&&c.parents.push(o[C].id)}return c.addChild(c.midpoint),c},t.registerElement("ellipse",t.createEllipse),t.registerElement("hyperbola",t.createHyperbola),t.registerElement("parabola",t.createParabola),t.registerElement("conic",t.createConic),{createEllipse:t.createEllipse,createHyperbola:t.createHyperbola,createParabola:t.createParabola,createConic:t.createConic}}),define("base/polygon",["jxg","base/constants","base/coords","math/statistics","utils/type","base/element","base/line","base/transformation"],function(t,e,r,i,s,o){return t.Polygon=function(r,i,o){this.constructor(r,o,e.OBJECT_TYPE_POLYGON,e.OBJECT_CLASS_AREA);var n,a,h,c,l,d=s.copyAttributes(o,r.options,"polygon","borders");for(this.withLines=o.withlines,this.attr_line=d,this.vertices=[],n=0;i.length>n;n++)a=this.board.select(i[n]),this.vertices[n]=a;if(this.vertices[this.vertices.length-1]!==this.vertices[0]&&this.vertices.push(this.vertices[0]),this.borders=[],this.withLines)for(c=this.vertices.length-1,l=0;c>l;l++)n=(l+1)%c,d.id=d.ids&&d.ids[n],d.strokecolor=s.isArray(d.colors)&&d.colors[n%d.colors.length]||d.strokecolor,d.visible=s.exists(o.borders.visible)?o.borders.visible:o.visible,d.strokecolor===!1&&(d.strokecolor="none"),h=r.create("segment",[this.vertices[n],this.vertices[n+1]],d),h.dump=!1,this.borders[n]=h,h.parentPolygon=this;for(n=0;this.vertices.length-1>n;n++)a=this.board.select(this.vertices[n]),a.addChild(this);this.id=this.board.setId(this,"Py"),this.board.renderer.drawPolygon(this),this.board.finalizeAdding(this),this.elType="polygon",this.createLabel(),this.methodMap=t.deepCopy(this.methodMap,{borders:"borders",vertices:"vertices",A:"Area",Area:"Area",addPoints:"addPoints",insertPoints:"insertPoints",removePoints:"removePoints"})},t.Polygon.prototype=new o,t.extend(t.Polygon.prototype,{hasPoint:function(t,e){var r,i,s,o=!1;if(this.visProp.hasinnerpoints)for(s=this.vertices.length,r=0,i=s-2;s-1>r;i=r++)this.vertices[r].coords.scrCoords[2]>e!=this.vertices[i].coords.scrCoords[2]>e&&(this.vertices[i].coords.scrCoords[1]-this.vertices[r].coords.scrCoords[1])*(e-this.vertices[r].coords.scrCoords[2])/(this.vertices[i].coords.scrCoords[2]-this.vertices[r].coords.scrCoords[2])+this.vertices[r].coords.scrCoords[1]>t&&(o=!o);else for(s=this.borders.length,r=0;s>r;r++)if(this.borders[r].hasPoint(t,e)){o=!0;break}return o},updateRenderer:function(){this.needsUpdate&&(this.board.renderer.updatePolygon(this),this.needsUpdate=!1),this.hasLabel&&this.label.content.visProp.visible&&(this.label.content.update(),this.board.renderer.updateText(this.label.content))},getTextAnchor:function(){var t,i=this.vertices[0].X(),s=this.vertices[0].Y(),o=i,n=s;for(t=0;this.vertices.length>t;t++)i>this.vertices[t].X()&&(i=this.vertices[t].X()),this.vertices[t].X()>o&&(o=this.vertices[t].X()),this.vertices[t].Y()>s&&(s=this.vertices[t].Y()),n>this.vertices[t].Y()&&(n=this.vertices[t].Y());return new r(e.COORDS_BY_USER,[.5*(i+o),.5*(s+n)],this.board)},getLabelAnchor:t.shortcut(t.Polygon.prototype,"getTextAnchor"),cloneToBackground:function(){var t,e={};return e.id=this.id+"T"+this.numTraces,this.numTraces++,e.vertices=this.vertices,e.visProp=s.deepCopy(this.visProp,this.visProp.traceattributes,!0),e.visProp.layer=this.board.options.layer.trace,e.board=this.board,s.clearVisPropOld(e),t=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawPolygon(e),this.board.renderer.enhancedRendering=t,this.traces[e.id]=e.rendNode,this},hideElement:function(t){var e;if(this.visProp.visible=!1,this.board.renderer.hide(this),!t)for(e=0;this.borders.length>e;e++)this.borders[e].hideElement();this.hasLabel&&s.exists(this.label)&&(this.label.hiddenByParent=!0,this.label.content.visProp.visible&&this.board.renderer.hide(this.label.content))},showElement:function(t){var e;if(this.visProp.visible=!0,this.board.renderer.show(this),!t)for(e=0;this.borders.length>e;e++)this.borders[e].showElement(),this.borders[e].updateRenderer();this.hasLabel&&s.exists(this.label)&&this.label.content.visProp.visible&&this.board.renderer.show(this.label.content)},Area:function(){var t,e=0;for(t=0;this.vertices.length-1>t;t++)e+=this.vertices[t].X()*this.vertices[t+1].Y()-this.vertices[t+1].X()*this.vertices[t].Y();return e/=2,Math.abs(e)},remove:function(){var t;for(t=0;this.borders.length>t;t++)this.board.removeObject(this.borders[t]);o.prototype.remove.call(this)},findPoint:function(t){var e;if(!s.isPoint(t))return-1;for(e=0;this.vertices.length>e;e++)if(this.vertices[e].id===t.id)return e;return-1},addPoints:function(){var t=Array.prototype.slice.call(arguments);return this.insertPoints.apply(this,[this.vertices.length-2].concat(t))},insertPoints:function(t){var e,r,i=[];if(0===arguments.length)return this;if(0>t||t>this.vertices.length-2)return this;for(e=1;arguments.length>e;e++)s.isPoint(arguments[e])&&i.push(arguments[e]);if(r=this.vertices.slice(0,t+1).concat(i),this.vertices=r.concat(this.vertices.slice(t+1)),this.withLines){for(r=this.borders.slice(0,t),this.board.removeObject(this.borders[t]),e=0;i.length>e;e++)r.push(this.board.create("segment",[this.vertices[t+e],this.vertices[t+e+1]],this.attr_line));r.push(this.board.create("segment",[this.vertices[t+i.length],this.vertices[t+i.length+1]],this.attr_line)),this.borders=r.concat(this.borders.slice(t))}return this.board.update(),this},removePoints:function(){var t,e,r,i=[],o=[],n=[],a=[];for(this.vertices=this.vertices.slice(0,this.vertices.length-1),t=0;arguments.length>t;t++)s.isPoint(arguments[t])&&(r=this.findPoint(arguments[t])),s.isNumber(r)&&r>-1&&this.vertices.length>r&&-1===s.indexOf(n,r)&&n.push(r);for(n=n.sort(),i=this.vertices.slice(),o=this.borders.slice(),this.withLines&&a.push([n[n.length-1]]),t=n.length-1;t>-1;t--)i[n[t]]=-1,this.withLines&&n[t]-1>n[t-1]&&(a[a.length-1][1]=n[t],a.push([n[t-1]]));for(this.withLines&&(a[a.length-1][1]=n[0]),this.vertices=[],t=0;i.length>t;t++)s.isPoint(i[t])&&this.vertices.push(i[t]);if(this.vertices[this.vertices.length-1].id!==this.vertices[0].id&&this.vertices.push(this.vertices[0]),this.withLines){for(t=0;a.length>t;t++){for(e=a[t][1]-1;a[t][0]+1>e;e++)0>e?(e=0,this.board.removeObject(this.borders[o.length-1]),o[o.length-1]=-1):e>o.length-1&&(e=o.length-1),this.board.removeObject(this.borders[e]),o[e]=-1;0!==a[t][1]&&a[t][0]!==i.length-1&&(o[a[t][0]-1]=this.board.create("segment",[i[Math.max(a[t][1]-1,0)],i[Math.min(a[t][0]+1,this.vertices.length-1)]],this.attr_line))}for(this.borders=[],t=0;o.length>t;t++)-1!==o[t]&&this.borders.push(o[t]);(5===a[0][1]||0===a[a.length-1][1])&&this.borders.push(this.board.create("segment",[this.vertices[0],this.vertices[this.vertices.length-2]],this.attr_line))}return this.board.update(),this},getParents:function(){var t,e=[];for(t=0;this.vertices.length>t;t++)e.push(this.vertices[t].id);return e},getAttributes:function(){var t,e=o.prototype.getAttributes.call(this);if(this.withLines)for(e.lines=e.lines||{},e.lines.ids=[],e.lines.colors=[],t=0;this.borders.length>t;t++)e.lines.ids.push(this.borders[t].id),e.lines.colors.push(this.borders[t].visProp.strokecolor);return e},snapToGrid:function(){var t;for(t=0;this.vertices.length>t;t++)this.vertices[t].snapToGrid()},setPositionDirectly:function(t,e,s){var o,n,a,h,c=new r(t,e,this.board),l=new r(t,s,this.board);for(h=this.vertices.length-1,a=0;h>a;a++)if(!this.vertices[a].draggable())return this;return o=i.subtract(c.usrCoords,l.usrCoords),n=this.board.create("transform",o.slice(1),{type:"translate"}),n.applyOnce(this.vertices.slice(0,-1)),this}}),t.createPolygon=function(e,r,i){var o,n,a=s.copyAttributes(i,e.options,"polygon");for(n=0;r.length>n;n++)if(r[n]=e.select(r[n]),!s.isPoint(r[n]))throw Error("JSXGraph: Can't create polygon with parent types other than 'point'.");return o=new t.Polygon(e,r,a),o.isDraggable=!0,o},t.createRegularPolygon=function(t,r,i){var o,n,a,h,c,l,d,u=[];if(s.isNumber(r[r.length-1])&&3!==r.length)throw Error("JSXGraph: A regular polygon needs two points and a number as input.");if(c=r.length,a=r[c-1],!s.isNumber(a)&&!s.isPoint(t.select(a))||3>a)throw Error("JSXGraph: The third parameter has to be number greater than 2 or a point.");for(s.isPoint(t.select(a))?(a=c,l=!0):(c--,l=!1),n=0;c>n;n++)if(r[n]=t.select(r[n]),!s.isPoint(r[n]))throw Error("JSXGraph: Can't create regular polygon if the first two parameters aren't points.");for(u[0]=r[0],u[1]=r[1],d=s.copyAttributes(i,t.options,"polygon","vertices"),n=2;a>n;n++)h=t.create("transform",[Math.PI*(2-(a-2)/a),u[n-1]],{type:"rotate"}),l?(u[n]=r[n],u[n].addTransform(r[n-2],h)):(s.isArray(d.ids)&&d.ids.length>=a-2&&(d.id=d.ids[n-2]),u[n]=t.create("point",[u[n-2],h],d),u[n].type=e.OBJECT_TYPE_CAS,u[n].isDraggable=!0,u[n].visProp.fixed=!1);return d=s.copyAttributes(i,t.options,"polygon"),o=t.create("polygon",u,d),o.elType="regularpolygon",o},t.registerElement("polygon",t.createPolygon),t.registerElement("regularpolygon",t.createRegularPolygon),{Polygon:t.Polygon,createPolygon:t.createPolygon,createRegularPolygon:t.createRegularPolygon}}),define("element/arc",["jxg","math/geometry","math/math","base/coords","base/circle","utils/type","base/constants","base/curve","element/composition"],function(t,e,r,i,s,o,n){return t.createArc=function(a,h,c){var l,d,u;if(3>h.length||h[0].elementClass!==n.OBJECT_CLASS_POINT||h[1].elementClass!==n.OBJECT_CLASS_POINT||h[2].elementClass!==n.OBJECT_CLASS_POINT||h[3]&&h[3].elementClass!==n.OBJECT_CLASS_POINT)throw Error("JSXGraph: Can't create Arc with parent types '"+typeof h[0]+"' and '"+typeof h[1]+"' and '"+typeof h[2]+"'."+"\nPossible parent types: [point,point,point]");for(d=o.copyAttributes(c,a.options,"arc"),l=a.create("curve",[[0],[0]],d),l.elType="arc",l.parents=[],u=0;h.length>u;u++)h[u].id&&l.parents.push(h[u].id);return l.type=n.OBJECT_TYPE_ARC,l.center=a.select(h[0]),l.radiuspoint=a.select(h[1]),l.point2=l.radiuspoint,l.anglepoint=a.select(h[2]),l.point3=l.anglepoint,l.center.addChild(l),l.radiuspoint.addChild(l),l.anglepoint.addChild(l),l.useDirection=d.usedirection,l.updateDataArray=function(){var t,i,s,o,n,a,c,l,d,u,p,f,b,m,g,v,C,y,P,_,E,S=1,O=.5*Math.PI,T=this.radiuspoint,x=this.center,w=this.anglepoint,k=x.X(),A=x.Y(),M=x.Z();for(n=e.rad(T,x,w),("minor"===this.visProp.type&&n>Math.PI||"major"===this.visProp.type&&Math.PI>n)&&(n=2*Math.PI-n,S=-1),this.useDirection&&(l=h[1].coords.usrCoords,d=h[3].coords.usrCoords,u=h[2].coords.usrCoords,c=(l[1]-u[1])*(l[2]-d[2])-(l[2]-u[2])*(l[1]-d[1]),0>c?(this.radiuspoint=h[1],this.anglepoint=h[2]):(this.radiuspoint=h[2],this.anglepoint=h[1])),p=[T.Z(),T.X(),T.Y()],m=p.slice(0),E=x.Dist(T),k/=M,A/=M,this.dataX=[p[1]/p[0]],this.dataY=[p[2]/p[0]];n>r.eps;)n>=O?(t=O,n-=O):(t=n,n=0),i=Math.cos(S*t),s=Math.sin(S*t),o=[[1,0,0],[k*(1-i)+A*s,i,-s],[A*(1-i)-k*s,s,i]],a=r.matVecMult(o,p),m=[a[0]/a[0],a[1]/a[0],a[2]/a[0]],v=p[1]-k,C=p[2]-A,y=m[1]-k,P=m[2]-A,_=Math.sqrt((v+y)*(v+y)+(C+P)*(C+P)),g=Math.abs(P-C)>r.eps?8*((v+y)*(E/_-.5)/(P-C))/3:8*((C+P)*(E/_-.5)/(v-y))/3,f=[1,p[1]-g*C,p[2]+g*v],b=[1,m[1]+g*P,m[2]-g*y],this.dataX=this.dataX.concat([f[1],b[1],m[1]]),this.dataY=this.dataY.concat([f[2],b[2],m[2]]),p=m.slice(0);this.bezierDegree=3,this.updateStdform(),this.updateQuadraticform()},l.Radius=function(){return this.radiuspoint.Dist(this.center)},l.getRadius=function(){return this.Radius()},l.hasPoint=function(t,s){var o,a,h,c,l,d,u,p,f=this.board.options.precision.hasPoint/this.board.unitX,b=this.Radius();return a=new i(n.COORDS_BY_SCREEN,[t,s],this.board),this.transformations.length>0&&(this.updateTransformMatrix(),u=r.inverse(this.transformMat),p=r.matVecMult(u,a.usrCoords),a=new i(n.COORDS_BY_USER,p,this.board)),o=this.center.coords.distance(n.COORDS_BY_USER,a),h=f>Math.abs(o-b),h&&(c=e.rad(this.radiuspoint,this.center,a.usrCoords.slice(1)),l=0,d=e.rad(this.radiuspoint,this.center,this.anglepoint),("minor"===this.visProp.type&&d>Math.PI||"major"===this.visProp.type&&Math.PI>d)&&(l=d,d=2*Math.PI),(l>c||c>d)&&(h=!1)),h},l.hasPointSector=function(t,r){var s,o,a,h=new i(n.COORDS_BY_SCREEN,[t,r],this.board),c=this.Radius(),l=this.center.coords.distance(n.COORDS_BY_USER,h),d=c>l;return d&&(s=e.rad(this.radiuspoint,this.center,h.usrCoords.slice(1)),o=0,a=e.rad(this.radiuspoint,this.center,this.anglepoint),("minor"===this.visProp.type&&a>Math.PI||"major"===this.visProp.type&&Math.PI>a)&&(o=a,a=2*Math.PI),(o>s||s>a)&&(d=!1)),d},l.getTextAnchor=function(){return this.center.coords},l.getLabelAnchor=function(){var t,r,s,a,h=e.rad(this.radiuspoint,this.center,this.anglepoint),c=10/this.board.unitX,l=10/this.board.unitY,d=this.point2.coords.usrCoords,u=this.center.coords.usrCoords,p=d[1]-u[1],f=d[2]-u[2];return o.exists(this.label.content)&&(this.label.content.relativeCoords=new i(n.COORDS_BY_SCREEN,[0,0],this.board)),("minor"===this.visProp.type&&h>Math.PI||"major"===this.visProp.type&&Math.PI>h)&&(h=-(2*Math.PI-h)),t=new i(n.COORDS_BY_USER,[u[1]+Math.cos(.5*h)*p-Math.sin(.5*h)*f,u[2]+Math.sin(.5*h)*p+Math.cos(.5*h)*f],this.board),r=t.usrCoords[1]-u[1],s=t.usrCoords[2]-u[2],a=Math.sqrt(r*r+s*s),r=r*(a+c)/a,s=s*(a+l)/a,new i(n.COORDS_BY_USER,[u[1]+r,u[2]+s],this.board)},l.updateQuadraticform=s.Circle.prototype.updateQuadraticform,l.updateStdform=s.Circle.prototype.updateStdform,l.methodMap=t.deepCopy(l.methodMap,{getRadius:"getRadius",radius:"Radius",center:"center",radiuspoint:"radiuspoint",anglepoint:"anglepoint"}),l.prepareUpdate().update(),l},t.registerElement("arc",t.createArc),t.createSemicircle=function(t,e,r){var i,s,n;if(!o.isPoint(e[0])||!o.isPoint(e[1]))throw Error("JSXGraph: Can't create Semicircle with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"'."+"\nPossible parent types: [point,point]");return n=o.copyAttributes(r,t.options,"semicircle","midpoint"),s=t.create("midpoint",[e[0],e[1]],n),s.dump=!1,n=o.copyAttributes(r,t.options,"semicircle"),i=t.create("arc",[s,e[1],e[0]],n),i.elType="semicircle",i.parents=[e[0].id,e[1].id],i.subs={midpoint:s},i.midpoint=i.center=s,i},t.registerElement("semicircle",t.createSemicircle),t.createCircumcircleArc=function(t,e,r){var i,s,n;if(!(o.isPoint(e[0])&&o.isPoint(e[1])&&o.isPoint(e[2])))throw Error("JSXGraph: create Circumcircle Arc with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"' and '"+typeof e[2]+"'."+"\nPossible parent types: [point,point,point]");return n=o.copyAttributes(r,t.options,"circumcirclearc","center"),s=t.create("circumcenter",[e[0],e[1],e[2]],n),s.dump=!1,n=o.copyAttributes(r,t.options,"circumcirclearc"),n.usedirection=!0,i=t.create("arc",[s,e[0],e[2],e[1]],n),i.elType="circumcirclearc",i.parents=[e[0].id,e[1].id,e[2].id],i.subs={center:s},i.center=s,i},t.registerElement("circumcirclearc",t.createCircumcircleArc),t.createMinorArc=function(e,r,i){return i.type="minor",t.createArc(e,r,i)},t.registerElement("minorarc",t.createMinorArc),t.createMajorArc=function(e,r,i){return i.type="major",t.createArc(e,r,i)},t.registerElement("majorarc",t.createMajorArc),{createArc:t.createArc,createSemicircle:t.createSemicircle,createCircumcircleArc:t.createCircumcircleArc,createMinorArc:t.createMinorArc,createMajorArc:t.createMajorArc}}),define("element/sector",["jxg","math/geometry","math/math","base/coords","base/constants","utils/type","base/point","base/curve","base/transformation","element/composition"],function(t,e,r,i,s,o){return t.createSector=function(n,a,h){var c,l,d,u=["center","radiuspoint","anglepoint"];if(!(o.isPoint(a[0])&&o.isPoint(a[1])&&o.isPoint(a[2])))try{for(l=0;a.length>l;l++)o.isPoint(a[l])||(d=o.copyAttributes(h,n.options,"sector",u[l]),a[l]=n.create("point",a[l],d))}catch(p){throw Error("JSXGraph: Can't create Sector with parent types '"+typeof a[0]+"' and '"+typeof a[1]+"' and '"+typeof a[2]+"'.")}return d=o.copyAttributes(h,n.options,"sector"),c=n.create("curve",[[0],[0]],d),c.type=s.OBJECT_TYPE_SECTOR,c.elType="sector",c.parents=[a[0].id,a[1].id,a[2].id],c.point1=n.select(a[0]),c.center=c.point1,c.point2=n.select(a[1]),c.radiuspoint=c.point2,c.point3=n.select(a[2]),c.anglepoint=c.point3,c.point1.addChild(c),c.point2.addChild(c),c.point3.addChild(c),c.useDirection=h.usedirection,c.methodMap=t.deepCopy(c.methodMap,{center:"center",radiuspoint:"radiuspoint",anglepoint:"anglepoint",radius:"getRadius",getRadius:"getRadius"}),c.updateDataArray=function(){var t,i,s,o,n,h,c,l,d,u,p,f,b,m,g,v,C,y,P,_,E=this.point2,S=this.point1,O=this.point3,T=e.rad(E,S,O),x=S.X(),w=S.Y(),k=S.Z(),A=.5*Math.PI;if(!E.isReal||!S.isReal||!O.isReal)return this.dataX=[0/0],this.dataY=[0/0],void 0;
for(this.useDirection&&(c=a[1].coords.usrCoords,l=a[3].coords.usrCoords,d=a[2].coords.usrCoords,h=(c[1]-d[1])*(c[2]-l[2])-(c[2]-d[2])*(c[1]-l[1]),0>h?(this.point2=a[1],this.point3=a[2]):(this.point2=a[2],this.point3=a[1])),_=S.Dist(E),u=[E.Z(),E.X(),E.Y()],u[1]/=u[0],u[2]/=u[0],u[0]/=u[0],b=u.slice(0),x/=k,w/=k,this.dataX=[x,x+.333*(u[1]-x),x+.666*(u[1]-x),u[1]],this.dataY=[w,w+.333*(u[2]-w),w+.666*(u[2]-w),u[2]];T>r.eps;)T>=A?(i=A,T-=A):(i=T,T=0),s=Math.cos(i),o=Math.sin(i),n=[[1,0,0],[x*(1-s)+w*o,s,-o],[w*(1-s)-x*o,o,s]],t=r.matVecMult(n,u),b=[t[0]/t[0],t[1]/t[0],t[2]/t[0]],g=u[1]-x,v=u[2]-w,C=b[1]-x,y=b[2]-w,P=Math.sqrt((g+C)*(g+C)+(v+y)*(v+y)),m=Math.abs(y-v)>r.eps?8*((g+C)*(_/P-.5)/(y-v))/3:8*((v+y)*(_/P-.5)/(g-C))/3,p=[1,u[1]-m*v,u[2]+m*g],f=[1,b[1]+m*y,b[2]-m*C],this.dataX=this.dataX.concat([p[1],f[1],b[1]]),this.dataY=this.dataY.concat([p[2],f[2],b[2]]),u=b.slice(0);this.dataX=this.dataX.concat([b[1]+.333*(x-b[1]),b[1]+.666*(x-b[1]),x]),this.dataY=this.dataY.concat([b[2]+.333*(w-b[2]),b[2]+.666*(w-b[2]),w]),this.bezierDegree=3},c.Radius=function(){return this.point2.Dist(this.point1)},c.getRadius=function(){return this.Radius()},c.hasPoint=function(t,r){var o,n,a,h=this.board.options.precision.hasPoint/this.board.unitX,c=new i(s.COORDS_BY_SCREEN,[t,r],this.board),l=this.Radius(),d=this.center.coords.distance(s.COORDS_BY_USER,c),u=h>Math.abs(d-l);return u&&(o=e.rad(this.point2,this.center,c.usrCoords.slice(1)),n=0,a=e.rad(this.point2,this.center,this.point3),(n>o||o>a)&&(u=!1)),u},c.hasPointSector=function(t,r){var o,n=new i(s.COORDS_BY_SCREEN,[t,r],this.board),a=this.Radius(),h=this.point1.coords.distance(s.COORDS_BY_USER,n),c=a>h;return c&&(o=e.rad(this.point2,this.point1,n.usrCoords.slice(1)),o>e.rad(this.point2,this.point1,this.point3)&&(c=!1)),c},c.getTextAnchor=function(){return this.point1.coords},c.getLabelAnchor=function(){var t,r,n,a,h=e.rad(this.point2,this.point1,this.point3),c=13/this.board.unitX,l=13/this.board.unitY,d=this.point2.coords.usrCoords,u=this.point1.coords.usrCoords,p=d[1]-u[1],f=d[2]-u[2];return o.exists(this.label.content)&&(this.label.content.relativeCoords=new i(s.COORDS_BY_SCREEN,[0,0],this.board)),t=new i(s.COORDS_BY_USER,[u[1]+Math.cos(.5*h)*p-Math.sin(.5*h)*f,u[2]+Math.sin(.5*h)*p+Math.cos(.5*h)*f],this.board),r=t.usrCoords[1]-u[1],n=t.usrCoords[2]-u[2],a=Math.sqrt(r*r+n*n),r=r*(a+c)/a,n=n*(a+l)/a,new i(s.COORDS_BY_USER,[u[1]+r,u[2]+n],this.board)},c.prepareUpdate().update(),c},t.registerElement("sector",t.createSector),t.createCircumcircleSector=function(t,e,r){var i,s,n;if(!(o.isPoint(e[0])&&o.isPoint(e[1])&&o.isPoint(e[2])))throw Error("JSXGraph: Can't create circumcircle sector with parent types '"+typeof e[0]+"' and '"+typeof e[1]+"' and '"+typeof e[2]+"'.");return n=o.copyAttributes(r,t.options,"circumcirclesector","center"),s=t.create("circumcenter",[e[0],e[1],e[2]],n),s.dump=!1,n=o.copyAttributes(r,t.options,"circumcirclesector"),i=t.create("sector",[s,e[0],e[2],e[1]],n),i.elType="circumcirclesector",i.parents=[e[0].id,e[1].id,e[2].id],i.center=s,i.subs={center:s},i},t.registerElement("circumcirclesector",t.createCircumcircleSector),t.createAngle=function(t,n,a){var h,c,l,d,u,p,f,b;if(!(o.isPoint(n[0])&&o.isPoint(n[1])&&o.isPoint(n[2])))throw Error("JSXGraph: Can't create angle with parent types '"+typeof n[0]+"' and '"+typeof n[1]+"' and '"+typeof n[2]+"'.");for(u=o.copyAttributes(a,t.options,"angle"),d=u.name,o.exists(d)&&""!==d||(d=t.generateName({type:s.OBJECT_TYPE_ANGLE}),u.name=d),p=o.copyAttributes(a,t.options,"angle","radiuspoint"),c=t.create("point",[0,1,0],p),c.dump=!1,p=o.copyAttributes(a,t.options,"angle","pointsquare"),l=t.create("point",[0,1,1],p),l.dump=!1,h=t.create("sector",[n[1],c,n[2]],u),h.elType="angle",h.parents=[n[0].id,n[1].id,n[2].id],h.subs={point:c,pointsquare:l},h.updateDataArraySquare=function(){var t,e,i,s,o=n[1];t=r.crossProduct(l.coords.usrCoords,o.coords.usrCoords),e=[-c.X()*t[1]-c.Y()*t[2],c.Z()*t[1],c.Z()*t[2]],t=r.crossProduct(c.coords.usrCoords,o.coords.usrCoords),i=[-l.X()*t[1]-l.Y()*t[2],l.Z()*t[1],l.Z()*t[2]],s=r.crossProduct(e,i),s[1]/=s[0],s[2]/=s[0],this.dataX=[o.X(),c.X(),s[1],l.X(),o.X()],this.dataY=[o.Y(),c.Y(),s[2],l.Y(),o.Y()],this.bezierDegree=1},h.updateDataArrayNone=function(){this.dataX=[0/0],this.dataY=[0/0],this.bezierDegree=1},h.updateDataArraySector=h.updateDataArray,h.updateDataArray=function(){var t=this.visProp.type,r=e.trueAngle(n[0],n[1],n[2]);Math.abs(r-90)<this.visProp.orthosensitivity&&(t=this.visProp.orthotype),"none"===t?this.updateDataArrayNone():"square"===t?this.updateDataArraySquare():"sector"===t?this.updateDataArraySector():"sectordot"===t&&(this.updateDataArraySector(),this.dot.visProp.visible||this.dot.setAttribute({visible:!0})),"sectordot"!==t&&this.dot.visProp.visible&&this.dot.setAttribute({visible:!1})},c.addConstraint([function(){var t=n[0],e=n[1],r=o.evaluate(h.visProp.radius),i=e.Dist(t);return[e.X()+(t.X()-e.X())*r/i,e.Y()+(t.Y()-e.Y())*r/i]}]),l.addConstraint([function(){var t=n[2],e=n[1],r=o.evaluate(h.visProp.radius),i=e.Dist(t);return[e.X()+(t.X()-e.X())*r/i,e.Y()+(t.Y()-e.Y())*r/i]}]),h.radiuspoint=c,h.point=c,h.pointsquare=l,b=o.copyAttributes(a,t.options,"angle","dot"),h.dot=t.create("point",[function(){if(o.exists(h.dot)&&!h.dot.visProp.visible)return[0,0];var t=c.coords.usrCoords,i=.5*e.rad(n[0],n[1],n[2]),s=n[1].X(),a=n[1].Y(),l=[[1,0,0],[s-.5*s*Math.cos(i)+.5*a*Math.sin(i),.5*Math.cos(i),.5*-Math.sin(i)],[a-.5*s*Math.sin(i)-.5*a*Math.cos(i),.5*Math.sin(i),.5*Math.cos(i)]];return r.matVecMult(l,t)}],b),h.dot.dump=!1,h.subs.dot=h.dot,f=0;3>f;f++)t.select(n[f]).addChild(c),t.select(n[f]).addChild(h.dot);return h.type=s.OBJECT_TYPE_ANGLE,t.select(n[0]).addChild(h),h.rot=t.create("transform",[function(){return.5*e.rad(h.point2,h.point1,h.point3)},h.point1],{type:"rotate"}),h.getLabelAnchor=function(){var t,e,n,a,h=12,c=12,l=this.point1.coords.usrCoords;return o.exists(this.label.content)&&(this.label.content.relativeCoords=new i(s.COORDS_BY_SCREEN,[0,0],this.board)),o.exists(this.visProp.label.fontSize)&&(h=this.visProp.label.fontSize,c=this.visProp.label.fontSize),h/=this.board.unitX,c/=this.board.unitY,this.rot.update(),a=r.matVecMult(this.rot.matrix,this.point2.coords.usrCoords),t=a[1]-l[1],e=a[2]-l[2],n=Math.sqrt(t*t+e*e),t=t*(n+h)/n,e=e*(n+c)/n,new i(s.COORDS_BY_USER,[l[1]+t,l[2]+e],this.board)},h.Value=function(){return e.rad(this.point2,this.point1,this.point3)},h.setAngle=function(t){var e,r=this.anglepoint,i=this.radiuspoint;return r.draggable()&&(e=this.board.create("transform",[t,this.center],{type:"rotate"}),r.addTransform(i,e),r.isDraggable=!1,r.parents=[i]),this},h.free=function(){var t=this.anglepoint;return t.transformations.length>0&&(t.transformations.pop(),t.isDraggable=!0,t.parents=[]),this},h.methodMap=o.deepCopy(h.methodMap,{Value:"Value",setAngle:"setAngle",free:"free"}),h},t.registerElement("angle",t.createAngle),{createSector:t.createSector,createCircumcircleSector:t.createCircumcircleSector,createAngle:t.createAngle}}),define("element/locus",["jxg","math/symbolic","utils/type","base/constants","base/curve"],function(t,e,r,i){return t.createLocus=function(t,s,o){var n,a;if(!r.isArray(s)||1!==s.length||s[0].elementClass!==i.OBJECT_CLASS_POINT)throw Error("JSXGraph: Can't create locus with parent of type other than point.\nPossible parent types: [point]");return a=s[0],n=t.create("curve",[[null],[null]],o),n.dontCallServer=!1,n.elType="locus",n.parents=[a.id],n.updateDataArray=function(){var r,i,s;n.board.mode>0||(r=e.generatePolynomials(t,a,!0).join("|"),r!==n.spe&&(n.spe=r,i=function(t,e,r,i){n.dataX=t,n.dataY=e,n.eq=r,n.ctime=i,n.generatePolynomial=function(t){return function(e){var r,i="("+e.symbolic.x+")",s="("+e.symbolic.y+")",o=[];for(r=0;t.length>r;r++)o[r]=t[r].replace(/\*\*/g,"^").replace(/x/g,i).replace(/y/g,s);return o}}(r)},s=e.geometricLocusByGroebnerBase(t,a,i),i(s.datax,s.datay,s.polynomial,s.exectime)))},n},t.registerElement("locus",t.createLocus),{createLocus:t.createLocus}}),define("base/image",["jxg","base/constants","base/coords","base/element","math/math","math/statistics","utils/type"],function(t,e,r,i,s,o,n){return t.Image=function(i,s,o,a,h){this.constructor(i,h,e.OBJECT_TYPE_IMAGE,e.OBJECT_CLASS_OTHER),this.initialCoords=new r(e.COORDS_BY_USER,o,this.board),n.isFunction(o[0])||n.isFunction(o[1])||(this.isDraggable=!0),this.X=n.createFunction(o[0],this.board,""),this.Y=n.createFunction(o[1],this.board,""),this.Z=n.createFunction(1,this.board,""),this.W=n.createFunction(a[0],this.board,""),this.H=n.createFunction(a[1],this.board,""),this.coords=new r(e.COORDS_BY_USER,[this.X(),this.Y()],this.board),this.usrSize=[this.W(),this.H()],this.size=[Math.abs(this.usrSize[0]*i.unitX),Math.abs(this.usrSize[1]*i.unitY)],this.url=s,this.elType="image",this.span=[[this.Z(),this.X(),this.Y()],[this.Z(),this.W(),0],[this.Z(),0,this.H()]],this.parent=i.select(h.anchor),this.id=this.board.setId(this,"Im"),this.board.renderer.drawImage(this),this.visProp.visible||this.board.renderer.hide(this),this.methodMap=t.deepCopy(this.methodMap,{addTransformation:"addTransform",trans:"addTransform"})},t.Image.prototype=new i,t.extend(t.Image.prototype,{hasPoint:function(t,i){var o,n,a,h,c,l,d,u=this.transformations.length;return 0===u?(o=t-this.coords.scrCoords[1],n=this.coords.scrCoords[2]-i,a=this.board.options.precision.hasPoint,o>=-a&&a>=o-this.size[0]&&n>=-a&&a>=n-this.size[1]):(h=new r(e.COORDS_BY_SCREEN,[t,i],this.board),h=h.usrCoords,c=[h[0]-this.span[0][0],h[1]-this.span[0][1],h[2]-this.span[0][2]],d=s.innerProduct,l=d(c,this.span[1]),l>=0&&d(this.span[1],this.span[1])>=l&&(l=d(c,this.span[2]),l>=0&&d(this.span[2],this.span[2])>=l)?!0:!1)},update:function(){return this.needsUpdate&&(this.visProp.frozen||this.updateCoords(),this.usrSize=[this.W(),this.H()],this.size=[Math.abs(this.usrSize[0]*this.board.unitX),Math.abs(this.usrSize[1]*this.board.unitY)],this.updateTransform(),this.updateSpan()),this},updateRenderer:function(){return this.needsUpdate&&(this.board.renderer.updateImage(this),this.needsUpdate=!1),this},updateTransform:function(){var t,e=this.transformations.length;if(e>0)for(t=0;e>t;t++)this.transformations[t].update();return this},updateCoords:function(){this.coords.setCoordinates(e.COORDS_BY_USER,[this.X(),this.Y()])},updateSize:function(){this.coords.setCoordinates(e.COORDS_BY_USER,[this.W(),this.H()])},updateSpan:function(){var t,e,r=this.transformations.length,i=[];if(0===r)this.span=[[this.Z(),this.X(),this.Y()],[this.Z(),this.W(),0],[this.Z(),0,this.H()]];else{for(i[0]=[this.Z(),this.X(),this.Y()],i[1]=[this.Z(),this.X()+this.W(),this.Y()],i[2]=[this.Z(),this.X(),this.Y()+this.H()],t=0;r>t;t++)for(e=0;3>e;e++)i[e]=s.matVecMult(this.transformations[t].matrix,i[e]);for(e=0;3>e;e++)i[e][1]/=i[e][0],i[e][2]/=i[e][0],i[e][0]/=i[e][0];for(e=1;3>e;e++)i[e][0]-=i[0][0],i[e][1]-=i[0][1],i[e][2]-=i[0][2];this.span=i}return this},addTransform:function(t){var e;if(n.isArray(t))for(e=0;t.length>e;e++)this.transformations.push(t[e]);else this.transformations.push(t)},setPositionDirectly:function(t,e,i){var s,a=new r(t,e,this.board),h=new r(t,i,this.board),c=[this.Z(),this.X(),this.Y()];return s=o.subtract(a.usrCoords,h.usrCoords),this.X=n.createFunction(c[1]+s[1],this.board,""),this.Y=n.createFunction(c[2]+s[2],this.board,""),this}}),t.createImage=function(e,r,i){var s,o;return s=n.copyAttributes(i,e.options,"image"),o=new t.Image(e,r[0],r[1],r[2],s),0!==n.evaluate(s.rotate)&&o.addRotation(n.evaluate(s.rotate)),o},t.registerElement("image",t.createImage),{Image:t.Image,createImage:t.createImage}}),define("element/slider",["jxg","math/math","base/constants","utils/type","base/point","base/group","base/line","base/ticks","base/text"],function(t,e,r,i,s){return t.createSlider=function(t,o,n){var a,h,c,l,d,u,p,f,b,m,g,v,C,y,P,_,E,S,O,T,x,w;return a=o[0],h=o[1],c=o[2][0],l=o[2][1],d=o[2][2],u=d-c,x=i.copyAttributes(n,t.options,"slider"),O=x.withticks,S=x.withlabel,T=x.snapwidth,w=x.precision,x=i.copyAttributes(n,t.options,"slider","point1"),p=t.create("point",a,x),x=i.copyAttributes(n,t.options,"slider","point2"),f=t.create("point",h,x),t.create("group",[p,f]),x=i.copyAttributes(n,t.options,"slider","baseline"),b=t.create("segment",[p,f],x),b.updateStdform(),O&&(x=i.copyAttributes(n,t.options,"slider","ticks"),m=2,g=t.create("ticks",[b,f.Dist(p)/m,function(t){var i=p.Dist(f),s=p.coords.distance(r.COORDS_BY_USER,t);return e.eps>i?0:s/i*u+c}],x)),v=a[0]+(h[0]-a[0])*(l-c)/(d-c),C=a[1]+(h[1]-a[1])*(l-c)/(d-c),x=i.copyAttributes(n,t.options,"slider"),x.withLabel=!1,y=t.create("glider",[v,C,b],x),y.setAttribute({snapwidth:T}),x=i.copyAttributes(n,t.options,"slider","highline"),P=t.create("segment",[p,y],x),y.Value=function(){return-1===y.visProp.snapwidth?this.position*u+c:Math.round((this.position*u+c)/this.visProp.snapwidth)*this.visProp.snapwidth},y.methodMap=i.deepCopy(y.methodMap,{Value:"Value"}),y._smax=d,y._smin=c,S&&(_=n.name&&""!==n.name?n.name+" = ":"",x=i.copyAttributes(n,t.options,"slider","label"),E=t.create("text",[function(){return.05*(f.X()-p.X())+f.X()},function(){return.05*(f.Y()-p.Y())+f.Y()},function(){return _+y.Value().toFixed(w)}],x),y.label.content=E),y.point1=p,y.point2=f,y.baseline=b,y.highline=P,O&&(y.ticks=g),y.remove=function(){S&&t.removeObject(E),t.removeObject(P),t.removeObject(b),t.removeObject(f),t.removeObject(p),s.Point.prototype.remove.call(y)},p.dump=!1,f.dump=!1,b.dump=!1,P.dump=!1,y.elType="slider",y.parents=o,y.subs={point1:p,point2:f,baseLine:b,highLine:P},O&&(g.dump=!1,y.subs.ticks=g),y},t.registerElement("slider",t.createSlider),{createSlider:t.createSlider}}),define("element/measure",["jxg","utils/type","base/element","base/point","base/line","base/ticks"],function(t,e,r){return t.createTapemeasure=function(i,s,o){var n,a,h,c,l,d,u,p,f,b,m;return n=s[0],a=s[1],h=e.copyAttributes(o,i.options,"tapemeasure"),c=h.withticks,l=h.withlabel,d=h.precision,h=e.copyAttributes(o,i.options,"tapemeasure","point1"),p=i.create("point",n,h),h=e.copyAttributes(o,i.options,"tapemeasure","point2"),f=i.create("point",a,h),h=e.copyAttributes(o,i.options,"tapemeasure"),l&&(h.withlabel=!0),u=i.create("segment",[p,f],h),l&&(b=o.name&&""!==o.name?o.name+" = ":"",u.label.content._setText(function(){return b+p.Dist(f).toFixed(d)})),c&&(h=e.copyAttributes(o,i.options,"tapemeasure","ticks"),m=i.create("ticks",[u,.1],h)),u.remove=function(){c&&u.removeTicks(m),i.removeObject(f),i.removeObject(p),r.prototype.remove.call(this)},u.Value=function(){return p.Dist(f)},p.dump=!1,f.dump=!1,u.elType="tapemeasure",u.parents=s,u.subs={point1:p,point2:f},c&&(m.dump=!1),u.methodMap=t.deepCopy(u.methodMap,{Value:"Value"}),u},t.registerElement("tapemeasure",t.createTapemeasure),{createTapemeasure:t.createTapemeasure}}),define("parser/datasource",["jxg","utils/type"],function(t,e){return t.DataSource=function(){return this.data=[],this.columnHeaders=[],this.rowHeaders=[],this},t.extend(t.DataSource.prototype,{loadFromArray:function(t,r,i){var s,o,n;if(e.isArray(r)&&(this.columnHeaders=r,r=!1),e.isArray(i)&&(this.rowHeaders=i,i=!1),this.data=[],r&&(this.columnHeaders=[]),i&&(this.rowHeaders=[]),e.exists(t)){for(this.data=[],s=0;t.length>s;s++)for(this.data[s]=[],o=0;t[s].length>o;o++)n=t[s][o],this.data[s][o]=""+parseFloat(n)===n?parseFloat(n):"-"!==n?n:0/0;if(r&&(this.columnHeaders=this.data[0].slice(1),this.data=this.data.slice(1)),i)for(this.rowHeaders=[],s=0;this.data.length>s;s++)this.rowHeaders.push(this.data[s][0]),this.data[s]=this.data[s].slice(1)}return this},loadFromTable:function(t,r,i){var s,o,n,a,h;if(e.isArray(r)&&(this.columnHeaders=r,r=!1),e.isArray(i)&&(this.rowHeaders=i,i=!1),this.data=[],r&&(this.columnHeaders=[]),i&&(this.rowHeaders=[]),t=document.getElementById(t),e.exists(t)){for(s=t.getElementsByTagName("tr"),this.data=[],o=0;s.length>o;o++)for(a=s[o].getElementsByTagName("td"),this.data[o]=[],n=0;a.length>n;n++)h=a[n].innerHTML,this.data[o][n]=""+parseFloat(h)===h?parseFloat(h):"-"!==h?h:0/0;if(r&&(this.columnHeaders=this.data[0].slice(1),this.data=this.data.slice(1)),i)for(this.rowHeaders=[],o=0;this.data.length>o;o++)this.rowHeaders.push(this.data[o][0]),this.data[o]=this.data[o].slice(1)}return this},addColumn:function(){throw Error("not implemented")},addRow:function(){throw Error("not implemented")},getColumn:function(t){var e,r=[];if("string"==typeof t)for(e=0;this.columnHeaders.length>e;e++)if(t===this.columnHeaders[e]){t=e;break}for(e=0;this.data.length>e;e++)this.data[e].length>t&&(r[e]=parseFloat(this.data[e][t]));return r},getRow:function(t){var e,r;if("string"==typeof t)for(r=0;this.rowHeaders.length>r;r++)if(t===this.rowHeaders[r]){t=r;break}for(e=[],r=0;this.data[t].length>r;r++)e[r]=this.data[t][r];return e}}),t.DataSource}),define("base/chart",["jxg","math/numerics","math/statistics","base/constants","base/coords","base/element","parser/datasource","utils/color","utils/type","utils/env","base/curve","base/point","base/text","base/polygon","element/sector","base/transformation","base/line","base/circle"],function(t,e,r,i,s,o,n,a,h,c){return t.Chart=function(t,e,r){this.constructor(t,r);var i,s,o,n,a,c;if(!h.isArray(e)||0===e.length)throw Error("JSXGraph: Can't create a chart without data");if(this.elements=[],h.isNumber(e[0]))for(s=e,i=[],o=0;s.length>o;o++)i[o]=o+1;else if(1===e.length&&h.isArray(e[0]))for(s=e[0],i=[],c=h.evaluate(s).length,o=0;c>o;o++)i[o]=o+1;else 2===e.length&&(c=Math.min(e[0].length,e[1].length),i=e[0].slice(0,c),s=e[1].slice(0,c));if(h.isArray(s)&&0===s.length)throw Error("JSXGraph: Can't create charts without data.");for(a=r.chartstyle.replace(/ /g,"").split(","),o=0;a.length>o;o++){switch(a[o]){case"bar":n=this.drawBar(t,i,s,r);break;case"line":n=this.drawLine(t,i,s,r);break;case"fit":n=this.drawFit(t,i,s,r);break;case"spline":n=this.drawSpline(t,i,s,r);break;case"pie":n=this.drawPie(t,s,r);break;case"point":n=this.drawPoints(t,i,s,r);break;case"radar":n=this.drawRadar(t,e,r)}this.elements.push(n)}return this.id=this.board.setId(this,"Chart"),this.elements},t.Chart.prototype=new o,t.extend(t.Chart.prototype,{drawLine:function(t,e,r,i){return i.fillcolor="none",i.highlightfillcolor="none",t.create("curve",[e,r],i)},drawSpline:function(t,e,r,i){return i.fillColor="none",i.highlightfillcolor="none",t.create("spline",[e,r],i)},drawFit:function(t,r,i,s){var o=s.degree;return o=Math.max(parseInt(o,10),1)||1,s.fillcolor="none",s.highlightfillcolor="none",t.create("functiongraph",[e.regressionPolynomial(o,r,i)],s)},drawBar:function(t,e,r,i){var s,o,n,a,c,l,d,u,p,f,b,m,g=[],v=[],C=function(t,r){return function(){return e[t]()-r*l}},y={fixed:!0,withLabel:!1,visible:!1,name:""};if(h.exists(i.fillopacity)||(i.fillopacity=.6),i&&i.width)l=i.width;else{if(1>=e.length)l=1;else for(l=e[1]-e[0],s=1;e.length-1>s;s++)l=l>e[s+1]-e[s]?e[s+1]-e[s]:l;l*=.8}for(n=i.fillcolor,m=h.copyAttributes(i,t.options,"chart","label"),a=parseFloat(m.fontsize),s=0;e.length>s;s++)h.isFunction(e[s])?(d=C(s,-.5),u=C(s,0),p=C(s,.5)):(d=e[s]-.5*l,u=e[s],p=e[s]+.5*l),f=r[s],"horizontal"===i.dir?(v[0]=t.create("point",[0,d],y),v[1]=t.create("point",[f,d],y),v[2]=t.create("point",[f,p],y),v[3]=t.create("point",[0,p],y),h.exists(i.labels)&&h.exists(i.labels[s])&&(o=(""+i.labels[s]).length,o=2*o*a/t.unitX,f>=0?f+=.5*a/t.unitX:f-=a*o/t.unitX,u-=.2*a/t.unitY,c=t.create("text",""+[f,u,i.labels[s]],m))):(v[0]=t.create("point",[d,0],y),v[1]=t.create("point",[d,f],y),v[2]=t.create("point",[p,f],y),v[3]=t.create("point",[p,0],y),h.exists(i.labels)&&h.exists(i.labels[s])&&(o=(""+i.labels[s]).length,o=.6*o*a/t.unitX,f>=0?f+=.5*a/t.unitY:f-=a/t.unitY,c=t.create("text",[u-.5*o,f,""+i.labels[s]],m))),i.withlines=!1,h.isArray(i.colors)&&(b=i.colors,i.fillcolor=b[s%b.length]),g[s]=t.create("polygon",v,i),h.exists(i.labels)&&h.exists(i.labels[s])&&(g[s].text=c);return g},drawPoints:function(t,e,r,i){var s,o=[],n=i.infoboxarray;for(i.fixed=!0,i.name="",s=0;e.length>s;s++)i.infoboxtext=n?n[s%n.length]:!1,o[s]=t.create("point",[e[s],r[s]],i);return o},drawPie:function(t,e,o){var n,a,c=[],l=[],d=(r.sum(e),o.colors),u=o.highlightcolors,p=o.labels,f=o.radius||4,b=f,m=o.center||[0,0],g=m[0],v=m[1],C=function(t,r,i){return function(){var s,o,n,a=0;for(o=0;t>=o;o++)a+=parseFloat(h.evaluate(e[o]));for(s=a,o=t+1;e.length>o;o++)s+=parseFloat(h.evaluate(e[o]));return n=0!==s?2*Math.PI*a/s:0,b()*Math[r](n)+i}},y=function(t,e){var r=-this.point1.coords.usrCoords[1]+this.point2.coords.usrCoords[1],o=-this.point1.coords.usrCoords[2]+this.point2.coords.usrCoords[2];h.exists(this.label.content)&&(this.label.content.rendNode.style.fontSize=e*this.label.content.visProp.fontsize+"px",this.label.content.prepareUpdate().update().updateRenderer()),this.point2.coords=new s(i.COORDS_BY_USER,[this.point1.coords.usrCoords[1]+r*t,this.point1.coords.usrCoords[2]+o*t],this.board),this.prepareUpdate().update().updateRenderer()},P=function(){this.highlighted||(this.highlighted=!0,this.board.renderer.highlight(this),y.call(this,1.1,2))},_=function(){this.highlighted&&(this.highlighted=!1,this.board.renderer.noHighlight(this),y.call(this,.9090909,1))},E={fixed:!0,withLabel:!1,visible:!1,name:""};if(!h.isArray(p))for(p=[],n=0;e.length>n;n++)p[n]="";for(h.isFunction(f)||(b=function(){return f}),o.highlightonsector=o.highlightonsector||!1,o.straightfirst=!1,o.straightlast=!1,a=t.create("point",[g,v],E),c[0]=t.create("point",[function(){return b()+g},function(){return v}],E),n=0;e.length>n;n++)c[n+1]=t.create("point",[C(n,"cos",g),C(n,"sin",v)],E),o.name=p[n],o.withlabel=""!==o.name,o.fillcolor=d&&d[n%d.length],o.labelcolor=d&&d[n%d.length],o.highlightfillcolor=u&&u[n%u.length],l[n]=t.create("sector",[a,c[n],c[n+1]],o),o.highlightonsector&&(l[n].hasPoint=l[n].hasPointSector),o.highlightbysize&&(l[n].highlight=P,l[n].noHighlight=_);return{sectors:l,points:c,midpoint:a}},drawRadar:function(e,r,o){var n,a,c,l,d,u,p,f,b,m,g,v,C,y,P,_,E,S,O,T,x,w,k,A,M,N,R,L,Y,B,j,D,X,I,J,G,U,F,z,H,V,q,$,W,Z,Q=r.length,K=function(){var t,e,r,o,n=this.visProp.label.offset.slice(0);return t=this.point1.X(),e=this.point2.X(),r=this.point1.Y(),o=this.point2.Y(),t>e&&(n[0]=-n[0]),r>o&&(n[1]=-n[1]),this.setLabelRelativeCoords(n),new s(i.COORDS_BY_USER,[this.point2.X(),this.point2.Y()],this.board)},te=function(t,r){var i,s,o;return i=e.create("transform",[-(P[r]-C[r]),0],{type:"translate"}),s=e.create("transform",[T/(_[r]+y[r]-(P[r]-C[r])),1],{type:"scale"}),i.melt(s),o=e.create("transform",[t],{type:"rotate"}),i.melt(o),i};if(0>=Q)return t.debug("No data"),void 0;if(c=o.paramarray,!h.exists(c))return t.debug("Need paramArray attribute"),void 0;if(l=c.length,1>=l)return t.debug("Need more than 1 param"),void 0;for(n=0;Q>n;n++)if(l!==r[n].length)return t.debug("Use data length equal to number of params ("+r[n].length+" != "+l+")"),void 0;for(d=[],u=[],a=0;l>a;a++)d[a]=r[0][a],u[a]=d[a];for(n=1;Q>n;n++)for(a=0;l>a;a++)r[n][a]>d[a]&&(d[a]=r[n][a]),r[n][a]<u[a]&&(u[a]=r[n][a]);for(p=[],f=[],n=0;Q>n;n++)p[n]="",f[n]=[];for(b=[],m=[],g=o.startshiftratio||0,v=o.endshiftratio||0,n=0;l>n;n++)b[n]=(d[n]-u[n])*g,m[n]=(d[n]-u[n])*v;if(C=o.startshiftarray||b,y=o.endshiftarray||m,P=o.startarray||u,h.exists(o.start))for(n=0;l>n;n++)P[n]=o.start;if(_=o.endarray||d,h.exists(o.end))for(n=0;l>n;n++)_[n]=o.end;if(C.length!==l)return t.debug("Start shifts length is not equal to number of parameters"),void 0;if(y.length!==l)return t.debug("End shifts length is not equal to number of parameters"),void 0;if(P.length!==l)return t.debug("Starts length is not equal to number of parameters"),void 0;if(_.length!==l)return t.debug("Ends length is not equal to number of parameters"),void 0;for(E=o.labelarray||p,S=o.colors,O=o.highlightcolors,T=o.radius||10,W=o.strokewidth||1,h.exists(o.highlightonsector)||(o.highlightonsector=!1),x={name:o.name,id:o.id,strokewidth:W,polystrokewidth:o.polystrokewidth||W,strokecolor:o.strokecolor||"black",straightfirst:!1,straightlast:!1,fillcolor:o.fillColor||"#FFFF88",fillopacity:o.fillOpacity||.4,highlightfillcolor:o.highlightFillColor||"#FF7400",highlightstrokecolor:o.highlightStrokeColor||"black",gradient:o.gradient||"none"},w=o.center||[0,0],k=w[0],A=w[1],M=e.create("point",[k,A],{name:"",fixed:!0,withlabel:!1,visible:!1}),N=Math.PI/2-Math.PI/l,N=o.startangle||0,R=N,L=[],Y=[],n=0;l>n;n++)for(R+=2*Math.PI/l,j=T*Math.cos(R)+k,D=T*Math.sin(R)+A,L[n]=e.create("point",[j,D],{name:"",fixed:!0,withlabel:!1,visible:!1}),Y[n]=e.create("line",[M,L[n]],{name:c[n],strokeColor:x.strokecolor,strokeWidth:x.strokewidth,strokeOpacity:1,straightFirst:!1,straightLast:!1,withLabel:!0,highlightStrokeColor:x.highlightstrokecolor}),Y[n].getLabelAnchor=K,B=te(R,n),a=0;r.length>a;a++)Z=r[a][n],f[a][n]=e.create("point",[Z,0],{name:"",fixed:!0,withlabel:!1,visible:!1}),f[a][n].addTransform(f[a][n],B);for(X=[],n=0;Q>n;n++)for(x.labelcolor=S&&S[n%S.length],x.strokecolor=S&&S[n%S.length],x.fillcolor=S&&S[n%S.length],X[n]=e.create("polygon",f[n],{withLines:!0,withLabel:!1,fillColor:x.fillcolor,fillOpacity:x.fillopacity,highlightFillColor:x.highlightfillcolor}),a=0;l>a;a++)X[n].borders[a].setAttribute("strokecolor:"+S[n%S.length]),X[n].borders[a].setAttribute("strokewidth:"+x.polystrokewidth);switch(I=o.legendposition||"none"){case"right":G=o.legendleftoffset||2,U=o.legendtopoffset||1,this.legend=e.create("legend",[k+T+G,A+T-U],{labels:E,colors:S});break;case"none":break;default:t.debug("Unknown legend position")}if(J=[],o.showcircles){for(F=[],n=0;6>n;n++)F[n]=20*n;if(F[0]="0",z=o.circlelabelarray||F,H=z.length,2>H)return t.debug("Too less circles"),void 0;for(V=[],q=N+Math.PI/l,B=te(q,0),x.fillcolor="none",x.highlightfillcolor="none",x.strokecolor=o.strokecolor||"black",x.strokewidth=o.circlestrokewidth||.5,x.layer=0,$=(_[0]-P[0])/(H-1),n=0;H>n;n++)V[n]=e.create("point",[P[0]+n*$,0],{name:z[n],size:0,fixed:!0,withLabel:!0,visible:!0}),V[n].addTransform(V[n],B),J[n]=e.create("circle",[M,V[n]],x)}return this.rendNode=X[0].rendNode,{circles:J,lines:Y,points:f,midpoint:M,polygons:X}},updateRenderer:function(){return this},update:function(){return this.needsUpdate&&this.updateDataArray(),this},updateDataArray:function(){}}),t.createChart=function(e,r,i){var s,o,l,d,u,p,f,b,m,g,v,C,y,P,_,E,S=[],O=c.isBrowser?document.getElementById(r[0]):null;if(1===r.length&&"string"==typeof r[0]){if(h.exists(O)){if(m=h.copyAttributes(i,e.options,"chart"),O=(new n).loadFromTable(r[0],m.withheaders,m.withheaders),s=O.data,u=O.columnHeaders,o=O.rowHeaders,g=m.width,v=m.name,C=m.strokecolor,y=m.fillcolor,P=m.highlightstrokecolor,_=m.highlightfillcolor,e.suspendUpdate(),E=s.length,b=[],m.rows&&h.isArray(m.rows)){for(l=0;E>l;l++)for(d=0;m.rows.length>d;d++)if(m.rows[d]===l||m.withheaders&&m.rows[d]===o[l]){b.push(s[l]);break}}else b=s;for(E=b.length,l=0;E>l;l++){if(f=[],m.chartstyle&&-1!==m.chartstyle.indexOf("bar")){for(p=g?g:.8,f.push(1-p/2+(l+.5)*p/E),d=1;b[l].length>d;d++)f.push(f[d-1]+1);m.width=p/E}v&&v.length===E?m.name=v[l]:m.withheaders&&(m.name=u[l]),m.strokecolor=C&&C.length===E?C[l]:a.hsv2rgb(360*((l+1)/E),.9,.6),m.fillcolor=y&&y.length===E?y[l]:a.hsv2rgb(360*((l+1)/E),.9,1),m.highlightstrokecolor=P&&P.length===E?P[l]:a.hsv2rgb(360*((l+1)/E),.9,1),m.highlightfillcolor=_&&_.length===E?_[l]:a.hsv2rgb(360*((l+1)/E),.9,.6),m.chartstyle&&-1!==m.chartstyle.indexOf("bar")?S.push(new t.Chart(e,[f,b[l]],m)):S.push(new t.Chart(e,[b[l]],m))}e.unsuspendUpdate()}return S}return m=h.copyAttributes(i,e.options,"chart"),new t.Chart(e,r,m)},t.registerElement("chart",t.createChart),t.Legend=function(t,e,r){var o;if(this.constructor(),o=h.copyAttributes(r,t.options,"legend"),this.board=t,this.coords=new s(i.COORDS_BY_USER,e,this.board),this.myAtts={},this.label_array=o.labelarray||o.labels,this.color_array=o.colorarray||o.colors,this.lines=[],this.myAtts.strokewidth=o.strokewidth||5,this.myAtts.straightfirst=!1,this.myAtts.straightlast=!1,this.myAtts.withlabel=!0,this.myAtts.fixed=!0,this.style=o.legendstyle||o.style,"vertical"!==this.style)throw Error("JSXGraph: Unknown legend style: "+this.style);this.drawVerticalLegend(t,o)},t.Legend.prototype=new o,t.Legend.prototype.drawVerticalLegend=function(t,e){var r,o=e.linelength||1,n=(e.rowheight||20)/this.board.unitY,a=function(){return this.setLabelRelativeCoords(this.visProp.label.offset),new s(i.COORDS_BY_USER,[this.point2.X(),this.point2.Y()],this.board)};for(r=0;this.label_array.length>r;r++)this.myAtts.strokecolor=this.color_array[r],this.myAtts.highlightstrokecolor=this.color_array[r],this.myAtts.name=this.label_array[r],this.myAtts.label={offset:[10,0],strokeColor:this.color_array[r],strokeWidth:this.myAtts.strokewidth},this.lines[r]=t.create("line",[[this.coords.usrCoords[1],this.coords.usrCoords[2]-r*n],[this.coords.usrCoords[1]+o,this.coords.usrCoords[2]-r*n]],this.myAtts),this.lines[r].getLabelAnchor=a},t.createLegend=function(e,r,i){var s=[0,0];return h.exists(r)&&2===r.length&&(s=r),new t.Legend(e,s,i)},t.registerElement("legend",t.createLegend),{Chart:t.Chart,Legend:t.Legend,createChart:t.createChart,createLegend:t.createLegend}}),define("base/turtle",["jxg","base/constants","base/element","utils/type","base/curve","base/point","base/line","base/transformation"],function(t,e,r,i){return t.Turtle=function(t,r,s){var o,n,a;return this.constructor(t,s,e.OBJECT_TYPE_TURTLE,e.OBJECT_CLASS_OTHER),this.turtleIsHidden=!1,this.board=t,this.visProp.curveType="plot",this._attributes=i.copyAttributes(this.visProp,t.options,"turtle"),delete this._attributes.id,o=0,n=0,a=90,0!==r.length&&(3===r.length?(o=r[0],n=r[1],a=r[2]):2===r.length?i.isArray(r[0])?(o=r[0][0],n=r[0][1],a=r[1]):(o=r[0],n=r[1]):(o=r[0][0],n=r[0][1])),this.init(o,n,a),this.methodMap=i.deepCopy(this.methodMap,{forward:"forward",fd:"forward",back:"back",bk:"back",right:"right",rt:"right",left:"left",lt:"left",penUp:"penUp",pu:"penUp",penDown:"penDown",pd:"pwnDown",clearScreen:"clearScreen",cs:"clearScreen",clean:"clean",setPos:"setPos",home:"home",hideTurtle:"hideTurtle",ht:"hideTurtle",showTurtle:"showTurtle",st:"showTurtle",penSize:"penSize",penColor:"penColor",pushTurtle:"pushTurtle",push:"pushTurtle",popTurtle:"popTurtle",pop:"popTurtle",lookTo:"lookTo",pos:"pos",moveTo:"moveTo",X:"X",Y:"Y"}),this},t.Turtle.prototype=new r,t.extend(t.Turtle.prototype,{init:function(t,e,r){var i={fixed:!0,name:"",visible:!1,withLabel:!1};this.arrowLen=20/Math.sqrt(this.board.unitX*this.board.unitX+this.board.unitY*this.board.unitY),this.pos=[t,e],this.isPenDown=!0,this.dir=90,this.stack=[],this.objects=[],this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this.turtle=this.board.create("point",this.pos,i),this.objects.push(this.turtle),this.turtle2=this.board.create("point",[this.pos[0],this.pos[1]+this.arrowLen],i),this.objects.push(this.turtle2),this.visProp.arrow.lastArrow=!0,this.visProp.arrow.straightFirst=!1,this.visProp.arrow.straightLast=!1,this.arrow=this.board.create("line",[this.turtle,this.turtle2],this.visProp.arrow),this.objects.push(this.arrow),this.right(90-r),this.board.update()},forward:function(t){if(0===t)return this;var e,r=t*Math.cos(this.dir*Math.PI/180),i=t*Math.sin(this.dir*Math.PI/180);return this.turtleIsHidden||(e=this.board.create("transform",[r,i],{type:"translate"}),e.applyOnce(this.turtle),e.applyOnce(this.turtle2)),this.isPenDown&&this.curve.dataX.length>=8192&&(this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve)),this.pos[0]+=r,this.pos[1]+=i,this.isPenDown&&(this.curve.dataX.push(this.pos[0]),this.curve.dataY.push(this.pos[1])),this.board.update(),this},back:function(t){return this.forward(-t)},right:function(t){if(this.dir-=t,this.dir%=360,!this.turtleIsHidden){var e=this.board.create("transform",[-t*Math.PI/180,this.turtle],{type:"rotate"});e.applyOnce(this.turtle2)}return this.board.update(),this},left:function(t){return this.right(-t)},penUp:function(){return this.isPenDown=!1,this},penDown:function(){return this.isPenDown=!0,this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this
},clean:function(){var t,r;for(t=0;this.objects.length>t;t++)r=this.objects[t],r.type===e.OBJECT_TYPE_CURVE&&(this.board.removeObject(r),this.objects.splice(t,1));return this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this.board.update(),this},clearScreen:function(){var t,e,r=this.objects.length;for(t=0;r>t;t++)e=this.objects[t],this.board.removeObject(e);return this.init(0,0,90),this},setPos:function(t,r){var s;return this.pos=i.isArray(t)?t:[t,r],this.turtleIsHidden||(this.turtle.setPositionDirectly(e.COORDS_BY_USER,[t,r]),this.turtle2.setPositionDirectly(e.COORDS_BY_USER,[t,r+this.arrowLen]),s=this.board.create("transform",[-(this.dir-90)*Math.PI/180,this.turtle],{type:"rotate"}),s.applyOnce(this.turtle2)),this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this.board.update(),this},setPenSize:function(t){return this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this.copyAttr("strokeWidth",t)),this.objects.push(this.curve),this},setPenColor:function(t){return this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this.copyAttr("strokeColor",t)),this.objects.push(this.curve),this},setHighlightPenColor:function(t){return this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this.copyAttr("highlightStrokeColor",t)),this.objects.push(this.curve),this},setAttribute:function(t){var r,s,o,n=this.objects.length;for(r=0;n>r;r++)s=this.objects[r],s.type===e.OBJECT_TYPE_CURVE&&s.setAttribute(t);return o=this.visProp.id,this.visProp=i.deepCopy(this.curve.visProp),this.visProp.id=o,this._attributes=i.deepCopy(this.visProp),delete this._attributes.id,this},copyAttr:function(t,e){return this._attributes[t.toLowerCase()]=e,this._attributes},showTurtle:function(){return this.turtleIsHidden=!1,this.arrow.setAttribute({visible:!0}),this.visProp.arrow.visible=!1,this.setPos(this.pos[0],this.pos[1]),this.board.update(),this},hideTurtle:function(){return this.turtleIsHidden=!0,this.arrow.setAttribute({visible:!1}),this.visProp.arrow.visible=!1,this.board.update(),this},home:function(){return this.pos=[0,0],this.setPos(this.pos[0],this.pos[1]),this},pushTurtle:function(){return this.stack.push([this.pos[0],this.pos[1],this.dir]),this},popTurtle:function(){var t=this.stack.pop();return this.pos[0]=t[0],this.pos[1]=t[1],this.dir=t[2],this.setPos(this.pos[0],this.pos[1]),this},lookTo:function(t){var e,r,s,o,n;return i.isArray(t)?(e=this.pos[0],r=this.pos[1],s=t[0],o=t[1],n=Math.atan2(o-r,s-e),this.right(this.dir-180*n/Math.PI)):i.isNumber(t)&&this.right(this.dir-t),this},moveTo:function(t){var e,r,s;return i.isArray(t)&&(e=t[0]-this.pos[0],r=t[1]-this.pos[1],this.turtleIsHidden||(s=this.board.create("transform",[e,r],{type:"translate"}),s.applyOnce(this.turtle),s.applyOnce(this.turtle2)),this.isPenDown&&this.curve.dataX.length>=8192&&(this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve)),this.pos[0]=t[0],this.pos[1]=t[1],this.isPenDown&&(this.curve.dataX.push(this.pos[0]),this.curve.dataY.push(this.pos[1])),this.board.update()),this},fd:function(t){return this.forward(t)},bk:function(t){return this.back(t)},lt:function(t){return this.left(t)},rt:function(t){return this.right(t)},pu:function(){return this.penUp()},pd:function(){return this.penDown()},ht:function(){return this.hideTurtle()},st:function(){return this.showTurtle()},cs:function(){return this.clearScreen()},push:function(){return this.pushTurtle()},pop:function(){return this.popTurtle()},evalAt:function(t,r){var i,s,o,n,a=this.objects.length;for(i=0,s=0;a>i;i++)if(o=this.objects[i],o.elementClass===e.OBJECT_CLASS_CURVE){if(t>=s&&s+o.numberPoints>t)return n=t-s,o[r](n);s+=o.numberPoints}return this[r]()},X:function(t){return i.exists(t)?this.evalAt(t,"X"):this.pos[0]},Y:function(t){return i.exists(t)?this.evalAt(t,"Y"):this.pos[1]},Z:function(){return 1},minX:function(){return 0},maxX:function(){var t,r,i=this.objects.length,s=0;for(t=0;i>t;t++)r=this.objects[t],r.elementClass===e.OBJECT_CLASS_CURVE&&(s+=this.objects[t].numberPoints);return s},hasPoint:function(t,r){var i,s;for(i=0;this.objects.length>i;i++)if(s=this.objects[i],s.type===e.OBJECT_TYPE_CURVE&&s.hasPoint(t,r))return!0;return!1}}),t.createTurtle=function(e,r,s){var o;return r=r||[],o=i.copyAttributes(s,e.options,"turtle"),new t.Turtle(e,r,o)},t.registerElement("turtle",t.createTurtle),{Turtle:t.Turtle,createTurtle:t.createTurtle}}),define("utils/dump",["jxg","utils/type"],function(t,e){return t.Dump={addMarkers:function(t,r,i){var s,o,n;e.isArray(r)||(r=[r]),e.isArray(i)||(i=[i]),o=Math.min(r.length,i.length),r.length=o,i.length=o;for(s in t.objects)if(t.objects.hasOwnProperty(s))for(n=0;o>n;n++)t.objects[s][r[n]]=i[n]},deleteMarkers:function(t,r){var i,s,o;e.isArray(r)||(r=[r]),s=r.length,r.length=s;for(i in t.objects)if(t.objects.hasOwnProperty(i))for(o=0;s>o;o++)delete t.objects[i][r[o]]},str:function(t){return"string"==typeof t&&"function"!==t.substr(0,7)&&(t="'"+t+"'"),t},minimizeObject:function(t){var r,i,s,o={},n=e.deepCopy(t),a=[];for(s=1;arguments.length>s;s++)a.push(arguments[s]);for(s=a.length;s>0;s--)o=e.deepCopy(o,a[s-1],!0);for(r in o)o.hasOwnProperty(r)&&(i=r.toLowerCase(),"object"!=typeof o[r]&&o[r]===n[i]&&delete n[i]);return n},prepareAttributes:function(e,r){var i,s;i=this.minimizeObject(r.getAttributes(),t.Options[r.elType]);for(s in r.subs)r.subs.hasOwnProperty(s)&&(i[s]=this.minimizeObject(r.subs[s].getAttributes(),t.Options[r.elType][s],t.Options[r.subs[s].elType]),i[s].id=r.subs[s].id,i[s].name=r.subs[s].name);return i.id=r.id,i.name=r.name,i},dump:function(t){var e,r,i,s,o=[],n=[],a=[],h=t.objectsList.length;for(this.addMarkers(t,"dumped",!1),n.push({obj:"$board",method:"setBoundingBox",params:[t.getBoundingBox(),!0]}),e=0;h>e;e++)if(r=t.objectsList[e],i={},!r.dumped&&r.dump){for(i.type=r.getType(),i.parents=r.getParents(),"point"===i.type&&1===i.parents[0]&&(i.parents=i.parents.slice(1)),s=0;i.parents.length>s;s++)"string"==typeof i.parents[s]&&(i.parents[s]="'"+i.parents[s]+"'");i.attributes=this.prepareAttributes(t,r),"glider"===i.type&&r.onPolygon&&o.push({obj:r.id,prop:"onPolygon",val:!0}),a.push(i)}return this.deleteMarkers(t,"dumped"),{elements:a,props:o,methods:n}},arrayToParamStr:function(t,e){var r,i=[];for(r=0;t.length>r;r++)i.push(e.call(this,t[r]));return i.join(", ")},toJSAN:function(t){var r,i,s;switch(typeof t){case"object":if(t){if(i=[],e.isArray(t)){for(r=0;t.length>r;r++)i.push(this.toJSAN(t[r]));return"["+i.join(",")+"]"}for(s in t)t.hasOwnProperty(s)&&i.push(s+": "+this.toJSAN(t[s]));return"<<"+i.join(", ")+">> "}return"null";case"string":return"'"+t.replace(/(["'])/g,"\\$1")+"'";case"number":case"boolean":return""+t;case"null":return"null"}},toJessie:function(t){var e,r,i=this.dump(t),s=[];for(r=i.elements,e=0;r.length>e;e++)r[e].attributes.name.length>0&&s.push("// "+r[e].attributes.name),s.push("s"+e+" = "+r[e].type+"("+r[e].parents.join(", ")+") "+this.toJSAN(r[e].attributes).replace(/\n/,"\\n")+";"),s.push("");for(e=0;i.methods.length>e;e++)s.push(i.methods[e].obj+"."+i.methods[e].method+"("+this.arrayToParamStr(i.methods[e].params,this.toJSAN)+");"),s.push("");for(e=0;i.props.length>e;e++)s.push(i.props[e].obj+"."+i.props[e].prop+" = "+this.toJSAN(i.props[e].val)+";"),s.push("");return s.join("\n")},toJavaScript:function(t){var r,i,s=this.dump(t),o=[];for(i=s.elements,r=0;i.length>r;r++)o.push('board.create("'+i[r].type+'", ['+i[r].parents.join(", ")+"], "+e.toJSON(i[r].attributes)+");");for(r=0;s.methods.length>r;r++)o.push(s.methods[r].obj+"."+s.methods[r].method+"("+this.arrayToParamStr(s.methods[r].params,e.toJSON)+");"),o.push("");for(r=0;s.props.length>r;r++)o.push(s.props[r].obj+"."+s.props[r].prop+" = "+e.toJSON(s.props[r].val)+";"),o.push("");return o.join("\n")}},t.Dump}),define("../build/core.deps.js",["jxg","utils/env","base/constants","utils/type","utils/xml","utils/event","utils/expect","math/math","math/numerics","math/statistics","math/symbolic","math/geometry","math/poly","math/complex","renderer/abstract","renderer/no","reader/file","parser/geonext","base/board","options","jsxgraph","base/element","base/coords","base/point","base/line","base/group","base/circle","element/conic","base/polygon","base/curve","element/arc","element/sector","base/composition","element/composition","element/locus","base/text","base/image","element/slider","element/measure","base/chart","base/transformation","base/turtle","utils/color","base/ticks","utils/zip","utils/base64","utils/uuid","utils/encoding","server/server","parser/datasource","parser/jessiecode","utils/dump","renderer/svg","renderer/vml","renderer/canvas","renderer/no"],function(t,e){return e.isBrowser?window.JXG=t:e.isNode()&&"object"==typeof module?module.exports=t:e.isWebWorker()&&(self.JXG=t),t}),require("../build/core.deps.js")})();