From b0f98a43381486995b99ed79e0eabb3af149dbf3 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 9 Mar 2021 01:23:23 +0100 Subject: Add simple support for cindyjs Notably, the error output (in case of compiler errors) is generated by overwriting the builtin console.error-function, which is a horrible idea for many reasons, but there isn't really any other way right now. --- .gitignore | 2 +- public/build/Cindy.js | 1027 ++++++++++++++++++++++++++++++++++++++ public/build/CindyGL.js | 140 ++++++ public/build/LICENSE_cindyjs | 201 ++++++++ public/js/extra.js | 43 ++ public/views/hedgedoc/footer.ejs | 3 + 6 files changed, 1415 insertions(+), 1 deletion(-) create mode 100644 public/build/Cindy.js create mode 100644 public/build/CindyGL.js create mode 100644 public/build/LICENSE_cindyjs diff --git a/.gitignore b/.gitignore index 9528746e..4fae05f9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ config.json .sequelizerc # ignore webpack build -public/build +#public/build public/views/build public/uploads/* diff --git a/public/build/Cindy.js b/public/build/Cindy.js new file mode 100644 index 00000000..872914b2 --- /dev/null +++ b/public/build/Cindy.js @@ -0,0 +1,1027 @@ +/* CindyJS - (C) 2014-2016 The CindyJS Project + * Mostly licensed under the Apache License 2.0, but subprojects may use different licensing. + * See https://github.com/CindyJS/CindyJS/tree/131b593c48ec6a2c773b580bea773a6298f7e901 + * for corresponding sources and their respective licensing conditions. + */ +/* + npm.im/iphone-inline-video 2.0.2 npm.im/intervalometer https://github.com/paulmillr/es6-shim + @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com) + and contributors, MIT License + es6-shim: v0.35.4 + see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE + Details and documentation: + https://github.com/paulmillr/es6-shim/ +*/ +'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,n,t){d!=Array.prototype&&d!=Object.prototype&&(d[n]=t.value)};$jscomp.getGlobal=function(d){return"undefined"!=typeof window&&window===d?d:"undefined"!=typeof global&&null!=global?global:d};$jscomp.global=$jscomp.getGlobal(this); +$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var d=0;return function(n){return $jscomp.SYMBOL_PREFIX+(n||"")+d++}}(); +$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var d=$jscomp.global.Symbol.iterator;d||(d=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[d]&&$jscomp.defineProperty(Array.prototype,d,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(d){var n=0;return $jscomp.iteratorPrototype(function(){return n=I}},"es6","es3"); +$jscomp.polyfill("String.prototype.endsWith",function(d){return d?d:function(d,t){var n=$jscomp.checkStringArgs(this,d,"endsWith");d+="";void 0===t&&(t=n.length);t=Math.max(0,Math.min(t|0,n.length));for(var B=d.length;0=B}},"es6","es3");$jscomp.polyfill("Object.is",function(d){return d?d:function(d,t){return d===t?0!==d||1/d===1/t:d!==d&&t!==t}},"es6","es3"); +$jscomp.polyfill("Array.prototype.includes",function(d){return d?d:function(d,t){var n=this;n instanceof String&&(n=String(n));var B=n.length;t=t||0;for(0>t&&(t=Math.max(t+B,0));td&&-.25d&&-.25d?-n:n}},"es6","es3"); +$jscomp.polyfill("Math.atanh",function(d){if(d)return d;var n=Math.log1p;return function(d){d=Number(d);return(n(d)-n(-d))/2}},"es6","es3");$jscomp.polyfill("Math.tanh",function(d){return d?d:function(d){d=Number(d);if(0===d)return d;var n=Math.exp(-2*Math.abs(d));n=(1-n)/(1+n);return 0>d?-n:n}},"es6","es3");$jscomp.polyfill("Math.acosh",function(d){return d?d:function(d){d=Number(d);return Math.log(d+Math.sqrt(d*d-1))}},"es6","es3"); +$jscomp.polyfill("Math.cbrt",function(d){return d?d:function(d){if(0===d)return d;d=Number(d);var n=Math.pow(Math.abs(d),1/3);return 0>d?-n:n}},"es6","es3");$jscomp.polyfill("Math.imul",function(d){return d?d:function(d,t){d=Number(d);t=Number(t);var n=d&65535,B=t&65535;return n*B+((d>>>16&65535)*B+n*(t>>>16&65535)<<16>>>0)|0}},"es6","es3"); +$jscomp.checkEs6ConformanceViaProxy=function(){try{var d={},n=Object.create(new $jscomp.global.Proxy(d,{get:function(t,G,B){return t==d&&"q"==G&&B==n}}));return!0===n.q}catch(t){return!1}};$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1;$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy();$jscomp.owns=function(d,n){return Object.prototype.hasOwnProperty.call(d,n)}; +$jscomp.polyfill("WeakMap",function(d){function n(){if(!d||!Object.seal)return!1;try{var h=Object.seal({}),n=Object.seal({}),p=new d([[h,2],[n,3]]);if(2!=p.get(h)||3!=p.get(n))return!1;p.delete(h);p.set(n,4);return!p.has(h)&&4==p.get(n)}catch(ia){return!1}}function t(d){$jscomp.owns(d,B)||$jscomp.defineProperty(d,B,{value:{}})}function G(d){var h=Object[d];h&&(Object[d]=function(d){t(d);return h(d)})}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(d&&$jscomp.ES6_CONFORMANCE)return d}else if(n())return d; +var B="$jscomp_hidden_"+Math.random();G("freeze");G("preventExtensions");G("seal");var I=0,O=function(d){this.id_=(I+=Math.random()+1).toString();if(d){$jscomp.initSymbol();$jscomp.initSymbolIterator();d=$jscomp.makeIterator(d);for(var h;!(h=d.next()).done;)h=h.value,this.set(h[0],h[1])}};O.prototype.set=function(d,n){t(d);if(!$jscomp.owns(d,B))throw Error("WeakMap key fail: "+d);d[B][this.id_]=n;return this};O.prototype.get=function(d){return $jscomp.owns(d,B)?d[B][this.id_]:void 0};O.prototype.has= +function(d){return $jscomp.owns(d,B)&&$jscomp.owns(d[B],this.id_)};O.prototype.delete=function(d){return $jscomp.owns(d,B)&&$jscomp.owns(d[B],this.id_)?delete d[B][this.id_]:!1};return O},"es6","es3");$jscomp.MapEntry=function(){}; +$jscomp.polyfill("Map",function(d){function n(){if($jscomp.ASSUME_NO_NATIVE_MAP||!d||"function"!=typeof d||!d.prototype.entries||"function"!=typeof Object.seal)return!1;try{var h=Object.seal({x:4}),n=new d($jscomp.makeIterator([[h,"s"]]));if("s"!=n.get(h)||1!=n.size||n.get({x:4})||n.set({x:4},"t")!=n||2!=n.size)return!1;var B=n.entries(),t=B.next();if(t.done||t.value[0]!=h||"s"!=t.value[1])return!1;t=B.next();return t.done||4!=t.value[0].x||"t"!=t.value[1]||!B.next().done?!1:!0}catch(nc){return!1}} +if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(d&&$jscomp.ES6_CONFORMANCE)return d}else if(n())return d;$jscomp.initSymbol();$jscomp.initSymbolIterator();var t=new WeakMap,G=function(d){this.data_={};this.head_=O();this.size=0;if(d){d=$jscomp.makeIterator(d);for(var h;!(h=d.next()).done;)h=h.value,this.set(h[0],h[1])}};G.prototype.set=function(d,h){d=0===d?0:d;var n=B(this,d);n.list||(n.list=this.data_[n.id]=[]);n.entry?n.entry.value=h:(n.entry={next:this.head_,previous:this.head_.previous,head:this.head_, +key:d,value:h},n.list.push(n.entry),this.head_.previous.next=n.entry,this.head_.previous=n.entry,this.size++);return this};G.prototype.delete=function(d){d=B(this,d);return d.entry&&d.list?(d.list.splice(d.index,1),d.list.length||delete this.data_[d.id],d.entry.previous.next=d.entry.next,d.entry.next.previous=d.entry.previous,d.entry.head=null,this.size--,!0):!1};G.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=O();this.size=0};G.prototype.has=function(d){return!!B(this,d).entry}; +G.prototype.get=function(d){return(d=B(this,d).entry)&&d.value};G.prototype.entries=function(){return I(this,function(d){return[d.key,d.value]})};G.prototype.keys=function(){return I(this,function(d){return d.key})};G.prototype.values=function(){return I(this,function(d){return d.value})};G.prototype.forEach=function(d,h){for(var n=this.entries(),p;!(p=n.next()).done;)p=p.value,d.call(h,p[1],p[0],this)};G.prototype[Symbol.iterator]=G.prototype.entries;var B=function(d,n){var p=n&&typeof n;"object"== +p||"function"==p?t.has(n)?p=t.get(n):(p=""+ ++h,t.set(n,p)):p="p_"+n;var B=d.data_[p];if(B&&$jscomp.owns(d.data_,p))for(d=0;dt&&(t=Math.max(0,n+t));if(null==G||G>n)G=n;G=Number(G);0>G&&(G=Math.max(0,n+G));for(t=Number(t||0);t=this.video.HAVE_FUTURE_DATA?(this.hasAudio||(this.driver.currentTime=this.video.currentTime+f*this.video.playbackRate/1E3,this.video.loop&&this.driver.currentTime>= +this.video.duration&&(this.driver.currentTime=0)),O(this.video,this.driver.currentTime)):this.video.networkState===this.video.NETWORK_IDLE&&0===this.video.buffered.length&&this.video.load();this.video.ended&&(delete this.video[K],this.video.pause(!0))}function X(){var f=this[db];return this.webkitDisplayingFullscreen?void this[ta]():("data:"!==f.driver.src&&f.driver.src!==this.src&&(O(this,0,!0),f.driver.src=this.src),void(this.paused&&(f.paused=!1,0===this.buffered.length&&this.load(),f.driver.play(), +f.updater.start(),f.hasAudio||(B(this,"play"),f.video.readyState>=f.video.HAVE_ENOUGH_DATA&&B(this,"playing")))))}function p(f){var d=this[db];d.driver.pause();d.updater.stop();this.webkitDisplayingFullscreen&&this[Na]();d.paused&&!f||(d.paused=!0,d.hasAudio||B(this,"pause"),this.ended&&(this[K]=!0,B(this,"ended")))}function ia(n,p){var t=n[db]={};t.paused=!0;t.hasAudio=p;t.video=n;t.updater=d(h.bind(t),requestAnimationFrame,cancelAnimationFrame);p?t.driver=I(n):(n.addEventListener("canplay",function(){n.paused|| +B(n,"playing")}),t.driver={src:n.src||n.currentSrc||"data:",muted:!0,paused:!0,pause:function(){t.driver.paused=!0},play:function(){t.driver.paused=!1;t.driver.currentTime>=t.video.duration&&O(n,0)},get ended(){return t.driver.currentTime>=t.video.duration}});n.addEventListener("emptied",function(){var f=!t.driver.src||"data:"===t.driver.src;t.driver.src&&t.driver.src!==n.src&&(O(n,0,!0),t.driver.src=n.src,f?t.driver.play():t.updater.stop())},!1);n.addEventListener("webkitbeginfullscreen",function(){n.paused? +p&&0===t.driver.buffered.length&&t.driver.load():(n.pause(),n[ta]())});p&&(n.addEventListener("webkitendfullscreen",function(){t.driver.currentTime=n.currentTime}),n.addEventListener("seeking",function(){0>f.indexOf(100*n.currentTime|0)&&(t.driver.currentTime=n.currentTime)}))}var Wa,nc="object"==typeof document&&"object-fit"in document.head.style&&!matchMedia("(-webkit-video-playable-inline)").matches,db="bfred-it:iphone-inline-video",K="bfred-it:iphone-inline-video:event",ta="bfred-it:iphone-inline-video:nativeplay", +Na="bfred-it:iphone-inline-video:nativepause",f=[],ba=0;return function(f,d){if(void 0===d&&(d={}),!f[db])if(d.everywhere||nc&&(d.iPad||d.ipad?/iPhone|iPod|iPad/:/iPhone|iPod/).test(navigator.userAgent))!f.paused&&f.webkitDisplayingFullscreen&&f.pause(),ia(f,!f.muted),d=f[db],f[ta]=f.play,f[Na]=f.pause,f.play=X,f.pause=p,t(f,"paused",d.driver),t(f,"muted",d.driver,!0),t(f,"playbackRate",d.driver,!0),t(f,"ended",d.driver),t(f,"loop",d.driver,!0),n(f,"seeking"),n(f,"seeked"),n(f,"timeupdate",K,!1), +n(f,"ended",K,!1),f.classList.add("IIV"),f.muted&&f.autoplay&&f.play(),/iPhone|iPod|iPad/.test(navigator.platform)||console.warn("iphone-inline-video is not guaranteed to work in emulated environments")}}(); +(function(){function d(b,c,k){f.biginteger_used=1;null!=b&&("number"==typeof b&&"undefined"==typeof c?this.fromInt(b):"number"==typeof b?this.fromNumber(b,c,k):null==c&&"string"!=typeof b?this.fromString(b,256):this.fromString(b,c))}function n(){return new d(null,void 0,void 0)}function t(b,c,k,U,f,d){for(;0<=--d;){var ca=c*this[b++]+k[U]+f;f=Math.floor(ca/67108864);k[U++]=ca&67108863}return f}function G(b,c,k,U,f,d){var ca=c&32767;for(c>>=15;0<=--d;){var h=this[b]&32767,Z=this[b++]>>15,n=c*h+Z*ca; +h=ca*h+((n&32767)<<15)+k[U]+(f&1073741823);f=(h>>>30)+(n>>>15)+c*Z+(f>>>30);k[U++]=h&1073741823}return f}function B(b,c,k,U,f,d){var ca=c&16383;for(c>>=14;0<=--d;){var h=this[b]&16383,Z=this[b++]>>14,n=c*h+Z*ca;h=ca*h+((n&16383)<<14)+k[U]+f;f=(h>>28)+(n>>14)+c*Z;k[U++]=h&268435455}return f}function I(b,c){b=Xa[b.charCodeAt(c)];return null==b?-1:b}function O(b){var c=n();c.fromInt(b);return c}function h(b){var c=1,k;0!=(k=b>>>16)&&(b=k,c+=16);0!=(k=b>>8)&&(b=k,c+=8);0!=(k=b>>4)&&(b=k,c+=4);0!=(k=b>> +2)&&(b=k,c+=2);0!=b>>1&&(c+=1);return c}function X(b){this.m=b}function p(b){this.m=b;this.mp=b.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<=Oa;++Oa)Xa[ua++]= +Oa;ua=97;for(Oa=10;36>Oa;++Oa)Xa[ua++]=Oa;ua=65;for(Oa=10;36>Oa;++Oa)Xa[ua++]=Oa;X.prototype.convert=function(b){return 0>b.s||0<=b.compareTo(this.m)?b.mod(this.m):b};X.prototype.revert=function(b){return b};X.prototype.reduce=function(b){b.divRemTo(this.m,null,b)};X.prototype.mulTo=function(b,c,k){b.multiplyTo(c,k);this.reduce(k)};X.prototype.sqrTo=function(b,c){b.squareTo(c);this.reduce(c)};p.prototype.convert=function(b){var c=n();b.abs().dlShiftTo(this.m.t,c);c.divRemTo(this.m,null,c);0>b.s&& +0>15)*this.mpl&this.um)<<15)&b.DM;k=c+this.m.t;for(b[k]+=this.m.am(0,U,b,c,0,this.m.t);b[k]>=b.DV;)b[k]-=b.DV,b[++k]++}b.clamp();b.drShiftTo(this.m.t,b);0<=b.compareTo(this.m)&&b.subTo(this.m,b)};p.prototype.mulTo=function(b,c,k){b.multiplyTo(c, +k);this.reduce(k)};p.prototype.sqrTo=function(b,c){b.squareTo(c);this.reduce(c)};d.prototype.copyTo=function(b){for(var c=this.t-1;0<=c;--c)b[c]=this[c];b.t=this.t;b.s=this.s};d.prototype.fromInt=function(b){this.t=1;this.s=0>b?-1:0;0b?this[0]=b+this.DV:this.t=0};d.prototype.fromString=function(b,c){if(16==c)c=4;else if(8==c)c=3;else if(256==c)c=8;else if(2==c)c=1;else if(32==c)c=5;else if(4==c)c=2;else{this.fromRadix(b,c);return}this.s=this.t=0;for(var k=b.length,U=!1,f=0;0<=--k;){var h= +8==c?b[k]&255:I(b,k);0>h?"-"==b.charAt(k)&&(U=!0):(U=!1,0==f?this[this.t++]=h:f+c>this.DB?(this[this.t-1]|=(h&(1<>this.DB-f):this[this.t-1]|=h<=this.DB&&(f-=this.DB))}8==c&&0!=(b[0]&128)&&(this.s=-1,0>f|h,h=(this[n]&d)<= +this.t)c.t=0;else{b%=this.DB;var f=this.DB-b,d=(1<>b;for(var h=k+1;h>b;0>=this.DB;if(b.t>=this.DB;f+=this.s}else{for(f+=this.s;k>=this.DB;f-=b.s}c.s=0>f?-1:0;-1>f?c[k++]= +this.DV+f:0=c.DV&&(b[k+c.t]-=c.DV,b[k+c.t+1]=1)}0=f.t)){var ca=this.abs();if(ca.t>this.F2:0),B=this.FV/t;t=(1<J&&d.ZERO.subTo(k,k)}}}};d.prototype.invDigit=function(){if(1>this.t)return 0;var b=this[0];if(0==(b&1))return 0;var c=b&3;c=c*(2-(b&15)*c)&15;c=c*(2-(b&255)*c)&255;c=c*(2-((b&65535)*c&65535))& +65535;c=c*(2-b*c%this.DV)%this.DV;return 0b)return d.ONE;var k=n(),f=n(),ca=c.convert(this),Z=h(b)-1;for(ca.copyTo(k);0<=--Z;)if(c.sqrTo(k,f),0<(b&1<this.s)return"-"+this.negate().toString(b);if(16==b)b=4;else if(8==b)b=3;else if(2==b)b=1;else if(32==b)b=5;else if(4== +b)b=2;else return this.toRadix(b);var c=(1<>n)&&(f=!0,d="0123456789abcdefghijklmnopqrstuvwxyz".charAt(k));0<=h;)n>(n+=this.DB-b)):(k=this[h]>>(n-=b)&c,0>=n&&(n+=this.DB,--h)),0this.s? +this.negate():this};d.prototype.compareTo=function(b){var c=this.s-b.s;if(0!=c)return c;var k=this.t;c=k-b.t;if(0!=c)return 0>this.s?-c:c;for(;0<=--k;)if(0!=(c=this[k]-b[k]))return c;return 0};d.prototype.bitLength=function(){return 0>=this.t?0:this.DB*(this.t-1)+h(this[this.t-1]^this.s&this.DM)};d.prototype.mod=function(b){var c=n();this.abs().divRemTo(b,null,c);0>this.s&&0b||c.isEven()?new X(c):new p(c);return this.exp(b, +c)};d.ZERO=O(0);d.ONE=O(1);K.prototype.convert=ta;K.prototype.revert=ta;K.prototype.mulTo=function(b,c,k){b.multiplyTo(c,k)};K.prototype.sqrTo=function(b,c){b.squareTo(c)};Na.prototype.convert=function(b){if(0>b.s||b.t>2*this.m.t)return b.mod(this.m);if(0>b.compareTo(this.m))return b;var c=n();b.copyTo(c);this.reduce(c);return c};Na.prototype.revert=function(b){return b};Na.prototype.reduce=function(b){b.drShiftTo(this.m.t-1,this.r2);b.t>this.m.t+1&&(b.t=this.m.t+1,b.clamp());this.mu.multiplyUpperTo(this.r2, +this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>b.compareTo(this.r2);)b.dAddOffset(1,this.m.t+1);for(b.subTo(this.r2,b);0<=b.compareTo(this.m);)b.subTo(this.m,b)};Na.prototype.mulTo=function(b,c,k){b.multiplyTo(c,k);this.reduce(k)};Na.prototype.sqrTo=function(b,c){b.squareTo(c);this.reduce(c)};var T=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229, +233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Gb=67108864/T[T.length-1];d.prototype.chunkSize= +function(b){return Math.floor(Math.LN2*this.DB/Math.log(b))};d.prototype.toRadix=function(b){null==b&&(b=10);if(0==this.signum()||2>b||36t?"-"==b.charAt(p)&&0==this.signum()&&(ca=!0):(n=c*n+t,++h>=k&&(this.dMultiply(f),this.dAddOffset(n,0),n=h=0))}0b)this.fromInt(1);else for(this.fromNumber(b,k),this.testBit(b-1)||this.bitwiseTo(d.ONE.shiftLeft(b-1),Wa,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>b&&this.subTo(d.ONE.shiftLeft(b- +1),this);else{k=[];var f=b&7;k.length=(b>>3)+1;c.nextBytes(k);k[0]=0>=this.DB;if(b.t>=this.DB;f+=this.s}else{for(f+=this.s;k>=this.DB;f+=b.s}c.s=0>f?-1:0;0f&&(c[k++]=this.DV+f);c.t=k;c.clamp()};d.prototype.dMultiply=function(b){this[this.t]=this.am(0,b-1,this,0,0,this.t);++this.t;this.clamp()};d.prototype.dAddOffset=function(b,c){if(0!=b){for(;this.t<=c;)this[this.t++]=0;for(this[c]+= +b;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}};d.prototype.multiplyLowerTo=function(b,c,k){var f=Math.min(this.t+b.t,c);k.s=0;for(k.t=f;0=b)return 0;var c=this.DV%b,k=0>this.s?b-1:0;if(0=k)return!1;var f=c.shiftRight(k);b=b+1>>1;b>T.length&&(b=T.length);for(var ca=n(),h=0;hthis.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24};d.prototype.shortValue=function(){return 0== +this.t?this.s:this[0]<<16>>16};d.prototype.signum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1};d.prototype.toByteArray=function(){var b=this.t,c=[];c[0]=this.s;var k=this.DB-b*this.DB%8,f,d=0;if(0>k)!=(this.s&this.DM)>>k&&(c[d++]=f|this.s<k?(f=(this[b]&(1<>(k+=this.DB-8)):(f=this[b]>>(k-=8)&255,0>=k&&(k+=this.DB,--b)),0!=(f&128)&&(f|=-256),0==d&&(this.s&128)!=(f&128)&&++d,0this.compareTo(b)?this:b};d.prototype.max=function(b){return 0b?this.rShiftTo(-b,c):this.lShiftTo(b,c);return c};d.prototype.shiftRight=function(b){var c=n();0>b?this.lShiftTo(-b,c):this.rShiftTo(b,c);return c};d.prototype.getLowestSetBit=function(){for(var b=0;b>=16,k+=16);0==(b&255)&&(b>>=8,k+=8);0==(b&15)&&(b>>=4,k+=4);0==(b&3)&&(b>>=2,k+=2); +0==(b&1)&&++k;b=k}return c+b}return 0>this.s?this.t*this.DB:-1};d.prototype.bitCount=function(){for(var b=0,c=this.s&this.DM,k=0;k=this.t?0!=this.s:0!=(this[c]&1<= +k)return f;var d=18>k?1:48>k?3:144>k?4:768>k?5:6;c=8>k?new X(c):c.isEven()?new Na(c):new p(c);var Z=[],J=3,t=d-1,B=(1<=t?G=b[F]>>k-t&B:(G=(b[F]&(1<>this.DB+k-t));for(J=d;0==(G&1);)G>>=1,--J;0>(k-=J)&&(k+=this.DB,--F);if(K)Z[G].copyTo(f),K=!1;else{for(;1--k&&(k=this.DB-1,--F)}return c.revert(f)};d.prototype.modInverse=function(b){var c=b.isEven();if(this.isEven()&&c||0==b.signum())return d.ZERO;for(var k=b.clone(),f=this.clone(),h=O(1),n=O(0),J=O(0),p=O(1);0!=k.signum();){for(;k.isEven();)k.rShiftTo(1,k),c?(h.isEven()&&n.isEven()||(h.addTo(this,h),n.subTo(b,n)),h.rShiftTo(1,h)):n.isEven()||n.subTo(b,n),n.rShiftTo(1,n);for(;f.isEven();)f.rShiftTo(1,f),c?(J.isEven()&&p.isEven()|| +(J.addTo(this,J),p.subTo(b,p)),J.rShiftTo(1,J)):p.isEven()||p.subTo(b,p),p.rShiftTo(1,p);0<=k.compareTo(f)?(k.subTo(f,k),c&&h.subTo(J,h),n.subTo(p,n)):(f.subTo(k,f),c&&J.subTo(h,J),p.subTo(n,p))}if(0!=f.compareTo(d.ONE))return d.ZERO;if(0<=p.compareTo(b))return p.subtract(b);if(0>p.signum())p.addTo(b,p);else return p;return 0>p.signum()?p.add(b):p};d.prototype.pow=function(b){return this.exp(b,new K)};d.prototype.gcd=function(b){var c=0>this.s?this.negate():this.clone();b=0>b.s?b.negate():b.clone(); +if(0>c.compareTo(b)){var k=c;c=b;b=k}k=c.getLowestSetBit();var f=b.getLowestSetBit();if(0>f)return c;kb.compareTo(c)?!0:!1};d.op_Addition=function(b,c){return(new d(b)).add(new d(c))};d.op_Subtraction=function(b,c){return(new d(b)).subtract(new d(c))};d.Int128Mul=function(b,c){return(new d(b)).multiply(new d(c))};d.op_Division=function(b,c){return b.divide(c)};d.prototype.ToDouble=function(){return parseFloat(this.toString())};ua=function(b,c){var k;if("undefined"==typeof Object.getOwnPropertyNames)for(k in c.prototype){if("undefined"==typeof b.prototype[k]||b.prototype[k]== +Object.prototype[k])b.prototype[k]=c.prototype[k]}else for(var f=Object.getOwnPropertyNames(c.prototype),d=0;db||2147483647b?Math.ceil(b):Math.floor(b):~~b}:Wb&&"function"==typeof Number.toInteger?function(b){return Number.toInteger(b)}:zb|| +Bb?function(b){return parseInt(b,10)}:va?function(b){return-2147483648>b||2147483647b?Math.ceil(b):Math.floor(b):b|0}:function(b){return 0>b?Math.ceil(b):Math.floor(b)};f.Clear=function(b){b.length=0};f.PI=3.141592653589793;f.PI2=6.283185307179586;f.IntPoint=function(){var b=arguments,c=b.length;this.Y=this.X=0;f.use_xyz?(this.Z=0,3==c?(this.X=b[0],this.Y=b[1],this.Z=b[2]):2==c?(this.X=b[0],this.Y=b[1],this.Z=0):1==c?b[0]instanceof f.DoublePoint?(b=b[0],this.X=f.Clipper.Round(b.X),this.Y=f.Clipper.Round(b.Y), +this.Z=0):(b=b[0],"undefined"==typeof b.Z&&(b.Z=0),this.X=b.X,this.Y=b.Y,this.Z=b.Z):this.Z=this.Y=this.X=0):2==c?(this.X=b[0],this.Y=b[1]):1==c?b[0]instanceof f.DoublePoint?(b=b[0],this.X=f.Clipper.Round(b.X),this.Y=f.Clipper.Round(b.Y)):(b=b[0],this.X=b.X,this.Y=b.Y):this.Y=this.X=0};f.IntPoint.op_Equality=function(b,c){return b.X==c.X&&b.Y==c.Y};f.IntPoint.op_Inequality=function(b,c){return b.X!=c.X||b.Y!=c.Y};f.use_xyz?(f.IntPoint0=function(){this.Z=this.Y=this.X=0},f.IntPoint1=function(b){this.X= +b.X;this.Y=b.Y;this.Z=b.Z},f.IntPoint1dp=function(b){this.X=f.Clipper.Round(b.X);this.Y=f.Clipper.Round(b.Y);this.Z=0},f.IntPoint2=function(b,c){this.X=b;this.Y=c;this.Z=0},f.IntPoint3=function(b,c,k){this.X=b;this.Y=c;this.Z=k}):(f.IntPoint0=function(){this.Y=this.X=0},f.IntPoint1=function(b){this.X=b.X;this.Y=b.Y},f.IntPoint1dp=function(b){this.X=f.Clipper.Round(b.X);this.Y=f.Clipper.Round(b.Y)},f.IntPoint2=function(b,c){this.X=b;this.Y=c});f.IntRect=function(){var b=arguments,c=b.length;4==c?(this.left= +b[0],this.top=b[1],this.right=b[2],this.bottom=b[3]):1==c?(this.left=b[0].left,this.top=b[0].top,this.right=b[0].right,this.bottom=b[0].bottom):this.bottom=this.right=this.top=this.left=0};f.IntRect0=function(){this.bottom=this.right=this.top=this.left=0};f.IntRect1=function(b){this.left=b.left;this.top=b.top;this.right=b.right;this.bottom=b.bottom};f.IntRect4=function(b,c,k,f){this.left=b;this.top=c;this.right=k;this.bottom=f};f.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3};f.PolyType= +{ptSubject:0,ptClip:1};f.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3};f.JoinType={jtSquare:0,jtRound:1,jtMiter:2};f.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4};f.EdgeSide={esLeft:0,esRight:1};f.Direction={dRightToLeft:0,dLeftToRight:1};f.TEdge=function(){this.Bot=new f.IntPoint;this.Curr=new f.IntPoint;this.Top=new f.IntPoint;this.Delta=new f.IntPoint;this.Dx=0;this.PolyTyp=f.PolyType.ptSubject;this.Side=f.EdgeSide.esLeft;this.OutIdx= +this.WindCnt2=this.WindCnt=this.WindDelta=0;this.PrevInSEL=this.NextInSEL=this.PrevInAEL=this.NextInAEL=this.NextInLML=this.Prev=this.Next=null};f.IntersectNode=function(){this.Edge2=this.Edge1=null;this.Pt=new f.IntPoint};f.MyIntersectNodeSort=function(){};f.MyIntersectNodeSort.Compare=function(b,c){b=c.Pt.Y-b.Pt.Y;return 0b?-1:0};f.LocalMinima=function(){this.Y=0;this.Next=this.RightBound=this.LeftBound=null};f.Scanbeam=function(){this.Y=0;this.Next=null};f.OutRec=function(){this.Idx=0;this.IsOpen= +this.IsHole=!1;this.PolyNode=this.BottomPt=this.Pts=this.FirstLeft=null};f.OutPt=function(){this.Idx=0;this.Pt=new f.IntPoint;this.Prev=this.Next=null};f.Join=function(){this.OutPt2=this.OutPt1=null;this.OffPt=new f.IntPoint};f.ClipperBase=function(){this.m_CurrentLM=this.m_MinimaList=null;this.m_edges=[];this.PreserveCollinear=this.m_HasOpenPaths=this.m_UseFullRange=!1;this.m_CurrentLM=this.m_MinimaList=null;this.m_HasOpenPaths=this.m_UseFullRange=!1};f.ClipperBase.horizontal=-9007199254740992;f.ClipperBase.Skip= +-2;f.ClipperBase.Unassigned=-1;f.ClipperBase.tolerance=1E-20;f.ClipperBase.loRange=47453132;f.ClipperBase.hiRange=0xfffffffffffff;f.ClipperBase.near_zero=function(b){return b>-f.ClipperBase.tolerance&&bc.X==b.Xc.Y==b.Yc.X==b.Xc.Y==b.Yf.ClipperBase.hiRange||b.Y>f.ClipperBase.hiRange||-b.X>f.ClipperBase.hiRange||-b.Y>f.ClipperBase.hiRange)&&f.Error("Coordinate outside allowed range in RangeTest().");else if(b.X>f.ClipperBase.loRange||b.Y>f.ClipperBase.loRange||-b.X>f.ClipperBase.loRange||-b.Y>f.ClipperBase.loRange)c.Value=!0,this.RangeTest(b,c)};f.ClipperBase.prototype.InitEdge= +function(b,c,k,d){b.Next=c;b.Prev=k;b.Curr.X=d.X;b.Curr.Y=d.Y;f.use_xyz&&(b.Curr.Z=d.Z);b.OutIdx=-1};f.ClipperBase.prototype.InitEdge2=function(b,c){b.Curr.Y>=b.Next.Curr.Y?(b.Bot.X=b.Curr.X,b.Bot.Y=b.Curr.Y,f.use_xyz&&(b.Bot.Z=b.Curr.Z),b.Top.X=b.Next.Curr.X,b.Top.Y=b.Next.Curr.Y,f.use_xyz&&(b.Top.Z=b.Next.Curr.Z)):(b.Top.X=b.Curr.X,b.Top.Y=b.Curr.Y,f.use_xyz&&(b.Top.Z=b.Curr.Z),b.Bot.X=b.Next.Curr.X,b.Bot.Y=b.Next.Curr.Y,f.use_xyz&&(b.Bot.Z=b.Next.Curr.Z));this.SetDx(b);b.PolyTyp=c};f.ClipperBase.prototype.FindNextLocMin= +function(b){for(var c;;){for(;f.IntPoint.op_Inequality(b.Bot,b.Prev.Bot)||f.IntPoint.op_Equality(b.Curr,b.Top);)b=b.Next;if(b.Dx!=f.ClipperBase.horizontal&&b.Prev.Dx!=f.ClipperBase.horizontal)break;for(;b.Prev.Dx==f.ClipperBase.horizontal;)b=b.Prev;for(c=b;b.Dx==f.ClipperBase.horizontal;)b=b.Next;if(b.Top.Y!=b.Prev.Bot.Y){c.Prev.Bot.Xd.Next.Top.X&&(d=h.Prev)}for(;b!=d;)b.NextInLML=b.Next,b.Dx==f.ClipperBase.horizontal&&b!=k&&b.Bot.X!=b.Prev.Top.X&&this.ReverseHorizontal(b),b=b.Next;b.Dx==f.ClipperBase.horizontal&&b!=k&&b.Bot.X!= +b.Prev.Top.X&&this.ReverseHorizontal(b);d=d.Next}else{for(;d.Top.Y==d.Prev.Bot.Y&&d.Prev.OutIdx!=f.ClipperBase.Skip;)d=d.Prev;if(d.Dx==f.ClipperBase.horizontal&&d.Prev.OutIdx!=f.ClipperBase.Skip){for(h=d;h.Next.Dx==f.ClipperBase.horizontal;)h=h.Next;h.Next.Top.X==d.Prev.Top.X?c||(d=h.Next):h.Next.Top.X>d.Prev.Top.X&&(d=h.Next)}for(;b!=d;)b.NextInLML=b.Prev,b.Dx==f.ClipperBase.horizontal&&b!=k&&b.Bot.X!=b.Next.Top.X&&this.ReverseHorizontal(b),b=b.Prev;b.Dx==f.ClipperBase.horizontal&&b!=k&&b.Bot.X!= +b.Next.Top.X&&this.ReverseHorizontal(b);d=d.Prev}return d};f.ClipperBase.prototype.AddPath=function(b,c,k){f.use_lines?k||c!=f.PolyType.ptClip||f.Error("AddPath: Open paths must be subject."):k||f.Error("AddPath: Open paths have been disabled.");var d=b.length-1;if(k)for(;0d||!k&&1>d)return!1;for(var h=[],n=0;n<=d;n++)h.push(new f.TEdge);var J=!0;h[1].Curr.X=b[1].X;h[1].Curr.Y=b[1].Y;f.use_xyz&&(h[1].Curr.Z= +b[1].Z);var p={Value:this.m_UseFullRange};this.RangeTest(b[0],p);this.m_UseFullRange=p.Value;p.Value=this.m_UseFullRange;this.RangeTest(b[d],p);this.m_UseFullRange=p.Value;this.InitEdge(h[0],h[1],h[d],b[0]);this.InitEdge(h[d],h[0],h[d-1],b[d]);for(n=d-1;1<=n;--n)p.Value=this.m_UseFullRange,this.RangeTest(b[n],p),this.m_UseFullRange=p.Value,this.InitEdge(h[n],h[n+1],h[n-1],b[n]);for(n=b=d=h[0];;)if(b.Curr!=b.Next.Curr||!k&&b.Next==d){if(b.Prev==b.Next)break;else if(k&&f.ClipperBase.SlopesEqual(b.Prev.Curr, +b.Curr,b.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(b.Prev.Curr,b.Curr,b.Next.Curr))){b==d&&(d=b.Next);b=this.RemoveEdge(b);n=b=b.Prev;continue}b=b.Next;if(b==n||!k&&b.Next==d)break}else{if(b==b.Next)break;b==d&&(d=b.Next);n=b=this.RemoveEdge(b)}if(!k&&b==b.Next||k&&b.Prev==b.Next)return!1;k||(this.m_HasOpenPaths=!0,d.Prev.OutIdx=f.ClipperBase.Skip);b=d;do this.InitEdge2(b,c),b=b.Next,J&&b.Curr.Y!=d.Curr.Y&&(J=!1);while(b!=d);if(J){if(k)return!1;b.Prev.OutIdx= +f.ClipperBase.Skip;b.Prev.Bot.Xb.X==c.X +b.Y==c.Y=this.m_MinimaList.Y)b.Next=this.m_MinimaList,this.m_MinimaList=b;else{for(var c=this.m_MinimaList;null!== +c.Next&&b.Ythis.m_Scanbeam.Y){var c=new f.Scanbeam;c.Y=b;c.Next=this.m_Scanbeam;this.m_Scanbeam=c}else{for(var k=this.m_Scanbeam;null!==k.Next&&b<=k.Next.Y;)k=k.Next;b!=k.Y&&(c=new f.Scanbeam,c.Y=b,c.Next=k.Next,k.Next=c)}};f.Clipper.prototype.Execute= +function(){var b=arguments,c=b.length,k=b[1]instanceof f.PolyTree;if(4!=c||k){if(4==c&&k){c=b[0];var d=b[1];k=b[2];b=b[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0;this.m_SubjFillType=k;this.m_ClipFillType=b;this.m_ClipType=c;this.m_UsingPolyTree=!0;try{(h=this.ExecuteInternal())&&this.BuildResult2(d)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(2==c&&!k||2==c&&k)return c=b[0],d=b[1],this.Execute(c,d,f.PolyFillType.pftEvenOdd,f.PolyFillType.pftEvenOdd)}else{c= +b[0];d=b[1];k=b[2];b=b[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&f.Error("Error: PolyTree struct is need for open path clipping.");this.m_ExecuteLocked=!0;f.Clear(d);this.m_SubjFillType=k;this.m_ClipFillType=b;this.m_ClipType=c;this.m_UsingPolyTree=!1;try{var h=this.ExecuteInternal();h&&this.BuildResult(d)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}};f.Clipper.prototype.FixHoleLinkage=function(b){if(null!==b.FirstLeft&&(b.IsHole==b.FirstLeft.IsHole||null===b.FirstLeft.Pts)){for(var c= +b.FirstLeft;null!==c&&(c.IsHole==b.IsHole||null===c.Pts);)c=c.FirstLeft;b.FirstLeft=c}};f.Clipper.prototype.ExecuteInternal=function(){try{this.Reset();if(null===this.m_CurrentLM)return!1;var b=this.PopScanbeam();do{this.InsertLocalMinimaIntoAEL(b);f.Clear(this.m_GhostJoins);this.ProcessHorizontals(!1);if(null===this.m_Scanbeam)break;var c=this.PopScanbeam();if(!this.ProcessIntersections(c))return!1;this.ProcessEdgesAtTopOfScanbeam(c);b=c}while(null!==this.m_Scanbeam||null!==this.m_CurrentLM);b=0; +for(var k=this.m_PolyOuts.length;bb.Top.Y?c.Top.Xf.Clipper.TopX(c,b.Top.Y):c.Curr.Xb.WindCnt2}case f.ClipType.ctUnion:switch(k){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2;default:return 0<=b.WindCnt2}case f.ClipType.ctDifference:if(b.PolyTyp==f.PolyType.ptSubject)switch(k){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2; +default:return 0<=b.WindCnt2}else switch(k){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0!==b.WindCnt2;case f.PolyFillType.pftPositive:return 0b.WindCnt2}case f.ClipType.ctXor:if(0===b.WindDelta)switch(k){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2;default:return 0<=b.WindCnt2}}return!0};f.Clipper.prototype.SetWindingCount=function(b){for(var c=b.PrevInAEL;null!== +c&&(c.PolyTyp!=b.PolyTyp||0===c.WindDelta);)c=c.PrevInAEL;if(null===c)b.WindCnt=0===b.WindDelta?1:b.WindDelta,b.WindCnt2=0,c=this.m_ActiveEdges;else{if(0===b.WindDelta&&this.m_ClipType!=f.ClipType.ctUnion)b.WindCnt=1;else if(this.IsEvenOddFillType(b))if(0===b.WindDelta){for(var k=!0,d=c.PrevInAEL;null!==d;)d.PolyTyp==c.PolyTyp&&0!==d.WindDelta&&(k=!k),d=d.PrevInAEL;b.WindCnt=k?0:1}else b.WindCnt=b.WindDelta;else b.WindCnt=0>c.WindCnt*c.WindDelta?1c.WindDelta*b.WindDelta?c.WindCnt: +c.WindCnt+b.WindDelta:0===b.WindDelta?1:b.WindDelta:0===b.WindDelta?0>c.WindCnt?c.WindCnt-1:c.WindCnt+1:0>c.WindDelta*b.WindDelta?c.WindCnt:c.WindCnt+b.WindDelta;b.WindCnt2=c.WindCnt2;c=c.NextInAEL}if(this.IsEvenOddAltFillType(b))for(;c!=b;)0!==c.WindDelta&&(b.WindCnt2=0===b.WindCnt2?1:0),c=c.NextInAEL;else for(;c!=b;)b.WindCnt2+=c.WindDelta,c=c.NextInAEL};f.Clipper.prototype.AddEdgeToSEL=function(b){null===this.m_SortedEdges?(this.m_SortedEdges=b,b.PrevInSEL=null,b.NextInSEL=null):(b.NextInSEL=this.m_SortedEdges, +b.PrevInSEL=null,this.m_SortedEdges=this.m_SortedEdges.PrevInSEL=b)};f.Clipper.prototype.CopyAELToSEL=function(){var b=this.m_ActiveEdges;for(this.m_SortedEdges=b;null!==b;)b.PrevInSEL=b.PrevInAEL,b=b.NextInSEL=b.NextInAEL};f.Clipper.prototype.SwapPositionsInAEL=function(b,c){if(b.NextInAEL!=b.PrevInAEL&&c.NextInAEL!=c.PrevInAEL){if(b.NextInAEL==c){var k=c.NextInAEL;null!==k&&(k.PrevInAEL=b);var f=b.PrevInAEL;null!==f&&(f.NextInAEL=c);c.PrevInAEL=f;c.NextInAEL=b;b.PrevInAEL=c;b.NextInAEL=k}else c.NextInAEL== +b?(k=b.NextInAEL,null!==k&&(k.PrevInAEL=c),f=c.PrevInAEL,null!==f&&(f.NextInAEL=b),b.PrevInAEL=f,b.NextInAEL=c,c.PrevInAEL=b,c.NextInAEL=k):(k=b.NextInAEL,f=b.PrevInAEL,b.NextInAEL=c.NextInAEL,null!==b.NextInAEL&&(b.NextInAEL.PrevInAEL=b),b.PrevInAEL=c.PrevInAEL,null!==b.PrevInAEL&&(b.PrevInAEL.NextInAEL=b),c.NextInAEL=k,null!==c.NextInAEL&&(c.NextInAEL.PrevInAEL=c),c.PrevInAEL=f,null!==c.PrevInAEL&&(c.PrevInAEL.NextInAEL=c));null===b.PrevInAEL?this.m_ActiveEdges=b:null===c.PrevInAEL&&(this.m_ActiveEdges= +c)}};f.Clipper.prototype.SwapPositionsInSEL=function(b,c){if(null!==b.NextInSEL||null!==b.PrevInSEL)if(null!==c.NextInSEL||null!==c.PrevInSEL){if(b.NextInSEL==c){var k=c.NextInSEL;null!==k&&(k.PrevInSEL=b);var f=b.PrevInSEL;null!==f&&(f.NextInSEL=c);c.PrevInSEL=f;c.NextInSEL=b;b.PrevInSEL=c;b.NextInSEL=k}else c.NextInSEL==b?(k=b.NextInSEL,null!==k&&(k.PrevInSEL=c),f=c.PrevInSEL,null!==f&&(f.NextInSEL=b),b.PrevInSEL=f,b.NextInSEL=c,c.PrevInSEL=b,c.NextInSEL=k):(k=b.NextInSEL,f=b.PrevInSEL,b.NextInSEL= +c.NextInSEL,null!==b.NextInSEL&&(b.NextInSEL.PrevInSEL=b),b.PrevInSEL=c.PrevInSEL,null!==b.PrevInSEL&&(b.PrevInSEL.NextInSEL=b),c.NextInSEL=k,null!==c.NextInSEL&&(c.NextInSEL.PrevInSEL=c),c.PrevInSEL=f,null!==c.PrevInSEL&&(c.PrevInSEL.NextInSEL=c));null===b.PrevInSEL?this.m_SortedEdges=b:null===c.PrevInSEL&&(this.m_SortedEdges=c)}};f.Clipper.prototype.AddLocalMaxPoly=function(b,c,k){this.AddOutPt(b,k);0==c.WindDelta&&this.AddOutPt(c,k);b.OutIdx==c.OutIdx?(b.OutIdx=-1,c.OutIdx=-1):b.OutIdxc.Dx?(d=this.AddOutPt(b,k),c.OutIdx=b.OutIdx,b.Side=f.EdgeSide.esLeft,c.Side=f.EdgeSide.esRight,h=b,b=h.PrevInAEL==c?c.PrevInAEL:h.PrevInAEL):(d=this.AddOutPt(c,k),b.OutIdx=c.OutIdx,b.Side=f.EdgeSide.esRight,c.Side=f.EdgeSide.esLeft,h=c,b=h.PrevInAEL==b?b.PrevInAEL:h.PrevInAEL);null!==b&&0<=b.OutIdx&&f.Clipper.TopX(b,k.Y)==f.Clipper.TopX(h,k.Y)&&f.ClipperBase.SlopesEqual(h, +b,this.m_UseFullRange)&&0!==h.WindDelta&&0!==b.WindDelta&&(k=this.AddOutPt(b,k),this.AddJoin(d,k,h.Top));return d};f.Clipper.prototype.CreateOutRec=function(){var b=new f.OutRec;b.Idx=-1;b.IsHole=!1;b.IsOpen=!1;b.FirstLeft=null;b.Pts=null;b.BottomPt=null;b.PolyNode=null;this.m_PolyOuts.push(b);b.Idx=this.m_PolyOuts.length-1;return b};f.Clipper.prototype.AddOutPt=function(b,c){var k=b.Side==f.EdgeSide.esLeft;if(0>b.OutIdx){var d=this.CreateOutRec();d.IsOpen=0===b.WindDelta;var h=new f.OutPt;d.Pts= +h;h.Idx=d.Idx;h.Pt.X=c.X;h.Pt.Y=c.Y;f.use_xyz&&(h.Pt.Z=c.Z);h.Next=h;h.Prev=h;d.IsOpen||this.SetHoleState(b,d);b.OutIdx=d.Idx}else{d=this.m_PolyOuts[b.OutIdx];b=d.Pts;if(k&&f.IntPoint.op_Equality(c,b.Pt))return b;if(!k&&f.IntPoint.op_Equality(c,b.Prev.Pt))return b.Prev;h=new f.OutPt;h.Idx=d.Idx;h.Pt.X=c.X;h.Pt.Y=c.Y;f.use_xyz&&(h.Pt.Z=c.Z);h.Next=b;h.Prev=b.Prev;h.Prev.Next=h;b.Prev=h;k&&(d.Pts=h)}return h};f.Clipper.prototype.SwapPoints=function(b,c){var k=new f.IntPoint(b.Value);b.Value.X=c.Value.X; +b.Value.Y=c.Value.Y;f.use_xyz&&(b.Value.Z=c.Value.Z);c.Value.X=k.X;c.Value.Y=k.Y;f.use_xyz&&(c.Value.Z=k.Z)};f.Clipper.prototype.HorzSegmentsOverlap=function(b,c,k,f){var d;b>c&&(d=b,b=c,c=d);k>f&&(d=k,k=f,f=d);return b=h&&d>=k||b>=h&&b>=k}; +f.Clipper.prototype.GetBottomPt=function(b){for(var c=null,k=b.Next;k!=b;)k.Pt.Y>b.Pt.Y?(b=k,c=null):k.Pt.Y==b.Pt.Y&&k.Pt.X<=b.Pt.X&&(k.Pt.Xf.Pt.Y?b:k.Pt.Yf.Pt.X?c:k.Next==k?c:f.Next==f?b:this.FirstIsBottomPt(k,f)?b:c};f.Clipper.prototype.Param1RightOfParam2=function(b,c){do if(b=b.FirstLeft,b==c)return!0;while(null!==b);return!1};f.Clipper.prototype.GetOutRec=function(b){for(b=this.m_PolyOuts[b];b!=this.m_PolyOuts[b.Idx];)b=this.m_PolyOuts[b.Idx];return b};f.Clipper.prototype.AppendPolygon=function(b,c){var k=this.m_PolyOuts[b.OutIdx],d=this.m_PolyOuts[c.OutIdx];var h=this.Param1RightOfParam2(k, +d)?d:this.Param1RightOfParam2(d,k)?k:this.GetLowermostRec(k,d);var n=k.Pts,J=n.Prev,p=d.Pts,t=p.Prev;b.Side==f.EdgeSide.esLeft?(c.Side==f.EdgeSide.esLeft?(this.ReversePolyPtLinks(p),p.Next=n,n.Prev=p,J.Next=t,t.Prev=J,k.Pts=t):(t.Next=n,n.Prev=t,p.Prev=J,J.Next=p,k.Pts=p),n=f.EdgeSide.esLeft):(c.Side==f.EdgeSide.esRight?(this.ReversePolyPtLinks(p),J.Next=t,t.Prev=J,p.Next=n,n.Prev=p):(J.Next=p,p.Prev=J,n.Prev=t,t.Next=n),n=f.EdgeSide.esRight);k.BottomPt=null;h==d&&(d.FirstLeft!=k&&(k.FirstLeft=d.FirstLeft), +k.IsHole=d.IsHole);d.Pts=null;d.BottomPt=null;d.FirstLeft=k;h=b.OutIdx;J=c.OutIdx;b.OutIdx=-1;c.OutIdx=-1;for(p=this.m_ActiveEdges;null!==p;){if(p.OutIdx==J){p.OutIdx=h;p.Side=n;break}p=p.NextInAEL}d.Idx=k.Idx};f.Clipper.prototype.ReversePolyPtLinks=function(b){if(null!==b){var c=b;do{var k=c.Next;c.Next=c.Prev;c=c.Prev=k}while(c!=b)}};f.Clipper.SwapSides=function(b,c){var k=b.Side;b.Side=c.Side;c.Side=k};f.Clipper.SwapPolyIndexes=function(b,c){var k=b.OutIdx;b.OutIdx=c.OutIdx;c.OutIdx=k};f.Clipper.prototype.IntersectEdges= +function(b,c,k){var d=0<=b.OutIdx,h=0<=c.OutIdx;f.use_xyz&&this.SetZ(k,b,c);if(!f.use_lines||0!==b.WindDelta&&0!==c.WindDelta){if(b.PolyTyp==c.PolyTyp)if(this.IsEvenOddFillType(b)){var n=b.WindCnt;b.WindCnt=c.WindCnt;c.WindCnt=n}else b.WindCnt=0===b.WindCnt+c.WindDelta?-b.WindCnt:b.WindCnt+c.WindDelta,c.WindCnt=0===c.WindCnt-b.WindDelta?-c.WindCnt:c.WindCnt-b.WindDelta;else this.IsEvenOddFillType(c)?b.WindCnt2=0===b.WindCnt2?1:0:b.WindCnt2+=c.WindDelta,this.IsEvenOddFillType(b)?c.WindCnt2=0===c.WindCnt2? +1:0:c.WindCnt2-=b.WindDelta;var J,p,t;b.PolyTyp==f.PolyType.ptSubject?(J=this.m_SubjFillType,t=this.m_ClipFillType):(J=this.m_ClipFillType,t=this.m_SubjFillType);c.PolyTyp==f.PolyType.ptSubject?(p=this.m_SubjFillType,n=this.m_ClipFillType):(p=this.m_ClipFillType,n=this.m_SubjFillType);switch(J){case f.PolyFillType.pftPositive:J=b.WindCnt;break;case f.PolyFillType.pftNegative:J=-b.WindCnt;break;default:J=Math.abs(b.WindCnt)}switch(p){case f.PolyFillType.pftPositive:p=c.WindCnt;break;case f.PolyFillType.pftNegative:p= +-c.WindCnt;break;default:p=Math.abs(c.WindCnt)}if(d&&h)0!=J&&1!=J||0!=p&&1!=p||b.PolyTyp!=c.PolyTyp&&this.m_ClipType!=f.ClipType.ctXor?this.AddLocalMaxPoly(b,c,k):(this.AddOutPt(b,k),this.AddOutPt(c,k),f.Clipper.SwapSides(b,c),f.Clipper.SwapPolyIndexes(b,c));else if(d){if(0===p||1==p)this.AddOutPt(b,k),f.Clipper.SwapSides(b,c),f.Clipper.SwapPolyIndexes(b,c)}else if(h){if(0===J||1==J)this.AddOutPt(c,k),f.Clipper.SwapSides(b,c),f.Clipper.SwapPolyIndexes(b,c)}else if(!(0!=J&&1!=J||0!=p&&1!=p)){switch(t){case f.PolyFillType.pftPositive:d= +b.WindCnt2;break;case f.PolyFillType.pftNegative:d=-b.WindCnt2;break;default:d=Math.abs(b.WindCnt2)}switch(n){case f.PolyFillType.pftPositive:h=c.WindCnt2;break;case f.PolyFillType.pftNegative:h=-c.WindCnt2;break;default:h=Math.abs(c.WindCnt2)}if(b.PolyTyp!=c.PolyTyp)this.AddLocalMinPoly(b,c,k);else if(1==J&&1==p)switch(this.m_ClipType){case f.ClipType.ctIntersection:0=d&&0>=h&&this.AddLocalMinPoly(b,c,k);break;case f.ClipType.ctDifference:(b.PolyTyp== +f.PolyType.ptClip&&0=d&&0>=h)&&this.AddLocalMinPoly(b,c,k);break;case f.ClipType.ctXor:this.AddLocalMinPoly(b,c,k)}else f.Clipper.SwapSides(b,c)}}else if(0!=b.WindDelta||0!=c.WindDelta)b.PolyTyp==c.PolyTyp&&b.WindDelta!=c.WindDelta&&this.m_ClipType==f.ClipType.ctUnion?0===b.WindDelta?h&&(this.AddOutPt(b,k),d&&(b.OutIdx=-1)):d&&(this.AddOutPt(c,k),h&&(c.OutIdx=-1)):b.PolyTyp!=c.PolyTyp&&(0!==b.WindDelta||1!=Math.abs(c.WindCnt)||this.m_ClipType==f.ClipType.ctUnion&& +0!==c.WindCnt2?0!==c.WindDelta||1!=Math.abs(b.WindCnt)||this.m_ClipType==f.ClipType.ctUnion&&0!==b.WindCnt2||(this.AddOutPt(c,k),h&&(c.OutIdx=-1)):(this.AddOutPt(b,k),d&&(b.OutIdx=-1)))};f.Clipper.prototype.DeleteFromAEL=function(b){var c=b.PrevInAEL,k=b.NextInAEL;if(null!==c||null!==k||b==this.m_ActiveEdges)null!==c?c.NextInAEL=k:this.m_ActiveEdges=k,null!==k&&(k.PrevInAEL=c),b.NextInAEL=null,b.PrevInAEL=null};f.Clipper.prototype.DeleteFromSEL=function(b){var c=b.PrevInSEL,k=b.NextInSEL;if(null!== +c||null!==k||b==this.m_SortedEdges)null!==c?c.NextInSEL=k:this.m_SortedEdges=k,null!==k&&(k.PrevInSEL=c),b.NextInSEL=null,b.PrevInSEL=null};f.Clipper.prototype.UpdateEdgeIntoAEL=function(b){null===b.NextInLML&&f.Error("UpdateEdgeIntoAEL: invalid call");var c=b.PrevInAEL,k=b.NextInAEL;b.NextInLML.OutIdx=b.OutIdx;null!==c?c.NextInAEL=b.NextInLML:this.m_ActiveEdges=b.NextInLML;null!==k&&(k.PrevInAEL=b.NextInLML);b.NextInLML.Side=b.Side;b.NextInLML.WindDelta=b.WindDelta;b.NextInLML.WindCnt=b.WindCnt; +b.NextInLML.WindCnt2=b.WindCnt2;b=b.NextInLML;b.Curr.X=b.Bot.X;b.Curr.Y=b.Bot.Y;f.use_xyz&&(b.Curr.Z=b.Bot.Z);b.PrevInAEL=c;b.NextInAEL=k;f.ClipperBase.IsHorizontal(b)||this.InsertScanbeam(b.Top.Y);return b};f.Clipper.prototype.ProcessHorizontals=function(b){for(var c=this.m_SortedEdges;null!==c;)this.DeleteFromSEL(c),this.ProcessHorizontal(c,b),c=this.m_SortedEdges};f.Clipper.prototype.GetHorzDirection=function(b,c){b.Bot.X=h){if(B==p&&t){if(0<=b.OutIdx){d=this.AddOutPt(b,b.Top);for(k=this.m_SortedEdges;null!==k;)0<=k.OutIdx&&this.HorzSegmentsOverlap(b.Bot.X,b.Top.X,k.Bot.X,k.Top.X)&&(h=this.AddOutPt(k,k.Bot),this.AddJoin(h,d,k.Top)),k=k.NextInSEL;this.AddGhostJoin(d,b.Bot);this.AddLocalMaxPoly(b,p,b.Top)}this.DeleteFromAEL(b);this.DeleteFromAEL(p);return}if(d==f.Direction.dLeftToRight){var F=new f.IntPoint(B.Curr.X,b.Curr.Y);this.IntersectEdges(b, +B,F)}else F=new f.IntPoint(B.Curr.X,b.Curr.Y),this.IntersectEdges(B,b,F);this.SwapPositionsInAEL(b,B)}else if(d==f.Direction.dLeftToRight&&B.Curr.X>=n||d==f.Direction.dRightToLeft&&B.Curr.X<=h)break;B=k}if(null!==b.NextInLML&&f.ClipperBase.IsHorizontal(b.NextInLML))b=this.UpdateEdgeIntoAEL(b),0<=b.OutIdx&&this.AddOutPt(b,b.Bot),k={Dir:d,Left:h,Right:n},this.GetHorzDirection(b,k),d=k.Dir,h=k.Left,n=k.Right;else break}null!==b.NextInLML?0<=b.OutIdx?(d=this.AddOutPt(b,b.Top),c&&this.AddGhostJoin(d,b.Bot), +b=this.UpdateEdgeIntoAEL(b),0!==b.WindDelta&&(p=b.PrevInAEL,k=b.NextInAEL,null!==p&&p.Curr.X==b.Bot.X&&p.Curr.Y==b.Bot.Y&&0!==p.WindDelta&&0<=p.OutIdx&&p.Curr.Y>p.Top.Y&&f.ClipperBase.SlopesEqual(b,p,this.m_UseFullRange)?(h=this.AddOutPt(p,b.Bot),this.AddJoin(d,h,b.Top)):null!==k&&k.Curr.X==b.Bot.X&&k.Curr.Y==b.Bot.Y&&0!==k.WindDelta&&0<=k.OutIdx&&k.Curr.Y>k.Top.Y&&f.ClipperBase.SlopesEqual(b,k,this.m_UseFullRange)&&(h=this.AddOutPt(k,b.Bot),this.AddJoin(d,h,b.Top)))):this.UpdateEdgeIntoAEL(b):(0<= +b.OutIdx&&this.AddOutPt(b,b.Top),this.DeleteFromAEL(b))};f.Clipper.prototype.GetNextInAEL=function(b,c){return c==f.Direction.dLeftToRight?b.NextInAEL:b.PrevInAEL};f.Clipper.prototype.IsMinima=function(b){return null!==b&&b.Prev.NextInLML!=b&&b.Next.NextInLML!=b};f.Clipper.prototype.IsMaxima=function(b,c){return null!==b&&b.Top.Y==c&&null===b.NextInLML};f.Clipper.prototype.IsIntermediate=function(b,c){return b.Top.Y==c&&null!==b.NextInLML};f.Clipper.prototype.GetMaximaPair=function(b){var c=null; +f.IntPoint.op_Equality(b.Next.Top,b.Top)&&null===b.Next.NextInLML?c=b.Next:f.IntPoint.op_Equality(b.Prev.Top,b.Top)&&null===b.Prev.NextInLML&&(c=b.Prev);return null===c||-2!=c.OutIdx&&(c.NextInAEL!=c.PrevInAEL||f.ClipperBase.IsHorizontal(c))?c:null};f.Clipper.prototype.ProcessIntersections=function(b){if(null==this.m_ActiveEdges)return!0;try{this.BuildIntersectList(b);if(0==this.m_IntersectList.length)return!0;if(1==this.m_IntersectList.length||this.FixupIntersectionOrder())this.ProcessIntersectList(); +else return!1}catch(c){this.m_SortedEdges=null,this.m_IntersectList.length=0,f.Error("ProcessIntersections error")}this.m_SortedEdges=null;return!0};f.Clipper.prototype.BuildIntersectList=function(b){if(null!==this.m_ActiveEdges){var c=this.m_ActiveEdges;for(this.m_SortedEdges=c;null!==c;)c.PrevInSEL=c.PrevInAEL,c.NextInSEL=c.NextInAEL,c.Curr.X=f.Clipper.TopX(c,b),c=c.NextInAEL;for(var k=!0;k&&null!==this.m_SortedEdges;){k=!1;for(c=this.m_SortedEdges;null!==c.NextInSEL;){b=c.NextInSEL;var d=new f.IntPoint; +c.Curr.X>b.Curr.X?(this.IntersectPoint(c,b,d),k=new f.IntersectNode,k.Edge1=c,k.Edge2=b,k.Pt.X=d.X,k.Pt.Y=d.Y,f.use_xyz&&(k.Pt.Z=d.Z),this.m_IntersectList.push(k),this.SwapPositionsInSEL(c,b),k=!0):c=b}if(null!==c.PrevInSEL)c.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}};f.Clipper.prototype.EdgesAdjacent=function(b){return b.Edge1.NextInSEL==b.Edge2||b.Edge1.PrevInSEL==b.Edge2};f.Clipper.IntersectNodeSort=function(b,c){return c.Pt.Y-b.Pt.Y};f.Clipper.prototype.FixupIntersectionOrder= +function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer);this.CopyAELToSEL();for(var b=this.m_IntersectList.length,c=0;cb?Math.ceil(b-.5):Math.round(b)};Wb=function(b){return 0>b?Math.ceil(b-.5):Math.floor(b+.5)};Ab=function(b){return 0>b?-Math.round(Math.abs(b)):Math.round(b)};Bb=function(b){if(0>b)return b-=.5,-2147483648>b?Math.ceil(b):b|0;b+=.5;return 2147483647c.Top.Y)return k.Y=b.Top.Y,k.X=f.Clipper.TopX(c,b.Top.Y),k.Xb.Curr.Y&&(k.Y=b.Curr.Y,k.X=Math.abs(b.Dx)>Math.abs(c.Dx)?f.Clipper.TopX(c,k.Y):f.Clipper.TopX(b,k.Y))}};f.Clipper.prototype.ProcessEdgesAtTopOfScanbeam= +function(b){for(var c=this.m_ActiveEdges;null!==c;){var k=this.IsMaxima(c,b);k&&(k=this.GetMaximaPair(c),k=null===k||!f.ClipperBase.IsHorizontal(k));if(k){var d=c.PrevInAEL;this.DoMaxima(c);c=null===d?this.m_ActiveEdges:d.NextInAEL}else{this.IsIntermediate(c,b)&&f.ClipperBase.IsHorizontal(c.NextInLML)?(c=this.UpdateEdgeIntoAEL(c),0<=c.OutIdx&&this.AddOutPt(c,c.Bot),this.AddEdgeToSEL(c)):(c.Curr.X=f.Clipper.TopX(c,b),c.Curr.Y=b);if(this.StrictlySimple&&(d=c.PrevInAEL,0<=c.OutIdx&&0!==c.WindDelta&& +null!==d&&0<=d.OutIdx&&d.Curr.X==c.Curr.X&&0!==d.WindDelta)){var h=new f.IntPoint(c.Curr);f.use_xyz&&this.SetZ(h,d,c);k=this.AddOutPt(d,h);d=this.AddOutPt(c,h);this.AddJoin(k,d,h)}c=c.NextInAEL}}this.ProcessHorizontals(!0);for(c=this.m_ActiveEdges;null!==c;)this.IsIntermediate(c,b)&&(k=null,0<=c.OutIdx&&(k=this.AddOutPt(c,c.Top)),c=this.UpdateEdgeIntoAEL(c),d=c.PrevInAEL,h=c.NextInAEL,null!==d&&d.Curr.X==c.Bot.X&&d.Curr.Y==c.Bot.Y&&null!==k&&0<=d.OutIdx&&d.Curr.Y>d.Top.Y&&f.ClipperBase.SlopesEqual(c, +d,this.m_UseFullRange)&&0!==c.WindDelta&&0!==d.WindDelta?(d=this.AddOutPt(d,c.Bot),this.AddJoin(k,d,c.Top)):null!==h&&h.Curr.X==c.Bot.X&&h.Curr.Y==c.Bot.Y&&null!==k&&0<=h.OutIdx&&h.Curr.Y>h.Top.Y&&f.ClipperBase.SlopesEqual(c,h,this.m_UseFullRange)&&0!==c.WindDelta&&0!==h.WindDelta&&(d=this.AddOutPt(h,c.Bot),this.AddJoin(k,d,c.Top))),c=c.NextInAEL};f.Clipper.prototype.DoMaxima=function(b){var c=this.GetMaximaPair(b);if(null===c)0<=b.OutIdx&&this.AddOutPt(b,b.Top),this.DeleteFromAEL(b);else{for(var k= +b.NextInAEL;null!==k&&k!=c;)this.IntersectEdges(b,k,b.Top),this.SwapPositionsInAEL(b,k),k=b.NextInAEL;-1==b.OutIdx&&-1==c.OutIdx?(this.DeleteFromAEL(b),this.DeleteFromAEL(c)):0<=b.OutIdx&&0<=c.OutIdx?(0<=b.OutIdx&&this.AddLocalMaxPoly(b,c,b.Top),this.DeleteFromAEL(b),this.DeleteFromAEL(c)):f.use_lines&&0===b.WindDelta?(0<=b.OutIdx&&(this.AddOutPt(b,b.Top),b.OutIdx=-1),this.DeleteFromAEL(b),0<=c.OutIdx&&(this.AddOutPt(c,b.Top),c.OutIdx=-1),this.DeleteFromAEL(c)):f.Error("DoMaxima error")}};f.Clipper.ReversePaths= +function(b){for(var c=0,k=b.length;ch)){for(var n=Array(h),p=0;ph||!d.IsOpen&&3>h)){this.FixHoleLinkage(d);var n=new f.PolyNode;b.m_AllPolys.push(n);d.PolyNode=n;n.m_polygon.length=h;d=d.Pts.Prev;for(var p=0;pc.Pt.X?f.Direction.dRightToLeft:f.Direction.dLeftToRight;d=k.Pt.X>d.Pt.X?f.Direction.dRightToLeft:f.Direction.dLeftToRight;if(U==d)return!1;if(U==f.Direction.dLeftToRight){for(;b.Next.Pt.X<=h.X&&b.Next.Pt.X>=b.Pt.X&&b.Next.Pt.Y==h.Y;)b=b.Next;n&&b.Pt.X!=h.X&&(b=b.Next);c=this.DupOutPt(b,!n);f.IntPoint.op_Inequality(c.Pt,h)&&(b=c,b.Pt.X=h.X,b.Pt.Y=h.Y,f.use_xyz&&(b.Pt.Z=h.Z),c=this.DupOutPt(b, +!n))}else{for(;b.Next.Pt.X>=h.X&&b.Next.Pt.X<=b.Pt.X&&b.Next.Pt.Y==h.Y;)b=b.Next;n||b.Pt.X==h.X||(b=b.Next);c=this.DupOutPt(b,n);f.IntPoint.op_Inequality(c.Pt,h)&&(b=c,b.Pt.X=h.X,b.Pt.Y=h.Y,f.use_xyz&&(b.Pt.Z=h.Z),c=this.DupOutPt(b,n))}if(d==f.Direction.dLeftToRight){for(;k.Next.Pt.X<=h.X&&k.Next.Pt.X>=k.Pt.X&&k.Next.Pt.Y==h.Y;)k=k.Next;n&&k.Pt.X!=h.X&&(k=k.Next);d=this.DupOutPt(k,!n);f.IntPoint.op_Inequality(d.Pt,h)&&(k=d,k.Pt.X=h.X,k.Pt.Y=h.Y,f.use_xyz&&(k.Pt.Z=h.Z),d=this.DupOutPt(k,!n))}else{for(;k.Next.Pt.X>= +h.X&&k.Next.Pt.X<=k.Pt.X&&k.Next.Pt.Y==h.Y;)k=k.Next;n||k.Pt.X==h.X||(k=k.Next);d=this.DupOutPt(k,n);f.IntPoint.op_Inequality(d.Pt,h)&&(k=d,k.Pt.X=h.X,k.Pt.Y=h.Y,f.use_xyz&&(k.Pt.Z=h.Z),d=this.DupOutPt(k,n))}U==f.Direction.dLeftToRight==n?(b.Prev=k,k.Next=b,c.Next=d,d.Prev=c):(b.Next=k,k.Prev=b,c.Prev=d,d.Next=c);return!0};f.Clipper.prototype.JoinPoints=function(b,c,k){var d=b.OutPt1,h;new f.OutPt;var n=b.OutPt2,p;new f.OutPt;if((p=b.OutPt1.Pt.Y==b.OffPt.Y)&&f.IntPoint.op_Equality(b.OffPt,b.OutPt1.Pt)&& +f.IntPoint.op_Equality(b.OffPt,b.OutPt2.Pt)){if(c!=k)return!1;for(h=b.OutPt1.Next;h!=d&&f.IntPoint.op_Equality(h.Pt,b.OffPt);)h=h.Next;h=h.Pt.Y>b.OffPt.Y;for(p=b.OutPt2.Next;p!=n&&f.IntPoint.op_Equality(p.Pt,b.OffPt);)p=p.Next;if(h==p.Pt.Y>b.OffPt.Y)return!1;h?(h=this.DupOutPt(d,!1),p=this.DupOutPt(n,!0),d.Prev=n,n.Next=d,h.Next=p,p.Prev=h):(h=this.DupOutPt(d,!0),p=this.DupOutPt(n,!1),d.Next=n,n.Prev=d,h.Prev=p,p.Next=h);b.OutPt1=d;b.OutPt2=h;return!0}if(p){for(h=d;d.Prev.Pt.Y==d.Pt.Y&&d.Prev!=h&& +d.Prev!=n;)d=d.Prev;for(;h.Next.Pt.Y==h.Pt.Y&&h.Next!=d&&h.Next!=n;)h=h.Next;if(h.Next==d||h.Next==n)return!1;for(p=n;n.Prev.Pt.Y==n.Pt.Y&&n.Prev!=p&&n.Prev!=h;)n=n.Prev;for(;p.Next.Pt.Y==p.Pt.Y&&p.Next!=n&&p.Next!=d;)p=p.Next;if(p.Next==n||p.Next==d)return!1;k={Left:null,Right:null};if(!this.GetOverlap(d.Pt.X,h.Pt.X,n.Pt.X,p.Pt.X,k))return!1;c=k.Left;var t=k.Right;k=new f.IntPoint;d.Pt.X>=c&&d.Pt.X<=t?(k.X=d.Pt.X,k.Y=d.Pt.Y,f.use_xyz&&(k.Z=d.Pt.Z),c=d.Pt.X>h.Pt.X):n.Pt.X>=c&&n.Pt.X<=t?(k.X=n.Pt.X, +k.Y=n.Pt.Y,f.use_xyz&&(k.Z=n.Pt.Z),c=n.Pt.X>p.Pt.X):h.Pt.X>=c&&h.Pt.X<=t?(k.X=h.Pt.X,k.Y=h.Pt.Y,f.use_xyz&&(k.Z=h.Pt.Z),c=h.Pt.X>d.Pt.X):(k.X=p.Pt.X,k.Y=p.Pt.Y,f.use_xyz&&(k.Z=p.Pt.Z),c=p.Pt.X>n.Pt.X);b.OutPt1=d;b.OutPt2=n;return this.JoinHorz(d,h,n,p,k,c)}for(h=d.Next;f.IntPoint.op_Equality(h.Pt,d.Pt)&&h!=d;)h=h.Next;if(t=h.Pt.Y>d.Pt.Y||!f.ClipperBase.SlopesEqual(d.Pt,h.Pt,b.OffPt,this.m_UseFullRange)){for(h=d.Prev;f.IntPoint.op_Equality(h.Pt,d.Pt)&&h!=d;)h=h.Prev;if(h.Pt.Y>d.Pt.Y||!f.ClipperBase.SlopesEqual(d.Pt, +h.Pt,b.OffPt,this.m_UseFullRange))return!1}for(p=n.Next;f.IntPoint.op_Equality(p.Pt,n.Pt)&&p!=n;)p=p.Next;var B=p.Pt.Y>n.Pt.Y||!f.ClipperBase.SlopesEqual(n.Pt,p.Pt,b.OffPt,this.m_UseFullRange);if(B){for(p=n.Prev;f.IntPoint.op_Equality(p.Pt,n.Pt)&&p!=n;)p=p.Prev;if(p.Pt.Y>n.Pt.Y||!f.ClipperBase.SlopesEqual(n.Pt,p.Pt,b.OffPt,this.m_UseFullRange))return!1}if(h==d||p==n||h==p||c==k&&t==B)return!1;t?(h=this.DupOutPt(d,!1),p=this.DupOutPt(n,!0),d.Prev=n,n.Next=d,h.Next=p,p.Prev=h):(h=this.DupOutPt(d,!0), +p=this.DupOutPt(n,!1),d.Next=n,n.Prev=d,h.Prev=p,p.Next=h);b.OutPt1=d;b.OutPt2=h;return!0};f.Clipper.GetBounds=function(b){for(var c=0,k=b.length;cd.right&&(d.right=b[c][h].X),b[c][h].Yd.bottom&&(d.bottom=b[c][h].Y);return d};f.Clipper.prototype.GetBounds2= +function(b){var c=b,k=new f.IntRect;k.left=b.Pt.X;k.right=b.Pt.X;k.top=b.Pt.Y;k.bottom=b.Pt.Y;for(b=b.Next;b!=c;)b.Pt.Xk.right&&(k.right=b.Pt.X),b.Pt.Yk.bottom&&(k.bottom=b.Pt.Y),b=b.Next;return k};f.Clipper.PointInPolygon=function(b,c){var k=0,f=c.length;if(3>f)return 0;for(var d=c[0],h=1;h<=f;++h){var n=h==f?c[0]:c[h];if(n.Y==b.Y&&(n.X==b.X||d.Y==b.Y&&n.X>b.X==d.X=b.X)if(n.X>b.X)k=1-k;else{var p= +(d.X-b.X)*(n.Y-b.Y)-(n.X-b.X)*(d.Y-b.Y);if(0==p)return-1;0d.Y&&(k=1-k)}else if(n.X>b.X){p=(d.X-b.X)*(n.Y-b.Y)-(n.X-b.X)*(d.Y-b.Y);if(0==p)return-1;0d.Y&&(k=1-k)}d=n}return k};f.Clipper.prototype.PointInPolygon=function(b,c){var k=0,f=c,d=b.X;b=b.Y;var h=c.Pt.X,n=c.Pt.Y;do{c=c.Next;var p=c.Pt.X,t=c.Pt.Y;if(t==b&&(p==d||n==b&&p>d==h=d)if(p>d)k=1-k;else{h=(h-d)*(t-b)-(p-d)*(n-b);if(0==h)return-1;0n&&(k=1-k)}else if(p>d){h=(h-d)*(t-b)-(p-d)*(n-b);if(0== +h)return-1;0n&&(k=1-k)}h=p;n=t}while(f!=c);return k};f.Clipper.prototype.Poly2ContainsPoly1=function(b,c){var k=b;do{var f=this.PointInPolygon(k.Pt,c);if(0<=f)return 0c)return 0;for(var k=0,d=0,f=c-1;dMath.abs(b.Y-c.Y)?b.X>c.X==b.Xb.X==c.Xc.Y== +b.Yb.Y==c.Yk&&(k=0);b=Array(k);for(h=0;hk)){var h=new f.PolyNode;h.m_jointype=c;h.m_endtype= +d;if(d==f.EndType.etClosedLine||d==f.EndType.etClosedPolygon)for(;0h.m_polygon[c].Y||b[p].Y==h.m_polygon[c].Y&&b[p].Xn)&&(this.m_polyNodes.AddChild(h),d==f.EndType.etClosedPolygon))if(0>this.m_lowest.X)this.m_lowest=new f.IntPoint(this.m_polyNodes.ChildCount()- +1,c);else if(b=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y],h.m_polygon[c].Y>b.Y||h.m_polygon[c].Y==b.Y&&h.m_polygon[c].X=this.ArcTolerance?f.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(b)*f.ClipperOffset.def_arc_tolerance? +Math.abs(b)*f.ClipperOffset.def_arc_tolerance:this.ArcTolerance)/Math.abs(b));this.m_sin=Math.sin(f.ClipperOffset.two_pi/h);this.m_cos=Math.cos(f.ClipperOffset.two_pi/h);this.m_StepsPerRad=h/f.ClipperOffset.two_pi;0>b&&(this.m_sin=-this.m_sin);for(c=0;c=b&&(3>n||d.m_endtype!=f.EndType.etClosedPolygon))){this.m_destPoly=[];if(1==n)if(d.m_jointype==f.JoinType.jtRound){d= +1;n=0;for(var p=1;p<=h;p++){this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+d*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+n*b)));var t=d;d=d*this.m_cos-this.m_sin*n;n=t*this.m_sin+n*this.m_cos}}else for(n=d=-1,p=0;4>p;++p)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+d*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+n*b))),0>d?d=1:0>n?n=1:d=-1;else{for(p=this.m_normals.length=0;pMath.abs(this.m_sinA*this.m_delta)){if(0this.m_sinA&&(this.m_sinA=-1);if(0>this.m_sinA*this.m_delta)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[c].X*this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[c].Y*this.m_delta))),this.m_destPoly.push(new f.IntPoint(this.m_srcPoly[b])),this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[b].X* +this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[b].Y*this.m_delta)));else switch(d){case f.JoinType.jtMiter:d=1+(this.m_normals[b].X*this.m_normals[c].X+this.m_normals[b].Y*this.m_normals[c].Y);d>=this.m_miterLim?this.DoMiter(b,c,d):this.DoSquare(b,c);break;case f.JoinType.jtSquare:this.DoSquare(b,c);break;case f.JoinType.jtRound:this.DoRound(b,c)}return b};f.ClipperOffset.prototype.DoSquare=function(b,c){var d=Math.tan(Math.atan2(this.m_sinA,this.m_normals[c].X*this.m_normals[b].X+ +this.m_normals[c].Y*this.m_normals[b].Y)/4);this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_delta*(this.m_normals[c].X-this.m_normals[c].Y*d)),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_delta*(this.m_normals[c].Y+this.m_normals[c].X*d))));this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_delta*(this.m_normals[b].X+this.m_normals[b].Y*d)),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_delta*(this.m_normals[b].Y-this.m_normals[b].X* +d))))};f.ClipperOffset.prototype.DoMiter=function(b,c,d){d=this.m_delta/d;this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+(this.m_normals[c].X+this.m_normals[b].X)*d),f.ClipperOffset.Round(this.m_srcPoly[b].Y+(this.m_normals[c].Y+this.m_normals[b].Y)*d)))};f.ClipperOffset.prototype.DoRound=function(b,c){var d=Math.max(f.Cast_Int32(f.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(Math.atan2(this.m_sinA,this.m_normals[c].X*this.m_normals[b].X+this.m_normals[c].Y*this.m_normals[b].Y)))), +1),h=this.m_normals[c].X;c=this.m_normals[c].Y;for(var n,p=0;pc)return b;d||(b=[b]);for(var h=b.length,n,p,t,B,F,G,I,K=[],ia=0;ian)t=p,K.push(t);else{t=p;B=c*c;F=p[0];for(I=G=1;Ic)return f.JS.Clone(b);b[0]instanceof Array||(b=[b]);var d,h,n,p,t,B=b.length,F=c*c,G=[];for(c=0;cn;n++){var I=[];p=h.length;h[p-1].X!=h[0].X||h[p-1].Y!=h[0].Y?(t=1,h.push({X:h[0].X,Y:h[0].Y}),p=h.length):t=0;var K=[];for(d=0;dh)return 0; +for(c&&(b[h]=b[0],h++);--h;){var n=b[h];var p=n.X;n=n.Y;var t=b[h-1];var B=t.X;t=t.Y;k+=f((p-B)*(p-B)+(n-t)*(n-t))}c&&b.pop();return k/d};f.JS.PerimeterOfPaths=function(b,c,d){d||(d=1);for(var k=0,h=0;hb?-1:1},Hb=function(b){b=Number(b);return-1>b||Sa(b)?NaN:0===b||Infinity===b?b:-1===b?-Infinity:0===1+b-1?b:b*(ca(1+b)/(1+b-1))},hd=function(b){return"[object Arguments]"===Na(b)},Hd=function(b){return null!==b&&"object"===typeof b&&"number"===typeof b.length&&0<=b.length&&"[object Array]"!==Na(b)&&"[object Function]"===Na(b.callee)}, +Jc=hd(arguments)?hd:Hd,Da={primitive:function(b){return null===b||"function"!==typeof b&&"object"!==typeof b},string:function(b){return"[object String]"===Na(b)},regex:function(b){return"[object RegExp]"===Na(b)},symbol:function(b){return"function"===typeof F.Symbol&&"symbol"===typeof b}},R=function(b,c,g){var d=b[c];K(b,c,g,!0);ba.preserveToString(b[c],d)},qc="function"===typeof oa&&"function"===typeof oa["for"]&&Da.symbol(oa()),eb=Da.symbol(oa.iterator)?oa.iterator:"_es6-shim iterator_";F.Set&& +"function"===typeof(new F.Set)["@@iterator"]&&(eb="@@iterator");F.Reflect||K(F,"Reflect",{},!0);var Ib=F.Reflect,Kc=String,Lc="undefined"!==typeof document&&document?document.all:null,rb=null==Lc?function(b){return null==b}:function(b){return null==b&&b!==Lc},A={Call:function(b,c){var g=2>0},ToUint32:function(b){return A.ToNumber(b)>>>0},ToNumber:function(b){if("[object Symbol]"===Na(b))throw new TypeError("Cannot convert a Symbol value to a number");return+b},ToInteger:function(b){b= +A.ToNumber(b);return Sa(b)?0:0!==b&&Ic(b)?(0=b?0:b>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:b},SameValue:function(b,c){return b===c?0===b?1/b===1/c:!0:Sa(b)&&Sa(c)},SameValueZero:function(b,c){return b===c||Sa(b)&&Sa(c)},IsIterable:function(b){return A.TypeIsObject(b)&&("undefined"!==typeof b[eb]||Jc(b))},GetIterator:function(b){if(Jc(b))return new Pa(b,"value");var c=A.GetMethod(b,eb);if(!A.IsCallable(c))throw new TypeError("value is not an iterable"); +b=A.Call(c,b);if(!A.TypeIsObject(b))throw new TypeError("bad iterator");return b},GetMethod:function(b,c){b=A.ToObject(b)[c];if(!rb(b)){if(!A.IsCallable(b))throw new TypeError("Method not callable: "+c);return b}},IteratorComplete:function(b){return!!b.done},IteratorClose:function(b,c){var g=A.GetMethod(b,"return");if(void 0!==g){try{var d=A.Call(g,b)}catch(L){var f=L}if(!c){if(f)throw f;if(!A.TypeIsObject(d))throw new TypeError("Iterator's return method returned a non-object.");}}},IteratorNext:function(b){var c= +1"+b+""},IsRegExp:function(b){if(!A.TypeIsObject(b))return!1;var c=b[oa.match];return"undefined"!==typeof c?!!c:Da.regex(b)},ToString:function(b){return Kc(b)}};if(X&&qc){var Zb=function(b){if(Da.symbol(oa[b]))return oa[b];var c=oa["for"]("Symbol."+b);Object.defineProperty(oa, +b,{configurable:!1,enumerable:!1,writable:!1,value:c});return c};if(!Da.symbol(oa.search)){var Id=Zb("search"),dc=String.prototype.search;K(RegExp.prototype,Id,function(b){return A.Call(dc,b,[this])});R(String.prototype,"search",function(b){var c=A.RequireObjectCoercible(this);if(!rb(b)){var g=A.GetMethod(b,Id);if("undefined"!==typeof g)return A.Call(g,b,[c])}return A.Call(dc,c,[A.ToString(b)])})}if(!Da.symbol(oa.replace)){var id=Zb("replace"),Ya=String.prototype.replace;K(RegExp.prototype,id,function(b, +c){return A.Call(Ya,b,[this,c])});R(String.prototype,"replace",function(b,c){var g=A.RequireObjectCoercible(this);if(!rb(b)){var d=A.GetMethod(b,id);if("undefined"!==typeof d)return A.Call(d,b,[g,c])}return A.Call(Ya,g,[A.ToString(b),c])})}if(!Da.symbol(oa.split)){var Jb=Zb("split"),jd=String.prototype.split;K(RegExp.prototype,Jb,function(b,c){return A.Call(jd,b,[this,c])});R(String.prototype,"split",function(b,c){var g=A.RequireObjectCoercible(this);if(!rb(b)){var d=A.GetMethod(b,Jb);if("undefined"!== +typeof d)return A.Call(d,b,[g,c])}return A.Call(jd,g,[A.ToString(b),c])})}var xa=Da.symbol(oa.match),$b=xa&&function(){var b={};b[oa.match]=function(){return 42};return 42!=="a".match(b)}();if(!xa||$b){var rc=Zb("match"),kd=String.prototype.match;K(RegExp.prototype,rc,function(b){return A.Call(kd,b,[this])});R(String.prototype,"match",function(b){var c=A.RequireObjectCoercible(this);if(!rb(b)){var g=A.GetMethod(b,rc);if("undefined"!==typeof g)return A.Call(g,b,[c])}return A.Call(kd,c,[A.ToString(b)])})}}var ld= +function(b,c,g){ba.preserveToString(c,b);Object.setPrototypeOf&&Object.setPrototypeOf(b,c);X?ia(Object.getOwnPropertyNames(b),function(d){d in Xb||g[d]||ba.proxy(b,d,c)}):ia(Object.keys(b),function(d){d in Xb||g[d]||(c[d]=b[d])});c.prototype=b.prototype;ba.redefine(b.prototype,"constructor",c)},sc=function(){return this},w=function(b){X&&!J(b,pc)&&ba.getter(b,pc,sc)},D=function(b,c){c=c||function(){return this};K(b,eb,c);!b[eb]&&Da.symbol(eb)&&(b[eb]=c)},Q=function(b,c,g){X?Object.defineProperty(b, +c,{configurable:!0,enumerable:!0,writable:!0,value:g}):b[c]=g;if(!A.SameValue(b[c],g))throw new TypeError("property is nonconfigurable");},lb=function(b,c,g,d){if(!A.TypeIsObject(b))throw new TypeError("Constructor requires `new`: "+c.name);b=c.prototype;A.TypeIsObject(b)||(b=g);g=ua(b);for(var f in d)J(d,f)&&K(g,f,d[f],!0);return g};if(String.fromCodePoint&&1!==String.fromCodePoint.length){var le=String.fromCodePoint;R(String,"fromCodePoint",function(b){return A.Call(le,this,arguments)})}var sa= +{fromCodePoint:function(b){for(var c=[],g,d=0,f=arguments.length;dg||1114111g?Xa(c,String.fromCharCode(g)):(g-=65536,Xa(c,String.fromCharCode((g>>10)+55296)),Xa(c,String.fromCharCode(g%1024+56320)))}return c.join("")},raw:function(b){var c=A.ToObject(b,"bad callSite");c=A.ToObject(c.raw,"bad raw value");var g=A.ToLength(c.length);if(0>=g)return"";for(var d=[],f=0,h;f=g)break;h=f+1c)return"";if(c%2)return q(b,c-1)+b;b=q(b,c/2);return b+b},Kb={repeat:function(b){var c=A.ToString(A.RequireObjectCoercible(this));b=A.ToInteger(b);if(0>b||Infinity<=b)throw new RangeError("repeat count must be less than infinity and not overflow maximum string size"); +return Jd(c,b)},startsWith:function(b){var c=A.ToString(A.RequireObjectCoercible(this));if(A.IsRegExp(b))throw new TypeError('Cannot call method "startsWith" with a regex');var g=A.ToString(b),d;1b||56319c||57343=b.length)return this._s=void 0,Mb();var g=b.charCodeAt(c);55296>g||56319g||57343h?Gb(f+h,0):b(h,f);k=0>k?Gb(f+k,0):b(k,f);var l;2l?Gb(f+l,0):b(l,f);f=b(l-k,f-h);l=1;kg?Gb(h+g,0):b(g,h);for(d=0>d?h+d:d;g1/[!0].indexOf(!0,-0)&&K(Array.prototype,"indexOf",function(b){var c=Ab(this,arguments);return 0===c&&0>1/c?0:c},!0);D(Array.prototype,function(){return this.values()});Object.getPrototypeOf&&D(Object.getPrototypeOf([].values()));var Md=function(){return I(function(){return 0===Array.from({length:-1}).length})}(),Nd=function(){var b=Array.from([0].entries());return 1===b.length&& +t(b[0])&&0===b[0][0]&&0===b[0][1]}();Md&&Nd||R(Array,"from",Nb.from);if(!function(){return I(function(){return Array.from([0],void 0)})}()){var Pc=Array.from;R(Array,"from",function(b){return 1>>0)-1:0]=!0;return I(function(){n(b,g,function(){throw new RangeError("should not reach here");},[]);return!0})};if(!Pb(Array.prototype.forEach)){var Od= +Array.prototype.forEach;R(Array.prototype,"forEach",function(b){return A.Call(Od,0<=this.length?this:[],arguments)},!0)}if(!Pb(Array.prototype.map)){var ec=Array.prototype.map;R(Array.prototype,"map",function(b){return A.Call(ec,0<=this.length?this:[],arguments)},!0)}if(!Pb(Array.prototype.filter)){var Qc=Array.prototype.filter;R(Array.prototype,"filter",function(b){return A.Call(Qc,0<=this.length?this:[],arguments)},!0)}if(!Pb(Array.prototype.some)){var oe=Array.prototype.some;R(Array.prototype, +"some",function(b){return A.Call(oe,0<=this.length?this:[],arguments)},!0)}if(!Pb(Array.prototype.every)){var pe=Array.prototype.every;R(Array.prototype,"every",function(b){return A.Call(pe,0<=this.length?this:[],arguments)},!0)}if(!Pb(Array.prototype.reduce)){var Pd=Array.prototype.reduce;R(Array.prototype,"reduce",function(b){return A.Call(Pd,0<=this.length?this:[],arguments)},!0)}if(!Pb(Array.prototype.reduceRight,!0)){var Qd=Array.prototype.reduceRight;R(Array.prototype,"reduceRight",function(b){return A.Call(Qd, +0<=this.length?this:[],arguments)},!0)}var fc=8!==Number("0o10"),Rd=2!==Number("0b10"),Sd=db("\u0085\u200b\ufffe",function(b){return 0===Number(b+0+b)});if(fc||Rd||Sd){var vb=Number,Za=/^0b[01]+$/i,od=/^0o[0-7]+$/i,Rc=Za.test.bind(Za),qe=od.test.bind(od),Td=function(b){if("function"===typeof b.valueOf){var c=b.valueOf();if(Da.primitive(c))return c}if("function"===typeof b.toString&&(c=b.toString(),Da.primitive(c)))return c;throw new TypeError("No default value");},pd=Ld.test.bind(Ld),Ud=Lb.test.bind(Lb), +Sc=function(){var b=function(c){var g=0g?0:g);for(var d=b;db)return NaN;if(1===c)return 0;if(Infinity===c)return c;b=1/(c*c);if(2>c)return Hb(c-1+Z(1-b)*c);c/=2;return Hb(c+Z(1-b)*c-1)+1/Ia},asinh:function(b){var c=Number(b);if(0===c||!ub(c))return c;b=k(c);var g=b*b;c=Yb(c);return 1>b?c*Hb(b+g/(Z(g+1)+1)):c*(Hb(b/2+Z(1+1/g)*b/2-1)+1/Ia)},atanh:function(b){b=Number(b);if(0===b)return b;if(-1===b)return-Infinity;if(1===b)return Infinity;if(Sa(b)||-1>b||1b;c&&(b=-b);if(Infinity===b)var g=Infinity;else g=U(ca(b)/3),g=(b/(g*g)+2*g)/3;return c?-g:g},clz32:function(b){b=A.ToUint32(Number(b));return 0===b?32:V?A.Call(V,b):31-c(ca(b+.5)*Ia)},cosh:function(b){b=Number(b);if(0===b)return 1;if(Sa(b))return NaN;if(!ub(b))return Infinity;b=U(k(b)-1);return Rb/2*(b+1/(b*Rb*Rb))},expm1:function(b){b=Number(b);if(-Infinity===b)return-1;if(!ub(b)||0===b)return b;if(.5c)return c=Math.expm1(c),Yb(b)*c*(1+1/(c+1))/2;c=U(c-1);return Yb(b)*(c-1/(c*Rb*Rb))*(Rb/2)},tanh:function(b){b= +Number(b);return Sa(b)||0===b?b:20<=b?1:-20>=b?-1:(Math.expm1(b)-Math.expm1(-b))/(U(b)+U(-b))},trunc:function(b){b=Number(b);return 0>b?-c(-b):c(b)},imul:function(b,c){b=A.ToUint32(b);c=A.ToUint32(c);var g=b&65535,d=c&65535;return g*d+((b>>>16&65535)*d+g*(c>>>16&65535)<<16>>>0)|0},fround:function(b){var c=Number(b);if(0===c||Infinity===c||-Infinity===c||Sa(c))return c;b=Yb(c);c=k(c);if(cte||Sa(c)?Infinity*b:b*c}}; +ta(Math,Ba);K(Math,"sinh",Ba.sinh,Infinity===Math.sinh(710));K(Math,"cosh",Ba.cosh,Infinity===Math.cosh(710));K(Math,"log1p",Ba.log1p,-1E-17!==Math.log1p(-1E-17));K(Math,"asinh",Ba.asinh,Math.asinh(-1E7)!==-Math.asinh(1E7));K(Math,"asinh",Ba.asinh,Infinity===Math.asinh(1E300));K(Math,"atanh",Ba.atanh,0===Math.atanh(1E-300));K(Math,"tanh",Ba.tanh,-2E-17!==Math.tanh(-2E-17));K(Math,"acosh",Ba.acosh,Infinity===Math.acosh(Number.MAX_VALUE));K(Math,"acosh",Ba.acosh,!(8>k(1-Math.acosh(1+Number.EPSILON)/ +Math.sqrt(2*Number.EPSILON))/Number.EPSILON));K(Math,"cbrt",Ba.cbrt,!(8>k(1-Math.cbrt(1E-300)/1E-100)/Number.EPSILON));K(Math,"sinh",Ba.sinh,-2E-17!==Math.sinh(-2E-17));var xc=Math.expm1(10);K(Math,"expm1",Ba.expm1,22025.465794806718xc);var yc=Math.round,ee=0===Math.round(.5-Number.EPSILON/4)&&1===Math.round(-.5+Number.EPSILON/3.99),wd=[Vc+1,2*Vc-1].every(function(b){return Math.round(b)===b});K(Math,"round",function(b){var g=c(b);return.5>b-g?g:-1===g?-0:g+1},!ee||!wd);ba.preserveToString(Math.round, +yc);var zc=Math.imul;-5!==Math.imul(4294967295,5)&&(Math.imul=Ba.imul,ba.preserveToString(Math.imul,zc));2!==Math.imul.length&&R(Math,"imul",function(b,c){return A.Call(zc,Math,arguments)});var Bc=function(){var b=F.setTimeout;if("function"===typeof b||"object"===typeof b){A.IsPromise=function(b){return A.TypeIsObject(b)&&"undefined"!==typeof b._promise?!0:!1};var c=function(b){if(!A.IsConstructor(b))throw new TypeError("Bad promise constructor");var c=this;c.resolve=void 0;c.reject=void 0;c.promise= +new b(function(b,g){if(void 0!==c.resolve||void 0!==c.reject)throw new TypeError("Bad Promise implementation!");c.resolve=b;c.reject=g});if(!A.IsCallable(c.resolve)||!A.IsCallable(c.reject))throw new TypeError("Bad promise constructor");},g;"undefined"!==typeof window&&A.IsCallable(window.postMessage)&&(g=function(){var b=[];window.addEventListener("message",function(c){c.source===window&&"zero-timeout-message"===c.data&&(c.stopPropagation(),0!==b.length&&T(b)())},!0);return function(c){Xa(b,c);window.postMessage("zero-timeout-message", +"*")}});var d=function(){var b=F.Promise,c=b&&b.resolve&&b.resolve();return c&&function(b){return c.then(b)}},f=A.IsCallable(F.setImmediate)?F.setImmediate:"object"===typeof process&&process.nextTick?process.nextTick:d()||(A.IsCallable(g)?g():function(c){b(c,0)}),h=function(b){return b},k=function(b){throw b;},l={},p=function(b,c,g){f(function(){if(c===l)b(g);else{try{var d=b(g);var f=c.resolve}catch(Xc){d=Xc,f=c.reject}f(d)}})},r=function(b,c){var g=b._promise,d=g.reactionLength;if(0t&&(t=0);++t;return function(){--t;0>t&&console.error("Wait count mismatch: "+d);if(0===t)for(var h=0,n=G.length;h=t?h.startup():!1!==d.autostart&&G.push(h);return h}var t=-1,G=[];Math.sign||(Math.sign=function(d){return(0d)||+d});"undefined"===typeof document||"undefined"===typeof window||"undefined"=== +typeof document.addEventListener||"undefined"!==typeof window.cindyDontWait&&!0===window.cindyDontWait||document.addEventListener("DOMContentLoaded",d("DOMContentLoaded"));var B=null,I=null,O={};n.getBaseDir=function(){if(null!==B)return B;for(var d=document.getElementsByTagName("script"),h=0;h tag for Cindy.js"); +return B=I=!1};n.addNewScript=function(d,h){h||console.error.bind(console);var p=n.getBaseDir();if(!1===p)return!1;h=document.createElement("script");h.src=p+d;d=I.nextSibling;p=I.parentElement;d?p.insertBefore(h,d):p.appendChild(h);return h};n.loadScript=function(d,h,t,B){for(var p=String(d).split("."),G=window;p.length&&"object"===typeof G&&null!==G;)G=G[p.shift()];if(G&&!p.length)return t(),!0;B||(B=console.error.bind(console));p=O[d];if(!p){p=n.addNewScript(h,B);if(!1===p)return B("Can't load additional components."), +!1;O[d]=p}p.addEventListener("load",t);p.addEventListener("error",B);return null};n._autoLoadingPlugin={};n.autoLoadPlugin=function(d,h,t){if(n._pluginRegistry[d])return t(),!0;var p=n._autoLoadingPlugin[d];if(!p){h||(h=d+"-plugin.js");p=n._autoLoadingPlugin[d]=[];d=n.addNewScript(h);if(!1===d)return!1;d.addEventListener("error",console.error.bind(console))}p.push(t);return null};var h={ctype:"undefined"};n.waitFor=d;n._pluginRegistry={};n.instances=[];n.registerPlugin=function(d,h,t){if(1!==d)return console.error("Plugin API version "+ +d+" not supported"),!1;n._pluginRegistry[h]=t;(n._autoLoadingPlugin[h]||[]).forEach(function(d){d()})};var X=0;n.dumpState=function(d){d=n.instances[d||0].saveState();console.log(JSON.stringify(d))};n.debugState=function(d){n.instances.map(function(d){var h=d.config;h=JSON.parse(JSON.stringify(h));var n=d.saveState();console.log(JSON.stringify(n));for(var p in n)h[p]=n[p];d.shutdown();return h}).forEach(function(d){n(d)})};n.newInstance=function(d){function n(){ra.width=ma=ra.clientWidth;ra.height= +pa=ra.clientHeight;wa=1;if(Zc||$c)wa=Math.max(Zc?Zc/ra.width:0,$c?$c/ra.height:0),ma=wa*ra.clientWidth,pa=wa*ra.clientHeight;z.setTransform(1/wa,0,0,1/wa,0,0);C.setMat(25,0,0,25,250.5,250.5);if(ic)for(var a=0;a=b.HAVE_METADATA?(v.width=b.videoWidth,v.height=b.videoHeight):(v.ready=!1,b.addEventListener("loadedmetadata",function(){v.width=b.videoWidth;v.height=b.videoHeight;v.ready=!0;v.whenReady=f;c.forEach(f);k()}),v.whenReady=c.push.bind(c));else if("canvas"===a)v.width=b.width,v.height=b.height;else return console.error("Not a valid image element", +a,b),h;return{ctype:"image",value:v}}function I(a){function e(a,e){var b=document.createElement("button"),x=document.createElement("img");b.appendChild(x);k.appendChild(b);jc(x,a);b.addEventListener("click",e);xb[a]=function(a){a?b.classList.add("CindyJS-active"):b.classList.remove("CindyJS-active")}}function b(a){if(l){var e=f.getBoundingClientRect();O(d*(a.clientX-e.left-f.clientLeft+.5)/e.width+c)}}var v=document.createElement("div");v.className="CindyJS-animcontrols";ra.parentNode.appendChild(v); +var c=0,g=1,d=1;a.animation&&a.animation.speedRange&&$a(a.animation.speedRange[0])&&$a(a.animation.speedRange[1])&&(c=a.animation.speedRange[0],g=a.animation.speedRange[1],d=g-c);var f=document.createElement("div");f.className="CindyJS-animspeed";v.appendChild(f);var h=document.createElement("div");f.appendChild(h);T(f,"mousedown",function(a){l=!0;b(a)});T(f,"mousemove",b);T(ra.parentNode,"mouseup",function(a){l=!1},!0);var k=document.createElement("div");k.className="CindyJS-animbuttons";v.appendChild(k); +e("play",F);e("pause",ub);e("stop",Wb);xb.stop(!0);Ec=function(a){a=(a-c)/d;a=Math.max(0,Math.min(1,a));a=.1*Math.round(1E3*a);h.style.width=a+"%"};var l=!1}function O(a){ee=a;Ec&&Ec(a)}function f(a){return a()}function ba(a,e,b){var x=null;d.plugins&&(x=d.plugins[a]);x||(x=Ia._pluginRegistry[a]);x?q.use$1([u.wrap(a)],{}):(++ge,Ia.autoLoadPlugin(a,e,function(){q.use$1([u.wrap(a)],{});ua(b)}))}function ua(a){0===--ge&&(a?k():(w(V.init),(d.animation||d).autoplay&&F(),La.canvas&&Gb(La.canvas,d)))}function va(){null!== +kc&&(Ja.set(kc.state),Object.keys(kc.speeds).forEach(function(a){var e=r.csnames[a];"undefined"!==typeof e.behavior&&(a=kc.speeds[a],e.behavior.vx=a[0],e.behavior.vy=a[1],e.behavior.vz=a[2],e.behavior.fx=0,e.behavior.fy=0,e.behavior.fz=0)}),Zd())}function F(){if(!Ba){if(xc){var a=Ub.backup;a.set(Ja);for(var e={},b=0;b
';document.body.appendChild(e);var b=document.getElementById("cmd");var v=document.getElementById("log");b.onkeydown=function(e){13===e.keyCode&&""!==b.value&&(a.in(b.value), +e=q.parse$1([u.wrap(b.value)],[]),e=w(e),console.log(da(e)),"undefined"!==e.ctype&&Qa.out(da(e)),b.value="",v.scrollTop=v.scrollHeight)};this.append=function(a){v.appendChild(a)};this.clear=function(){v.innerHTML=""}}function Xa(a){var e=a;"string"===typeof a&&(e=document.getElementById(a));this.append=function(a){e.appendChild(a)};this.clear=function(){e.innerHTML=""}}function Oa(){this.append=function(a){};this.clear=function(){}}function T(a,e,b,v){void 0===v&&(v=!1);Db.push(function(){a.removeEventListener(e, +b,v)});a.addEventListener(e,b,v)}function Gb(a,e){function b(e,b){for(var x=0;x(x|0)+1&&(bc[a]=(x|0)+1,b=!0);b||(bc[a]=e.length+1);return bc[a]}function f(a){var e=a.changedTouches;b(a,!1);for(var x=0;xd[0]&&(d=[k.value.real,h]),fa.value.realf[0]&&(f=[fa.value.real,h])))}d[0]-e[0]>f[0]-b[0]?(e=e[1],d=d[1]):(e=b[1],d=f[1]);if(e!==d){q.draw$2([e,d],{dashtype:v.dashtype,size:v.size,color:v.color,alpha:v.alpha,overhang:v.overhang});break a}}q.draw$1([v.homog],{dashtype:v.dashtype,size:v.size,color:v.color,alpha:v.alpha})}for(a=0;a"+da(a.value):"shape"===a.ctype?a.type:"error"===a.ctype?"Error: "+a.message:"variable"===a.ctype?da(L.getvar(a.name)):"geo"===a.ctype?a.value.name:"image"===a.ctype?"IMAGE":"_?_"}function Fb(a,e){e="undefined"===a[0].ctype;var b="undefined"===a[1].ctype,v=w(a[1]);if(e||b)return h;"variable"===a[0].ctype?L.setvar(a[0].name,v):"infix"===a[0].ctype?"_"===a[0].oper?E.assigntake(a[0],v):sa("Can't use infix expression as lvalue"):"field"=== +a[0].ctype?E.assigndot(a[0],v):"userdata"===a[0].ctype?E.assigncolon(a[0],v):"function"===a[0].ctype&&"genList"===a[0].oper?"list"===v.ctype?E.assignlist(a[0].args,v.value):sa("Expected list in rhs of assignment"):sa("Left hand side of assignment is not a recognized lvalue");return v}function oc(a,e){e=w(a[0]);a=w(a[1]);if(e.ctype===a.ctype){if("number"===e.ctype)return u.bool(e.value.real===a.value.real&&e.value.imag===a.value.imag);if("string"===e.ctype||"boolean"===e.ctype)return u.bool(e.value=== +a.value);if("list"===e.ctype)return g.equals(e,a);if("geo"===e.ctype)return u.bool(e.value===a.value)}return{ctype:"boolean",value:!1}}function oa(a,e){return u.not(oc(a,e))}function pc(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype?{ctype:"boolean",value:l._helper.isAlmostEqual(e,a)}:"string"===e.ctype&&"string"===a.ctype||"boolean"===e.ctype&&"boolean"===a.ctype?{ctype:"boolean",value:e.value===a.value}:"list"===e.ctype&&"list"===a.ctype?g.almostequals(e,a):{ctype:"boolean", +value:!1}}function Sa(a,e){e=D(a[0]);a=D(a[1]);return"boolean"===e.ctype&&"boolean"===a.ctype?{ctype:"boolean",value:e.value&&a.value}:h}function Ic(a,e){e=D(a[0]);a=D(a[1]);return"boolean"===e.ctype&&"boolean"===a.ctype?{ctype:"boolean",value:e.value||a.value}:h}function Yb(a,e){e=a[0];"void"!==e.ctype&&(e=D(e));a=D(a[1]);var b=u.add(e,a);"Angle"===e.usage&&"Angle"===a.usage&&(b=u.withUsage(b,"Angle"));return b}function Hb(a,e){e=a[0];"void"!==e.ctype&&(e=D(e));a=D(a[1]);var b=u.sub(e,a);"Angle"=== +e.usage&&"Angle"===a.usage&&(b=u.withUsage(b,"Angle"));return b}function hd(a,e){e=D(a[0]);a=D(a[1]);var b=u.mult(e,a);"Angle"!==e.usage||a.usage?"Angle"!==a.usage||e.usage||(b=u.withUsage(b,"Angle")):b=u.withUsage(b,"Angle");return b}function Hd(a,e){e=D(a[0]);a=D(a[1]);"number"===a.ctype&&l._helper.isZero(a)&&sa("WARNING: Division by zero!");var b=u.div(e,a);"Angle"!==e.usage||a.usage?"Angle"!==a.usage||e.usage||(b=u.withUsage(b,"Angle")):b=u.withUsage(b,"Angle");return b}function Jc(a,e){e=D(a[0]); +a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype?l.pow(e,a):h}function Da(a,e){e=Q(a[0]);a=Q(a[1]);if(e!==h&&a!==h){var b=g.cross(e,a);"Point"===e.usage&&"Point"===a.usage&&(b=u.withUsage(b,"Line"));"Line"===e.usage&&"Line"===a.usage&&(b=u.withUsage(b,"Point"));return b}return h}function R(a){var e=a.length;if(0===e)return[];if(1===e)return[0];if(2===e)return a[0][0]+a[1][1]<=a[0][1]+a[1][0]?[0,1]:[1,0];if(4a[d][f]&&(h[d].cost= +a[d][f]);for(;;){for(d=0;dk[d][f]&&(m=k[d][f]);for(d=0;da&&(a= +e.value.length+a+1);if(0e.left&&(x=e.left);Ne.top&&(h=e.top);Y"===l.oper){var k=l.args[0];if("variable"!==k.ctype)throw xa("Modifier name must be an identifier",l.start);f[k.name]=l.args[1]}else c.push(l)}g.oper=g.name.toLowerCase()+"$"+g.args.length}else if("||"===f)if(1===d.length)b.push({ctype:"function",oper:"abs_infix",args:d,modifs:{}});else if(2===d.length)b.push({ctype:"function",oper:"dist_infix",args:d,modifs:{}});else throw xa("Don't support |\u2026| with "+ +d.length+" arguments",c.start);else"{}"===f?b.push({ctype:"function",oper:"genJSON",args:d,modifs:{}}):"[]"!==f&&1===d.length?b.push({ctype:"paren",args:d}):0===d.length?b.push({ctype:"list",value:[]}):b.push({ctype:"function",oper:"genList",args:d,modifs:{}});break;case "EOF":break a}}for(b.length&1||b.push(null);3<=b.length;)rc(b);return{expr:b[0],closedBy:c}}function sc(a){this.usedFunctions={};this.usedVariables={}}function w(a){if(void 0===a)return h;if("infix"===a.ctype)return a.impl(a.args, +{},a);if("variable"===a.ctype)return w(L.getvar(a.name));if("function"===a.ctype)return Ed.push(a),a=E.evaluate(a.oper,a.args,a.modifs),Ed.pop(),a;if("void"===a.ctype)return h;if("field"===a.ctype){var e=w(a.obj);return"geo"===e.ctype?Ha.getField(e.value,a.key):"list"===e.ctype?g.getField(e,a.key):"JSON"===e.ctype?Ea.getField(e,a.key):h}return"userdata"===a.ctype?(e=w(a.obj),a=u.string(da(w(a.key))),"_?_"===a.value&&(a=h),"geo"===e.ctype?Ha.getuserData(e.value,a):"list"===e.ctype||"string"===e.ctype? +Ha.getuserData(e,a):h):a}function D(a){a=w(a);if("geo"===a.ctype){var e=a.value;if("P"===e.kind)return Ha.getField(e,"xy");if("V"===e.kind)return e.value}return a}function Q(a){a=w(a);if("geo"===a.ctype){var e=a.value;if("P"===e.kind||"L"===e.kind)return Ha.getField(e,"homog")}return g._helper.isNumberVecN(a,3)?a:g._helper.isNumberVecN(a,2)?(e=g.turnIntoCSList([a.value[0],a.value[1],l.real(1)]),a.usage&&(e=u.withUsage(e,a.usage)),e):h}function lb(a){var e=new sc;e.usedFunctions=Sb;e.infixmap=S;a= +e.parse(a);for(var b in e.usedVariables)L.create(b);return a}function le(a,e){return{ctype:"infix",args:[],impl:function(){Ed=[{oper:e}];var b=w(a);Ed=[];return b}}}function sa(a){Qa.err(a+Ed.map(function(a){return"\n at "+a.oper}).join("\n"))}function Jd(){this._path=[];this._defs=[""];this._imgcache=[];this._body=[];this._saveStack=[""];this._clipIndex=0;this._stroke=this._fill="#000";this._strokeOpacity=this._fillOpacity=null;this.height=this.width=0;this.lineWidth=1;this.lineCap="butt"; +this.lineJoin="miter";this.miterLimit=10;this.globalAlpha=1}function Kb(){this._body=[];this._yPos=this._xPos=NaN;this._extGState={Af255:"<< /ca 1 >>",As255:"<< /CA 1 >>"};this._objects=[["%PDF-1.4\n"]];this._offset=this._objects[0][0].length;this._nextIndex=5;this._imgcache=[];this._xobjects={};this._pathUsed=-1;this._fillAlpha=this._strokeAlpha=this._globalAlpha=1;this.height=this.width=0;this.lineWidth=1;this.lineCap="butt";this.lineJoin="miter";this.miterLimit=10}function Kd(a,e){var b=a.width, +v=a.height,c=document.createElement("canvas");c.setAttribute("width",b);c.setAttribute("height",v);c.setAttribute("style","display:none;");var d=La.canvas;d.parentNode.insertBefore(c,d.nextSibling);try{return c.getContext("2d").drawImage(a,0,0,b,v),c.toDataURL(e||"image/png")}finally{c.parentNode.removeChild(c)}}function me(a){a=a.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/]+/g,"");var e=new Uint8Array(3*a.length>>2),b,v;for(v=b=0;b+3>4;e[v++]=d<<4|g>>2;e[v++]=g<<6|f}switch(a.length-b){case 0:break;case 2:c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(b));d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(b+ +1));e[v++]=c<<2|d>>4;break;case 3:c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(b));d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(b+1));g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(b+2));e[v++]=c<<2|d>>4;e[v++]=d<<4|g>>2;break;default:throw Error("Malformed Base64 input: "+(a.length-b)+" chars left: "+a.substr(b));}if(v!==e.length)throw Error("Failed assertion: "+v+" should be "+ +e.length);return e}function ne(a){function e(e){return(a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3])>>>0}if(57>a.length)throw Error("Too short to be a PNG file");if(2303741511!==e(0)||218765834!==e(4))throw Error("PNG signature missing");for(var b=[],v=8;va.length)throw Error("Incomplete chunk at offset 0x"+v.toString(16));var c=e(v);if(2147483648<=c)throw Error("Chunk too long");var d=v+12+c;if(d>a.length)throw Error("Incomplete chunk at offset 0x"+v.toString(16));var g=a.subarray(v+ +4,v+8);g=String.fromCharCode.apply(String,g);b.push({len:c,type:g,data:a.subarray(v+8,v+8+c),crc:e(v+8+c)});v=d}return b}function tc(a,e){var b;if(b=/^rgba\(([0-9.]+), *([0-9.]+), *([0-9.]+), *([0-9.]+)\)$/.exec(a))e(+b[1],+b[2],+b[3],+b[4]);else if(b=/^rgb\(([0-9.]+), *([0-9.]+), *([0-9.]+)\)$/.exec(a))e(+b[1],+b[2],+b[3],1);else throw Error("Can't handle color style "+a);}function Ld(a){var e=1;Object.keys(gb).forEach(function(b){var x=gb[b].value.img;if(void 0===x.cachedDataURL&&x.src)if("data:"=== +x.src.substr(0,5))x.cachedDataURL=x.src;else{++e;x.cachedDataURL=null;var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(c.readyState===XMLHttpRequest.DONE)if(200===c.status){var b=new FileReader;b.onloadend=function(){x.cachedDataURL=b.result;console.log("Cached data for image "+x.src);0===--e&&a()};b.readAsDataURL(c.response)}else console.error("Failed to load "+x.src+": "+c.statusText),0===--e&&a()};c.open("GET",x.src,!0);c.send()}});0===--e&&a()}function Lb(a,e, +b){for(b||(b="0");a.length20/d&&(m=1E4)}else if("C"===c.kind)k=r.csnames[c.args[0]],m=0,"undefined"!==typeof c.radius&&(m=c.radius.value.real),h=l.div(k.homog.value[0],k.homog.value[2]).value.real,k=l.div(k.homog.value[1],k.homog.value[2]).value.real,h-=a.x,k-=a.y,m=Math.sqrt(h*h+k*k)-m,k=h=0,0>m&&(m=-m),m+=30/d;else if("L"===c.kind||"S"===c.kind)h=c.homog,m=l,k=m.add(m.mult(h.value[0],m.conjugate(h.value[0])),m.mult(h.value[1], +m.conjugate(h.value[1]))),k=g.scaldiv(m.sqrt(k),h),m=k.value[0].value.real*a.x+k.value[1].value.real*a.y+k.value[2].value.real,h=k.value[0].value.real*m,k=k.value[1].value.real*m,0>m&&(m=-m),m+=1;if(mMath.abs(a.offset.x)&&.5>Math.abs(a.offset.y)&& +!a.mover.tmp}function Md(a){return nd(a)&&"P"===a.mover.kind}function Nd(a){return nd(a)&&("L"===a.mover.kind||"S"===a.mover.kind)}function Pc(a){ya={mover:a,offset:{x:0,y:0},prev:{x:ja.x,y:ja.y}}}function ac(){var a=Nb(ja);Md(a)?ib[Vb]=a.mover:(ib[Vb]={type:"Free",name:Pa(),labeled:!0,pos:[Ma[0],Ma[1],1]},Za(ib[Vb]));Vb++}function Pb(){var a=Nb(ja);return Nd(a)?(ib[Vb]=a.mover,Vb++,!0):!1}function Od(){var a=Nb(ja),e;(e=Nd(a))||(e=nd(a)&&"C"===a.mover.kind);return e?(ib[Vb]=a.mover,Vb++,!0):!1}function ec(){var a= +Nb(ja);if(Md(a))for(Gd.args[1]=a.mover.name,a=0;aa*a):!1}function pd(a,e){a.isshowing= +!0;if(a.args)for(var b=0;b1E12*e(ob[b+1])&&(ob[b+1]=0)}function uc(){if(fd)sb=!0;else throw Oe;}function Wd(a,e,b,c,d){return u.add(c,u.mult(b,u.sub(d,c)))}function Xd(){P&&(P.currentMouseAndScripts=[]);Ge=!0;if(ya){var a=ya.mover,e=g.realVector([ja.x+ya.offset.x,ja.y+ya.offset.y,1]); +Yd(a,e,"mouse");ya.prev.x=ja.x;ya.prev.y=ja.y}w(V.move);w(V.draw);sb||gc();Ge=!1;P&&(P.fullLog.push(g.turnIntoCSList([g.turnIntoCSList(P.currentMouseAndScripts)])),P.length>P.logLength&&P.splice(0,P.length-P.logLength),P.currentMouseAndScripts=null,P.postMouseHooks.forEach(function(a){a()}))}function Ta(a,e,b){Yd(a,e,b);Ge||sb||gc()}function Yd(a,e,b){P&&P.currentMouseAndScripts&&(P.currentMover=[]);a===Pe?(Ja.set(ob),sb=!1):(Pe=a,gc());yb.set(Ja);var x=1E4;var c=je[a.name];if(!c){var d={},f=0;c= +[];d[a.name]=a;for(var h=r.gslp,k=0;kn){var p=[e,a];m=n}else p=[a,e];n=function(){};if(P&&P.currentStep){var q=[P.labelTracing2,u.wrap(P.currentElement.name),g.turnIntoCSList(p),g.turnIntoCSList([b,c]),g.realMatrix([[x,v],[d,f]]),u.wrap(m),u.wrap(l),u.wrap(k),h];P.currentStep.push(g.turnIntoCSList(q));n=function(a){P.hasOwnProperty(a)||(P[a]=u.wrap(a));q[q.length-1]=P[a]}}g._helper.isNaN(a)||g._helper.isNaN(e)?(n("Tracing failed due to NaNs."), +sb=!0):l>3*m&&k>3*m?n("Normal case, everything all right."):1E-5>k?1E-5>l?n("Staying inside singularity."):(n("Moved into singularity."),sb=!0):1E-5>l?n("Moved out of singularity."):(fd?n("Reached refinement limit, giving up."):n("Need to refine."),uc());return p}function rd(a,e,b,c){var x=ha(3),v=ha(3),d=ha(3),f=ha(3);a=se(a,e,b,c,x,v,d,f);ea(a[0]);ea(a[1]);ea(a[2]);ea(a[3]);return g.turnIntoCSList(a)}function se(a,e,b,c,d,f,l,k){var x=function(){};d=[d,f,l,k];a=[a,e,b,c];if(lc)return a;f=0;c=Array(4); +for(b=0;4>b;b++)for(c[b]=Array(4),k=0;4>k;k++)l=g.projectiveDistMinScal(d[b],a[k]),c[b][k]=l;l=R(c);e=Array(4);for(b=0;4>b;++b)e[b]=a[l[b]],f+=c[b][l[b]];var v=1*f,N=Infinity,Y=Infinity;for(b=0;4>b;b++){if(g._helper.isNaN(a[b]))return x("Tracing failed due to NaNs."),sb=!0,e;for(k=b+1;4>k;k++)l=g.projectiveDistMinScal(d[b],d[k]),N>l&&(N=l),l=g.projectiveDistMinScal(e[b],e[k]),Y>l&&(Y=l)}if(P&&P.currentStep){var m=[P.labelTracing4,u.wrap(P.currentElement.name),g.turnIntoCSList(e),g.turnIntoCSList(d), +g.realMatrix(c),u.wrap(f),u.wrap(N),u.wrap(Y),h];P.currentStep.push(g.turnIntoCSList(m));x=function(a){P.hasOwnProperty(a)||(P[a]=u.wrap(a));m[m.length-1]=P[a]}}N>v&&Y>v||(1E-5>Y?1E-5>N?x("Staying inside singularity."):(x("Moved into singularity."),sb=!0):1E-5>N?x("Moved out of singularity."):(fd?x("Reached refinement limit, giving up."):x("Need to refine."),uc()));return e}function be(a){var e=a.length,b,c;if(lc){for(b=0;b1-na&&(k=1-na),na=g.sesquilinearproduct(a[b],a[c]).value,na=(na.real*na.real+na.imag*na.imag)/ +(l[b]*l[c]),m>1-na&&(m=1-na)}na=R(n);c=Array(e);f=0;l=!1;for(b=0;b3*f&&m>3*f?a("Normal case, everything all right."): +1E-5>m?1E-5>k?a("Staying inside singularity."):(a("Moved into singularity."),sb=!0):1E-5>k?a("Moved out of singularity."):(fd?a("Reached refinement limit, giving up."):a("Need to refine."),uc());return c}function vc(a,e){a=m._helper.flattenConicMatrix(a);e=m._helper.flattenConicMatrix(e);var b=ha(6),c=ha(6);e=qd(a,e,b,c);ea(e[0]);ea(e[1]);a=m._helper.buildConicMatrix(e[0].value);e=m._helper.buildConicMatrix(e[1].value);return g.turnIntoCSList([a,e])}function qa(a){if(qa.hasOwnProperty(a.kind))qa[a.kind](a)} +function Qb(a){Qb.hasOwnProperty(a.kind)&&(a.incidences=[],Qb[a.kind](a))}function sd(a,e){return function(){a.incidences.push(e.name);e.incidences.push(a.name)}}function wc(a,e){return function(){a.Duplicate=e}}function td(a,e){return{getInvolved:function(){return[a,e]},toString:function(){return"point "+a.name+" incident line "+e.name},apply:sd(a,e),holds:function(){var b=g.scaldiv(g.abs(a.homog),a.homog),c=g.scaldiv(g.abs(e.homog),e.homog);return l.abs(g.scalproduct(b,c)).value.realg;g++){for(var f in a){var h=r.csnames[f];!h.pinned&&m[h.type].isMovable&&(d=m[h.type].getRandomMove(h),Ta(h,d.value,d.type),Ra=Ra.filter(c))}e()}Ja.set(Ub.prover);Zd();for(e=0;ea&&(c+=2*Math.PI);0===a&&0>e&&(c=Math.PI);c>Math.PI&&(c-=2*Math.PI);return l.snap({ctype:"number",value:{real:Math.log(b),imag:c}})};l.pow=function(a,e){return l._helper.isZero(e)?l.one:l._helper.isZero(a)?l.zero:l._helper.isReal(e)?l.powRealExponent(a,e.value.real):l.exp(l.mult(l.log(a),e))};l.mod=function(a,e){var b=a.value.real,c=e.value.real;a=a.value.imag;e=e.value.imag;b-=Math.floor(b/ +c)*c;a-=Math.floor(a/e)*e;0===c&&(b=0);0===e&&(a=0);return l.snap({ctype:"number",value:{real:b,imag:a}})};l._helper.seed="NO";l._helper.seedrandom=function(a){a-=Math.floor(a);l._helper.seed=.8*a+.1};l._helper.rand=function(){if("NO"===l._helper.seed)return Math.random();var a=l._helper.seed;a=1E3*Math.sin(1E3*a);a-=Math.floor(a);return l._helper.seed=a};l._helper.randnormal=function(){var a=l._helper.rand(),e=l._helper.rand();return Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*e)};l._helper.isEqual= +function(a,e){return a.value.real===e.value.real&&a.value.imag===e.value.imag};l._helper.isLessThan=function(a,e){return a.value.real-x&&a-x};l._helper.isZero=function(a){return 0=== +a.value.real&&0===a.value.imag};l._helper.isAlmostZero=function(a){var e=a.value.real;a=a.value.imag;return e-l.eps&&a-l.eps};l._helper.isReal=function(a){return 0===a.value.imag};l._helper.isAlmostReal=function(a){a=a.value.imag;return a-l.epsbig};l._helper.isNaN=function(a){return isNaN(a.value.real)||isNaN(a.value.imag)};l._helper.isFinite=function(a){return isFinite(a.value.real)&&isFinite(a.value.imag)};l._helper.isAlmostImag=function(a){a=a.value.real;return a< +l.epsbig&&a>-l.epsbig};l._helper.z3a=l.complex(-.5,.5*Math.sqrt(3));l._helper.z3b=l.complex(-.5,-.5*Math.sqrt(3));l._helper.cub1={ctype:"list",value:[l.one,l.one,l.one]};l._helper.cub2={ctype:"list",value:[l._helper.z3a,l.one,l._helper.z3b]};l._helper.cub3={ctype:"list",value:[l._helper.z3b,l.one,l._helper.z3a]};l.solveCubic=function(a,e,b,c){a=l._helper.solveCubicHelper(a,e,b,c);return[g.scalproduct(l._helper.cub1,a),g.scalproduct(l._helper.cub2,a),g.scalproduct(l._helper.cub3,a)]};l._helper.solveCubicHelper= +function(a,e,b,c){var x=a.value.real;a=a.value.imag;var v=e.value.real;e=e.value.imag;var d=b.value.real,f=b.value.imag,h=c.value.real,k=c.value.imag,m=x*d-a*f;b=x*f+a*d;c=4*m-(v*v-e*e);var n=4*b-2*v*e,p=x*v-a*e,q=x*e+a*v,r=c*d-n*f-18*(p*h-q*k);n=c*f+n*d-18*(p*k+q*h);c=27*(x*x-a*a);var t=54*a*x,u=c*h-t*k,w=c*k+t*h,y=v*v-e*e,z=2*v*e,C=y*v-z*e,A=y*e+z*v,B=u+4*C;t=w+4*A;c=27*(r*d-n*f+B*h-t*k);n=27*(r*f+n*d+B*k+t*h);B=Math.sqrt(Math.sqrt(c*c+n*n));t=Math.atan2(n,c);n=B*Math.sin(t/2);c=B*Math.cos(t/2); +C=-2*C+9*(p*d-q*f)-u+(c*x-n*a);A=-2*A+9*(p*f+q*d)-w+(c*a+n*x);c=Math.exp(Math.log(Math.sqrt(C*C+A*A))/3);d=Math.atan2(A,C);t=c*Math.sin(d/3);n=c*Math.cos(d/3);c*=c;d*=2;m=2*y-6*m;b=2*z-6*b;z=-1.5874010519681996*(v*n-e*t);v=-1.5874010519681996*(v*t+e*n);e=1.2599210498948732*c*Math.cos(d/3);d=1.2599210498948732*c*Math.sin(d/3);c=4.762203155904599*(n*x-t*a);n=4.762203155904599*(n*a+t*x);x=c*c+n*n;t=(-m*n+b*c)/x;m=(m*c+b*n)/x;b=t;t=(-z*n+v*c)/x;z=(z*c+v*n)/x;v=t;t=(-e*n+d*c)/x;e=(e*c+d*n)/x;d=t;return g.turnIntoCSList([l.complex(m, +b),l.complex(z,v),l.complex(e,d)])};l._helper.getRangeRand=function(a,e){return Math.random()*(e-a)+a};l.getRandReal=function(a,e){a=l._helper.getRangeRand(a,e);return l.real(a)};l.getRandComplex=function(a,e){var b=l._helper.getRangeRand(a,e);a=l._helper.getRangeRand(a,e);return l.complex(b,a)};var g={_helper:{},turnIntoCSList:function(a){return{ctype:"list",value:a}}};g.EMPTY=g.turnIntoCSList([]);g.asList=function(a){return"list"===a.ctype?a:"number"===a.ctype||"boolean"===a.ctype||"geo"===a.ctype? +g.turnIntoCSList([a]):g.EMPTY};g.realVector=function(a){for(var e=[],b=0;b=b||d>=c)&&u.isEqual(a.value[d],e.value[d]);)d++;return d===b&&dx&&(b=c,x=d)}return b};g.normalizeMax=function(a){var e=l.inv(g.maxval(a));return l._helper.isFinite(e)?g.scalmult(e,a):a};g.normalizeZ=function(a){var e=l.inv(a.value[2]);return g.scalmult(e,a)};g.dehom=function(a){a=a.value.slice();var e=a.length-1,b=l.inv(a[e]);a.length=e;for(var c=0;ce&&(b=a.value[c],e=d.value.real)}return g.scaldiv(b,a)};g.recursive=function(a,e){for(var b=[],c=0;cg.abs(n).value.real&&0===k&&(n=g._helper.inverseIteration(a, +c.value[b]));f.value[b]=g._helper.isAlmostZeroVec(n)?n:g.scaldiv(g.abs(n),n);bl.abs(l.sub(c.value[b],c.value[b+1])).value.real)?k++:k=0)}f=g.transpose(f)}return g.turnIntoCSList([c,f])};g._helper.isNormalMatrix=function(a){return 1E-10>g.abs(g.sub(a,g.transjugate(a))).value.real};g._helper.QRIteration=function(a,e){var b=l.real(a.value.length),c=b.value.real,d=b.value.real;l.real(0);g.idMatrix(b,b);var f=g.zeromatrix(b,b);b=g.idMatrix(b,b);var h=e?e:2500,k=0,m=Array(d);for(e=0;el.abs2(a.value[a.value.length-1].value[a.value[0].value.length-2]).value.real&&1d;d++)c=g.scaldiv(g.abs(c),c),c=g.LUsolve(g.sub(a,g.scalmult(e,b)),JSON.parse(JSON.stringify(c)));return g.scaldiv(g.abs(c),c)};g._helper.toHessenberg=function(a){var e=JSON.parse(JSON.stringify(a)),b=e.value.length,c=l.real(b-1),d=l.real(b); +l.real(1);if(g._helper.isUpperTriangular(e))return[g.idMatrix(c,c),a];a=g.idMatrix(d,d);for(d=1;de&&q++;break}d=l.sub(d,f);h.value=h.value.splice(0,h.value.length-1)}return{Q:k,R:m,P:g.turnIntoCSList(n), +rank:l.real(q)}};g._helper.getHouseHolder=function(a){var e=l.real(a.value.length);if(1E-16>g.abs2(a))return g.idMatrix(e,e);var b=l.real(1),c=g._helper.unitvector(l.real(a.value.length),b);var d=g._helper.QRgetAlpha(a,0);d=g.sub(a,g.scalmult(d,c));d=g.scaldiv(g.abs(d),d);a=l.div(g.sesquilinearproduct(a,d),g.sesquilinearproduct(d,a));e=g.idMatrix(e,e);return e=g.sub(e,g.scalmult(l.add(b,a),g._helper.transposeMult(d,g.conjugate(d))))};g._helper.reOrderbyPivots=function(a,e){var b=a.value.length.length; +a=g.transpose(a);b=Array(b);for(var c=0;ca.value[e].value.real? +g.abs(a):l.neg(g.abs(a))};g.LUdecomp=function(a){a=JSON.parse(JSON.stringify(a));var e,b,c=0,d=a.value.length,g=d-1,f=Array(d);for(b=0;b=f&&console.log("CG did not converge");return c};g.det=function(a){if(1===a.value.length)return a.value[0].value[0];if(2===a.value.length)return g.det2(a.value[0],a.value[1]);if(3===a.value.length)return g.det3(a.value[0], +a.value[1],a.value[2]);if(4===a.value.length)return g.det4m(a);var e=a.value.length,b=l.real(1),c,d=JSON.parse(JSON.stringify(a));for(a=0;al.abs(d.value[f].value[a]).value.real&&(f=c);f!==a&&(c=d.value[f],d.value[f]=d.value[a],d.value[a]=c,b=l.neg(b));var h=d.value[a];for(c=a+1;cd.maxElVisit||d.level> +d.maxLevel)return b.printedWarning||(console.log("Warning: We visited a key-value pair very often or encountered a very deeply nested dictionary. Dictionary is probably cyclic. Output will be probably incomplete."),b.printedWarning=!0),c+":...";d.newLevel&&(d.tracker.set(x,d.tracker.get(x)+1),d.newLevel=!1)}else d.tracker.set(x,1);return c+":"+Ea._helper.niceprint(x,e,b)}).join(", ")+"}"};Ea._helper.handlePrintException=function(a){a instanceof RangeError?console.log("Warning: Dictionary string could not be generated! Probably large cyclic Dictionary!"): +a instanceof SyntaxError?console.log("Warning: Dictionary string could not be parsed!"):console.log("Warning: Dictionary printing failed!")};var nb={key:function(a){if("string"===a.ctype)return"s"+a.value.length+":"+a.value+";";if("number"===a.ctype)return"n"+a.value.real+","+a.value.imag+";";if("list"===a.ctype)return"l"+a.value.length+":"+a.value.map(nb.key).join(",")+";";if("boolean"===a.ctype)return"b"+a.value+";";if("dict"===a.ctype)return a=Object.keys(a.value).sort(),"d"+a.length+":"+a.join(",")+ +";";"undefined"!==a.ctype&&Qa.err("Bad dictionary key: "+da(a));return"undef"},create:function(){return{ctype:"dict",value:{}}},clone:function(a){var e=nb.create(),b;for(b in a.value)a.value.hasOwnProperty(b)&&(e.value[b]=a.value[b]);return e},put:function(a,e,b){a.value[nb.key(e)]={key:e,value:b}},get:function(a,e,b){return(a=a.value[nb.key(e)])?a.value:b},niceprint:function(a){return"{"+Object.keys(a.value).sort().map(function(e){e=a.value[e];return da(e.key)+":"+da(e.value)}).join(", ")+"}"}}, +u={_helper:{},order:{undefined:0,boolean:1,number:2,term:3,atomic:4,variable:5,geo:6,string:7,list:8},string:function(a){return{ctype:"string",value:a}},bool:function(a){return{ctype:"boolean",value:a}},not:function(a){return u.bool(!a.value)},isLessThan:function(a,e){return-1===u.compare(a,e)},isEqual:function(a,e){return 0===u.compare(a,e)},compareResults:function(a,e){return u.compare(a.result,e.result)},compare:function(a,e){if(a.ctype!==e.ctype)return u.order[a.ctype]-u.order[e.ctype];if("number"=== +a.ctype)return l._helper.compare(a,e);if("list"===a.ctype)return g._helper.compare(a,e);if("geo"===a.ctype)return a.value.name===e.value.name?0:a.value.name"]=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(a)?{ctype:"boolean",value:e.value.real-a.value.real>=l.eps}:h};S["=:="]= +gd("=:=");S[">="]=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(a)?{ctype:"boolean",value:e.value.real>=a.value.real}:"string"===e.ctype&&"string"===a.ctype?{ctype:"boolean",value:e.value>=a.value}:h};S["<="]=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(a)?{ctype:"boolean",value:e.value.real<=a.value.real}:"string"===e.ctype&&"string"=== +a.ctype?{ctype:"boolean",value:e.value<=a.value}:h};S["~>="]=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(a)?{ctype:"boolean",value:e.value.real-a.value.real>-l.eps}:h};S["~<="]=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(a)?{ctype:"boolean",value:e.value.real-a.value.real"]=function(a,e){e=D(a[0]);a=D(a[1]);return"number"=== +e.ctype&&"number"===a.ctype&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(a)?{ctype:"boolean",value:e.value.real>a.value.real}:"string"===e.ctype&&"string"===a.ctype?{ctype:"boolean",value:e.value>a.value}:h};S["<"]=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(a)?{ctype:"boolean",value:e.value.real"]=oa;S["\u2208"]= +function(a,e){e=w(a[0]);a=w(a[1]);return"list"===a.ctype?g.contains(a,e):h};S["\u2209"]=function(a,e){e=w(a[0]);a=w(a[1]);return"list"===a.ctype?u.not(g.contains(a,e)):h};S["&"]=Sa;S["%"]=Ic;S["!="]=oa;S["~!="]=function(a,e){return u.not(pc(a,e))};S[".."]=function(a,e){e=w(a[0]);a=w(a[1]);return"number"===e.ctype&&"number"===a.ctype?g.sequence(e,a):h};S["++"]=Ib;S["--"]=Lc;S["~~"]=Kc;S[":>"]=rb;S["<:"]=A;S["="]=Fb;S[":="]=function(a,e,b){e="undefined"===a[1].ctype;if("undefined"===a[0].ctype||e)return h; +if("function"===a[0].ctype){e=a[0].oper;var c=a[0].args,d=a[1],x=1;if(Ka.hasOwnProperty(e)){x=Ka[e];if(x.definer===b)return h;x=x.generation+1}Ka[e]={oper:e,body:d,arglist:c,definer:b,generation:x}}"variable"===a[0].ctype&&L.setvar(a[0].name,a[1]);return h};S[":=_"]=function(a,e){if("void"!==a[1].ctype)return h;"function"===a[0].ctype&&delete Ka[a[0].oper];return h};S["::="]=gd("::=");S[";"]=function(a,e){e="void"===a[0].ctype;var b="void"===a[1].ctype;if(e&&b)return h;if(!e&&b)return w(a[0]);e|| +b||w(a[0]);return b?h:w(a[1])};da.errorTypes=["_?_","_??_","_???_","___"];var q={},E={evaluate:function(a,e,b){if(Ka.hasOwnProperty(a)){a=Ka[a];if(void 0===a)e=h;else{var c=[];for(b=0;b "+da(e[a]))};L.vstack=[];L.pushVstack=function(a){this.vstack.push(a)};L.popVstack=function(){this.vstack.pop()};L.cleanVstack=function(){for(var a= +this.vstack;0 "+da(w(a));sa(a);return h};q.errc$1=function(a,e){"variable"===a[0].ctype?(e=w(L.getvar(a[0].name)),console.log(a[0].name+" ===> "+da(e))):(e=w(a[0]),console.log(" ===> "+da(e)));return h};q.print$1=function(a,e){Qa.out(da(w(a[0]),e),!0);return h};q.println$1=function(a,e){Qa.out(da(w(a[0], +e)));return h};q.assert$2=function(a,e){var b=w(a[0]);if("boolean"===b.ctype){if(!1===b.value)return q.println$1([a[1]],e)}else sa("Condition for assert is not boolean");return h};q.dump$1=function(a,e){console.log(JSON.stringify(a[0]));return h};q.repeat$2=function(a,e){return q.repeat$3([a[0],null,a[1]],e)};q.repeat$3=function(a,e){var b=D(a[0]),c="#";null!==a[1]&&"variable"===a[1].ctype&&(c=a[1].name);if("number"!==b.ctype)return h;b=Math.round(b.value.real);var d=1,g=1,f=b+1,k=!1,l=!1,m=!1;if(void 0!== +e.start){var n=w(e.start);"number"===n.ctype&&(k=!0,g=n.value.real)}void 0!==e.step&&(n=w(e.step),"number"===n.ctype&&(m=!0,d=n.value.real));void 0!==e.stop&&(n=w(e.stop),"number"===n.ctype&&(l=!0,f=n.value.real));!k||l||m||(f=d*b+g);k||!l||m||(g=-d*(b-1)+f,f+=d);k||l||!m||(f=d*b+g);k&&l&&!m&&(d=(f-g)/(b-1),f+=d);k&&!l&&m&&(f=d*b+g);!k&&l&&m&&(g=-d*(b-1)+f,f+=d);k&&l&&m&&(f+=d);(g<=f&&0=f&&0>d)&&k&&l&&m&&(b=Math.floor((f-g)/d));L.newvar(c);e=h;for(f=0;ff&&(f=c.value.length+f+1);0=c)return g.turnIntoCSList([]);if(l._helper.isZero(a.value[c]))return e=E.roots(g.turnIntoCSList(a.value.slice(0,c))),g.append(e,l.infinity);if(1===c)e[0]=l.neg(l.div(a.value[0],a.value[1]));else if(2===c)e=E.quadratic_roots(a);else{for(var d=0;da.value.real)return sa("grade cant be < 1"),h;a=l.add(a,l.real(1));return aa.autodiff(b,e,c,a)};q.cos$1=function(a,e){a=D(a[0]);return"number"===a.ctype?l.cos(a):h};q.tan$1=function(a,e){a=D(a[0]);return"number"===a.ctype?l.tan(a):h};q.arccos$1=function(a,e){a=D(a[0]);return"number"===a.ctype?l.arccos(a):h};q.arcsin$1=function(a,e){a=D(a[0]);return"number"===a.ctype?l.arcsin(a):h};q.arctan$1=function(a, +e){a=D(a[0]);return"number"===a.ctype?l.arctan(a):h};q.arctan2$2=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype?l.arctan2(e,a):h};q.arctan2$1=function(a,e){a=D(a[0]);if("list"===a.ctype&&2===a.value.length){if(a=a.value,"number"===a[0].ctype&&"number"===a[1].ctype)return q.arctan2$2(a,e)}else if("number"===a.ctype)return l.arctan2(a);return h};q.log$1=function(a,e){a=D(a[0]);return"number"===a.ctype?l.log(a):h};E.recursiveGen=function(a){var e=l[a],b=g[a];q[a+"$1"]= +function(a,c){a=D(a[0]);return"number"===a.ctype?e(a):"list"===a.ctype?b(a):h}};E.recursiveGen("im");E.recursiveGen("re");E.recursiveGen("conjugate");E.recursiveGen("round");E.recursiveGen("ceil");E.recursiveGen("floor");E.recursiveGen("abs");q.abs_infix=q.abs$1;q.random$0=function(a,e){return l.real(l._helper.rand())};q.random$1=function(a,e){a=D(a[0]);return"number"===a.ctype?l.complex(a.value.real*l._helper.rand(),a.value.imag*l._helper.rand()):h};q.seedrandom$1=function(a,e){a=D(a[0]);"number"=== +a.ctype&&l._helper.seedrandom(a.value.real);return h};q.randomnormal$0=function(a,e){return l.real(l._helper.randnormal())};q.randominteger$1=function(a,e){e=D(a[0]);return"number"===e.ctype?(a=e.value.real|0,e=e.value.imag|0,a=a*l._helper.rand()|0,e=e*l._helper.rand()|0,l.complex(a,e)):h};q.randomint$1=q.randominteger$1;q.randombool$0=function(a,e){return.5d)return l.real(0);if(0===d)return l.real(1);if(1===d)return c;for(var k=e=a=1;k<=d;++k){var m=f-d+k|0,n=k|0,fa=Zb(m,n)|0;m=m/fa|0;n=n/fa|0;fa=Zb(a,n)|0;a=a/fa|0;n=n/fa|0;fa=Zb(m,e)|0;m=m/fa|0;e=e/fa|0;a=a*m|0;e=e*n|0}return l.real(a/e)}if("list"===c.ctype){f=c.value.length;if(0>d||d>f)return g.turnIntoCSList([]);if(0===d)return g.turnIntoCSList([g.turnIntoCSList([])]); +if(d===f)return g.turnIntoCSList([c]);var p=[];var q=Array(d);b(0,0);return g.turnIntoCSList(p)}}return h};q.zeromatrix$2=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===e.ctype&&"number"===a.ctype?g.zeromatrix(e,a):h};q.zerovector$1=function(a,e){a=D(a[0]);return"number"===a.ctype?g.zerovector(a):h};q.transpose$1=function(a,e){a=D(a[0]);return"list"===a.ctype&&-1!==g._helper.colNumb(a)?g.transpose(a):h};q.row$2=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===a.ctype&&"list"===e.ctype&&-1!== +g._helper.colNumb(e)?g.row(e,a):h};q.column$2=function(a,e){e=D(a[0]);a=D(a[1]);return"number"===a.ctype&&"list"===e.ctype&&-1!==g._helper.colNumb(e)?g.column(e,a):h};q.dict$0=function(a,e){a=nb.create();for(var b in e)e.hasOwnProperty(b)&&nb.put(a,u.string(b),w(e[b]));return a};q.put$3=function(a,e){e=w(a[0]);var b=w(a[1]);a=w(a[2]);return"dict"===e.ctype?(e=nb.clone(e),nb.put(e,b,a),e):h};q.get$2=function(a,e){e=w(a[0]);a=w(a[1]);return"dict"===e.ctype?nb.get(e,a,h):h};q.red$1=function(a,e){a=w(a[0]); +return"number"===a.ctype?g.realVector([Math.min(1,Math.max(0,a.value.real)),0,0]):h};q.green$1=function(a,e){a=w(a[0]);return"number"===a.ctype?g.realVector([0,Math.min(1,Math.max(0,a.value.real)),0]):h};q.blue$1=function(a,e){a=w(a[0]);return"number"===a.ctype?g.realVector([0,0,Math.min(1,Math.max(0,a.value.real))]):h};q.gray$1=function(a,e){a=w(a[0]);return"number"===a.ctype?(a=Math.min(1,Math.max(0,a.value.real)),g.realVector([a,a,a])):h};q.grey$1=q.gray$1;E.HSVtoRGB=function(a,e,b){a&&void 0=== +e&&void 0===b&&(e=a.s,b=a.v,a=a.h);var c=Math.floor(6*a);var d=6*a-c;a=b*(1-e);var f=b*(1-d*e);e=b*(1-(1-d)*e);switch(c%6){case 0:var x=b;var h=e;var k=a;break;case 1:x=f;h=b;k=a;break;case 2:x=a;h=b;k=e;break;case 3:x=a;h=f;k=b;break;case 4:x=e;h=a;k=b;break;case 5:x=b,h=a,k=f}return g.realVector([x,h,k])};q.hue$1=function(a,e){a=w(a[0]);return"number"===a.ctype?(a=a.value.real,a-=Math.floor(a),E.HSVtoRGB(a,1,1)):h};E.shapeconvert=function(a){if("circle"===a.type){var e=a.value.value[0];e=u.div(e, +e.value[2]);var b=e.value[0].value.real,c=e.value[1].value.real;a=a.value.value[1].value.real;var d=Array(125);var g=2*Math.PI/125;for(e=0;125>e;e++)d[e]={X:b+Math.cos(e*g)*a,Y:c+Math.sin(e*g)*a};return[d]}if("polygon"===a.type){b=[];for(e=0;e=e?e=String.fromCharCode(e):(e-=65536,e=String.fromCharCode((e>>10)+55296,(e&1023)+56320));return u.string(e)};q.international$1=function(a,e){return q.international$2([a[0],null],e)};q.international$2=function(a,e){e=w(a[0]);if("string"!==e.ctype)return h;var b=(d.translations||{})[d.language||"en"]||{};if(!b.hasOwnProperty(e.value))return e;var c=b[e.value];if("string"===typeof c)return u.string(c); +if(null===a[1])return e;a=w(a[1]);a="number"===a.ctype?a.value.real:0;a=(b._pluralFormFunction||Id)(a);return aMath.min(a[0],a[1])};a=r.points.filter(function(a){return.5>c(a.homog)});e=r.lines.filter(function(a){var e=d(a.homog);e=g.normalizeMax(g.cross(a.homog,e));if((e=.5>c(e))&&"S"===a.kind){var f=a.homog;f=g.turnIntoCSList([f.value[0],f.value[1],l.zero]);a=g.crossratio3(a.farpoint,a.startpos,a.endpos,b,f).value.real;if(0>a||1a.value.real&&(c=l.neg(c));0>c.value.real&&(e=!1)}return e});a=a.concat(e,h);return g.ofGeos(a)};q.incidences$1=q.allelements$1;q.createpoint$2=function(a,e){e=w(a[0]);a=Q(a[1]);return"string"!== +e.ctype?(sa("Name must be a string"),h):"list"!==a.ctype&&g.isNumberVector(a)?(sa("Position must be a number vector"),h):{ctype:"geo",value:Za({name:e.value,type:"Free",labeled:!0,pos:a},!0)}};q.create$3=function(a,e){var b=w(a[0]),c=w(a[1]),d=w(a[2]);a={};for(var f in e)a[f]=D(e[f]);if("string"===b.ctype)f=b.value;else{if("list"!==b.ctype)return sa("Names must be a string or a list of strings"),h;if(1!==b.value.length){f=u.string(b.value.map(function(a){return a.value}).join("__"));d=q.create$3([f, +c,d],a);var k=[];if(d!==h)for(c=u.string(d.value.kind.replace(/^(.*)s$/,"Select$1")),d=g.turnIntoCSList([u.string(d.value.name)]),e=0;ec&!b;c++)8!==c&&9!==c&&e(String.fromCharCode(65+c));else if("L"===a||"S"===a)for(c=0;26>c&!b;c++)8!==c&&9!==c&&e(String.fromCharCode(97+c));for(c=0;!b;c++)e(a+c);return b}var c=w(a[0]);a=w(a[1]);var d={};for(f in e)d[f]=D(e[f]);if(!m.hasOwnProperty(c.value)&&!ed.hasOwnProperty(c.value)&&!Ee.hasOwnProperty(c.value))return sa("Invalid geometric operation: '"+c.value+"'"),h;for(;ed.hasOwnProperty(c.value);)c.value=ed[c.value];var f=m[c.value];e=u.string(b(f.kind));if(a.value.length> +f.signature.length){var k="Operation "+c.value+" requieres only "+f.signature.length+" argument"+(1===f.signature.length?"":"s")+" ("+a.value.length+" argument"+(1===a.value.length?"":"s")+" given) to create "+e.value+". Ignoring the last arguments.";if(!d.pos){var n=Q(a.value[a.value.length-1]);n!==h&&(k+=" Use the last argument as modifier `pos`.",d.pos=n)}sa(k);a=g.turnIntoCSList(a.value.slice(0,f.signature.length))}f=q.create$3([e,c,a],d);if(f!==h&&"s"===f.value.kind[1]&&f.value.results){c=u.string("Select"+ +f.value.kind[0]);a=g.turnIntoCSList([u.string(f.value.name)]);if(d.pos)return e=u.string(b(f.value.kind[0])),q.create$3([e,c,a],d);k=[];for(n=0;nl&&(l= +a.length)});g=[];for(k=0;kc.length)for(k=c.length;k")}; +q.guess$1=function(a,b){function e(a){if((a=kb.doPSLQ([a,1,Math.PI*Math.E],15))&&0===a[2])return[Math.round(a[0]),Math.round(a[1])]}function c(a){if(l._helper.isAlmostZero(a))return"0";if(!l._helper.isAlmostReal(a)){var b=a.value.real,c=a.value.imag,x=e(b),h=e(b*b+c*c);if(x&&h){b=-x[0]*h[0];var v=-x[1]*h[0]*2,m=x[0]*h[1];x=g(-v,2*b);h=v*v-4*m*b;a=f(h);h/=a*a;h=a===2*b?"+i*sqrt("+-h+")":a===-2*b?"+i*sqrt("+-h+")":"+i*"+g(a,2*b).substring(1)+"*sqrt("+-h+")";a="-"+h.substring(1);v=Math.abs((v*v-4*m* +b)/(4*b*b));b=Math.sqrt(v);v=-Math.sqrt(v);if("+0"===x||"-0"===x)x="";c=Math.abs(c-b)(x=d(n))){b=a.value.real;v=n[0];h=-n[1];n=n[2];var Y="";if(0!==v){var ka=Math.round(v);var p=Math.round(h);Y=g(ka,p)+"*pi"}ka="";0!==n&&(ka=Math.round(n),p=Math.round(h),ka=g(ka,p));k=Math.abs(b-(n/h+Math.PI*v/h));b=ka+Y;""===b?b="0":b.startsWith("+")&& +(b=b.substring(1));v=k}Y=kb.doPSLQ([a.value.real*a.value.real,a.value.real,1],15);h=1E5;if(Y&&9E3>(h=10+d(Y))){a=a.value.real;N=Y[0];n=Y[1];Y=Y[2];ka=Math.round(N);p=Math.round(n);var za=Math.round(Y);m=g(-p,2*ka);p=p*p-4*za*ka;za=f(p);p/=za*za;ka=za===2*ka?"+sqrt("+p+")":za===-2*ka?"-sqrt("+p+")":g(za,2*ka)+"*sqrt("+p+")";p=-n/(2*N);Y=Math.abs((n*n-4*Y*N)/(4*N*N));ka="+"+ka.substring(1);N="-"+ka.substring(1);n=p+Math.sqrt(Y);Y=p-Math.sqrt(Y);if("+0"===m||"-0"===m)m="";Math.abs(a-n)v&&(c=b);hN&&(c=m);return c}function d(a){var b=Math.abs(a[0]);Math.abs(a[1])>b&&(b=Math.abs(a[1]));Math.abs(a[2])>b&&(b=Math.abs(a[2]));return b}function g(a,b){var e="+";0>a*b&&(a=Math.abs(a),b=Math.abs(b),e="-");var c=Zb(a,b);a/=c;b/=c;0>a&&0>b&&(a=-a,b=-b);return 1===b?e+a:e+a+"/"+b}function f(a){for(var b=3E3;0(c.x-b.x)*(c.x-b.x)+(c.y-b.y)*(c.y-b.y)||1E-12>k||1E-12>f)return h;0>g.crossratio3(e,a,d,g.cross(g.cross(e,d),g.linfty),g.ii).value.real?y.drawsegcore(c,x):y.drawRaySegment(e,a)}return h};E.drawcircle=function(a,b,c){var e=D(a[0]);a=D(a[1]); +var d=E.extractPoint(e);if(!d.ok||"number"!==a.ctype||!l._helper.isAlmostReal(a))return h;e=C.drawingstate.matrix;var g=d.x*e.a-d.y*e.b+e.tx;d=d.x*e.c-d.y*e.d-e.ty;y.handleModifs(b,y.conicModifs);y.preDrawCurve();z.lineJoin="miter";z.beginPath();z.arc(g,d,Math.abs(a.value.real)*e.sdet,0,2*Math.PI);z.closePath();"D"===c&&z.stroke();"F"===c&&(z.fillStyle=y.lineColor,z.fill());"C"===c&&z.clip();return h};q.drawconic$1=function(a,b){a=D(a[0]);if("list"!==a.ctype||3!==a.value.length&&6!==a.value.length)return console.error("could not parse conic"), +h;if(6===a.value.length){for(var e=0;6>e;e++)if("number"!==a.value[e].ctype)return console.error("could not parse conic"),h;var c=l.real(.5);e=a.value[0];var d=a.value[2];d=l.mult(d,c);var f=a.value[1],k=a.value[3];k=l.mult(k,c);var m=a.value[4];m=l.mult(m,c);a=a.value[5];a=g.turnIntoCSList([g.turnIntoCSList([e,d,k]),g.turnIntoCSList([d,f,m]),g.turnIntoCSList([k,m,a])])}else{if(!g.isNumberMatrix(a).value||3!==a.value.length||3!==a.value[0].value.length)return h;e=g.transpose(a);g.equals(a,e).value|| +(a=g.add(e,a))}return E.drawconic(a,b)};E.drawconic=function(a,b){function e(a,b){a=(l*a+m*b+n)*a+(p*b+q)*b+r;return 0<=a?1:0>a?-1:NaN}function c(a){L.next=a;a.prev=L;return L=a}function d(a,b,c,d){return{a:a,b1:b,b2:c,vertical:!0,index:d,sign:function(b){return e(a,b)},mkp:function(b){return{x:a,y:b}},sol:dc(p,m*a+q,(l*a+n)*a+r),discr:function(){return dc(D,-2*w,t)},tpt:function(a){return{x:a,y:-.5*(m*a+q)/p}}}}function f(a,b,c,d){return{a:a,b1:b,b2:c,vertical:!1,index:d,sign:function(b){return e(b, +a)},mkp:function(b){return{x:b,y:a}},sol:dc(l,m*a+n,(p*a+q)*a+r),discr:function(){return dc(D,-2*B,A)},tpt:function(a){return{x:-.5*(m*a+n)/l,y:a}}}}function h(a){var b=Math.min(a.b1,a.b2),e=Math.max(a.b1,a.b2),d=a.sign(b),g=a.sign(e);if(!isFinite(d*g))return!1;var f=a.sol;if(d!==g){if(null===f)return!1;var x=.5*(f[0]+f[1]);x>b&&x=E)return!0;f=a.discr();if(null===f)return!0; +a=a.tpt(f[a.index]);a.x>=F&&a.x<=H&&a.y>=G&&a.y<=I&&c(a);return!0}x=.5*(f[0]+f[1]);if(!(x>b&&xa.b2&&(f=[f[1],f[0]]);J.push(c(a.mkp(f[0])));J.push(c(a.mkp(f[1])))}return!0}function k(a,b,e,c,d){var g=b-c,f=e-a,x=a*c-b*e,h=w*g+B*f+D*x;if(1E-14>Math.abs(h))return z.lineTo(e,c);var v=(t*g+u*f+w*x)/h;g=(u*g+A*f+B*x)/h;if(!isFinite(v)||!isFinite(g)||.04>Math.abs(a*g+v*c+e*b-e*g-v*b-a*c))return z.lineTo(e,c);do if(!(10N*N+h*h)){var Y=l*N*N+m*N*h+p*h*h,ka=2*l*N*x+m*(N*f+h*x)+2*p*h*f+n*N+q*h,za=(l*x+m*f+n)*x+(p*f+q)*f+r,fa=dc(Y,ka,za);fa||(fa=[-.5*ka/Y,-2*za/ka]);if(0x*x+f*f)){k(a,b,N,h,d+1);k(N,h,e,c,d+1);return}}}while(0);z.quadraticCurveTo(v,g,e,c)}y.handleModifs(b,y.conicModifs);if(0!==y.lsize&&(y.preDrawCurve(),a=g.normalizeMax(a),g._helper.isAlmostReal(a))){b=C.toMat();a=g.mult(g.transpose(b), +a);a=g.mult(a,b);a=g.normalizeMax(a);var l=a.value[0].value[0].value.real,m=2*a.value[0].value[1].value.real,n=2*a.value[0].value[2].value.real,p=a.value[1].value[1].value.real,q=2*a.value[1].value[2].value.real,r=a.value[2].value[2].value.real,t=4*r*p-q*q,u=q*n-2*r*m,w=q*m-2*p*n,A=4*r*l-n*n,B=n*m-2*q*l,D=4*p*l-m*m,E=D;a=p*A+m*u+l*t-r*D;0>a&&(l=-l,m=-m,n=-n,p=-p,q=-q,r=-r,a=-a);a=y.lsize;var F=-a,G=-a,H=ma+a,I=pa+a,J=[],L=a={};if(h(d(F,G,I,0))&&h(f(I,F,H,1))&&h(d(H,I,G,1))&&h(f(G,H,F,0))&&L!==a){L.next= +a.next;a.next.prev=L;z.beginPath();if(0===J.length){var K=L;z.moveTo(K.x,K.y);do{var M=K.next;k(K.x,K.y,M.x,M.y,0);K=M}while(K!==L);z.closePath()}b=1===e(F,G)?0:1;if(4===J.length){var P=0;for(a=0;2>a;++a){K=J[a];M=J[a+2];var O=M.x-K.x;K=M.y-K.y;K=(l*O+m*K)*O+p*K*K;Math.abs(K)>Math.abs(P)&&(P=K)}if(isNaN(P))return;0<=P&&(b=1-b)}for(a=b;ad&&(d=e[f].value.length);-1===d?(e=e.map(function(a){return[a]}),d=1):e=e.map(function(a){return g.asList(a).value});var k=100,l=null,m=!0,n=C.drawingstate.textcolor;y.handleModifs(b,{size:!0,color:function(a){g._helper.isNumberVecN(a,3)&&(n=y.makeColor([a.value[0].value.real,a.value[1].value.real, +a.value[2].value.real]))},alpha:!0,bold:!0,italics:!0,family:!0,align:!0,x_offset:!0,y_offset:!0,offset:!0,width:function(a){"number"===a.ctype&&(k=a.value.real)},height:function(a){"number"===a.ctype&&(l=a.value.real)},border:function(a){"boolean"===a.ctype&&(m=a.value)}});f=C.drawingstate.textsize;null===f&&(f=Aa.textsize);null!==y.size&&(f=y.size);null===l&&(l=1.6*f);z.font=y.bold+y.italics+Math.round(10*f)/10+"px "+y.family;f=C.drawingstate.matrix;var p=d*k,q=a*l;b=c.x*f.a-c.y*f.b+f.tx+y.xOffset; +var r=c.x*f.c-c.y*f.d-f.ty-y.yOffset-q;if(m){y.preDrawCurve();z.strokeStyle=y.lineColor;z.beginPath();for(f=1;fh)!f&&n&&(z.stroke(),n=!1);else if(v||m){var N=l.real((a.value.real+b.value.real)/2);L.setvar(A,N);var Y=w(u),p=e(Y);if(v&&m&&p){var ka=g.value.real;m=Y.value.real;p=x.value.real;if(v=1>Math.abs(ka+p-2*m)/k){var q=l.real((a.value.real+N.value.real)/2);L.setvar(A,q);q=w(u);var za=l.real((N.value.real+b.value.real)/2);L.setvar(A,za);za=w(u);ka=Math.abs(ka+m-2*q.value.real)/k;m=Math.abs(m+p-2*za.value.real)/k;v=v&&1>ka&&1>m}v?(c(a,N,g,Y,h/2),c(N,b,Y,x,h/2)):(d(a,N,g,Y,h/2),d(N,b, +Y,x,h/2))}else d(a,N,g,Y,h/2),d(N,b,Y,x,h/2)}}var f=!1,k=.2/Yc,m=0,n=!1,p=-10,q=10,r=.1,t=1E3,u=a[0];if(null!==a[1]&&"variable"===a[1].ctype)var A=a[1].name;else a=E.plotvars(u),A="#",-1!==a.indexOf("t")&&(A="t"),-1!==a.indexOf("z")&&(A="z"),-1!==a.indexOf("y")&&(A="y"),-1!==a.indexOf("x")&&(A="x");L.newvar(A);var B=C.drawingstate.matrix;y.handleModifs(b,{color:!0,alpha:!0,size:!0,dashpattern:!0,dashtype:!0,dashing:!0,lineCap:!0,lineJoin:!0,miterLimit:!0,connect:function(a){"boolean"===a.ctype&&(f= +a.value)},start:function(a){"number"===a.ctype&&(p=a.value.real)},stop:function(a){"number"===a.ctype&&(q=a.value.real)},steps:function(a){"number"===a.ctype&&(t=a.value.real)}});z.strokeStyle=y.lineColor;z.lineWidth=y.lsize;n=!1;b=l.real(14.32);L.setvar(A,b);var D=w(u);if("number"!==D.ctype){if(g.isNumberVector(D).value&&2===D.value.length){n=!1;r=(q-p)/t;for(b=p;bp&&d(G,b,F,D,r),G=b,F=D;L.removevar(A);n&&z.stroke();return h};q.plotX$1=function(a,b){a=a[0];var e=E.plotvars(a);b="#";-1!==e.indexOf("t")&&(b="t");-1!==e.indexOf("z")&&(b="z");-1!==e.indexOf("y")&&(b="y");-1!==e.indexOf("x")&&(b="x");L.newvar(b);e=C.drawingstate.matrix;z.fillStyle=C.drawingstate.linecolor;z.lineWidth= +1;z.lineCap=y.lineCap;z.lineJoin=y.lineJoin;z.miterLimit=y.miterLimit;for(var c=!1,d=-10;10>d;d+=.01){L.setvar(b,l.real(d));var g=w(a);if("number"===g.ctype){var f=+g.value.real;g=d*e.a-f*e.b+e.tx;f=d*e.c-f*e.d-e.ty;c?z.lineTo(g,f):(z.beginPath(),z.moveTo(g,f),c=!0)}}z.stroke();L.removevar(b);return h};E.plotvars=function(a){function b(a,b){var e={},c;for(c=a.length-1;0<=c;--c)e[a[c]]=a[c];for(c=b.length-1;0<=c;--c)e[b[c]]=b[c];a=[];for(var d in e)e.hasOwnProperty(d)&&a.push(e[d]);return a}function c(a, +b){for(var e=0;eb||!Number.isInteger(b)?(c.video.aspectRatio=b,c.video.advanced[0].aspectRatio={min:b,max:b},c.video.advanced[1].aspectRatio={ideal:b}):(c.video.height=b,c.video.advanced[0].height={min:b,max:b},c.video.advanced[1].height={ideal:b})));a&&(c=[320,640,1024,1280,1920,2560],c=c.map(function(a){return{width:{min:a}}}),c={video:{width:16E3, +height:9E3,advanced:c},audio:!1});a=JSON.stringify(c);if(yd[a])return yd[a];b=null;var d=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia;d?b=function(a,b){navigator.mediaDevices.getUserMedia(c).then(a,b)}:(d=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia)&&(b=function(a,b){d.call(navigator,c,a,b)});if(!b)return console.warn("getUserMedia call not supported"),yd[a]=h;var f=document.createElement("video");f.autoplay=!0;yd[a]=G(f, +!0);console.log("Opening stream.");b(function(a){f.srcObject=a;f.setAttribute("autoplay","");f.setAttribute("muted","");f.setAttribute("playsinline","");f.play();f.addEventListener("loadeddata",F)},function(a){console.error("Could not get user video:",String(a),a)});return yd[a]};q.playvideo$1=function(a,b){a=Ya(D(a[0]));a.live&&a.img.play&&a.img.play();return h};q.pausevideo$1=function(a,b){a=Ya(D(a[0]));a.live&&a.img.pause&&a.img.pause();return h};var xd;q.imagergba$3=function(a,b){b=Ya(D(a[0])); +var e=D(a[1]);a=D(a[2]);if(!b||"number"!==e.ctype||"number"!==a.ctype||!b.ready)return h;e=Math.round(e.value.real);a=Math.round(a.value.real);if(!$a(e)||!$a(a))return h;a=Jb(b,e,a,1,1);return g.realVector([255*a[0],255*a[1],255*a[2],a[3]])};q.imagergb$3=q.imagergba$3;q.imagergba$4=function(a,b){var e=Ya(D(a[2]));if(!e||!e.ready)return h;var c=e.width,d=e.height,f=Q(a[0]),k=Q(a[1]),l=Q(g.realVector([0,d,1]));c=Q(g.realVector([c,d,1]));if(f===h||k===h||m===h)return h;m=g.ii;d=g.jj;l=E.basismap(l,c, +m,d);f=E.basismap(f,k,d,m);var m=Q(a[3]);d=E.extractPoint(u.mult(l,u.mult(g.adjoint3(f),m)));if(d.ok)if(a=e.width,f=e.height,k=!0,l=!1,void 0!==b.interpolate&&(m=w(b.interpolate),"boolean"===m.ctype&&(k=m.value)),void 0!==b.repeat&&(m=w(b.repeat),"boolean"===m.ctype&&(l=m.value)),k&&(d.x-=.5,d.y-=.5),l&&(d.x=(d.x%a+a)%a,d.y=(d.y%f+f)%f),m=Math.floor(d.x),c=Math.floor(d.y),$a(m)&&$a(c)){b=[0,0,0,0];if(k){k=d.x-m;d=d.y-c;var n=Jb(e,m,c,2,2);if(l){if(m===a-1||c===f-1){l=Jb(e,(m+1)%a,c,1,1);var p=Jb(e, +m,(c+1)%f,1,1);e=Jb(e,(m+1)%a,(c+1)%f,1,1);n=n.slice(0,4).concat(l,p,e)}}else{if(-1===m||m===a-1)k=Math.round(k);if(-1===c||c===f-1)d=Math.round(d)}for(e=0;4>e;e++)b[e]=(1-d)*((1-k)*n[e]+k*n[e+4])+d*((1-k)*n[e+8]+k*n[e+12])}else b=Jb(e,m,c,1,1);e=g.realVector(b)}else e=h;else e=h;return e};q.imagergb$4=function(a,b){a=q.imagergba$4(a,b);return a===h?h:g.turnIntoCSList(a.value.slice(0,3))};q.readpixels$1=function(a,b){a=Ya(D(a[0]));a=Jb(a,0,0,a.width,a.height);b=[];for(var e=0;e+3","\u2260"],lt:["<"],gt:[">"],le:["<=","\u2264","\u2266"],ge:[">=","\u2265","\u2267"],aeq:["~=","\u2248"], +ane:["~!=","\u2249"],alt:["~<","\u2a89"],agt:["~>","\u2a8a"],ale:["~<=","\u2a85"],age:["~>=","\u2a86"],"in":["\u2208"],nin:["\u2209"]},{and:["&","\u2227"],or:["%","\u2228"]},{rassoc:!0,prepend:["<:"]},{concat:["++","\u222a"],remove:["--","\u2216"],common:["~~","\u2229"],append:[":>"]},{rassoc:!0,assign:["="],define:[":="],undefine:[":=_"],bdefine:["::="]},{seq:[";"]},{modif:["->","\u2192"]},{rassoc:!0,list:[","]}],Ue=["+","-"],Qe=["!","\u221a"],Re=["\u00b0",":=_"],Se=[";",","],ue=[],Ua={},Xc;(function(){var a= +0;Ve.forEach(function(b){a+=2;var e=!!b.rassoc;b.functionCall&&(Xc=a);for(var c in b){var d=b[c];if("boolean"!==typeof d)for(var g={name:c,sym:d[0],symbols:d,rassoc:e,precedence:a,prefix:!1,postfix:!1,infix:!0,bare:!1},f=0;f &%C( / . $$!L! %5%;( D#!*!* 4'&*$W + !#&]F %6&]% !#% !#!(# & ! !#% # %1!#$ !/#L!S( @?$\u00817-!*''#$!$%+ ',6!:= !&!#7 \u0090 ##& ! ##D ##B ##& ! ##9 K ##^Y2*V#'$\u009d#5 4&p((+, #2*2*2, 5OC!'!Uy.D !&_)0J<#$,E'4Q/1Pv!|8:&K<9%)E>@7 )@\u0080# #$%1gT\u008e#'#=#'#( ! ! ! 0#P & !$ &$##'',& &d!9!*,b!'!#. !$$(! ! ! # 1##&$'!G%\u00a58 8 \u0084(#$%6= !&!#Q+!*/1& & & & & & & &t!\u0097%E$&%'V( z #&D${:Aj2\u0099\u00a6q\u00a9E\u00a4UZ#\u008d$2)%-8*0#_J+#b#M#(S1 # /0O2[R'$! !6>)/A?+8?G)-):9*\ud803!`KJ9J\ud804#PriL3>@7M$!6F2#/! !C* 3V& ! # 9 .+8N(#%#- & % $$!;!6$\ud805eF-% !\u008987#=F-!k7x4\ud806\u0087RB!\u0095K\ud808!\u00a2\ud809e\u008a\ud80d!8\ud811!\u009c\ud81a!\u009b+0c<;F*#BH&:\ud81b\u00a0U,!l,\ud82c!%\ud82f!\"&,$++.\ud835!w m %#!#%## ) ! & S ##( & > # $ !$& \u0091#3 3 0 3 0 3 0 3 0 3 (\ud83a!\u008b\ud83b\u0098# A % !#! . # ! !(!'! ! ! % !#! ! ! ! ! % !## & # # ! . 5& $ 5\ud869!\u009f7\u008c\ud86d!\u00a1,g\ud86e!<#\u00a3\ud873!\u009e\ud87e!\u009a", +"\ud80c\ud840-\ud868\ud86a-\ud86c\ud86f-\ud872"),fe=("#(?: [1-9])?|(?:'|"+Ac+")(?: (?:[0-9']|"+Ac+"))*").replace(/ /g,"[ \t]*"),Ke=["([ \t\n\r]+)|(//.*)|(/\\*)","("+("(?:[0-9](?: [0-9])*(?: \\.(?! \\.)(?:(?! "+fe+")|(?= (?: [Ee](?: [+-])?(?: [0-9])+)))(?: [0-9])*)?|\\.(?: [0-9])+)(?: [Ee](?: [+-])?(?: [0-9])+)?").replace(/ /g,"[ \t]*")+")","("+ue.map(jd).join("|")+")","("+"[](){}||".split("").map(jd).join("|")+")","("+xe+")","("+Te+")","("+fe+")",'("[^"]*")|($)'].join("|"),We=new RegExp("[ \t]*".replace(/\*$/, +"+"),"g"),ye="ANY WS COMMENT START_COMMENT NUM OP BRA SUB SUP ID STR EOF".split(" ");(function(){var a=(new RegExp(Ke,"g")).exec("");if(a.hasOwnProperty(ye.length))throw Error("RE has more groups than expected");if(!a.hasOwnProperty(ye.length-1))throw Error("RE has fewer groups than expected");})();$b.prototype.advanceBy=function(a){this.advanceTo(this.pos+a)};$b.prototype.advanceTo=function(a){for(this.pos=a;this.bols[0]<=a;)this.bol=this.bols.shift(),this.line++};$b.prototype.curPos=function(){return{row:this.line, +col:this.pos-this.bol,pos:this.pos}};$b.prototype.nextInternal=function(){var a=this.re.exec(this.input);if(a.index!==this.pos)throw xa("Invalid token",this.curPos(),this.input.substring(this.pos,a.index));var b=this.curPos();this.advanceBy(a[0].length);var c=this.curPos(),d;for(d=1;null==a[d];++d);return{start:b,end:c,raw:a[0],text:a[0].replace(We,""),toktype:ye[d]}};$b.prototype.next=function(){do{var a=this.nextInternal();if("START_COMMENT"===a.toktype){var b=/\*\/|\/\*/g;b.lastIndex=a.start.pos+ +2;for(var c=1,d;0a.length){for(var c=[],d=0,g=0;da.length&&(g=0),c[d]=a[g];a=c}b=new Float32Array(a);a=e.createBuffer(1,b.length,e.sampleRate);a.copyToChannel(b,0);e=e.createBufferSource();e.buffer=a;return e},createMonoOscillator:function(a,b){var e=this.getAudioContext().createOscillator();if(0!==b){var c=new Float32Array(2),d=new Float32Array(2);c[1]=Math.sin(b);d[1]=Math.cos(b);b=this.getAudioContext().createPeriodicWave(c,d,{disableNormalization:!0});e.setPeriodicWave(b)}else e.type="sine";e.mono=!0;e.frequency.value=a;return e},createWaveOscillator:function(a, +b,c){for(var e=this.getAudioContext().createOscillator(),d=new Float32Array(b.length+1),g=new Float32Array(b.length+1),f=0;fMath.abs(a-1)});0this.damp&&this.masterGain.gain.setTargetAtTime(1, +this.audioCtx.currentTime+this.attack,-this.damp)};tb.prototype.startOscillators=function(){if(this.precompute)this.oscNodes[0]=M.playOscillator(M.createWaveOscillator(this.freq,this.harmonics,this.phaseshift),this.masterGain,1,this.attack,this.duration,this.release);else for(var a=0;ab.value.real||b.value.real!==Math.floor(b.value.real))return aa.root(a,b);for(var e=a,c=1;c=y.psize&&(y.psize=0);0>=y.lsize&&(y.lsize=0);y.overhang=1;y.dashing=!1;y.isArrow=!1;y.arrowSides="==>";y.arrowposition=1;y.headlen=10;y.arrowShape=y.arrowShapes.line;y.alpha=C.drawingstate.alpha;y.fillalpha=0;y.bold="";y.italics="";y.family="sans-serif";y.align=0;y.angle=0;y.xOffset=0;y.yOffset=0;y.lineCap="round";y.lineJoin="round";y.miterLimit=10;y.noborder=!1;var e,c;for(e in a){var d=a[e];d&&((c=b[e])?(!0===c&&(c=y.modifHandlers[e]),c(w(d))):console.log("Modifier not supported: "+ +e))}null!==y.size?y.psize=y.lsize=y.size:(y.psize=C.drawingstate.pointsize,y.lsize=C.drawingstate.linesize);y.dashing&&y.dashing(y.lsize);null!==y.colorraw?y.pointColor=y.lineColor=y.textColor=y.makeColor(y.colorraw):1===y.alpha?(y.pointColor=C.drawingstate.pointcolor,y.lineColor=C.drawingstate.linecolor,y.textColor=C.drawingstate.textcolor):(y.pointColor=y.makeColor(C.drawingstate.pointcolorraw),y.lineColor=y.makeColor(C.drawingstate.linecolorraw),y.textColor=y.makeColor(C.drawingstate.textcolorraw)); +y.black=1===y.alpha?"rgb(0,0,0)":"rgba(0,0,0,"+y.alpha+")";y.fillColor=y.fillcolorraw&&0y.size&&(y.size=0),1E3"!==a.value&&"<==>"!==a.value&&"<=="!==a.value?console.error("arrowsides is unknows"):(y.arrowSides=a.value,y.isArrow= +!0)},arrowposition:function(a){"number"!==a.ctype?console.error("arrowposition is not of type number"):0>a.value.real?console.error("arrowposition has to be positive"):1a.value.real?console.error("arrowsize has to be positive"):y.headlen*=a.value.real},bold:function(a){"boolean"===a.ctype&& +a.value&&(y.bold="bold ")},italics:function(a){"boolean"===a.ctype&&a.value&&(y.italics="italic ")},family:function(a){"string"===a.ctype&&(y.family=a.value)},align:function(a){"string"===a.ctype&&(a=a.value,"left"===a&&(y.align=0),"right"===a&&(y.align=1),"mid"===a||"center"===a)&&(y.align=.5)},angle:function(a){"number"===a.ctype&&(y.angle=a.value.real)},x_offset:function(a){"number"===a.ctype&&(y.xOffset=a.value.real)},y_offset:function(a){"number"===a.ctype&&(y.yOffset=a.value.real)},offset:function(a){"list"=== +a.ctype&&2===a.value.length&&"number"===a.value[0].ctype&&"number"===a.value[1].ctype&&(y.xOffset=a.value[0].value.real,y.yOffset=a.value[1].value.real)},lineCap:function(a){"string"!==a.ctype||"round"!==a.value&&"square"!==a.value&&"butt"!==a.value||(y.lineCap=a.value)},lineJoin:function(a){"string"!==a.ctype||"round"!==a.value&&"bevel"!==a.value&&"miter"!==a.value||(y.lineJoin=a.value)},fillrule:function(a){"string"!==a.ctype||"nonzero"!==a.value&&"evenodd"!==a.value||(y.fillrule=a.value)},miterLimit:function(a){"number"=== +a.ctype&&0h&&(g=a);1e&&(d=a);1b||b>ma||0>c||c>pa||0>a||a>ma||0>k||k>pa){k=y.clipSegment({x:b,y:c},{x:a,y:k});if(2!==k.length||.01>y.lsize)return;b=k[0].x;c=k[0].y;a=k[1].x;k=k[1].y}y.preDrawCurve();if(!y.isArrow||d===g&&f===h).01>y.lsize||(z.beginPath(),z.moveTo(b,c),z.lineTo(a, +k),z.stroke());else{d=f-d;g=h-g;f=y.headlen/Math.sqrt(d*d+g*g);var m=d*f,n=g*f;h=y.arrowposition;l=1-h;d=h*b+l*a;g=h*c+l*k;f=h*a+l*b;h=h*k+l*c;l=y.arrowSides;z.beginPath();y.arrowShape.close?("<==>"===l||"<=="===l?(1>y.arrowposition&&(z.moveTo(b,c),z.lineTo(d,g)),z.moveTo(d+m,g+n)):z.moveTo(b,c),"==>"===l||"<==>"===l?(z.lineTo(f-m,h-n),1>y.arrowposition&&(z.moveTo(f,h),z.lineTo(a,k))):z.lineTo(a,k)):(z.moveTo(b,c),z.lineTo(a,k));z.stroke();"==>"!==l&&"<==>"!==l||e(f,h,1,y.arrowShape.ratio);"<=="!== +l&&"<==>"!==l||e(d,g,-1,-y.arrowShape.ratio)}};y.drawpoint=function(a){var b=C.drawingstate.matrix,c=a.x*b.a-a.y*b.b+b.tx;a=a.x*b.c-a.y*b.d-b.ty;z.lineWidth=.3*y.psize;z.beginPath();z.arc(c,a,y.psize,0,2*Math.PI);z.fillStyle=y.pointColor;z.fill();y.noborder||(z.beginPath(),z.arc(c,a,1.15*y.psize,0,2*Math.PI),z.fillStyle=y.black,z.strokeStyle=y.black,z.stroke())};y.clipLineCore=function(a,b,c){var e=Math.SQRT1_2*y.lsize,d=0-e,g=ma+e,f=0-e;e=pa+e;var h=0>d*a+f*b+c,k=0>g*a+f*b+c,l=0>d*a+e*b+c,x=0>g* +a+e*b+c,m=[];h!==k&&m.push({x:(-c-b*f)/a,y:f});k!==x&&m.push({x:g,y:(-c-a*g)/b});l!==x&&m.push({x:(-c-b*e)/a,y:e});h!==l&&m.push({x:d,y:(-c-a*d)/b});return m};y.clipLine=function(a){a=g.normalizeMax(g.productVM(a,C.toMat()));return y.clipLineCore(a.value[0].value.real,a.value[1].value.real,a.value[2].value.real)};y.drawline=function(a){g._helper.isAlmostReal(a)&&(a=y.clipLine(a),2===a.length&&.01<=y.lsize&&(y.preDrawCurve(),z.beginPath(),z.moveTo(a[0].x,a[0].y),z.lineTo(a[1].x,a[1].y),z.stroke()))}; +y.drawRaySegment=function(a,b){a=E.extractPoint(a);b=E.extractPoint(b);if(a.ok&&b.ok){var e=a.x-b.x,c=a.y-b.y,d=25E3/C.drawingstate.matrix.sdet/Math.sqrt(e*e+c*c);e*=d;c*=d;y.drawsegcore(a,{x:a.x+e,y:a.y+c});y.drawsegcore(b,{x:b.x-e,y:b.y-c})}};y.dashTypes={solid:[],dashed:[10,10],tightdash:[10,4],dotted:[1,3],dashdot:[10,5,1,5],"dashvalue.solid":[],"dashvalue.dashed":[10,10],"dashvalue.tightdash":[10,4],"dashvalue.dotted":[1,3],"dashvalue.dashdot":[10,5,1,5],0:[],1:[10,10],2:[10,4],3:[1,3],4:[10, +5,1,5]};y.setDash=function(a,b){b=Math.sqrt(b);a=a.slice();for(var e=0;e=2*Math.PI?this._pathcmd(this._path.length?"L":"M",e,h,"A",c,c,0,0,f?1:0,a-c*Math.cos(d),b-c*Math.sin(d),"A",c,c,0,0,f?1:0,e,h):this._pathcmd(this._path.length?"L":"M",e,h,"A",c,c,0,g>Math.PI?1:0,f?1:0,k,l)},rect:function(a,b,c,d){this._pathcmd("M",a,b,"h",c,"v",d,"h",-c,"z")},_cmd:function(a){1!==this.globalAlpha?(this._body.push(''),this._body.push(a),this._body.push("")):this._body.push(a)},_attrs:function(a){var b="",c;for(c in a)null!== +a[c]&&(b+=" "+c+'="'+a[c]+'"');return b},fill:function(){this._cmd("")},stroke:function(){this._cmd("")},clip:function(){++this._clipIndex;this._body.push('','');this._saveStack[this._saveStack.length-1]+=""},save:function(){this._saveStack.push("")},restore:function(){this._body.push(this._saveStack.pop());0===this._saveStack.length&&this._saveStack.push("")},_transform:function(a){this._body.push('');this._saveStack[this._saveStack.length-1]+=""},translate:function(a,b){this._transform("translate("+a+" "+b+")")}, +rotate:function(a){this._transform("rotate("+Math.PI/180*a+")")},scale:function(a,b){this._transform("scale("+a+" "+b+")")},transform:function(a,b,c,d,g,f){this._transform("matrix("+[a,b,c,d,g,f].join(" ")+")")},drawImage:function(a,b,c){if(3!==arguments.length)throw Error("SvgWriterContext only supports 3-argument version of drawImage");var e=this._imgcache.indexOf(a);if(-1===e){e=this._imgcache.length;var d=a.cachedDataURL?a.cachedDataURL:Kd(a);this._defs.push('');this._imgcache.push(a)}this._cmd('')},toBlob:function(){for(;1\n'+this._defs.join("\n")+'\n\n\n'+ +this._body.join("\n")+"\n\n\n";return new Blob([a],{type:"image/svg+xml"})}};Kb.prototype={_cmd:function(){this._body.push(Array.prototype.join.call(arguments," "))},_setAlpha:function(a,b,c){var e=Math.round(255*a*this._globalAlpha);b+=e;this._extGState[b]="<< /"+c+" "+e/255+" >>";this._cmd("/"+b,"gs");return a},set globalAlpha(a){this._globalAlpha=a;this._setAlpha(this._strokeAlpha,"As","CA");this._setAlpha(this._fillAlpha,"Af","ca")},set fillStyle(a){var b=this;tc(a,function(a,e,c,d){b._cmd(a/ +255,e/255,c/255,"rg");b._setAlpha(b._fillAlpha=d,"Af","ca")})},set strokeStyle(a){var b=this;tc(a,function(a,e,c,d){b._cmd(a/255,e/255,c/255,"RG");b._setAlpha(b._strokeAlpha=d,"As","CA")})},set lineWidth(a){this._cmd(a,"w")},set lineCap(a){this._cmd({butt:0,round:1,square:2}[a],"J")},set lineJoin(a){this._cmd({miter:0,round:1,bevel:2}[a],"j")},set miterLimit(a){this._cmd(a,"M")},clearRect:function(){},beginPath:function(){this._pathUsed=!1},closePath:function(){this._cmd("h")},moveTo:function(a,b){this._cmd(this._xPos= +a,this._yPos=-b,"m")},lineTo:function(a,b){this._cmd(this._xPos=a,this._yPos=-b,"l")},bezierCurveTo:function(a,b,c,d,g,f){this._cmd(a,-b,c,-d,this._xPos=g,this._yPos=-f,"c")},quadraticCurveTo:function(a,b,c,d){this.bezierCurveTo((2*a+this._xPos)/3,(2*b-this._yPos)/3,(c+2*a)/3,(d+2*b)/3,c,d)},_kappa:.5522847498307935,arc:function(a,b,c,d,g,f){if(0===d&&g===2*Math.PI)d=this._kappa*c,this.moveTo(a+c,b),this.bezierCurveTo(a+c,b+d,a+d,b+c,a,b+c),this.bezierCurveTo(a-d,b+c,a-c,b+d,a-c,b),this.bezierCurveTo(a- +c,b-d,a-d,b-c,a,b-c),this.bezierCurveTo(a+d,b-c,a+c,b-d,a+c,b);else throw Error("PdfWriterContext.arc only supports full circles");},rect:function(a,b,c,d){this._cmd(a,-b,c,-d,"re")},_usePath:function(a){if(this._pathUsed){var b=this._body[this._pathUsed],c={"S + f":"B","f + S":"B","W n + S":"W S","W n + f":"W f","S + W n":"W S","f + W n":"W f","B + W n":"W B","W S + f":"W B","W f + S":"W B"}[b+" + "+a];if(!c)throw Error("Don't know how to combine '"+b+"' and '"+a+"'");this._body.splice(this._pathUsed, +1);a=c}this._pathUsed=this._body.length;this._cmd(a)},fill:function(){this._usePath("f")},stroke:function(){this._usePath("S")},clip:function(){this._usePath("W n")},save:function(){this._cmd("q")},restore:function(){this._cmd("Q")},translate:function(a,b){this.transform(1,0,0,1,a,b)},rotate:function(a){var b=Math.cos(a);a=Math.sin(a);this.transform(b,a,-a,b,0,0)},scale:function(a,b){this.transform(a,0,0,b,0,0)},transform:function(a,b,c,d,g,f){this._cmd(a,-b,-c,d,g,-f,"cm")},_png:function(a){if("data:image/png;base64,"!== +a.substr(0,22))return{error:"Not a base64-encoded PNG file"};a=me(a.substr(22));var b=ne(a);console.log("PNG chunks:",b.map(function(a){return a.type}));if("IHDR"!==b[0].type)throw Error("Image does not start with an IHDR");var c=b[0].data;a=(c[0]<<24|c[1]<<16|c[2]<<8|c[3])>>>0;var d=(c[4]<<24|c[5]<<16|c[6]<<8|c[7])>>>0,g=c[8],f=c[9],h=0===(f&2),k=0!==(f&4),l=c[10],m=c[11];c=c[12];if(0!==l)throw Error("Unsupported PNG compression method: "+l);if(0!==m)throw Error("Unsupported PNG filter method: "+ +m);if(0!==c)return{error:"Interlaced image not supported"};if(0!==(f&1))return{error:"Indexed PNG image not supported"};m=null;f=h?1:3;l=b.filter(function(a){return"IDAT"===a.type}).map(function(a){return a.data});if(k){k=window.pako;m=new k.Inflate;for(b=0;b>>3;if(m.length!==d*(a*(f+1)*c+1))throw Error("Data length mismatch");var n=f*c;l=new Uint8Array(d*(a*n+1));for(var p=new Uint8Array(d*(a*c+1)),q=0,r=0,t=0,u= +0;u>"},_obj:function(a,b){b||(b=this._nextIndex++);Array.isArray(a)||(a=[this._dict(a)]); +a.index=b;a.ref=b+" 0 R";a.offset=this._offset;var e=0;a.unshift(b+" 0 obj\n");a.push("\nendobj\n");for(b=0;b("number"===typeof h.narrow?h.narrow:20)/k)continue}else if("C"===h.kind){m=g.normalizeZ(r.csnames[h.args[0]].homog);n=h.radius;if(!g._helper.isAlmostReal(m)|| +!l._helper.isAlmostReal(n))continue;p=m.value[0].value.real;var q=m.value[1].value.real;m=a.x-p;var t=a.y-q,u=Math.sqrt(m*m+t*t);if(0===u)continue;q+=t/u*n.value.real;n=p+m/u*n.value.real-a.x;m=q-a.y;p=Math.sqrt(n*n+m*m);p+=30/k;if(h.narrow&&p>(("number"===typeof h.narrow?h.narrow:20)+30)/k)continue}else if("L"===h.kind)n=h.homog,p=l,m=p.add(p.mult(n.value[0],p.conjugate(n.value[0])),p.mult(n.value[1],p.conjugate(n.value[1]))),m=g.scaldiv(p.sqrt(m),n),p=m.value[0].value.real*a.x+m.value[1].value.real* +a.y+m.value[2].value.real,n=-m.value[0].value.real*p,m=-m.value[1].value.real*p,0>p&&(p=-p),p+=25/k;else if("Text"===h.kind){if(!h.homog||h.dock||!h._bbox)continue;m=C.from(a.x,a.y,1);n=Math.max(0,m[0]-h._bbox.right,h._bbox.left-m[0]);m=Math.max(0,m[1]-h._bbox.bottom,h._bbox.top-m[1]);p=Math.sqrt(n*n+m*m);if(20Math.abs(b)&&console.log("PSLQ: inverting singular matrix!");this._e=a.map(function(a){return a/b});return this};Fa.prototype.swRow=function(a,b){for(var e=0;9>e;)this.exchange(e+a,e+b),e+=3};Fa.prototype.swCol=function(a,b){for(var e=0;3>e;++e)this.exchange(3*a+e,3*b+e)};Fa.mult=function(a, +b,c){a=[a.get(0)*b.get(0)+a.get(3)*b.get(1)+a.get(6)*b.get(2),a.get(1)*b.get(0)+a.get(4)*b.get(1)+a.get(7)*b.get(2),a.get(2)*b.get(0)+a.get(5)*b.get(1)+a.get(8)*b.get(2),a.get(0)*b.get(3)+a.get(3)*b.get(4)+a.get(6)*b.get(5),a.get(1)*b.get(3)+a.get(4)*b.get(4)+a.get(7)*b.get(5),a.get(2)*b.get(3)+a.get(5)*b.get(4)+a.get(8)*b.get(5),a.get(0)*b.get(6)+a.get(3)*b.get(7)+a.get(6)*b.get(8),a.get(1)*b.get(6)+a.get(4)*b.get(7)+a.get(7)*b.get(8),a.get(2)*b.get(6)+a.get(5)*b.get(7)+a.get(8)*b.get(8)];c.set(a)}; +Fa.prototype.getString=function(){var a=this._e;return"/"+a[0]+"\t "+a[3]+"\t "+a[6]+"\\\n|"+a[1]+"\t "+a[4]+"\t "+a[7]+"|\n\\"+a[2]+"\t "+a[5]+"\t "+a[8]+"/\n"};Fa.prototype.transpose=function(){this.exchange(1,3);this.exchange(2,6);this.exchange(5,7);return this};Fa.VMmult=function(a,b,c){c[0]=b.get(0)*a[0]+b.get(1)*a[1]+b.get(2)*a[2];c[1]=b.get(3)*a[0]+b.get(4)*a[1]+b.get(5)*a[2];c[2]=b.get(6)*a[0]+b.get(7)*a[1]+b.get(8)*a[2]};var kb=function(){};kb.dot=function(a,b){for(var e=0,c=0;ca[b]&&(b=c);return b};kb.hermiteReduce=function(a){for(var b=[[1,0,0],[0,1,0],[0,0,1]],c=a.length,d=a.map(function(a){return[].concat($jscomp.arrayFromIterable(a))}),g,f=1;fc;c++)a[c]=d[c];return new Fa(b)};kb.doPSLQ= +function(a,b){for(var e=a.length,c=[],d=[],g=0;gk?-c[h]*c[k]/d[k]/d[k+1]:h===k?d[h+1]/d[h]:0;h=kb.hermiteReduce(f);k=h.clone().inverse().transpose();Fa.VMmult(c,k,c);Fa.mult(h,g,g);Fa.mult(a,k,a);for(d=0;d +Math.pow(this.GAMMA,1)*Math.abs(k[0])&&(h=1);var l=k=0,m=0;hp;p++)n[p]=[];if(hl.sub(l.mult(a.value[0],c.value[1]),l.mult(a.value[1],c.value[0])).value.real&&(b=g.neg(b));return g.turnIntoCSList([b.value[1], +l.neg(b.value[0]),l.zero])};m.PointOnCircle.parameterPath=function(a,b,c,d,f){d=g.normalizeAbs(d);f=g.normalizeAbs(f);var e=g.scalproduct(d,f);if(0<=e.value.real)return Wd(a,b,c,d,f);a=g.turnIntoCSList([l.sub(d.value[1],f.value[1]),l.sub(f.value[0],d.value[0]),l.zero]);e=g.scalproduct(d,a);0>e.value.real&&(a=g.neg(a));0>b?(b=2*b+1,c=b*b,e=.25/(1+c),c=l.complex(2*b*e+.25,(1-c)*e)):(b=2*b-1,c=b*b,e=.25/(1+c),c=l.complex(2*b*e+.75,(1-c)*e));var h=l.sub(l.real(1),c);b=l.mult(c,c);e=l.mult(h,h);c=l.mult(c, +h);d=g.scalmult(e,d);d=g.add(d,g.scalmult(c,a));return d=g.add(d,g.scalmult(b,f))};m.PointOnCircle.updatePosition=function(a){var b=ha(3);ea(b);var c=r.csnames[a.args[0]];b=g.productMV(c.matrix,b);c=m._helper.IntersectLC(b,c.matrix);c=mb(c[0],c[1]);b=g.normalizeMax(c.value[0]);a.homog=u.withUsage(b,"Point");a.antipodalPoint=c.value[1]};m.PointOnCircle.getRandomMove=m._helper.getRandPointMove;m.PointOnCircle.stateSize=6+mb.stateSize;m.PointOnCircle.get_angle=function(a){var b=m._helper.CenterOfCircle(r.csnames[a.args[0]].matrix), +c=g._helper.isAlmostFarpoint;if(c(a.homog)||c(b))return h;a=g.normalizeZ(a.homog);b=g.normalizeZ(b);b=g.sub(a,b);b=l.arctan2(b.value[0],b.value[1]);a=l.real(Hc);b=l.mod(l.add(b,a),a);return u.withUsage(b,"Angle")};m.PointOnCircle.set_angle=function(a,b){if("number"===b.ctype){var e=r.csnames[a.args[0]],c=m._helper.CenterOfCircle(e.matrix);if(!g._helper.isAlmostFarpoint(c)){c=g.normalizeZ(c);var d=l.cos(b);b=l.sin(b);e=g.turnIntoCSList([l.mult(d,e.radius),l.mult(b,e.radius),l.real(0)]);Ta(a,g.add(c, +e),"homog")}}return h};m.OtherPointOnCircle={};m.OtherPointOnCircle.kind="P";m.OtherPointOnCircle.signature=["P"];m.OtherPointOnCircle.signatureConstraints=function(a){return"PointOnCircle"===r.csnames[a.args[0]].type};m.OtherPointOnCircle.updatePosition=function(a){var b=r.csnames[a.args[0]].antipodalPoint;b=g.normalizeMax(b);a.homog=u.withUsage(b,"Point")};m.PointOnSegment={};m.PointOnSegment.kind="P";m.PointOnSegment.signature=["S"];m.PointOnSegment.isMovable=!0;m.PointOnSegment.initialize=function(a){var b= +m._helper.initializePoint(a);a=m.PointOnSegment.getParamForInput(a,b);wb(a)};m.PointOnSegment.getParamForInput=function(a,b,c){a=r.csnames[a.args[0]];var e=a.homog;"mouse"===c&&Cc&&0!==Va&&(b=m._helper.snapPointToLine(b,e));c=g.turnIntoCSList([e.value[0],e.value[1],l.zero]);e=g.sub(a.startpos,a.endpos);b=g.crossratio3(e,a.startpos,a.endpos,b,c);0>b.value.real&&(b=l.complex(0,b.value.imag));1a.value.real&&(b=-1>a.value.real?g.realVector([1,0]):g.realVector([0,1]));return b};m.PointOnArc.getParamFromState=function(a){return ha(2)};m.PointOnArc.putParamToState=function(a,b){ea(b)};m.PointOnArc.updatePosition=function(a){var b=r.csnames[a.args[0]],c=b.startPoint,d=b.viaPoint,f=b.endPoint,h=g.ii,k=g.cross(c,h);d=g.cross(d,h);var n=g.cross(f,h);n=g.turnIntoCSList([k,n]);k=g.transpose(n);n=g.conjugate(n);k=g.productMM(n,k);d=g.productMV(n, +d);k=g.productMV(g.adjoint2(k),d);d=k.value[0];k=k.value[1];n=ha(2);ea(n);c=g.normalizeMax(g.add(g.scalmult(l.mult(d,n.value[0]),c),g.scalmult(l.mult(k,n.value[1]),f)));b=m._helper.conicOtherIntersection(b.matrix,h,c);a.homog=u.withUsage(b,"Point")};m.PointOnArc.getRandomMove=m._helper.getRandPointMove;m.PointOnArc.stateSize=4;m._helper.CenterOfCircle=function(a){return g.turnIntoCSList([a.value[2].value[0],a.value[2].value[1],l.neg(a.value[0].value[0])])};m._helper.CenterOfConic=function(a){a=g.adjoint3(a); +return{ctype:"list",value:[a.value[2].value[0],a.value[2].value[1],a.value[2].value[2]]}};m.CenterOfConic={};m.CenterOfConic.kind="P";m.CenterOfConic.signature=["C"];m.CenterOfConic.updatePosition=function(a){var b=m._helper.CenterOfConic(r.csnames[a.args[0]].matrix);a.homog=b;a.homog=g.normalizeMax(a.homog);a.homog=u.withUsage(a.homog,"Point")};m._helper.CircleMP=function(a,b){var e=a.value[0],c=a.value[1];a=l.neg(a.value[2]);var d=l.zero;e=g.turnIntoCSList([g.turnIntoCSList([a,d,e]),g.turnIntoCSList([d, +a,c]),g.turnIntoCSList([e,c,d])]);c=u.mult(u.mult(b,e),b);b=u.mult(u.mult(b,g.fund),b);c=u.mult(c,g.fund);b=u.mult(b,e);return g.sub(c,b)};m.CircleMP={};m.CircleMP.kind="C";m.CircleMP.signature=["P","P"];m.CircleMP.updatePosition=function(a){a.matrix=m._helper.CircleMP(r.csnames[a.args[0]].homog,r.csnames[a.args[1]].homog);a.matrix=g.normalizeMax(a.matrix);a.matrix=u.withUsage(a.matrix,"Circle")};m.CircleMr={};m.CircleMr.kind="C";m.CircleMr.signature=["P"];m.CircleMr.isMovable=!0;m.CircleMr.initialize= +function(a){wb(l.real(a.radius))};m.CircleMr.getParamForInput=function(a,b,c){if("radius"===c)return b;a=r.csnames[a.args[0]].homog;a=g.normalizeZ(a);b=g.normalizeZ(b);b=g.sub(a,b);return b=g.abs(b)};m.CircleMr.getParamFromState=function(a){return hc()};m.CircleMr.putParamToState=function(a,b){wb(b)};m.CircleMr.updatePosition=function(a){var b=hc();wb(b);var c=r.csnames[a.args[0]].homog,d=l.mult(c.value[2],b);d=l.mult(d,d);if(!l._helper.isFinite(d)&&!l._helper.isNaN(d))return g.fund;c=m._helper.ScaledCircleMrr(c, +d);a.matrix=u.withUsage(c,"Circle");a.radius=b};m.CircleMr.getRandomMove=function(a){a=a.radius;return{type:"radius",value:l.abs(a).value.reall.abs(g.det(a)).value.real)return"degenerate";var b=l.mult(a.value[0].value[0],a.value[1].value[1]);b=l.sub(b,l.pow(a.value[0].value[1],l.real(2)));b=b.value.real;return 1E-16>Math.abs(b)?"parabola":1E-16a;++a)for(var e=0;e<=a;++e)wb(b.value[a].value[e])};m.FreeConic.updatePosition=function(a){var b=ha(6);ea(b);a.matrix=m._helper.buildConicMatrix(b.value);a.matrix=g.normalizeMax(a.matrix);a.matrix=u.withUsage(a.matrix,"Conic")};m.FreeConic.set_matrix=function(a,b){g._helper.isNumberMatrixMN(b,3,3)&&Ta(a,g.add(b,g.transpose(b)),"matrix")};m.FreeConic.stateSize=12;m._helper.buildConicMatrix=function(a){var b=a[1],c=a[2],d=a[3],f=a[4],h=a[5];return g.turnIntoCSList([g.turnIntoCSList([a[0], +b,d]),g.turnIntoCSList([b,c,f]),g.turnIntoCSList([d,f,h])])};m._helper.flattenConicMatrix=function(a){return g.turnIntoCSList([a.value[0].value[0],a.value[0].value[1],a.value[1].value[1],a.value[0].value[2],a.value[1].value[2],a.value[2].value[2]])};m._helper.splitDegenConic=function(a){var b=g.adjoint3(a),c=0,d,f=l.abs2(b.value[0].value[0]).value.real;for(d=1;3>d;d++){var h=l.abs2(b.value[d].value[d]).value.real;h>f&&(c=d,f=h)}d=l.sqrt(l.mult(l.real(-1),b.value[c].value[c]));if(1E-16>l.abs2(d).value.real)return a= +g.turnIntoCSList([l.zero,l.zero,l.zero]),[a,a];c=l.real(c+1);h=g.column(b,c);h=g.scaldiv(d,h);d=h.value[0];f=h.value[1];h=h.value[2];d=g.turnIntoCSList([g.turnIntoCSList([l.real(0),h,l.mult(l.real(-1),f)]),g.turnIntoCSList([l.mult(l.real(-1),h),l.real(0),d]),g.turnIntoCSList([f,l.mult(l.real(-1),d),l.real(0)])]);a=g.add(a,d);var k=0;for(d=f=b=0;3>d;d++)for(c=0;3>c;c++)h=l.abs2(a.value[d].value[c]).value.real,h>f&&(k=d,b=c,f=h);d=a.value[k];a=g.transpose(a);a=a.value[b];d=g.normalizeMax(d);a=g.normalizeMax(a); +d=u.withUsage(d,"Line");a=u.withUsage(a,"Line");return[d,a]};m._helper.inputConic=function(a){var b="xx xy yy xz yz zz".split(" ").map(function(b){var e=l._helper.input(a[b]);b[0]!==b[1]&&(e=l.realmult(.5,e));return e});return m._helper.buildConicMatrix(b)};m.SelectConic={};m.SelectConic.kind="C";m.SelectConic.signature=["Cs"];m.SelectConic.initialize=function(a){if(void 0!==a.index)return a.index-1;var b=m._helper.inputConic(a.pos);a=r.csnames[a.args[0]].results;for(var c=g.conicDist(b,a[0]),d=0, +f=1;fx;++x){var p=(x&2)-1,q=d(l.real(((x&1)<<1)-1),m),r=d(l.real(p),n),t=e(f,q,h,r),u=e(b,r,a,q);p=e(a,f,b,h);var N=l.add(l.add(e(b,h,a,f),e(h,r,f,q)),e(r,b,q,a));q=d(t,t);r=d(u,u);var w=d(N,N),y=d(t,u);t=d(t,N);u=d(u,N);y=l.sub(y,d(l.real(.5),d(p,p)));p=g.turnIntoCSList([g.turnIntoCSList([q,y,t]),g.turnIntoCSList([y,r,u]),g.turnIntoCSList([t,u,w])]);p=g.productMM(k,g.productMM(p,c));p=g.turnIntoCSList([p.value[0].value[0], +p.value[0].value[1],p.value[0].value[2],p.value[1].value[1],p.value[1].value[2],p.value[2].value[2]]);v[x]=p}return v};m.ConicBy3p2l={};m.ConicBy3p2l.kind="Cs";m.ConicBy3p2l.signature=["P","P","P","L","L"];m.ConicBy3p2l.updatePosition=function(a){var b=m._helper.ConicBy3p2l(r.csnames[a.args[0]].homog,r.csnames[a.args[1]].homog,r.csnames[a.args[2]].homog,r.csnames[a.args[3]].homog,r.csnames[a.args[4]].homog);b=be(b);for(var c=Array(4),d=0;4>d;++d){var f=b[d].value;c[d]=g.turnIntoCSList([g.turnIntoCSList([f[0], +f[1],f[2]]),g.turnIntoCSList([f[1],f[3],f[4]]),g.turnIntoCSList([f[2],f[4],f[5]])])}a.results=c};m.ConicBy3p2l.stateSize=48;m.ConicBy2p3l={};m.ConicBy2p3l.kind="Cs";m.ConicBy2p3l.signature=["P","P","L","L","L"];m.ConicBy2p3l.updatePosition=function(a){var b=m._helper.ConicBy3p2l(r.csnames[a.args[2]].homog,r.csnames[a.args[3]].homog,r.csnames[a.args[4]].homog,r.csnames[a.args[0]].homog,r.csnames[a.args[1]].homog);b=be(b);for(var c=Array(4),d=0;4>d;++d){var f=b[d].value;f=g.turnIntoCSList([g.turnIntoCSList([f[0], +f[1],f[2]]),g.turnIntoCSList([f[1],f[3],f[4]]),g.turnIntoCSList([f[2],f[4],f[5]])]);c[d]=g.normalizeMax(g.adjoint3(f))}a.results=c};m.ConicBy2p3l.stateSize=48;m.ConicBy1p4l={};m.ConicBy1p4l.kind="Cs";m.ConicBy1p4l.signature=["P","L","L","L","L"];m.ConicBy1p4l.updatePosition=function(a){var b=m._helper.ConicBy4p1l(a,r.csnames[a.args[1]].homog,r.csnames[a.args[2]].homog,r.csnames[a.args[3]].homog,r.csnames[a.args[4]].homog,r.csnames[a.args[0]].homog),c=b[0];b=b[1];c=g.adjoint3(c);b=g.adjoint3(b);b= +[c,b];a.results=b};m.ConicBy1p4l.stateSize=mb.stateSize;m.ConicParabolaPL={};m.ConicParabolaPL.kind="C";m.ConicParabolaPL.signature=["P","L"];m.ConicParabolaPL.updatePosition=function(a){var b=r.csnames[a.args[0]].homog.value,c=r.csnames[a.args[1]].homog.value,d=l.mult,f=l.neg,h=l.add,k=l.sub,n=b[0],p=b[1],q=b[2],t=c[0];b=c[1];c=c[2];var w=d(q,q),y=d(t,t),z=d(b,b),A=d(q,c),B=f(q);q=h(y,z);z=d(w,z);y=d(w,y);f=d(f(w),d(t,b));t=d(B,h(d(n,q),d(A,t)));b=d(B,h(d(p,q),d(A,b)));d=k(d(h(d(n,n),d(p,p)),q), +d(w,d(c,c)));d=m._helper.buildConicMatrix([z,f,y,t,b,d]);d=g.normalizeMax(d);a.matrix=u.withUsage(d,"Conic")};m.ConicBy2Foci1P={};m.ConicBy2Foci1P.kind="Cs";m.ConicBy2Foci1P.signature=["P","P","P"];m.ConicBy2Foci1P.updatePosition=function(a){var b=r.csnames[a.args[0]].homog,c=r.csnames[a.args[1]].homog,d=r.csnames[a.args[2]].homog,f=g.ii,h=g.jj,k=g.normalizeMax(g.cross(b,d)),n=g.normalizeMax(g.cross(c,d)),p=g.normalizeMax(g.cross(d,f));d=g.normalizeMax(g.cross(d,h));n=m._helper.coHarmonic(p,d,k,n); +k=g.normalizeMax(n[0]);n=g.normalizeMax(n[1]);f=g.turnIntoCSList([f]);p=g.turnIntoCSList([h]);d=g.turnIntoCSList([b]);var q=g.turnIntoCSList([c]);h=m._helper.conicFromTwoDegenerates(f,p,d,q,k);h=g.normalizeMax(h);f=m._helper.conicFromTwoDegenerates(f,p,d,q,n);f=g.normalizeMax(f);h=g.normalizeMax(g.adjoint3(h));f=g.normalizeMax(g.adjoint3(f));"ellipsoid"!==m._helper.getConicType(h)&&(k=h,h=f,f=k);g.almostequals(b,c).value&&(b=l.real(3),f=g.zeromatrix(b,b));a.results=[h,f]};m.ConicBy2Pol1P={};m.ConicBy2Pol1P.kind= +"C";m.ConicBy2Pol1P.signature=["P","L","P","L","P"];m.ConicBy2Pol1P.updatePosition=function(a){var b=r.csnames[a.args[0]].homog,c=r.csnames[a.args[1]].homog,d=r.csnames[a.args[2]].homog,f=r.csnames[a.args[3]].homog,h=r.csnames[a.args[4]].homog,k=g.scalproduct,m=g.scalmult,n=g.sub,p=g.productMM,q=l.realmult,t=g.transpose,w=g.turnIntoCSList,y=n(m(k(c,b),h),m(q(2,k(c,h)),b)),z=n(m(k(f,d),h),m(q(2,k(f,h)),d)),A=w([g.cross(b,h)]);h=w([g.cross(d,h)]);z=p(t(A),w([g.cross(b,z)]));w=p(t(h),w([g.cross(d,y)])); +p=p(t(A),h);b=k(b,f);c=k(d,c);d=g.add(m(c,z),m(b,w));d=n(d,m(q(2,l.mult(b,c)),p));d=g.add(d,t(d));d=g.normalizeMax(d);d=u.withUsage(d,"Conic");a.matrix=d};m.ConicBy2Pol1L={};m.ConicBy2Pol1L.kind="C";m.ConicBy2Pol1L.signature=["P","L","P","L","L"];m.ConicBy2Pol1L.updatePosition=function(a){var b=r.csnames[a.args[0]].homog,c=r.csnames[a.args[1]].homog,d=r.csnames[a.args[2]].homog,f=r.csnames[a.args[3]].homog,h=r.csnames[a.args[4]].homog,k=g.scalproduct,m=g.scalmult,n=g.productMM,p=l.mult,q=g.transpose, +t=g.turnIntoCSList,w=k(c,b),y=k(c,d),z=k(f,b),A=k(f,d),B=k(h,b);k=k(h,d);var C=t([g.sub(m(p(z,k),c),m(p(y,B),f))]);b=g.add(n(q(t([m(p(z,y),h)])),t([g.sub(g.add(m(l.sub(p(w,k),p(y,B)),f),m(l.sub(p(A,B),p(z,k)),c)),m(g.det3(c,f,h),g.cross(b,d)))])),n(q(C),C));b=g.add(b,q(b));b=g.normalizeMax(b);b=u.withUsage(b,"Conic");a.matrix=b};m._helper.conic1Pol3Inc=function(a,b,c,d,f){var e=g.scalproduct,h=g.scalmult,k=g.productMM,m=g.cross,n=l.realmult,x=l.mult,p=g.transpose,v=g.turnIntoCSList,q=g.det3,r=q(a, +c,d),t=v([m(c,f)]),u=v([m(a,f)]),w=v([m(c,d)]),y=e(b,a),z=e(b,c);b=e(b,f);m=v([m(d,g.sub(h(y,f),h(n(2,b),a)))]);t=h(r,k(p(t),m));a=n(2,l.add(x(q(a,d,f),z),x(r,b)));a=l.sub(x(q(c,d,f),y),a);t=g.add(t,h(a,k(p(u),w)));t=g.add(t,p(t));return t=g.normalizeMax(t)};m.ConicBy1Pol3P={};m.ConicBy1Pol3P.kind="C";m.ConicBy1Pol3P.signature=["P","L","P","P","P"];m.ConicBy1Pol3P.updatePosition=function(a){var b=m._helper.conic1Pol3Inc(r.csnames[a.args[0]].homog,r.csnames[a.args[1]].homog,r.csnames[a.args[2]].homog, +r.csnames[a.args[3]].homog,r.csnames[a.args[4]].homog);b=u.withUsage(b,"Conic");a.matrix=b};m.ConicBy1Pol3L={};m.ConicBy1Pol3L.kind="C";m.ConicBy1Pol3L.signature=["P","L","L","L","L"];m.ConicBy1Pol3L.updatePosition=function(a){var b=m._helper.conic1Pol3Inc(r.csnames[a.args[1]].homog,r.csnames[a.args[0]].homog,r.csnames[a.args[2]].homog,r.csnames[a.args[3]].homog,r.csnames[a.args[4]].homog);b=g.normalizeMax(g.adjoint3(b));b=u.withUsage(b,"Conic");a.matrix=b};m.ConicBy1Pol2P1L={};m.ConicBy1Pol2P1L.kind= +"Cs";m.ConicBy1Pol2P1L.signature=["P","L","P","P","L"];m.ConicBy1Pol2P1L.updatePosition=function(a){var b=r.csnames[a.args[0]].homog,c=r.csnames[a.args[1]].homog,d=r.csnames[a.args[2]].homog,f=r.csnames[a.args[3]].homog,h=r.csnames[a.args[4]].homog,k=l.add,m=g.turnIntoCSList,n=g.cross,p=g.productMM,q=l.mult,t=l.realmult,u=g.scalmult,w=g.scalproduct,y=l.sub,z=g.transpose,A=w(c,b),B=w(c,d),C=w(c,f);c=w(h,b);var D=w(h,d);w=w(h,f);h=m([n(b,d)]);b=m([n(b,f)]);d=m([n(d,f)]);f=l.sqrt(q(q(D,w),q(y(q(A,D), +t(2,q(c,B))),y(q(A,w),t(2,q(c,C))))));m=p(z(h),b);f=u(f,g.add(m,z(m)));k=u(y(q(A,q(D,w)),k(q(c,q(B,w)),q(c,q(D,C)))),m);t=g.add(g.sub(u(C,h),u(B,b)),u(t(.5,A),d));k=g.add(k,u(q(c,c),p(z(d),t)));k=g.add(k,z(k));p=g.normalizeMax(g.add(f,k));q=g.normalizeMax(g.sub(f,k));a.results=vc(p,q).value};m.ConicBy1Pol2P1L.stateSize=vc.stateSize;m.ConicBy1Pol1P2L={};m.ConicBy1Pol1P2L.kind="Cs";m.ConicBy1Pol1P2L.signature=["P","L","P","L","L"];m.ConicBy1Pol1P2L.updatePosition=function(a){var b=r.csnames[a.args[0]].homog, +c=r.csnames[a.args[1]].homog,d=r.csnames[a.args[2]].homog,f=r.csnames[a.args[3]].homog,h=r.csnames[a.args[4]].homog,k=l.add,m=g.turnIntoCSList,n=g.cross,p=g.productMM,q=l.mult,t=l.realmult,u=g.scalmult,w=g.scalproduct,y=l.sub,z=g.transpose,A=w(c,b),B=w(c,d),C=w(f,b),D=w(f,d),E=w(h,b),F=w(h,d),G=q(A,A),H=q(A,B);w=q(B,B);var I=q(C,C),J=q(C,D),K=q(D,D),L=q(E,E),M=q(E,F),P=q(F,F),O=q(q(G,K),P);O=y(O,t(2,q(q(H,J),P)));O=y(O,t(2,q(q(H,K),M)));O=k(O,t(.5,q(q(w,I),P)));O=k(O,t(3,q(q(w,J),M)));O=k(O,t(.5, +q(q(w,K),L)));M=q(q(A,D),F);M=y(M,q(q(B,C),F));M=y(M,q(q(B,D),E));M=q(M,q(w,E));P=y(q(A,D),t(2,q(B,C)));P=q(P,q(w,q(D,E)));O=p(z(m([c])),m([g.add(g.add(u(O,c),u(M,f)),u(P,h))]));M=m([f]);O=g.add(O,u(t(.5,q(q(w,w),L)),p(z(M),M)));O=g.add(O,u(w,p(z(m([h])),m([g.add(u(y(y(t(2,q(H,J)),q(G,K)),t(.5,q(w,I))),h),u(q(g.det3(c,f,h),y(q(A,D),q(B,C))),n(b,d)))]))));O=g.add(O,z(O));b=l.sqrt(q(q(D,F),q(y(q(A,D),t(2,q(B,C))),y(q(A,F),t(2,q(B,E))))));c=p(z(m([c])),m([g.sub(u(y(q(B,k(q(C,F),q(D,E))),q(A,q(D,F))), +c),u(w,g.add(u(E,f),u(C,h))))]));c=g.add(c,u(q(A,w),p(z(m([f])),m([h]))));c=u(b,c);c=g.add(c,z(c));f=g.normalizeMax(g.add(O,c));h=g.normalizeMax(g.sub(O,c));a.results=vc(f,h).value};m.ConicBy1Pol1P2L.stateSize=vc.stateSize;m._helper.coHarmonic=function(a,b,c,d){var e=g.realVector([100*Math.random(),100*Math.random(),1]),f=g.det3(e,c,a),h=g.det3(e,c,b);c=g.det3(e,d,a);d=g.det3(e,d,b);d=l.sqrt(l.mult(d,h));f=l.sqrt(l.mult(c,f));a=u.mult(a,d);f=u.mult(b,f);b=g.add(a,f);a=g.sub(a,f);return[b,a]};m.ConicInSquare= +{};m.ConicInSquare.kind="C";m.ConicInSquare.signature=["P","P","P","P"];m.ConicInSquare.updatePosition=function(a){var b=E.basismap(r.csnames[a.args[0]].homog,r.csnames[a.args[1]].homog,r.csnames[a.args[2]].homog,r.csnames[a.args[3]].homog),c=l.one;c=m._helper.buildConicMatrix([c,c,c,l.real(-3),c,c]);b=g.adjoint3(b);b=g.productMM(g.productMM(g.transpose(b),c),b);b=g.normalizeMax(b);a.matrix=u.withUsage(b,"Conic")};m.ConicBy5lines={};m.ConicBy5lines.kind="C";m.ConicBy5lines.signature=["L","L","L", +"L","L"];m.ConicBy5lines.updatePosition=function(a){var b=m._helper.ConicBy5(a,r.csnames[a.args[0]].homog,r.csnames[a.args[1]].homog,r.csnames[a.args[2]].homog,r.csnames[a.args[3]].homog,r.csnames[a.args[4]].homog);b=g.adjoint3(b);a.matrix=b;a.matrix=g.normalizeMax(a.matrix);a.matrix=u.withUsage(a.matrix,"Conic")};m.ConicFromPrincipalDirections={};m.ConicFromPrincipalDirections.kind="C";m.ConicFromPrincipalDirections.signature=["P","P","P"];m.ConicFromPrincipalDirections.updatePosition=function(a){var b= +r.csnames[a.args[0]].homog,c=r.csnames[a.args[1]].homog,d=r.csnames[a.args[2]].homog,f=m._helper.pointReflection(b,c),h=g.cross(c,b);b=g.turnIntoCSList([h.value[0],h.value[1],l.zero]);h=g.turnIntoCSList([h]);c=g.turnIntoCSList([g.cross(c,b)]);f=g.turnIntoCSList([g.cross(f,b)]);a.matrix=m._helper.conicFromTwoDegenerates(h,h,c,f,d);a.matrix=g.normalizeMax(a.matrix);a.matrix=u.withUsage(a.matrix,"Conic")};m.CircleBy3={};m.CircleBy3.kind="C";m.CircleBy3.signature=["P","P","P"];m.CircleBy3.updatePosition= +function(a){var b=m._helper.ConicBy5(a,r.csnames[a.args[0]].homog,r.csnames[a.args[1]].homog,g.ii,g.jj,r.csnames[a.args[2]].homog);a.matrix=g.normalizeMax(b);a.matrix=u.withUsage(a.matrix,"Circle")};m.ArcBy3={};m.ArcBy3.kind="C";m.ArcBy3.signature=["P","P","P"];m.ArcBy3.updatePosition=function(a){m.CircleBy3.updatePosition(a);a.startPoint=r.csnames[a.args[0]].homog;a.viaPoint=r.csnames[a.args[1]].homog;a.endPoint=r.csnames[a.args[2]].homog};m.ArcBy3.initialize=function(a){a.startPoint=r.csnames[a.args[0]].homog; +a.viaPoint=r.csnames[a.args[1]].homog;a.endPoint=r.csnames[a.args[2]].homog;a.isArc=!0};m.PolarOfPoint={};m.PolarOfPoint.kind="L";m.PolarOfPoint.signature=["P","C"];m.PolarOfPoint.updatePosition=function(a){var b=u.mult(r.csnames[a.args[1]].matrix,r.csnames[a.args[0]].homog);b=g.normalizeMax(b);a.homog=u.withUsage(b,"Line")};m.PolarOfLine={};m.PolarOfLine.kind="P";m.PolarOfLine.signature=["L","C"];m.PolarOfLine.updatePosition=function(a){var b=r.csnames[a.args[0]],c=g.adjoint3(r.csnames[a.args[1]].matrix); +b=u.mult(c,b.homog);b=g.normalizeMax(b);a.homog=u.withUsage(b,"Point")};m.AngleBisector={};m.AngleBisector.kind="Ls";m.AngleBisector.signature=["L","L","P"];m.AngleBisector.updatePosition=function(a){var b=r.csnames[a.args[0]].homog,c=r.csnames[a.args[1]].homog,d=r.csnames[a.args[2]].homog,f=g.add,h=g.sub,k=g.abs,l=g.cross,m=g.scalmult,n=g.normalizeMax,p=g._helper.isAlmostZero,q=g.linfty,t=m(k(l(l(q,c),q)),b);b=m(k(l(l(q,b),q)),c);h=h(t,b);f=f(t,b);p(h)&&(h=l(l(l(q,f),q),d));p(f)&&(f=l(l(l(q,h),q), +d));a.results=mb(n(h),n(f))};m.AngleBisector.stateSize=mb.stateSize;m._helper.IntersectLC=function(a,b){var c=l,e=g.crossOperator(a),d=g.transpose(e);b=u.mult(d,u.mult(b,e));d=g.maxIndex(a,l.abs2);if(0===d){d=b.value[1].value[1];var f=b.value[1].value[2];var h=b.value[2].value[1];var k=b.value[2].value[2];a=a.value[0]}else 1===d?(d=b.value[0].value[0],f=b.value[0].value[2],h=b.value[2].value[0],k=b.value[2].value[2],a=a.value[1]):(d=b.value[0].value[0],f=b.value[0].value[1],h=b.value[1].value[0], +k=b.value[1].value[1],a=a.value[2]);c=c.div(c.sqrt(c.sub(c.mult(f,h),c.mult(d,k))),a);c=g.add(b,g.scalmult(c,e));d=g.maxIndex(c,g.abs2);e=c.value[d];e=g.normalizeMax(e);e=u.withUsage(e,"Point");c=g.transpose(c);d=g.maxIndex(c,g.abs2);c=c.value[d];c=g.normalizeMax(c);c=u.withUsage(c,"Point");return[e,c]};m.IntersectLC={};m.IntersectLC.kind="Ps";m.IntersectLC.signature=["L","C"];m.IntersectLC.updatePosition=function(a){var b=m._helper.IntersectLC(r.csnames[a.args[0]].homog,r.csnames[a.args[1]].matrix); +a.results=mb(b[0],b[1])};m.IntersectLC.stateSize=mb.stateSize;m.OtherIntersectionCL={};m.OtherIntersectionCL.kind="P";m.OtherIntersectionCL.signature=["C","L","P"];m.OtherIntersectionCL.updatePosition=function(a){var b=r.csnames[a.args[2]].homog,c=m._helper.IntersectLC(r.csnames[a.args[1]].homog,r.csnames[a.args[0]].matrix),d=c[0];c=c[1];var f=g.projectiveDistMinScal(d,b);b=g.projectiveDistMinScal(c,b);a.homog=fk?(n=a,p=b):(p=l.solveCubic(n,p,c,f),c=l.abs2(l.sub(p[0], +p[1])).value.real,f=l.abs2(l.sub(p[0],p[2])).value.real,h=l.abs2(l.sub(p[1],p[2])).value.real,c>f?(n=p[1],p=c>h?p[0]:p[2]):(n=p[2],p=f>h?p[0]:p[1]),n=g.add(g.scalmult(n,a),b),p=g.add(g.scalmult(p,a),b));b=m._helper.splitDegenConic(n);a=b[0];b=b[1];n=m._helper.splitDegenConic(p);c=n[0];p=n[1];n=g.cross(a,c);c=g.cross(b,c);a=g.cross(a,p);b=g.cross(b,p);n=g.normalizeMax(n);c=g.normalizeMax(c);a=g.normalizeMax(a);b=g.normalizeMax(b);n=u.withUsage(n,"Point");c=u.withUsage(c,"Point");a=u.withUsage(a,"Point"); +b=u.withUsage(b,"Point");return[n,c,a,b]};m.IntersectConicConic={};m.IntersectConicConic.kind="Ps";m.IntersectConicConic.signature=["C","C"];m.IntersectConicConic.updatePosition=function(a){var b=m._helper.IntersectConicConic(r.csnames[a.args[0]].matrix,r.csnames[a.args[1]].matrix);b=rd(b[0],b[1],b[2],b[3]);a.results=b};m.IntersectConicConic.stateSize=rd.stateSize;m.SelectP={};m.SelectP.kind="P";m.SelectP.signature=["Ps"];m.SelectP.initialize=function(a){if(void 0!==a.index)return a.index-1;var b= +r.csnames[a.args[0]].results.value;a=m._helper.initializePoint(a);for(var c=g.projectiveDistMinScal(a,b[0]),d=0,f=1;fa.isEuclidean,ar:b[0].value[0],ai:b[1].value[0],br:b[0].value[2],bi:b[1].value[2],cr:l.zero,ci:l.zero,dr:b[2].value[2],di:l.zero}};m.TrComposeMtMt={};m.TrComposeMtMt.kind="Mt";m.TrComposeMtMt.signature=["Mt","Mt"];m.TrComposeMtMt.updatePosition=function(a){m._helper.composeMtMt(a,r.csnames[a.args[0]].moebius,r.csnames[a.args[1]].moebius)};m.TrComposeTrMt={};m.TrComposeTrMt.kind="Mt";m.TrComposeTrMt.signature=["Tr","Mt"];m.TrComposeTrMt.signatureConstraints= +function(a){return!!r.csnames[a.args[0]].isEuclidean};m.TrComposeTrMt.updatePosition=function(a){m._helper.composeMtMt(a,m._helper.euc2moeb(r.csnames[a.args[0]]),r.csnames[a.args[1]].moebius)};m.TrComposeMtTr={};m.TrComposeMtTr.kind="Mt";m.TrComposeMtTr.signature=["Mt","Tr"];m.TrComposeMtTr.signatureConstraints=function(a){return!!r.csnames[a.args[1]].isEuclidean};m.TrComposeMtTr.updatePosition=function(a){m._helper.composeMtMt(a,r.csnames[a.args[0]].moebius,m._helper.euc2moeb(r.csnames[a.args[1]]))}; +m._helper.pointReflection=function(a,b){return g.normalizeMax(g.sub(g.scalmult(l.realmult(2,b.value[2]),a),g.scalmult(a.value[2],b)))};m._helper.conicOtherIntersection=function(a,b,c){var e=g.productMV(a,c);a=g.scalproduct(c,e);e=g.scalproduct(b,e);e=l.realmult(-2,e);b=g.scalmult(a,b);c=g.scalmult(e,c);c=g.add(b,c);return c=g.normalizeMax(c)};m.Dist={};m.Dist.kind="V";m.Dist.signature=["P","P"];m.Dist.updatePosition=function(a){var b=r.csnames[a.args[1]].homog;a.value=g.abs(g.sub(g.normalizeZ(r.csnames[a.args[0]].homog), +g.normalizeZ(b)))};m.Angle={};m.Angle.kind="V";m.Angle.signature=["L","L","P"];m.Angle.initialize=function(a){void 0===a.angle&&(a.angle=.5*Math.PI);wb(l._helper.input(a.angle))};m.Angle.updatePosition=function(a){var b=r.csnames[a.args[1]].homog,c=r.csnames[a.args[2]].homog,d=g.cross(r.csnames[a.args[0]].homog,g.linfty);b=g.cross(b,g.linfty);c=g.crossratio3(d,b,g.ii,g.jj,c);c=l.mult(l.complex(0,.5),l.log(c));d=(hc().value.real-c.value.real)/Math.PI;b=Math.round(d);!lc&&.01a;++a)m.IFS["set_prob"+a]=m.IFS.probSetter.bind(null,a)})();m._helper.snapPointToLine=function(a,b){if(l._helper.isAlmostZero(a.value[2]))return a; +var c=m._helper.projectPointToLine(a,b);c=g.normalizeZ(c);var e=c.value[0].value.real;c=c.value[1].value.real;var d=Math.round(e/Va)*Va,f=Math.round(c/Va)*Va,h=g.realVector([d,f,1]);Math.abs(d-e)a&&c>.999*a;)b=cb.oneRKStep(b),c+=b,b=Math.min(2*b,a-c),b=Math.max(b,1E-16),cb.restorePosition(),cb.doCollisions(),cb.calculateForces(),cb.moveToFinalPos();return!0};cb.restorePosition=function(){qb.forEach(function(a){W[a.type].restorePos(a,9)})};cb.doCollisions=function(){qb.forEach(function(a){W[a.type].doCollisions(a)})};cb.calculateForces=function(){qb.forEach(function(a){W[a.type].calculateForces(a)})};cb.moveToFinalPos=function(){qb.forEach(function(a){W[a.type].move(a)})}; +cb.oneRKStep=function(a){for(var b=function(a){qb.forEach(function(b){W[b.type].initRK(b,a);W[b.type].storePosition(b)})},c=function(a){qb.forEach(function(b){W[b.type].setToTimestep(b,ke[a])})},d=function(a){qb.forEach(function(b){W[b.type].proceedMotion(b,ke[a],a,$e[a])})},f=function(){qb.forEach(function(a){W[a.type].resetForces(a)})},g=function(a){qb.forEach(function(b){W[b.type].calculateDelta(b,a)})},h=function(b){var c=0;qb.forEach(function(a){W[a.type].proceedMotion(a,ke[6],7,af);W[a.type].savePos(a, +8);W[a.type].proceedMotion(a,ke[6],7,bf);W[a.type].savePos(a,9);c+=W[a.type].sqDist(a,8,9)});return c=Math.sqrt(c)/a},k=function(a){qb.forEach(function(a){W[a.type].recallPosition(a)})},l=!1;!l;){b(a);for(var m=0;7>m;m++)c(m),d(m),f(),cb.calculateForces(),g(m);h(a)>W.env.errorbound&&a>W.env.lowestdeltat?(a/=W.env.slowdownfactor,k()):l=!0}return a};var W={Mass:{reset:function(a,b){a.vel=[0,0,0];a.pos=[0,0,0,0];a.el=b;"undefined"===typeof a.mass&&(a.mass=1);"undefined"===typeof a.charge&&(a.charge= +0);"undefined"===typeof a.friction&&(a.friction=0);a.lnfrict=0;"undefined"===typeof a.limitspeed&&(a.limitspeed=!1);"undefined"===typeof a.fixed&&(a.fixed=!1);"undefined"===typeof a.radius&&(a.radius=1);a.internalmove=!1;a.fx=0;a.fy=0;a.fz=0;a.vx=a.vx||0;a.vy=a.vy||0;a.vz=a.vz||0;a.mtype=0;a.env=W.env;a.deltat=0;a.mx=0;a.my=0;a.mz=0;a.mvx=0;a.mvy=0;a.mvz=0;a.dx=[0,0,0,0,0,0,0,0,0,0];a.dy=[0,0,0,0,0,0,0,0,0,0];a.dz=[0,0,0,0,0,0,0,0,0,0];a.dvx=[0,0,0,0,0,0,0,0,0,0];a.dvy=[0,0,0,0,0,0,0,0,0,0];a.dvz= +[0,0,0,0,0,0,0,0,0,0];a.midx=0;a.midy=0;a.midz=0;a.lx=0;a.ly=0;a.lz=0},resetForces:function(a){a.fx=0;a.fy=0;a.fz=0},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){var c=E.extractPoint(a.el.homog);a.x=c.x;a.y=c.y;a.z=0;a.xo=a.x;a.yo=a.y;a.zo=a.z;a.vxo=a.vx;a.vyo=a.vy;a.vzo=a.vz;a.deltat=b;a.fx=0;a.fy=0;a.fz=0},setVelocity:function(a,b,c,d){d||(d=0);a.vx=b;a.vy=c;a.vz=d},move:function(a){a.pos=[a.x,a.y,1];a.internalmove=!0;ya&&ja.down&&a.el===ya.mover||Ta(a.el,g.realVector(a.pos), +"homog");a.el.sx=a.x;a.el.sy=a.y;a.internalmove=!1},proceedMotion:function(a,b,c,d){if(!a.fixed)for(a.x=a.mx,a.y=a.my,a.z=a.mz,a.vx=a.mvx,a.vy=a.mvy,a.vz=a.mvz,b=0;bW.det(d,b,f,c,w,y)*W.det(d,b,f,c,z.value.real,z.value.imag)&&0>W.det(d,b,w,y,z.value.real, +z.value.imag)*W.det(f,c,w,y,z.value.real,z.value.imag)&&(u=r.behavior.mvx+a.deltat*(-z.value.real+r.behavior.xo),w=r.behavior.mvy+a.deltat*(-z.value.imag+r.behavior.yo),t=p*u+n*w,u=n*u-p*w,r.behavior.x=z.value.real,r.behavior.y=z.value.imag,r.behavior.vx=p*t*(1-a.xdamp),r.behavior.vy=n*t*(1-a.xdamp),r.behavior.vx+=-n*u*(1-a.ydamp),r.behavior.vy+=p*u*(1-a.ydamp))}a.x1o=d;a.y1o=b;a.x2o=f;a.y2o=c}},Environment:{init:function(a){"undefined"===typeof a.gravity&&(a.gravity=0);"undefined"===typeof a.friction&& +(a.friction=0);"undefined"===typeof a.springstrength&&(a.springstrength=1);"undefined"!==typeof a.accuracy&&(zc=a.accuracy);"undefined"!==typeof a.deltat&&O(a.deltat/.6);"undefined"===typeof a.charges&&(a.charges=!1);"undefined"===typeof a.balls&&(a.balls=!1);"undefined"===typeof a.newton&&(a.newton=!1);"undefined"===typeof a.ballInteractionBoosting&&(a.ballInteractionBoosting=1);W.env=a;a.errorbound=.001;a.lowestdeltat=1E-7;a.slowdownfactor=2},reset:function(a){},resetForces:function(a){},getBlock:!1, +setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateForces:function(a){var b,c;if(a.newton)for(b=0;bn?0:(m-n)*(m-n)),l=(g-l)/(m*m*m)*(m>n?0:(m-n)*(m-n))):1===a.ballInteractionBoosting?(k=(f-k)/(m*m*m*m)*(m>n?0:(m-n)*(m-n)),l=(g-l)/(m*m*m*m)*(m>n?0:(m-n)*(m-n))):(k=(f-k)/(m*m*m*m*m)*(m>n?0:(m-n)*(m-n)),l=(g-l)/(m*m*m*m*m)*(m>n?0:(m-n)*(m-n)));d.behavior.fx+=k;d.behavior.fy+=l;h.behavior.fx-=k;h.behavior.fy-=l}for(b= +0;bc&&(c=Math.max(0,b+c));if(null==e||e>b)e=b;e=Number(e);0>e&&(e=Math.max(0,b+e));for(c=Number(c||0);c1.)return vec2(0,log(z+sqrt(z*z-1.)));\nelse return vec2(pi, -log(-z+sqrt(z*z-1.)));\n}\n", +arcsinc:"vec2 arcsinc(vec2 a){\nvec2 t2=multc(a,negc(a));\nvec2 tmp=sqrtc(addc(vec2(1.0,0.0),t2));\nvec2 tmp1=addc(multc(a,vec2(0.0,1.0)),tmp);\nvec2 erg=multc(logc(tmp1),vec2(0.0,-1.0));\nreturn erg;\n}\n",arcsinf:"vec2 arcsinf(float z){\nif(abs(z)<=1.)return vec2(asin(z),0.);\nelse if(z>1.)return vec2(pi*.5, -log(z+sqrt(z*z-1.)));\nelse return vec2(-pi*.5,log(-z+sqrt(z*z-1.)));\n}\n",arctan2c:"\n\n\n\nvec2 arctan2c(vec2 x,vec2 y){\nvec2 r=logc(divc(x+vec2(-y.y,y.x),sqrtc(multc(x,x)+multc(y,y))));\nreturn vec2(r.y, -r.x);\n}\n", +arctan2cvec2:"vec2 arctan2cvec2(cvec2 v){\nreturn arctan2c(v.real,v.imag);\n}\n",arctan2vec2:"float arctan2vec2(vec2 v){\nreturn atan(v.y,v.x);\n}\n",arctanc:"vec2 arctanc(vec2 a){\nvec2 t1=logc(addc(multc(a,vec2(0.0,-1.0)),vec2(1.0,0.0)));\nvec2 t2=logc(addc(multc(a,vec2(0.0,1.0)),vec2(1.0,0.0)));\nvec2 erg=multc(subc(t1,t2),vec2(0.0,0.5));\nreturn erg;\n}\n",blue:"vec3 blue(float f)\n{\nreturn vec3(0.,0.,clamp(f,0.,1.));\n}\n",cimag:"float imagc(vec2 a){\nreturn a.y;\n}\n",conjugate:"vec2 conjugate(vec2 a){\nreturn vec2(a.x, -a.y);\n}\n", +copytexture_f:"#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D sampler;\nvarying vec2 cgl_pixel;\n\nvoid main(void){\ngl_FragColor=texture2D(sampler,cgl_pixel);\n}\n",copytexture_v:"attribute vec3 aPos;\nattribute vec2 aTexCoord;\nvarying vec2 cgl_pixel;\n\nvoid main(void){\ngl_Position=vec4(aPos,1.);\ncgl_pixel=aTexCoord;\n}\n",cosc:"vec2 cosc(vec2 a){\n\nfloat n=exp(a.y);\nfloat imag1=n*sin(-a.x);\nfloat real1=n*cos(-a.x);\nn=exp(-a.y);\nfloat imag2=n*sin(a.x);\nfloat real2=n*cos(a.x);\nfloat i= (imag1+imag2) /2.0;\nfloat r= (real1+real2) /2.0;\n\nreturn vec2(r,i);\n}\n", +creal:"float realc(vec2 a){\nreturn a.x;\n}\n",dehomogenize:"vec2 dehomogenize(vec3 z){\nreturn vec2(z.x,z.y)/z.z;\n}\n",dehomogenizex:"float dehomogenizex(vec3 z){\nreturn z.x/z.z;\n}\n",dehomogenizey:"float dehomogenizey(vec3 z){\nreturn z.y/z.z;\n}\n",det2:"float det2(mat2 a){\nreturn a[0][0]*a[1][1] -a[0][1]*a[1][0];\n}\n",det3:"float det3(mat3 a){\nreturn dot(cross(a[0],a[1]),a[2]);\n}\n",det3v:"float det3v(vec3 a,vec3 b,vec3 c){\nreturn dot(cross(a,b),c);\n}\n",det4:"float det4(mat4 a){\nfloat s00=a[0][0]*a[1][1] -a[0][1]*a[1][0],\ns01=a[0][0]*a[1][2] -a[0][2]*a[1][0],\ns02=a[0][0]*a[1][3] -a[0][3]*a[1][0],\ns03=a[0][1]*a[1][2] -a[0][2]*a[1][1],\ns04=a[0][1]*a[1][3] -a[0][3]*a[1][1],\ns05=a[0][2]*a[1][3] -a[0][3]*a[1][2],\ns06=a[2][0]*a[3][1] -a[2][1]*a[3][0],\ns07=a[2][0]*a[3][2] -a[2][2]*a[3][0],\ns08=a[2][0]*a[3][3] -a[2][3]*a[3][0],\ns09=a[2][1]*a[3][2] -a[2][2]*a[3][1],\ns10=a[2][1]*a[3][3] -a[2][3]*a[3][1],\ns11=a[2][2]*a[3][3] -a[2][3]*a[3][2];\nreturn s00*s11-s01*s10+s02*s09+s03*s08-s04*s07+s05*s06;\n}\n", +divc:"vec2 divc(vec2 a,vec2 b){\nreturn vec2(dot(a,b),dot(a,vec2(-b.y,b.x)))/dot(b,b);\n}\n",divfc:"vec2 divfc(float a,vec2 b){\nreturn a*vec2(b.x,-b.y)/dot(b,b);\n}\n",expc:"vec2 expc(vec2 a){\nfloat n=exp(a.x);\nfloat r=n*cos(a.y);\nfloat i=n*sin(a.y);\nreturn vec2(r,i);\n}\n",float2color:"vec4 float2color(float f)\n{\nreturn vec4(f,f,f,1.);\n}\n",gray:"vec3 gray(float f)\n{\nf=clamp(f,0.,1.);\nreturn vec3(f,f,f);\n}\n",green:"vec3 green(float f)\n{\nreturn vec3(0.,clamp(f,0.,1.),0.);\n}\n",hsv2rgb:"vec3 hsv2rgb(vec3 c)\n{\nvec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);\nvec3 p=abs(fract(c.xxx+K.xyz) *6.0-K.www);\nreturn c.z*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),c.y);\n}\n", +hue:"vec3 hue(float a){\nreturn hsv2rgb(vec3(a,1.,1.));\n}\n",imagc:"float imagc(vec2 a){\nreturn a.y;\n}\n",invc:"vec2 invc(vec2 a){\nfloat n=a.x*a.x+a.y*a.y;\nreturn vec2(a.x/n,-a.y/n);\n}\n",logc:"vec2 logc(vec2 a){\nfloat re=a.x;\nfloat im=a.y;\nfloat s=sqrt(re*re+im*im);\nfloat i=im;\nfloat imag=atan(im,re);\nif(i<0.0){\nimag+= (2.0*pi);\n}\nif(i==0.0&&re<0.0){\nimag=pi;\n}\nif(imag>pi){\nimag-= (2.0*pi);\n};\nfloat real=log(s);\n\nreturn vec2(real,imag);\n}\n",logr:"vec2 logr(float a){\nif(a>=0.)return vec2(log(a),0);\nelse return vec2(log(-a),pi);\n}\n", +mat2complex:"mat4 mat2complex(mat2 a)\n{\nreturn mat4(\nvec4(a[0][0],0,a[0][1],0),\nvec4(0,a[0][0],0,a[0][1]),\nvec4(a[1][0],0,a[1][1],0),\nvec4(0,a[1][0],0,a[1][1])\n);\n}\n",multc:"vec2 multc(vec2 a,vec2 b){\nreturn vec2(dot(a,vec2(b.x,-b.y)),dot(a,b.yx));\n}\n",negc:"vec2 negc(vec2 a){\nreturn vec2(-a.x,-a.y);\n}\n",powc:"vec2 powc(vec2 a,vec2 b){\nreturn(b.x==0. &&b.y==0.) ?vec2(1.,0.) : ((a.x==0. &&a.y==0.) ?vec2(0.) :expc(multc(logc(a),b)));\n}\n",powi:"float powi(float a,int b){\nif(mod(float(b),2.) < .5)\nreturn pow(abs(a),float(b));\nelse\nreturn sign(a)*pow(abs(a),float(b));\n}\n", +random:"uniform float rnd_;\n\nfloat last_rnd= .1231;\nfloat random(){\nfloat a=fract(132422.21*sin(dot(plain_pixel,343433.671228*vec2(.176574+last_rnd, .1131+rnd_))));\nfloat b=fract(last_rnd*2321.2312*sin(dot(plain_pixel+vec2(rnd_,last_rnd),plain_pixel) *43758.5453));\nlast_rnd=fract(rnd_ +last_rnd+a+b);\nreturn last_rnd;\n}\n",randomnormal:"float randomnormal(){\nreturn sqrt(-2. *log(random())) *cos(6.283185307179586*random());\n}\n",realc:"float realc(vec2 a){\nreturn a.x;\n}\n",red:"vec3 red(float f)\n{\nreturn vec3(clamp(f,0.,1.),0.,0.);\n}\n", +rgb2hsv:"vec3 rgb2hsv(vec3 c)\n{\nvec4 K=vec4(0.0, -1.0/3.0,2.0/3.0, -1.0);\nvec4 p=mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));\nvec4 q=mix(vec4(p.xyw,c.r),vec4(c.r,p.yzx),step(p.x,c.r));\n\nfloat d=q.x-min(q.w,q.y);\nfloat e=1.0e-10;\nreturn vec3(abs(q.z+ (q.w-q.y) / (6.0*d+e)),d/ (q.x+e),q.x);\n}\n",sinc:"\n\nvec2 sinc(vec2 a){\n\nfloat n=exp(a.y);\nfloat imag1=n*sin(-a.x);\nfloat real1=n*cos(-a.x);\nn=exp(-a.y);\nfloat imag2=n*sin(a.x);\nfloat real2=n*cos(a.x);\nfloat r= -(imag1-imag2) /2.0;\nfloat i= (real1-real2) /2.0;\n\nreturn vec2(r,i);\n}\n", +sqrtc:"vec2 sqrtc(vec2 a){\nreturn expc(multc(logc(a),vec2(0.5,0.0)));\n}\n",sqrtf:"vec2 sqrtf(float a){\nif(a>=0.)return vec2(sqrt(a),0.);\nelse return vec2(0.,sqrt(-a));\n}\n",standardFragmentHeader:"#ifdef GL_ES\nprecision highp float;\nprecision highp int;\n#endif\n\n#define pi 3.141592653589793\n\nvarying vec2 cgl_pixel;\nvarying vec2 plain_pixel;\n",subc:"vec2 subc(vec2 a,vec2 b){\nreturn a-b;\n}\n",subpoints:"vec2 subpoints(vec3 a,vec3 b){\nreturn dehomogenize(a) -dehomogenize(b);\n}\n",tanc:"vec2 tanc(vec2 a){\nvec2 s=sinc(a);\nvec2 c=cosc(a);\nreturn divc(s,c);\n}\n", +vec2complex:"vec4 vec2complex(vec2 a)\n{\nreturn vec4(a.x,0.,a.y,0);\n}\n",vshader:"attribute vec3 aPos;\nattribute vec2 aTexCoord;\nvarying vec2 cgl_pixel;\nvarying vec2 plain_pixel;\nuniform mat3 transformMatrix;\nvoid main(void){\ngl_Position=vec4(aPos,1.);\nplain_pixel=aTexCoord;\nvec3 r=transformMatrix*vec3(plain_pixel,1);\ncgl_pixel=r.xy/r.z;\n}\n"};var la=!1,g,m,n,ma,r,t,w=!1,na,x=!1,oa=!1,pa=1; +function qa(){function a(c){g.removeEventListener("webglcontextcreationerror",a,!1);c.statusMessage&&(b=c.statusMessage)}if(!la){g=document.createElement("canvas");g.id="glcanvas";g.style.display="none";g.width=g.height=0;document.body.appendChild(g);m=document.createElement("canvas");m.id="tmpcanvas";m.style.display="none";m.width=m.height=0;document.body.appendChild(m);n=document.createElement("canvas");n.id="dummycanvas";n.style.display="none";n.width=n.height=1;document.body.appendChild(n);ma= +{ctype:"image",value:{img:n,width:1,height:1,ready:!0,live:!1,generation:0,whenReady:function(){}}};var b="Unknown";g.addEventListener("webglcontextcreationerror",a,!1);var c={};"undefined"!==typeof CindyJS._pluginRegistry.CindyXR&&(c.xrCompatible=!0);(r=g.getContext("webgl",c))||(r=g.getContext("experimental-webgl",c));if(!r)throw new ta("Could not obtain a WebGL context.\nReason: "+b);ua.gl=r;g.removeEventListener("webglcontextcreationerror",a,!1);oa||(x=r.getExtension("OES_texture_float")&&r.getExtension("OES_texture_float_linear"), +x||(console.error("Your browser does not suppert OES_texture_float, trying OES_texture_half_float..."),(w=(na=r.getExtension("OES_texture_half_float"))&&r.getExtension("OES_texture_half_float_linear"))||console.error("Your browser does not suppert OES_texture_half_float, will use 8-bit textures.")),navigator.userAgent.match(/(iPad|iPhone)/i)&&(console.log("You are using an iPhone/iPad."),x=w=!1,r.getExtension("OES_texture_half_float")&&r.getExtension("OES_texture_half_float_linear")&&r.getExtension("EXT_color_buffer_half_float")? +w=!0:console.error("Your browser does not suppert writing to half_float textures, we will use 8-bit textures.")));la=!0}};function va(a){if(null==a||"object"!=typeof a)return a;if(a instanceof Array){var b=[];for(var c=0,e=a.length;cMath.abs(a.imag)?(a.real|0)===a.real?z.u:z.f:z.h;if("list"===a.ctype){var b=a.value;if(3===b.length){if("Point"===a.usage)return z.w;if("Line"===a.usage)return z.line}if(0g.width||b>g.height)g.width=Math.ceil(a),g.height=Math.ceil(b)}function Ba(a,b){a.instance.ha||(a.instance.ha={});a.instance.ha[b]||(a.instance.ha[b]=a.instance.parse(b));a=a.evaluate(a.instance.ha[b]);return a.ctype&&"number"===a.ctype?a.value.real:0}function Ca(a){return{x:Ba(a,"(screenbounds()_4).x"),y:Ba(a,"(screenbounds()_4).y")}} +function Da(a){return{x:Ba(a,"(screenbounds()_3).x"),y:Ba(a,"(screenbounds()_3).y")}}var Ea=new Float32Array(1),Fa=new Int32Array(Ea.buffer);function Ga(a){Ea[0]=a;a=Fa[0];var b=a>>16&32768,c=(a&2147483647)+4096;if(1199570944<=c)return 1199570944<=(a&2147483647)?2139095040>c?b|31744:b|31744|(a&8388607)>>13:b|31743;if(947912704<=c)return b|c-939524096>>13;if(855638016>c)return b;c=(a&2147483647)>>23;return b|(a&8388607|8388608)+(8388608>>>c-102)>>126-c} +function Ha(a){if(x)return new Float32Array(a);if(w){for(var b=new Uint16Array(a.length),c=0;c>10,h=e&1023;b.push((e>>15?-1:1)*(f?31===f?h?NaN:Infinity:Math.pow(2,f-15)*(1+h/1024):h/1024*6.103515625E-5))}else b.push(a[c]/255);return b}function La(a){for(var b=1;be;e++)r.bindTexture(r.TEXTURE_2D,b.textures[e]),c.mipmap?r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,c.interpolate?r.LINEAR_MIPMAP_LINEAR:r.NEAREST_MIPMAP_LINEAR): +r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,c.interpolate?r.LINEAR:r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,c.interpolate?r.LINEAR:r.NEAREST),c.clamptoedge&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE))}}else a.canvaswrapper=new Oa(a.ready?a:ma,c||{interpolate:!0,mipmap:!1,repeat:!1,clamptoedge:!1}),a.ready||console.log("Image is not ready yet.");return a.canvaswrapper} +function Oa(a,b){this.canvas=a;this.j=b;this.L=a.width;this.G=a.height;Pa(this);this.it=0;this.textures=[];this.X=[];this.generation=-1;this.bindTexture();a.drawTo=this.drawTo.bind(this);a.readPixels=this.la.bind(this);a.cdyUpdate=this.pa.bind(this);a=Ia(this.P*this.M*4);for(var c=0;2>c;c++)this.textures[c]=r.createTexture(),r.bindTexture(r.TEXTURE_2D,this.textures[c]),r.pixelStorei(r.UNPACK_ALIGNMENT,1),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.P,this.M,0,r.RGBA,Ja(),a),b.mipmap?r.texParameteri(r.TEXTURE_2D, +r.TEXTURE_MIN_FILTER,b.interpolate?r.LINEAR_MIPMAP_LINEAR:r.NEAREST_MIPMAP_LINEAR):r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,b.interpolate?r.LINEAR:r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,b.interpolate?r.LINEAR:r.NEAREST),b.clamptoedge&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE)),this.X[c]=r.createFramebuffer(),r.bindFramebuffer(r.FRAMEBUFFER,this.X[c]),r.framebufferTexture2D(r.FRAMEBUFFER, +r.COLOR_ATTACHMENT0,r.TEXTURE_2D,this.textures[c],0);this.B=new Qa(ka.copytexture_v,ka.copytexture_f);b=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,b);b=new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0]);a=r.getAttribLocation(this.B.handle,"aPos");r.enableVertexAttribArray(a);c=r.getAttribLocation(this.B.handle,"aTexCoord");r.enableVertexAttribArray(c);var e=new Float32Array([0,0,1,0,0,1,1,1]),f=b.byteLength;r.bufferData(r.ARRAY_BUFFER,f+e.byteLength,r.STATIC_DRAW);r.bufferSubData(r.ARRAY_BUFFER,0, +b);r.bufferSubData(r.ARRAY_BUFFER,f,e);r.vertexAttribPointer(a,3,r.FLOAT,!1,0,0);r.vertexAttribPointer(c,2,r.FLOAT,!1,0,f)}function Pa(a){a.j.clamptoedge&&a.j.interpolate&&!a.j.repeat&&!a.j.mipmap?(a.P=a.L,a.M=a.G):(a.P=La(a.L+a.L/2*(a.j.mipmap&&a.j.repeat)),a.M=La(a.G+a.G/2*(a.j.mipmap&&a.j.repeat)))}Oa.prototype.bindTexture=function(){r.bindTexture(r.TEXTURE_2D,this.textures[this.it])};Oa.prototype.bindFramebuffer=function(){r.bindFramebuffer(r.FRAMEBUFFER,this.X[this.it^1]);this.it^=1}; +Oa.prototype.pa=function(){if(this.canvas.img.hasOwnProperty("getContext"))var a=this.canvas.img.getContext("2d");else this.canvas.img=document.createElement("canvas"),this.canvas.img.style.display="none",this.canvas.img.width=this.L,this.canvas.img.height=this.G,a=this.canvas.img.getContext("2d");a.clearRect(0,0,this.L,this.G);this.drawTo(a,0,0);this.canvas.img.generation++}; +Oa.prototype.reloadIfRequired=function(){if(!(this.canvas.live&&(this.canvas.img.webkitDecodedFrameCount||this.canvas.img.j)&&this.fa>=(this.canvas.img.webkitDecodedFrameCount||this.canvas.img.j)||!this.canvas.live&&(!this.canvas.ready||this.generation>=this.canvas.generation))){if(this.L!=this.canvas.width||this.G!=this.canvas.height){this.L=this.canvas.width;this.G=this.canvas.height;Pa(this);for(var a=Ia(this.P*this.M*4),b=0;2>b;b++)r.bindTexture(r.TEXTURE_2D,this.textures[b]),r.texImage2D(r.TEXTURE_2D, +0,r.RGBA,this.P,this.M,0,r.RGBA,Ja(),a)}this.bindTexture();r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1);this.j.repeat?(m.width=this.P,m.height=this.M,a=m.getContext("2d"),a.drawImage(this.canvas.img,0,this.M-this.G),a.drawImage(this.canvas.img,this.L,this.M-this.G),a.drawImage(this.canvas.img,0,this.M-2*this.G),a.drawImage(this.canvas.img,this.L,this.M-2*this.G),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,Ja(),m)):r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,Ja(),this.canvas.img);this.j.mipmap&&r.generateMipmap(r.TEXTURE_2D); +r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,0);this.generation=this.canvas.generation;this.fa=Math.min(this.fa+1,this.canvas.img.webkitDecodedFrameCount||this.canvas.img.j)}}; +Oa.prototype.drawTo=function(a,b,c){Aa(this.P,this.M);r.viewport(0,0,this.P,this.M);this.B.use(r);r.activeTexture(r.TEXTURE0);r.bindTexture(r.TEXTURE_2D,this.textures[this.it]);this.B.uniform.sampler([0]);r.bindFramebuffer(r.FRAMEBUFFER,null);r.drawArrays(r.TRIANGLE_STRIP,0,4);r.flush();a.drawImage(g,0,g.height-this.G,this.L,this.G,b,c,this.L,this.G)}; +Oa.prototype.la=function(a,b,c,e){r.bindFramebuffer(r.FRAMEBUFFER,this.X[this.it]);r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,this.textures[this.it],0);var f=Ia(c*e*4);r.readPixels(a,this.G-b-e,c,e,r.RGBA,Ja(),f);a=[];for(--e;0<=e;e--)a=a.concat(Ka(f.slice(e*c*4,(e+1)*c*4)));return a};function Ra(a,b){this.C=a;this.X=b;Sa(this)} +function Sa(a){var b=Ta(new Ua(a.C),a.X);a.B=b.D;a.N=b.N;a.ea=b.ea;a.fa=ka.standardFragmentHeader+b.code;a.la=ka.vshader;a.j=new Qa(a.la,a.fa);b=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,b);b=new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0]);var c=r.getAttribLocation(a.j.handle,"aPos");r.enableVertexAttribArray(c);a=r.getAttribLocation(a.j.handle,"aTexCoord");r.enableVertexAttribArray(a);var e=new Float32Array([0,0,1,0,0,1,1,1]),f=b.byteLength;r.bufferData(r.ARRAY_BUFFER,f+e.byteLength,r.STATIC_DRAW); +r.bufferSubData(r.ARRAY_BUFFER,0,b);r.bufferSubData(r.ARRAY_BUFFER,f,e);r.vertexAttribPointer(c,3,r.FLOAT,!1,0,0);r.vertexAttribPointer(a,2,r.FLOAT,!1,0,f)}function Va(a,b,c,e){b=[c.x-b.x,e.x-b.x,b.x,c.y-b.y,e.y-b.y,b.y,0,0,1];a.j.uniform.hasOwnProperty("transformMatrix")&&a.j.uniform.transformMatrix([b[0],b[3],b[6],b[1],b[4],b[7],b[2],b[5],b[8]])} +function Wa(a){function b(a,c,e){if(a)if("function"===typeof a)switch(c){case z.h:a([e.value.real,e.value.imag]);break;case z.A:e.value?a([1]):a([0]);break;case z.u:case z.f:a([e.value.real]);break;case z.w:case z.line:"geo"===e.ctype?a(e.value.homog.value.map(function(a){return a.value.real})):"list"===e.ctype&&2===e.value.length?a(e.value.map(function(a){return a.value.real}).concat([1])):"list"===e.ctype&&3===e.value.length&&a(e.value.map(function(a){return a.value.real}));break;default:if("list"=== +c.type&&c.parameters===z.f)a(e.value.map(function(a){return a.value.real}));else if("list"===c.type&&"list"===c.parameters.type&&c.parameters.parameters===z.f){for(var f=[],h=0;ha.ea[b])return console.log(b+" is outdated; forcing rebuild."),!1;return!0};function ua(a){function b(b,e,f,h,k,l){if(!b.ka||b.ja=a?"bool int float complex voidt color point line coordinate2d image".split(" ")[a-1]:"list"===a.type?B(a.parameters)+"["+a.length+"]":"constant"===a.type?"const["+JSON.stringify(a.value.value)+"]":JSON.stringify(a)}function H(a){return"list"===a.type&&H(a.parameters)||F(a,z.f)}function I(a){return"list"===a.type&&I(a.parameters)||F(a,z.h)}function fb(a){return"constant"===a.type&&F(a,z.u)}function J(a){return"constant"===a.type?xa(a.value):a} +function C(a){return"list"===a.type?C(a.parameters)+1:0}function Xa(a){return void 0!==a.parameters?Xa(a.parameters):a}function gb(a,b){return C(a)===C(b)&&(0===C(a)||a.length===b.length&&gb(a.parameters,b.parameters))}function K(a){return F(a,z.f)?z.f:F(a,z.h)?z.h:{type:"list",length:a.length,parameters:K(a.parameters)}}function hb(a){return F(a,z.h)?z.h:{type:"list",length:a.length,parameters:hb(a.parameters)}} +function L(a){return"constant"===a.type&&L(J(a))||a===z.A||a===z.u||a===z.f||a===z.h||a===z.w||a===z.line||"list"===a.type&&a.parameters===z.f&&1<=a.length&&4>=a.length||"list"===a.type&&"list"===a.parameters.type&&a.parameters.parameters===z.f&&a.length===a.parameters.length&&2<=a.length&&4>=a.length}function ib(a){return-1!==[z.A,z.u,z.f,z.h].indexOf(a)} +function jb(a,b){return a===b||"constant"===a.type&&"constant"===b.type&&wa(a.value,b.value)||"list"===a.type&&"list"===b.type&&a.length===b.length&&jb(a.parameters,b.parameters)} +function F(a,b){return jb(a,b)?!0:a?ib(a)&&ib(b)?a<=b:"constant"===b.type?!1:"constant"===a.type?F(xa(a.value),b):b===z.K?F(a,z.h)||F(a,z.F)||F(a,z.w):b===z.w?F(a,z.J)||F(a,z.F):b===z.line?F(a,z.J):b===z.color?F(a,z.f)||"list"===a.type&&(3===a.length||4===a.length)&&F(a.parameters,z.f):"list"===a.type&&"list"===b.type&&a.length===b.length?F(a.parameters,b.parameters):!1:!1} +function A(a,b){if(!a)return b;if(!b||jb(a,b))return a;"constant"===a.type&&(a=xa(a.value));"constant"===b.type&&(b=xa(b.value));return ib(a)&&ib(b)?Math.max(a,b):"list"===a.type&&"list"===b.type&&a.length===b.length&&(b=A(a.parameters,b.parameters))?{type:"list",length:a.length,parameters:b}:!1} +function M(a){return function(b){var c={},e;for(e in a){var f=a[e];c.ca=f[0];if(b.length==c.ca.length&&b.every(function(a){return function(b,c){return F(b,a.ca[c])}}(c)))return{o:c.ca,s:f[1],l:f[2]};c={ca:c.ca}}return!1}} +function kb(a){switch(a){case z.u:return M([[[z.A],z.u,N("int")]]);case z.f:return M([[[z.A],z.f,N("float")],[[z.u],z.f,N("float")]]);case z.h:return M([[[z.f],z.h,function(a){return"vec2("+a+", 0.)"}]]);case z.color:return M([[[z.f],z.color,O("float2color")],[[z.J],z.color,function(a){return"vec4("+a+",1.0)"}],[[z.O],z.color,P]]);case z.w:return M([[[z.F],z.w,function(a){return"vec3("+a+",1.0)"}],[[z.J],z.w,P]]);case z.line:return M([[[z.F],z.line,function(a){return"vec3("+a+",1.0)"}],[[z.J],z.line, +P]]);case z.K:return M([[[z.h],z.K,P],[[z.F],z.K,P],[[z.w],z.K,O("dehomogenize")]]);default:if("list"===a.type)return function(b){var c=b[0],e=kb(a.parameters)([c.parameters]).l;return{o:b,s:a,l:function(b,h,k){return lb(a)(E(a.length).map(function(a){return e([Q(c,a)([b],h,k)],h,k)}),h,k)}}}}console.log("no inclusionfunction ->"+B(a)+" implemented yet; using identity...");return function(b){return{o:b,s:a,l:P}}} +function R(a){a=J(a);switch(a){case z.A:return"bool";case z.u:return"int";case z.f:return"float";case z.h:case z.K:return"vec2";case z.T:return"void";case z.color:return"vec4";case z.w:case z.line:return"vec3"}if("list"===a.type&&a.parameters===z.f)return 1==a.length?"float":"vec"+a.length;if("list"===a.type&&a.parameters===z.h)return"cvec"+a.length;if("list"===a.type&&"list"===a.parameters.type&&a.length===a.parameters.length&&a.parameters.parameters===z.f)switch(a.length){case 2:return"mat2";case 3:return"mat3"; +case 4:return"mat4"}if("list"===a.type)return"l"+a.length+"_"+R(a.parameters);console.error("No WebGL implementation for type "+B(a)+" found")}function mb(a,b){switch(b){case z.A:return R(b)+"("+a.value+")";case z.u:return""+(a.value.real|0);case z.f:return R(b)+"("+a.value.real+")";case z.h:return R(b)+"("+a.value.real+", "+a.value.imag+")";case z.color:return a=a.value.real,"vec4("+a+","+a+","+a+",1.)";default:console.error("Dont know how to paste values of Type "+B(b)+" yet.")}};var S={};function nb(a,b,c){if(!c.mark("includedfunctions",a)){for(var e in S[a])nb(S[a][e],b,c);c.add("includedfunctions",a,function(){return ka[a]})}}function O(a){return function(b,c,e){nb(a,c,e);return N(a)(b)}};function E(a){return Array.from(Array(a).keys())}function Ya(a){return 4>=a?[a]:5==a?[2,3]:Ya(a-4).concat([4])}function ob(a){var b=Xa(a),c=C(a);return 1==c&&b===z.f?Ya(a.length).map(function(a,b){return{type:z.aa(a),name:"a"+b}}):1<=c?E(a.length).map(function(b){return{type:a.parameters,name:"a"+b}}):[]}function pb(a,b){if(!L(a)){var c=R(a);b.add("structs",c,function(){return"struct "+c+" { "+ob(a).map(function(a){return pb(a.type,b)||R(a.type)+" "+a.name+";"}).join("")+"};"})}} +function qb(a,b,c){if(!L(a)){var e=a.length,f=a.parameters.length;c.add("functions","mult"+e+"_"+f,function(){return R(z.aa(e))+" mult"+e+"_"+f+"("+R(a)+" a, "+R(z.aa(f))+" b){return "+rb(e)(E(e).map(function(a){return sb(f)(["a.a"+a,"b"],b,c)}),b,c)+";}"})}} +function tb(a,b,c){if(!(L(a)&&1>=C(a))){var e=a.length,f="sum"+R(a);c.add("functions",f,function(){return R(a.parameters)+" "+f+"("+R(a)+" a){"+(R(a.parameters)+" res = "+ub(a.parameters,0)([],b,c)+";\n "+E(e).map(function(e){return"res = "+vb(a.parameters)(["res",Q(a,e)(["a",e],b,c)],b,c)+";"}).join("\n")+"\n return res;\n }")})}} +function wb(a,b,c){var e=a.length,f=a.parameters.length;c.add("functions","multc"+e+"_"+f,function(){return R(z.da(e))+" multc"+e+"_"+f+"("+R(a)+" a, "+R(z.da(f))+" b){\n return cvec"+e+"("+E(e).map(function(a){return xb(f)(["a.a"+a,"b"],b,c)})+");\n }\n "})}function yb(a,b){2<=a&&4>=a||b.add("functions","dot"+a,function(){return"float dot"+a+"(vec"+a+" a, vec"+a+" b) {\n return "+Ya(a).map(function(a,b){return"dot(a.a"+b+",b.a"+b+")"}).join("+")+"; }\n "})} +function zb(a,b){b.add("functions","cdot"+a,function(){return"vec2 cdot"+a+"(cvec"+a+" a, cvec"+a+" b) {\n return "+E(a).map(function(a){return"vec2(dot(a.a"+a+",vec2(b.a"+a+".x,-b.a"+a+".y)), dot(a.a"+a+",b.a"+a+".yx))"}).join("+\n")+";\n }\n "})} +function Ab(a,b,c){var e="add"+R(a);c.add("functions",e,function(){return R(a)+" "+e+"("+R(a)+" a, "+R(a)+" b) {\n return "+R(a)+"("+ob(a).map(function(a){return R(a.type)+"("+vb(a.type)(["a."+a.name,"b."+a.name],b,c)+")"}).join(",")+");\n }"})} +function Bb(a,b,c){var e="sub"+R(a);c.add("functions",e,function(){return R(a)+" "+e+"("+R(a)+" a, "+R(a)+" b) {\n return "+R(a)+"("+ob(a).map(function(a){return R(a.type)+"("+Cb(a.type)(["a."+a.name,"b."+a.name],b,c)+")"}).join(",")+");\n }"})}function Db(a,b,c){var e="scalarmult"+R(a);c.add("functions",e,function(){return R(a)+" "+e+"(float a, "+R(a)+" b) {\n return "+R(a)+"("+ob(a).map(function(a){return R(a.type)+"("+Eb(a.type)(["a","b."+a.name],b,c)+")"}).join(",")+");\n }"})} +function Fb(a,b,c){nb("multc",b,c);var e="cscalarmult"+R(a);c.add("functions",e,function(){return R(a)+" "+e+"(vec2 a, "+R(a)+" b) {\n return "+R(a)+"("+ob(a).map(function(a){return""+Gb(a.type)(["a","b."+a.name],b,c)}).join(",")+");\n }"})} +function Hb(a){if(a===z.h)return O("multc");if(L(a))return function(a){return T("*")([a[1],a[0]])};var b=Xa(a);if(F(b,z.f))return function(b,e,f){return qb(a,e,f)||"mult"+a.length+"_"+a.parameters.length+"("+b.join(",")+")"};if(b===z.h)return function(b,e,f){return wb(a,e,f)||"multc"+a.length+"_"+a.parameters.length+"("+b.join(",")+")"}}function sb(a){return function(b,c,e){return yb(a,e)||"dot"+(2<=a&&4>=a?"":a)+"("+b.join(",")+")"}} +function xb(a){return function(b,c,e){return zb(a,e)||"cdot"+a+"("+b.join(",")+")"}}function vb(a){return L(a)?T("+"):function(b,c,e){return Ab(a,c,e)||"add"+R(a)+"("+b.join(",")+")"}}function Cb(a){return L(a)?T("-"):function(b,c,e){return Bb(a,c,e)||"sub"+R(a)+"("+b.join(",")+")"}}function Ib(a){return H(a)&&1==C(a)?function(b,c,e){return sb(a.length)([b[0],rb(a.length)(Array(a.length).fill("1."),c,e)],c,e)}:function(b,c,e){return tb(a,c,e)||"sum"+R(a)+"("+b.join(",")+")"}} +function rb(a){if(2<=a&&4>=a)return function(b){return"vec"+a+"("+b.join(",")+")"};if(1==a)return function(a){return"float("+a.join(",")+")"};var b=0;return function(c,e,f){return pb(z.aa(a),f)||"vec"+a+"("+Ya(a).map(function(a){return"vec"+a+"("+E(a).map(function(){return++b&&c[b-1]}).join(",")+")"}).join(",")+")"}}function lb(a){var b=C(a);return L(a)?function(b){return R(a)+"("+b.join(",")+")"}:1==b&&a.parameters===z.f?rb(a.length):function(b,e,f){return pb(a,f)||R(a)+"("+b.join(",")+")"}} +function Q(a,b){var c=Xa(a);return 1==C(a)&&c===z.f?Jb(a.length,b):L(a)?function(a){return"("+a[0]+")["+b+"]"}:function(a){return"("+a[0]+").a"+b}}function ub(a,b){return L(a)?function(){return R(a)+"(float("+b+"))"}:function(c,e,f){return lb(a)+"("+ob(a).map(function(a){return ub(a.type,b)(c,e,f)}).join(",")+")"}} +function Jb(a,b){return function(c){if(1==a)return c[0];if(2<=a&&4>=a)return"("+c[0]+")["+b+"]";a:{var e=b;var f=Ya(a),h;for(h in f)if(f[h]<=e)e-=f[h];else{e={first:h,second:e};break a}console.error("Accessing index out of range");e=void 0}return"("+c[0]+").a"+e.first+"["+e.second+"]"}}function Eb(a){return L(a)?T("*"):function(b,c,e){return Db(a,c,e)||"scalarmult"+R(a)+"("+b.join(",")+")"}} +function Gb(a){return a===z.h?O("multc"):function(b,c,e){return Fb(a,c,e)||"cscalarmult"+R(a)+"("+b.join(",")+")"}}function Kb(a,b,c){var e="reverse"+R(a);c.add("functions",e,function(){return R(a)+" "+e+"("+R(a)+" a){"+(R(a.parameters)+" m;\n")+E(Math.floor(a.length/2)).map(function(e){var f=Q(a,e)(["a",e],b,c);e=Q(a,a.length-1-e)(["a",a.length-1-e],b,c);return"m = "+f+"; "+f+" = "+e+"; "+e+" = m;"}).join("\n")+"return a;\n }"})} +function Lb(a){return function(b,c,e){return Kb(a,c,e)||"reverse"+R(a)+"("+b.join(",")+")"}}function Mb(a,b,c){var e="max"+R(a);c.add("functions",e,function(){return R(a.parameters)+" "+e+"("+R(a)+" a){"+(R(a.parameters)+" m = "+Q(a,a.length-1)(["a",a.length-1],b,c)+";\n")+E(a.length-1).map(function(e){return"m = max(m,"+Q(a,e)(["a",e],b,c)+");"}).join("\n")+"return m;\n }"})}function Nb(a){return function(b,c,e){return Mb(a,c,e)||"max"+R(a)+"("+b.join(",")+")"}} +function Ob(a,b,c){var e="min"+R(a);c.add("functions",e,function(){return R(a.parameters)+" "+e+"("+R(a)+" a){"+(R(a.parameters)+" m = "+Q(a,a.length-1)(["a",a.length-1],b,c)+";\n")+E(a.length-1).map(function(e){return"m = min(m,"+Q(a,e)(["a",e],b,c)+");"}).join("\n")+"return m;\n }"})}function Pb(a){return function(b,c,e){return Ob(a,c,e)||"min"+R(a)+"("+b.join(",")+")"}} +function Qb(a,b,c){var e="transpose"+R(a),f=G(a.parameters.length,G(a.length,a.parameters.parameters));c.add("functions",e,function(){return R(f)+" "+e+"("+R(a)+" a){return "+lb(f)(E(f.length).map(function(e){return lb(f.parameters)(E(f.parameters.length).map(function(f){return Q(a.parameters,e)([Q(a,f)(["a",f],b,c),e],b,c)}),b,c)}),b,c)+";}"})}function Rb(a){return function(b,c,e){return Qb(a,c,e)||"transpose"+R(a)+"("+b.join(",")+")"}};function Sb(a){function b(a,e,k){if(1>=1;for(var h=a;hc&&(c=b.length+c),{o:a,s:b.parameters,l:Q(b,c)}):{o:a,s:b.parameters,l:function(){return console.error("try to access "+c+"-th Element of "+b.length+"-list "+JSON.stringify(a[0]))}}}return!1}; +V.mult=function(a){var b=M([[[z.u,z.u],z.u,T("*")],[[z.f,z.f],z.f,T("*")],[[z.h,z.f],z.h,T("*")],[[z.f,z.h],z.h,T("*")],[[z.h,z.h],z.h,O("multc")],[[z.Y,z.Y],z.Y,U()],[[z.Z,z.Z],z.Z,U()],[[z.$,z.$],z.$,U()],[[z.Y,z.F],z.F,U()],[[z.Z,z.J],z.J,U()],[[z.$,z.O],z.O,U()],[[z.F,z.Y],z.F,U()],[[z.J,z.Z],z.J,U()],[[z.O,z.$],z.O,U()]])(a);if(b)return b;if(2!==a.length)return!1;b=a[0];var c=a[1];if([b,c].every(function(a){return"list"===a.type&&F(a.parameters,z.f)})&&b.length===c.length)return a=K(b),L(a)? +{o:[a,a],s:z.f,l:N("dot")}:{o:[a,a],s:z.f,l:sb(b.length)};if([b,c].every(function(a){return"list"===a.type&&F(a.parameters,z.h)})&&b.length===c.length)return a=hb(b),{o:[a,a],s:z.h,l:xb(b.length)};if(H(b)&&2===C(b)&&H(c)&&1===C(c)&&b.parameters.length===c.length)return{o:[K(b),K(c)],s:z.aa(b.length),l:Hb(K(b))};if(I(b)&&2===C(b)&&I(c)&&1===C(c)&&b.parameters.length===c.length)return{o:[hb(b),hb(c)],s:z.da(b.length),l:Hb(hb(b))};for(b={H:0};2>b.H;b={V:b.V,H:b.H,ba:b.ba},b.H++){if(F(a[0^b.H],z.f)&& +(H(a[1^b.H])||I(a[1^b.H])))return b.V=K(a[1^b.H]),{o:b.H?[b.V,z.f]:[z.f,b.V],s:b.V,l:function(a){return function(b,c,e){return Eb(a.V)([b[0^a.H],b[1^a.H]],c,e)}}(b)};if(F(a[0^b.H],z.h)&&I(a[1^b.H]))return b.ba=hb(a[1^b.H]),{o:b.H?[b.ba,z.h]:[z.h,b.ba],s:b.ba,l:function(a){return function(b,c,e){return Gb(a.ba)([b[0^a.H],b[1^a.H]],c,e)}}(b)}}};V["*"]=V.mult; +V.div=function(a){var b=M([[[z.f,z.f],z.f,T("/")],[[z.f,z.h],z.h,O("divfc")],[[z.h,z.f],z.h,T("/")],[[z.h,z.h],z.h,O("divc")]])(a);return b?b:F(a[1],z.f)&&I(a[0])&&(a=K(a[0]),L(a))?{o:[a,z.f],s:a,l:T("/")}:!1};V["/"]=V.div;V.re=M([[[z.h],z.f,O("realc")]]);V.im=M([[[z.h],z.f,O("imagc")]]);V.floor=M([[[z.f],z.u,function(a){return"int(floor("+a+"))"}],[[z.h],z.h,N("floor")]]);V.round=M([[[z.f],z.u,function(a){return"int(floor("+a+"+.5))"}],[[z.h],z.h,function(a){return"floor("+a+"+vec2(.5))"}]]); +V.ceil=M([[[z.f],z.u,function(a){return"int(ceil("+a+"))"}],[[z.h],z.h,N("ceil")]]);V.mod=M([[[z.u,z.u],z.u,function(a,b){return"int("+N("mod")("float("+a[0]+"), float("+a[1]+")",b)+")"}],[[z.f,z.f],z.f,N("mod")],[[z.h,z.h],z.h,O("mod")]]);V.random=M([[[],z.f,O("random")],[[z.f],z.f,function(a,b,c){return O("random")([],b,c)+"*"+a[0]}],[[z.h],z.h,function(a,b,c){return"vec2("+O("random")([],b,c)+","+O("random")([],b,c)+")*"+a[0]}]]); +V.randomint=M([[[z.u],z.u,function(a,b,c){return"int(floor("+O("random")([],b,c)+"*float("+a[0]+")))"}],[[z.f],z.u,function(a,b,c){return"int(floor("+O("random")([],b,c)+"*floor("+a[0]+")))"}]]);V.randominteger=V.randomint;V.randombool=M([[[],z.A,function(a,b,c){return"("+O("random")([],b,c)+">.5)"}]]);V.randomnormal=M([[[],z.f,O("randomnormal")]]); +V.arctan2=M([[[z.f,z.f],z.f,function(a){return"atan("+a[1]+", "+a[0]+")"}],[[z.h,z.h],z.h,O("arctan2c")],[[z.h],z.f,O("arctan2vec2")],[[z.F],z.f,O("arctan2vec2")],[[z.da(2)],z.h,O("arctan2cvec2")]]);["red","green","blue","gray","hue"].forEach(function(a){V[a]=M([[[z.f],z.J,O(a)]])});V.grey=V.gray;V.min=function(a){var b=M([[[z.f,z.f],z.f,N("min")]])(a);if(b)return b;if(1===a.length&&1===C(a[0])&&H(a[0]))return{o:a,s:a[0].parameters,l:Pb(a[0])}}; +V.max=function(a){var b=M([[[z.u,z.u],z.u,N("max")],[[z.f,z.f],z.f,N("max")]])(a);if(b)return b;if(1===a.length&&1===C(a[0])&&H(a[0]))return{o:a,s:a[0].parameters,l:Nb(a[0])}};function Xb(a,b){if(!(1>=a))if(2==a)b.add("functions","raise2",function(){return"float raise2(float a) { return a*a; }"});else{Xb(2,b);var c=function(a,b){return 1==b?a:b&1?c(a,b-1)+"*a":"raise2("+c(a,b/2)+")"},e="raise"+a;b.add("functions",e,function(){return"float "+e+"(float a) { return "+c("a",a)+";}"})}} +function Yb(a){return function(b,c,e){return 0==a?"1.":1==a?b[0]:Xb(a,e)||"raise"+a+"("+b[0]+")"}}V.pow=function(a){if(fb(a[1])&&F(a[0],z.f)){var b=Number(a[1].value.value.real);if(0<=b)return{o:[z.f,a[1]],s:z.f,l:Yb(b)}}return M([[[z.f,z.u],z.f,O("powi")],[[z.h,z.h],z.h,O("powc")]])(a)};V["^"]=V.pow;V.re=M([[[z.h],z.f,function(a){return"("+a+").x"}]]);V.conjugate=M([[[z.h],z.h,O("conjugate")]]);V.im=M([[[z.h],z.f,function(a){return"("+a+").y"}]]); +V.genList=function(a){var b=a.length;if(0 < >= <= == !=".split(" ").forEach(function(a){V[a]=M([[[z.u,z.u],z.A,T(a)],[[z.f,z.f],z.A,T(a)]])});V["!"]=M([[[z.A],z.A,N("!")],[[z.T,z.A],z.A,function(a){return N("!")([a[1]])}]]);V.not=V["!"];V.imagergb=M([[[z.image,z.K],z.J,Zb],[[z.K,z.K,z.image,z.K],z.J,$b]]); +V.imagergba=M([[[z.image,z.K],z.O,ac],[[z.K,z.K,z.image,z.K],z.O,bc]]);V.reverse=function(a){return 1===a.length&&"list"===a[0].type?{o:a,s:a[0],l:Lb(a[0])}:!1};V.sort=function(a){return 1===a.length&&1===C(a[0])&&H(a[0])?{o:a,s:a[0],l:Ub(a[0])}:!1};V.transpose=function(a){return 1===a.length&&2<=C(a[0])?{o:a,s:G(a[0].parameters.length,G(a[0].length,a[0].parameters.parameters)),l:Rb(a[0])}:!1};V.det=M([[[z.Y],z.f,O("det2")],[[z.Z],z.f,O("det3")],[[z.$],z.f,O("det4")],[[z.w,z.w,z.w],z.f,O("det3v")]]); +Object.freeze(V);S.powc=["expc","multc","logc"];S.sqrtc=["expc","multc","logc"];S.arccosc=["multc","negc","sqrtc","addc","logc"];S.arcsinc=["multc","negc","sqrtc","addc","logc"];S.tanc=["sinc","cosc","divc"];S.arctanc=["logc","addc","multc","subc"];S.arctan2c=["logc","divc","sqrtc","multc"];S.arctan2vec2c=["arctan2c"];S.hue=["hsv2rgb"];S.randomnormal=["random"];S.subpoints=["dehomogenize"];S.addpoints=["dehomogenize"];Object.freeze(S);function Ua(a){this.i={};this.D={};this.j={};this.R=0;this.B={};this.C=a;this.N={}}Ua.prototype.add=function(a,b,c){this.mark(a,b);this.j[a].ia[b]||(this.j[a].ia[b]=c(),this.j[a].ga[b]=!0,this.j[a].order.push(b))};Ua.prototype.mark=function(a,b){this.j[a]||(this.j[a]={order:[],ga:{},ia:{}});var c=this.j[a].ga[b]||!1;this.j[a].ga[b]=!0;return c};function cc(a,b){return a.j[b]?a.j[b].order.map(function(c){return a.j[b].ia[c]}).join("\n"):"\n"} +function W(a,b,c,e){if(jb(c,e))return b;if(F(c,e)){if("constant"===c.type)return mb(c.value,e);var f=kb(e)([c]);if(!f)return console.error("cannot find an implementation for "+B(c)+" -> "+B(e)+", using identity"),b;e=f.l;return e(W(a,b,c,f.o[0]),{},a)}console.error(B(c)+" is no subtype of "+B(e)+" (trying to cast the term "+b+")");return b}function X(a,b,c){a.i[b]||(a.i[b]={});a.i[b].S||(a.i[b].S=[]);a.i[b].v||(a.i[b].v=!1);a.hasOwnProperty("global")||(a.i[b].global=c)} +function dc(a,b){var c=b.I;if(b.isuniform)return a.D[b.uvariable].type;if("variable"===b.ctype)return b=b.name,b=c[b]||b,a.i[b].v;if("function"===b.ctype&&a.B.hasOwnProperty(b.oper))return a.i[c[b.oper]].v;if("number"===b.ctype)return Za(b);if("void"===b.ctype)return z.T;if("field"===b.ctype){a=J(Y(a,b.obj));if(1==b.key.length){if("list"===a.type)return a.parameters;if(F(a,z.w))return z.f}else if("xy"==b.key&&F(a,z.w))return z.F;if(!a)return!1}else{if("string"===b.ctype)return z.image;if("function"=== +b.ctype||"infix"===b.ctype){c=Array(b.args.length);for(var e=!0,f=0;fb.R)b.na=dc(a,b),b.R=a.R;return b.na} +function ec(a,b,c){function e(a,b,c){var e={},f;for(f in a)e[f]=a[f];a=za();X(l,a,!1);h[a].v=c;h[a].oa=!0;e[b]=a;return e}function f(a,b,c,v){a.I=b;for(var p in a.args){var q=v||"repeat$2"===a.oper&&0==p||"repeat$3"===a.oper&&0==p||"_"===a.oper&&1==p,u=b;-1!==["repeat","forall","apply"].indexOf(y(a.oper))&&(1==p?u="repeat$2"===a.oper?e(b,"#",z.u):"repeat$3"===a.oper?e(b,a.args[1].name,z.u):"forall$2"===a.oper||"apply$2"===a.oper?e(b,"#",!1):"forall$3"===a.oper||"apply$3"===a.oper?e(b,a.args[1].name, +!1):b:2==p&&(u=a.args[1].I));f(a.args[p],u,c,q)}"field"===a.ctype&&f(a.obj,b,c,v);"variable"===a.ctype&&(p=a.name,p=b[p]||p,v&&l.i[p]&&(l.i[p].W=!0));if("="===a.oper)v=a.args[0].name,v=b[v]||v,X(l,v,!0),h[v].S.push(a.args[1]);else if(a.oper&&"regional"===y(a.oper)&&"global"!=c)for(var ra in a.args){v=a.args[ra].name;var sa=za();b[v]=sa;k[c].i||(k[c].i=[]);k[c].i.push(sa);X(l,sa,!1)}else if("forall$2"===a.oper||"apply$2"===a.oper||"forall$3"===a.oper||"apply$3"===a.oper)h[2===a.args.length?a.args[1].I["#"]: +a.args[2].I[a.args[1].name]].S.push({ctype:"infix",oper:"_",args:[a.args[0],{ctype:"number",value:{real:1,imag:0}}],I:a.args[0].I});else if("function"===a.ctype&&k.hasOwnProperty(a.oper)){c=a.oper;ra=c.replace("$","_");X(l,ra,!1);b[c]=ra;b={};for(sa in k[c].arglist)p=k[c].arglist[sa].name,q=ra+"_"+p,b[p]=q,X(l,q,!1),h[q].S.push(a.args[sa]);k[c].qa||(k[c].qa=!0,f(k[c].body,b,c,v),h[ra].S.push(k[c].body))}}var h=a.i,k=a.B,l=a;f(b,c,"global",!1)} +function fc(a,b){function c(a){if(a.hasOwnProperty("dependsOnPixel"))return a.dependsOnPixel;if("variable"===a.ctype){var b=a.name;b=a.I[b]||b;return k[b]?a.dependsOnPixel=!0:a.dependsOnPixel=!1}b="random randomint randominteger randombool randomnormal verbatimglsl".split(" ");if("function"===a.ctype&&-1!==b.indexOf(y(a.oper)))return a.dependsOnPixel=!0;if("repeat$2"===a.oper||"forall$2"===a.oper||"apply$2"===a.oper)return c(a.args[1])?(k[a.args[1].I["#"]]=!0,a.dependsOnPixel=!0):a.dependsOnPixel= +!1;if("repeat$3"===a.oper||"forall$3"===a.oper||"apply$3"===a.oper)return c(a.args[2])?(k[a.args[2].I[a.args[1].name]]=!0,a.args[1].dependsOnPixel=!0,a.dependsOnPixel=!0):a.dependsOnPixel=!1;for(var e in a.args)if(c(a.args[e]))return a.dependsOnPixel=!0;return"function"===a.ctype&&h.hasOwnProperty(a.oper)&&c(h[a.oper].body)?a.dependsOnPixel=!0:"field"===a.ctype?a.dependsOnPixel=c(a.obj):a.dependsOnPixel=!1}function e(a,b){if(c(a)){for(var f in a.args)e(a.args[f],b||"repeat$2"===a.oper&&0==f||"repeat$3"=== +a.oper&&0==f||"_"===a.oper&&1==f);"field"===a.ctype&&e(a.obj,b);"function"===a.ctype&&h.hasOwnProperty(a.oper)&&(a=a.oper,q.hasOwnProperty(a)||(q[a]=!0,e(h[a].body,b)))}else if("boolean"!==a.ctype&&"number"!==a.ctype&&"void"!==a.ctype){".."===a.oper&&(b=!0);f=!1;var k;for(k in u)if(!f&&wa(a,u[k].U)){f=!0;var l=k}f||(l=za(),u[l]={U:a,type:!1,W:b});u[l].W=u[l].W||b;a.isuniform=!0;a.uvariable=l}}var f=a.i,h=a.B,k={cgl_pixel:!0,"cgl_pixel.x":!0,"cgl_pixel.y":!0},l;for(l in f)if(1<=f[l].S.length||f[l].oa)k[l]= +!0;c(b);var q={"":!0},u=a.D;e(b,!1)}function gc(a,b){if("function"===b.ctype&&!a.B.hasOwnProperty(b.oper)&&null!==a.C.getMyfunction(b.oper)){var c=b.oper;a.B[c]=va(a.C.getMyfunction(c));gc(a,a.B[c].body)}for(var e in b.args)gc(a,b.args[e])} +function hc(a,b){function c(a){var b={},c;for(c in a)b[c]=a[c];return b}function e(a,b){"repeat$2"===a.oper||"forall$2"===a.oper||"apply$2"===a.oper?(b=c(b),b["#"]=!0):"repeat$3"===a.oper||"forall$3"===a.oper||"apply$3"===a.oper?(b=c(b),b[a.args[1].name]=!0):"="===a.oper&&(b[a.args[0].name]=!0);for(var f in a.args)e(a.args[f],b);"field"===a.ctype&&e(a.obj,b);"variable"===a.ctype&&(a=a.name,b[a]||(h[a]=!0))}var f={},h={};e(b,{});X(a,"cgl_pixel",!1);a.i.cgl_pixel.v=z.F;if(1==Object.keys(h).length)f[Object.keys(h)[0]]= +"cgl_pixel";else if(h["#"])f["#"]="cgl_pixel";else if(h.x&&h.y)X(a,"cgl_pixel.x",!1),a.i["cgl_pixel.x"].v=z.f,f.x="cgl_pixel.x",X(a,"cgl_pixel.y",!1),a.i["cgl_pixel.y"].v=z.f,f.y="cgl_pixel.y";else{b=[];for(var k in h)a.C.nada==a.C.evaluateAndVal({ctype:"variable",name:k})&&b.push(k);1==b.length?f[b[0]]="cgl_pixel":h.p?f.p="cgl_pixel":h.z&&(f.z="cgl_pixel")}"cgl_pixel"===f.z&&(a.i.cgl_pixel.v=z.h);return f} +function Z(a,b,c){var e=Y(a,b);if(b.isuniform)return b=b.uvariable,c?{code:"",m:"constant"===e.type?mb(e.value,J(e)):b}:{code:""};if(";"===b.oper){e={m:""};for(var f="",h=b.args.length-1,k=h;0<=k;k--)"void"===b.args[k].ctype&&(h=k-1);for(k=0;k<=h;k++)e=Z(a,b.args[k],c&&k===h),f+=e.code;return c?{code:f,m:e.m}:{code:f}}if("constant"===e.type)return c?{m:mb(e.value,J(e)),code:""}:{code:""};if("="===b.oper)return e=Z(a,b.args[1],!0),b=Z(a,b.args[0],!0).m+" = "+W(a,e.m,Y(a,b.args[1]),Y(a,b.args[0])), +c?{code:e.code,m:b}:{code:e.code+b+";\n"};if("repeat$2"===b.oper||"repeat$3"===b.oper){f=Z(a,b.args[0],!0);if("constant"!==Y(a,b.args[0]).type)return console.error("repeat possible only for fixed constant number in GLSL"),!1;e="repeat$2"===b.oper?b.args[1].I["#"]:b.args[2].I[b.args[1].name];f=Number(f.m);h="";if("constant"===a.i[e].v.type)for(k=1;k<=f;k++){a.i[e].v=eb(k);a.R++;var l=Z(a,b.args["repeat$2"===b.oper?1:2],k===f&&c);h+=l.code;if(k===f&&c)return{code:h,m:l.m}}else if(k="",l=Z(a,b.args["repeat$2"=== +b.oper?1:2],c),b=Y(a,b.args["repeat$2"===b.oper?1:2]),c&&(k=za(),a.i[k]||(X(a,k,!0),a.i[k].v=b)),h=h+("for(int "+e+"=1; "+e+" <= "+f+"; "+e+"++) {\n")+l.code,c&&(h+=k+" = "+l.m+";\n"),h+="}\n",c)return{code:h,m:k};return{code:h}}if("forall$2"===b.oper||"forall$3"===b.oper||"apply$2"===b.oper||"apply$3"===b.oper){var q=Y(a,b.args[0]);if("list"!==q.type&&("constant"!==q.type||"list"!==q.value.ctype))return console.error(b.oper+" only possible for lists"),!1;f=q.length||q.value.value.length;k=2===b.args.length? +b.args[1].I["#"]:b.args[2].I[b.args[1].name];var u=a.i[k].v,p=l="";c&&(p=za(),l+=R(e)+" "+p+";\n");"list"===e.type&&pb(e,a);if("constant"===a.i[k].v.type||"constant"===q.type)for(q=a.C.evaluateAndVal(b.args[0]),u=0;ua?0:1 { + try { + var $value = $(value) + let drawscript = $value.text(); + let canvas = document.createElement("div") + let debug = document.createElement("div") + var $ele = $(value).closest("pre")[0] + + // remove current children (to remove the pre-formatted code text) + while ($ele.lastChild) + $ele.removeChild($ele.lastChild) + + // append debug output (error messages) and canvas + $ele.appendChild(debug) + $ele.appendChild(canvas) + $ele.style.height = "30em"; + + console.log("cindyscript code is:", drawscript, $ele[0]) + console.error = (err) => { + debug.innerText = err + $ele.removeChild(canvas) + } + CindyJS({ + scripts: {draw: drawscript}, + autoplay: true, + ports: [{ + element: canvas, + fill: "parent", + transform: [{ + visibleRect: [0, 1, 1, 0] + }] + }] + }); + + console.log("the cindy render hook was executed!") + } catch (err) { + $value.unwrap() + $value.parent().append(`
${escapeHTML(err)}
`) + console.warn(err) + } + }) // abc.js const abcs = view.find('div.abc.raw').removeClass('raw') abcs.each((key, value) => { diff --git a/public/views/hedgedoc/footer.ejs b/public/views/hedgedoc/footer.ejs index 51d47221..ebe7ab6d 100644 --- a/public/views/hedgedoc/footer.ejs +++ b/public/views/hedgedoc/footer.ejs @@ -20,10 +20,13 @@ + <%- include('../build/index-scripts') %> <% } else { %> + + <%- include('../build/index-pack-scripts') %> <% } %> -- cgit v1.2.3