varri-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ /*! For license information please see fornac.js.LICENSE.txt */
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("d3")):"function"==typeof define&&define.amd?define(["d3"],e):"object"==typeof exports?exports.fornac=e(require("d3")):t.fornac=e(t.d3)}(self,(function(t){return(()=>{var e={953:(t,e,n)=>{"use strict";n.r(e),n.d(e,{Connection:()=>i});var r=n(724),o=n(75);function i(){this.loop=new r.r,this.region=new o.y,this.start=null,this.end=null,this.xrad=null,this.yrad=null,this.angle=null,this.extruded=null,this.broken=null,this._isNull=!1}i.prototype.isNull=function(){return this._isNull},i.prototype.setNull=function(t){this._isNull=t},i.prototype.getLoop=function(){return this.loop},i.prototype.setLoop=function(t){this.loop=t},i.prototype.getRegion=function(){return this.region},i.prototype.setRegion=function(t){this.region=t},i.prototype.getStart=function(){return this.start},i.prototype.setStart=function(t){this.start=t},i.prototype.getEnd=function(){return this.end},i.prototype.setEnd=function(t){this.end=t},i.prototype.getXrad=function(){return this.xrad},i.prototype.setXrad=function(t){this.xrad=t},i.prototype.getYrad=function(){return this.yrad},i.prototype.setYrad=function(t){this.yrad=t},i.prototype.getAngle=function(){return this.angle},i.prototype.setAngle=function(t){this.angle=t},i.prototype.isExtruded=function(){return this.extruded},i.prototype.setExtruded=function(t){this.extruded=t},i.prototype.isBroken=function(){return this.broken},i.prototype.setBroken=function(t){this.broken=t}},724:(t,e,n)=>{"use strict";n.d(e,{r:()=>o});var r=n(953);function o(){this.nconnection=null,this.connections=[],this._connections=[],this.number=null,this.depth=null,this.mark=null,this.x=null,this.y=null,this.radius=null}o.prototype.getNconnection=function(){return this.nconnection},o.prototype.setNconnection=function(t){this.nconnection=t},o.prototype.setConnection=function(t,e){null!=e?this._connections[t]=e:(this._connections[t]||(this._connections[t]=new r.Connection),this._connections[t].setNull(!0))},o.prototype.getConnection=function(t){var e=n(953);this._connections[t]||(this._connections[t]=new e);var r=this._connections[t];return r.isNull()?null:r},o.prototype.addConnection=function(t,e){this._connections.push(e)},o.prototype.getNumber=function(){return this.number},o.prototype.setNumber=function(t){this.number=t},o.prototype.getDepth=function(){return this.depth},o.prototype.setDepth=function(t){this.depth=t},o.prototype.isMark=function(){return this.mark},o.prototype.setMark=function(t){this.mark=t},o.prototype.getX=function(){return this.x},o.prototype.setX=function(t){this.x=t},o.prototype.getY=function(){return this.y},o.prototype.setY=function(t){this.y=t},o.prototype.getRadius=function(){return this.radius},o.prototype.setRadius=function(t){this.radius=t}},75:(t,e,n)=>{"use strict";function r(){this._start1=null,this._end1=null,this._start2=null,this._end2=null}n.d(e,{y:()=>r}),r.prototype.getStart1=function(){return this._start1},r.prototype.setStart1=function(t){this._start1=t},r.prototype.getEnd1=function(){return this._end1},r.prototype.setEnd1=function(t){this._end1=t},r.prototype.getStart2=function(){return this._start2},r.prototype.setStart2=function(t){this._start2=t},r.prototype.getEnd2=function(){return this._end2},r.prototype.setEnd2=function(t){this._end2=t}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,i=u(t),s=i[0],a=i[1],l=new o(function(t,e,n){return 3*(e+n)/4-n}(0,s,a)),c=0,f=a>0?s-4:s;for(n=0;n<f;n+=4)e=r[t.charCodeAt(n)]<<18|r[t.charCodeAt(n+1)]<<12|r[t.charCodeAt(n+2)]<<6|r[t.charCodeAt(n+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===a&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,l[c++]=255&e),1===a&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=16383,a=0,u=r-o;a<u;a+=s)i.push(l(t,a,a+s>u?u:a+s));return 1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),i.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=i.length;s<a;++s)n[s]=i[s],r[i.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},764:(t,e,n)=>{"use strict";const r=n(742),o=n(645),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return l(t,e,n)}function l(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|g(t,e);let r=a(n);const o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return h(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return h(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return u.from(r,e,n);const o=function(t){if(u.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?a(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return c(t),a(t<0?0:0|p(t))}function d(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function h(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,u.prototype),r}function p(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(t).length;default:if(o)return r?-1:$(t).length;e=(""+e).toLowerCase(),o=!0}}function y(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,n);case"utf8":case"utf-8":return L(this,e,n);case"ascii":return _(this,e,n);case"latin1":case"binary":return M(this,e,n);case"base64":return N(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function m(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function b(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),H(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=u.from(e,r)),u.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,o){let i,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let r=-1;for(i=n;i<a;i++)if(l(t,i)===l(e,-1===r?0:i-r)){if(-1===r&&(r=i),i-r+1===u)return r*s}else-1!==r&&(i-=i-r),r=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){let n=!0;for(let r=0;r<u;r++)if(l(t,i+r)!==l(e,r)){n=!1;break}if(n)return i}return-1}function k(t,e,n,r){n=Number(n)||0;const o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;const i=e.length;let s;for(r>i/2&&(r=i/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(H(r))return s;t[n+s]=r}return s}function x(t,e,n,r){return G($(e,t.length-n),t,n,r)}function w(t,e,n,r){return G(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return G(W(e),t,n,r)}function A(t,e,n,r){return G(function(t,e){let n,r,o;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function N(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function L(t,e,n){n=Math.min(t.length,n);const r=[];let o=e;for(;o<n;){const e=t[o];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=n){let n,r,a,u;switch(s){case 1:e<128&&(i=e);break;case 2:n=t[o+1],128==(192&n)&&(u=(31&e)<<6|63&n,u>127&&(i=u));break;case 3:n=t[o+1],r=t[o+2],128==(192&n)&&128==(192&r)&&(u=(15&e)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:n=t[o+1],r=t[o+2],a=t[o+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(u=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),o+=s}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=T));return n}(r)}e.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,n){return l(t,e,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,n){return function(t,e,n){return c(t),t<=0?a(t):void 0!==e?"string"==typeof n?a(t).fill(e,n):a(t).fill(e):a(t)}(t,e,n)},u.allocUnsafe=function(t){return f(t)},u.allocUnsafeSlow=function(t){return f(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let o=0,i=Math.min(n,r);o<i;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=u.allocUnsafe(e);let o=0;for(n=0;n<t.length;++n){let e=t[n];if(J(e,Uint8Array))o+e.length>r.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(r,o)):Uint8Array.prototype.set.call(r,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,o)}o+=e.length}return r},u.byteLength=g,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)m(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?L(this,0,t):y.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,n,r,o){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;let i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0);const a=Math.min(i,s),l=this.slice(r,o),c=t.slice(e,n);for(let t=0;t<a;++t)if(l[t]!==c[t]){i=l[t],s=c[t];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return b(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return b(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return k(this,t,e,n);case"utf8":case"utf-8":return x(this,t,e,n);case"ascii":case"latin1":case"binary":return w(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function _(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function M(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function S(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let r=e;r<n;++r)o+=K[t[r]];return o}function B(t,e,n){const r=t.slice(e,n);let o="";for(let t=0;t<r.length-1;t+=2)o+=String.fromCharCode(r[t]+256*r[t+1]);return o}function I(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,n,r,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function R(t,e,n,r,o){F(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i>>=8,t[n++]=i,i>>=8,t[n++]=i,i>>=8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function C(t,e,n,r,o){F(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i>>=8,t[n+6]=i,i>>=8,t[n+5]=i,i>>=8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function U(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function O(t,e,n,r,i){return e=+e,n>>>=0,i||U(t,0,n,4),o.write(t,e,n,r,23,4),n+4}function X(t,e,n,r,i){return e=+e,n>>>=0,i||U(t,0,n,8),o.write(t,e,n,r,52,8),n+8}u.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,u.prototype),r},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||I(t,e,this.length);let r=this[t],o=1,i=0;for(;++i<e&&(o*=256);)r+=this[t+i]*o;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||I(t,e,this.length);let r=this[t+--e],o=1;for(;e>0&&(o*=256);)r+=this[t+--e]*o;return r},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(o)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(o)})),u.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||I(t,e,this.length);let r=this[t],o=1,i=0;for(;++i<e&&(o*=256);)r+=this[t+i]*o;return o*=128,r>=o&&(r-=Math.pow(2,8*e)),r},u.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||I(t,e,this.length);let r=e,o=1,i=this[t+--r];for(;r>0&&(o*=256);)i+=this[t+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||I(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){t>>>=0,e||I(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||I(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||I(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||I(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||I(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||P(this,t,e,n,Math.pow(2,8*n)-1,0);let o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||P(this,t,e,n,Math.pow(2,8*n)-1,0);let o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return R(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);P(this,t,e,n,r-1,-r)}let o=0,i=1,s=0;for(this[e]=255&t;++o<n&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+n},u.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);P(this,t,e,n,r-1,-r)}let o=n-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return R(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,n){return O(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return O(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return X(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return X(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{const i=u.isBuffer(t)?t:u.from(t,r),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=i[o%s]}return this};const Y={};function q(t,e,n){Y[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function D(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function F(t,e,n,r,o,i){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(i+1)}${r}`:`>= -(2${r} ** ${8*(i+1)-1}${r}) and < 2 ** ${8*(i+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new Y.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,n){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||V(e,t.length-(n+1))}(r,o,i)}function z(t,e){if("number"!=typeof t)throw new Y.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,n){if(Math.floor(t)!==t)throw z(t,n),new Y.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new Y.ERR_BUFFER_OUT_OF_BOUNDS;throw new Y.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=D(String(n)):"bigint"==typeof n&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function $(t,e){let n;e=e||1/0;const r=t.length;let o=null;const i=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function W(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const K=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},274:t=>{t.exports={}},977:t=>{t.exports={nodeStrokeWidth:"0.8",directionArrowSize:"6",directionArrowWidth:"0.7",node:"fornac-node",directionArrow:"fornac-directionArrow",plot:"fornac-plot",selectedNode:"fornac-selectedNode",nodeLabel:"fornac-nodeLabel",link:"fornac-link",plotLabel:"fornac-plotLabel",transparent:"fornac-transparent",dragLine:"fornac-dragLine",mouseEventHelper:"fornac-mouseEventHelper"}},645:(t,e)=>{e.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,l=u>>1,c=-7,f=n?o-1:0,d=n?-1:1,h=t[e+f];for(f+=d,i=h&(1<<-c)-1,h>>=-c,c+=a;c>0;i=256*i+t[e+f],f+=d,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=r;c>0;s=256*s+t[e+f],f+=d,c-=8);if(0===i)i=1-l;else{if(i===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=l}return(h?-1:1)*s*Math.pow(2,i-r)},e.write=function(t,e,n,r,o,i){var s,a,u,l=8*i-o-1,c=(1<<l)-1,f=c>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,p=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?d/u:d*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=c?(a=0,s=c):s+f>=1?(a=(e*u-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[n+h]=255&a,h+=p,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;t[n+h]=255&s,h+=p,s/=256,l-=8);t[n+h-p]|=128*g}},386:(t,e,n)=>{t.exports=n(861)},861:(t,e,n)=>{var r=n(764).Buffer,o=n(614);e.encode=function(t){var e=o.parse(t);return r.from(e).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").substring(0,22)},e.decode=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/")+"==";return o.stringify(r.from(e,"base64"))},e.v4=function(){return o.v4(null,r.alloc(16)).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").substring(0,22)},e.nice=function(){var t=o.v4(null,r.alloc(16));return t[0]=127&t[0],t.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").substring(0,22)}},614:(t,e,n)=>{"use strict";var r;n.r(e),n.d(e,{NIL:()=>S,parse:()=>y,stringify:()=>c,v1:()=>g,v3:()=>N,v4:()=>L,v5:()=>M,validate:()=>a,version:()=>B});var o=new Uint8Array(16);function i(){if(!r&&!(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(o)}const s=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,a=function(t){return"string"==typeof t&&s.test(t)};for(var u=[],l=0;l<256;++l)u.push((l+256).toString(16).substr(1));const c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!a(n))throw TypeError("Stringified UUID is invalid");return n};var f,d,h=0,p=0;const g=function(t,e,n){var r=e&&n||0,o=e||new Array(16),s=(t=t||{}).node||f,a=void 0!==t.clockseq?t.clockseq:d;if(null==s||null==a){var u=t.random||(t.rng||i)();null==s&&(s=f=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=d=16383&(u[6]<<8|u[7]))}var l=void 0!==t.msecs?t.msecs:Date.now(),g=void 0!==t.nsecs?t.nsecs:p+1,y=l-h+(g-p)/1e4;if(y<0&&void 0===t.clockseq&&(a=a+1&16383),(y<0||l>h)&&void 0===t.nsecs&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=l,p=g,d=a;var m=(1e4*(268435455&(l+=122192928e5))+g)%4294967296;o[r++]=m>>>24&255,o[r++]=m>>>16&255,o[r++]=m>>>8&255,o[r++]=255&m;var b=l/4294967296*1e4&268435455;o[r++]=b>>>8&255,o[r++]=255&b,o[r++]=b>>>24&15|16,o[r++]=b>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=s[v];return e||c(o)},y=function(t){if(!a(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=255&e,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=255&e,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=255&e,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=255&e,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=255&e,n};function m(t,e,n){function r(t,r,o,i){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}(t)),"string"==typeof r&&(r=y(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+t.length);if(s.set(r),s.set(t,r.length),(s=n(s))[6]=15&s[6]|e,s[8]=63&s[8]|128,o){i=i||0;for(var a=0;a<16;++a)o[i+a]=s[a];return o}return c(s)}try{r.name=t}catch(t){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function b(t){return 14+(t+64>>>9<<4)+1}function v(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function k(t,e,n,r,o,i){return v((s=v(v(e,t),v(r,i)))<<(a=o)|s>>>32-a,n);var s,a}function x(t,e,n,r,o,i,s){return k(e&n|~e&r,t,e,o,i,s)}function w(t,e,n,r,o,i,s){return k(e&r|n&~r,t,e,o,i,s)}function E(t,e,n,r,o,i,s){return k(e^n^r,t,e,o,i,s)}function A(t,e,n,r,o,i,s){return k(n^(e|~r),t,e,o,i,s)}const N=m("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return function(t){for(var e=[],n=32*t.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=t[o>>5]>>>o%32&255,s=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);e.push(s)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[b(e)-1]=e;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,s=0;s<t.length;s+=16){var a=n,u=r,l=o,c=i;n=x(n,r,o,i,t[s],7,-680876936),i=x(i,n,r,o,t[s+1],12,-389564586),o=x(o,i,n,r,t[s+2],17,606105819),r=x(r,o,i,n,t[s+3],22,-1044525330),n=x(n,r,o,i,t[s+4],7,-176418897),i=x(i,n,r,o,t[s+5],12,1200080426),o=x(o,i,n,r,t[s+6],17,-1473231341),r=x(r,o,i,n,t[s+7],22,-45705983),n=x(n,r,o,i,t[s+8],7,1770035416),i=x(i,n,r,o,t[s+9],12,-1958414417),o=x(o,i,n,r,t[s+10],17,-42063),r=x(r,o,i,n,t[s+11],22,-1990404162),n=x(n,r,o,i,t[s+12],7,1804603682),i=x(i,n,r,o,t[s+13],12,-40341101),o=x(o,i,n,r,t[s+14],17,-1502002290),n=w(n,r=x(r,o,i,n,t[s+15],22,1236535329),o,i,t[s+1],5,-165796510),i=w(i,n,r,o,t[s+6],9,-1069501632),o=w(o,i,n,r,t[s+11],14,643717713),r=w(r,o,i,n,t[s],20,-373897302),n=w(n,r,o,i,t[s+5],5,-701558691),i=w(i,n,r,o,t[s+10],9,38016083),o=w(o,i,n,r,t[s+15],14,-660478335),r=w(r,o,i,n,t[s+4],20,-405537848),n=w(n,r,o,i,t[s+9],5,568446438),i=w(i,n,r,o,t[s+14],9,-1019803690),o=w(o,i,n,r,t[s+3],14,-187363961),r=w(r,o,i,n,t[s+8],20,1163531501),n=w(n,r,o,i,t[s+13],5,-1444681467),i=w(i,n,r,o,t[s+2],9,-51403784),o=w(o,i,n,r,t[s+7],14,1735328473),n=E(n,r=w(r,o,i,n,t[s+12],20,-1926607734),o,i,t[s+5],4,-378558),i=E(i,n,r,o,t[s+8],11,-2022574463),o=E(o,i,n,r,t[s+11],16,1839030562),r=E(r,o,i,n,t[s+14],23,-35309556),n=E(n,r,o,i,t[s+1],4,-1530992060),i=E(i,n,r,o,t[s+4],11,1272893353),o=E(o,i,n,r,t[s+7],16,-155497632),r=E(r,o,i,n,t[s+10],23,-1094730640),n=E(n,r,o,i,t[s+13],4,681279174),i=E(i,n,r,o,t[s],11,-358537222),o=E(o,i,n,r,t[s+3],16,-722521979),r=E(r,o,i,n,t[s+6],23,76029189),n=E(n,r,o,i,t[s+9],4,-640364487),i=E(i,n,r,o,t[s+12],11,-421815835),o=E(o,i,n,r,t[s+15],16,530742520),n=A(n,r=E(r,o,i,n,t[s+2],23,-995338651),o,i,t[s],6,-198630844),i=A(i,n,r,o,t[s+7],10,1126891415),o=A(o,i,n,r,t[s+14],15,-1416354905),r=A(r,o,i,n,t[s+5],21,-57434055),n=A(n,r,o,i,t[s+12],6,1700485571),i=A(i,n,r,o,t[s+3],10,-1894986606),o=A(o,i,n,r,t[s+10],15,-1051523),r=A(r,o,i,n,t[s+1],21,-2054922799),n=A(n,r,o,i,t[s+8],6,1873313359),i=A(i,n,r,o,t[s+15],10,-30611744),o=A(o,i,n,r,t[s+6],15,-1560198380),r=A(r,o,i,n,t[s+13],21,1309151649),n=A(n,r,o,i,t[s+4],6,-145523070),i=A(i,n,r,o,t[s+11],10,-1120210379),o=A(o,i,n,r,t[s+2],15,718787259),r=A(r,o,i,n,t[s+9],21,-343485551),n=v(n,a),r=v(r,u),o=v(o,l),i=v(i,c)}return[n,r,o,i]}(function(t){if(0===t.length)return[];for(var e=8*t.length,n=new Uint32Array(b(e)),r=0;r<e;r+=8)n[r>>5]|=(255&t[r/8])<<r%32;return n}(t),8*t.length))})),L=function(t,e,n){var r=(t=t||{}).random||(t.rng||i)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=r[o];return e}return c(r)};function T(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:case 3:return e^n^r;case 2:return e&n^e&r^n&r}}function _(t,e){return t<<e|t>>>32-e}const M=m("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var r=unescape(encodeURIComponent(t));t=[];for(var o=0;o<r.length;++o)t.push(r.charCodeAt(o))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var i=t.length/4+2,s=Math.ceil(i/16),a=new Array(s),u=0;u<s;++u){for(var l=new Uint32Array(16),c=0;c<16;++c)l[c]=t[64*u+4*c]<<24|t[64*u+4*c+1]<<16|t[64*u+4*c+2]<<8|t[64*u+4*c+3];a[u]=l}a[s-1][14]=8*(t.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(t.length-1)&4294967295;for(var f=0;f<s;++f){for(var d=new Uint32Array(80),h=0;h<16;++h)d[h]=a[f][h];for(var p=16;p<80;++p)d[p]=_(d[p-3]^d[p-8]^d[p-14]^d[p-16],1);for(var g=n[0],y=n[1],m=n[2],b=n[3],v=n[4],k=0;k<80;++k){var x=Math.floor(k/20),w=_(g,5)+T(x,y,m,b)+v+e[x]+d[k]>>>0;v=b,b=m,m=_(y,30)>>>0,y=g,g=w}n[0]=n[0]+g>>>0,n[1]=n[1]+y>>>0,n[2]=n[2]+m>>>0,n[3]=n[3]+b>>>0,n[4]=n[4]+v>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),S="00000000-0000-0000-0000-000000000000",B=function(t){if(!a(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}},990:e=>{"use strict";e.exports=t}},n={};function o(t){var r=n[t];if(void 0!==r)return r.exports;var i=n[t]={exports:{}};return e[t](i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");n.length&&(t=n[n.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t})();var i={};return(()=>{"use strict";o.r(i),o.d(i,{ColorScheme:()=>p,FornaContainer:()=>L,RNAUtilities:()=>d,rnaPlot:()=>T,rnaTreemap:()=>_});var t=o(977),e=o.n(t),n=o(990),s=o.n(n),a=o(386);o(274);const u=o.p+"02188894d5236b1517df3210b79c2a7f.svg";function l(t,e){var n,r,o=!1,i=a.nice(),c=null,f="right",d=null,h=null;return"function"==typeof e?n=e:(n=(e=e||{}).onOpen,r=e.onClose),"rootElement"in e&&(c=e.rootElement),"pos"in e&&(d=e.pos),"orientation"in e&&(f=e.orientation),"parentStart"in e&&(h=e.parentStart),s().selectAll(".d3-context-menu-"+i).data([1]).enter().append("div").classed("d3-context-menu",!0).classed("d3-context-menu-"+i,!0),s().select("body").on("click.d3-context-menu-"+i,(function(){o?o=!1:(console.log("body click close"),s().select(".d3-context-menu-"+i).style("display","none"),f="right",r&&r())})),function(e,a){var p=arguments.length>2&&void 0!==arguments[2]&&arguments[2],g=this,y=null,m=this;y=null==c?s().mouse(this):s().mouse(c);var b=null;o=p,s().selectAll(".d3-context-menu-"+i).html("");var v=s().selectAll(".d3-context-menu-"+i).on("contextmenu",(function(t){console.log("context-menu close"),s().select(".d3-context-menu-"+i).style("display","none"),f="right",s().event.preventDefault(),s().event.stopPropagation()})).append("ul");if(v.selectAll("li").data("function"==typeof t?t(e):t).enter().append("li").attr("class",(function(t){console.log("d:",t);var e="";return t.divider&&(e+=" is-divider"),t.disabled&&(e+=" is-disabled"),t.action||(e+=" is-header"),"children"in t&&(e+=" d3-context-menu-recursive"),e})).html((function(t){return t.divider?"<hr>":(t.title||console.error("No title attribute set. Check the spelling of your options."),"string"==typeof t.title?t.title:t.title(e))})).on("click",(function(t,n){t.disabled||t.action&&(t.action(g,e,a,y),console.log("click close"),s().selectAll(".d3-context-menu").style("display","none"),f="right",r&&r())})).on("mouseenter",(function(t,n){if(s().select(this).classed("d3-context-menu-selected",!0),null!=b){if(s().select(".d3-context-menu-"+i).selectAll("li").classed("d3-context-menu-selected",!1),void 0===t.children)return console.log("no children close"),s().select(".d3-context-menu-"+b).style("display","none"),void(b=null);if(t.childUid==b)return;console.log("open different child menu close"),s().select(".d3-context-menu-"+b).style("display","none"),b=null}if(void 0!==t.children){var r=this.getBoundingClientRect(),o=null;o=l(t.children,"left"==f?{rootElement:m,pos:[r.left+window.pageXOffset,r.top-2+window.pageYOffset],orientation:"left"}:{pos:[r.left+r.width+window.pageXOffset,r.top-2+window.pageYOffset],rootElement:m,parentStart:[r.left+window.pageXOffset,r.top-2+window.pageYOffset]}),t.childUid=o.apply(this,[e,n,!0,function(){}]),b=t.childUid}s().select(this).classed("d3-context-menu-selected",!0)})).on("mouseleave",(function(t,e){null==b&&s().select(this).classed("d3-context-menu-selected",!1)})),v.selectAll(".d3-context-menu-recursive").append("img").attr("src",u).attr("width","14px").attr("height","14px").style("position","absolute").style("right","5px"),n&&!1===n(e,a))return i;var k=s().select(".d3-context-menu-"+i).style("display","block");null==d?s().select(".d3-context-menu-"+i).style("left",s().event.pageX-2+"px").style("top",s().event.pageY-2+"px"):s().select(".d3-context-menu-"+i).style("left",d[0]+"px").style("top",d[1]+"px");var x=k.node().getBoundingClientRect();return(x.left+x.width>window.innerWidth||"left"==f)&&(f="left",null==d?s().select(".d3-context-menu-"+i).style("left",s().event.pageX-2-x.width+"px").style("top",s().event.pageY-2+"px"):null!=h?s().select(".d3-context-menu-"+i).style("left",h[0]-x.width+"px").style("top",h[1]+"px"):s().select(".d3-context-menu-"+i).style("left",d[0]-x.width+"px").style("top",d[1]+"px")),o||(s().event.preventDefault(),s().event.stopPropagation()),i}}var c=function(t,e){return t-e};function f(t,e){if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!=e.length)return!1;for(var n=0;n<t.length;++n)if(t[n]!==e[n])return!1;return!0}function d(){var t=this;t.bracketLeft="([{<ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),t.bracketRight=")]}>abcdefghijklmnopqrstuvwxyz".split(""),t.inverseBrackets=function(t){for(var e={},n=0;n<t.length;n++)e[t[n]]=n;return e},t.maximumMatching=function(t){for(var e=t[0],n=new Array(e+1),r=0;r<=e;r++){n[r]=new Array(e+1);for(var o=r;o<=e;o++)n[r][o]=0}var i=0;for(r=e-0-1;r>0;r--)for(o=r+0+1;o<=e;o++){i=n[r][o-1];for(var s=o-0-1;s>=r;s--)t[s]===o&&(i=Math.max(i,(s>r?n[r][s-1]:0)+1+(o-s-1>0?n[s+1][o-1]:0)));n[r][o]=i}return i=n[1][e],n},t.backtrackMaximumMatching=function(e,n){var r=Array.apply(null,Array(e.length)).map((function(){return 0}));return t.mmBt(e,r,n,1,e.length-1),r},t.mmBt=function(e,n,r,o,i){var s=e[o][i];if(!(i-o-1<0))if(e[o][i-1]!=s){for(var a=i-0-1;a>=o;a--)if(r[i]===a&&(a>o?e[o][a-1]:0)+(i-a-1>0?e[a+1][i-1]:0)+1==s)return n[a]=i,n[i]=a,o<a&&t.mmBt(e,n,r,o,a-1),void t.mmBt(e,n,r,a+1,i-1);console.log("FAILED!!!"+o+","+i+": backtracking failed!")}else t.mmBt(e,n,r,o,i-1)},t.dotbracketToPairtable=function(e){var n=Array.apply(null,new Array(e.length+1)).map(Number.prototype.valueOf,0);n[0]=e.length;for(var r={},o=0;o<t.bracketLeft.length;o++)r[o]=[];var i=t.inverseBrackets(t.bracketLeft),s=t.inverseBrackets(t.bracketRight);for(o=0;o<e.length;o++){var a=e[o],u=o+1;if("."==a||"o"==a)n[u]=0;else if(a in i)r[i[a]].push(u);else{if(!(a in s))throw"Unknown symbol in dotbracket string";var l=r[s[a]].pop();n[u]=l,n[l]=u}}for(var c in r)if(r[c].length>0)throw"Unmatched base at position "+r[c][0];return n},t.insertIntoStack=function(t,e,n){for(var r=0;t[r].length>0&&t[r][t[r].length-1]<n;)r+=1;return t[r].push(n),r},t.deleteFromStack=function(t,e){for(var n=0;0===t[n].length||t[n][t[n].length-1]!=e;)n+=1;return t[n].pop(),n},t.pairtableToDotbracket=function(e){for(var n={},r=0;r<e[0];r++)n[r]=[];var o={},i="";for(r=1;r<e[0]+1;r++){if(0!==e[r]&&e[r]in o)throw"Invalid pairtable contains duplicate entries";o[e[r]]=!0,0===e[r]?i+=".":e[r]>r?i+=t.bracketLeft[t.insertIntoStack(n,r,e[r])]:i+=t.bracketRight[t.deleteFromStack(n,r)]}return i},t.findUnmatched=function(e,n,r){for(var o=[],i=[],s=n,a=r,u=n;u<=r;u++)0!==e[u]&&(e[u]<n||e[u]>r)&&i.push([u,e[u]]);for(u=s;u<=a;u++){for(;0===e[u]&&u<=a;)u++;for(r=e[u];e[u]===r;)u++,r--;o=o.concat(t.findUnmatched(e,u,r))}return i.length>0&&o.push(i),o},t.removePseudoknotsFromPairtable=function(e){for(var n=t.maximumMatching(e),r=t.backtrackMaximumMatching(n,e),o=[],i=1;i<e.length;i++)e[i]<i||r[i]!=e[i]&&(o.push([i,e[i]]),e[e[i]]=0,e[i]=0);return o},t.ptToElements=function(e,n,r,o,i){var s=[],a=[r-1],u=[o+1];if(arguments.length<5&&(i=[]),r>o)return[];for(;0===e[r];r++)a.push(r);for(;0===e[o];o--)u.push(o);if(r>o){if(a.push(r),0===n)return[["e",n,a.sort(c)]];for(var l=!1,f=[],d=[],h=0;h<a.length;h++)l?d.push(a[h]):f.push(a[h]),i.indexOf(a[h])>=0&&(l=!0);return[["h",n,a.sort(c)]]}if(e[r]!=o){var p=a;for(h=r,p.push(h);h<=o;){for(s=s.concat(t.ptToElements(e,n,h,e[h],i)),p.push(e[h]),h=e[h]+1;0===e[h]&&h<=o;h++)p.push(h);p.push(h)}return p.pop(),(p=p.concat(u)).length>0&&(0===n?s.push(["e",n,p.sort(c)]):s.push(["m",n,p.sort(c)])),s}if(e[r]===o){a.push(r),u.push(o);var g=a.concat(u);g.length>4&&(0===n?s.push(["e",n,a.concat(u).sort(c)]):s.push(["i",n,a.concat(u).sort(c)]))}for(var y=[];e[r]===o&&r<o;)y.push(r),y.push(o),r+=1,o-=1,n+=1;return a=[r-1],u=[o+1],s.push(["s",n,y.sort(c)]),s.concat(t.ptToElements(e,n,r,o,i))}}var h=new d;function p(t){var e=this;return e.colorsText=t,e.parseRange=function(t){for(var e=t.split(","),n=[],r=0;r<e.length;r++){var o=e[r].split("-");if(1==o.length)n.push(parseInt(o[0]));else if(2==o.length)for(var i=parseInt(o[0]),s=parseInt(o[1]),a=i;a<=s;a++)n.push(a);else console.log("Malformed range (too many dashes):",t)}return n},e.parseColorText=function(t){for(var n=t.split("\n"),r="",o=1,i={colorValues:{"":{}},range:["white","steelblue"]},s=[],a=0;a<n.length;a++)if(">"!=n[a][0])for(var u=n[a].trim().split(/[\s]+/),l=0;l<u.length;l++)if(isNaN(u[l])){if(0===u[l].search("range")){var c=u[l].split("=")[1].split(":");i.range=[c[0],c[1]];continue}if(0==u[l].search("domain")){var f=u[l].split("=")[1].split(":");i.domain=[f[0],f[1]];continue}for(var d=u[l].split(":"),h=e.parseRange(d[0]),p=d[1],g=0;g<h.length;g++)isNaN(p)?i.colorValues[r][h[g]]=p:(i.colorValues[r][h[g]]=+p,s.push(Number(p)))}else i.colorValues[r][o]=Number(u[l]),o+=1,s.push(Number(u[l]));else r=n[a].trim().slice(1),o=1,i.colorValues[r]={};return"domain"in i||(i.domain=[Math.min.apply(null,s),Math.max.apply(null,s)]),e.colorsJson=i,e},e.normalizeColors=function(){var t;for(var n in e.colorsJson){var r=Number.MAX_VALUE,o=Number.MIN_VALUE;for(var i in e.colorsJson.colorValues[n])"number"==typeof(t=e.colorsJson.colorValues[n][i])&&(t<r&&(r=t),t>o&&(o=t));for(i in e.colorsJson.colorValues[n])"number"==typeof(t=e.colorsJson.colorValues[n][i])&&(e.colorsJson.colorValues[n][i]=(t-r)/(o-r))}return e},e.parseColorText(e.colorsText),e}var g=function(t,e){return t-e};function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=this;o.type="rna",o.circularizeExternal=!1,o.seq=t,o.dotbracket=e,o.structName=n,o.circular=!1,"*"==o.dotbracket.slice(-1)&&(o.dotbracket=o.dotbracket.slice(0,-1),o.circular=!0),o.uid=a.nice(),o.elements=[],o.pseudoknotPairs=[],o.nucsToNodes={},o.addUids=function(t){for(var e=o.nodes.filter((function(t){return"nucleotide"==t.nodeType})),n=0;n<t.length&&n<e.length;n++)e[n].uid=t[n];return o},o.computePairtable=function(){o.pairtable=h.dotbracketToPairtable(o.dotbracket)},o.removeBreaks=function(t){for(var e=[],n=-1;(n=t.indexOf("&"))>=0;)e.push(n),t=t.substring(0,n)+t.substring(n+1,t.length);return{targetString:t,breaks:e}};var i=o.removeBreaks(o.dotbracket);o.dotbracket=i.targetString,o.dotBracketBreaks=i.breaks,i=o.removeBreaks(o.seq),o.seq=i.targetString,o.seqBreaks=i.breaks,o.rnaLength=o.dotbracket.length,f(o.dotBracketBreaks,o.seqBreaks)||(console.log("WARNING: Sequence and structure breaks not equal"),console.log("WARNING: Using the breaks in the structure")),o.computePairtable(),o.addPositions=function(t,e){for(var n=o.nodes.filter((function(e){return e.nodeType==t})),r=0;r<n.length;r++)n[r].x=e[r][0],n[r].y=e[r][1];return o},o.breakNodesToFakeNodes=function(){for(var t=o.nodes.filter((function(t){return"nucleotide"==t.nodeType})),e=0;e<t.length;e++)o.dotBracketBreaks.indexOf(e)>=0&&(t[e].nodeType="middle",t[e+1].nodeType="middle");for(var n=function(t){i=!1;for(var e=0;e<o.elements[t][2].length;e++)o.dotBracketBreaks.indexOf(o.elements[t][2][e])>=0&&(i=!0);i?o.elements[t][2].map((function(t){0!=t&&(o.nodes[t-1].elemType="e")})):o.elements[t][2].map((function(e){0!=e&&(o.nodes[e-1].elemType=o.elements[t][0])}))},r=0;r<o.elements.length;r++){var i;n(r)}return o},o.getPositions=function(t){for(var e=[],n=o.nodes.filter((function(e){return e.nodeType==t})),r=0;r<n.length;r++)e.push([n[r].x,n[r].y]);return e},o.getUids=function(){for(var t=[],e=0;e<o.dotbracket.length;e++)t.push(o.nodes[e].uid);return t},o.reinforceStems=function(){for(var t=o.pairtable,e=o.elements.filter((function(t){return"s"==t[0]&&t[2].length>=4})),n=0;n<e.length;n++)for(var r=e[n][2],i=r.slice(0,r.length/2),s=0;s<i.length-1;s++)o.addFakeNode([i[s],i[s+1],t[i[s+1]],t[i[s]]]);return o},o.reinforceLoops=function(){for(var t=function(t){return 0!==t&&t<=o.dotbracket.length},e=0;e<o.elements.length;e++)if("s"!=o.elements[e][0]&&(o.circularizeExternal||"e"!=o.elements[e][0])){var n=o.elements[e][2].filter(t);if("e"==o.elements[e][0]){var r={name:"",num:-3,radius:0,rna:o,nodeType:"middle",elemType:"f",nucs:[],x:o.nodes[o.rnaLength-1].x,y:o.nodes[o.rnaLength-1].y,px:o.nodes[o.rnaLength-1].px,py:o.nodes[o.rnaLength-1].py,uid:a.nice()},i={name:"",num:-2,radius:0,rna:o,nodeType:"middle",elemType:"f",nucs:[],x:o.nodes[0].x,y:o.nodes[0].y,px:o.nodes[0].px,py:o.nodes[0].py,uid:a.nice()};n.push(o.nodes.length+1),n.push(o.nodes.length+2),o.nodes.push(r),o.nodes.push(i)}o.addFakeNode(n)}return o},o.updateLinkUids=function(){for(var t=0;t<o.links.length;t++)o.links[t].uid=o.links[t].source.uid+o.links[t].target.uid;return o},o.addFakeNode=function(t){for(var e=6.283/(2*t.length),n=18/(2*Math.tan(e)),r="",i=0;i<t.length;i++)r+=o.nodes[t[i]-1].uid;var s={name:"",num:-1,radius:n,rna:o,nodeType:"middle",elemType:"f",nucs:t,uid:r};o.nodes.push(s);var u=0,l=0,c=0;e=3.14159*(t.length-2)/(2*t.length),n=.5/Math.cos(e);for(var f=0;f<t.length;f++)if(!(0===t[f]||t[f]>o.dotbracket.length)){o.links.push({source:o.nodes[t[f]-1],target:o.nodes[o.nodes.length-1],linkType:"fake",value:n,uid:a.nice()}),t.length>4&&o.links.push({source:o.nodes[t[f]-1],target:o.nodes[t[(f+Math.floor(t.length/2))%t.length]-1],linkType:"fake",value:2*n,uid:a.nice()});var d=3.14159*(t.length-2)/t.length,h=2*Math.cos(1.570795-d/2);o.links.push({source:o.nodes[t[f]-1],target:o.nodes[t[(f+2)%t.length]-1],linkType:"fake",value:h});var p=o.nodes[t[f]-1];"x"in p&&(u+=p.x,l+=p.y,c+=1)}return c>0&&(s.x=u/c,s.y=l/c,s.px=s.x,s.py=s.y),o},o.connectFakeNodes=function(){for(var t={},e=o.nodes.filter((function(t){return"middle"==t.nodeType})),n={},r=1;r<=o.nodes.length;r++)t[r]=[];for(r=0;r<e.length;r++)for(var i=e[r],s=0;s<i.nucs.length;s++){for(var a=i.nucs[s],u=0;u<t[a].length;u++)if(!(JSON.stringify([t[a][u].uid,i.uid].sort())in n)){var l=t[a][u].radius+i.radius;o.links.push({source:t[a][u],target:i,value:l/18,linkType:"fake_fake"}),n[JSON.stringify([t[a][u].uid,i.uid].sort())]=!0}t[a].push(i)}return o},o.addExtraLinks=function(t){if(void 0===t)return o;for(var e=0;e<t.length;e++){var n={source:o.getNodeFromNucleotides(t[e].from),target:o.getNodeFromNucleotides(t[e].to),linkType:"extra",extraLinkType:t[e].linkType,uid:a.nice()};o.links.push(n)}return o},o.elementsToJson=function(){var t=o.pairtable;o.elements,o.nodes=[],o.links=[];var e={};o.elements.sort();for(var n=0;n<o.elements.length;n++)for(var i=o.elements[n][2],s=0;s<i.length;s++)e[i[s]]=o.elements[n][0];for(var u=1;u<=t[0];u++){var l=o.seq[u-1];(o.dotBracketBreaks.indexOf(u-1)>=0||o.dotBracketBreaks.indexOf(u-2)>=0)&&(l=""),o.nodes.push({name:l,num:r+u-1,radius:5,rna:o,nodeType:"nucleotide",structName:o.structName,elemType:e[u],uid:a.nice(),linked:!1})}for(var c=0;c<o.nodes.length;c++)o.nodes[c].prevNode=0===c?null:o.nodes[c-1],c==o.nodes.length-1?o.nodes[c].nextNode=null:o.nodes[c].nextNode=o.nodes[c+1];for(var f=1;f<=t[0];f++)0!==t[f]&&o.links.push({source:o.nodes[f-1],target:o.nodes[t[f]-1],linkType:"basepair",value:1,uid:a.nice()}),f>1&&-1===o.dotBracketBreaks.indexOf(f-1)&&-1==o.dotBracketBreaks.indexOf(f-2)&&-1==o.dotBracketBreaks.indexOf(f-3)&&(o.links.push({source:o.nodes[f-2],target:o.nodes[f-1],linkType:"backbone",value:1,uid:a.nice()}),o.nodes[f-1].linked=!0);for(var d=0;d<o.pseudoknotPairs.length;d++)o.links.push({source:o.nodes[o.pseudoknotPairs[d][0]-1],target:o.nodes[o.pseudoknotPairs[d][1]-1],linkType:"pseudoknot",value:1,uid:a.nice()});return o.circular&&o.links.push({source:o.nodes[0],target:o.nodes[o.rnaLength-1],linkType:"backbone",value:1,uid:a.nice()}),o},o.ptToElements=function(t,e,n,r){var i=[],s=[n-1],a=[r+1];if(n>r)return[];for(;0===t[n];n++)s.push(n);for(;0===t[r];r--)a.push(r);if(n>r){if(s.push(n),0===e)return[["e",e,s.sort(g)]];for(var u=!1,l=[],c=[],f=0;f<s.length;f++)u?c.push(s[f]):l.push(s[f]),o.dotBracketBreaks.indexOf(s[f])>=0&&(u=!0);return[["h",e,s.sort(g)]]}if(t[n]!=r){var d=s;for(f=n,d.push(f);f<=r;){for(i=i.concat(o.ptToElements(t,e,f,t[f])),d.push(t[f]),f=t[f]+1;0===t[f]&&f<=r;f++)d.push(f);d.push(f)}return d.pop(),(d=d.concat(a)).length>0&&(0===e?i.push(["e",e,d.sort(g)]):i.push(["m",e,d.sort(g)])),i}t[n]===r&&(s.push(n),a.push(r),s.concat(a).length>4&&(0===e?i.push(["e",e,s.concat(a).sort(g)]):i.push(["i",e,s.concat(a).sort(g)])));for(var h=[];t[n]===r&&n<r;)h.push(n),h.push(r),n+=1,r-=1,e+=1;return s=[n-1],a=[r+1],i.push(["s",e,h.sort(g)]),i.concat(o.ptToElements(t,e,n,r))},o.addLabels=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if(0===e)return o;for(var n=1;n<=o.rnaLength;n++)if(n%e==0){var r=void 0,i=void 0,s=o.nodes[n-1],u=void 0,l=void 0,c=void 0,f=void 0;1==o.rnaLength?(f=[s.x-15,s.y],c=[s.x-15,s.y]):(u=1==n?o.nodes[o.rnaLength-1]:o.nodes[n-2],l=n==o.rnaLength?o.nodes[0]:o.nodes[n],0!==o.pairtable[l.num-t+1]&&0!==o.pairtable[u.num-t+1]&&0!==o.pairtable[s.num-t+1]&&(u=l=o.nodes[o.pairtable[s.num-t+1]-1]),0===o.pairtable[s.num-t+1]||0!==o.pairtable[l.num-t+1]&&0!==o.pairtable[u.num-t+1]?(f=[l.x-s.x,l.y-s.y],c=[u.x-s.x,u.y-s.y]):(f=[s.x-l.x,s.y-l.y],c=[s.x-u.x,s.y-u.y]));var d=[f[0]+c[0],f[1]+c[1]],h=Math.sqrt(d[0]*d[0]+d[1]*d[1]),p=[d[0]/h,d[1]/h],g=[-15*p[0],-15*p[1]];r=o.nodes[n-1].x+g[0],i=o.nodes[n-1].y+g[1];var y={name:n+t-1,num:-1,radius:6,rna:o,nodeType:"label",structName:o.structName,elemType:"l",x:r,y:i,px:r,py:i,uid:a.nice()},m={source:o.nodes[n-1],target:y,value:1,linkType:"label_link",uid:a.nice()};o.nodes.push(y),o.links.push(m)}return o},o.recalculateElements=function(){if(o.removePseudoknots(),o.elements=o.ptToElements(o.pairtable,0,1,o.dotbracket.length),o.circular){var t=o.elements.filter((function(t){if("e"==t[0])return!0}));if(t.length>0){eloop=t[0],nucs=eloop[2].sort(g),prev=nucs[0],hloop=!0,numGreater=0;for(var e=1;e<nucs.length;e++)nucs[e]-prev>1&&(numGreater+=1),prev=nucs[e];1==numGreater?eloop[0]="h":2==numGreater?eloop[0]="i":eloop[0]="m"}}return o},o.reassignLinkUids=function(){for(var t=0;t<o.links.length;t++)o.links[t].uid=o.links[t].source.uid+o.links[t].target.uid;return o},o.removePseudoknots=function(){return o.pairtable.length>1&&(o.pseudoknotPairs=o.pseudoknotPairs.concat(h.removePseudoknotsFromPairtable(o.pairtable))),o},o.addPseudoknots=function(){for(var t=o.pairtable,e=o.pseudoknotPairs,n=0;n<e.length;n++)t[e[n][0]]=e[n][1],t[e[n][1]]=e[n][0];return o.pseudoknotPairs=[],o},o.addName=function(t){return void 0===t?(o.name="",o):(o.name=t,o)},o.rnaLength>0&&o.recalculateElements(),o.getNodeFromNucleotides=function(t){if("[object Array]"===Object.prototype.toString.call(t)){for(var e=0;e<o.nodes.length;e++)if("nucs"in o.nodes[e]&&o.nodes[e].nucs.equals(t))return o.nodes[e]}else for(var n=0;n<o.nodes.length;n++)if(o.nodes[n].num==t)return o.nodes[n];return console.log("ERROR: No node found for nucs:",t),null}}function m(t){var e,n,r,o=[],i=[];n=t[0];var s=Array.apply(null,new Array(n+5)).map(Number.prototype.valueOf,0),a=Array.apply(null,new Array(16+Math.floor(n/5))).map(Number.prototype.valueOf,0),u=Array.apply(null,new Array(16+Math.floor(n/5))).map(Number.prototype.valueOf,0),l=0,c=0,f=Math.PI/2;!function t(e,n,r){var o,i,d,h,p,g,y,m,b,v,k,x,w=2,E=0,A=0,N=Array.apply(null,new Array(3+2*Math.floor((n-e)/5))).map(Number.prototype.valueOf,0);for(o=e-1,n++;e!=n;)if((i=r[e])&&0!=e){w+=2,d=e,h=i,N[++E]=d,N[++E]=h,e=i+1,p=d,g=h,m=0;do{d++,h--,m++}while(r[d]==h&&r[d]>d);if(y=m-2,m>=2&&(s[p+1+y]+=f,s[g-1-y]+=f,s[p]+=f,s[g]+=f,m>2))for(;y>=1;y--)s[p+y]=Math.PI,s[g-y]=Math.PI;u[++c]=m,d<=h&&t(d,h,r)}else e++,w++,A++;for(x=Math.PI*(w-2)/w,N[++E]=n,b=o<0?0:o,v=1;v<=E;v++){for(k=N[v]-b,y=0;y<=k;y++)s[b+y]+=x;if(v>E)break;b=N[++v]}a[++l]=A}(0,n+1,t),a[l]-=2,r=0,o[0]=100,i[0]=100;var d=[];for(d.push([o[0],i[0]]),e=1;e<n;e++)o[e]=o[e-1]+15*Math.cos(r),i[e]=i[e-1]+15*Math.sin(r),d.push([o[e],i[e]]),r+=Math.PI-s[e+1];return d}function b(){this.radius=null,this.loopnumber=null,this.next=null,this.prev=null}void 0===String.prototype.trim&&(String.prototype.trim=function(){return String(this).replace(/^\s+|\s+$/g,"")}),b.prototype.getRadius=function(){return this.radius},b.prototype.setRadius=function(t){this.radius=t},b.prototype.getLoopnumber=function(){return this.loopnumber},b.prototype.setLoopnumber=function(t){this.loopnumber=t},b.prototype.getNext=function(){return this.next},b.prototype.setNext=function(t){this.next=t},b.prototype.getPrev=function(){return this.prev},b.prototype.setPrev=function(t){this.prev=t};var v=o(953),k=o(75);function x(){this.mate=null,this.x=null,this.y=null,this.extracted=null,this.region=new k.y}x.prototype.getMate=function(){return this.mate},x.prototype.setMate=function(t){this.mate=t},x.prototype.getX=function(){return this.x},x.prototype.setX=function(t){this.x=t},x.prototype.getY=function(){return this.y},x.prototype.setY=function(t){this.y=t},x.prototype.isExtracted=function(){return this.extracted},x.prototype.setExtracted=function(t){this.extracted=t},x.prototype.getRegion=function(){return this.region},x.prototype.setRegion=function(t){this.region=t};var w=o(724);function E(){this.ANUM=9999,this.MAXITER=500,this.bases=[],this.nbase=null,this.nregion=null,this.loop_count=null,this.root=new w.r,this.loops=[],this.regions=[],this.rlphead=new b,this.lencut=.8,this.RADIUS_REDUCTION_FACTOR=1.4,this.angleinc=null,this._h=null,this.HELIX_FACTOR=.6,this.BACKBONE_DISTANCE=27}function A(){var t=new w.r,e=null,n=null;for(e=0;e<this.loop_count;e++){for(t=this.loops[e],n=0;n<this.loop_count;n++)this.loops[n].setMark(!1);t.setDepth(N(t))}}function N(t){var e=null,n=null,r=null;if(t.getNconnection()<=1)return 0;if(t.isMark())return-1;t.setMark(!0),e=0,n=0;for(var o=0;null!=t.getConnection(o);o++)(r=N(t.getConnection(o).getLoop()))>=0&&(1==++e||n>r)&&(n=r);return t.setMark(!1),n+1}function L(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this,i={editable:!1,zoomable:!0,animation:!0,displayAllLinks:!1,labelInterval:10,chargeDistance:110,friction:.35,middleCharge:-30,otherCharge:-30,linkDistanceMultiplier:15,initialSize:null,layout:"standard-polygonal",transitionDuration:500,maxNodeRadius:80};o.options=Object.assign(i,n),null!==o.options.initialSize?(o.options.svgW=o.options.initialSize[0],o.options.svgH=o.options.initialSize[1]):(o.options.svgW=300,o.options.svgH=300),o.linkStrengths={pseudoknot:0,proteinChain:0,chainChain:0,intermolecule:10,external:0,other:10},o.displayParameters={displayNumbering:!0,displayNodeOutline:!0,displayNodeLabel:!0,displayLinks:!0,displayPseudoknotLinks:!0,displayProteinLinks:!0,displayDirectionArrows:!0},o.colorScheme="structure",o.customColors={},o.rnas={},o.extraLinks=[];var u=null,c=null,f=!1,d=function(){u=null,c=null},g=o.graph={nodes:[],links:[]};if(Array.prototype.equals=function(t){if(!t)return!1;if(this.length!=t.length)return!1;for(var e=0,n=this.length;e<n;e++)if(this[e]instanceof Array&&t[e]instanceof Array){if(!this[e].equals(t[e]))return!1}else if(this[e]!=t[e])return!1;return!0},o.options.editable||o.options.animation){var b=!1,v=!1,k=function(){switch(s().event.keyCode){case 68:console.log("dotbracket:",o.getStructuresDotBracket());break;case 16:b=!0;break;case 17:v=!0;break;case 67:o.centerView()}v&&(o.options.zoomable&&R(),(o.options.editable||o.options.animation)&&Y())},x=function(){b=!1,v=!1,o.options.zoomable&&P(),q()};s().select("body").on("keydown",k).on("keyup",x).on("contextmenu",(function(){s().event.preventDefault()}))}if(o.options.editable){var w=[{title:"Add Node",action:function(t,e,n,r){},children:[{title:"A",action:function(t,e,n,r){console.log("mousePos:",r,o.options.svgW,o.options.svgH);var i=[B.invert(r[0]),I.invert(r[1])];console.log("canvasMousePos",i),o.addRNA(".",{sequence:"A",centerPos:i})}},{title:"C",action:function(t,e,n,r){console.log("mousePos:",r,o.options.svgW,o.options.svgH);var i=[B.invert(r[0]),I.invert(r[1])];console.log("canvasMousePos",i),o.addRNA(".",{sequence:"C",centerPos:i})}},{title:"G",action:function(t,e,n,r){console.log("mousePos:",r,o.options.svgW,o.options.svgH);var i=[B.invert(r[0]),I.invert(r[1])];console.log("canvasMousePos",i),o.addRNA(".",{sequence:"G",centerPos:i})}},{title:"U",action:function(t,e,n,r){console.log("mousePos:",r,o.options.svgW,o.options.svgH);var i=[B.invert(r[0]),I.invert(r[1])];console.log("canvasMousePos",i),o.addRNA(".",{sequence:"U",centerPos:i})}}],disabled:!1}],A=[{title:"Delete Node",action:function(t,e,n){Z(e)},disabled:!1},{title:"Change Node",action:function(t,e,n){console.log("You have clicked the second item!"),console.log("The data for this circle is: "+e)},children:[{title:"A",action:function(t,e,n){H("A",e)}},{title:"C",action:function(t,e,n){H("C",e)}},{title:"G",action:function(t,e,n){H("G",e)}},{title:"U",action:function(t,e,n){H("U",e)}}]},{title:"Insert Before",action:function(t,e,n){},children:[{title:"A",action:function(t,e,n){K("A",e,-1)}},{title:"C",action:function(t,e,n){K("C",e,-1)}},{title:"G",action:function(t,e,n){K("G",e,-1)}},{title:"U",action:function(t,e,n){K("U",e,-1)}}]},{title:"Insert After",action:function(t,e,n){console.log("d:",e)},children:[{title:"A",action:function(t,e,n){K("A",e,0)}},{title:"C",action:function(t,e,n){K("C",e,0)}},{title:"G",action:function(t,e,n){K("G",e,0)}},{title:"U",action:function(t,e,n){K("U",e,0)}}]}];o.nodeContextMenu=l(A),o.backgroundContextMenu=l(w)}else o.nodeContextMenu=function(){};s().select(t).select("svg").remove();var N=s().select(t).attr("tabindex",1).each((function(){this.focus()})).append("svg:svg").attr("preserveAspectRatio","xMidYMid meet").attr("viewBox","0 0 "+o.options.svgW+" "+o.options.svgH);if(o.options.svg=N,o.options.editable||o.options.animation)(L=N.append("svg:g").on("mousemove",(function(){if(u){var t=s().mouse(T.node());S.attr("x1",u.x).attr("y1",u.y).attr("x2",t[0]).attr("y2",t[1])}})).on("mousedown",(function(){})).on("mouseup",(function(){u&&!f&&S.classed(e().transparent,!0),d()})).classed(e().mouseEventHelper,!0).style("pointer-events","all")).append("svg:rect").classed("background",!0).style("visibility","hidden").attr("width",o.options.svgW).attr("height",o.options.svgH).on("mousedown",(function(){O()}));else var L=N;var T=L.append("svg:g").classed(e().plot,!0),_=T.append("svg:g").classed("fornac-links",!0),M=T.append("svg:g").classed("fornac-nodes",!0);if(o.options.editable){var S=T.append("line").attr("class",e().dragLine).attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",0);N.on("contextmenu",o.backgroundContextMenu)}var B=s().scale.linear().domain([0,o.options.svgW]).range([0,o.options.svgW]),I=s().scale.linear().domain([0,o.options.svgH]).range([0,o.options.svgH]);o.zoomer=s().behavior.zoom().scaleExtent([.1,10]).x(B).y(I).on("zoom",(function(){T.attr("transform","translate("+s().event.translate+") scale("+s().event.scale+")")}));var P=function(){N.call(o.zoomer).on("dblclick.zoom",null)},R=function(){N.call(o.zoomer).on("dblclick.zoom",null).on("mousedown.zoom",null).on("touchstart.zoom",null).on("touchmove.zoom",null).on("touchend.zoom",null)};o.options.zoomable&&P();var C=function(t){t.selected=!t.selected,M.selectAll("g.gnode").filter((function(e){return t.uid==e.uid})).classed(e().selectedNode,(function(t){return t.selected}))},U=function(t){t.selected=!0,M.selectAll("g.gnode").filter((function(e){return t.uid==e.uid})).classed(e().selectedNode,(function(t){return t.selected}))},O=function(){M.selectAll("g.gnode").classed(e().selectedNode,(function(t){return t.selected=!1}))},X=function(){return M.selectAll("g.gnode").filter((function(t){return t.selected}))};o.brusher=s().svg.brush().x(B).y(I).on("brushstart",(function(t){})).on("brush",(function(){var t=s().event.target.extent();M.selectAll("g.gnode").classed(e().selectedNode,(function(e){return e.selected^(t[0][0]<=e.x&&e.x<t[1][0]&&t[0][1]<=e.y&&e.y<t[1][1])}))})).on("brushend",(function(){var t=s().event.target.extent();M.selectAll("g.gnode").filter((function(e){return t[0][0]<=e.x&&e.x<t[1][0]&&t[0][1]<=e.y&&e.y<t[1][1]})).each(C),s().event.target.clear(),s().select(this).call(s().event.target)}));var Y=function(){L.select(".background").style("cursor","crosshair"),L.call(o.brusher)},q=function(){L.select(".background").style("cursor","auto"),L.call(o.brusher).on("mousedown.brush",null).on("touchstart.brush",null).on("touchmove.brush",null).on("touchend.brush",null)};o.force=s().layout.force().charge((function(t){return"middle"==t.nodeType?o.options.middleCharge:o.options.otherCharge})).friction(o.options.friction).linkDistance((function(t){return o.options.linkDistanceMultiplier*t.value})).linkStrength((function(t){return t.linkType in o.linkStrengths?o.linkStrengths[t.linkType]:o.linkStrengths.other})).gravity(0).nodes(o.graph.nodes).links(o.graph.links).chargeDistance(o.options.chargeDistance).size([o.options.svgW,o.options.svgH]);var D=s().behavior.drag().on("dragstart",(function(t){s().event.sourceEvent.stopPropagation(),X().each((function(t){t.fixed|=2}))})).on("drag",(function(t){b||(X().each((function(t){t.x+=s().event.dx,t.y+=s().event.dy,t.px+=s().event.dx,t.py+=s().event.dy})),o.resumeForce(),s().event.sourceEvent.preventDefault())})).on("dragend",(function(t){X().each((function(t){t.fixed&=-7}))})),F=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={sequence:"",name:"empty",positions:[],labelInterval:o.options.labelInterval,avoidOthers:!0,uids:[],circularizeExternal:!0},r=new y((n=Object.assign(n,e)).sequence,t,n.name);r.circularizeExternal=n.circularizeExternal;var i=r.recalculateElements();if(0===n.positions.length)if("naview"==o.options.layout){var s=new E,a=s.naview_xy_coordinates(r.pairtable);n.positions=[];for(var u=0;u<a.nbase;u++)n.positions.push([a.x[u],a.y[u]])}else n.positions=m(i.pairtable);return i.elementsToJson().addUids(n.uids).addPositions("nucleotide",n.positions).addLabels(1,n.labelInterval).reinforceStems().reinforceLoops().connectFakeNodes().reassignLinkUids().breakNodesToFakeNodes()},z=function(t){(t=t.append("g").classed("gnode",!0).attr("struct_name",(function(t){return t.structName})).attr("transform",(function(t){return void 0!==t.x&&void 0!==t.y?"translate("+[t.x,t.y]+")":""})).each((function(t){t.selected=t.previouslySelected=!1}))).attr("num",(function(t){return"n"+t.num})).attr("rnum",(function(t){return"n"+(t.rna.rnaLength-t.num+1)})).transition().duration(750).ease("elastic"),(o.options.editable||o.options.animation)&&t.on("mousedown",it).on("mouseup",ot).on("contextmenu",o.nodeContextMenu).call(D);var n=t.filter((function(t){return"label"==t.nodeType||"protein"==t.nodeType})),r=t.filter((function(t){return"nucleotide"==t.nodeType}));return n.append("svg:circle").classed(e().node,!0).attr("r",(function(t){return"middle"==t.nodeType?0:t.radius})).attr("node_type",(function(t){return t.nodeType})).attr("node_num",(function(t){return t.num})),r.append("svg:path").attr("class",e().directionArrow).attr("node_num",(function(t){return t.num})),r.append("svg:circle").attr("class",e().node).attr("node_type",(function(t){return t.nodeType})).attr("node_num",(function(t){return t.num})).attr("r",(function(t){return t.radius})).append("svg:title").text((function(t){return"nucleotide"==t.nodeType?t.structName+":"+t.num:""})),t.append("text").text((function(t){return t.name})).attr("class",e().nodeLabel).attr("label_type",(function(t){return t.nodeType})).append("svg:title").text((function(t){return"nucleotide"==t.nodeType?t.structName+":"+t.num:""})),t},V=function(t){var n=t.append("svg:line");return n.append("svg:title").text((function(t){return t.linkType+":"+t.source.num+"-"+t.target.num})),n.classed("link",!0).classed(e().link,!0).attr("x1",(function(t){return t.source.x})).attr("y1",(function(t){return t.source.y})).attr("x2",(function(t){return t.target.x})).attr("y2",(function(t){return t.target.y})).attr("link_type",(function(t){return t.linkType})).attr("pointer-events",(function(t){return"fake"==t.linkType?"none":"all"})),o.options.editable&&n.on("click",st),n};function j(t){var n=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},r=t,o=t.prevNode,i=parseFloat(e().nodeStrokeWidth)/2,a=parseFloat(e().directionArrowSize),u=parseFloat(e().directionArrowWidth);if(null!==o&&t.linked){var l=[-(r.x-o.x),-(r.y-o.y)];if(0!=l[0]||0!=l[1]){var c=[-(l=[l[0]/n(l),l[1]/n(l)])[1],l[0]],f=[(t.radius+i)*l[0],(t.radius+i)*l[1]],d="M"+(f[0]+a*(l[0]/2+c[0]*u/2))+","+(f[1]+a*(l[1]/2+c[1]*u/2))+"L"+f[0]+","+f[1]+"L"+(f[0]+a*(l[0]/2-c[0]*u/2))+","+(f[1]+a*(l[1]/2-c[1]*u/2));s().select(this).attr("d",d)}}}var $=function(t){return"basepair"==t.linkType||"backbone"==t.linkType||"intermolecule"==t.linkType||"pseudoknot"==t.linkType||"label_link"==t.linkType||"external"==t.linkType||"chain_chain"==t.linkType},W=function(){for(var t in o.graph.nodes=[],o.graph.links=[],o.rnas)o.graph.nodes=o.graph.nodes.concat(o.rnas[t].nodes),o.graph.links=o.graph.links.concat(o.rnas[t].links);for(var e={},n=0;n<o.graph.nodes.length;n++)e[o.graph.nodes[n].uid]=o.graph.nodes[n];o.graph.links.forEach((function(t){t.source=e[t.source.uid],t.target=e[t.target.uid]}));for(var r=function(t){if(!(o.extraLinks[t].target.uid in e))return console.log("not there:",o.extraLinks[t]),"continue";if(o.extraLinks[t].source=e[o.extraLinks[t].source.uid],o.extraLinks[t].target=e[o.extraLinks[t].target.uid],"intermolecule"==o.extraLinks[t].linkType)for(var n=o.graph.links.filter((function(e){return(e.source==o.extraLinks[t].source||e.source==o.extraLinks[t].target||e.target==o.extraLinks[t].source||e.target==o.extraLinks[t].source)&&"fake"==e.linkType})),r=0;r<n.length;r++){var i=o.graph.links.indexOf(n[r]);o.graph.links.splice(i,1)}g.links.push(o.extraLinks[t])},i=0;i<o.extraLinks.length;i++)r(i)};o.update=function(){o.force.nodes(o.graph.nodes).links(o.graph.links),o.options.animation&&o.force.start();var t=_.selectAll("line.link").data(o.graph.links.filter($),Q);t.attr("class","").classed("link",!0).classed(e().link,!0).attr("link_type",(function(t){return t.linkType}));var n=t.enter();V(n),t.exit().remove();var r=M.selectAll("g.gnode").data(o.graph.nodes,Q),i=r.enter();z(i),r.exit().remove();var a=o.graph.nodes.filter((function(t){return"nucleotide"==t.nodeType||"label"==t.nodeType}));r.select("."+e().directionArrow).each(j),o.force.on("tick",(function(){for(var n=s().geom.quadtree(a),o=0,i=a.length,u=function(t){var e=t.radius+16,n=t.x-e,r=t.x+e,o=t.y-e,i=t.y+e;return function(e,s,a,u,l){if(e.point&&e.point!==t){var c=t.x-e.point.x,f=t.y-e.point.y,d=Math.sqrt(c*c+f*f),h=t.radius+e.point.radius;d<h&&(d=(d-h)/d*.1,t.x-=c*=d,t.y-=f*=d,e.point.x+=c,e.point.y+=f)}return s>r||u<n||a>i||l<o}};++o<i;)n.visit(u(a[o]));t.attr("x1",(function(t){return t.source.x})).attr("y1",(function(t){return t.source.y})).attr("x2",(function(t){return t.target.x})).attr("y2",(function(t){return t.target.y})),r.attr("transform",(function(t){return"translate("+[t.x,t.y]+")"})),r.select("."+e().directionArrow).each(j)})),o.force.on("end",(function(){r.selectAll("[node_type=nucleotide]").filter((function(t,e){return 0==e})).each((function(t,e){}))})),o.changeColorScheme(o.colorScheme),o.options.animation&&o.force.start(),J()},o.transitionRNA=function(t,n){if(o.dotbracket!=t){o.dotbracket=t;var r=o.options.transitionDuration,i=o.graph.nodes.filter((function(t){return"nucleotide"==t.nodeType})).map((function(t){return t.uid})),s=F(t,{uids:i}),a=M.selectAll("g.gnode").data(s.nodes,Q),u=_.selectAll("line.link").data(s.links.filter($),Q);0===r?a.attr("transform",(function(t){return"translate("+[t.x,t.y]+")"})):a.transition().attr("transform",(function(t){return"translate("+[t.x,t.y]+")"})).duration(r);var l=z(a.enter()).attr("transform",(function(t){return void 0!==t.x&&void 0!==t.y?"translate("+[0,0]+")":""}));0===r?a.exit().remove():a.exit().transition().attr("transform",(function(t){return void 0!==t.x&&void 0!==t.y?"translate("+[0,0]+")":""})),o.graph.nodes=a.data(),a.select("."+e().directionArrow).each(j),o.changeColorScheme(o.colorScheme),J(),o.centerView(r),u.exit().remove(),0===r?(u.attr("x1",(function(t){return t.source.x})).attr("y1",(function(t){return t.source.y})).attr("x2",(function(t){return t.target.x})).attr("y2",(function(t){return t.target.y})),V(u.enter()),o.graph.links=u.data(),J()):u.transition().attr("x1",(function(t){return t.source.x})).attr("y1",(function(t){return t.source.y})).attr("x2",(function(t){return t.target.x})).attr("y2",(function(t){return t.target.y})).duration(r).call((function(t,e){0===t.size()&&setTimeout(e,r);var n=0;t.each((function(){++n})).each("end",(function(){--n||e.apply(this,arguments)}))}),(function(){V(u.enter()),o.graph.links=u.data(),o.changeColorScheme(o.colorScheme),J(),void 0!==n&&n()})),0===r?l.attr("transform",(function(t){return void 0!==t.x&&void 0!==t.y?"translate("+[t.x,t.y]+")":""})):l.transition().attr("transform",(function(t){return void 0!==t.x&&void 0!==t.y?"translate("+[t.x,t.y]+")":""}))}};var G=function(){if(0===o.graph.nodes.length)return{translate:[0,0],scale:1};var t=s().min(o.graph.nodes.map((function(t){return t.x}))),e=s().min(o.graph.nodes.map((function(t){return t.y}))),n=s().max(o.graph.nodes.map((function(t){return t.x}))),r=s().max(o.graph.nodes.map((function(t){return t.y}))),i=s().max(o.graph.nodes.map((function(t){return t.radius}))),a=n-t,u=r-e,l=o.options.svgW/(a+1),c=o.options.svgH/(u+1),f=.8*Math.min(l,c,o.options.maxNodeRadius/i),d=a*f,h=u*f;return{translate:[-t*f+(o.options.svgW-d)/2,-e*f+(o.options.svgH-h)/2],scale:f}};o.centerView=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=G();null!==e&&(T.transition().attr("transform","translate("+e.translate+") scale("+e.scale+")").duration(t),o.zoomer.translate(e.translate),o.zoomer.scale(e.scale))},o.setSize=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s().select(t).node().offsetWidth,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s().select(t).node().offsetHeight;o.options.svgW=e,o.options.svgH=n,N.attr("viewBox","0 0 "+e+" "+n),B.range([0,e]).domain([0,e]),I.range([0,n]).domain([0,n]),o.zoomer.x(B).y(I),o.brusher.x(B).y(I),N.select(".background").attr("width",e).attr("height",n),o.centerView()},o.setOutlineColor=function(t){M.selectAll("g.gnode").select("[node_type=nucleotide]").style("fill",t)},o.addCustomColors=function(t){o.customColors=t,o.changeColorScheme("custom")},o.addCustomColorsText=function(t){var e=new p(t);o.customColors=e.colorsJson,o.changeColorScheme("custom")},o.changeColorScheme=function(t){M.selectAll("[node_type=protein]").classed(e().node,!0).attr("r",(function(t){return t.radius})),M.selectAll("g.gnode"),M.selectAll("g.gnode").selectAll("circle");var n=M.selectAll("g.gnode").select("[node_type=nucleotide]");if(o.colorScheme=t,"sequence"==t){var r=s().scale.ordinal().range(["#dbdb8d","#98df8a","#ff9896","#aec7e8","#aec7e8"]).domain(["A","C","G","U","T"]);n.style("fill",(function(t){return r(t.name)}))}else if("structure"==t)r=s().scale.category10().domain(["s","m","i","e","t","h","x"]).range(["lightgreen","#ff9896","#dbdb8d","lightsalmon","lightcyan","lightblue","transparent"]),n.style("fill",(function(t){return r(t.elemType)}));else if("positions"==t)n.style("fill",(function(t){return s().scale.linear().range(["#98df8a","#dbdb8d","#ff9896"]).interpolate(s().interpolateLab).domain([1,1+(t.rna.rnaLength-1)/2,t.rna.rnaLength])(t.num)}));else if("custom"==t){void 0!==o.customColors&&"domain"in o.customColors&&"range"in o.customColors&&(r=s().scale.linear().interpolate(s().interpolateLab).domain(o.customColors.domain).range(o.customColors.range));var i=function(t,e,n){if(t.hasOwnProperty(e.num)){var r=parseFloat(t[e.num]);return isNaN(r)?t[e.num]:n(r)}return"white"};n.style("fill",(function(t){if(void 0===o.customColors||!o.customColors.hasOwnProperty("colorValues"))return"white";if(o.customColors.colorValues.hasOwnProperty(t.structName)&&o.customColors.colorValues[t.structName].hasOwnProperty(t.num)){var e=o.customColors.colorValues[t.structName];return i(e,t,r)}if(o.customColors.colorValues.hasOwnProperty("")){var n=o.customColors.colorValues[""];return i(n,t,r)}return"white"}))}};var J=function(){M.selectAll("[node_type=label]").classed(e().transparent,!o.displayParameters.displayNumbering),M.selectAll("[label_type=label]").classed(e().transparent,!o.displayParameters.displayNumbering),_.selectAll("[link_type=label_link]").classed(e().transparent,!o.displayParameters.displayNumbering),N.selectAll("[node_type=nucleotide]").classed(e().transparent,!o.displayParameters.displayNodeOutline),M.selectAll("[label_type=nucleotide]").classed(e().transparent,!o.displayParameters.displayNodeLabel),N.selectAll("[link_type=real],[link_type=basepair],[link_type=backbone],[link_type=pseudoknot],[link_type=protein_chain],[link_type=chain_chain],[link_type=external]").classed(e().transparent,!o.displayParameters.displayLinks),N.selectAll("[link_type=pseudoknot]").classed(e().transparent,!o.displayParameters.displayPseudoknotLinks),N.selectAll("[link_type=protein_chain]").classed(e().transparent,!o.displayParameters.displayProteinLinks),_.selectAll("[link_type=fake]").classed(e().transparent,!o.options.displayAllLinks),_.selectAll("[link_type=fake_fake]").classed(e().transparent,!o.options.displayAllLinks),N.selectAll("."+e().directionArrow).classed(e().transparent,!o.displayParameters.displayDirectionArrows)},H=function(t,e){var n=e.rna,r=h.pairtableToDotbracket(n.pairtable),i=n.getPositions("nucleotide"),s=n.seq,u=n.getUids(),l=e.num,c=r,f=s.slice(0,l-1)+t+s.slice(l);console.log("newSequence:",f),console.log("uids:",u),u.splice(l-1,1,a.nice());var d=i;delete o.rnas[n.uid],o.addRNA(c,{sequence:f,positions:d,uids:u,centerView:!1})},K=function(t,e,n){var r=e.rna,i=h.pairtableToDotbracket(r.pairtable),s=r.getPositions("nucleotide"),u=r.seq,l=r.getUids(),c=e.num+n,f=i.slice(0,c)+"."+i.slice(c),d=u.slice(0,c)+t+u.slice(c);console.log("newSequence:",d),l.splice(c,0,a.nice()),s.splice(c,0,s[c-n-1]);var p=l,g=s;console.log("positions:",s),console.log("new node positions:",g),delete o.rnas[r.uid],o.addRNA(f,{sequence:d,positions:g,uids:p,centerView:!1})},Z=function(t){console.log("deleting...",t);var e=t.rna,n=e.pairtable[t.num];0!=n&&(e.pairtable[t.num]=0,e.pairtable[n]=0);var r=h.pairtableToDotbracket(e.pairtable),i=e.getPositions("nucleotide"),s=e.seq,a=e.getUids(),u=r.slice(0,t.num-1)+r.slice(t.num),l=i.slice(0,t.num-1).concat(i.slice(t.num)),c=s.slice(0,t.num-1)+s.slice(t.num),f=a.slice(0,t.num-1).concat(a.slice(t.num));delete o.rnas[e.uid],o.addRNA(u,{sequence:c,positions:l,uids:f,centerView:!1}),console.log("new dotbracket:",u)},Q=function(t){return t.uid},tt=function(t){var e=t.getPositions("nucleotide"),n=t.getPositions("label"),r=t.getUids();t.recalculateElements().elementsToJson().addPseudoknots().addPositions("nucleotide",e).addUids(r).addLabels(1,o.options.labelInterval).addPositions("label",n).reinforceStems().reinforceLoops().updateLinkUids()},et=function(t){if(t.target.num-t.source.num==1){for(var e=t.target.rna,n=[],r=0;r<e.links.length;r++){var i=e.links[r];"basepair"==i.linkType&&i.source.num<=t.source.num&&i.target.num>=t.target.num&&(console.log("crossing basepair",i),n.push(i))}console.log("toRemove:",n);for(var s=0;s<n.length;s++)e.pairtable[n[s].source.num]=0,e.pairtable[n[s].target.num]=0,n[s].from=n[s].source.num,n[s].to=n[s].target.num-t.source.num;e.seq;var u=e.seq.slice(0,t.source.num),l=e.seq.slice(t.source.num),c=h.pairtableToDotbracket(e.pairtable),f=c.slice(0,t.source.num),d=c.slice(t.source.num),p=e.getPositions("nucleotide"),g=e.getUids(),y=p.slice(0,t.source.num),m=p.slice(t.source.num),b=g.slice(0,t.source.num),v=g.slice(t.source.num);console.log("positions1:",y),console.log("positions2:",m),delete o.rnas[e.uid];for(var k=o.addRNA(f,{sequence:u,positions:y,uids:b}),x=o.addRNA(d,{sequence:l,positions:m,uids:v}),w=0;w<n.length;w++)console.log("rna1:",k),console.log("rna2:",x),console.log("toRemove[i]",n[w]),o.extraLinks.push({source:k.nodes[n[w].from-1],target:x.nodes[n[w].to-1],value:1,uid:a.nice(),linkType:"intermolecule"}),W(),o.update();console.log("self.extraLinks:",o.extraLinks)}else console.log("ERROR: non adjacent nodes. Target:",t.target,"Source:",t.source,"Link:",t)},nt=function(t){var e=o.graph.links.indexOf(t);if(console.log("removing link:",e),e>-1){if(t.source.rna==t.target.rna){if("backbone"==t.linkType)return console.log("trying to remove a backbone link",t.source.num,t.target.num),void et(t);var n=t.source.rna;n.addPseudoknots(),n.pairtable[t.source.num]=0,n.pairtable[t.target.num]=0,tt(n)}else{var r=o.extraLinks.indexOf(t);o.extraLinks.splice(r,1)}W()}o.update()},rt=function(t){var e=t.target.rna,n=t.source.rna;1==t.target.num&&(e=t.source.rna,n=t.target.rna);for(var r=h.pairtableToDotbracket(e.pairtable),i=h.pairtableToDotbracket(n.pairtable),s=e.seq,u=n.seq,l=e.getPositions("nucleotide"),c=n.getPositions("nucleotide"),f=r+i,d=s+u,p=l.concat(c),g=[],y={},m=0;m<o.extraLinks.length;m++)console.log("self.extraLinks[i]",o.extraLinks[m]),console.log("rna1:",e),console.log("rna2:",n),o.extraLinks[m].source.rna==e?o.extraLinks[m].target.rna==n||(g.push({source:o.extraLinks[m].target,target:o.extraLinks[m].source.num}),y[o.extraLinks[m].uid]=!0):o.extraLinks[m].source.rna==n&&(o.extraLinks[m].target.rna==e||(g.push({source:o.extraLinks[m].target,target:o.extraLinks[m].source.num+r.length}),y[o.extraLinks[m].uid]=!0)),o.extraLinks[m].target.rna==e?o.extraLinks[m].source.rna==n||(g.push({source:o.extraLinks[m].source,target:o.extraLinks[m].target.num}),y[o.extraLinks[m].uid]=!0):o.extraLinks[m].target.rna==n&&o.extraLinks[m].source.rna==e&&(g.push({source:o.extraLinks[m].source,target:o.extraLinks[m].target.num+r.length}),y[o.extraLinks[m].uid]=!0);o.extraLinks=o.extraLinks.filter((function(t){return!(t.uid in y)})),delete o.rnas[e.uid],delete o.rnas[n.uid];var b;b=o.options.animation?o.addRNA(f,{sequence:d,positions:p,centerView:!1}):o.addRNA(f,{sequence:d,centerView:!1});for(var v=0;v<g.length;v++)o.extraLinks.push({source:g[v].source,target:b.nodes[g[v].target-1],value:1,uid:a.nice(),linkType:"intermolecule"});W(),o.update(),console.log("self.extraLinks:",o.extraLinks)},ot=function(t,n){var r=!0;if(u){if("middle"==(c=t).nodeType||"middle"==u.nodeType||"label"==c.nodeType||"label"==u.nodeType)return;if(c==u)return void d();for(var i={source:u,target:c,linkType:"basepair",value:1,uid:a.nice()},s=0;s<o.graph.links.length;s++)if(o.graph.links[s].source!=u&&o.graph.links[s].target!=u&&o.graph.links[s].source!=c&&o.graph.links[s].target!=c||"basepair"!=o.graph.links[s].linkType&&"pseudoknot"!=o.graph.links[s].linkType&&"intermolecule"!=o.graph.links[s].linkType||(console.log("no basepair possible"),r=!1),(o.graph.links[s].source==c&&o.graph.links[s].target==u||o.graph.links[s].source==u&&o.graph.links[s].target==c)&&"backbone"==o.graph.links[s].linkType)return;if(i.source.rna!=i.target.rna)if(1==i.source.num&&i.target.num==i.target.rna.rnaLength||1==i.target.num&&i.source.num==i.source.rna.rnaLength){var h=[{title:"Backbone Link",action:function(t,n,r){f=!1,console.log("Item #1 clicked!"),console.log("The data for this circle is: "+n),S.attr("class",e().transparent),rt(i)},disabled:!1},{title:"Basepair Link",action:function(t,n,r){f=!1,console.log("You have clicked the second item!"),console.log("The data for this circle is: "+n),S.attr("class",e().transparent),o.addLink(i)}}];f=!0;var p=l(h);console.log("newLinkMenu"),p.apply(this,[t,n,!0,function(){S.attr("class",e().transparent)}])}else r&&o.addLink(i);else r&&o.addLink(i)}},it=function(t){console.log("nodeMousedown"),t.selected||v||O(),b||(v?C(t):U(t)),b&&o.options.editable&&(u=t,S.attr("class",e().dragLine).attr("x1",u.x).attr("y1",u.y).attr("x2",u.x).attr("y2",u.y),s().event.stopPropagation())},st=function(t){b&&(console.log("d.linkType:",t.linkType),t.linkType in{fake:!0,fake_fake:!0,label_link:!0}||nt(t))};o.toJSON=function(){var t={rnas:o.rnas,extraLinks:o.extraLinks};return JSON.stringify(t,(function(t,e){return"rna"==t?void 0:e}),"\t")},o.fromJSON=function(t){var e,n;try{var i=JSON.parse(t);e=i.rnas,n=i.extraLinks}catch(t){throw t}for(var s in e)"rna"==e[s].type?(r=new y,r.seq=e[s].seq,r.dotbracket=e[s].dotbracket,r.circular=e[s].circular,r.pairtable=e[s].pairtable,r.uid=e[s].uid,r.structName=e[s].structName,r.nodes=e[s].nodes,r.links=e[s].links,r.rnaLength=e[s].rnaLength,r.elements=e[s].elements,r.nucsToNodes=e[s].nucsToNodes,r.pseudoknotPairs=e[s].pseudoknotPairs):(r=new ProteinGraph,r.size=e[s].size,r.nodes=e[s].nodes,r.uid=e[s].uid),o.addRNAJSON(r,!1);n.forEach((function(t){o.extraLinks.push(t)})),W(),o.update()},o.addRNA=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=F(t,e);if("extraLinks"in e){var r=o.addExternalLinks(n,e.extraLinks);o.extraLinks=o.extraLinks.concat(r)}return"centerPos"in e?o.addRNAJSON(n,{centerPos:e.centerPos,centerView:!1}):"avoidOthers"in e?o.addRNAJSON(n,{avoidOthers:e.avoidOthers}):o.addRNAJSON(n,{centerView:e.centerView}),n},o.addRNAJSON=function(t,e){var n,r,i=e.avoidOthers,a=void 0!==i&&i,u=e.centerPos,l=void 0===u?null:u,c=e.centerView,f=void 0===c||c;if(null!=l){var d=0,h=0,p=0;t.nodes.forEach((function(t){d+=t.x,h+=t.y,p+=1})),p>0&&t.nodes.forEach((function(t){t.x=t.x+l[0]-d/p,t.y=t.y+l[1]-h/p,t.px=t.x,t.py=t.y}))}return a&&(n=o.graph.nodes.length>0?s().max(o.graph.nodes.map((function(t){return t.x}))):0,r=s().min(t.nodes.map((function(t){return t.x}))),t.nodes.forEach((function(t){t.x+=n-r+20,t.px+=n-r}))),t.nodes.forEach((function(e){e.rna=t})),o.rnas[t.uid]=t,W(),o.update(),f&&o.centerView(),t},o.addNodes=function(t){t.links.forEach((function(e){"number"==typeof e.source&&(e.source=t.nodes[e.source]),"number"==typeof e.target&&(e.target=t.nodes[e.target])})),o.graph.nodes.length>0?(maxX=s().max(o.graph.nodes.map((function(t){return t.x}))),maxY=s().max(o.graph.nodes.map((function(t){return t.y})))):(maxX=0,maxY=0),t.nodes.forEach((function(t){t.rna.uid in o.rnas||(o.rnas[t.rna.uid]=t.rna),t.x+=maxX,t.px+=maxX})),r=new y("",""),r.nodes=t.nodes,r.links=t.links,W(),o.update(),o.centerView()},o.clearNodes=function(){o.graph.nodes=[],o.graph.links=[],o.rnas={},o.extraLinks=[],o.update()},o.addLink=function(t){if(console.log("adding new link"),t.source.rna==t.target.rna){var e=t.source.rna;e.pairtable[t.source.num]=t.target.num,e.pairtable[t.target.num]=t.source.num,tt(e)}else console.log("intermolecule"),t.linkType="intermolecule",o.extraLinks.push(t);W(),o.update()},o.addExternalLinks=function(t,e){for(var n=[],r=0;r<e.length;r++){var o={linkType:"external",value:1,uid:a.nice(),source:null,target:null};if("[object Array]"===Object.prototype.toString.call(e[r][0])){for(var i=0;i<t.nodes.length;i++)if("nucs"in t.nodes[i]&&t.nodes[i].nucs.equals(e[r][0])){o.source=t.nodes[i];break}}else for(var s=0;s<t.nodes.length;s++)t.nodes[s].num==e[r][0]&&(o.source=t.nodes[s]);if("[object Array]"===Object.prototype.toString.call(e[r][1]))for(var u=0;u<t.nodes.length;u++)"nucs"in t.nodes[u]&&t.nodes[u].nucs.equals(e[r][1])&&(o.target=t.nodes[u]);else for(var l=0;l<t.nodes.length;l++)t.nodes[l].num==e[r][1]&&(o.target=t.nodes[l]);null!=o.source&&null!=o.target?n.push(o):console.log("ERROR: source or target of new link not found:",o,e[r])}return n},o.getStructuresDotBracket=function(){console.log("self.rnas:",o.rnas);var t=[],e=1,n={},r=[],i=[];for(var s in o.rnas){for(var a=o.rnas[s],u=0;u<a.nodes.length;u++){var l=a.nodes[u];"nucleotide"==l.nodeType&&(n[l.uid]=e,e+=1,t.push(l.name))}r.push(e)}i=[e-1];for(var c=0;c<e;c++)i.push(0);for(var f in o.rnas)for(var d=o.rnas[f],p=0;p<d.links.length;p++){var g=d.links[p];if("basepair"==g.linkType){var y=n[g.source.uid],m=n[g.target.uid];i[y]=m,i[m]=y}}for(var b=0;b<o.extraLinks.length;b++){var v=o.extraLinks[b],k=n[v.source.uid],x=n[v.target.uid];i[k]=x,i[x]=k}for(var w=h.pairtableToDotbracket(i).split(""),E=0;E<r.length-1;E++)console.log("breaks[i]:",r[E]),t.splice(r[E]+E-1,0,"&"),w.splice(r[E]+E-1,0,"&");return [t.join(""),w.join("")]},o.startAnimation=function(){o.options.animation=!0,T.selectAll("g.gnode").call(D),o.force.start()},o.stopAnimation=function(){o.options.animation=!1,T.selectAll("g.gnode").on("mousedown.drag",null),o.force.stop()},o.resumeForce=function(){o.options.animation&&o.force.resume()},o.setFriction=function(t){o.force.friction(t),o.resumeForce()},o.setCharge=function(t){o.force.charge(t),o.resumeForce()},o.setGravity=function(t){o.force.gravity(t),o.resumeForce()},o.setPseudoknotStrength=function(t){o.linkStrengths.pseudoknot=t,o.update()},o.displayNumbering=function(t){o.displayParameters.displayNumbering=t,J()},o.displayNodeOutline=function(t){o.displayParameters.displayNodeOutline=t,J()},o.displayNodeLabel=function(t){o.displayParameters.displayNodeLabel=t,J()},o.displayLinks=function(t){o.displayParameters.displayLinks=t,J()},o.displayPseudoknotLinks=function(t){o.displayParameters.displayPseudoknotLinks=t,J()},o.displayProteinLinks=function(t){o.displayParameters.displayProteinLinks=t,J()},o.displayDirectionArrows=function(t){o.displayParameters.displayDirectionArrows=t,J()}}function T(){var t,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o={width:300,height:300,nucleotideRadius:5,rnaEdgePadding:1,labelInterval:10,showNucleotideLabels:!0,startNucleotideNumber:1,bundleExternalLinks:!1,rnaLayout:"simple",namePosition:"0 0"};function i(e,r){var i=d3.extent(e),s=d3.extent(r);i[0]-=o.nucleotideRadius+o.rnaEdgePadding,s[0]-=o.nucleotideRadius+o.rnaEdgePadding,i[1]+=o.nucleotideRadius+o.rnaEdgePadding,s[1]+=o.nucleotideRadius+o.rnaEdgePadding;var a,u=i[1]-i[0],l=s[1]-s[0];function c(t,e,n){var r=(t.range()[1]-t.range()[0])/(t.domain()[1]-t.domain()[0]),o=(e[1]-e[0])*r,i=(n[1]-n[0]-o)/2;return{scaleFactor:r,scale:d3.scale.linear().domain(e).range([n[0]+i,n[1]-i])}}return u-o.width>l-o.height?(a=c(t=d3.scale.linear().domain(i).range([0,o.width]),s,[0,o.height]),n=a.scale):(a=c(n=d3.scale.linear().domain(s).range([0,o.height]),i,[0,o.width]),t=a.scale),t.range()[0],t.domain()[0],n.range()[0],n.domain()[0],"translate("+-(t.domain()[0]*a.scaleFactor-t.range()[0])+","+-(n.domain()[0]*a.scaleFactor-n.range()[0])+")scale("+a.scaleFactor+")"}function s(t,n){var r=t.selectAll(".gnode").data(n).enter().append("svg:g").classed("gnode",!0).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"}));r.append("svg:circle").classed(e().node,!0).attr("node_type","nucleotide").attr("base_type",(function(t){if(t.name)return t.name.toLowerCase()})).attr("r",o.nucleotideRadius),o.showNucleotideLabels&&r.append("svg:text").text((function(t){return t.name})).classed(e().nodeLabel,!0).append("svg:title").text((function(t){return t.struct_name+":"+t.num}))}function a(t,n){var r=t.selectAll().data(n).enter().append("svg:g").classed("gnode",!0).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"}));r.append("svg:circle").classed(e().node,!0).attr("node_type","label").attr("r",o.nucleotideRadius),r.append("svg:text").classed(e().nodeLabel,!0).text((function(t){return t.name}))}function u(t,n){var r=t.append("svg:text").classed(e().plotLabel,!0).text(n),i=o.namePosition.split(" ",2),s=[],a=r.node().getBBox(),u=[a.width,a.height],l=[o.width,o.height];for(var c in[0,1])switch(i[c]){case"0":s[c]=u[c]/2;break;case"1":s[c]=l[c]-u[c]/2;break;case"0.5":s[c]=l[c]/2}r.attr("x",s[0]).attr("y",s[1])}function l(t,e){var n={},r=[];e=e.filter((function(t){return"correct"==t.linkType||"incorrect"==t.linkType||"extra"==t.linkType})),t.selectAll("[link-type=extra]").remove();for(var o=0;o<e.length;o++)null!==e[o].source&&null!==e[o].target&&(n[e[o].source.uid]=e[o].source,n[e[o].target.uid]=e[o].target,r.push({source:e[o].source.uid,target:e[o].target.uid,linkType:e[o].linkType,extraLinkType:e[o].extraLinkType}));var i=d3.ForceEdgeBundling().nodes(n).edges(r).compatibility_threshold(.8).step_size(.2)(),s=d3.svg.line().x((function(t){return t.x})).y((function(t){return t.y})).interpolate("linear");for(o=0;o<i.length;o++){var a=i[o];t.append("path").attr("d",s(a)).style("fill","none").attr("link-type",(function(t){return r[o].linkType})).attr("extra-link-type",(function(t){return r[o].extraLinkType})).style("stroke-opacity",.4)}}function c(t,n){n=n.filter((function(t){return null!==t.source&&null!==t.target})),t.selectAll(".link").data(n).enter().append("svg:line").attr("x1",(function(t){return t.source.x})).attr("x2",(function(t){return t.target.x})).attr("y1",(function(t){return t.source.y})).attr("y2",(function(t){return t.target.y})).attr("link-type",(function(t){return t.linkType})).attr("extra-link-type",(function(t){return t.extraLinkType})).classed("link",!0).classed(e().link,!0)}function f(t){t.each((function(t){var n=d3.select(this).append("g").classed(e().plot,!0),r=new y(t.sequence,t.structure,t.name,o.startNucleotideNumber).recalculateElements().elementsToJson().addName(t.name);t.rnaGraph=r;var f=[];if("naview"===o.rnaLayout)for(var d=(new E).naview_xy_coordinates(r.pairtable),h=0;h<d.nbase;h++)f.push([d.x[h],d.y[h]]);else f=m(r.pairtable);r.addPositions("nucleotide",f).addLabels(o.startNucleotideNumber,o.labelInterval);var p=i(r.nodes.map((function(t){return t.x})),r.nodes.map((function(t){return t.y})));n.attr("transform",p);var g=r.nodes.filter((function(t){return"nucleotide"==t.nodeType})),b=r.nodes.filter((function(t){return"label"==t.nodeType})),v=r.links;c(n,v),s(n,g),a(n,b),u(d3.select(this),t.name),o.bundleExternalLinks&&l(n,v)}))}return o=Object.assign(o,r),f.width=function(t){return arguments.length?(o.width=t,f):o.width},f.height=function(t){return arguments.length?(o.height=t,f):o.height},f.showNucleotideLabels=function(t){return arguments.length?(o.showNucleotideLabels=t,f):o.showNucleotideLabels},f.rnaEdgePadding=function(t){return arguments.length?(o.rnaEdgePadding=t,f):o.rnaEdgePadding},f.nucleotideRadius=function(t){return arguments.length?(o.nucleotideRadius=t,f):o.nucleotideRadius},f.labelInterval=function(t){return arguments.length?(o.labelInterval=t,f):o.labelInterval},f.showNucleotideLabels=function(t){return arguments.length?(o.showNucleotideLabels=t,f):o.showNucleotideLabels},f.startNucleotideNumber=function(t){return arguments.length?(o.startNucleotideNumber=t,f):o.startNucleotideNumber},f.bundleExternalLinks=function(t){return arguments.length?(o.bundleExternalLinks=t,f):o.bundleExternalLinks},f.rnaLayout=function(t){return arguments.length?(o.rnaLayout=t,f):o.rnaLayout},f.namePosition=function(t){return arguments.length?(o.namePosition=t,f):o.namePosition},f}function _(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={width:300,height:300,nucleotideRadius:5,rnaEdgePadding:1,labelInterval:10,showNucleotideLabels:!0,startNucleotideNumber:1,bundleExternalLinks:!1,rnaLayout:"simple",namePosition:"0 0"};function n(t){t.each((function(t){d3.select(this).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})).append("rect").attr("fill","transparent").attr("width",(function(t){return Math.max(0,t.dx)})).attr("height",(function(t){return Math.max(0,t.dy)}));var n=T(e).width(Math.max(0,t.dx)).height(Math.max(0,t.dy));"structure"in t&&d3.select(this).call(n)}))}e=Object.assign(e,t);var r=function(t){t.each((function(t){console.log("data:",t);var r=d3.layout.treemap().size([e.width,e.height]).sticky(!1).value((function(t){return t.size}));d3.select(this).append("g").classed("rnatreemap",!0).datum(t).selectAll(".treemapnode").data(r.nodes).enter().append("g").classed("treemapnode",!0).call(n)}))};return r.width=function(t){return arguments.length?(e.width=t,r):e.width},r.height=function(t){return arguments.length?(e.height=t,r):e.height},r.showNucleotideLabels=function(t){return arguments.length?(e.showNucleotideLabels=t,r):e.showNucleotideLabels},r.rnaEdgePadding=function(t){return arguments.length?(e.rnaEdgePadding=t,r):e.rnaEdgePadding},r.nucleotideRadius=function(t){return arguments.length?(e.nucleotideRadius=t,r):e.nucleotideRadius},r.labelInterval=function(t){return arguments.length?(e.labelInterval=t,r):e.labelInterval},r.showNucleotideLabels=function(t){return arguments.length?(e.showNucleotideLabels=t,r):e.showNucleotideLabels},r.startNucleotideNumber=function(t){return arguments.length?(e.startNucleotideNumber=t,r):e.startNucleotideNumber},r.bundleExternalLinks=function(t){return arguments.length?(e.bundleExternalLinks=t,r):e.bundleExternalLinks},r.rnaLayout=function(t){return arguments.length?(e.rnaLayout=t,r):e.rnaLayout},r.namePosition=function(t){return arguments.length?(e.namePosition=t,r):e.namePosition},r.zoom=function(t){return arguments.length?(e.zoom=t,r):e.zoom},r}E.prototype.naview_xy_coordinates=function(t){var e,n=[],r=[];if(0===t.length||0===t[0])return 0;this.nbase=t[0],this.bases=[];for(var o=0;o<this.nbase+1;o++)this.bases.push(new x);for(this.regions=[],o=0;o<this.nbase+1;o++)this.regions.push(new k.y);for(this.read_in_bases(t),this.rlphead=null,this.find_regions(),this.loop_count=0,this.loops=[],o=0;o<this.nbase+1;o++)this.loops.push(new w.r);for(this.construct_loop(0),this.find_central_loop(),this.traverse_loop(this.root,null),e=0;e<this.nbase;e++)n.push(100+this.BACKBONE_DISTANCE*this.bases[e+1].getX()),r.push(100+this.BACKBONE_DISTANCE*this.bases[e+1].getY());return{nbase:this.nbase,x:n,y:r}},E.prototype.read_in_bases=function(t){var e=null,n=null;for(this.bases.push(new x),this.bases[0].setMate(0),this.bases[0].setExtracted(!1),this.bases[0].setX(this.ANUM),this.bases[0].setY(this.ANUM),n=0,e=1;e<=this.nbase;e++)this.bases.push(new x),this.bases[e].setExtracted(!1),this.bases[e].setX(this.ANUM),this.bases[e].setY(this.ANUM),this.bases[e].setMate(t[e]),t[e]>e&&n++;0==n&&(this.bases[1].setMate(this.nbase),this.bases[this.nbase].setMate(1))},E.prototype.find_regions=function(){var t,e=null,n=null;t=this.nbase+1;var r=[];for(e=0;e<t;e++)r.push(!1);for(this.nregion=0,e=0;e<=this.nbase;e++)if(0!=(n=this.bases[e].getMate())&&!r[e]){for(this.regions[this.nregion].setStart1(e),this.regions[this.nregion].setEnd2(n),r[e]=!0,r[n]=!0,this.bases[e].setRegion(this.regions[this.nregion]),this.bases[n].setRegion(this.regions[this.nregion]),e++,n--;e<n&&this.bases[e].getMate()==n;e++,n--)r[n]=!0,r[e]=!0,this.bases[e].setRegion(this.regions[this.nregion]),this.bases[n].setRegion(this.regions[this.nregion]);this.regions[this.nregion].setEnd1(--e),this.regions[this.nregion].setStart2(n+1),this.nregion++}},E.prototype.construct_loop=function(t){var e=null,n=null,r=new w.r,o=new w.r,i=new v.Connection,s=new k.y,a=new b;for((r=this.loops[this.loop_count++]).setNconnection(0),r.setDepth(0),r.setNumber(this.loop_count),r.setRadius(0),a=this.rlphead;null!=a;a=a.getNext())a.getLoopnumber()==this.loop_count&&r.setRadius(a.getRadius());e=t;do{0!=(n=this.bases[e].getMate())&&(s=this.bases[e].getRegion(),this.bases[s.getStart1()].isExtracted()||(e==s.getStart1()?(this.bases[s.getStart1()].setExtracted(!0),this.bases[s.getEnd1()].setExtracted(!0),this.bases[s.getStart2()].setExtracted(!0),this.bases[s.getEnd2()].setExtracted(!0),o=this.construct_loop(s.getEnd1()<this.nbase?s.getEnd1()+1:0)):e==s.getStart2()?(this.bases[s.getStart2()].setExtracted(!0),this.bases[s.getEnd2()].setExtracted(!0),this.bases[s.getStart1()].setExtracted(!0),this.bases[s.getEnd1()].setExtracted(!0),o=this.construct_loop(s.getEnd2()<this.nbase?s.getEnd2()+1:0)):console.log("Something went terribly wrong ...."),r.setNconnection(r.getNconnection()+1),i=new v.Connection,r.setConnection(r.getNconnection()-1,i),r.setConnection(r.getNconnection(),null),i.setLoop(o),i.setRegion(s),e==s.getStart1()?(i.setStart(s.getStart1()),i.setEnd(s.getEnd2())):(i.setStart(s.getStart2()),i.setEnd(s.getEnd1())),i.setExtruded(!1),i.setBroken(!1),o.setNconnection(o.getNconnection()+1),i=new v.Connection,o.setConnection(o.getNconnection()-1,i),o.setConnection(o.getNconnection(),null),i.setLoop(r),i.setRegion(s),e==s.getStart1()?(i.setStart(s.getStart2()),i.setEnd(s.getEnd1())):(i.setStart(s.getStart1()),i.setEnd(s.getEnd2())),i.setExtruded(!1),i.setBroken(!1)),e=n),++e>this.nbase&&(e=0)}while(e!=t);return r},E.prototype.find_central_loop=function(){var t=new w.r,e=null,n=null,r=null;for(A.bind(this)(),e=0,n=-1,r=0;r<this.loop_count;r++)(t=this.loops[r]).getNconnection()>e?(n=t.getDepth(),e=t.getNconnection(),this.root=t):t.getDepth()>n&&t.getNconnection()==e&&(n=t.getDepth(),this.root=t)},E.prototype.traverse_loop=function(t,e){var n,r,o,i,s,a,u,l,c,f,d,h,p,g,y,m,b,v,k,x,w,E,A,N,L,T,_,M,S,B,I,P,R,C,U,O,X,Y,q,D,F,z,V,j,$,W,G,J,H,K,Z,Q,tt,et,nt,rt,ot,it,st,at,ut,lt,ct,ft,dt,ht,pt,gt,yt,mt=0;a=2*Math.PI/(this.nbase+1),v=null,B=-1;var bt=0;for(A=0;null!=(m=t.getConnection(bt));bt++,A++)n=-Math.sin(a*m.getStart()),r=Math.cos(a*m.getStart()),o=-Math.sin(a*m.getEnd()),i=Math.cos(a*m.getEnd())-r,s=n-o,u=Math.sqrt(i*i+s*s),m.setXrad(i/u),m.setYrad(s/u),m.setAngle(Math.atan2(s,i)),m.getAngle()<0&&m.setAngle(m.getAngle()+2*Math.PI),null!=e&&e.getRegion()==m.getRegion()&&(v=m,B=A);t:for(;;){this.determine_radius(t,this.lencut),l=t.getRadius()/this.RADIUS_REDUCTION_FACTOR,null==e?c=f=0:(d=(this.bases[v.getStart()].getX()+this.bases[v.getEnd()].getX())/2,h=(this.bases[v.getStart()].getY()+this.bases[v.getEnd()].getY())/2,c=d-l*v.getXrad(),f=h-l*v.getYrad()),_=-1==B?0:B,m=t.getConnection(_),T=0,I=!1;do{if((w=_-1)<0&&(w=t.getNconnection()-1),k=t.getConnection(w),this.connected_connection(k,m)?(_=w,m=k):I=!0,++T>t.getNconnection()){for(L=-1,A=0;A<t.getNconnection();A++)(w=A+1)>=t.getNconnection()&&(w=0),m=t.getConnection(A),(dt=(b=t.getConnection(w)).getAngle()-m.getAngle())<0&&(dt+=2*Math.PI),dt>L&&(L=dt,mt=A);M=mt,(_=mt+1)>=t.getNconnection()&&(_=0),(m=t.getConnection(M)).setBroken(!0),I=!0}}while(!I);for(P=!1,W=_;!P;){for(T=0,I=!1,M=_,R=!1;!I;)if(m=t.getConnection(M),M==B&&(R=!0),(w=M+1)>=t.getNconnection()&&(w=0),b=t.getConnection(w),this.connected_connection(m,b)){if(++T>=t.getNconnection())break;M=w}else I=!0;for(A=G=J=S=this.find_ic_middle(_,M,e,v,t),I=!1,K=0;!I;)(A=K<0?G:0==K?S:J)>=0&&(m=t.getConnection(A),null!=e&&v==m||(0==K?(p=m.getAngle()-Math.asin(.5/l),g=m.getAngle()+Math.asin(.5/l),this.bases[m.getStart()].setX(c+l*Math.cos(p)),this.bases[m.getStart()].setY(f+l*Math.sin(p)),this.bases[m.getEnd()].setX(c+l*Math.cos(g)),this.bases[m.getEnd()].setY(f+l*Math.sin(g))):K<0?((w=A+1)>=t.getNconnection()&&(w=0),m=t.getConnection(A),b=t.getConnection(w),nt=m.getXrad(),rt=m.getYrad(),dt=(m.getAngle()+b.getAngle())/2,m.getAngle()>b.getAngle()&&(dt-=Math.PI),st=Math.cos(dt),lt=Math.sin(dt),ct=-st,(N=b.getAngle()-m.getAngle())<0&&(N+=2*Math.PI),ft=m.isExtruded()?N<=Math.PI/2?2:1.5:1,this.bases[m.getEnd()].setX(this.bases[b.getStart()].getX()+ft*lt),this.bases[m.getEnd()].setY(this.bases[b.getStart()].getY()+ft*ct),this.bases[m.getStart()].setX(this.bases[m.getEnd()].getX()+rt),this.bases[m.getStart()].setY(this.bases[m.getEnd()].getY()-nt)):((w=A-1)<0&&(w=t.getNconnection()-1),m=t.getConnection(w),ot=(b=t.getConnection(A)).getXrad(),it=b.getYrad(),dt=(m.getAngle()+b.getAngle())/2,m.getAngle()>b.getAngle()&&(dt-=Math.PI),st=Math.cos(dt),lt=-Math.sin(dt),ct=st,(N=b.getAngle()-m.getAngle())<0&&(N+=2*Math.PI),ft=m.isExtruded()?N<=Math.PI/2?2:1.5:1,this.bases[b.getStart()].setX(this.bases[m.getEnd()].getX()+ft*lt),this.bases[b.getStart()].setY(this.bases[m.getEnd()].getY()+ft*ct),this.bases[b.getEnd()].setX(this.bases[b.getStart()].getX()-it),this.bases[b.getEnd()].setY(this.bases[b.getStart()].getY()+ot)))),K<0?(J==M?J=-1:J>=0&&++J>=t.getNconnection()&&(J=0),K=1):(G==_?G=-1:G>=0&&--G<0&&(G=t.getNconnection()-1),K=-1),I=-1==G&&-1==J;if((H=M+1)>=t.getNconnection()&&(H=0),M!=_&&(_!=W||H!=W))if(m=t.getConnection(_),b=t.getConnection(M),Q=this.bases[b.getEnd()].getX()-this.bases[m.getStart()].getX(),tt=this.bases[b.getEnd()].getY()-this.bases[m.getStart()].getY(),U=this.bases[m.getStart()].getX()+Q/2,O=this.bases[m.getStart()].getY()+tt/2,q=Q/(et=Math.sqrt(Q*Q+tt*tt)),D=tt/et,F=c-U,z=f-O,X=(V=(F/=et=Math.sqrt(Q*Q+tt*tt))*q+(z/=et)*D)*q-F,Y=V*D-z,X/=et=Math.sqrt(X*X+Y*Y),Y/=et,Q=this.bases[m.getStart()].getX()-c,tt=this.bases[m.getStart()].getY()-f,(dt=Math.atan2(tt,Q))<0&&(dt+=2*Math.PI),Q=this.bases[b.getEnd()].getX()-c,tt=this.bases[b.getEnd()].getY()-f,(ht=Math.atan2(tt,Q))<0&&(ht+=2*Math.PI),ht<dt&&(ht+=2*Math.PI),j=c+(C=ht-dt>Math.PI?-1:1)*l*X,$=f+C*l*Y,R)c-=j-U,f-=$-O;else for(A=_;x=(m=t.getConnection(A)).getStart(),this.bases[x].setX(this.bases[x].getX()+j-U),this.bases[x].setY(this.bases[x].getY()+$-O),x=m.getEnd(),this.bases[x].setX(this.bases[x].getX()+j-U),this.bases[x].setY(this.bases[x].getY()+$-O),A!=M;)++A>=t.getNconnection()&&(A=0);P=(_=H)==W}for(A=0;A<t.getNconnection();A++){if(m=t.getConnection(A),(w=A+1)>=t.getNconnection()&&(w=0),b=t.getConnection(w),Q=this.bases[m.getEnd()].getX()-c,tt=this.bases[m.getEnd()].getY()-f,ut=Math.sqrt(Q*Q+tt*tt),(dt=Math.atan2(tt,Q))<0&&(dt+=2*Math.PI),Q=this.bases[b.getStart()].getX()-c,tt=this.bases[b.getStart()].getY()-f,at=Math.sqrt(Q*Q+tt*tt),(ht=Math.atan2(tt,Q))<0&&(ht+=2*Math.PI),ht<dt&&(ht+=2*Math.PI),Z=ht-dt,(yt=b.getAngle()-m.getAngle())<=0&&(yt+=2*Math.PI),Math.abs(Z-yt)>Math.PI)if(m.isExtruded())console.log("Warning from traverse_loop. Loop "+t.getNumber()+" has crossed regions\n");else if(b.getStart()-m.getEnd()!=1){m.setExtruded(!0);continue t}if(m.isExtruded())this.construct_extruded_segment(m,b);else for((E=b.getStart()-m.getEnd())<0&&(E+=this.nbase+1),a=Z/E,w=1;w<E;w++)(x=m.getEnd()+w)>this.nbase&&(x-=this.nbase+1),et=ut+(at-ut)*((y=dt+w*a)-dt)/Z,this.bases[x].setX(c+et*Math.cos(y)),this.bases[x].setY(f+et*Math.sin(y))}break}for(A=0;A<t.getNconnection();A++)B!=A&&(m=t.getConnection(A),this.generate_region(m),this.traverse_loop(m.getLoop(),m));for(E=0,pt=0,gt=0,A=0;A<t.getNconnection();A++)if((w=A+1)>=t.getNconnection()&&(w=0),m=t.getConnection(A),b=t.getConnection(w),E+=2,pt+=this.bases[m.getStart()].getX()+this.bases[m.getEnd()].getX(),gt+=this.bases[m.getStart()].getY()+this.bases[m.getEnd()].getY(),!m.isExtruded())for(w=m.getEnd()+1;w!=b.getStart();w++)w>this.nbase&&(w-=this.nbase+1),E++,pt+=this.bases[w].getX(),gt+=this.bases[w].getY();t.setX(pt/E),t.setY(gt/E)},E.prototype.determine_radius=function(t,e){var n,r,o,i,s,a,u,l,c,f,d,h=0,p=new v.Connection,g=new v.Connection,y=.7071068;do{for(n=1e10,s=0,i=0,l=0;l<t.getNconnection();l++)p=t.getConnection(l),(c=l+1)>=t.getNconnection()&&(c=0),g=t.getConnection(c),f=p.getEnd(),(d=g.getStart())<f&&(d+=this.nbase+1),(o=g.getAngle()-p.getAngle())<=0&&(o+=2*Math.PI),i+=o*(1/(r=p.isExtruded()?o<=Math.PI/2?2:1.5:d-f)+1),s+=o*o/r,(u=o/r)<n&&!p.isExtruded()&&r>1&&(n=u,h=l);(a=i/s)<y&&(a=y),n*a<e&&t.getConnection(h).setExtruded(!0)}while(n*a<e);t.getRadius()>0?a=t.getRadius():t.setRadius(a)},E.prototype.find_ic_middle=function(t,e,n,r,o){var i,s,a,u,l;for(i=0,s=-1,a=t,l=!1;!l;)i++>2*o.getNconnection()&&console.log("Infinite loop in 'find_ic_middle'"),null!=n&&o.getConnection(a)==r&&(s=a),l=a==e,++a>=o.getNconnection()&&(a=0);if(-1==s){for(u=1,a=t;u<(i+1)/2;u++)++a>=o.getNconnection()&&(a=0);s=a}return s},E.prototype.construct_extruded_segment=function(t,e){var n,r,o,i,s,a,u,l,c,f,d,h,p,g,y,m,b,v;if(n=t.getAngle(),(o=r=e.getAngle())<n&&(o+=2*Math.PI),i=(n+o)/2,p=t.getEnd(),(y=(g=e.getStart())-p)<0&&(y+=this.nbase+1),(d=e.getAngle()-t.getAngle())<0&&(d+=2*Math.PI),2==y)this.construct_circle_segment(p,g);else{s=this.bases[g].getX()-this.bases[p].getX(),a=this.bases[g].getY()-this.bases[p].getY(),s/=f=Math.sqrt(s*s+a*a),a/=f,f>=1.5&&d<=Math.PI/2&&((m=p+1)>this.nbase&&(m-=this.nbase+1),(b=g-1)<0&&(b+=this.nbase+1),this.bases[m].setX(this.bases[p].getX()+.5*s),this.bases[m].setY(this.bases[p].getY()+.5*a),this.bases[b].setX(this.bases[g].getX()-.5*s),this.bases[b].setY(this.bases[g].getY()-.5*a),p=m,g=b);do{v=!1,this.construct_circle_segment(p,g),(m=p+1)>this.nbase&&(m-=this.nbase+1),s=this.bases[m].getX()-this.bases[p].getX(),a=this.bases[m].getY()-this.bases[p].getY(),(u=Math.atan2(a,s))<0&&(u+=2*Math.PI),(h=u-n)<0&&(h+=2*Math.PI),h>Math.PI&&(v=!0),(b=g-1)<0&&(b+=this.nbase+1),s=this.bases[b].getX()-this.bases[g].getX(),a=this.bases[b].getY()-this.bases[g].getY(),(l=Math.atan2(a,s))<0&&(l+=2*Math.PI),(h=r-l)<0&&(h+=2*Math.PI),h>Math.PI&&(v=!0),v&&(c=this.minf2(i,n+.5),this.bases[m].setX(this.bases[p].getX()+Math.cos(c)),this.bases[m].setY(this.bases[p].getY()+Math.sin(c)),p=m,c=this.maxf2(i,o-.5),this.bases[b].setX(this.bases[g].getX()+Math.cos(c)),this.bases[b].setY(this.bases[g].getY()+Math.sin(c)),g=b,y-=2)}while(v&&y>1)}},E.prototype.construct_circle_segment=function(t,e){var n,r,o,i,s,a,u,l,c,f,d,h,p,g,y;if(n=this.bases[e].getX()-this.bases[t].getX(),r=this.bases[e].getY()-this.bases[t].getY(),o=Math.sqrt(n*n+r*r),(p=e-t)<0&&(p+=this.nbase+1),o>=p)for(n/=o,r/=o,g=1;g<p;g++)(y=t+g)>this.nbase&&(y-=this.nbase+1),this.bases[y].setX(this.bases[t].getX()+n*g/p),this.bases[y].setY(this.bases[t].getY()+r*g/p);else for(this.find_center_for_arc(p-1,o),n/=o,r/=o,i=this.bases[t].getX()+n*o/2,s=this.bases[t].getY()+r*o/2,a=r,u=-n,l=i+this._h*a,c=s+this._h*u,f=this.bases[t].getX()-l,d=this.bases[t].getY()-c,o=Math.sqrt(f*f+d*d),h=Math.atan2(d,f),g=1;g<p;g++)(y=t+g)>this.nbase&&(y-=this.nbase+1),this.bases[y].setX(l+o*Math.cos(h+g*this.angleinc)),this.bases[y].setY(c+o*Math.sin(h+g*this.angleinc))},E.prototype.find_center_for_arc=function(t,e){var n,r,o,i,s,a,u,l;o=-(r=(t+1)/Math.PI)-e/(t+1.000001-e),e<1&&(o=0),l=0;do{n=(r+o)/2,s=1-.5/((i=Math.sqrt(n*n+e*e/4))*i),Math.abs(s)>1&&console.log("Unexpected large magnitude discriminant = "+s+" "+i),(u=(a=Math.acos(s))*(t+1)+2*Math.acos(n/i)-2*Math.PI)>0?o=n:r=n}while(Math.abs(u)>1e-4&&++l<this.MAXITER);l>=this.MAXITER&&(noIterationFailureYet&&(console.log("Iteration failed in find_center_for_arc"),noIterationFailureYet=!1),n=0,a=0),this._h=n,this.angleinc=a},E.prototype.generate_region=function(t){var e,n,r,o,i,s;for(s=t.getRegion(),e=0,t.getStart()==s.getStart1()?(n=s.getStart1(),r=s.getEnd1()):(n=s.getStart2(),r=s.getEnd2()),(this.bases[t.getStart()].getX()>this.ANUM-100||this.bases[t.getEnd()].getX()>this.ANUM-100)&&console.log("Bad region passed to generate_region. Coordinates not defined."),o=n+1;o<=r;o++)e++,this.bases[o].setX(this.bases[t.getStart()].getX()+this.HELIX_FACTOR*e*t.getXrad()),this.bases[o].setY(this.bases[t.getStart()].getY()+this.HELIX_FACTOR*e*t.getYrad()),i=this.bases[o].getMate(),this.bases[i].setX(this.bases[t.getEnd()].getX()+this.HELIX_FACTOR*e*t.getXrad()),this.bases[i].setY(this.bases[t.getEnd()].getY()+this.HELIX_FACTOR*e*t.getYrad())},E.prototype.minf2=function(t,e){return t<e?t:e},E.prototype.maxf2=function(t,e){return t>e?t:e},E.prototype.connected_connection=function(t,e){return!!t.isExtruded()||t.getEnd()+1==e.getStart()}})(),i})()}));
3
+ //# sourceMappingURL=fornac.js.map