// simple log(c) form

/*
===============================================================================
Crc32 is a JavaScript function for computing the CRC32 of a string
...............................................................................

Version: 1.2 - 2006/11 - http://noteslog.com/category/javascript/

-------------------------------------------------------------------------------
Copyright (c) 2006 Andrea Ercolino
http://www.opensource.org/licenses/mit-license.php
===============================================================================
*/

/*
* jQuery Mobile Framework : "mouse" plugin
* Copyright (c) jQuery Project
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/

/*!
 * Raphael 1.5.2 - JavaScript Vector Library
 *
 * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
 * Licensed under the MIT (http://raphaeljs.com/license.html) license.
 */

/*! Perseus | http://github.com/Khan/perseus */

// Based on Steven Levithan's MIT-licensed split, available at

/**
	     * A more strict encodeURIComponent that escapes `()'!`s
	     * Especially useful for creating URLs that are embeddable in markdown
	     *
	     * Adapted from
	     * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
	     * This function and the above original available under the
	     * CC-BY-SA 2.5 license.
	     */

/*
	 * A class for formatting number to significant digits.
	 * Copyright (C) 2001 Stephen Ostermiller
	 * http://ostermiller.org/contact.pl?regarding?JavaScript+Significant+Figures
	 *
	 * This program is free software; you can redistribute it and/or modify
	 * it under the terms of the GNU General Public License as published by
	 * the Free Software Foundation; either version 2 of the License, or
	 * (at your option) any later version.
	 *
	 * This program is distributed in the hope that it will be useful,
	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	 * GNU General Public License for more details.
	 */

/*
	Software License Agreement (BSD License)

	Copyright (c) 2009-2011, Kevin Decker <kpdecker@gmail.com>

	All rights reserved.

	Redistribution and use of this software in source and binary forms, with or without modification,
	are permitted provided that the following conditions are met:

	* Redistributions of source code must retain the above
	  copyright notice, this list of conditions and the
	  following disclaimer.

	* Redistributions in binary form must reproduce the above
	  copyright notice, this list of conditions and the
	  following disclaimer in the documentation and/or other
	  materials provided with the distribution.

	* Neither the name of Kevin Decker nor the names of its
	  contributors may be used to endorse or promote products
	  derived from this software without specific prior
	  written permission.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
	FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
	CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
	DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
	IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
	OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	*/

/**
	 * Simple-Markdown
	 * ===============
	 *
	 * Simple-Markdown's primary goal is to be easy to adapt. It aims
	 * to be compliant with John Gruber's [Markdown Syntax page][1],
	 * but compatiblity with other markdown implementations' edge-cases
	 * will be sacrificed where it conflicts with simplicity or
	 * extensibility.
	 *
	 * If your goal is to simply embed a standard markdown implementation
	 * in your website, simple-markdown is probably not the best library
	 * for you (although it should work). But if you have struggled to
	 * customize an existing library to meet your needs, simple-markdown
	 * might be able to help.
	 *
	 * Many of the regexes and original logic has been adapted from
	 * the wonderful [marked.js](https://github.com/chjj/marked)
	 *
	 * LICENSE (MIT):
	 * New code copyright (c) 2014 Khan Academy.
	 *
	 * Portions adapted from marked.js copyright (c) 2011-2014
	 * Christopher Jeffrey (https://github.com/chjj/).
	 *
	 * Permission is hereby granted, free of charge, to any person obtaining a copy
	 * of this software and associated documentation files (the "Software"), to deal
	 * in the Software without restriction, including without limitation the rights
	 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	 * copies of the Software, and to permit persons to whom the Software is
	 * furnished to do so, subject to the following conditions:
	 *
	 * The above copyright notice and this permission notice shall be included in
	 * all copies or substantial portions of the Software.
	 *
	 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	 * THE SOFTWARE.
	 */

/**
	 * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
	 * Build: `lodash modularize modern exports="npm" -o ./npm/`
	 * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
	 * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
	 * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	 * Available under MIT license <http://lodash.com/license>
	 */

/**
	 * Lo-Dash 2.4.3 (Custom Build) <http://lodash.com/>
	 * Build: `lodash modularize modern exports="npm" -o ./npm/`
	 * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
	 * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
	 * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	 * Available under MIT license <http://lodash.com/license>
	 */

define("../perseus/ke/utils/answer-types.js",["require"],function(e){function r(e){return $(e).text().replace(/\s+/g,"")}function i(e){return $.trim(e)===""||e instanceof Array&&$.trim(e.join("").replace(/,/g,""))===""}function s(e,t){e.data("qtip")&&e.qtip("destroy",!0);var n=$('<ul class="examples" style="display: none"></ul>');_.each(t,function(e){n.append("<li>"+e+"</li>")}),e.qtip({content:{text:n.remove(),prerender:!0},style:{classes:"qtip-light leaf-tooltip"},position:{my:"top left",at:"bottom left"},show:{delay:0,effect:{length:0},event:"focus"},hide:{delay:0,event:"blur"},events:{render:function(){n.children().runModules()}}})}function o(e){return{setupFunctional:function(t,n,r){return Khan.answerTypes.number.setupFunctional(t,n,$.extend({},r,{forms:e}))},createValidatorFunctional:function(t,n){return Khan.answerTypes.number.createValidatorFunctional(t,$.extend({},n,{forms:e}))}}}var t=Math.pow(2,-42),n=function(e){var t=$(e).clone(!0),n=t.find("code");return n.length&&$.each(n,function(e,t){$(t).replaceWith('<code><script type="math/tex">'+KhanUtil.retrieveMathFormula(t)+"</script></code>")}),t.html()};Khan.answerTypes=$.extend(Khan.answerTypes,{text:{setupFunctional:function(e,t,n){var r;return window.Modernizr&&Modernizr.touchevents?r=$('<input type="text" autocapitalize="off">'):r=$('<input type="text">'),$(e).append(r),{validator:Khan.answerTypes.text.createValidatorFunctional(t,n),answer:function(){return r.val()},solution:$.trim(t),showGuess:function(e){r.val(e===undefined?"":e)}}},createValidatorFunctional:function(e,t){return t=$.extend({correctCase:"required"},t),e=$.trim(e),function(n){var r=t.fallback!=null?""+t.fallback:"";n=$.trim(n)||r;var i={empty:!1,correct:!1,message:null,guess:n};return n.toLowerCase()===e.toLowerCase()&&(e===n||t.correctCase==="optional"?i.correct=!0:n===n.toLowerCase()?i.message=$._("Your answer is almost correct, but must be in capital letters."):n===n.toUpperCase()?i.message=$._("Your answer is almost correct, but must not be in capital letters."):i.message=$._("Your answer is almost correct, but must be in the correct case.")),i}}},predicate:{defaultForms:"integer, proper, improper, mixed, decimal",setupFunctional:function(e,n,r){var i=$.extend({simplify:"required",ratio:!1,forms:Khan.answerTypes.predicate.defaultForms},r),o=i.forms.split(/\s*,\s*/);i.inexact===undefined&&(i.maxError=0),i.maxError=+i.maxError+t;var u=$('<input type="text" autocapitalize="off">');$(e).append(u);var a={integer:$._("an integer, like <code>6</code>"),proper:function(){return i.simplify==="optional"?$._("a <em>proper</em> fraction, like <code>1/2</code> or <code>6/10</code>"):$._("a <em>simplified proper</em> fraction, like <code>3/5</code>")}(),improper:function(){return i.simplify==="optional"?$._("an <em>improper</em> fraction, like <code>10/7</code> or <code>14/8</code>"):$._("a <em>simplified improper</em> fraction, like <code>7/4</code>")}(),pi:$._("a multiple of pi, like <code>12\\ \\text{pi}</code> or <code>2/3\\ \\text{pi}</code>"),log:$._("an expression, like <code>\\log(100)</code>"),percent:$._("a percent, like <code>%(NUM)s\\%</code>",{NUM:KhanUtil.localeToFixed(12.34,2)}),mixed:$._("a mixed number, like <code>1\\ 3/4</code>"),decimal:function(){return i.inexact===undefined?$._("an <em>exact</em> decimal, like <code>%(NUM)s</code>",{NUM:KhanUtil.localeToFixed(.75,2)}):$._("a decimal, like <code>%(NUM)s</code>",{NUM:KhanUtil.localeToFixed(.75,2)})}()},f=[];return $.each(o,function(e,t){a[t]!=null&&f.push(a[t])}),i.forms!==Khan.answerTypes.predicate.defaultForms&&s(u,f),{validator:Khan.answerTypes.predicate.createValidatorFunctional(n,r),answer:function(){return u.val()},solution:$.trim(n),showGuess:function(e){u.val(e===undefined?"":e)}}},createValidatorFunctional:function(e,n){n=$.extend({simplify:"required",ratio:!1,forms:Khan.answerTypes.predicate.defaultForms},n);var r;_.isArray(n.forms)?r=n.forms:r=n.forms.split(/\s*,\s*/),n.inexact===undefined&&(n.maxError=0),n.maxError=+n.maxError+t,_.contains(r,"percent")&&(r=_.without(r,"percent"),r.push("percent")),e=_.isFunction(e)?e:KhanUtil.tmpl.getVAR(e);var i=function(e){e=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").replace(/(^\s*)|(\s*$)/gi,"");var t=e.match(/^([+-]?\d+)\s*\/\s*([+-]?\d+)$/),r=parseInt(e,10);if(t){var i=parseFloat(t[1]),s=parseFloat(t[2]),o=s>0&&(n.ratio||t[2]!=="1")&&KhanUtil.getGCD(i,s)===1;return[{value:i/s,exact:o}]}return!isNaN(r)&&""+r===e?[{value:r,exact:!0}]:[]},s={integer:function(e){var t=s.decimal(e),n=s.decimal(e,1);return t[0].value!=null&&t[0].value===n[0].value||t[1].value!=null&&t[1].value===n[1].value?t:[]},proper:function(e){return $.map(i(e),function(e){return Math.abs(e.value)<1?[e]:[]})},improper:function(e){return $.map(i(e),function(e){return Math.abs(e.value)>=1?[e]:[]})},pi:function(e){var t,n=[];e=e.replace(/\u2212/,"-");if(t=e.match(/^([+-]?)\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=[{value:parseFloat(t[1]+"1"),exact:!0}];else if(t=e.match(/^([+-]?\s*\d+\s*(?:\/\s*[+-]?\s*\d+)?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=i(t[1]);else if(t=e.match(/^([+-]?)\s*(\d+)\s*([+-]?\d+)\s*\/\s*([+-]?\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i)){var r=parseFloat(t[1]+"1"),o=parseFloat(t[2]),u=parseFloat(t[3]),a=parseFloat(t[4]),f=u<a&&KhanUtil.getGCD(u,a)===1;n=[{value:r*(o+u/a),exact:f}]}else if(t=e.match(/^([+-]?\s*\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\s*\d+))?$/i))n=i(t[1]+"/"+t[3]);else if(t=e.match(/^([+-]?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\d+))?$/i))n=i(t[1]+"1/"+t[3]);else if(e==="0")n=[{value:0,exact:!0}];else{if(!(t=e.match(/^(.+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i)))return n=_.reduce(Khan.answerTypes.predicate.defaultForms.split(/\s*,\s*/),function(t,n){return t.concat(s[n](e))},[]),$.each(n,function(e,t){t.piApprox=!0}),n;n=s.decimal(t[1])}var l=Math.PI;return e.match(/\\?tau|t|\u03c4/)&&(l=Math.PI*2),e.match(/pau/)&&(l=Math.PI*1.5),$.each(n,function(e,t){t.value*=l}),n},coefficient:function(e){var t=[];return e=e.replace(/\u2212/,"-"),e===""?t=[{value:1,exact:!0}]:e==="-"&&(t=[{value:-1,exact:!0}]),t},log:function(e){var t,n=[];return e=e.replace(/\u2212/,"-"),e=e.replace(/[ \(\)]/g,""),(t=e.match(/^log\s*(\S+)\s*$/i))?n=s.decimal(t[1]):e==="0"&&(n=[{value:0,exact:!0}]),n},percent:function(e){e=$.trim(e);var t=!1;e.indexOf("%")===e.length-1&&(e=$.trim(e.substring(0,e.length-1)),t=!0);var n=s.decimal(e);return $.each(n,function(e,n){n.exact=t,n.value=n.value/100}),n},mixed:function(e){var t=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?)(\d+)\s+(\d+)\s*\/\s*(\d+)$/);if(t){var n=parseFloat(t[1]+"1"),r=parseFloat(t[2]),i=parseFloat(t[3]),s=parseFloat(t[4]),o=i<s&&KhanUtil.getGCD(i,s)===1;return[{value:n*(r+i/s),exact:o}]}return[]},decimal:function(e,t){t==null&&(t=1e10);var r=function(e){e=$.trim(e);var r=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?(?:\d{1,3}(?:[, ]?\d{3})*\.?|\d{0,3}(?:[, ]?\d{3})*\.(?:\d{3}[, ]?)*\d{1,3}))$/),i=e.match(/^0[0,]*,/);if(r&&!i){var s=parseFloat(r[1].replace(/[, ]/g,""));return n.inexact===undefined&&(s=Math.round(s*t)/t),s}},i=function(e){return e=e.replace(/([\.,])/g,function(e,t){return t==="."?",":"."}),r(e)};return[{value:r(e),exact:!0},{value:i(e),exact:!0}]}};return function(t){var i=n.fallback!=null?""+n.fallback:"";t=$.trim(t)||i;var o={empty:t==="",correct:!1,message:null,guess:t};$.each(r,function(r,i){var u=s[i](t);for(var a=0,f=u.length;a<f;a++){var l=u[a].value,c=u[a].exact,h=u[a].piApprox;if(e(l,n.maxError))return c||n.simplify==="optional"?(o.correct=!0,o.message=n.message||null,o.empty=!1):i==="percent"?(o.empty=!0,o.message=$._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end.")):(n.simplify!=="enforced"&&(o.empty=!0),o.message=$._("Your answer is almost correct, but it needs to be simplified.")),!1;h&&e(l,Math.abs(l*.001))&&(o.empty=!0,o.message=$._("Your answer is close, but you may have approximated pi. Enter your answer as a multiple of pi, like <code>12\\ \\text{pi}</code> or <code>2/3\\ \\text{pi}</code>"))}});if(o.correct===!1){var u=!1;_.each(s,function(e){_.any(e(t),function(e){return e.value!=null&&!_.isNaN(e.value)})&&(u=!0)});if(!u)return o.empty=!0,o.message=$._("We could not understand your answer. Please check your answer for extra text or symbols."),o}return o}}},number:{convertToPredicate:function(e,t){var n=parseFloat($.trim(e));return[function(e,t){return Math.abs(e-n)<t},$.extend({},t,{type:"predicate"})]},setupFunctional:function(e,t,n){var r=Khan.answerTypes.number.convertToPredicate(t,n);return Khan.answerTypes.predicate.setupFunctional(e,r[0],r[1])},createValidatorFunctional:function(e,t){return Khan.answerTypes.predicate.createValidatorFunctional.apply(Khan.answerTypes.predicate,Khan.answerTypes.number.convertToPredicate(e,t))}},decimal:o("decimal"),rational:o("integer, proper, improper, mixed"),improper:o("integer, proper, improper"),mixed:o("integer, proper, mixed"),regex:{setupFunctional:function(e,t,n){var r;return window.Modernizr&&Modernizr.touchevents?r=$('<input type="text" autocapitalize="off">'):r=$('<input type="text">'),$(e).append(r),{validator:Khan.answerTypes.regex.createValidatorFunctional(t,n),answer:function(){return r.val()},solution:$.trim(t),showGuess:function(e){r.val(e===undefined?"":e)}}},createValidatorFunctional:function(e,t){var n="";return t.caseInsensitive!=null&&(n+="i"),e=new RegExp($.trim(e),n),function(n){var r=t.fallback!=null?""+t.fallback:"";return n=$.trim(n)||r,{empty:!1,correct:n.match(e)!=null,message:null,guess:n}}}},radical:{setupFunctional:function(e,t,n){var r=$.extend({simplify:"required"},n),i=$('<input type="text" autocapitalize="off">'),o=$('<input type="text" autocapitalize="off">'),u=r.simplify==="required"?[$._("a simplified radical, like <code>\\sqrt{2}</code> or <code>3\\sqrt{5}</code>")]:[$._("a radical, like <code>\\sqrt{8}</code> or <code>2\\sqrt{2}</code>")];s(i,u),s(o,u),$("<div class='radical'>").append($("<span>").append(i)).append('<span class="surd">&radic;</span>').append($("<span>").append(o).addClass("overline")).appendTo(e);var a=parseFloat(t),f=KhanUtil.splitRadical(a);return{validator:Khan.answerTypes.radical.createValidatorFunctional(t,n),answer:function(){return[$.trim(i.val()),$.trim(o.val())]},solution:f,showGuess:function(e){i.val(e?e[0]:""),o.val(e?e[1]:"")}}},createValidatorFunctional:function(e,t){t=$.extend({simplify:"required"},t),e=parseFloat(e);var n=KhanUtil.splitRadical(e);return function(r){if(r[0].length===0&&r[1].length===0)return{empty:!0,correct:!1,message:null,guess:r};r[0]=r[0].length>0?r[0]:"1",r[1]=r[1].length>0?r[1]:"1";var i=parseFloat(r[0]),s=parseFloat(r[1]),o=Math.abs(i)*i*s===e,u=i===n[0]&&s===n[1],a={empty:!1,correct:!1,message:null,guess:r};return o&&(u||t.simplify==="optional"?a.correct=!0:a.message=$._("Your answer is almost correct, but it needs to be simplified.")),a}}},cuberoot:{setupFunctional:function(e,t,n){var r=$.extend({simplify:"required"},n),i=$('<input type="text" autocapitalize="off">'),o=$('<input type="text" autocapitalize="off">'),u=r.simplify==="required"?[$._("a simplified radical, like <code>\\sqrt[3]{2}</code> or <code>3\\sqrt[3]{5}</code>")]:[$._("a radical, like <code>\\sqrt[3]{8}</code> or <code>2\\sqrt[3]{2}</code>")];s(i,u),s(o,u),$("<div class='radical'>").append($("<span>").append(i)).append('<span class="surd" style="vertical-align: 6px;"><code>\\sqrt[3]{}</code></span>').append($("<span>").append(o).addClass("overline")).appendTo(e).tex();var a=parseFloat(t),f=KhanUtil.splitCube(a);return{validator:Khan.answerTypes.cuberoot.createValidatorFunctional(t,n),answer:function(){return[i.val(),o.val()]},solution:f,showGuess:function(e){i.val(e?e[0]:""),o.val(e?e[1]:"")}}},createValidatorFunctional:function(e,t){t=$.extend({simplify:"required"},t),e=parseFloat(e);var n=KhanUtil.splitCube(e);return function(r){if(r[0].length===0&&r[1].length===0)return{empty:!0,correct:!1,message:null,guess:r};r[0]=r[0].length>0?r[0]:"1",r[1]=r[1].length>0?r[1]:"1";var i=parseFloat(r[0]),s=parseFloat(r[1]),o=Math.abs(i)*i*i*s===e,u=i===n[0]&&s===n[1],a={empty:!1,correct:!1,message:null,guess:r};return o&&(u||t.simplify==="optional"?a.correct=!0:a.message=$._("Your answer is almost correct, but it needs to be simplified.")),a}}},multiple:{setup:function(e,t){$(e).append($(t).clone(!0).texCleanup().contents().runModules());var n=[];return $(e).find(".sol").each(function(e){var r=$(this).data("type");r=r!=null?r:"number";var i=$(t).find(".sol").eq(e),s=$(this).empty(),o=Khan.answerTypes[r].setup(s,i);n.push(o)}),{validator:Khan.answerTypes.multiple.createValidator(t),answer:function(){var e=[];return $.each(n,function(t,n){e.push(n.answer())}),e},solution:function(){$.map(n,function(e){return e.solution})}(),showGuess:function(e){$.each(n,function(t,n){e!==undefined?n.showGuess(e[t]):n.showGuess()})},showCustomGuess:function(e){$.each(n,function(t,n){if(!_.isFunction(n.showCustomGuess))return;e!==undefined?n.showCustomGuess(e[t]):n.showCustomGuess()})}}},createValidator:function(e){var t=[];return $(e).find(".sol").each(function(){var e=$(this),n=e.data("type");n=n!=null?n:"number";var r=Khan.answerTypes[n].createValidator(e);t.push(r)}),function(e){var n={empty:!0,correct:!0,message:null,guess:e},r=null;return i(e)?(n.empty=!0,n.correct=!1,n):($.each(e,function(e,i){var s=t[e](i);s.message&&s.empty?r=s.message:(n.empty=n.empty&&s.empty,n.correct=n.correct&&s.correct,n.message=n.message||s.message)}),n.correct&&r!=null?{empty:!0,correct:!1,message:r,guess:e}:(n.empty=!1,n))}}},set:{setup:function(e,t){$(e).append($(t).find(".input-format").clone(!0).texCleanup().contents().runModules());var n=[],r=[];$(e).find(".entry").each(function(){var e=$(this),t=$(this).data("type");t=t!=null?t:"number";var i=e.clone(!0),s=e.empty(),o=Khan.answerTypes[t].setup(s,i);n.push(o.answer),r.push(o.showGuess)});var i=[];return $(t).find(".set-sol").clone(!0).each(function(){var e=$(this).data("type");e=e!=null?e:"number";var t=$("<div>"),n=Khan.answerTypes[e].setup(t,$(this));i.push(n.solution)}),{validator:Khan.answerTypes.set.createValidator(t),answer:function(){var e=[];return $.each(n,function(t,n){e.push(n())}),e},solution:t,showGuess:function(e){$.each(r,function(t,n){e===undefined?n():n(e[t])})}}},createValidator:function(e){var t=[];return $(e).find(".set-sol").clone(!0).each(function(){var e=$(this).data("type");e=e!=null?e:"number";var n=Khan.answerTypes[e].createValidator($(this));t.push(n)}),function(e){var n={empty:t.length===0?!1:!0,correct:!0,message:null,guess:e},r=null,s=t.slice(0);return $.each(e,function(e,t){var o=!1;$.each(s,function(e,n){var i=n(t);if(i.empty&&i.message)return s.splice(e,1),r=i.message,o=!0,!1;if(i.correct)return o=i.correct,s.splice(e,1),!1;!i.correct&&i.message&&(o=i.message)}),!i(t)&&!i(o)&&(n.empty=!1);if(!o&&$.trim([t].join(""))!=="")return n.correct=!1,!1;typeof o=="string"&&(n.message=o,n.correct=!1)}),t.length>e.length?s.length>t.length-e.length&&(n.correct=!1):s.length>0&&(n.correct=!1),n.correct&&r!=null?{empty:!0,correct:!1,message:r,guess:e}:n}}},radio:{setup:function(e,t){var i=$("<ul></ul>");$(e).append(i);var s=$(t).siblings(".choices"),o=s.clone(!0).texCleanup(),u=$(t).clone(!0).texCleanup(),a=u.text(),f=!!s.data("category"),l;if(f){var c=r(u);l=_.map(o.children().get(),function(e){return r(e)===c?u[0]:e})}else l=u.get().concat(KhanUtil.shuffle(o.children().get()));var h=+s.data("show")||l.length,p=!!s.data("none"),d=_.uniq(l,!1,function(e){return r(e)}),v=p&&d.length===h-1;if(d.length<h&&!v)return!1;d.length>h&&(d=d.slice(0,h)),f||(d=KhanUtil.shuffle(d));var m;_.each(d,function(e,t){e===u[0]&&(m=t)});var g=p&&m===h-1;if(p){var y=$("<span>").html($._("None of the above"));y.data("noneOfTheAbove",!0),g&&i.data("realAnswer",$("<span>").addClass("value").append(u.clone(!0).contents()));var b=d.length-1;v&&(b=d.length),d.splice(b,1,$("<span>").append(y))}var w=_.map(d,function(e,t){return $("<li><label></label></li>").find("label").append([$('<input type="radio" name="solution">').val(t),$('<span class="value"></span>').append($(e).contents())]).end()});return i.append(w).runModules(),{validator:Khan.answerTypes.radio.createValidator({solution:t,index:m,noneIsCorrect:g}),answer:function(){var e=i.find("input:checked");if(e.length===0)return null;var t=e.siblings(".value"),r=t.children().eq(0);return{isNone:r.data("noneOfTheAbove"),value:n(t),index:+e.val()}},solution:a,showGuess:function(t){t==null?$(e).find("input:checked").attr("checked",!1):i.children().filter(function(){return t.index===$(this).find("input").val()}).find("input").attr("checked",!0)}}},createValidator:function(e){function r(){var e=$("#solutionarea").find("ul"),t=e.children().filter(function(){return $(this).find("span.value > span").data("noneOfTheAbove")}).find("input");t.next().fadeOut("fast",function(){var t=e.data("realAnswer");$(this).replaceWith(t),t.tex().fadeIn("fast")})}var t=n(e.solution||e);return function(n){var i={empty:!1,correct:!1,message:null,guess:n};return n==null?(i.empty=!0,i):(n.index?n.isNone&&e.noneIsCorrect?(r(),i.correct=!0):i.correct=n.index===e.index:n.isNone&&$("#solutionarea").find("ul").data("real-answer")!=null?(r(),i.correct=!0):$.trim(n.value).replace(/\r\n?|\n/g,"")===$.trim(t.replace(/\r\n?|\n/g,""))?i.correct=!0:i.correct=!1,i)}}},list:{setupFunctional:function(e,t,n){var r=$("<select></select>");$(e).append(r);var i=$.tmpl.getVAR(n.choices);return $.each(i,function(e,t){r.append('<option value="'+t+'">'+t+"</option>")}),{validator:Khan.answerTypes.list.createValidatorFunctional(t,n),answer:function(){return r.val()},solution:$.trim(t),showGuess:function(e){r.val(e===undefined?"":e)}}},createValidatorFunctional:function(e,t){return e=$.trim(e),function(t){return t=$.trim(t),{empty:!1,correct:e===t,message:null,guess:t}}}},custom:{setup:function(e,t){t.find(".instruction").appendTo(e).runModules();var n=t.find(".guess").text(),r=t.find(".show-guess").text(),i=t.find(".show-guess-solutionarea").text();return{validator:Khan.answerTypes.custom.createValidator(t),answer:function(){return KhanUtil.tmpl.getVAR(n,KhanUtil.currentGraph)},solution:$.trim($(t).text()),showCustomGuess:function(e){var t="(function() { var guess = "+JSON.stringify(e)+";"+r+"})()";KhanUtil.tmpl.getVAR(t,KhanUtil.currentGraph)},showGuess:function(e){var t="(function() { var guess = "+JSON.stringify(e)+";"+i+"})()";KhanUtil.tmpl.getVAR(t,KhanUtil.currentGraph)}}},createValidator:function(e){var t=$(e).find(".validator-function").text(),n=function(e){var n="(function() { var guess = "+JSON.stringify(e)+";"+t+"})()";return KhanUtil.tmpl.getVAR(n,KhanUtil.currentGraph)};return function(e){var t=n(e);return typeof t=="object"?t:{empty:t==="",correct:t===!0,message:typeof t=="string"?t:null,guess:e}}}},primeFactorization:{setupFunctional:function(e,t,n){var r;window.Modernizr&&Modernizr.touchevents?r=$('<input type="text" autocapitalize="off">'):r=$('<input type="text">'),r.addClass("prime-factorization"),$(e).append(r);var i=[$._("a product of prime factors, like <code>2 \\times 3</code>"),$._("a single prime number, like <code>5</code>")];return s(r,i),{validator:Khan.answerTypes.primeFactorization.createValidatorFunctional(t,n),answer:function(){return r.val()},solution:$.trim(t),showGuess:function(e){r.val(e===undefined?"":e)}}},createValidatorFunctional:function(e,t){return e=$.trim(e),function(t){t=t.split(" ").join("").toLowerCase(),t=t.replace(/{|}/g,""),t=t.split(/x|\*|\u00d7|\\times|\\cdot/);var n=[];for(var r=0;r<t.length;r++){var i=t[r].split("^");if(i.length>1)for(var s=0;s<i[1];s++)n.push(i[0]);else n.push(t[r])}return t=KhanUtil.sortNumbers(n).join("x"),{empty:t==="",correct:t===e,message:null,guess:t}}}},checkbox:{setupFunctional:function(e,t,n){var r=$('<input type="checkbox">');return $(e).append(r),{validator:Khan.answerTypes.checkbox.createValidatorFunctional(t,n),answer:function(){return r.is(":checked")||""},solution:$.trim(t),showGuess:function(e){r.attr("checked",e===undefined?!1:e)}}},createValidatorFunctional:function(e,t){return e=$.trim(e)==="true",function(t){var n={empty:!1,correct:!1,message:null,guess:t};return!!e==!!t?n.correct=!0:t?n.correct=!1:n.empty=!0,n}}},expression:{setup:function(e,t){var n=this._parseOptions($(t).data()),r=$('<span class="tex"/>'),i=$('<input type="text">'),o=$('<div class="error-div" style="display: none;"/>');$(e).append($('<span class="expression"/>').append($('<span class="output"/>').append(r),$('<span class="input"/>').append(i,o.append($('<i class="icon-exclamation-sign error-icon"/>')))));var u=null,a="",f=function(){clearTimeout(u);var e=KAS.parse(i.val(),n);if(e.parsed){c(),r.css({opacity:1});var t=e.expr.asTex(n);t!==a&&(r.empty().append($("<code>").text(t)).tex(),a=t)}else u=setTimeout(l,2e3),r.css({opacity:.5})},l=function(){o.is(":visible")||(o.show(),i.addClass("error"))},c=function(){o.is(":visible")&&(o.hide(),i.removeClass("error"))};i.on("input propertychange",f),i.on("keydown",function(e){var t=i[0],n=t.selectionStart,r=t.selectionEnd,s=n!==undefined;if(s&&e.which===8){var o=t.value;n===r&&o.slice(n-1,n+1)==="()"&&(e.preventDefault(),t.value=o.slice(0,n-1)+o.slice(n+1),t.selectionStart=n-1,t.selectionEnd=r-1,f())}}),i.on("keypress",function(e){var t=i[0],n=t.selectionStart,r=t.selectionEnd,s=n!==undefined;if(s&&e.which===40){var o=t.value;e.preventDefault();if(n===r){var u=_.any([" ",")",""],function(e){return o.charAt(n)===e});t.value=o.slice(0,n)+(u?"()":"(")+o.slice(r)}else t.value=o.slice(0,n)+"("+o.slice(n,r)+")"+o.slice(r);t.selectionStart=n+1,t.selectionEnd=r+1,f()}else if(s&&e.which===41){var o=t.value;n===r&&o.charAt(n)===")"&&(e.preventDefault(),t.selectionStart=n+1,t.selectionEnd=r+1,f())}});var h=$._("For <code>2\\cdot2</code>, enter <strong>2*2</strong>");n.times&&(h=h.replace(/\\cdot/g,"\\times"));var p=[h,$._("For <code>3y</code>, enter <strong>3y</strong> or <strong>3*y</strong>"),$._("For <code>\\dfrac{1}{x}</code>, enter <strong>1/x</strong>"),$._("For <code>x^{y}</code>, enter <strong>x^y</strong>"),$._("For <code>\\sqrt{x}</code>, enter <strong>sqrt(x)</strong>"),$._("For <code>\\pi</code>, enter <strong>pi</strong>"),$._("For <code>\\sin \\theta</code>, enter <strong>sin(theta)</strong>"),$._("For <code>\\le</code> or <code>\\ge</code>, enter <strong><=</strong> or <strong>>=</strong>"),$._("For <code>\\neq</code>, enter <strong>=/=</strong>")];return s(i,p),{validator:Khan.answerTypes.expression.createValidator(t),answer:function(){return i.val()},solution:t,showGuess:function(e){i.val(e===undefined?"":e)}}},parseSolution:function(e,t){var n=KAS.parse(e,t);if(!n.parsed)throw new Error("The provided solution ("+e+") didn't parse.");if(t.simplified&&!n.expr.isSimplified())throw new Error("The provided solution ("+e+") isn't fully expanded and simplified.");return n=n.expr,n},_parseOptions:function(e){var t=e.form!==undefined?e.form:e.sameForm,n=function(e){return e!=null&&e!==!1},r={form:n(t),simplify:n(e.simplify),times:n(e.times)};return _.isString(e.functions)?r.functions=_.compact(e.functions.split(/[ ,]+/)):_.isArray(e.functions)&&(r.functions=_.compact(e.functions)),r},createValidator:function(e){var t=$(e),n=[],r=this.createValidatorFunctional,i=this._parseOptions;$(e).find(".set-sol").each(function(){var e=i($(this).data());n.push(r($(this).text(),e))});if(n.length===0){var s=i(t.data());n.push(r(t.text(),s))}return function(e){var t={empty:!1,correct:!1,message:null,guess:e};return $.each(n,function(n,r){var i=r(e);if(i.correct)return t.correct=!0,t.message=null,!1;i.message&&(t.message=i.message),i.empty&&(t.empty=!0)}),t}},createValidatorFunctional:function(e,t){return function(n){var r={empty:!1,correct:!1,message:null,guess:n};if(!n)return r.empty=!0,r;var i=KAS.parse(n,t);if(!i.parsed)return r.empty=!0,r;typeof e=="string"&&(e=Khan.answerTypes.expression.parseSolution(e,t));var s=KAS.compare(i.expr,e,t);if(s.equal)r.correct=!0;else if(s.message)r.message=s.message;else{var o=KAS.parse(n.replace(/[xX]/g,"*"),t);if(o.parsed){var u=KAS.compare(o.expr,e,t);u.equal?(r.empty=!0,r.message="I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign."):u.message&&(r.message=u.message+" Also, "+"I'm a computer. I only "+"understand multiplication if you use an "+"asterisk (*) as the multiplication sign.")}}return r}}}}),_.each(Khan.answerTypes,function(e,t){"setup"in e||(e.setup=function(t,n){var r=$(n);return e.setupFunctional(t,r.text(),r.data())}),"createValidator"in e||(e.createValidator=function(t){var n=$(t);return e.createValidatorFunctional(n.text(),n.data())})})}),define("../perseus/ke/utils/knumber.js",["require"],function(e){var t=1e-9,n=Math.pow(2,-42),r=KhanUtil.knumber={DEFAULT_TOLERANCE:t,EPSILON:n,is:function(e){return _.isNumber(e)&&!_.isNaN(e)},equal:function(e,n,r){return e==null||n==null?e===n:(r==null&&(r=t),Math.abs(e-n)<r)},sign:function(e,t){return r.equal(e,0,t)?0:Math.abs(e)/e},round:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n},roundTo:function(e,t){return Math.round(e/t)*t},floorTo:function(e,t){return Math.floor(e/t)*t},ceilTo:function(e,t){return Math.ceil(e/t)*t},isInteger:function(e,t){return r.equal(Math.round(e),e,t)},toFraction:function(e,t,i){i=i||1e3,t=t||n;var s=[1,0],o=[0,1],u=Math.floor(e),a=e-u;while(o[0]<=i){if(r.equal(s[0]/o[0],e,t))return[s[0],o[0]];s=[u*s[0]+s[1],s[0]],o=[u*o[0]+o[1],o[0]],u=Math.floor(1/a),a=1/a-u}return[e,1]}};return r}),define("../perseus/ke/utils/kvector.js",["require","./knumber.js"],function(e){function n(e){return _.reduce(e,function(e,t){return e+t},0)}function r(e){return _.reduce(e,function(e,t){return e*t},1)}var t=e("./knumber.js"),i=KhanUtil.kvector={is:function(e,n){return _.isArray(e)?n!==undefined&&e.length!==n?!1:_.all(e,t.is):!1},normalize:function(e){return i.scale(e,1/i.length(e))},length:function(e){return Math.sqrt(i.dot(e,e))},dot:function(e,t){var i=_.toArray(arguments),s=_.zip.apply(_,i),o=_.map(s,r);return n(o)},add:function(){var e=_.toArray(arguments),t=_.zip.apply(_,e);return _.map(t,n)},subtract:function(e,t){return _.map(_.zip(e,t),function(e){return e[0]-e[1]})},negate:function(e){return _.map(e,function(e){return-e})},scale:function(e,t){return _.map(e,function(e){return e*t})},equal:function(e,n,r){return _.all(_.zip(e,n),function(e){return t.equal(e[0],e[1],r)})},codirectional:function(e,n,r){return t.equal(i.length(e),0,r)||t.equal(i.length(n),0,r)?!0:(e=i.normalize(e),n=i.normalize(n),i.equal(e,n,r))},collinear:function(e,t,n){return i.codirectional(e,t,n)||i.codirectional(e,i.negate(t),n)},polarRadFromCart:function(e){var t=i.length(e),n=Math.atan2(e[1],e[0]);return n<0&&(n+=2*Math.PI),[t,n]},polarDegFromCart:function(e){var t=i.polarRadFromCart(e);return[t[0],t[1]*180/Math.PI]},cartFromPolarRad:function(e,t){return _.isUndefined(t)&&(t=e[1],e=e[0]),[e*Math.cos(t),e*Math.sin(t)]},cartFromPolarDeg:function(e,t){return _.isUndefined(t)&&(t=e[1],e=e[0]),i.cartFromPolarRad(e,t*Math.PI/180)},rotateRad:function(e,t){var n=i.polarRadFromCart(e),r=n[1]+t;return i.cartFromPolarRad(n[0],r)},rotateDeg:function(e,t){var n=i.polarDegFromCart(e),r=n[1]+t;return i.cartFromPolarDeg(n[0],r)},angleRad:function(e,t){return Math.acos(i.dot(e,t)/(i.length(e)*i.length(t)))},angleDeg:function(e,t){return i.angleRad(e,t)*180/Math.PI},projection:function(e,t){var n=i.dot(e,t)/i.dot(t,t);return i.scale(t,n)},round:function(e,n){return _.map(e,function(e,r){return t.round(e,n[r]||n)})},roundTo:function(e,n){return _.map(e,function(e,r){return t.roundTo(e,n[r]||n)})},floorTo:function(e,n){return _.map(e,function(e,r){return t.floorTo(e,n[r]||n)})},ceilTo:function(e,n){return _.map(e,function(e,r){return t.ceilTo(e,n[r]||n)})}};return i}),define("../perseus/ke/utils/kpoint.js",["require","./kvector.js","./knumber.js"],function(e){var t=e("./kvector.js"),n=e("./knumber.js"),r=KhanUtil.kpoint={rotateRad:function(e,n,r){return r===undefined?t.rotateRad(e,n):t.add(r,t.rotateRad(t.subtract(e,r),n))},rotateDeg:function(e,n,r){return r===undefined?t.rotateDeg(e,n):t.add(r,t.rotateDeg(t.subtract(e,r),n))},distanceToPoint:function(e,n){return t.length(t.subtract(e,n))},distanceToLine:function(e,n){var r=t.subtract(n[1],n[0]),i=t.subtract(e,n[0]),s=t.projection(i,r),o=t.subtract(s,i);return t.length(o)},reflectOverLine:function(e,n){var r=t.subtract(n[1],n[0]),i=t.subtract(e,n[0]),s=t.projection(i,r),o=t.subtract(t.scale(s,2),i);return t.add(n[0],o)},compare:function(e,t,r){if(e.length!==t.length)return e.length-t.length;for(var i=0;i<e.length;i++)if(!n.equal(e[i],t[i],r))return e[i]-t[i];return 0}};return _.extend(r,{is:t.is,addVector:t.add,addVectors:t.add,subtractVector:t.subtract,equal:t.equal,polarRadFromCart:t.polarRadFromCart,polarDegFromCart:t.polarDegFromCart,cartFromPolarRad:t.cartFromPolarRad,cartFromPolarDeg:t.cartFromPolarDeg,round:t.round,roundTo:t.roundTo,floorTo:t.floorTo,ceilTo:t.ceilTo}),r}),define("../perseus/ke/utils/tex.js",["require"],function(e){function t(e,t){var n=$(e).find("."+t);return n.length===0?$("<span>").addClass(t).appendTo($(e)):n}function n(e,t){var n=0;(function r(){var i=e.scrollHeight;i>18||n>=10?t():(n++,setTimeout(r,100))})()}$.extend(KhanUtil,{processMath:function(e,r,i,s){var o=$(e);if(o.attr("data-math-formula")==null||i){var u=t(o,"katex-holder"),a=t(o,"mathjax-holder"),f=a.find("script[type='math/tex']")[0];r==null&&(o.attr("data-math-formula")?r=o.attr("data-math-formula"):f&&(r=f.text||f.textContent)),r=r!=null?r+"":"",KhanUtil.cleanMath&&(r=KhanUtil.cleanMath(r)),o.attr("data-math-formula",r);if(Exercises.useKatex)try{katex.render(r,u[0]);if(o.attr("data-math-type")==="mathjax"){var l=MathJax.Hub.getJaxFor(f);if(l){var c=l.SourceElement();c.previousSibling&&c.previousSibling.className&&l.Remove()}}o.attr("data-math-type","katex"),s&&n(e,s);return}catch(h){if(h.__proto__!==katex.ParseError.prototype)throw h}o.attr("data-math-type","mathjax"),f?"text"in f?f.text=r:f.textContent=r:a.append("<script type='math/tex'>"+r.replace(/<\//g,"< /")+"</script>"),typeof MathJax!="undefined"&&(MathJax.Hub.Queue(["Reprocess",MathJax.Hub,a[0]]),MathJax.Hub.Queue(function(){KhanUtil.debugLog("MathJax done typesetting ("+r+")")}),s&&MathJax.Hub.Queue(function(){var t=MathJax.Callback(function(){});return n(e,function(){s(),t()}),t}))}},processAllMath:function(e,t){var n=$(e);n.filter("code").add(n.find("code")).each(function(){var e=$(this),n=e.attr("data-math-formula");n==null&&(n=e.text(),e.empty()),KhanUtil.processMath(this,n,t)})},cleanupMath:function(e){var t=$(e);if(t.attr("data-math-formula")){if(typeof MathJax!="undefined"){var n=MathJax.Hub.getJaxFor(t.find("script")[0]);if(n){var r=n.SourceElement();r.previousSibling&&r.previousSibling.className&&n.Remove()}}t.text(t.attr("data-math-formula")),t.attr("data-math-formula",null),t.attr("data-math-type",null)}return e},retrieveMathFormula:function(e){return $(e).attr("data-math-formula")}}),$.fn.tex=function(){return KhanUtil.processAllMath(this,!1),this},$.fn.texCleanup=function(){return this.filter("code").add(this.find("code")).each(function(){KhanUtil.cleanupMath(this)}),this}}),define("../perseus/ke/utils/crc32.js",["require"],function(e){var t="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D",n=function(e,n){n==null&&(n=0);var r=0,i=0;n^=-1;for(var s=0,o=e.length;s<o;s++)r=(n^e.charCodeAt(s))&255,i="0x"+t.substr(r*9,8),n=n>>>8^i;return Math.abs(n^-1)};return n}),define("../perseus/ke/utils/tmpl.js",["require","./crc32.js"],function(require){var crc32=require("./crc32.js"),localMode,VARS={};$.tmpl={DATA_ENSURE_LOOPS:0,attr:{"data-ensure":function(e,t){return function(e){var n=!!t&&!!$.tmpl.getVAR(t);return!n&&$.tmpl.DATA_ENSURE_LOOPS++>1e4&&localMode?(alert("unsatisfiable data-ensure?"),!0):n}},"data-if":function(e,t){var n=$(e);t=t&&$.tmpl.getVAR(t);var r=n.next();r.data("lastCond")===undefined&&r.data("lastCond",t);if(!t)return[]},"data-else-if":function(e,t){var n=$(e),r=n.data("lastCond");t=!r&&t&&$.tmpl.getVAR(t);var i=n.next();i.data("lastCond")===undefined&&i.data("lastCond",r||t);if(!t)return[]},"data-else":function(e){var t=$(e);if(t.data("lastCond"))return[]},"data-each":function(e,t){var n;$(e).removeAttr("data-each");if(n=/^(.+) times(?: as (\w+))?$/.exec(t)){var r=$.tmpl.getVAR(n[1]);return{items:$.map(new Array(r),function(e,t){return t}),value:n[2],oldValue:VARS[n[2]]}}if(n=/^(.*?)(?: as (?:(\w+), )?(\w+))?$/.exec(t))return{items:$.tmpl.getVAR(n[1]),value:n[3],pos:n[2],oldValue:VARS[n[3]],oldPos:VARS[n[2]]}},"data-unwrap":function(e){return $(e).contents()},"data-video-hint":function(e){var t=$(e).data("youtube-id");if(!t)return;t=t.split(/,\s*/);var n=$(e).data("video-hint-author")||"Sal",r=$._("Watch %(author)s work through a very similar problem:",{author:n}),i=$("<p>").text(r),s=$("<div>",{"class":"video-hint"});return s.append(i),_.each(t,function(e){var t="http://www.khanacademy.org/embed_video?v="+e,n=$("<iframe>").attr({frameborder:"0",scrolling:"no",width:"100%",height:"360px",src:t});s.append(n)}),s}},type:{"var":function(e,t){if(!t&&$(e).children().length>0)return function(e){return $.tmpl.type["var"](e,e.innerHTML)};t=t||$.tmpl.getVAR(e);var n=e.id;if(!n){if(t==null)return[];var s=$("<div>"),o=s.append(t+" ").html();return s.html(o.slice(0,-1)).contents()}var r=function(e,t){KhanUtil[e]&&Khan.error("Defining variable '"+e+"' overwrites utility property of same name."),VARS[e]=t};if(n.indexOf(",")!==-1){var i=n.split(/\s*,\s*/);$.each(i,function(e,n){n.length>0&&r(n,t[e])})}else r(n,t)}},getVAR:function(elem,ctx){function doEval(){with(Math)with(KhanUtil)with(ctx)with(VARS)return eval("(function() { return ("+code+"); })()")}var code=elem.nodeName?$(elem).text():elem;ctx==null&&(ctx={});if(Khan.query.debug!=null)return doEval();try{return doEval()}catch(e){var info;elem.nodeName?(info=elem.nodeName.toLowerCase(),elem.id!=null&&elem.id.length>0&&(info+="#"+elem.id)):info=JSON.stringify(code),Khan.error("Error while evaluating "+info,e)}},getVarsHash:function(){return crc32(JSON.stringify($.map(VARS,function(e,t){return[t,String(e)]})))}},typeof KhanUtil!="undefined"&&(KhanUtil.tmpl=$.tmpl),$.fn.tmplLoad=function(e,t){VARS={},$.tmpl.DATA_ENSURE_LOOPS=0,localMode=t.localMode,localMode&&($.tmpl.VARS=VARS)},$.fn.tmpl=function(){function n(e){var t=[],i=e.childNodes,s=r(e,t);if(s===!1)return n(e);if(s!==undefined){if(typeof s=="object"&&typeof s.length!="undefined")return e.parentNode&&($.each(s,function(t,n){n.nodeType&&e.parentNode.insertBefore(n,e)}),$.each(s,function(e,t){n(t)}),e.parentNode.removeChild(e)),null;if(s.items){var o=e.parentNode,u=e.nextSibling;return $.each(s.items,function(t,r){s.value&&(VARS[s.value]=r),s.pos&&(VARS[s.pos]=t);var i=$(e).clone(!0).removeAttr("data-each").removeData("each")[0],a=["data-if","data-else-if","data-else"],f="";f+=s.pos?"var "+s.pos+" = "+JSON.stringify(t)+";":"",f+=s.value?"var "+s.value+" = "+JSON.stringify(r)+";":"";for(var l=0;l<a.length;l++){var c=a[l];$(i).find("["+c+"]").each(function(){var e=$(this).attr(c);e="(function() { "+f+" return "+e+" })()",$(this).attr(c,e)})}$(i).find(".graphie").addBack().filter(".graphie").each(function(){var e=$(this).text();$(this).text(f+e)}),u?o.insertBefore(i,u):o.appendChild(i),n(i)}),s.value&&(VARS[s.value]=s.oldValue),s.pos&&(VARS[s.pos]=s.oldPos),$(e).remove(),null}}for(var a=0;a<i.length;a++)i[a].nodeType===1&&n(i[a])===null&&a--;for(var a=0,f=t.length;a<f;a++)if(t[a](e)===!1)return n(e);return e}function r(e,t){var n,r=$(e);for(var i in $.tmpl.attr)if($.tmpl.attr.hasOwnProperty(i)){var s;/^data-/.test(i)?s=r.data(i.replace(/^data-/,"")):s=r.attr(i);if(s!==undefined){n=$.tmpl.attr[i](e,s);if(typeof n=="function")t.push(n);else if(n!==undefined)return n}}var o=e.nodeName.toLowerCase();return $.tmpl.type[o]!=null&&(n=$.tmpl.type[o](e),typeof n=="function"&&t.push(n)),n}for(var e=0,t=this.length;e<t;e++)n(this[e]);return this},$.extend($.expr[":"],{inherited:function(e){return $(e).data("inherited")}}),$.fn.extend({tmplApply:function(e){e=e||{};var t=e.attribute||"id",n=e.defaultApply||"replace",r={};return this.each(function(){var e=$(this),i=e.attr(t),s=e.data("apply")&&!e.data("apply").indexOf("hint");i&&(i in r&&!s?(r[i]=$.tmplApplyMethods[e.data("apply")||n].call(r[i],this),r[i]==null&&delete r[i]):e.closest(":inherited").length>0&&(r[i]=this))})}}),$.extend({tmplApplyMethods:{remove:function(e){$(this).remove(),$(e).remove()},replace:function(e){return $(this).replaceWith(e),e},splice:function(e){$(this).replaceWith($(e).contents())},append:function(e){return $(this).append(e),this},appendContents:function(e){return $(this).append($(e).contents()),$(e).remove(),this},prepend:function(e){return $(this).prepend(e),this},prependContents:function(e){return $(this).prepend($(e).contents()),$(e).remove(),this},before:function(e){return $(this).before(e),this},beforeContents:function(e){return $(this).before($(e).contents()),$(e).remove(),this},after:function(e){return $(this).after(e),this},afterContents:function(e){return $(this).after($(e).contents()),$(e).remove(),this},appendVars:function(e){var t=$(this).data("ensure")||"1",n=$(e).data("ensure")||"1";return $(this).data("ensure","("+t+") && ("+n+")"),$.tmplApplyMethods.appendContents.call(this,e)},prependVars:function(e){var t=$(this).data("ensure")||"1",n=$(e).data("ensure")||"1";return $(this).data("ensure","("+n+") && ("+t+")"),$.tmplApplyMethods.prependContents.call(this,e)}}})}),define("../perseus/ke/utils/graphie.js",["require","./kpoint.js","./kvector.js","./tex.js","./tmpl.js"],function(e){function i(e,t){var n=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)),r=Math.atan2(e[1],e[0]);return r<0&&(r+=2*Math.PI),t||(r=r*180/Math.PI),[n,r]}function s(e,t){return typeof e=="number"&&(e=[e,e]),t=t*Math.PI/180,[e[0]*Math.cos(t),e[1]*Math.sin(t)]}function u(){_.each(o,function(e){window.clearInterval(e)}),o.length=0}var t=e("./kpoint.js"),n=e("./kvector.js");e("./tex.js"),e("./tmpl.js");var r=KhanUtil.Graphie=function(){},o=[];$.extend(KhanUtil,{unscaledSvgPath:function(e){return e[0]===!0?"":$.map(e,function(e,t){return e===!0?"z":(t===0?"M":"L")+e[0]+" "+e[1]}).join("")},getDistance:function(e,n){return t.distanceToPoint(e,n)},coordDiff:function(e,t){return _.map(t,function(n,r){return t[r]-e[r]})},snapCoord:function(e,t){return _.map(e,function(e,n){return KhanUtil.roundToNearest(t[n],e)})},findAngle:function(e,t,n){if(n===undefined){var r=e[0]-t[0],i=e[1]-t[1];return!r&&!i?0:(180+Math.atan2(-i,-r)*180/Math.PI+360)%360}return KhanUtil.findAngle(e,n)-KhanUtil.findAngle(t,n)},graphs:{}}),_.extend(r.prototype,{cartToPolar:i,polar:s});var a={center:[-0.5,-0.5],above:[-0.5,-1],"above right":[0,-1],right:[0,-0.5],"below right":[0,0],below:[-0.5,0],"below left":[-1,0],left:[-1,-0.5],"above left":[-1,-1]};KhanUtil.createGraphie=function(e){var t=40,i=40,u,f;$(e).css("position","relative");var l=Raphael(e);$(e).children("div").css("position","absolute");var c={"stroke-width":2,fill:"none"},h=function(e){if(typeof e=="number")return h([e,e]);var n=e[0],r=e[1];return[n*t,r*i]},p=function T(e){if(typeof e=="number")return T([e,e]);var n=e[0],r=e[1];return[(n-u[0])*t,(f[1]-r)*i]},d=function(e){if(typeof e=="number")return d([e,e]);var n=e[0],r=e[1];return[n/t+u[0],f[1]-r/i]},v=function(e){return typeof e=="number"?v([e,e]):[e[0]/t,e[1]/i]},m=function(e,t){var n=$(e),r=n.data("labelDirection");n.css("visibility","");if(typeof r=="number"){var i=Math.cos(r),s=Math.sin(r),o=Math.min(t[0]/2/Math.abs(i),t[1]/2/Math.abs(s));n.css({marginLeft:-t[0]/2+i*o,marginTop:-t[1]/2-s*o})}else{var u=a[r||"center"];n.css({marginLeft:Math.round(t[0]*u[0]),marginTop:Math.round(t[1]*u[1])})}},g=function(e,t){return $.map(e,function(e,n){if(e===!0)return"z";var r=t?e:p(e);return(n===0?"M":"L")+KhanUtil.bound(r[0])+" "+KhanUtil.bound(r[1])}).join("")},y=function(e,t,n){var r=function(r){return(e*r+t)*r+n};if(e===0){var i=_.map(u,function(e){return[e,r(e)]});return g(i)}var s=-t/(2*e),o=Math.max(Math.abs(s-u[0]),Math.abs(s-u[1])),a=s+o,f=[s,r(s)],l=[a,r(a)],c=[f[0],f[1]-(l[1]-f[1])],h=Math.abs(f[0]-l[0]),d=[f[0]-h,l[1]],v=[f[0]+h,l[1]],i=_.map([d,c,v],p),m=_.map(_.flatten(i),KhanUtil.bound);return"M"+m[0]+","+m[1]+" Q"+m[2]+","+m[3]+" "+m[4]+","+m[5]},b=function(e,t,n,r){var i=Math.abs(Math.PI/(2*t)),s=function(i){return e*Math.sin(t*i-n)+r},o=function(r){return e*t*Math.cos(n-t*r)},a=function(e,t){var n=e+i*t,r=n+i,u=[n,n*2/3+r*1/3,n*1/3+r*2/3,r],a=[s(n),s(n)+o(n)*(r-n)/3,s(r)-o(r)*(r-n)/3,s(r)];return _.map(_.zip(u,a),p)},f=u[1]-u[0],l=Math.ceil(f/i)+1,c=n/t,h=c-u[0];c-=i*Math.ceil(h/i);var d=a(c,0),v="M"+d[0][0]+","+d[0][1]+" C"+d[1][0]+","+d[1][1]+" "+d[2][0]+","+d[2][1]+" "+d[3][0]+","+d[3][1];for(var m=1;m<l;m++)d=a(c,m),v+=" C"+d[1][0]+","+d[1][1]+" "+d[2][0]+","+d[2][1]+" "+d[3][0]+","+d[3][1];return v};$.extend(KhanUtil,{svgPath:g});var w=function(e){var n={scale:function(e){typeof e=="number"&&(e=[e,e]),t=e[0],i=e[1],l.setSize((u[1]-u[0])*t,(f[1]-f[0])*i)},clipRect:function(e){var t=e[0],n=e[1];return t[1]+=n[1],{"clip-rect":p(t).concat(h(n)).join(" ")}},strokeWidth:function(e){return{"stroke-width":parseFloat(e)}},rx:function(e){return{rx:h([e,0])[0]}},ry:function(e){return{ry:h([0,e])[1]}},r:function(e){var t=h([e,e]);return{rx:t[0],ry:t[1]}}},r={};return $.each(e||{},function(e,t){var i=n[e];if(typeof i=="function")$.extend(r,i(t));else{var s=e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase();r[s]=t}}),r},E=function N(e){var t=e.constructor.prototype;if(t===Raphael.el){if(e.type==="path"&&typeof e.arrowheadsDrawn=="undefined"){var n=e.attr("stroke-width"),r=.6+.4*n,i=e.getTotalLength();if(!(i<.75*r)){var s=l.set(),o=l.path("M-3 4 C-2.75 2.5 0 0.25 0.75 0C0 -0.25 -2.75 -2.5 -3 -4"),u=e.getPointAtLength(i-.4),a=e.getPointAtLength(i-.75*r),f=Math.atan2(u.y-a.y,u.x-a.x)*180/Math.PI,c=e.attr();delete c.path;var h=e.getSubpath(0,i-.75*r);return h=l.path(h).attr(c),h.arrowheadsDrawn=!0,e.remove(),o.rotate(f,.75,0).scale(r,r,.75,0).translate(a.x,a.y).attr(c).attr({"stroke-linejoin":"round","stroke-linecap":"round"}),o.arrowheadsDrawn=!0,s.push(h),s.push(o),s}}}else if(t===Raphael.st)for(var p=0,i=e.items.length;p<i;p++)N(e.items[p]);return e},S={circle:function(e,t){return l.ellipse.apply(l,p(e).concat(h([t,t])))},rect:function(e,t,n,r){var i=p([e,t+r]),s=h([n,r]);return l.rect.apply(l,i.concat(s))},ellipse:function(e,t){return l.ellipse.apply(l,p(e).concat(h(t)))},fixedEllipse:function(e,t,n){var r=p(e),i=h(t),s=2,o=2*i[0]*n+s,u=2*i[1]*n+s,a=r[0]-o/2,f=r[1]-u/2,l=document.createElement("div");$(l).css({position:"absolute",width:o+"px",height:u+"px",left:a+"px",top:f+"px"});var c=Raphael(l,o,u),d=c.ellipse(o/2,u/2,i[0],i[1]);return{wrapper:l,visibleShape:d}},arc:function(e,t,n,r,i){n=(n%360+360)%360,r=(r%360+360)%360;var o=p(e),u=h(t),a=s(t,n),f=s(t,r),c=p([e[0]+a[0],e[1]+a[1]]),d=p([e[0]+f[0],e[1]+f[1]]),v=((r-n)%360+360)%360>180;return l.path("M"+c.join(" ")+"A"+u.join(" ")+" 0 "+(v?1:0)+" 0 "+d.join(" ")+(i?"L"+o.join(" ")+"z":""))},path:function(e){var t=l.path(g(e));return t.graphiePath=e,t},fixedPath:function(e,t,r){e=_.map(e,p),t=t?p(t):null,r=r||g;var i=_.min(_.pluck(e,0)),s=_.max(_.pluck(e,0)),o=_.min(_.pluck(e,1)),u=_.max(_.pluck(e,1)),a=[4,4],f=[i,o];e=_.map(e,function(e){return n.add(n.subtract(e,f),n.scale(a,.5))});var l=s-i+a[0],c=u-o+a[1],h=f[0]-a[0]/2,d=f[1]-a[1]/2,v=document.createElement("div");$(v).css({position:"absolute",width:l+"px",height:c+"px",left:h+"px",top:d+"px",transformOrigin:t?l/2+t[0]+"px "+(c/2+t[1])+"px":null});var m=Raphael(v,l,c),y=m.path(r(e));return{wrapper:v,visibleShape:y}},scaledPath:function(e){var t=l.path(g(e,!0));return t.graphiePath=e,t},line:function(e,t){return this.path([e,t])},parabola:function(e,t,n){return l.path(y(e,t,n))},fixedLine:function(e,t,r){var i=[r,r];e=p(e),t=p(t);var s=[Math.min(e[0],t[0]),Math.min(e[1],t[1])];e=n.add(n.subtract(e,s),n.scale(i,.5)),t=n.add(n.subtract(t,s),n.scale(i,.5));var o=s[0]-i[0]/2,u=s[1]-i[1]/2,a=Math.abs(e[0]-t[0])+i[0],f=Math.abs(e[1]-t[1])+i[1],l=document.createElement("div");$(l).css({position:"absolute",width:a+"px",height:f+"px",left:o+"px",top:u+"px",transformOrigin:e[0]+"px "+e[1]+"px"});var c=Raphael(l,a,f),h="M"+e[0]+" "+e[1]+" "+"L"+t[0]+" "+t[1],d=c.path(h);return d.graphiePath=[e,t],{wrapper:l,visibleShape:d}},sinusoid:function(e,t,n,r){return l.path(b(e,t,n,r))},grid:function(e,t){var n=c.step||[1,1],r=l.set(),i=n[0]*Math.ceil(e[0]/n[0]);for(;i<=e[1];i+=n[0])r.push(this.line([i,t[0]],[i,t[1]]));var s=n[1]*Math.ceil(t[0]/n[1]);for(;s<=t[1];s+=n[1])r.push(this.line([e[0],s],[e[1],s]));return r},label:function(t,n,r,i){i=typeof i=="undefined"||i;var s=$("<span>").addClass("graphie-label");i||s.html(n);var o=c["label-distance"];s.css($.extend({},c,{position:"absolute",padding:(o!=null?o:7)+"px"})).data("labelDirection",r).appendTo(e),s.setPosition=function(e){var t=p(e);s.css({left:t[0],top:t[1]})},s.setPosition(t);var u=s[0];s.processMath=function(e,t){KhanUtil.processMath(u,e,t,function(){var e=u.scrollWidth,t=u.scrollHeight;m(u,[e,t])})};if(i)s.processMath(n,!1);else{var a=u.scrollWidth,f=u.scrollHeight;m(u,[a,f])}return s},plotParametric:function(e,t,n,r){r=r||function(e){return[e,0]},c.strokeLinejoin||(c.strokeLinejoin="round"),c.strokeLinecap||(c.strokeLinecap="round");var s=t[0],o=t[1],u=(o-s)/(c["plot-points"]||800);u===0&&(u=1);var a=l.set(),f=[],h=KhanUtil.coordDiff(e(s),r(s)),p=s;for(var d=s;d<=o;d+=u){var v=e(d),m=r(d),g=KhanUtil.coordDiff(v,m);if(g[1]<0!=h[1]<0&&Math.abs(g[1]-h[1])>2*i||Math.abs(g[1])>1e7||isNaN(g[1])){if(n){f.push(v);for(var y=d-u;y>=p;y-=u)f.push(r(y));p=d}a.push(this.path(f)),f=[],n&&f.push(v)}else f.push(v);h=g}if(n)for(var y=o-u;y>=p;y-=u)f.push(r(y));return a.push(this.path(f)),a},plotPolar:function(e,n){var r=n[0],i=n[1];return c["plot-points"]||(c["plot-points"]=2*(i-r)*t),this.plotParametric(function(t){return s(e(t),t*180/Math.PI)},n)},plot:function(e,n,r,i,s){var o=n[0],u=n[1];c["plot-points"]||(c["plot-points"]=2*(u-o)*t);if(r){if(s)throw new Error("Can't shade area between functions with swapped axes.");return this.plotParametric(function(t){return[e(t),t]},n,i)}if(s){if(i)return this.plotParametric(function(t){return[t,e(t)]},n,i,function(e){return[e,s(e)]});throw new Error("fn2 should only be set when 'shade' is True.")}return this.plotParametric(function(t){return[t,e(t)]},n,i)},plotPiecewise:function(e,t){var n=l.set(),r=this;return _.times(e.length,function(i){var s=e[i],o=t[i],u=r.plotParametric(function(e){return[e,s(e)]},o);_.each(u,function(e){n.push(e)})}),n},plotEndpointCircles:function(e){var t=l.set(),n=this;return _.each(e,function(e,r){t.push(n.circle(e,.15))}),t},plotAsymptotes:function(e,t){var n=t[0],r=t[1],s=(r-n)/(c["plot-points"]||800),o=l.set(),u=e(n);for(var a=n;a<=r;a+=s){var f=e(a);f<0!=u<0&&Math.abs(f-u)>2*i&&o.push(this.line([a,i],[a,-i])),u=f}return o}},x=new r;return _.extend(x,{raphael:l,init:function(n){var r=n.scale||[40,40];r=typeof r=="number"?[r,r]:r,t=r[0],i=r[1];if(n.range==null)return Khan.error("range should be specified in graph init");u=n.range[0],f=n.range[1];var s=(u[1]-u[0])*t,o=(f[1]-f[0])*i;return l.setSize(s,o),$(e).css({width:s,height:o}),this.range=n.range,this.scale=r,this.dimensions=[s,o],this.xpixels=s,this.ypixels=o,this},setInterval:function(){var e=Function.prototype.apply.call(window.setInterval,window,arguments);return o.push(e),e},style:function(e,t){var n=w(e);if(typeof t=="function"){var r=c;c=$.extend({},c,n);var i=t.call(x);return c=r,i}$.extend(c,n)},scalePoint:p,scaleVector:h,unscalePoint:d,unscaleVector:v,svgPath:g,svgParabolaPath:y,svgSinusoidPath:b}),$.each(S,function(e){x[e]=function(){var t=arguments[arguments.length-1],n=c,r;if(typeof t=="object"&&!_.isArray(t)){c=$.extend({},c,w(t));var i=[].slice.call(arguments,0,arguments.length-1);r=S[e].apply(S,i)}else c=$.extend({},c),r=S[e].apply(S,arguments);var s=r.constructor.prototype;return s===Raphael.el||s===Raphael.st?(r.attr(c),c.arrows&&(r=E(r))):r instanceof $&&r.css(c),c=n,r}}),x.graphInit=function(e){e=e||{},$.each(e,function(t,n){!t.match(/.*Opacity$/)&&t!=="range"&&typeof n=="number"&&(e[t]=[n,n]);if(t==="range"||t==="gridRange")n.constructor===Array?n[0].constructor!==Array&&(e[t]=[[-n[0],n[0]],[-n[1],n[1]]]):typeof n=="number"&&(e[t]=[[-n,n],[-n,n]])});var t=e.range||[[-10,10],[-10,10]],n=e.gridRange||e.range,r=e.scale||[20,20],i=e.grid!=null?e.grid:!0,s=e.gridOpacity||.1,o=e.gridStep||[1,1],u=e.axes!=null?e.axes:!0,a=e.axisArrows||"",f=e.axisOpacity||1,l=e.axisCenter||[Math.min(Math.max(t[0][0],0),t[0][1]),Math.min(Math.max(t[1][0],0),t[1][1])],c=e.axisLabels!=null?e.axisLabels:!1,h=e.ticks!=null?e.ticks:!0,p=e.tickStep||[2,2],d=e.tickLen||[5,5],v=e.tickOpacity||1,m=e.labels||e.labelStep||!1,g=e.labelStep||[1,1],y=e.labelOpacity||1,b=e.unityLabels||!1,w=e.labelFormat||function(e){return e},E=e.xLabelFormat||w,S=e.yLabelFormat||w,x=e.smartLabelPositioning!=null?e.smartLabelPositioning:!0,T=[[t[0][0]-(t[0][0]>0?1:0),t[0][1]+(t[0][1]<0?1:0)],[t[1][0]-(t[1][0]>0?1:0),t[1][1]+(t[1][1]<0?1:0)]];_.isArray(b)||(b=[b,b]);if(x){var N=function(e){return function(t){return(e(t)+"").replace(/-(\d)/g,"\\llap{-}$1")}};E=N(E),S=N(S)}this.init({range:T,scale:r}),i&&this.grid(n[0],n[1],{stroke:"#000000",opacity:s,step:o}),u&&(a==="<->"||a===!0?this.style({stroke:"#000000",opacity:f,strokeWidth:2,arrows:"->"},function(){t[1][0]<0&&t[1][1]>0&&(this.path([l,[n[0][0],l[1]]]),this.path([l,[n[0][1],l[1]]])),t[0][0]<0&&t[0][1]>0&&(this.path([l,[l[0],n[1][0]]]),this.path([l,[l[0],n[1][1]]]))}):(a==="->"||a==="")&&this.style({stroke:"#000000",opacity:f,strokeWidth:2,arrows:a},function(){this.path([[n[0][0],l[1]],[n[0][1],l[1]]]),this.path([[l[0],n[1][0]],[l[0],n[1][1]]])}),c&&c.length===2&&(this.label([n[0][1],l[1]],c[0],"right"),this.label([l[0],n[1][1]],c[1],"above"))),h&&this.style({stroke:"#000000",opacity:v,strokeWidth:1},function(){var e=o[0]*p[0],i=d[0]/r[1],s=n[0][0],u=n[0][1];if(t[1][0]<0&&t[1][1]>0){for(var f=e+l[0];f<=u;f+=e)(f<u||!a)&&this.line([f,-i+l[1]],[f,i+l[1]]);for(var f=-e+l[0];f>=s;f-=e)(f>s||!a)&&this.line([f,-i+l[1]],[f,i+l[1]])}e=o[1]*p[1],i=d[1]/r[0],s=n[1][0],u=n[1][1];if(t[0][0]<0&&t[0][1]>0){for(var c=e+l[1];c<=u;c+=e)(c<u||!a)&&this.line([-i+l[0],c],[i+l[0],c]);for(var c=-e+l[1];c>=s;c-=e)(c>s||!a)&&this.line([-i+l[0],c],[i+l[0],c])}}),m&&this.style({stroke:"#000000",opacity:y},function(){var e=o[0]*p[0]*g[0],t=n[0][0],r=n[0][1],i=l[0]<0?"above":"below",s=l[0]<0?"right":"left",u=l[0]===0&&l[1]!==0,f=l[0]!==0&&l[1]===0,c=l[0]!==0||l[1]!==0,h=b[0]||c,d=b[1]||c;for(var v=(u?0:e)+l[0];v<=r;v+=e)(v<r||!a)&&this.label([v,l[1]],E(v),i);for(var v=-e*(h?1:2)+l[0];v>=t;v-=e)(v>t||!a)&&this.label([v,l[1]],E(v),i);e=o[1]*p[1]*g[1],t=n[1][0],r=n[1][1];for(var m=(f?0:e)+l[1];m<=r;m+=e)(m<r||!a)&&this.label([l[0],m],S(m),s);for(var m=-e*(d?1:2)+l[1];m>=t;m-=e)(m>t||!a)&&this.label([l[0],m],S(m),s)})},x},$.fn.graphie=function(e){if(Khan.query.nographie!=null)return;return this.find(".graphie, script[type='text/graphie']").addBack().filter(".graphie, script[type='text/graphie']").each(function(){var t=$(this).text(),n;if($(this).data("graphie")!=null)return;$(this).empty();if($(this).data("update")){var r=$(this).data("update");$(this).remove();var i=$("#problemarea").add(e);n=i.find("#"+r+".graphie").data("graphie")}else{var s=this;$(this).filter("script")[0]!=null&&(s=$("<div>").addClass("graphie").attr("id",$(this).attr("id")).insertAfter(this)[0],$(this).remove()),n=KhanUtil.createGraphie(s),$(s).data("graphie",n);var r=$(s).attr("id");r&&(KhanUtil.graphs[r]=n)}typeof n.graph=="undefined"&&(n.graph={}),t="(function() {"+t+"\n})()",KhanUtil.currentGraph=n,$.tmpl.getVAR(t,n)}).end()},$.fn.graphieCleanup=function(e){u()}}),function(e,t,n,r){function S(e){while(e&&typeof e.originalEvent!="undefined")e=e.originalEvent;return e}function x(t,n){var i=t.type,s,o,a,l,c,h,p,d;t=e.Event(t),t.type=n,s=t.originalEvent,o=e.event.props,i.search(/mouse/)>-1&&(o=f);if(s)for(p=o.length,l;p;)l=o[--p],t[l]=s[l];i.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1);if(i.search(/^touch/)!==-1){a=S(s),i=a.touches,c=a.changedTouches,h=i&&i.length?i[0]:c&&c.length?c[0]:r;if(h)for(d=0,len=u.length;d<len;d++)l=u[d],t[l]=h[l]}return t}function T(t){var n={},r,s;while(t){r=e.data(t,i);for(s in r)r[s]&&(n[s]=n.hasVirtualBinding=!0);t=t.parentNode}return n}function N(t,n){var r;while(t){r=e.data(t,i);if(r&&(!n||r[n]))return t;t=t.parentNode}return null}function C(){g=!1}function k(){g=!0}function L(){E=0,v.length=0,m=!1,k()}function A(){C()}function O(){M(),c=setTimeout(function(){c=0,L()},e.vmouse.resetTimerDuration)}function M(){c&&(clearTimeout(c),c=0)}function _(t,n,r){var i;if(r&&r[t]||!r&&N(n.target,t))i=x(n,t),e(n.target).trigger(i);return i}function D(t){var n=e.data(t.target,s);if(!m&&(!E||E!==n)){var r=_("v"+t.type,t);r&&(r.isDefaultPrevented()&&t.preventDefault(),r.isPropagationStopped()&&t.stopPropagation(),r.isImmediatePropagationStopped()&&t.stopImmediatePropagation())}}function P(t){var n=S(t).touches,r,i;if(n&&n.length===1){r=t.target,i=T(r);if(i.hasVirtualBinding){E=w++,e.data(r,s,E),M(),A(),d=!1;var o=S(t).touches[0];h=o.pageX,p=o.pageY,_("vmouseover",t,i),_("vmousedown",t,i)}}}function H(e){if(g)return;d||_("vmousecancel",e,T(e.target)),d=!0,O()}function B(t){if(g)return;var n=S(t).touches[0],r=d,i=e.vmouse.moveDistanceThreshold;d=d||Math.abs(n.pageX-h)>i||Math.abs(n.pageY-p)>i,flags=T(t.target),d&&!r&&_("vmousecancel",t,flags),_("vmousemove",t,flags),O()}function j(e){if(g)return;k();var t=T(e.target),n;_("vmouseup",e,t);if(!d){var r=_("vclick",e,t);r&&r.isDefaultPrevented()&&(n=S(e).changedTouches[0],v.push({touchID:E,x:n.clientX,y:n.clientY}),m=!0)}_("vmouseout",e,t),d=!1,O()}function F(t){var n=e.data(t,i),r;if(n)for(r in n)if(n[r])return!0;return!1}function I(){}function q(t){var n=t.substr(1);return{setup:function(r,s){F(this)||e.data(this,i,{});var o=e.data(this,i);o[t]=!0,l[t]=(l[t]||0)+1,l[t]===1&&b.bind(n,D),e(this).bind(n,I),y&&(l.touchstart=(l.touchstart||0)+1,l.touchstart===1&&b.bind("touchstart",P).bind("touchend",j).bind("touchmove",B).bind("scroll",H))},teardown:function(r,s){--l[t],l[t]||b.unbind(n,D),y&&(--l.touchstart,l.touchstart||b.unbind("touchstart",P).unbind("touchmove",B).unbind("touchend",j).unbind("scroll",H));var o=e(this),u=e.data(this,i);u&&(u[t]=!1),o.unbind(n,I),F(this)||o.removeData(i)}}}var i="virtualMouseBindings",s="virtualTouchID",o="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),u="clientX clientY pageX pageY screenX screenY".split(" "),a=e.event.mouseHooks?e.event.mouseHooks.props:[],f=e.event.props.concat(a),l={},c=0,h=0,p=0,d=!1,v=[],m=!1,g=!1,y="addEventListener"in n,b=e(n),w=1,E=0;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var R=0;R<o.length;R++)e.event.special[o[R]]=q(o[R]);y&&n.addEventListener("click",function(t){var n=v.length,r=t.target,i,o,u,a,f,l;if(n){i=t.clientX,o=t.clientY,threshold=e.vmouse.clickDistanceThreshold,u=r;while(u){for(a=0;a<n;a++){f=v[a],l=0;if(u===r&&Math.abs(f.x-i)<threshold&&Math.abs(f.y-o)<threshold||e.data(u,s)===f.touchID){t.preventDefault(),t.stopPropagation();return}}u=u.parentNode}}},!0)}(jQuery,window,document),define("../perseus/ke/third_party/jquery.mobile.vmouse.js",function(){}),define("../perseus/ke/utils/kline.js",["require","./kpoint.js","./knumber.js"],function(e){var t=e("./kpoint.js"),n=e("./knumber.js"),r=KhanUtil.kline={distanceToPoint:function(e,n){return t.distanceToLine(n,e)},reflectPoint:function(e,n){return t.reflectOverLine(n,e)},midpoint:function(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]},equal:function(e,t,r){var i=e[0][0],s=e[0][1],o=e[1][0],u=e[1][1];return _.every(t,function(e){var t=e[0],a=e[1],f=.5*Math.abs(i*u+o*a+t*s-o*s-t*u-i*a);return n.equal(f,0,r)})},intersect:function(e,t,n,r,i,s,o,u){function a(e,t,n,r){return e*r-t*n}if(a(n,r,o,u)===0)return a(i-e,s-t,n,r)===0;var f=a(i-e,s-t,o,u)/a(n,r,o,u),l=a(i-e,s-t,n,r)/a(n,r,o,u);return 0<=f&&f<=1&&0<=l&&l<=1}};return r}),define("../perseus/ke/utils/objective_.js",["require"],function(e){var t=function(e,t){return _.object(_.map(e,function(e,n){return[n,e[t]]}))},n=function(e,t){var n={};return _.each(_.keys(e),function(r){n[r]=t(e[r],r)}),n},r=function(e,t){var n={};return _.each(e,function(e){n[e]=t(e)}),n};return{pluck:t,mapObject:n,mapObjectFromArray:r}}),define("../perseus/ke/utils/transform-helpers.js",["require"],function(e){function n(){var e=document.createElement("div"),t=["transform","msTransform","MozTransform","WebkitTransform","OTransform"],n=null;return _.each(t,function(t){typeof e.style[t]!="undefined"&&(n=t)}),n}function i(){var e=document.createElement("div"),t=KhanUtil.getPrefixedTransform();return e.style[t]="translateZ(0px)",!!e.style[t]}var t=null,r=null;$.extend(KhanUtil,{getPrefixedTransform:function(){return t=t||n(),t},getCanUse3dTransform:function(){return r==null&&(r=i()),r}})}),define("../perseus/ke/utils/wrapped-defaults.js",["require","./objective_.js","./kvector.js","./transform-helpers.js"],function(e){var t=e("./objective_.js"),n=e("./kvector.js");e("./transform-helpers.js");var r=["attr","animate"],i=_.extend({transform:function(e){var t=KhanUtil.getPrefixedTransform();this.wrapper.style[t]=e},toFront:function(){var e=this.wrapper.parentNode;e&&e.appendChild(this.wrapper)},toBack:function(){var e=this.wrapper.parentNode;e.firstChild!==this.wrapper&&e.insertBefore(this.wrapper,e.firstChild)},remove:function(){this.visibleShape.remove(),$(this.wrapper).remove()},getMouseTarget:function(){return this.visibleShape[0]},moveTo:function(e){var t=n.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),r=KhanUtil.getCanUse3dTransform(),i="translateX("+t[0]+"px) "+"translateY("+t[1]+"px)"+(r?" translateZ(0)":"");this.transform(i)},hide:function(){this.visibleShape.hide()},show:function(){this.visibleShape.show()}},t.mapObjectFromArray(r,function(e){return function(){this.visibleShape[e].apply(this.visibleShape,arguments)}}));return i}),define("../perseus/ke/utils/wrapped-ellipse.js",["require","./wrapped-defaults.js","./kvector.js"],function(e){var t=e("./wrapped-defaults.js"),n=e("./kvector.js"),r={maxScale:1,mouselayer:!1},i=function(e,t,n,i){i=_.extend({},r,i),_.extend(this,e.fixedEllipse(t,n,i.maxScale),{graphie:e,initialPoint:t}),i.mouselayer?this.graphie.addToMouseLayerWrapper(this.wrapper):this.graphie.addToVisibleLayerWrapper(this.wrapper)};return _.extend(i.prototype,{animateTo:function(e,t,r){var i=n.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),s=KhanUtil.getCanUse3dTransform(),o=this,u=null,a=null;$(this.wrapper).animate({cx:i[0],cy:i[1]},{duration:t,step:function(e,t){u=t.prop==="cx"&&e||u!=null&&u||t.prop==="cx"&&t.start,a=t.prop==="cy"&&e||a!=null&&a||t.prop==="cy"&&t.start;var i="translateX("+u+"px) "+"translateY("+a+"px)"+(s?" translateZ(0)":"");o.transform(i);var f=o.graphie.unscalePoint(n.add(o.graphie.scalePoint(o.initialPoint),[u,a]));r&&r(f)}})}},t),i}),define("../perseus/ke/utils/wrapped-line.js",["require","./wrapped-defaults.js","./kpoint.js","./kvector.js","./transform-helpers.js"],function(e){var t=e("./wrapped-defaults.js"),n=e("./kpoint.js"),r=e("./kvector.js");e("./transform-helpers.js");var i={thickness:2,mouselayer:!1},s=function(e,t,r,s){s=_.extend({},i,s);var o=[e.range[0][0],0],u=[e.range[0][1],0];_.extend(this,e.fixedLine(o,u,s.thickness)),_.extend(this,{graphie:e,initialPoint:e.scalePoint(o),initialLength:n.distanceToPoint(e.scalePoint(o),e.scalePoint(u))}),s.mouselayer?this.graphie.addToMouseLayerWrapper(this.wrapper):this.graphie.addToVisibleLayerWrapper(this.wrapper),this.moveTo(t,r)};return _.extend(s.prototype,t,{getMouseTarget:function(){return this.wrapper},moveTo:function(e,t){var n=this.graphie.scalePoint(e),i=this.graphie.scalePoint(t),s=r.polarDegFromCart(r.subtract(i,n)),o=s[0],u=KhanUtil.bound(s[1]),a=r.subtract(n,this.initialPoint),f=KhanUtil.bound(o/this.initialLength),l=KhanUtil.getCanUse3dTransform(),c="translateX("+a[0]+"px) "+"translateY("+a[1]+"px) "+(l?"translateZ(0) ":"")+"rotate("+u+"deg) "+"scaleX("+f+") scaleY(1)";this.transform(c)}}),s}),define("../perseus/ke/utils/wrapped-path.js",["require","./wrapped-defaults.js"],function(e){var t=e("./wrapped-defaults.js"),n={center:null,createPath:null,mouselayer:!1},r=function(e,t,r){r=_.extend({},n,r),_.extend(this,e.fixedPath(t,r.center,r.createPath)),_.extend(this,{graphie:e,initialPoint:e.scalePoint(_.head(t))}),r.mouselayer?this.graphie.addToMouseLayerWrapper(this.wrapper):this.graphie.addToVisibleLayerWrapper(this.wrapper)};return _.extend(r.prototype,t),r}),define("../perseus/ke/utils/interactive.js",["require","../third_party/jquery.mobile.vmouse.js","./graphie.js","./kvector.js","./kpoint.js","./kline.js","./wrapped-ellipse.js","./wrapped-line.js","./wrapped-path.js"],function(e){function u(e){return _.reduce(e,function(e,t){return e+t},0)}function a(e){var t=_.zip(e,e.slice(1).concat(e.slice(0,1))),n=_.map(t,function(e){var t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])});return u(n)>0}function f(){var e=_.toArray(arguments),t=_.zip.apply(_,e);return _.map(t,u)}function l(e){return _.map(e,function(e){return e*-1})}function c(e){var t=70.2941120352484,n=11.374597405497571,r=-0.037587715462826674;return(t-n)*Math.exp(r*e)+n}function h(e,t){return[e*Math.cos(t),e*Math.sin(t)*-1]}function p(e,t){var n=t*Math.PI/180;return h(e,n)}function d(e,t){this.set=e.raphael.set(),this.cx=t[0],this.cy=t[1];var n=this,r=e.unscaleVector(180.5)[0],i=e.scalePoint([this.cx-r,this.cy+r-e.unscaleVector(10.5)[1]]);this.set.push(e.mouselayer.image("https://ka-perseus-graphie.s3.amazonaws.com/e9d032f2ab8b95979f674fbfa67056442ba1ff6a.png",i[0],i[1],360,180));var s=function(n,i){var s=e.scaleVector(r);s[0]-=16,s[1]-=16;var o=e.scalePoint(t),u=Math.sin((n+90)*Math.PI/180)*(s[0]+i)+o[0],a=Math.cos((n+90)*Math.PI/180)*(s[1]+i)+o[1];return u+","+a},o=e.raphael.path(" M"+s(180,6)+" L"+s(180,2)+" L"+s(183,10)+" L"+s(180,18)+" L"+s(180,14)+" A"+(e.scaleVector(r)[0]+10)+","+(e.scaleVector(r)[1]+10)+",0,0,1,"+s(170,14)+" L"+s(170,18)+" L"+s(167,10)+" L"+s(170,2)+" L"+s(170,6)+" A"+(e.scaleVector(r)[0]+10)+","+(e.scaleVector(r)[1]+10)+",0,0,0,"+s(180,6)+" Z").attr({stroke:null,fill:KhanUtil.INTERACTIVE});this.set.push(o),this.centerPoint=e.addMovablePoint({coord:t,visible:!1}),this.rotateHandle=e.addMovablePoint({coord:[Math.sin(275*Math.PI/180)*(r+.5)+this.cx,Math.cos(275*Math.PI/180)*(r+.5)+this.cy],onMove:function(e,t){var r=Math.atan2(n.centerPoint.coord[1]-t,n.centerPoint.coord[0]-e)*180/Math.PI;n.rotate(-r-5,!0)}}),this.rotateHandle.constraints.fixedDistance.dist=r+.5,this.rotateHandle.constraints.fixedDistance.point=this.centerPoint,this.rotateHandle.visibleShape.remove(),this.rotateHandle.mouseTarget.attr({scale:2});var u=!1,a=!1,f=function(){return a||u},l=this,c=$(l.rotateHandle.mouseTarget.getMouseTarget());c.bind("vmousedown",function(e){u=!0,o.animate({scale:1.5,fill:KhanUtil.INTERACTING},50),$(document).bind("vmouseup.rotateHandle",function(e){u=!1,f()||o.animate({scale:1,fill:KhanUtil.INTERACTIVE},50),$(document).unbind("vmouseup.rotateHandle")})}),c.bind("vmouseover",function(e){a=!0,o.animate({scale:1.5,fill:KhanUtil.INTERACTING},50)}),c.bind("vmouseout",function(e){a=!1,f()||o.animate({scale:1,fill:KhanUtil.INTERACTIVE},50)});var h=$.map(this.set,function(e){return e.node});return this.makeTranslatable=function(){$(h).css("cursor","move"),$(h).bind("vmousedown",function(t){t.preventDefault();var r=t.pageX-$(e.raphael.canvas.parentNode).offset().left,i=t.pageY-$(e.raphael.canvas.parentNode).offset().top;$(document).bind("vmousemove.protractor",function(t){var s=t.pageX-$(e.raphael.canvas.parentNode).offset().left,o=t.pageY-$(e.raphael.canvas.parentNode).offset().top;s=Math.max(10,Math.min(e.xpixels-10,s)),o=Math.max(10,Math.min(e.ypixels-10,o));var u=s-r,a=o-i;$.each(n.set.items,function(){this.translate(u,a)}),n.centerPoint.setCoord([n.centerPoint.coord[0]+u/e.scale[0],n.centerPoint.coord[1]-a/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+u/e.scale[0],n.rotateHandle.coord[1]-a/e.scale[1]]),r=s,i=o}),$(document).one("vmouseup",function(e){$(document).unbind("vmousemove.protractor")})})},this.rotation=0,this.rotate=function(t,n){var r=e.scalePoint(this.centerPoint.coord);return n&&(this.rotation=0),this.set.rotate(this.rotation+t,r[0],r[1]),this.rotation=this.rotation+t,this},this.moveTo=function(r,i){var s=e.scalePoint(n.centerPoint.coord),o=e.scalePoint([r,i]),u=KhanUtil.getDistance(s,o)*2;$({x:s[0],y:s[1]}).animate({x:o[0],y:o[1]},{duration:u,step:function(t,r){var i=0,s=0;r.prop==="x"?i=t-e.scalePoint(n.centerPoint.coord)[0]:r.prop==="y"&&(s=t-e.scalePoint(n.centerPoint.coord)[1]),$.each(n.set.items,function(){this.translate(i,s)}),n.centerPoint.setCoord([n.centerPoint.coord[0]+i/e.scale[0],n.centerPoint.coord[1]-s/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+i/e.scale[0],n.rotateHandle.coord[1]-s/e.scale[1]])}})},this.rotateTo=function(t){Math.abs(this.rotation-t)>180&&(this.rotation+=360);var i=Math.abs(this.rotation-t)*5;$({0:this.rotation}).animate({0:t},{duration:i,step:function(e,t){n.rotate(e,!0),n.rotateHandle.setCoord([Math.sin((e+275)*Math.PI/180)*(r+.5)+n.centerPoint.coord[0],Math.cos((e+275)*Math.PI/180)*(r+.5)+n.centerPoint.coord[1]])}})},this.remove=function(){this.set.remove()},this.makeTranslatable(),this}function v(e,n){function m(e){for(var t=0;t<v.length;t++){var n=v[t];if(e%n===0)return h[n]}}_.defaults(n,{center:[0,0],pixelsPerUnit:40,ticksPerUnit:10,units:10,label:"",style:{fill:null,stroke:KhanUtil.GRAY}});var r=_.extend({},n.style,{strokeWidth:1}),i=_.extend({},n.style,{strokeWidth:2}),s=n.units*n.pixelsPerUnit,o=50,u=e.unscalePoint(t.subtract(e.scalePoint(n.center),t.scale([s,-o],.5))),a=n.pixelsPerUnit/e.scale[0],f=o/e.scale[0],l=t.add(u,[n.units*a,f]),c=1,h;if(n.ticksPerUnit===10)h={10:c,5:c*.55,1:c*.35};else{var p=[1,.6,.45,.3];h={};for(var d=n.ticksPerUnit;d>=1;d/=2)h[d]=c*(p.shift()||.2)}var v=_.keys(h).sort(function(e,t){return t-e}),g=u[0],y=u[1],b=l[0],w=l[1],E=n.units*n.ticksPerUnit+1,S=e.raphael.set(),x=1/e.scale[0];S.push(e.line([g-x,y],[b+x,y],i)),S.push(e.line([g-x,w],[b+x,w],i)),_.times(E,function(t){var s=t/n.ticksPerUnit,o=g+s*a,u=m(t)*f,l=t===0||t===E-1?i:r;S.push(e.line([o,y],[o,y+u],l));if(s%1===0){var c=e.scalePoint([o,w]),h,p;s===0?(h=n.label,p={mm:13,cm:11,m:8,km:11,"in":8,ft:8,yd:10,mi:10}[h]||3*h.toString().length):(h=s,p=-3*(s.toString().length+1));var d=e.raphael.text(c[0]+p,c[1]+10,h);d.attr({"font-family":"KaTeX_Main","font-size":"12px",color:"#444"}),S.push(d)}});var T=e.mouselayer.path(KhanUtil.svgPath([u,[g,w],l,[b,y],!0]));T.attr({fill:"#000",opacity:0,stroke:"#000","stroke-width":2}),S.push(T);var N=$.map(S,function(e){return e.node});$(N).css("cursor","move"),$(N).bind("vmousedown",function(t){t.preventDefault();var n=t.pageX-$(e.raphael.canvas.parentNode).offset().left,r=t.pageY-$(e.raphael.canvas.parentNode).offset().top;$(document).bind("vmousemove.ruler",function(t){var i=t.pageX-$(e.raphael.canvas.parentNode).offset().left,s=t.pageY-$(e.raphael.canvas.parentNode).offset().top;i=Math.max(10,Math.min(e.xpixels-10,i)),s=Math.max(10,Math.min(e.ypixels-10,s));var o=i-n,u=s-r;S.translate(o,u),C.setCoord([C.coord[0]+o/e.scale[0],C.coord[1]-u/e.scale[1]]),k.setCoord([k.coord[0]+o/e.scale[0],k.coord[1]-u/e.scale[1]]),n=i,r=s}),$(document).one("vmouseup",function(e){$(document).unbind("vmousemove.ruler")})});var C=e.addMovablePoint({coord:u,normalStyle:{fill:KhanUtil.INTERACTIVE,"fill-opacity":0,stroke:KhanUtil.INTERACTIVE},highlightStyle:{fill:KhanUtil.INTERACTING,"fill-opacity":.1,stroke:KhanUtil.INTERACTING},pointSize:6,onMove:function(n,r){var i=k.coord[1]-r,s=k.coord[0]-n,o=Math.atan2(i,s)*180/Math.PI,u=t.scale(t.add([n,r],k.coord),.5),a=e.scalePoint(u),f=t.scale(t.add(C.coord,k.coord),.5),l=e.scalePoint(f),c=t.subtract(a,l);S.rotate(-o,l[0],l[1]),S.translate(c[0],c[1])}}),k=e.addMovablePoint({coord:[b,y],normalStyle:{fill:KhanUtil.INTERACTIVE,"fill-opacity":0,stroke:KhanUtil.INTERACTIVE},highlightStyle:{fill:KhanUtil.INTERACTING,"fill-opacity":.1,stroke:KhanUtil.INTERACTING},pointSize:6,onMove:function(n,r){var i=r-C.coord[1],s=n-C.coord[0],o=Math.atan2(i,s)*180/Math.PI,u=t.scale(t.add([n,r],C.coord),.5),a=e.scalePoint(u),f=t.scale(t.add(C.coord,k.coord),.5),l=e.scalePoint(f),c=t.subtract(a,l);S.rotate(-o,l[0],l[1]),S.translate(c[0],c[1])}});return C.constraints.fixedDistance.dist=s/e.scale[0],C.constraints.fixedDistance.point=k,k.constraints.fixedDistance.dist=s/e.scale[0],k.constraints.fixedDistance.point=C,this.remove=function(){S.remove(),C.remove(),k.remove()},this}function m(e,t){this.graphie=e,_.extend(this,t),_.defaults(this,{normalStyle:{stroke:KhanUtil.INTERACTIVE,"stroke-width":2,fill:KhanUtil.INTERACTIVE},highlightStyle:{stroke:KhanUtil.INTERACTING,"stroke-width":2,fill:KhanUtil.INTERACTING},labelStyle:{stroke:KhanUtil.DYNAMIC,"stroke-width":1,color:KhanUtil.DYNAMIC},angleStyle:{stroke:KhanUtil.DYNAMIC,"stroke-width":1,color:KhanUtil.DYNAMIC},allowReflex:!0});if(!this.points||this.points.length!==3)throw new Error("MovableAngle requires 3 points");this.points=_.map(t.points,function(t){return _.isArray(t)?e.addMovablePoint({coord:t,visible:!1,constraints:{fixed:!0},normalStyle:this.normalStyle}):t},this),this.coords=_.pluck(this.points,"coord"),this.reflex==null&&(this.allowReflex?this.reflex=this._getClockwiseAngle(this.coords)>180:this.reflex=!1),this.rays=_.map([0,2],function(t){return e.addMovableLineSegment({pointA:this.points[1],pointZ:this.points[t],fixed:!0,extendRay:!0})},this),this.temp=[],this.labeledAngle=e.label([0,0],"","center",this.labelStyle),this.fixed||(this.addMoveHandlers(),this.addHighlightHandlers()),this.update()}e("../third_party/jquery.mobile.vmouse.js"),e("./graphie.js");var t=e("./kvector.js"),n=e("./kpoint.js"),r=e("./kline.js"),i=e("./wrapped-ellipse.js"),s=e("./wrapped-line.js"),o=e("./wrapped-path.js");$.extend(KhanUtil,{FILL_OPACITY:.3,dragging:!1,createSorter:function(){var e={},t;return e.hasAttempted=!1,e.init=function(n){t=$("[id="+n+"]").last();var r=t.wrap("<div>").parent(),i=$("<li>");i.addClass("placeholder"),r.addClass("sortable ui-helper-clearfix"),t.find("li").each(function(n,r){$(r).bind("vmousedown",function(n){if(n.type==="vmousedown"&&(n.which===1||n.which===0)){n.preventDefault(),$(r).addClass("dragging");var s=$(this).index();i.insertAfter(r),i.width($(r).width()),$(this).css("z-index",100);var o=$(this).offset(),u={left:n.pageX-o.left-3,top:n.pageY-o.top-3};$(r).css({position:"absolute"}),$(r).offset({left:o.left,top:o.top}),$(document).bind("vmousemove.tile vmouseup.tile",function(n){n.preventDefault();if(n.type==="vmousemove"){e.hasAttempted=!0,$(r).offset({left:n.pageX-u.left,top:n.pageY-u.top});var o=t.offset().left,a=$(r).offset().left-o,f=0,l=0;t.find("li").each(function(){if(this===i[0]||this===r)return;a>l+$(this).outerWidth(!0)/2&&(f+=1),l+=$(this).outerWidth(!0)});if(f!==s){s=f;if(f===0)i.prependTo(t),$(r).prependTo(t);else{i.detach(),$(r).detach();var c=t.find("li")[f-1];i.insertAfter(c),$(r).insertAfter(c)}}}else if(n.type==="vmouseup"){$(document).unbind(".tile");var h=$(r).offset();$(h).animate(i.offset(),{duration:150,step:function(e,t){h[t.prop]=e,$(r).offset(h)},complete:function(){$(r).css("z-index",0),i.detach(),$(r).css({position:"static"}),$(r).removeClass("dragging")}})}})}})})},e.getContent=function(){var e=[];return t.find("li").each(function(t,n){e.push($.trim($(n).find(".sort-key").text()))}),e},e.setContent=function(e){var n=[];$.each(e,function(e,r){var i=t.find("li .sort-key").filter(function(){return $(this).text()===r}).closest("li").get(0);$(i).detach(),n.push(i)}),t.append(n)},e},bogusShape:{animate:function(){},attr:function(){},remove:function(){}}}),$.extend(KhanUtil.Graphie.prototype,{initAutoscaledGraph:function(e,t){var n=this;t=$.extend({xpixels:500,ypixels:500,xdivisions:20,ydivisions:20,labels:!0,unityLabels:!0,range:e===undefined?[[-10,10],[-10,10]]:e},t),t.scale=[t.xpixels/(t.range[0][1]-t.range[0][0]),t.ypixels/(t.range[1][1]-t.range[1][0])],t.gridStep=[(t.range[0][1]-t.range[0][0])/t.xdivisions,(t.range[1][1]-t.range[1][0])/t.ydivisions],n.xpixels=t.xpixels,n.ypixels=t.ypixels,n.range=t.range,n.scale=t.scale,n.graphInit(t)},addMouseLayer:function(e){var t=this;e=_.extend({allowScratchpad:!1},e);var n=2;t.mouselayer=Raphael(t.raphael.canvas.parentNode,t.xpixels,t.ypixels),$(t.mouselayer.canvas).css("z-index",n);if(e.onClick||e.onMouseDown||e.onMouseMove||e.onMouseOver||e.onMouseOut){var r=t.mouselayer.rect(0,0,t.xpixels,t.ypixels).attr({fill:"#000",opacity:0}),i=!1;$(t.mouselayer.canvas).on("vmousedown",function(n){n.target===r[0]&&(e.onMouseDown&&e.onMouseDown(t.getMouseCoord(n)),i=!0,e.onMouseMove&&$(document).bind("vmousemove.mouseLayer",function(n){i&&(n.preventDefault(),e.onMouseMove(t.getMouseCoord(n)))}),$(document).bind("vmouseup.mouseLayer",function(n){$(document).unbind(".mouseLayer"),i&&e.onClick&&e.onClick(t.getMouseCoord(n)),i=!1}))}),e.onMouseOver&&$(t.mouselayer.canvas).on("vmouseover",function(n){e.onMouseOver(t.getMouseCoord(n))}),e.onMouseOut&&$(t.mouselayer.canvas).on("vmouseout",function(n){e.onMouseOut(t.getMouseCoord(n))})}e.allowScratchpad||Khan.scratchpad.disable(),t._mouselayerWrapper=document.createElement("div"),$(t._mouselayerWrapper).css({position:"absolute",left:0,top:0,zIndex:n}),t._visiblelayerWrapper=document.createElement("div"),$(t._visiblelayerWrapper).css({position:"absolute",left:0,top:0});var s=t.raphael.canvas.parentNode;s.appendChild(t._visiblelayerWrapper),s.appendChild(t._mouselayerWrapper),t.addToMouseLayerWrapper=function(e){this._mouselayerWrapper.appendChild(e)},t.addToVisibleLayerWrapper=function(e){this._visiblelayerWrapper.appendChild(e)}},getMousePx:function(e){var t=this,n=e.pageX-$(t.raphael.canvas.parentNode).offset().left,r=e.pageY-$(t.raphael.canvas.parentNode).offset().top;return[n,r]},getMouseCoord:function(e){return this.unscalePoint(this.getMousePx(e))},drawArcs:function(e,t,n,r){var i=KhanUtil.findAngle(e,t),s=KhanUtil.findAngle(n,t);if(((s-i)%360+360)%360>180){var o=i;i=s,s=o}var u=.3;((s-i)%360+360)%360<75&&(u=-0.6/90*(((s-i)%360+360)%360)+.8);var a=[];for(var f=0;f<r;++f)a.push(this.arc(t,u+.15*f,i,s));return a},labelAngle:function(e){var t=this;_.defaults(e,{point1:[0,0],vertex:[0,0],point3:[0,0],label:null,numArcs:1,showRightAngleMarker:!0,pushOut:0,clockwise:!1,style:{}});var n=e.text===undefined?"":e.text,r=e.vertex,i=t.scalePoint(r),s,o;e.clockwise?(s=e.point1,o=e.point3):(s=e.point3,o=e.point1);var u=KhanUtil.findAngle(s,r),a=KhanUtil.findAngle(o,r),l=(a+360-u)%360,h=(u+l/2)%360,d=5*e.pushOut,v=d+c(l),m=[];if(Math.abs(l-90)<1e-9&&e.showRightAngleMarker){var g=f(i,p(v,u)),y=f(i,p(v,a));v*=Math.SQRT2;var b=f(i,p(v,h));_.each([g,y],function(n){m.push(t.scaledPath([n,b],e.style))})}else _.times(e.numArcs,function(n){m.push(t.arc(r,t.unscaleVector(v),u,a,e.style)),v+=3});if(n){var w=n.match(/\$deg(\d)?/);if(w){var E=w[1]||1;n=n.replace(w[0],KhanUtil.toFixedApprox(l,E)+"^{\\circ}")}var S=p(v+15,h),x=f(i,S),T=t.unscalePoint(x);e.label?(e.label.setPosition(T),e.label.processMath(n,!0)):t.label(T,n,"center",e.style)}return m},labelSide:function(e){var t=this;_.defaults(e,{point1:[0,0],point2:[0,0],label:null,text:"",numTicks:0,numArrows:0,clockwise:!1,style:{}});var n,r;e.clockwise?(n=e.point1,r=e.point2):(n=e.point2,r=e.point1);var i=[(n[0]+r[0])/2,(n[1]+r[1])/2],s=t.scalePoint(i),o=Math.atan2(r[1]-n[1],r[0]-n[0]),u=o+Math.PI/2,a=[],c=0;if(e.numTicks){var p=e.numTicks,d=5,v=5,m=_.extend({},e.style,{strokeWidth:2});_.times(p,function(e){var n=d*(e-(p-1)/2),r=h(n,o),i=h(v,u),c=[f(s,r,i),f(s,r,l(i))];a.push(t.scaledPath(c,m))}),c+=d*(p-1)+15}if(e.numArrows){var p=e.numArrows,g=[n,r].sort(function(e,t){return e[1]===t[1]?e[0]-t[0]:e[1]-t[1]})[0],y=t.scalePoint(g),m=_.extend({},e.style,{arrows:"->",strokeWidth:2}),d=5;_.times(p,function(e){var r=c+d*e,i=h(r,o);g!==n&&(i=l(i));var u=f(s,i);a.push(t.scaledPath([y,u],m))})}var b=e.text;if(b){var w=b.match(/\$len(\d)?/);if(w){var E=KhanUtil.getDistance(n,r),S=w[1]||1;b=b.replace(w[0],KhanUtil.toFixedApprox(E,S))}var x=20,T=h(x,u),N=f(s,T),C=t.unscalePoint(N);e.label?(e.label.setPosition(C),e.label.processMath(b,!0)):t.label(C,b,"center",e.style)}return a},labelVertex:function(e){var t=this;_.defaults(e,{point1:null,vertex:[0,0],point3:null,label:null,text:"",clockwise:!1,style:{}});if(!e.text)return;var n=e.vertex,r=t.scalePoint(n),i,s;e.clockwise?(i=e.point1,s=e.point3):(i=e.point3,s=e.point1);var o=135,u;if(i&&s){var a=KhanUtil.findAngle(i,n),l=KhanUtil.findAngle(s,n);o=(l+360-a)%360,u=(a+o/2+180)%360}else if(i){var h=KhanUtil.findAngle(n,i);u=h+90}else if(s){var h=KhanUtil.findAngle(s,n);u=h+90}else u=135;var d=10+c(360-o),v=p(d,u),m=f(r,v),g=t.unscalePoint(m);e.label?(e.label.setPosition(g),e.label.processMath(e.text,!0)):t.label(g,e.text,"center",e.style)},addMovablePoint:function(e){var t=$.extend(!0,{graph:this,coord:[0,0],snapX:0,snapY:0,pointSize:4,highlight:!1,dragging:!1,visible:!0,bounded:!0,constraints:{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},lineStarts:[],lineEnds:[],polygonVertices:[],normalStyle:{},highlightStyle:{fill:KhanUtil.INTERACTING,stroke:KhanUtil.INTERACTING},labelStyle:{color:KhanUtil.INTERACTIVE},vertexLabel:"",mouseTarget:null},e),n=t.constraints.fixed?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE;t.normalStyle=_.extend({},{fill:n,stroke:n},e.normalStyle),e.coordX!==undefined&&(t.coord[0]=e.coordX),e.coordY!==undefined&&(t.coord[1]=e.coordY);var r=t.graph,s=function(e){t.visible&&t.bounded&&!t.constraints.fixed&&(e=r.constrainToBounds(e,10));var n=e[0],i=e[1];t.snapX!==0&&(n=Math.round(n/t.snapX)*t.snapX),t.snapY!==0&&(i=Math.round(i/t.snapY)*t.snapY);if(t.constraints.fixedDistance.snapPoints){var s=r.scalePoint(e),o=s[0],u=s[1],a=2*Math.PI/t.constraints.fixedDistance.snapPoints,f=t.constraints.fixedDistance.dist,l=t.constraints.fixedDistance.point,c=(l[0]-r.range[0][0])*r.scale[0],h=(-l[1]+r.range[1][1])*r.scale[1],p=o-c,d=-u+h,v=Math.atan(d/p),m=p<0;m&&(v+=Math.PI),v=Math.round(v/a)*a,p=f*Math.cos(v),d=f*Math.sin(v),o=p+c,u=-d+h,n=KhanUtil.roundTo(5,o/r.scale[0]+r.range[0][0]),i=KhanUtil.roundTo(5,r.range[1][1]-u/r.scale[1])}var g=t.applyConstraint([n,i]);return g};t.applyConstraint=function(e,n,r){var i=e.slice(),s={};r?$.extend(s,{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},n):$.extend(s,this.constraints,n);if(s.constrainX)i=[this.coord[0],e[1]];else if(s.constrainY)i=[e[0],this.coord[1]];else if(typeof s.fixedAngle.angle=="number"&&typeof s.fixedDistance.dist=="number"){var o=s.fixedAngle.vertex.coord||s.fixedAngle.vertex,u=s.fixedAngle.ref.coord||s.fixedAngle.ref,a=s.fixedDistance.point.coord||s.fixedDistance.point,f=(s.fixedAngle.angle+KhanUtil.findAngle(u,o))*Math.PI/180,l=s.fixedDistance.dist;i[0]=l*Math.cos(f)+a[0],i[1]=l*Math.sin(f)+a[1]}else if(typeof s.fixedAngle.angle=="number"){var o=s.fixedAngle.vertex.coord||s.fixedAngle.vertex,u=s.fixedAngle.ref.coord||s.fixedAngle.ref,f=(s.fixedAngle.angle+KhanUtil.findAngle(u,o))*Math.PI/180,c=KhanUtil.findAngle(e,o)*Math.PI/180,h=KhanUtil.getDistance(e,o),l=h*Math.cos(f-c);l=l<1?1:l,i[0]=l*Math.cos(f)+o[0],i[1]=l*Math.sin(f)+o[1]}else if(typeof s.fixedDistance.dist=="number"){var a=s.fixedDistance.point.coord||s.fixedDistance.point,c=KhanUtil.findAngle(e,a),l=s.fixedDistance.dist;c=c*Math.PI/180,i[0]=l*Math.cos(c)+a[0],i[1]=l*Math.sin(c)+a[1]}else s.fixed&&(i=t.coord);return i},t.coord=s(t.coord);var o=2;t.visible&&r.style(t.normalStyle,function(){var e=[t.pointSize/r.scale[0],t.pointSize/r.scale[1]],n={maxScale:o};t.visibleShape=new i(r,t.coord,e,n),t.visibleShape.attr(_.omit(t.normalStyle,"scale")),t.visibleShape.toFront()}),t.normalStyle.scale=1,t.highlightStyle.scale=o,t.vertexLabel&&(t.labeledVertex=this.label([0,0],"","center",t.labelStyle)),t.drawLabel=function(){t.vertexLabel&&t.graph.labelVertex({vertex:t.coord,label:t.labeledVertex,text:t.vertexLabel,style:t.labelStyle})},t.drawLabel(),t.grab=function(){$(document).bind("vmousemove.point vmouseup.point",function(e){e.preventDefault(),t.dragging=!0,KhanUtil.dragging=!0;var n=r.getMouseCoord(e);n=s(n);var i=n[0],o=n[1],u,a;if(e.type==="vmousemove"){var f=!0;if(_.isFunction(t.onMove)){var l=t.onMove(i,o);l===!1&&(f=!1),_.isArray(l)&&(i=l[0],o=l[1])}u=(i-r.range[0][0])*r.scale[0],a=(-o+r.range[1][1])*r.scale[1];if(f){var c=r.unscalePoint([u,a]);t.visibleShape.moveTo(c),t.mouseTarget.moveTo(c),t.coord=[i,o],t.updateLineEnds(),$(t).trigger("move")}t.drawLabel()}else if(e.type==="vmouseup"){$(document).unbind(".point"),t.dragging=!1,KhanUtil.dragging=!1;if(_.isFunction(t.onMoveEnd)){var l=t.onMoveEnd(i,o);if(_.isArray(l)){i=l[0],o=l[1],u=(i-r.range[0][0])*r.scale[0],a=(-o+r.range[1][1])*r.scale[1];var c=r.unscalePoint([u,a]);t.visibleShape.moveTo(c),t.mouseTarget.moveTo(c),t.coord=[i,o]}}t.highlight||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight())}})};if(t.visible&&!t.constraints.fixed){if(!t.mouseTarget){var u=r.unscaleVector(15),e={mouselayer:!0};t.mouseTarget=new i(r,t.coord,u,e),t.mouseTarget.attr({fill:"#000",opacity:0})}var a=$(t.mouseTarget.getMouseTarget());a.css("cursor","move"),a.bind("vmousedown vmouseover vmouseout",function(e){e.type==="vmouseover"?(t.highlight=!0,KhanUtil.dragging||(t.visibleShape.animate(t.highlightStyle,50),t.onHighlight&&t.onHighlight())):e.type==="vmouseout"?(t.highlight=!1,!t.dragging&&!KhanUtil.dragging&&(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight())):e.type==="vmousedown"&&(e.which===1||e.which===0)&&(e.preventDefault(),t.grab())})}return t.moveTo=function(e,n,r){var i=KhanUtil.getDistance(this.graph.scalePoint([e,n]),this.graph.scalePoint(this.coord)),s=i*5,o=r&&function(e){t.coord=e,t.updateLineEnds()};this.visibleShape.animateTo([e,n],s,o),this.mouseTarget.animateTo([e,n],s,o),this.coord=[e,n],_.isFunction(this.onMove)&&this.onMove(e,n)},t.updateLineEnds=function(){$(this.lineStarts).each(function(){this.coordA=t.coord,this.transform()}),$(this.lineEnds).each(function(){this.coordZ=t.coord,this.transform()}),$(this.polygonVertices).each(function(){this.transform()})},t.setCoord=function(e){this.visible&&(this.visibleShape.moveTo(e),this.mouseTarget!=null&&this.mouseTarget.moveTo(e)),this.coord=e.slice()},t.setCoordConstrained=function(e){this.setCoord(s(e))},t.toBack=function(){this.visible&&(this.mouseTarget!=null&&this.mouseTarget.toBack(),this.visibleShape.toBack())},t.toFront=function(){this.visible&&(this.mouseTarget!=null&&this.mouseTarget.toFront(),this.visibleShape.toFront())},t.remove=function(){this.visibleShape&&this.visibleShape.remove(),this.mouseTarget&&this.mouseTarget.remove(),this.labeledVertex&&this.labeledVertex.remove()},t},addInteractiveFn:function(e,t){var n=this;t=$.extend({graph:n,snap:0,range:[n.range[0][0],n.range[0][1]]},t);var r={highlight:!1};n.style({stroke:KhanUtil.BLUE},function(){r.visibleShape=n.plot(e,t.range,t.swapAxes)}),n.style({fill:KhanUtil.BLUE,stroke:KhanUtil.BLUE},function(){r.cursorPoint=n.ellipse([0,e(0)],[4/n.scale[0],4/n.scale[1]])}),r.cursorPoint.attr("opacity",0);var i=30,s=[],o=(t.range[1]-t.range[0])/100,u=function(e,r){t.swapAxes?s.push([(r-n.range[0][0])*n.scale[0],(n.range[1][1]-e)*n.scale[1]]):s.push([(e-n.range[0][0])*n.scale[0],(n.range[1][1]-r)*n.scale[1]])};for(var a=t.range[0];a<=t.range[1];a+=o){var f=(e(a-.001)-e(a+.001))/.002,l=a,c=e(a)+i/(2*n.scale[1]);if(f!==0){var h=-1/(f*(n.scale[1]/n.scale[0]))/(n.scale[1]/n.scale[0]);f<0?(l=a-Math.cos(-Math.atan(h*(n.scale[1]/n.scale[0])))*i/(2*n.scale[0]),c=h*(a-l)+e(a)):f>0&&(l=a+Math.cos(-Math.atan(h*(n.scale[1]/n.scale[0])))*i/(2*n.scale[0]),c=h*(a-l)+e(a))}u(l,c)}for(var a=t.range[1];a>=t.range[0];a-=o){var f=(e(a-.001)-e(a+.001))/.002,l=a,c=e(a)-i/(2*n.scale[1]);if(f!==0){var h=-1/(f*(n.scale[1]/n.scale[0]))/(n.scale[1]/n.scale[0]);f<0?(l=a+Math.cos(-Math.atan(h*(n.scale[1]/n.scale[0])))*i/(2*n.scale[0]),c=h*(a-l)+e(a)):f>0&&(l=a-Math.cos(-Math.atan(h*(n.scale[1]/n.scale[0])))*i/(2*n.scale[0]),c=h*(a-l)+e(a))}u(l,c)}return r.mouseTarget=n.mouselayer.path(KhanUtil.unscaledSvgPath(s)),r.mouseTarget.attr({fill:"#000",opacity:0}),$(r.mouseTarget[0]).bind("vmouseover vmouseout vmousemove",function(i){i.preventDefault();var s=i.pageX-$(n.raphael.canvas.parentNode).offset().left,o=i.pageY-$(n.raphael.canvas.parentNode).offset().top;s=Math.max(10,Math.min(n.xpixels-10,s)),o=Math.max(10,Math.min(n.ypixels-10,o)),t.snap&&(s=Math.round(s/(n.scale[0]*t.snap))*n.scale[0]*t.snap);var u=s/n.scale[0]+n.range[0][0],a=n.range[1][1]-o/n.scale[1],f=function(r,i){var s=0,o=Math.sqrt(r*r+i*i);for(var u=t.range[0];u<t.range[1];u+=(t.range[1]-t.range[0])/n.xpixels)Math.sqrt((u-r)*(u-r)+(e(u)-i)*(e(u)-i))<o&&(s=u,o=Math.sqrt((u-r)*(u-r)+(e(u)-i)*(e(u)-i)));return s};if(t.swapAxes){var l=f(a,u);u=e(l),a=l}else{var l=f(u,a);u=l,a=e(l)}r.cursorPoint.attr("cx",(n.range[0][1]+u)*n.scale[0]),r.cursorPoint.attr("cy",(n.range[1][1]-a)*n.scale[1]),_.isFunction(r.onMove)&&r.onMove(u,a),i.type==="vmouseover"?(r.cursorPoint.animate({opacity:1},50),r.highlight=!0):i.type==="vmouseout"&&(r.highlight=!1,r.cursorPoint.animate({opacity:0},50),_.isFunction(r.onLeave)&&r.onLeave(u,a))}),r.mouseTarget.toBack(),r},addMovableLineSegment:function(e){var n=$.extend({graph:this,coordA:[0,0],coordZ:[1,1],snapX:0,snapY:0,fixed:!1,ticks:0,normalStyle:{},highlightStyle:{stroke:KhanUtil.INTERACTING,"stroke-width":6},labelStyle:{stroke:KhanUtil.INTERACTIVE,color:KhanUtil.INTERACTIVE},highlight:!1,dragging:!1,tick:[],extendLine:!1,extendRay:!1,constraints:{fixed:!1,constrainX:!1,constrainY:!1},sideLabel:"",vertexLabels:[],numArrows:0,numTicks:0,movePointsWithLine:!1},e),r=n.fixed?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE;n.normalStyle=_.extend({},{"stroke-width":2,stroke:r},e.normalStyle),n.arrowStyle=_.extend({},n.normalStyle,{color:n.normalStyle.stroke}),e.pointA!==undefined?(n.coordA=e.pointA.coord,n.pointA.lineStarts.push(n)):e.coordA!==undefined&&(n.coordA=e.coordA.slice()),e.pointZ!==undefined?(n.coordZ=e.pointZ.coord,n.pointZ.lineEnds.push(n)):e.coordA!==undefined&&(n.coordA=n.coordA.slice());var i=n.graph;i.style(n.normalStyle);for(var u=0;u<n.ticks;++u)n.tick[u]=KhanUtil.bogusShape;var a=KhanUtil.unscaledSvgPath([[0,0],[1,0]]);for(var u=0;u<n.ticks;++u){var f=.5-(n.ticks-1+u*2)/i.scale[0];a+=KhanUtil.unscaledSvgPath([[f,-7],[f,7]])}var e={thickness:Math.max(n.normalStyle["stroke-width"],n.highlightStyle["stroke-width"])};n.visibleLine=new s(i,[0,0],[1,0],e),n.visibleLine.attr(n.normalStyle);if(!n.fixed){var e={thickness:30,mouselayer:!0};n.mouseTarget=new s(i,[0,0],[1,0],e),n.mouseTarget.attr({fill:"#000",opacity:0})}n.transform=function(e){e&&(typeof this.pointA=="object"&&(this.coordA=this.pointA.coord),typeof this.pointZ=="object"&&(this.coordZ=this.pointZ.coord));var r=function(e){var n=e.graph.scalePoint(e.coordA),r=e.graph.scalePoint(e.coordZ);return t.polarDegFromCart(t.subtract(r,n))[1]},s=function(e,r,i){var e=n.graph,s=e.range[0][1]-e.range[0][0],o=e.range[1][1]-e.range[1][0],u=s+o,a=e.unscaleVector(t.cartFromPolarDeg([1,i])),f=t.scale(t.normalize(a),u),l=t.add(r,f),c=t.polarDegFromCart(a)[1],h=e.constrainToBoundsOnAngle(l,4,c*Math.PI/180);return h},u=r(this),a=this.coordA,f=this.coordZ;this.extendLine?(a=s(i,a,360-u),f=s(i,f,(540-u)%360)):this.extendRay&&(f=s(i,a,360-u));var l=[this.visibleLine];this.fixed||l.push(this.mouseTarget),_.each(l,function(e){e.moveTo(a,f)});var c=function(e,n){var r=[.75,0],i=[[-3,4],[-2.75,2.5],[0,.25],r,[0,-0.25],[-2.75,-2.5],[-3,-4]],u=1.4;i=_.map(i,function(e){var n=t.subtract(e,r),i=t.scale(n,u);return t.add(r,i)});var a=function(e){var t="M"+e[0][0]+" "+e[0][1];for(var n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t},f=_.map(i,e.unscalePoint),l={center:e.unscalePoint(r),createPath:a},c=new o(e,f,l);return c.attr(_.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},n)),c.toCoordAtAngle=function(t,n){var i=e.scalePoint(s(e,t,n)),o=KhanUtil.getCanUse3dTransform();c.transform("translateX("+(i[0]+u*r[0])+"px) "+"translateY("+(i[1]+u*r[1])+"px) "+(o?"translateZ(0) ":"")+"rotate("+(360-KhanUtil.bound(n))+"deg)")},c};this._arrows==null&&(this._arrows=[],this.extendLine?(this._arrows.push(c(i,this.normalStyle)),this._arrows.push(c(i,this.normalStyle))):this.extendRay&&this._arrows.push(c(i,this.normalStyle)));var h=[this.coordA,this.coordZ],p=[360-u,(540-u)%360];_.each(this._arrows,function(e,t){e.toCoordAtAngle(h[t],p[t])}),_.invoke(this.temp,"remove"),this.temp=[];var d=this.coordA[0]<this.coordZ[0]||this.coordA[0]===this.coordZ[0]&&this.coordA[1]>this.coordZ[1];this.sideLabel&&this.temp.push(this.graph.labelSide({point1:this.coordA,point2:this.coordZ,label:this.labeledSide,text:this.sideLabel,numArrows:this.numArrows,numTicks:this.numTicks,clockwise:d,style:this.labelStyle})),this.vertexLabels.length&&(this.graph.labelVertex({vertex:this.coordA,point3:this.coordZ,label:this.labeledVertices[0],text:this.vertexLabels[0],clockwise:d,style:this.labelStyle}),this.graph.labelVertex({point1:this.coordA,vertex:this.coordZ,label:this.labeledVertices[1],text:this.vertexLabels[1],clockwise:d,style:this.labelStyle})),this.temp=_.flatten(this.temp)},n.toBack=function(){n.fixed||n.mouseTarget.toBack(),n.visibleLine.toBack()},n.toFront=function(){n.fixed||n.mouseTarget.toFront(),n.visibleLine.toFront()},n.remove=function(){n.fixed||n.mouseTarget.remove(),n.visibleLine.remove(),n.labeledSide&&n.labeledSide.remove(),n.labeledVertices&&_.invoke(n.labeledVertices,"remove"),n._arrows&&_.invoke(n._arrows,"remove"),n.temp.length&&_.invoke(n.temp,"remove")},n.hide=function(){n.visibleLine.hide(),n.temp.length&&_.invoke(n.temp,"hide"),n._arrows&&_.invoke(n._arrows,"hide")},n.show=function(){n.visibleLine.show(),n.temp.length&&_.invoke(n.temp,"show"),n._arrows&&_.invoke(n._arrows,"show")},n.sideLabel&&(n.labeledSide=this.label([0,0],"","center",n.labelStyle)),n.vertexLabels.length&&(n.labeledVertices=_.map(n.vertexLabels,function(e){return this.label([0,0],"","center",n.labelStyle)},this));if(!n.fixed&&!n.constraints.fixed){var l=$(n.mouseTarget.getMouseTarget());l.css("cursor","move"),l.bind("vmousedown vmouseover vmouseout",function(e){if(e.type==="vmouseover")KhanUtil.dragging||(n.highlight=!0,n.visibleLine.animate(n.highlightStyle,50),n.arrowStyle=_.extend({},n.arrowStyle,{color:n.highlightStyle.stroke,stroke:n.highlightStyle.stroke}),n.transform());else if(e.type==="vmouseout")n.highlight=!1,n.dragging||(n.visibleLine.animate(n.normalStyle,50),n.arrowStyle=_.extend({},n.arrowStyle,{color:n.normalStyle.stroke,stroke:n.normalStyle.stroke}),n.transform());else if(e.type==="vmousedown"&&(e.which===1||e.which===0)){e.preventDefault();var t=(e.pageX-$(i.raphael.canvas.parentNode).offset().left)/i.scale[0]+i.range[0][0],r=i.range[1][1]-(e.pageY-$(i.raphael.canvas.parentNode).offset().top)/i.scale[1];n.snapX>0&&(t=Math.round(t/n.snapX)*n.snapX),n.snapY>0&&(r=Math.round(r/n.snapY)*n.snapY);var s=[n.coordA[0]-t,n.coordA[1]-r],o=[n.coordZ[0]-t,n.coordZ[1]-r],u=-Math.min(i.scaleVector(s)[0],i.scaleVector(o)[0]),a=Math.max(i.scaleVector(s)[0],i.scaleVector(o)[0]),f=Math.max(i.scaleVector(s)[1],i.scaleVector(o)[1]),l=-Math.min(i.scaleVector(s)[1],i.scaleVector(o)[1]);$(document).bind("vmousemove.lineSegment vmouseup.lineSegment",function(e){e.preventDefault(),n.dragging=!0,KhanUtil.dragging=!0;var t=e.pageX-$(i.raphael.canvas.parentNode).offset().left,r=e.pageY-$(i.raphael.canvas.parentNode).offset().top;t=Math.max(u+10,Math.min(i.xpixels-10-a,t)),r=Math.max(f+10,Math.min(i.ypixels-10-l,r));var c=t/i.scale[0]+i.range[0][0],h=i.range[1][1]-r/i.scale[1];n.snapX>0&&(c=Math.round(c/n.snapX)*n.snapX),n.snapY>0&&(h=Math.round(h/n.snapY)*n.snapY);if(e.type==="vmousemove"){n.constraints.constrainX&&(c=n.coordA[0]-s[0]),n.constraints.constrainY&&(h=n.coordA[1]-s[1]);var p=c+s[0]-n.coordA[0],d=h+s[1]-n.coordA[1];n.coordA=[c+s[0],h+s[1]],n.coordZ=[c+o[0],h+o[1]],n.transform(),n.movePointsWithLine&&(typeof n.pointA=="object"&&n.pointA.setCoord([n.pointA.coord[0]+p,n.pointA.coord[1]+d]),typeof n.pointZ=="object"&&n.pointZ.setCoord([n.pointZ.coord[0]+p,n.pointZ.coord[1]+d])),_.isFunction(n.onMove)&&n.onMove(p,d)}else e.type==="vmouseup"&&($(document).unbind(".lineSegment"),n.dragging=!1,KhanUtil.dragging=!1,n.highlight||(n.visibleLine.animate(n.normalStyle,50),n.arrowStyle=_.extend({},n.arrowStyle,{color:n.normalStyle.stroke,stroke:n.normalStyle.stroke}),n.transform()),_.isFunction(n.onMoveEnd)&&n.onMoveEnd());$(n).trigger("move")})}})}return n.pointA!==undefined&&n.pointA.toFront(),n.pointZ!==undefined&&n.pointZ.toFront(),n.transform(),n},addMovablePolygon:function(e){var t=this,n=$.extend({snapX:0,snapY:0,fixed:!1,constrainToGraph:!0,normalStyle:{},highlightStyle:{stroke:KhanUtil.INTERACTING,"stroke-width":2,fill:KhanUtil.INTERACTING,"fill-opacity":.05},pointHighlightStyle:{fill:KhanUtil.INTERACTING,stroke:KhanUtil.INTERACTING},labelStyle:{stroke:KhanUtil.DYNAMIC,"stroke-width":1,color:KhanUtil.DYNAMIC},angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],updateOnPointMove:!0,closed:!0},_.omit(e,"points")),r=n.fixed?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE;n.normalStyle=_.extend({"stroke-width":2,"fill-opacity":0,fill:r,stroke:r},e.normalStyle),n.points=e.points;var i=function(e){return!_.isArray(e)};return n.update=function(){var e=n.points.length;n.coords=_.map(n.points,function(e,t){return i(e)?e.coord:e}),n.left=_.min(_.pluck(n.coords,0)),n.right=_.max(_.pluck(n.coords,0)),n.top=_.max(_.pluck(n.coords,1)),n.bottom=_.min(_.pluck(n.coords,1));var r=_.map(n.coords,function(e){return t.scalePoint(e)});n.closed?r.push(!0):r=r.concat(_.clone(r).reverse()),n.path=KhanUtil.unscaledSvgPath(r),_.invoke(n.temp,"remove"),n.temp=[];var s=a(n.coords);(n.angleLabels.length||n.showRightAngleMarkers.length)&&_.each(n.labeledAngles,function(r,i){n.temp.push(t.labelAngle({point1:n.coords[(i-1+e)%e],vertex:n.coords[i],point3:n.coords[(i+1)%e],label:r,text:n.angleLabels[i],showRightAngleMarker:n.showRightAngleMarkers[i],numArcs:n.numArcs[i],clockwise:s,style:n.labelStyle}))}),n.sideLabels.length&&_.each(n.labeledSides,function(r,i){n.temp.push(t.labelSide({point1:n.coords[i],point2:n.coords[(i+1)%e],label:r,text:n.sideLabels[i],numArrows:n.numArrows[i],numTicks:n.numTicks[i],clockwise:s,style:n.labelStyle}))}),n.vertexLabels.length&&_.each(n.labeledVertices,function(r,i){t.labelVertex({point1:n.coords[(i-1+e)%e],vertex:n.coords[i],point3:n.coords[(i+1)%e],label:r,text:n.vertexLabels[i],clockwise:s,style:n.labelStyle})}),n.temp=_.flatten(n.temp)},n.transform=function(){n.update(),n.visibleShape.attr({path:n.path}),n.fixed||n.mouseTarget.attr({path:n.path})},n.remove=function(){n.visibleShape.remove(),n.fixed||n.mouseTarget.remove(),n.labeledAngles&&_.invoke(n.labeledAngles,"remove"),n.labeledSides&&_.invoke(n.labeledSides,"remove"),n.labeledVertices&&_.invoke(n.labeledVertices,"remove"),n.temp.length&&_.invoke(n.temp,"remove")},n.toBack=function(){n.fixed||n.mouseTarget.toBack(),n.visibleShape.toBack()},n.toFront=function(){n.fixed||n.mouseTarget.toFront(),n.visibleShape.toFront()},n.updateOnPointMove&&_.each(_.filter(n.points,i),function(e){e.polygonVertices.push(n)}),n.coords=new Array(n.points.length),n.angleLabels.length&&(n.labeledAngles=_.times(Math.max(n.angleLabels.length,n.showRightAngleMarkers.length),function(){return this.label([0,0],"","center",n.labelStyle)},this)),n.sideLabels.length&&(n.labeledSides=_.map(n.sideLabels,function(e){return this.label([0,0],"","center",n.labelStyle)},this)),n.vertexLabels.length&&(n.labeledVertices=_.map(n.vertexLabels,function(e){return this.label([0,0],"","center",n.labelStyle)},this)),n.update(),n.visibleShape=t.raphael.path(n.path),n.visibleShape.attr(n.normalStyle),n.fixed||(n.mouseTarget=t.mouselayer.path(n.path),n.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"}),$(n.mouseTarget[0]).bind("vmousedown vmouseover vmouseout",function(e){if(e.type==="vmouseover"){if(!KhanUtil.dragging||n.dragging)n.highlight=!0,n.visibleShape.animate(n.highlightStyle,50),_.each(_.filter(n.points,i),function(e){e.visibleShape.animate(n.pointHighlightStyle,50)})}else if(e.type==="vmouseout"){n.highlight=!1;if(!n.dragging){n.visibleShape.animate(n.normalStyle,50);var r=_.filter(n.points,i);_.any(_.pluck(r,"dragging"))||_.each(r,function(e){e.visibleShape.animate(e.normalStyle,50)})}}else if(e.type==="vmousedown"&&(e.which===1||e.which===0)){e.preventDefault(),_.each(_.filter(n.points,i),function(e){e.dragging=!0});var s=(e.pageX-$(t.raphael.canvas.parentNode).offset().left)/t.scale[0]+t.range[0][0],o=t.range[1][1]-(e.pageY-$(t.raphael.canvas.parentNode).offset().top)/t.scale[1];n.snapX>0&&(s=Math.round(s/n.snapX)*n.snapX),n.snapY>0&&(o=Math.round(o/n.snapY)*n.snapY);var u=s,a=o,f=n.coords.slice(),l=(s-n.left)*t.scale[0],c=(n.right-s)*t.scale[0],h=(n.top-o)*t.scale[1],p=(o-n.bottom)*t.scale[1];$(document).bind("vmousemove.polygon vmouseup.polygon",function(e){e.preventDefault(),n.dragging=!0,KhanUtil.dragging=!0;var r=e.pageX-$(t.raphael.canvas.parentNode).offset().left,d=e.pageY-$(t.raphael.canvas.parentNode).offset().top;n.constrainToGraph&&(r=Math.max(l+10,Math.min(t.xpixels-10-c,r)),d=Math.max(h+10,Math.min(t.ypixels-10-p,d)));var v=r/t.scale[0]+t.range[0][0],m=t.range[1][1]-d/t.scale[1];n.snapX>0&&(v=Math.round(v/n.snapX)*n.snapX),n.snapY>0&&(m=Math.round(m/n.snapY)*n.snapY);if(e.type==="vmousemove"){var g=v-s,y=m-o,b=!0;if(_.isFunction(n.onMove)){var w=n.onMove(g,y);w===!1?b=!1:_.isArray(w)&&(g=w[0],y=w[1],v=s+g,m=o+y)}var E=function(e){return[f[e][0]+g,f[e][1]+y]};b&&(_.each(n.points,function(e,t){i(e)?e.setCoord(E(t)):n.points[t]=E(t)}),n.transform(),$(n).trigger("move"),u=v,a=m)}else if(e.type==="vmouseup"){$(document).unbind(".polygon");var S=_.filter(n.points,i);_.each(S,function(e){e.dragging=!1}),n.dragging=!1,KhanUtil.dragging=!1,n.highlight||(n.visibleShape.animate(n.normalStyle,50),_.each(S,function(e){e.visibleShape.animate(e.normalStyle,50)})),_.isFunction(n.onMoveEnd)&&n.onMoveEnd(u-s,a-o)}})}})),_.invoke(_.filter(n.points,i),"toFront"),n},constrainToBounds:function(e,t){var n=this.unscalePoint([t,this.ypixels-t]),r=this.unscalePoint([this.xpixels-t,t]),i=Math.max(n[0],Math.min(r[0],e[0])),s=Math.max(n[1],Math.min(r[1],e[1]));return[i,s]},constrainToBoundsOnAngle:function(e,t,n){var r=this.unscalePoint([t,this.ypixels-t]),i=this.unscalePoint([this.xpixels-t,t]),s=e.slice();return s[0]<r[0]?s=[r[0],s[1]+(r[0]-s[0])*Math.tan(n)]:s[0]>i[0]&&(s=[i[0],s[1]-(s[0]-i[0])*Math.tan(n)]),s[1]<r[1]?s=[s[0]+(r[1]-s[1])/Math.tan(n),r[1]]:s[1]>i[1]&&(s=[s[0]-(s[1]-i[1])/Math.tan(n),i[1]]),s},addMovableAngle:function(e){return new m(this,e)},addArrowWidget:function(e){var t=$.extend({graph:this,direction:"up",coord:[0,0],onClick:function(){}},e),n=t.graph;return t.direction==="up"?t.visibleShape=n.path([[t.coord[0],t.coord[1]-4/n.scale[1]],[t.coord[0]-4/n.scale[0],t.coord[1]-4/n.scale[1]],[t.coord[0],t.coord[1]+4/n.scale[1]],[t.coord[0]+4/n.scale[0],t.coord[1]-4/n.scale[1]],[t.coord[0],t.coord[1]-4/n.scale[1]]],{stroke:"",fill:KhanUtil.INTERACTIVE}):t.direction==="down"&&(t.visibleShape=n.path([[t.coord[0],t.coord[1]+4/n.scale[1]],[t.coord[0]-4/n.scale[0],t.coord[1]+4/n.scale[1]],[t.coord[0],t.coord[1]-4/n.scale[1]],[t.coord[0]+4/n.scale[0],t.coord[1]+4/n.scale[1]],[t.coord[0],t.coord[1]+4/n.scale[1]]],{stroke:"",fill:KhanUtil.INTERACTIVE})),_.defer(function(){t.visibleShape.attr({stroke:"",fill:KhanUtil.INTERACTIVE})}),t.mouseTarget=n.mouselayer.circle(n.scalePoint(t.coord)[0],n.scalePoint(t.coord)[1],15),t.mouseTarget.attr({fill:"#000",opacity:0}),$(t.mouseTarget[0]).css("cursor","pointer"),$(t.mouseTarget[0]).bind("vmousedown vmouseover vmouseout",function(e){if(e.type==="vmouseover")t.visibleShape.animate({scale:2,fill:KhanUtil.INTERACTING},20);else if(e.type==="vmouseout")t.visibleShape.animate({scale:1,fill:KhanUtil.INTERACTING},20);else if(e.type==="vmousedown"&&(e.which===1||e.which===0))return t.hidden||t.onClick(),!1}),t.hide=function(){t.visibleShape.hide(),t.hidden=!0,$(t.mouseTarget[0]).css("cursor","default")},t.show=function(){t.visibleShape.show(),t.hidden=!1,$(t.mouseTarget[0]).css("cursor","pointer")},t},addRectGraph:function(e){function o(e,n,r,i){t.points[r].setCoord([e,t.points[r].coord[1]]),t.points[i].setCoord([t.points[i].coord[0],n]),t.points[r].updateLineEnds(),t.points[i].updateLineEnds()}function u(e,t,n){return n?t<e:t>e}function a(e,n,r){var i=t.getXLims(),o=t.getYLims(),a=s[e],f=u(i[a[0]],n,a[0]===1),l=u(o[a[1]],r,a[1]===1);return f&&l}function l(e,n){var r=t.constraints.constrainX,i=t.getX()+e<t.constraints.xmin,s=t.getX2()+e>t.constraints.xmax,o=t.constraints.constrainY,u=t.getY()+n<t.constraints.ymin,a=t.getY2()+n>t.constraints.ymax;return e=r||i||s?0:e,n=o||u||a?0:n,[e,n]}var t=$.extend(!0,{x:0,y:0,width:1,height:1,normalStyle:{points:{stroke:KhanUtil.INTERACTIVE,fill:KhanUtil.INTERACTIVE,opacity:1},edges:{stroke:KhanUtil.INTERACTIVE,opacity:1,"stroke-width":1},area:{fill:KhanUtil.INTERACTIVE,"fill-opacity":.1,"stroke-width":0}},hoverStyle:{points:{color:KhanUtil.INTERACTING,opacity:1,width:2},edges:{stroke:KhanUtil.INTERACTING,opacity:1,"stroke-width":1},area:{fill:KhanUtil.INTERACTING,"fill-opacity":.2,"stroke-width":0}},fixed:{edges:[!1,!1,!1,!1],points:[!1,!1,!1,!1]},constraints:{constrainX:!1,constrainY:!1,xmin:null,xmax:null,ymin:null,ymax:null},snapX:0,snapY:0,onMove:function(){}},e);t=$.extend({initialized:function(){return t.points&&t.points.length},x2:function(){return this.x+this.width},y2:function(){return this.y+this.height},getX:function(){return t.initialized()?t.points[0].coord[0]:t.x},getY:function(){return t.initialized()?t.points[0].coord[1]:t.y},getX2:function(){return t.getX()+t.getWidth()},getY2:function(){return t.getY()+t.getHeight()},getXLims:function(){var e=t.getX();return[e,e+t.getWidth()]},getYLims:function(){var e=t.getY();return[e,e+t.getHeight()]},getWidth:function(){if(t.initialized()){var e=t.points[1].coord[0],n=t.points[2].coord[0];return n-e}return t.width},getHeight:function(){if(t.initialized()){var e=t.points[0].coord[1],n=t.points[1].coord[1];return n-e}return t.height},getCoord:function(){return[t.getX(),t.getY()]},getRaphaelParamsArr:function(){var e=t.getWidth(),r=t.getHeight(),i=t.getX(),s=t.getY(),o=n.scalePoint([i,s+r]),u=n.scaleVector([e,r]);return o.concat(u)},getRaphaelParams:function(){var e=t.getRaphaelParamsArr();return{x:e[0],y:e[1],width:e[2],height:e[3]}}},t);var n=this;t.fillArea=n.rect().attr(t.normalStyle.area),t.mouseTarget=n.mouselayer.rect().attr({fill:"#000",opacity:0,"fill-opacity":0}),t.render=function(){t.fillArea.attr(t.getRaphaelParams()),t.mouseTarget.attr(t.getRaphaelParams())},t.render(),t.points=[];var r=[[t.x,t.y],[t.x,t.y2()],[t.x2(),t.y2()],[t.x2(),t.y]],i=[[1,3],[0,2],[3,1],[2,0]],s=[[1,1],[1,0],[0,0],[0,1]];_.times(4,function(e){var s=i[e][0],u=i[e][1],f=r[e],l=n.addMovablePoint({graph:n,coord:f,normalStyle:t.normalStyle.points,hoverStyle:t.hoverStyle.points,snapX:t.snapX,snapY:t.snapY,visible:!t.fixed.points[e],constraints:{fixed:t.fixed.points[e]},onMove:function(n,r){if(!a(e,n,r))return!1;o(n,r,s,u),t.render()}});t.points.push(l)}),t.edges=[],t.moveEdge=function(e,n,r){var i=t.edges[r].pointA,s=t.edges[r].pointZ;i.setCoord([i.coord[0]+e,i.coord[1]+n]),s.setCoord([s.coord[0]+e,s.coord[1]+n]),i.updateLineEnds(),s.updateLineEnds()},_.times(4,function(e){var r=t.points[e],i=t.points[(e+1)%4],s=e%2,o=(e+1)%2,u=n.addMovableLineSegment({graph:n,pointA:r,pointZ:i,normalStyle:t.normalStyle.edges,hoverStyle:t.hoverStyle.edges,snapX:t.snapX,snapY:t.snapY,fixed:t.fixed.edges[e],constraints:{constrainX:s,constrainY:o},onMove:function(n,r){t.moveEdge(n,r,e),t.render()}});t.edges.push(u)});var f=[t.fillArea,t.mouseTarget];t.elems=f.concat(t.edges).concat(t.points),t.translate=function(e,n){if(t.constraints.constrainX&&t.constraints.constrainY)return;var r=l(e,n);e=r[0],n=r[1],_.each(t.points,function(t,r){var i=t.coord[0]+e,s=t.coord[1]+n;t.setCoord([i,s]),t.updateLineEnds()}),t.render(),t.onMove(e,n)},t.moveTo=function(e,n){var r=e-t.getX(),i=n-t.getY();t.translate(r,i)},t.snap=function(){var e,n;_.each(t.points,function(r,i){var s=r.coord[0],o=r.coord[1],u=s,a=o;t.snapX&&(u=KhanUtil.roundToNearest(t.snapX,s)),t.snapY&&(a=KhanUtil.roundToNearest(t.snapY,o));if(!e||!n)e=u-s,n=a-o;r.setCoord([u,a]),r.updateLineEnds()}),t.render(),t.onMove(e,n)},t.toFront=function(){_.each(t.elems,function(e){e.toFront()})},t.hide=function(e){if(t.hidden)return;e=e||100,t.fillArea.animate({"fill-opacity":0},e),$(t.mouseTarget[0]).css("display","none"),t.hidden=!0},t.show=function(e){if(!t.hidden)return;e=e||100,t.fillArea.animate(t.normalStyle.area,e),$(t.mouseTarget[0]).css("display","block"),t.hidden=!1},t.enableHoverStyle=function(){t.highlight=!0,KhanUtil.dragging||t.fillArea.animate(t.hoverStyle.area,100)},t.enableNormalStyle=function(){t.highlight=!1,t.dragging||t.fillArea.animate(t.normalStyle.area,100)};var c=function(){$(t.mouseTarget[0]).css("cursor","move"),$(t.mouseTarget[0]).on("vmouseover vmouseout vmousedown",function(e){e.type==="vmouseover"?t.enableHoverStyle():e.type==="vmouseout"?t.enableNormalStyle():e.type==="vmousedown"&&(e.which===1||e.which===0)&&(e.preventDefault(),t.toFront(),t.prevCoord=n.getMouseCoord(e),t.enableHoverStyle(),$(document).on("vmousemove vmouseup",function(e){e.preventDefault(),t.dragging=!0,KhanUtil.dragging=!0;if(e.type==="vmousemove"){var r=n.getMouseCoord(e);if(t.prevCoord&&t.prevCoord.length===2){var i=KhanUtil.coordDiff(t.prevCoord,r);t.translate(i[0],i[1])}t.prevCoord=r}else if(e.type==="vmouseup"){$(document).off("vmousemove vmouseup"),t.dragging=!1,KhanUtil.dragging=!1;var r=n.getMouseCoord(e);(r[0]<t.getX()||r[0]>t.getX2()||r[1]<t.getY()||r[1]>t.getY2())&&t.enableNormalStyle(),t.snap()}}))})};return c(),t},addCircleGraph:function(e){var t=this,n=$.extend({center:[0,0],radius:2,snapX:.5,snapY:.5,snapRadius:.5,minRadius:1,centerConstraints:{},centerNormalStyle:{},centerHighlightStyle:{stroke:KhanUtil.INTERACTING,fill:KhanUtil.INTERACTING},circleNormalStyle:{stroke:KhanUtil.INTERACTIVE,"fill-opacity":0},circleHighlightStyle:{stroke:KhanUtil.INTERACTING,fill:KhanUtil.INTERACTING,"fill-opacity":.05}},e),r=n.centerConstraints.fixed?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE,i=e?e.centerNormalStyle:null;return n.centerNormalStyle=_.extend({},{fill:r,stroke:r},i),n.centerPoint=t.addMovablePoint({graph:t,coord:n.center,normalStyle:n.centerNormalStyle,snapX:n.snapX,snapY:n.snapY,constraints:n.centerConstraints}),n.circ=t.circle(n.center,n.radius,n.circleNormalStyle),n.perim=t.mouselayer.circle(t.scalePoint(n.center)[0],t.scalePoint(n.center)[1],t.scaleVector(n.radius)[0]).attr({"stroke-width":20,opacity:.002}),n.centerConstraints.fixed||$(n.centerPoint.mouseTarget.getMouseTarget()).on("vmouseover vmouseout",function(e){n.centerPoint.highlight||n.centerPoint.dragging?n.circ.animate(n.circleHighlightStyle,50):n.circ.animate(n.circleNormalStyle,50)}),n.toFront=function(){n.circ.toFront(),n.perim.toFront(),n.centerPoint.visibleShape.toFront(),n.centerConstraints.fixed||n.centerPoint.mouseTarget.toFront()},n.centerPoint.onMove=function(e,r){n.toFront(),n.circ.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(r)[1]}),n.perim.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(r)[1]}),n.onMove&&n.onMove(e,r)},$(n.centerPoint).on("move",function(){n.center=this.coord,$(n).trigger("move")}),n.setCenter=function(e,t){n.centerPoint.setCoord([e,t]),n.centerPoint.onMove(e,t),n.center=[e,t]},n.setRadius=function(e){n.radius=e,n.perim.attr({r:t.scaleVector(e)[0]}),n.circ.attr({rx:t.scaleVector(e)[0],ry:t.scaleVector(e)[1]})},n.remove=function(){n.centerPoint.remove(),n.circ.remove(),n.perim.remove()},$(n.perim[0]).css("cursor","move"),$(n.perim[0]).on("vmouseover vmouseout vmousedown",function(e){if(e.type==="vmouseover")n.highlight=!0,KhanUtil.dragging||(n.circ.animate(n.circleHighlightStyle,50),n.centerPoint.visibleShape.animate(n.centerHighlightStyle,50));else if(e.type==="vmouseout")n.highlight=!1,!n.dragging&&!n.centerPoint.dragging&&(n.circ.animate(n.circleNormalStyle,50),n.centerPoint.visibleShape.animate(n.centerNormalStyle,50));else if(e.type==="vmousedown"&&(e.which===1||e.which===0)){e.preventDefault(),n.toFront();var r=n.radius;$(document).on("vmousemove vmouseup",function(e){e.preventDefault(),n.dragging=!0,KhanUtil.dragging=!0;if(e.type==="vmousemove"){var i=t.constrainToBounds(t.getMouseCoord(e),10),s=KhanUtil.getDistance(n.centerPoint.coord,i);s=Math.max(n.minRadius,Math.round(s/n.snapRadius)*n.snapRadius);var o=n.radius,u=!0;if(n.onResize){var a=n.onResize(s,o);_.isNumber(a)?s=a:a===!1&&(u=!1)}u&&(n.setRadius(s),$(n).trigger("move"))}else e.type==="vmouseup"&&($(document).off("vmousemove vmouseup"),n.dragging=!1,KhanUtil.dragging=!1,n.onResizeEnd&&n.onResizeEnd(n.radius,r))})}}),n},interactiveEllipse:function(e){var t=this,n=$.extend({center:[0,0],radius:2,xRadius:2,yRadius:2,ellipseNormalStyle:{stroke:KhanUtil.BLUE,"fill-opacity":0},ellipseBoundaryHideStyle:{"fill-opacity":0,"stroke-width":0},ellipseBoundaryShowStyle:{"fill-opacity":1,fill:KhanUtil.BLUE},onMove:function(e,t){},onLeave:function(e,t){}},e);return n.circ=t.ellipse(n.center,[n.xRadius,n.yRadius],n.ellipseNormalStyle),n.perim=t.mouselayer.ellipse(t.scalePoint(n.center)[0],t.scalePoint(n.center)[1],t.scaleVector(n.xRadius)[0],t.scaleVector(n.yRadius)[0]).attr({"stroke-width":30,opacity:.002}),n.boundaryPoint=t.circle(n.center,.4,n.ellipseBoundaryHideStyle),n.remove=function(){n.circ.remove(),n.perim.remove()},n.showPoint=function(e){var r=t.constrainToBounds(t.getMouseCoord(e),10),i=n.yRadius*(n.center[0]-r[0]),s=n.xRadius*(n.center[1]-r[1]),o=Math.atan2(s,i);r[0]=n.center[0]-n.xRadius*Math.cos(o),r[1]=n.center[1]-n.yRadius*Math.sin(o);var u=t.scalePoint(r);n.boundaryPoint.attr({cx:u[0]}),n.boundaryPoint.attr({cy:u[1]}),n.boundaryPoint.animate(n.ellipseBoundaryShowStyle,50),n.onMove(r[0],r[1])},$(n.perim[0]).on("vmouseover vmouseout vmousemove",function(e){e.type==="vmouseover"?n.showPoint(e):e.type==="vmouseout"?(n.boundaryPoint.animate(n.ellipseBoundaryHideStyle,50),n.onLeave()):e.type==="vmousemove"&&n.showPoint(e)}),n},addRotateHandle:function(){var e=function(e,t,n,r,i,s,o){var u=function(r,i){var o=n+i,u=KhanUtil.kvector.cartFromPolarDeg([o,s+r]),a=KhanUtil.kvector.add(t,u),f=e.scalePoint(a);return f[0]+","+f[1]},a=e.scaleVector(n-r),f=e.scaleVector(n+r);return e.raphael.path(" M"+u(i,-r)+" L"+u(i,-3*r)+" L"+u(2*i,0)+" L"+u(i,3*r)+" L"+u(i,r)+" A"+f[0]+","+f[1]+",0,0,1,"+u(-i,r)+" L"+u(-i,3*r)+" L"+u(-2*i,0)+" L"+u(-i,-3*r)+" L"+u(-i,-r)+" A"+a[0]+","+a[1]+",0,0,0,"+u(i,-r)+" Z").attr({stroke:null,fill:o?KhanUtil.INTERACTING:KhanUtil.INTERACTIVE})};return function(t){var n=this,r=t.center,i=t.radius,s=t.lengthAngle||30,o=t.hideArrow||!1,u=t.mouseTarget,a=_.uniqueId("rotateHandle");_.isArray(r)&&(r={coord:r});var f=n.addMovablePoint({coord:KhanUtil.kpoint.addVector(r.coord,KhanUtil.kvector.cartFromPolarDeg(i,t.angleDeg||0)),constraints:{fixedDistance:{dist:i,point:r}},mouseTarget:u});r.toFront();var l=r.coord,c=f.coord,h=c,p=!1,d=!1,v,m=function(i){if(o)return;var u=KhanUtil.kvector.subtract(i,r.coord),a=KhanUtil.kvector.polarDegFromCart(u),f=a[1];v&&v.remove(),v=e(n,r.coord,t.radius,p||d?t.hoverWidth/2:t.width/2,s,f,p||d)};$(r).on("move."+a,function(){var e=KhanUtil.kvector.subtract(r.coord,l);f.setCoord(KhanUtil.kvector.add(f.coord,e)),m(f.coord),l=r.coord,f.constraints.fixedDistance.point=r,c=f.coord}),f.onMove=function(e,n){p||(h=c,p=!0);var i=[e,n];if(t.onMove){var s=KhanUtil.kvector.polarDegFromCart(KhanUtil.kvector.subtract(c,r.coord)),o=KhanUtil.kvector.polarDegFromCart(KhanUtil.kvector.subtract(i,r.coord)),u=s[1],a=o[1],f=t.onMove(a,u);f!=null&&f!==!0&&(f===!1&&(f=u),i=KhanUtil.kvector.add(r.coord,KhanUtil.kvector.cartFromPolarDeg([s[0],f])))}return m(i),c=i,i},f.onMoveEnd=function(){p=!1,m(f.coord);if(t.onMoveEnd){var e=KhanUtil.kvector.polarDegFromCart(KhanUtil.kvector.subtract(h,r.coord)),n=KhanUtil.kvector.polarDegFromCart(KhanUtil.kvector.subtract(f.coord,r.coord));t.onMoveEnd(n[1],e[1])}},f.visibleShape.remove(),u||f.mouseTarget.attr({scale:2});var g=$(f.mouseTarget.getMouseTarget());g.bind("vmouseover",function(e){d=!0,m(f.coord)}),g.bind("vmouseout",function(e){d=!1,m(f.coord)}),m(f.coord);var y=f.remove;return f.remove=function(){y.call(f),v&&v.remove(),$(r).off("move."+a)},f.update=function(){m(f.coord)},f}}(),addReflectButton:function(){var e=function(e,r,i,s,o,u,a){n.equal(i[0],i[1])&&(i=[i[0],n.addVector(i[0],[1,1])]);var f=t.normalize(t.subtract(i[1],i[0])),l=t.scale(f,s/2),c=t.scale(f,o),h=t.rotateDeg(c,90),p=t.rotateDeg(c,-90),d=t.negate(l),v=t.rotateDeg(l,90),m=t.rotateDeg(l,-90),g=n.addVectors(r,h),y=n.addVectors(r,p),b=n.addVectors(r,h,l,v),w=n.addVectors(r,h,d,v),E=n.addVectors(r,p,l,m),S=n.addVectors(r,p,d,m),x=e.path([g,b,w,!0],u),T=e.path([y,E,S,!0],a);return{remove:function(){x.remove(),T.remove()}}};return function(t){var n=this,i=t.line,s=n.addMovablePoint({constraints:t.constraints,coord:r.midpoint([i.pointA.coord,i.pointZ.coord]),snapX:n.snap[0],snapY:n.snap[1],onMove:function(e,t){return!1},onMoveEnd:function(e,n){t.onMoveEnd&&t.onMoveEnd.call(this,e,n)}}),o=!1,u=!1,a,f=function(){return o},l=_.map([0,1],function(e){var n=e?t.highlightStyle:t.normalStyle;return _.map([0,1],function(e){return _.defaults({"fill-opacity":e},n)})}),c=function(e){return u&&(e=!e),l[+f()][+e]},h=function(r,i){a&&a.remove(),a=e(n,r,i,f()?t.size*1.5:t.size,f()?t.size*.125:.25,c(0),c(1))},p=function(e,t){e=e||i.pointA.coord,t=t||i.pointZ.coord;var n=r.midpoint([e,t]);s.setCoord(n),h(n,[e,t])};$(i).on("move",_.bind(p,s,null,null));var d=$(s.mouseTarget.getMouseTarget());d.on("vclick",function(){var e=t.onClick();e!==!1&&(u=!u,h(s.coord,[i.pointA.coord,i.pointZ.coord]))}),i.pointA.toFront(),i.pointZ.toFront(),s.visibleShape.remove();var v=n.scaleVector(t.size)[0]/20;s.mouseTarget.attr({scale:1.5*v}),d.css("cursor","pointer"),d.bind("vmouseover",function(e){o=!0,h(s.coord,[i.pointA.coord,i.pointZ.coord])}),d.bind("vmouseout",function(e){o=!1,h(s.coord,[i.pointA.coord,i.pointZ.coord])});var m=s.remove;return s.remove=function(){a.remove(),m.call(s)},s.update=p,s.isFlipped=function(){return u},p(),s}}(),protractor:function(e){return new d(this,e)},ruler:function(e){return new v(this,e||{})},addPoints:f}),_.extend(m.prototype,{points:[],snapDegrees:0,snapOffsetDeg:0,angleLabel:"",numArcs:1,pushOut:0,fixed:!1,addMoveHandlers:function(){function t(t,n){var r=30,i=KhanUtil.getDistance(e.scalePoint(t),e.scalePoint(n));return i<r}var e=this.graphie,n=this.points;n[1].onMove=function(r,i){var s=n[1].coord,o=[r,i],u=f(o,l(s)),a=!0,c={};return _.each([0,2],function(r){var i=n[r].coord,s=f(i,u),l=KhanUtil.findAngle(o,s);l*=Math.PI/180,s=e.constrainToBoundsOnAngle(s,10,l),c[r]=s,t(o,s)&&(a=!1)}),a&&_.each(c,function(e,t){n[t].setCoord(e)}),a};var r=this.snapDegrees,i=this.snapOffsetDeg;_.each([0,2],function(s){n[s].onMove=function(s,o){var u=[s,o],a=n[1].coord;if(t(a,u))return!1;if(r){var l=KhanUtil.findAngle(u,a);l=Math.round((l-i)/r)*r+i;var c=KhanUtil.getDistance(u,a);return f(a,e.polar(c,l))}return!0}}),$(n).on("move",function(){this.update(),$(this).trigger("move")}.bind(this))},addHighlightHandlers:function(){var e=this.points[1];e.onHighlight=function(){_.each(this.points,function(e){e.visibleShape.animate(this.highlightStyle,50)},this),_.each(this.rays,function(e){e.visibleLine.animate(this.highlightStyle,50),e.arrowStyle=_.extend({},e.arrowStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke})},this),this.angleStyle=_.extend({},this.angleStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke}),this.update()}.bind(this),e.onUnhighlight=function(){_.each(this.points,function(e){e.visibleShape.animate(this.normalStyle,50)},this),_.each(this.rays,function(e){e.visibleLine.animate(e.normalStyle,50),e.arrowStyle=_.extend({},e.arrowStyle,{color:e.normalStyle.stroke,stroke:e.normalStyle.stroke})},this),this.angleStyle=_.extend({},this.angleStyle,{color:KhanUtil.DYNAMIC,stroke:KhanUtil.DYNAMIC}),this.update()}.bind(this)},_getClockwiseAngle:function(e){var t=(KhanUtil.findAngle(e[2],e[0],e[1])+360)%360;return t},isReflex:function(){return this.reflex},isClockwise:function(){var e=this._getClockwiseAngle(this.coords)>180;return e===this.reflex},getClockwiseCoords:function(){return this.isClockwise()?_.clone(this.coords):_.clone(this.coords).reverse()},update:function(e){var t=this.coords;this.coords=_.pluck(this.points,"coord"),_.invoke(this.points,"updateLineEnds");var n=this._getClockwiseAngle(t),r=this._getClockwiseAngle(this.coords),i=n>180,s=r>180;this.allowReflex&&(e==null&&(e=i!==s&&Math.abs(r-n)<180),e&&(this.reflex=!this.reflex)),_.invoke(this.temp,"remove"),this.temp=this.graphie.labelAngle({point1:this.coords[0],vertex:this.coords[1],point3:this.coords[2],label:this.labeledAngle,text:this.angleLabel,numArcs:this.numArcs,pushOut:this.pushOut,clockwise:this.reflex===s,style:this.angleStyle})},remove:function(){_.invoke(this.rays,"remove"),_.invoke(this.temp,"remove"),this.labeledAngle.remove()}})}),function(){function t(){if(t.is(arguments[0],D)){var e=arguments[0],n=$t[p](t,e.splice(0,3+t.is(e[0],M))),i=n.set();for(var s=0,u=e[x];s<u;s++){var a=e[s]||{};r[o](a.type)&&i[F](n[a.type]().attr(a))}return i}return $t[p](t,arguments)}function ut(){var e=[],t=0;for(;t<32;t++)e[t]=(~~(N.random()*16))[P](16);return e[12]=4,e[16]=(e[16]&3|8)[P](16),"r-"+e[S]("")}function ht(e,t,n){function r(){var i=Array[s].slice.call(arguments,0),u=i[S]("►"),a=r.cache=r.cache||{},f=r.count=r.count||[];return a[o](u)?n?n(a[u]):a[u]:(f[x]>=1e3&&delete a[f.shift()],f[F](u),a[u]=e[p](t,i),n?n(a[u]):a[u])}return r}function mn(){return this.x+g+this.y}function Ln(e){return function(n,r,i,s){var o={back:e};return t.is(i,"function")?s=i:o.rot=i,n&&n.constructor==It&&(n=n.attrs.path),n&&(o.along=n),this.animate(o,r,s)}}function An(e,t,n,r,i,s){function h(e){return((a*e+u)*e+o)*e}function p(e,t){var n=d(e,t);return((c*n+l)*n+f)*n}function d(e,t){var n,r,i,s,f,l;for(i=e,l=0;l<8;l++){s=h(i)-e;if(L(s)<t)return i;f=(3*a*i+2*u)*i+o;if(L(f)<1e-6)break;i-=s/f}n=0,r=1,i=e;if(i<n)return n;if(i>r)return r;while(n<r){s=h(i);if(L(s-e)<t)return i;e>s?n=i:r=i,i=(r-n)/2+n}return i}var o=3*t,u=3*(r-t)-o,a=1-o-u,f=3*n,l=3*(i-n)-f,c=1-f-l;return p(e,1/(200*s))}var e;"".trim?e=function(e,t,n){e.setAttribute(t,String(n).trim())}:e=function(e,t,n){e.setAttribute(t,String(n))},t.version="1.5.2";var n=/[, ]+/,r={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},i=/\{(\d+)\}/g,s="prototype",o="hasOwnProperty",u=document,a=window,f={was:Object[s][o].call(a,"Raphael"),is:a.Raphael},l=function(){this.customAttributes={}},c,h="appendChild",p="apply",d="concat",v="createTouch"in u,m="",g=" ",y=String,b="split",w="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[b](g),E={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},S="join",x="length",T=y[s].toLowerCase,N=Math,C=N.max,k=N.min,L=N.abs,A=N.pow,O=N.PI,M="number",_="string",D="array",P="toString",H="fill",B=Object[s][P],j={},F="push",I=/^url\(['"]?([^\)]+?)['"]?\)$/i,q=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,R={NaN:1,Infinity:1,"-Infinity":1},U=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,z=N.round,W=parseFloat,X=parseInt,V=" progid:DXImageTransform.Microsoft",$=y[s].toUpperCase,J={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},K={along:"along",blur:M,"clip-rect":"csv",cx:M,cy:M,fill:"colour","fill-opacity":M,"font-size":M,height:M,opacity:M,path:"path",r:M,rotation:"csv",rx:M,ry:M,scale:"csv",stroke:"colour","stroke-opacity":M,"stroke-width":M,translation:"csv",width:M,x:M,y:M},Q="replace",G=/^(from|to|\d+%?)$/,Y=/\s*,\s*/,Z={hs:1,rg:1},et=/,?([achlmqrstvxz]),?/gi,tt=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,nt=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,rt=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,it=function(e,t){return e.key-t.key};t.type=a.SVGAngle||u.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML";if(t.type=="VML"){var st=u.createElement("div"),ot;st.innerHTML='<v:shape adj="1"/>',ot=st.firstChild,ot.style.behavior="url(#default#VML)";if(!ot||typeof ot.adj!="object")return t.type=null;st=null}t.svg=!(t.vml=t.type=="VML"),l[s]=t[s],c=l[s],t._id=0,t._oid=0,t.fn={},t.is=function(e,t){return t=T.call(t),t=="finite"?!R[o](+e):t=="null"&&e===null||t==typeof e||t=="object"&&e===Object(e)||t=="array"&&Array.isArray&&Array.isArray(e)||B.call(e).slice(8,-1).toLowerCase()==t},t.angle=function(e,n,r,i,s,o){if(s==null){var u=e-r,a=n-i;return!u&&!a?0:((u<0)*180+N.atan(-a/-u)*180/O+360)%360}return t.angle(e,n,s,o)-t.angle(r,i,s,o)},t.rad=function(e){return e%360*O/180},t.deg=function(e){return e*180/O%360},t.snapTo=function(e,n,r){r=t.is(r,"finite")?r:10;if(t.is(e,D)){var i=e.length;while(i--)if(L(e[i]-n)<=r)return e[i]}else{e=+e;var s=n%e;if(s<r)return n-s;if(s>e-r)return n-s+e}return n},t.setWindow=function(e){a=e,u=a.document};var at=function(e){if(t.vml){var n=/^\s+|\s+$/g,r;try{var i=new ActiveXObject("htmlfile");i.write("<body>"),i.close(),r=i.body}catch(s){r=createPopup().document.body}var o=r.createTextRange();at=ht(function(e){try{r.style.color=y(e)[Q](n,m);var t=o.queryCommandValue("ForeColor");return t=(t&255)<<16|t&65280|(t&16711680)>>>16,"#"+("000000"+t[P](16)).slice(-6)}catch(i){return"none"}})}else{var a=u.createElement("i");a.title="Raphaël Colour Picker",a.style.display="none",u.body[h](a),at=ht(function(e){return a.style.color=e,u.defaultView.getComputedStyle(a,m).getPropertyValue("color")})}return at(e)},ft=function(){return"hsb("+[this.h,this.s,this.b]+")"},lt=function(){return"hsl("+[this.h,this.s,this.l]+")"},ct=function(){return this.hex};t.hsb2rgb=function(e,n,r,i){return t.is(e,"object")&&"h"in e&&"s"in e&&"b"in e&&(r=e.b,n=e.s,e=e.h,i=e.o),t.hsl2rgb(e,n,r/2,i)},t.hsl2rgb=function(e,n,r,i){t.is(e,"object")&&"h"in e&&"s"in e&&"l"in e&&(r=e.l,n=e.s,e=e.h);if(e>1||n>1||r>1)e/=360,n/=100,r/=100;var s={},o=["r","g","b"],u,a,f,l,c,h;if(!n)s={r:r,g:r,b:r};else{r<.5?u=r*(1+n):u=r+n-r*n,a=2*r-u;for(var p=0;p<3;p++)f=e+1/3*-(p-1),f<0&&f++,f>1&&f--,f*6<1?s[o[p]]=a+(u-a)*6*f:f*2<1?s[o[p]]=u:f*3<2?s[o[p]]=a+(u-a)*(2/3-f)*6:s[o[p]]=a}return s.r*=255,s.g*=255,s.b*=255,s.hex="#"+(16777216|s.b|s.g<<8|s.r<<16).toString(16).slice(1),t.is(i,"finite")&&(s.opacity=i),s.toString=ct,s},t.rgb2hsb=function(e,n,r){n==null&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(r=e.b,n=e.g,e=e.r);if(n==null&&t.is(e,_)){var i=t.getRGB(e);e=i.r,n=i.g,r=i.b}if(e>1||n>1||r>1)e/=255,n/=255,r/=255;var s=C(e,n,r),o=k(e,n,r),u,a,f=s;if(o==s)return{h:0,s:0,b:s,toString:ft};var l=s-o;return a=l/s,e==s?u=(n-r)/l:n==s?u=2+(r-e)/l:u=4+(e-n)/l,u/=6,u<0&&u++,u>1&&u--,{h:u,s:a,b:f,toString:ft}},t.rgb2hsl=function(e,n,r){n==null&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(r=e.b,n=e.g,e=e.r);if(n==null&&t.is(e,_)){var i=t.getRGB(e);e=i.r,n=i.g,r=i.b}if(e>1||n>1||r>1)e/=255,n/=255,r/=255;var s=C(e,n,r),o=k(e,n,r),u,a,f=(s+o)/2,l;if(o==s)l={h:0,s:0,l:f};else{var c=s-o;a=f<.5?c/(s+o):c/(2-s-o),e==s?u=(n-r)/c:n==s?u=2+(r-e)/c:u=4+(e-n)/c,u/=6,u<0&&u++,u>1&&u--,l={h:u,s:a,l:f}}return l.toString=lt,l},t._path2string=function(){return this.join(",")[Q](et,"$1")},t.getRGB=ht(function(e){if(!e||!!((e=y(e)).indexOf("-")+1))return{r:-1,g:-1,b:-1,hex:"none",error:1};if(e=="none")return{r:-1,g:-1,b:-1,hex:"none"};!Z[o](e.toLowerCase().substring(0,2))&&e.charAt()!="#"&&(e=at(e));var n,r,i,s,u,a,f,l=e.match(q);return l?(l[2]&&(s=X(l[2].substring(5),16),i=X(l[2].substring(3,5),16),r=X(l[2].substring(1,3),16)),l[3]&&(s=X((a=l[3].charAt(3))+a,16),i=X((a=l[3].charAt(2))+a,16),r=X((a=l[3].charAt(1))+a,16)),l[4]&&(f=l[4][b](Y),r=W(f[0]),f[0].slice(-1)=="%"&&(r*=2.55),i=W(f[1]),f[1].slice(-1)=="%"&&(i*=2.55),s=W(f[2]),f[2].slice(-1)=="%"&&(s*=2.55),l[1].toLowerCase().slice(0,4)=="rgba"&&(u=W(f[3])),f[3]&&f[3].slice(-1)=="%"&&(u/=100)),l[5]?(f=l[5][b](Y),r=W(f[0]),f[0].slice(-1)=="%"&&(r*=2.55),i=W(f[1]),f[1].slice(-1)=="%"&&(i*=2.55),s=W(f[2]),f[2].slice(-1)=="%"&&(s*=2.55),(f[0].slice(-3)=="deg"||f[0].slice(-1)=="°")&&(r/=360),l[1].toLowerCase().slice(0,4)=="hsba"&&(u=W(f[3])),f[3]&&f[3].slice(-1)=="%"&&(u/=100),t.hsb2rgb(r,i,s,u)):l[6]?(f=l[6][b](Y),r=W(f[0]),f[0].slice(-1)=="%"&&(r*=2.55),i=W(f[1]),f[1].slice(-1)=="%"&&(i*=2.55),s=W(f[2]),f[2].slice(-1)=="%"&&(s*=2.55),(f[0].slice(-3)=="deg"||f[0].slice(-1)=="°")&&(r/=360),l[1].toLowerCase().slice(0,4)=="hsla"&&(u=W(f[3])),f[3]&&f[3].slice(-1)=="%"&&(u/=100),t.hsl2rgb(r,i,s,u)):(l={r:r,g:i,b:s},l.hex="#"+(16777216|s|i<<8|r<<16).toString(16).slice(1),t.is(u,"finite")&&(l.opacity=u),l)):{r:-1,g:-1,b:-1,hex:"none",error:1}},t),t.getColor=function(e){var t=this.getColor.start=this.getColor.start||{h:0,s:1,b:e||.75},n=this.hsb2rgb(t.h,t.s,t.b);return t.h+=.075,t.h>1&&(t.h=0,t.s-=.2,t.s<=0&&(this.getColor.start={h:0,s:1,b:t.b})),n.hex},t.getColor.reset=function(){delete this.start},t.parsePathString=ht(function(e){if(!e)return null;var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=[];return t.is(e,D)&&t.is(e[0],D)&&(r=dt(e)),r[x]||y(e)[Q](tt,function(e,t,i){var s=[],o=T.call(t);i[Q](nt,function(e,t){t&&s[F](+t)}),o=="m"&&s[x]>2&&(r[F]([t][d](s.splice(0,2))),o="l",t=t=="m"?"l":"L");while(s[x]>=n[o]){r[F]([t][d](s.splice(0,n[o])));if(!n[o])break}}),r[P]=t._path2string,r}),t.findDotsAtSegment=function(e,t,n,r,i,s,o,u,a){var f=1-a,l=A(f,3)*e+A(f,2)*3*a*n+f*3*a*a*i+A(a,3)*o,c=A(f,3)*t+A(f,2)*3*a*r+f*3*a*a*s+A(a,3)*u,h=e+2*a*(n-e)+a*a*(i-2*n+e),p=t+2*a*(r-t)+a*a*(s-2*r+t),d=n+2*a*(i-n)+a*a*(o-2*i+n),v=r+2*a*(s-r)+a*a*(u-2*s+r),m=(1-a)*e+a*n,g=(1-a)*t+a*r,y=(1-a)*i+a*o,b=(1-a)*s+a*u,w=90-N.atan((h-d)/(p-v))*180/O;return(h>d||p<v)&&(w+=180),{x:l,y:c,m:{x:h,y:p},n:{x:d,y:v},start:{x:m,y:g},end:{x:y,y:b},alpha:w}};var pt=ht(function(e){if(!e)return{x:0,y:0,width:0,height:0};e=St(e);var t=0,n=0,r=[],i=[],s;for(var o=0,u=e[x];o<u;o++){s=e[o];if(s[0]=="M")t=s[1],n=s[2],r[F](t),i[F](n);else{var a=Et(t,n,s[1],s[2],s[3],s[4],s[5],s[6]);r=r[d](a.min.x,a.max.x),i=i[d](a.min.y,a.max.y),t=s[5],n=s[6]}}var f=k[p](0,r),l=k[p](0,i);return{x:f,y:l,width:C[p](0,r)-f,height:C[p](0,i)-l}}),dt=function(e){var n=[];if(!t.is(e,D)||!t.is(e&&e[0],D))e=t.parsePathString(e);for(var r=0,i=e[x];r<i;r++){n[r]=[];for(var s=0,o=e[r][x];s<o;s++)n[r][s]=e[r][s]}return n[P]=t._path2string,n},vt=ht(function(e){if(!t.is(e,D)||!t.is(e&&e[0],D))e=t.parsePathString(e);var n=[],r=0,i=0,s=0,o=0,u=0;e[0][0]=="M"&&(r=e[0][1],i=e[0][2],s=r,o=i,u++,n[F](["M",r,i]));for(var a=u,f=e[x];a<f;a++){var l=n[a]=[],c=e[a];if(c[0]!=T.call(c[0])){l[0]=T.call(c[0]);switch(l[0]){case"a":l[1]=c[1],l[2]=c[2],l[3]=c[3],l[4]=c[4],l[5]=c[5],l[6]=+(c[6]-r).toFixed(3),l[7]=+(c[7]-i).toFixed(3);break;case"v":l[1]=+(c[1]-i).toFixed(3);break;case"m":s=c[1],o=c[2];default:for(var h=1,p=c[x];h<p;h++)l[h]=+(c[h]-(h%2?r:i)).toFixed(3)}}else{l=n[a]=[],c[0]=="m"&&(s=c[1]+r,o=c[2]+i);for(var d=0,v=c[x];d<v;d++)n[a][d]=c[d]}var m=n[a][x];switch(n[a][0]){case"z":r=s,i=o;break;case"h":r+=+n[a][m-1];break;case"v":i+=+n[a][m-1];break;default:r+=+n[a][m-2],i+=+n[a][m-1]}}return n[P]=t._path2string,n},0,dt),mt=ht(function(e){if(!t.is(e,D)||!t.is(e&&e[0],D))e=t.parsePathString(e);var n=[],r=0,i=0,s=0,o=0,u=0;e[0][0]=="M"&&(r=+e[0][1],i=+e[0][2],s=r,o=i,u++,n[0]=["M",r,i]);for(var a=u,f=e[x];a<f;a++){var l=n[a]=[],c=e[a];if(c[0]!=$.call(c[0])){l[0]=$.call(c[0]);switch(l[0]){case"A":l[1]=c[1],l[2]=c[2],l[3]=c[3],l[4]=c[4],l[5]=c[5],l[6]=+(c[6]+r),l[7]=+(c[7]+i);break;case"V":l[1]=+c[1]+i;break;case"H":l[1]=+c[1]+r;break;case"M":s=+c[1]+r,o=+c[2]+i;default:for(var h=1,p=c[x];h<p;h++)l[h]=+c[h]+(h%2?r:i)}}else for(var d=0,v=c[x];d<v;d++)n[a][d]=c[d];switch(l[0]){case"Z":r=s,i=o;break;case"H":r=l[1];break;case"V":i=l[1];break;case"M":s=n[a][n[a][x]-2],o=n[a][n[a][x]-1];default:r=n[a][n[a][x]-2],i=n[a][n[a][x]-1]}}return n[P]=t._path2string,n},null,dt),gt=function(e,t,n,r){return[e,t,n,r,n,r]},yt=function(e,t,n,r,i,s){var o=1/3,u=2/3;return[o*e+u*n,o*t+u*r,o*i+u*n,o*s+u*r,i,s]},bt=function(e,t,n,r,i,s,o,u,a,f){var l=O*120/180,c=O/180*(+i||0),h=[],p,v=ht(function(e,t,n){var r=e*N.cos(n)-t*N.sin(n),i=e*N.sin(n)+t*N.cos(n);return{x:r,y:i}});if(!f){p=v(e,t,-c),e=p.x,t=p.y,p=v(u,a,-c),u=p.x,a=p.y;var m=N.cos(O/180*i),g=N.sin(O/180*i),y=(e-u)/2,w=(t-a)/2,E=y*y/(n*n)+w*w/(r*r);E>1&&(E=N.sqrt(E),n=E*n,r=E*r);var T=n*n,C=r*r,k=(s==o?-1:1)*N.sqrt(L((T*C-T*w*w-C*y*y)/(T*w*w+C*y*y))),A=k*n*w/r+(e+u)/2,M=k*-r*y/n+(t+a)/2,_=N.asin(((t-M)/r).toFixed(9)),D=N.asin(((a-M)/r).toFixed(9));_=e<A?O-_:_,D=u<A?O-D:D,_<0&&(_=O*2+_),D<0&&(D=O*2+D),o&&_>D&&(_-=O*2),!o&&D>_&&(D-=O*2)}else _=f[0],D=f[1],A=f[2],M=f[3];var P=D-_;if(L(P)>l){var H=D,B=u,j=a;D=_+l*(o&&D>_?1:-1),u=A+n*N.cos(D),a=M+r*N.sin(D),h=bt(u,a,n,r,i,0,o,B,j,[D,H,A,M])}P=D-_;var F=N.cos(_),I=N.sin(_),q=N.cos(D),R=N.sin(D),U=N.tan(P/4),z=4/3*n*U,W=4/3*r*U,X=[e,t],V=[e+z*I,t-W*F],$=[u+z*R,a-W*q],J=[u,a];V[0]=2*X[0]-V[0],V[1]=2*X[1]-V[1];if(f)return[V,$,J][d](h);h=[V,$,J][d](h)[S]()[b](",");var K=[];for(var Q=0,G=h[x];Q<G;Q++)K[Q]=Q%2?v(h[Q-1],h[Q],c).y:v(h[Q],h[Q+1],c).x;return K},wt=function(e,t,n,r,i,s,o,u,a){var f=1-a;return{x:A(f,3)*e+A(f,2)*3*a*n+f*3*a*a*i+A(a,3)*o,y:A(f,3)*t+A(f,2)*3*a*r+f*3*a*a*s+A(a,3)*u}},Et=ht(function(e,t,n,r,i,s,o,u){var a=i-2*n+e-(o-2*i+n),f=2*(n-e)-2*(i-n),l=e-n,c=(-f+N.sqrt(f*f-4*a*l))/2/a,h=(-f-N.sqrt(f*f-4*a*l))/2/a,d=[t,u],v=[e,o],m;return L(c)>"1e12"&&(c=.5),L(h)>"1e12"&&(h=.5),c>0&&c<1&&(m=wt(e,t,n,r,i,s,o,u,c),v[F](m.x),d[F](m.y)),h>0&&h<1&&(m=wt(e,t,n,r,i,s,o,u,h),v[F](m.x),d[F](m.y)),a=s-2*r+t-(u-2*s+r),f=2*(r-t)-2*(s-r),l=t-r,c=(-f+N.sqrt(f*f-4*a*l))/2/a,h=(-f-N.sqrt(f*f-4*a*l))/2/a,L(c)>"1e12"&&(c=.5),L(h)>"1e12"&&(h=.5),c>0&&c<1&&(m=wt(e,t,n,r,i,s,o,u,c),v[F](m.x),d[F](m.y)),h>0&&h<1&&(m=wt(e,t,n,r,i,s,o,u,h),v[F](m.x),d[F](m.y)),{min:{x:k[p](0,v),y:k[p](0,d)},max:{x:C[p](0,v),y:C[p](0,d)}}}),St=ht(function(e,t){var n=mt(e),r=t&&mt(t),i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},s={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},o=function(e,t){var n,r;if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null);switch(e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C"][d](bt[p](0,[t.x,t.y][d](e.slice(1))));break;case"S":n=t.x+(t.x-(t.bx||t.x)),r=t.y+(t.y-(t.by||t.y)),e=["C",n,r][d](e.slice(1));break;case"T":t.qx=t.x+(t.x-(t.qx||t.x)),t.qy=t.y+(t.y-(t.qy||t.y)),e=["C"][d](yt(t.x,t.y,t.qx,t.qy,e[1],e[2]));break;case"Q":t.qx=e[1],t.qy=e[2],e=["C"][d](yt(t.x,t.y,e[1],e[2],e[3],e[4]));break;case"L":e=["C"][d](gt(t.x,t.y,e[1],e[2]));break;case"H":e=["C"][d](gt(t.x,t.y,e[1],t.y));break;case"V":e=["C"][d](gt(t.x,t.y,t.x,e[1]));break;case"Z":e=["C"][d](gt(t.x,t.y,t.X,t.Y))}return e},u=function(e,t){if(e[t][x]>7){e[t].shift();var i=e[t];while(i[x])e.splice(t++,0,["C"][d](i.splice(0,6)));e.splice(t,1),l=C(n[x],r&&r[x]||0)}},a=function(e,t,i,s,o){e&&t&&e[o][0]=="M"&&t[o][0]!="M"&&(t.splice(o,0,["M",s.x,s.y]),i.bx=0,i.by=0,i.x=e[o][1],i.y=e[o][2],l=C(n[x],r&&r[x]||0))};for(var f=0,l=C(n[x],r&&r[x]||0);f<l;f++){n[f]=o(n[f],i),u(n,f),r&&(r[f]=o(r[f],s)),r&&u(r,f),a(n,r,i,s,f),a(r,n,s,i,f);var c=n[f],h=r&&r[f],v=c[x],m=r&&h[x];i.x=c[v-2],i.y=c[v-1],i.bx=W(c[v-4])||i.x,i.by=W(c[v-3])||i.y,s.bx=r&&(W(h[m-4])||s.x),s.by=r&&(W(h[m-3])||s.y),s.x=r&&h[m-2],s.y=r&&h[m-1]}return r?[n,r]:n},null,dt),xt=ht(function(e){var n=[];for(var r=0,i=e[x];r<i;r++){var s={},o=e[r].match(/^([^:]*):?([\d\.]*)/);s.color=t.getRGB(o[1]);if(s.color.error)return null;s.color=s.color.hex,o[2]&&(s.offset=o[2]+"%"),n[F](s)}for(r=1,i=n[x]-1;r<i;r++)if(!n[r].offset){var u=W(n[r-1].offset||0),a=0;for(var f=r+1;f<i;f++)if(n[f].offset){a=n[f].offset;break}a||(a=100,f=i),a=W(a);var l=(a-u)/(f-r+1);for(;r<f;r++)u+=l,n[r].offset=u+"%"}return n}),Tt=function(e,n,r,i){var s;if(!t.is(e,_)&&!t.is(e,"object"))return{container:1,x:e,y:n,width:r,height:i};s=t.is(e,_)?u.getElementById(e):e;if(s.tagName)return n==null?{container:s,width:s.style.pixelWidth||s.offsetWidth,height:s.style.pixelHeight||s.offsetHeight}:{container:s,width:n,height:r}},Nt=function(e,t){var n=this;for(var r in t)if(t[o](r)&&!(r in e))switch(typeof t[r]){case"function":(function(t){e[r]=e===n?t:function(){return t[p](n,arguments)}})(t[r]);break;case"object":e[r]=e[r]||{},Nt.call(this,e[r],t[r]);break;default:e[r]=t[r]}},Ct=function(e,t){e==t.top&&(t.top=e.prev),e==t.bottom&&(t.bottom=e.next),e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next)},kt=function(e,t){if(t.top===e)return;Ct(e,t),e.next=null,e.prev=t.top,t.top.next=e,t.top=e},Lt=function(e,t){if(t.bottom===e)return;Ct(e,t),e.next=t.bottom,e.prev=null,t.bottom.prev=e,t.bottom=e},At=function(e,t,n){Ct(e,n),t==n.top&&(n.top=e),t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e},Ot=function(e,t,n){Ct(e,n),t==n.bottom&&(n.bottom=e),t.prev&&(t.prev.next=e),e.prev=t.prev,t.prev=e,e.next=t},Mt=function(e){return function(){throw new Error("Raphaël: you are calling to method “"+e+"” of removed object")}};t.pathToRelative=vt;if(t.svg){c.svgns="http://www.w3.org/2000/svg",c.xlink="http://www.w3.org/1999/xlink",z=function(e){return+e+(~~e===e)*.5};var _t=function(t,n){if(!n)return t=u.createElementNS(c.svgns,t),t.style.webkitTapHighlightColor="rgba(0,0,0,0)",t;for(var r in n)n[o](r)&&e(t,r,y(n[r]))};t[P]=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var Dt=function(e,t){var n=_t("path");t.canvas&&t.canvas[h](n);var r=new It(n,t);return r.type="path",Bt(r,{fill:"none",stroke:"#000",path:e}),r},Pt=function(e,t,n){var r="linear",i=.5,s=.5,o=e.style;t=y(t)[Q](rt,function(e,t,n){r="radial";if(t&&n){i=W(t),s=W(n);var o=(s>.5)*2-1;A(i-.5,2)+A(s-.5,2)>.25&&(s=N.sqrt(.25-A(i-.5,2))*o+.5)&&s!=.5&&(s=s.toFixed(5)-1e-5*o)}return m}),t=t[b](/\s*\-\s*/);if(r=="linear"){var a=t.shift();a=-W(a);if(isNaN(a))return null;var f=[0,0,N.cos(a*O/180),N.sin(a*O/180)],l=1/(C(L(f[2]),L(f[3]))||1);f[2]*=l,f[3]*=l,f[2]<0&&(f[0]=-f[2],f[2]=0),f[3]<0&&(f[1]=-f[3],f[3]=0)}var c=xt(t);if(!c)return null;var p=e.getAttribute(H);p=p.match(/^url\(#(.*)\)$/),p&&n.defs.removeChild(u.getElementById(p[1]));var d=_t(r+"Gradient");d.id=ut(),_t(d,r=="radial"?{fx:i,fy:s}:{x1:f[0],y1:f[1],x2:f[2],y2:f[3]}),n.defs[h](d);for(var v=0,g=c[x];v<g;v++){var w=_t("stop");_t(w,{offset:c[v].offset?c[v].offset:v?"100%":"0%","stop-color":c[v].color||"#fff"}),d[h](w)}return _t(e,{fill:"url(#"+d.id+")",opacity:1,"fill-opacity":1}),o.fill=m,o.opacity=1,o.fillOpacity=1,1},Ht=function(e){var n=e.getBBox();_t(e.pattern,{patternTransform:t.format("translate({0},{1})",n.x,n.y)})},Bt=function(r,i){var s={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},a=r.node,f=r.attrs,l=r.rotate(),c=function(e,t){t=s[T.call(t)];if(t){var n=e.attrs["stroke-width"]||"1",r={round:n,square:n,butt:0}[e.attrs["stroke-linecap"]||i["stroke-linecap"]]||0,o=[],u=t[x];while(u--)o[u]=t[u]*n+(u%2?1:-1)*r;_t(a,{"stroke-dasharray":o[S](",")})}};i[o]("rotation")&&(l=i.rotation);var p=y(l)[b](n);p.length-1?(p[1]=+p[1],p[2]=+p[2]):p=null,W(l)&&r.rotate(0,!0);for(var d in i)if(i[o](d)){if(!J[o](d))continue;var v=i[d];f[d]=v;switch(d){case"blur":r.blur(v);break;case"rotation":r.rotate(v,!0);break;case"href":case"title":case"target":var w=a.parentNode;if(T.call(w.tagName)!="a"){var E=_t("a");w.insertBefore(E,a),E[h](a),w=E}d=="target"&&v=="blank"?w.setAttributeNS(r.paper.xlink,"show","new"):w.setAttributeNS(r.paper.xlink,d,v);break;case"cursor":a.style.cursor=v;break;case"clip-rect":var N=y(v)[b](n);if(N[x]==4){r.clip&&r.clip.parentNode.parentNode.removeChild(r.clip.parentNode);var C=_t("clipPath"),k=_t("rect");C.id=ut(),_t(k,{x:N[0],y:N[1],width:N[2],height:N[3]}),C[h](k),r.paper.defs[h](C),_t(a,{"clip-path":"url(#"+C.id+")"}),r.clip=k}if(!v){var L=u.getElementById(a.getAttribute("clip-path")[Q](/(^url\(#|\)$)/g,m));L&&L.parentNode.removeChild(L),_t(a,{"clip-path":m}),delete r.clip}break;case"path":r.type=="path"&&_t(a,{d:v?f.path=mt(v):"M0,0"});break;case"width":e(a,d,v);if(!f.fx)break;d="x",v=f.x;case"x":f.fx&&(v=-f.x-(f.width||0));case"rx":if(d=="rx"&&r.type=="rect")break;case"cx":p&&(d=="x"||d=="cx")&&(p[1]+=v-f[d]),e(a,d,v),r.pattern&&Ht(r);break;case"height":e(a,d,v);if(!f.fy)break;d="y",v=f.y;case"y":f.fy&&(v=-f.y-(f.height||0));case"ry":if(d=="ry"&&r.type=="rect")break;case"cy":p&&(d=="y"||d=="cy")&&(p[2]+=v-f[d]),e(a,d,v),r.pattern&&Ht(r);break;case"r":r.type=="rect"?_t(a,{rx:v,ry:v}):e(a,d,v);break;case"src":r.type=="image"&&a.setAttributeNS(r.paper.xlink,"href",v);break;case"stroke-width":a.style.strokeWidth=v,e(a,d,v),f["stroke-dasharray"]&&c(r,f["stroke-dasharray"]);break;case"stroke-dasharray":c(r,v);break;case"translation":var A=y(v)[b](n);A[0]=+A[0]||0,A[1]=+A[1]||0,p&&(p[1]+=A[0],p[2]+=A[1]),kn.call(r,A[0],A[1]);break;case"scale":A=y(v)[b](n),r.scale(+A[0]||1,+A[1]||+A[0]||1,isNaN(W(A[2]))?null:+A[2],isNaN(W(A[3]))?null:+A[3]);break;case H:var O=y(v).match(I);if(O){C=_t("pattern");var M=_t("image");C.id=ut(),_t(C,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1}),_t(M,{x:0,y:0}),M.setAttributeNS(r.paper.xlink,"href",O[1]),C[h](M);var _=u.createElement("img");_.style.cssText="position:absolute;left:-9999em;top-9999em",_.onload=function(){_t(C,{width:this.offsetWidth,height:this.offsetHeight}),_t(M,{width:this.offsetWidth,height:this.offsetHeight}),u.body.removeChild(this),r.paper.safari()},u.body[h](_),_.src=O[1],r.paper.defs[h](C),a.style.fill="url(#"+C.id+")",_t(a,{fill:"url(#"+C.id+")"}),r.pattern=C,r.pattern&&Ht(r);break}var D=t.getRGB(v);if(!D.error)delete i.gradient,delete f.gradient,!t.is(f.opacity,"undefined")&&t.is(i.opacity,"undefined")&&_t(a,{opacity:f.opacity}),!t.is(f["fill-opacity"],"undefined")&&t.is(i["fill-opacity"],"undefined")&&_t(a,{"fill-opacity":f["fill-opacity"]});else if(({circle:1,ellipse:1}[o](r.type)||y(v).charAt()!="r")&&Pt(a,v,r.paper)){f.gradient=v,f.fill="none";break}D[o]("opacity")&&_t(a,{"fill-opacity":D.opacity>1?D.opacity/100:D.opacity});case"stroke":D=t.getRGB(v),e(a,d,D.hex),d=="stroke"&&D[o]("opacity")&&_t(a,{"stroke-opacity":D.opacity>1?D.opacity/100:D.opacity});break;case"gradient":((({circle:1,ellipse:1}))[o](r.type)||y(v).charAt()!="r")&&Pt(a,v,r.paper);break;case"opacity":f.gradient&&!f[o]("stroke-opacity")&&_t(a,{"stroke-opacity":v>1?v/100:v});case"fill-opacity":if(f.gradient){var P=u.getElementById(a.getAttribute(H)[Q](/^url\(#|\)$/g,m));if(P){var B=P.getElementsByTagName("stop");e(B[B[x]-1],"stop-opacity",v)}break};default:d=="font-size"&&(v=X(v,10)+"px");var j=d[Q](/(\-.)/g,function(e){return $.call(e.substring(1))});a.style[j]=v,e(a,d,v)}}Ft(r,i),p?r.rotate(p.join(g)):W(l)&&r.rotate(l,!0)},jt=1.2,Ft=function(e,n){if(e.type!="text"||!(n[o]("text")||n[o]("font")||n[o]("font-size")||n[o]("x")||n[o]("y")))return;var r=e.attrs,i=e.node,s=i.firstChild?X(u.defaultView.getComputedStyle(i.firstChild,m).getPropertyValue("font-size"),10):10;if(n[o]("text")){r.text=n.text;while(i.firstChild)i.removeChild(i.firstChild);var a=y(n.text)[b]("\n");for(var f=0,l=a[x];f<l;f++)if(a[f]){var c=_t("tspan");f&&_t(c,{dy:s*jt,x:r.x}),c[h](u.createTextNode(a[f])),i[h](c)}}else{a=i.getElementsByTagName("tspan");for(f=0,l=a[x];f<l;f++)f&&_t(a[f],{dy:s*jt,x:r.x})}_t(i,{y:r.y});var p=e.getBBox(),d=r.y-(p.y+p.height/2);d&&t.is(d,"finite")&&_t(i,{y:r.y+d})},It=function(e,n){var r=0,i=0;this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.paper=n,this.attrs=this.attrs||{},this.transformations=[],this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1},!n.bottom&&(n.bottom=this),this.prev=n.top,n.top&&(n.top.next=this),n.top=this,this.next=null},qt=It[s];It[s].rotate=function(e,r,i){if(this.removed)return this;if(e==null)return this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy][S](g):this._.rt.deg;var s=this.getBBox();return e=y(e)[b](n),e[x]-1&&(r=W(e[1]),i=W(e[2])),e=W(e[0]),r!=null&&r!==!1?this._.rt.deg=e:this._.rt.deg+=e,i==null&&(r=null),this._.rt.cx=r,this._.rt.cy=i,r=r==null?s.x+s.width/2:r,i=i==null?s.y+s.height/2:i,this._.rt.deg?(this.transformations[0]=t.format("rotate({0} {1} {2})",this._.rt.deg,r,i),this.clip&&_t(this.clip,{transform:t.format("rotate({0} {1} {2})",-this._.rt.deg,r,i)})):(this.transformations[0]=m,this.clip&&_t(this.clip,{transform:m})),_t(this.node,{transform:this.transformations[S](g)}),this},It[s].hide=function(){return!this.removed&&(this.node.style.display="none"),this},It[s].show=function(){return!this.removed&&(this.node.style.display=""),this},It[s].remove=function(){if(this.removed)return;Ct(this,this.paper),this.node.parentNode.removeChild(this.node);for(var e in this)delete this[e];this.removed=!0},It[s].getBBox=function(){if(this.removed)return this;if(this.type=="path")return pt(this.attrs.path);if(this.node.style.display=="none"){this.show();var e=!0}var t={};try{t=this.node.getBBox()}catch(n){}finally{t=t||{}}if(this.type=="text"){t={x:t.x,y:Infinity,width:0,height:0};for(var r=0,i=this.node.getNumberOfChars();r<i;r++){var s=this.node.getExtentOfChar(r);s.y<t.y&&(t.y=s.y),s.y+s.height-t.y>t.height&&(t.height=s.y+s.height-t.y),s.x+s.width-t.x>t.width&&(t.width=s.x+s.width-t.x)}}return e&&this.hide(),t},It[s].attr=function(e,n){if(this.removed)return this;if(e==null){var r={};for(var i in this.attrs)this.attrs[o](i)&&(r[i]=this.attrs[i]);return this._.rt.deg&&(r.rotation=this.rotate()),(this._.sx!=1||this._.sy!=1)&&(r.scale=this.scale()),r.gradient&&r.fill=="none"&&(r.fill=r.gradient)&&delete r.gradient,r}if(n==null&&t.is(e,_))return e=="translation"?kn.call(this):e=="rotation"?this.rotate():e=="scale"?this.scale():e==H&&this.attrs.fill=="none"&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(n==null&&t.is(e,D)){var s={};for(var u=0,a=e.length;u<a;u++)s[e[u]]=this.attr(e[u]);return s}if(n!=null){var f={};f[e]=n}else e!=null&&t.is(e,"object")&&(f=e);for(var l in this.paper.customAttributes)if(this.paper.customAttributes[o](l)&&f[o](l)&&t.is(this.paper.customAttributes[l],"function")){var c=this.paper.customAttributes[l].apply(this,[][d](f[l]));this.attrs[l]=f[l];for(var h in c)c[o](h)&&(f[h]=c[h])}return Bt(this,f),this},It[s].toFront=function(){if(this.removed)return this;this.node.parentNode[h](this.node);var e=this.paper;return e.top!=this&&kt(this,e),this},It[s].toBack=function(){if(this.removed)return this;if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild),Lt(this,this.paper);var e=this.paper}return this},It[s].insertAfter=function(e){if(this.removed)return this;var t=e.node||e[e.length-1].node;return t.nextSibling?t.parentNode.insertBefore(this.node,t.nextSibling):t.parentNode[h](this.node),At(this,e,this.paper),this},It[s].insertBefore=function(e){if(this.removed)return this;var t=e.node||e[0].node;return t.parentNode.insertBefore(this.node,t),Ot(this,e,this.paper),this},It[s].blur=function(e){var t=this;if(+e!==0){var n=_t("filter"),r=_t("feGaussianBlur");t.attrs.blur=e,n.id=ut(),_t(r,{stdDeviation:+e||1.5}),n.appendChild(r),t.paper.defs.appendChild(n),t._blur=n,_t(t.node,{filter:"url(#"+n.id+")"})}else t._blur&&(t._blur.parentNode.removeChild(t._blur),delete t._blur,delete t.attrs.blur),t.node.removeAttribute("filter")};var Rt=function(e,t,n,r){var i=_t("circle");e.canvas&&e.canvas[h](i);var s=new It(i,e);return s.attrs={cx:t,cy:n,r:r,fill:"none",stroke:"#000"},s.type="circle",_t(i,s.attrs),s},Ut=function(e,t,n,r,i,s){var o=_t("rect");e.canvas&&e.canvas[h](o);var u=new It(o,e);return u.attrs={x:t,y:n,width:r,height:i,r:s||0,rx:s||0,ry:s||0,fill:"none",stroke:"#000"},u.type="rect",_t(o,u.attrs),u},zt=function(e,t,n,r,i){var s=_t("ellipse");e.canvas&&e.canvas[h](s);var o=new It(s,e);return o.attrs={cx:t,cy:n,rx:r,ry:i,fill:"none",stroke:"#000"},o.type="ellipse",_t(s,o.attrs),o},Wt=function(e,t,n,r,i,s){var o=_t("image");_t(o,{x:n,y:r,width:i,height:s,preserveAspectRatio:"none"}),o.setAttributeNS(e.xlink,"href",t),e.canvas&&e.canvas[h](o);var u=new It(o,e);return u.attrs={x:n,y:r,width:i,height:s,src:t},u.type="image",u},Xt=function(e,t,n,r){var i=_t("text");_t(i,{x:t,y:n,"text-anchor":"middle"}),e.canvas&&e.canvas[h](i);var s=new It(i,e);return s.attrs={x:t,y:n,"text-anchor":"middle",text:r,font:J.font,stroke:"none",fill:"#000"},s.type="text",Bt(s,s.attrs),s},Vt=function(t,n){return this.width=t||this.width,this.height=n||this.height,e(this.canvas,"width",this.width),e(this.canvas,"height",this.height),this},$t=function(){var e=Tt[p](0,arguments),n=e&&e.container,r=e.x,i=e.y,s=e.width,o=e.height;if(!n)throw new Error("SVG container not found.");var a=_t("svg");return r=r||0,i=i||0,s=s||512,o=o||342,_t(a,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:s,height:o}),n==1?(a.style.cssText="position:absolute;left:"+r+"px;top:"+i+"px",u.body[h](a)):n.firstChild?n.insertBefore(a,n.firstChild):n[h](a),n=new l,n.width=s,n.height=o,n.canvas=a,Nt.call(n,n,t.fn),n.clear(),n};c.clear=function(){var e=this.canvas;while(e.firstChild)e.removeChild(e.firstChild);this.bottom=this.top=null,(this.desc=_t("desc"))[h](u.createTextNode("Created with Raphaël")),e[h](this.desc),e[h](this.defs=_t("defs"))},c.remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var e in this)this[e]=Mt(e)}}if(t.vml){var Jt={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},Kt=/([clmz]),?([^clmz]*)/gi,Qt=/ progid:\S+Blur\([^\)]+\)/g,Gt=/-?[^,\s-]+/g,Yt=1e3+g+1e3,Zt=10,en={path:1,rect:1},tn=function(e){var t=/[ahqstv]/ig,n=mt;y(e).match(t)&&(n=St),t=/[clmz]/g;if(n==mt&&!y(e).match(t)){var r=y(e)[Q](Kt,function(e,t,n){var r=[],i=T.call(t)=="m",s=Jt[t];return n[Q](Gt,function(e){i&&r[x]==2&&(s+=r+Jt[t=="m"?"l":"L"],r=[]),r[F](z(e*Zt))}),s+r});return r}var i=n(e),s,o;r=[];for(var u=0,a=i[x];u<a;u++){s=i[u],o=T.call(i[u][0]),o=="z"&&(o="x");for(var f=1,l=s[x];f<l;f++)o+=z(s[f]*Zt)+(f!=l-1?",":m);r[F](o)}return r[S](g)};t[P]=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version},Dt=function(e,t){var n=rn("group");n.style.cssText="position:absolute;left:0;top:0;width:"+t.width+"px;height:"+t.height+"px",n.coordsize=t.coordsize,n.coordorigin=t.coordorigin;var r=rn("shape"),i=r.style;i.width=t.width+"px",i.height=t.height+"px",r.coordsize=Yt,r.coordorigin=t.coordorigin,n[h](r);var s=new It(r,n,t),o={fill:"none",stroke:"#000"};return e&&(o.path=e),s.type="path",s.path=[],s.Path=m,Bt(s,o),t.canvas[h](n),s},Bt=function(e,r){e.attrs=e.attrs||{};var i=e.node,s=e.attrs,a=i.style,f,l=(r.x!=s.x||r.y!=s.y||r.width!=s.width||r.height!=s.height||r.r!=s.r)&&e.type=="rect",c=e;for(var p in r)r[o](p)&&(s[p]=r[p]);l&&(s.path=nn(s.x,s.y,s.width,s.height,s.r),e.X=s.x,e.Y=s.y,e.W=s.width,e.H=s.height),r.href&&(i.href=r.href),r.title&&(i.title=r.title),r.target&&(i.target=r.target),r.cursor&&(a.cursor=r.cursor),"blur"in r&&e.blur(r.blur);if(r.path&&e.type=="path"||l)i.path=tn(s.path);r.rotation!=null&&e.rotate(r.rotation,!0),r.translation&&(f=y(r.translation)[b](n),kn.call(e,f[0],f[1]),e._.rt.cx!=null&&(e._.rt.cx+=+f[0],e._.rt.cy+=+f[1],e.setBox(e.attrs,f[0],f[1]))),r.scale&&(f=y(r.scale)[b](n),e.scale(+f[0]||1,+f[1]||+f[0]||1,+f[2]||null,+f[3]||null));if("clip-rect"in r){var d=y(r["clip-rect"])[b](n);if(d[x]==4){d[2]=+d[2]+ +d[0],d[3]=+d[3]+ +d[1];var v=i.clipRect||u.createElement("div"),g=v.style,w=i.parentNode;g.clip=t.format("rect({1}px {2}px {3}px {0}px)",d),i.clipRect||(g.position="absolute",g.top=0,g.left=0,g.width=e.paper.width+"px",g.height=e.paper.height+"px",w.parentNode.insertBefore(v,w),v[h](w),i.clipRect=v)}r["clip-rect"]||i.clipRect&&(i.clipRect.style.clip=m)}e.type=="image"&&r.src&&(i.src=r.src),e.type=="image"&&r.opacity&&(i.filterOpacity=V+".Alpha(opacity="+r.opacity*100+")",a.filter=(i.filterMatrix||m)+(i.filterOpacity||m)),r.font&&(a.font=r.font),r["font-family"]&&(a.fontFamily='"'+r["font-family"][b](",")[0][Q](/^['"]+|['"]+$/g,m)+'"'),r["font-size"]&&(a.fontSize=r["font-size"]),r["font-weight"]&&(a.fontWeight=r["font-weight"]),r["font-style"]&&(a.fontStyle=r["font-style"]);if(r.opacity!=null||r["stroke-width"]!=null||r.fill!=null||r.stroke!=null||r["stroke-width"]!=null||r["stroke-opacity"]!=null||r["fill-opacity"]!=null||r["stroke-dasharray"]!=null||r["stroke-miterlimit"]!=null||r["stroke-linejoin"]!=null||r["stroke-linecap"]!=null){i=e.shape||i;var E=i.getElementsByTagName(H)&&i.getElementsByTagName(H)[0],S=!1;!E&&(S=E=rn(H));if("fill-opacity"in r||"opacity"in r){var T=((+s["fill-opacity"]+1||2)-1)*((+s.opacity+1||2)-1)*((+t.getRGB(r.fill).o+1||2)-1);T=k(C(T,0),1),E.opacity=T}r.fill&&(E.on=!0);if(E.on==null||r.fill=="none")E.on=!1;if(E.on&&r.fill){var N=r.fill.match(I);N?(E.src=N[1],E.type="tile"):(E.color=t.getRGB(r.fill).hex,E.src=m,E.type="solid",t.getRGB(r.fill).error&&(c.type in{circle:1,ellipse:1}||y(r.fill).charAt()!="r")&&Pt(c,r.fill)&&(s.fill="none",s.gradient=r.fill))}S&&i[h](E);var L=i.getElementsByTagName("stroke")&&i.getElementsByTagName("stroke")[0],A=!1;!L&&(A=L=rn("stroke"));if(r.stroke&&r.stroke!="none"||r["stroke-width"]||r["stroke-opacity"]!=null||r["stroke-dasharray"]||r["stroke-miterlimit"]||r["stroke-linejoin"]||r["stroke-linecap"])L.on=!0;(r.stroke=="none"||L.on==null||r.stroke==0||r["stroke-width"]==0)&&(L.on=!1);var O=t.getRGB(r.stroke);L.on&&r.stroke&&(L.color=O.hex),T=((+s["stroke-opacity"]+1||2)-1)*((+s.opacity+1||2)-1)*((+O.o+1||2)-1);var M=(W(r["stroke-width"])||1)*.75;T=k(C(T,0),1),r["stroke-width"]==null&&(M=s["stroke-width"]),r["stroke-width"]&&(L.weight=M),M&&M<1&&(T*=M)&&(L.weight=1),L.opacity=T,r["stroke-linejoin"]&&(L.joinstyle=r["stroke-linejoin"]||"miter"),L.miterlimit=r["stroke-miterlimit"]||8,r["stroke-linecap"]&&(L.endcap=r["stroke-linecap"]=="butt"?"flat":r["stroke-linecap"]=="square"?"square":"round");if(r["stroke-dasharray"]){var _={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};L.dashstyle=_[o](r["stroke-dasharray"])?_[r["stroke-dasharray"]]:m}A&&i[h](L)}if(c.type=="text"){a=c.paper.span.style,s.font&&(a.font=s.font),s["font-family"]&&(a.fontFamily=s["font-family"]),s["font-size"]&&(a.fontSize=s["font-size"]),s["font-weight"]&&(a.fontWeight=s["font-weight"]),s["font-style"]&&(a.fontStyle=s["font-style"]),c.node.string&&(c.paper.span.innerHTML=y(c.node.string)[Q](/</g,"&#60;")[Q](/&/g,"&#38;")[Q](/\n/g,"<br>")),c.W=s.w=c.paper.span.offsetWidth,c.H=s.h=c.paper.span.offsetHeight,c.X=s.x,c.Y=s.y+z(c.H/2);switch(s["text-anchor"]){case"start":c.node.style["v-text-align"]="left",c.bbx=z(c.W/2);break;case"end":c.node.style["v-text-align"]="right",c.bbx=-z(c.W/2);break;default:c.node.style["v-text-align"]="center"}}},Pt=function(e,t){e.attrs=e.attrs||{};var n=e.attrs,r,i="linear",s=".5 .5";e.attrs.gradient=t,t=y(t)[Q](rt,function(e,t,n){return i="radial",t&&n&&(t=W(t),n=W(n),A(t-.5,2)+A(n-.5,2)>.25&&(n=N.sqrt(.25-A(t-.5,2))*((n>.5)*2-1)+.5),s=t+g+n),m}),t=t[b](/\s*\-\s*/);if(i=="linear"){var o=t.shift();o=-W(o);if(isNaN(o))return null}var u=xt(t);if(!u)return null;e=e.shape||e.node,r=e.getElementsByTagName(H)[0]||rn(H),!r.parentNode&&e.appendChild(r);if(u[x]){r.on=!0,r.method="none",r.color=u[0].color,r.color2=u[u[x]-1].color;var a=[];for(var f=0,l=u[x];f<l;f++)u[f].offset&&a[F](u[f].offset+g+u[f].color);r.colors&&(r.colors.value=a[x]?a[S]():"0% "+r.color),i=="radial"?(r.type="gradientradial",r.focus="100%",r.focussize=s,r.focusposition=s):(r.type="gradient",r.angle=(270-o)%360)}return 1},It=function(e,n,r){var i=0,s=0,o=0,u=1;this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.X=0,this.Y=0,this.attrs={},this.Group=n,this.paper=r,this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1},!r.bottom&&(r.bottom=this),this.prev=r.top,r.top&&(r.top.next=this),r.top=this,this.next=null},qt=It[s],qt.rotate=function(e,t,r){return this.removed?this:e==null?this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy][S](g):this._.rt.deg:(e=y(e)[b](n),e[x]-1&&(t=W(e[1]),r=W(e[2])),e=W(e[0]),t!=null?this._.rt.deg=e:this._.rt.deg+=e,r==null&&(t=null),this._.rt.cx=t,this._.rt.cy=r,this.setBox(this.attrs,t,r),this.Group.style.rotation=this._.rt.deg,this)},qt.setBox=function(e,t,n){if(this.removed)return this;var r=this.Group.style,i=this.shape&&this.shape.style||this.node.style;e=e||{};for(var s in e)e[o](s)&&(this.attrs[s]=e[s]);t=t||this._.rt.cx,n=n||this._.rt.cy;var u=this.attrs,a,f,l,c;switch(this.type){case"circle":a=u.cx-u.r,f=u.cy-u.r,l=c=u.r*2;break;case"ellipse":a=u.cx-u.rx,f=u.cy-u.ry,l=u.rx*2,c=u.ry*2;break;case"image":a=+u.x,f=+u.y,l=u.width||0,c=u.height||0;break;case"text":this.textpath.v=["m",z(u.x),", ",z(u.y-2),"l",z(u.x)+1,", ",z(u.y-2)][S](m),a=u.x-z(this.W/2),f=u.y-this.H/2,l=this.W,c=this.H;break;case"rect":case"path":if(!this.attrs.path)a=0,f=0,l=this.paper.width,c=this.paper.height;else{var h=pt(this.attrs.path);a=h.x,f=h.y,l=h.width,c=h.height}break;default:a=0,f=0,l=this.paper.width,c=this.paper.height}t=t==null?a+l/2:t,n=n==null?f+c/2:n;var p=t-this.paper.width/2,d=n-this.paper.height/2,v;r.left!=(v=p+"px")&&(r.left=v),r.top!=(v=d+"px")&&(r.top=v),this.X=en[o](this.type)?-p:a,this.Y=en[o](this.type)?-d:f,this.W=l,this.H=c,en[o](this.type)?(i.left!=(v=-p*Zt+"px")&&(i.left=v),i.top!=(v=-d*Zt+"px")&&(i.top=v)):this.type=="text"?(i.left!=(v=-p+"px")&&(i.left=v),i.top!=(v=-d+"px")&&(i.top=v)):(r.width!=(v=this.paper.width+"px")&&(r.width=v),r.height!=(v=this.paper.height+"px")&&(r.height=v),i.left!=(v=a-p+"px")&&(i.left=v),i.top!=(v=f-d+"px")&&(i.top=v),i.width!=(v=l+"px")&&(i.width=v),i.height!=(v=c+"px")&&(i.height=v))},qt.hide=function(){return!this.removed&&(this.Group.style.display="none"),this},qt.show=function(){return!this.removed&&(this.Group.style.display="block"),this},qt.getBBox=function(){return this.removed?this:en[o](this.type)?pt(this.attrs.path):{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}},qt.remove=function(){if(this.removed)return;Ct(this,this.paper),this.node.parentNode.removeChild(this.node),this.Group.parentNode.removeChild(this.Group),this.shape&&this.shape.parentNode.removeChild(this.shape);for(var e in this)delete this[e];this.removed=!0},qt.attr=function(e,n){if(this.removed)return this;if(e==null){var r={};for(var i in this.attrs)this.attrs[o](i)&&(r[i]=this.attrs[i]);return this._.rt.deg&&(r.rotation=this.rotate()),(this._.sx!=1||this._.sy!=1)&&(r.scale=this.scale()),r.gradient&&r.fill=="none"&&(r.fill=r.gradient)&&delete r.gradient,r}if(n==null&&t.is(e,"string"))return e=="translation"?kn.call(this):e=="rotation"?this.rotate():e=="scale"?this.scale():e==H&&this.attrs.fill=="none"&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(this.attrs&&n==null&&t.is(e,D)){var s,u={};for(i=0,s=e[x];i<s;i++)u[e[i]]=this.attr(e[i]);return u}var a;n!=null&&(a={},a[e]=n),n==null&&t.is(e,"object")&&(a=e);if(a){for(var f in this.paper.customAttributes)if(this.paper.customAttributes[o](f)&&a[o](f)&&t.is(this.paper.customAttributes[f],"function")){var l=this.paper.customAttributes[f].apply(this,[][d](a[f]));this.attrs[f]=a[f];for(var c in l)l[o](c)&&(a[c]=l[c])}a.text&&this.type=="text"&&(this.node.string=a.text),Bt(this,a),a.gradient&&({circle:1,ellipse:1}[o](this.type)||y(a.gradient).charAt()!="r")&&Pt(this,a.gradient),(!en[o](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this},qt.toFront=function(){return!this.removed&&this.Group.parentNode[h](this.Group),this.paper.top!=this&&kt(this,this.paper),this},qt.toBack=function(){return this.removed?this:(this.Group.parentNode.firstChild!=this.Group&&(this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild),Lt(this,this.paper)),this)},qt.insertAfter=function(e){return this.removed?this:(e.constructor==On&&(e=e[e.length-1]),e.Group.nextSibling?e.Group.parentNode.insertBefore(this.Group,e.Group.nextSibling):e.Group.parentNode[h](this.Group),At(this,e,this.paper),this)},qt.insertBefore=function(e){return this.removed?this:(e.constructor==On&&(e=e[0]),e.Group.parentNode.insertBefore(this.Group,e.Group),Ot(this,e,this.paper),this)},qt.blur=function(e){var n=this.node.runtimeStyle,r=n.filter;r=r.replace(Qt,m),+e!==0?(this.attrs.blur=e,n.filter=r+g+V+".Blur(pixelradius="+(+e||1.5)+")",n.margin=t.format("-{0}px 0 0 -{0}px",z(+e||1.5))):(n.filter=r,n.margin=0,delete this.attrs.blur)},Rt=function(e,t,n,r){var i=rn("group"),s=rn("oval"),o=s.style;i.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",i.coordsize=Yt,i.coordorigin=e.coordorigin,i[h](s);var u=new It(s,i,e);return u.type="circle",Bt(u,{stroke:"#000",fill:"none"}),u.attrs.cx=t,u.attrs.cy=n,u.attrs.r=r,u.setBox({x:t-r,y:n-r,width:r*2,height:r*2}),e.canvas[h](i),u};function nn(e,n,r,i,s){return s?t.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",e+s,n,r-s*2,s,-s,i-s*2,s*2-r,s*2-i):t.format("M{0},{1}l{2},0,0,{3},{4},0z",e,n,r,i,-r)}Ut=function(e,t,n,r,i,s){var o=nn(t,n,r,i,s),u=e.path(o),a=u.attrs;return u.X=a.x=t,u.Y=a.y=n,u.W=a.width=r,u.H=a.height=i,a.r=s,a.path=o,u.type="rect",u},zt=function(e,t,n,r,i){var s=rn("group"),o=rn("oval"),u=o.style;s.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",s.coordsize=Yt,s.coordorigin=e.coordorigin,s[h](o);var a=new It(o,s,e);return a.type="ellipse",Bt(a,{stroke:"#000"}),a.attrs.cx=t,a.attrs.cy=n,a.attrs.rx=r,a.attrs.ry=i,a.setBox({x:t-r,y:n-i,width:r*2,height:i*2}),e.canvas[h](s),a},Wt=function(e,t,n,r,i,s){var o=rn("group"),u=rn("image");o.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",o.coordsize=Yt,o.coordorigin=e.coordorigin,u.src=t,o[h](u);var a=new It(u,o,e);return a.type="image",a.attrs.src=t,a.attrs.x=n,a.attrs.y=r,a.attrs.w=i,a.attrs.h=s,a.setBox({x:n,y:r,width:i,height:s}),e.canvas[h](o),a},Xt=function(e,n,r,i){var s=rn("group"),o=rn("shape"),u=o.style,a=rn("path"),f=a.style,l=rn("textpath");s.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",s.coordsize=Yt,s.coordorigin=e.coordorigin,a.v=t.format("m{0},{1}l{2},{1}",z(n*10),z(r*10),z(n*10)+1),a.textpathok=!0,u.width=e.width,u.height=e.height,l.string=y(i),l.on=!0,o[h](l),o[h](a),s[h](o);var c=new It(l,s,e);return c.shape=o,c.textpath=a,c.type="text",c.attrs.text=i,c.attrs.x=n,c.attrs.y=r,c.attrs.w=1,c.attrs.h=1,Bt(c,{font:J.font,stroke:"none",fill:"#000"}),c.setBox(),e.canvas[h](s),c},Vt=function(e,t){var n=this.canvas.style;return e==+e&&(e+="px"),t==+t&&(t+="px"),n.width=e,n.height=t,n.clip="rect(0 "+e+" "+t+" 0)",this};var rn;u.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!u.namespaces.rvml&&u.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),rn=function(e){return u.createElement("<rvml:"+e+' class="rvml">')}}catch(sn){rn=function(e){return u.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}$t=function(){var e=Tt[p](0,arguments),n=e.container,r=e.height,i,s=e.width,o=e.x,a=e.y;if(!n)throw new Error("VML container not found.");var f=new l,c=f.canvas=u.createElement("div"),d=c.style;return o=o||0,a=a||0,s=s||512,r=r||342,s==+s&&(s+="px"),r==+r&&(r+="px"),f.width=1e3,f.height=1e3,f.coordsize=Zt*1e3+g+Zt*1e3,f.coordorigin="0 0",f.span=u.createElement("span"),f.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",c[h](f.span),d.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",s,r),n==1?(u.body[h](c),d.left=o+"px",d.top=a+"px",d.position="absolute"):n.firstChild?n.insertBefore(c,n.firstChild):n[h](c),Nt.call(f,f,t.fn),f},c.clear=function(){this.canvas.innerHTML=m,this.span=u.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas[h](this.span),this.bottom=this.top=null},c.remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var e in this)this[e]=Mt(e);return!0}}var on=navigator.userAgent.match(/Version\/(.*?)\s/);navigator.vendor=="Apple Computer, Inc."&&(on&&on[1]<4||navigator.platform.slice(0,2)=="iP")?c.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});a.setTimeout(function(){e.remove()})}:c.safari=function(){};var un=function(){this.returnValue=!1},an=function(){return this.originalEvent.preventDefault()},fn=function(){this.cancelBubble=!0},ln=function(){return this.originalEvent.stopPropagation()},cn=function(){if(u.addEventListener)return function(e,t,n,r){var i=v&&E[t]?E[t]:t,s=function(i){if(v&&E[o](t))for(var s=0,u=i.targetTouches&&i.targetTouches.length;s<u;s++)if(i.targetTouches[s].target==e){var a=i;i=i.targetTouches[s],i.originalEvent=a,i.preventDefault=an,i.stopPropagation=ln;break}return n.call(r,i)};return e.addEventListener(i,s,!1),function(){return e.removeEventListener(i,s,!1),!0}};if(u.attachEvent)return function(e,t,n,r){var i=function(e){return e=e||a.event,e.preventDefault=e.preventDefault||un,e.stopPropagation=e.stopPropagation||fn,n.call(r,e)};e.attachEvent("on"+t,i);var s=function(){return e.detachEvent("on"+t,i),!0};return s}}(),hn=[],pn=function(e){var t=e.clientX,n=e.clientY,r=u.documentElement.scrollTop||u.body.scrollTop,i=u.documentElement.scrollLeft||u.body.scrollLeft,s,o=hn.length;while(o--){s=hn[o];if(v){var a=e.touches.length,f;while(a--){f=e.touches[a];if(f.identifier==s.el._drag.id){t=f.clientX,n=f.clientY,(e.originalEvent?e.originalEvent:e).preventDefault();break}}}else e.preventDefault();t+=i,n+=r,s.move&&s.move.call(s.move_scope||s.el,t-s.el._drag.x,n-s.el._drag.y,t,n,e)}},dn=function(e){t.unmousemove(pn).unmouseup(dn);var n=hn.length,r;while(n--)r=hn[n],r.el._drag={},r.end&&r.end.call(r.end_scope||r.start_scope||r.move_scope||r.el,e);hn=[]};for(var vn=w[x];vn--;)(function(e){t[e]=It[s][e]=function(n,r){return t.is(n,"function")&&(this.events=this.events||[],this.events.push({name:e,f:n,unbind:cn(this.shape||this.node||u,e,n,r||this)})),this},t["un"+e]=It[s]["un"+e]=function(t){var n=this.events,r=n[x];while(r--)if(n[r].name==e&&n[r].f==t)return n[r].unbind(),n.splice(r,1),!n.length&&delete this.events,this;return this}})(w[vn]);qt.hover=function(e,t,n,r){return this.mouseover(e,n).mouseout(t,r||n)},qt.unhover=function(e,t){return this.unmouseover(e).unmouseout(t)},qt.drag=function(e,n,r,i,s,o){return this._drag={},this.mousedown(function(a){(a.originalEvent||a).preventDefault();var f=u.documentElement.scrollTop||u.body.scrollTop,l=u.documentElement.scrollLeft||u.body.scrollLeft;this._drag.x=a.clientX+l,this._drag.y=a.clientY+f,this._drag.id=a.identifier,n&&n.call(s||i||this,a.clientX+l,a.clientY+f,a),!hn.length&&t.mousemove(pn).mouseup(dn),hn.push({el:this,move:e,end:r,move_scope:i,start_scope:s,end_scope:o})}),this},qt.undrag=function(e,n,r){var i=hn.length;while(i--)hn[i].el==this&&hn[i].move==e&&hn[i].end==r&&hn.splice(i++,1);!hn.length&&t.unmousemove(pn).unmouseup(dn)},c.circle=function(e,t,n){return Rt(this,e||0,t||0,n||0)},c.rect=function(e,t,n,r,i){return Ut(this,e||0,t||0,n||0,r||0,i||0)},c.ellipse=function(e,t,n,r){return zt(this,e||0,t||0,n||0,r||0)},c.path=function(e){return e&&!t.is(e,_)&&!t.is(e[0],D)&&(e+=m),Dt(t.format[p](t,arguments),this)},c.image=function(e,t,n,r,i){return Wt(this,e||"about:blank",t||0,n||0,r||0,i||0)},c.text=function(e,t,n){return Xt(this,e||0,t||0,y(n))},c.set=function(e){return arguments[x]>1&&(e=Array[s].splice.call(arguments,0,arguments[x])),new On(e)},c.setSize=Vt,c.top=c.bottom=null,c.raphael=t,qt.resetScale=function(){if(this.removed)return this;this._.sx=1,this._.sy=1,this.attrs.scale="1 1"},qt.scale=function(t,n,r,i){if(this.removed)return this;if(t==null&&n==null)return{x:this._.sx,y:this._.sy,toString:mn};n=n||t,!+n&&(n=t);var s,o,u,a,f=this.attrs;if(t!=0){var l=this.getBBox(),c=l.x+l.width/2,h=l.y+l.height/2,p=L(t/this._.sx),v=L(n/this._.sy);r=+r||r==0?r:c,i=+i||i==0?i:h;var y=this._.sx>0,b=this._.sy>0,w=~~(t/L(t)),E=~~(n/L(n)),T=p*w,N=v*E,C=this.node.style,k=r+L(c-r)*T*(c>r==y?1:-1),A=i+L(h-i)*N*(h>i==b?1:-1),O=t*w>n*E?v:p;switch(this.type){case"rect":case"image":var M=f.width*p,_=f.height*v;this.attr({height:_,r:f.r*O,width:M,x:k-M/2,y:A-_/2});break;case"circle":case"ellipse":this.attr({rx:f.rx*p,ry:f.ry*v,r:f.r*O,cx:k,cy:A});break;case"text":this.attr({x:k,y:A});break;case"path":var D=vt(f.path),P=!0,H=y?T:p,B=b?N:v;for(var j=0,F=D[x];j<F;j++){var I=D[j],q=$.call(I[0]);if(q=="M"&&P)continue;P=!1;if(q=="A")I[D[j][x]-2]*=H,I[D[j][x]-1]*=B,I[1]*=p,I[2]*=v,I[5]=+(w+E?!!+I[5]:!+I[5]);else if(q=="H")for(var R=1,U=I[x];R<U;R++)I[R]*=H;else if(q=="V")for(R=1,U=I[x];R<U;R++)I[R]*=B;else for(R=1,U=I[x];R<U;R++)I[R]*=R%2?H:B}var z=pt(D);s=k-z.x-z.width/2,o=A-z.y-z.height/2,D[0][1]+=s,D[0][2]+=o,this.attr({path:D})}this.type in{text:1,image:1}&&(w!=1||E!=1)?this.transformations?(this.transformations[2]="scale("[d](w,",",E,")"),e(this.node,"transform",this.transformations[S](g)),s=w==-1?-f.x-(M||0):f.x,o=E==-1?-f.y-(_||0):f.y,this.attr({x:s,y:o}),f.fx=w-1,f.fy=E-1):(this.node.filterMatrix=V+".Matrix(M11="[d](w,", M12=0, M21=0, M22=",E,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')"),C.filter=(this.node.filterMatrix||m)+(this.node.filterOpacity||m)):this.transformations?(this.transformations[2]=m,e(this.node,"transform",this.transformations[S](g)),f.fx=0,f.fy=0):(this.node.filterMatrix=m,C.filter=(this.node.filterMatrix||m)+(this.node.filterOpacity||m)),f.scale=[t,n,r,i][S](g),this._.sx=t,this._.sy=n}return this},qt.clone=function(){if(this.removed)return null;var e=this.attr();return delete e.scale,delete e.translation,this.paper[this.type]().attr(e)};var gn={},yn=function(e,n,r,i,s,o,u,a,f){if(e===r&&n===i&&s===u&&o==a){var l=u-e,c=a-n,h=Math.sqrt(l*l+c*c);if(f==null)return h;var p=f/h;return{start:{x:e,y:n},m:{x:e,y:n},n:{x:u,y:a},end:{x:u,y:a},x:e+p*l,y:n+p*c,alpha:90-N.atan(l/c)*180/O}}var d=0,v=100,m=[e,n,r,i,s,o,u,a].join(),g=gn[m],y,b;!g&&(gn[m]=g={data:[]}),g.timer&&clearTimeout(g.timer),g.timer=setTimeout(function(){delete gn[m]},2e3);if(f!=null){var w=yn(e,n,r,i,s,o,u,a);v=~~w*10}for(var E=0;E<v+1;E++){g.data[f]>E?b=g.data[E*v]:(b=t.findDotsAtSegment(e,n,r,i,s,o,u,a,E/v),g.data[E]=b),E&&(d+=A(A(y.x-b.x,2)+A(y.y-b.y,2),.5));if(f!=null&&d>=f)return b;y=b}if(f==null)return d},bn=function(e,n){return function(r,i,s){r=St(r);var o,u,a,f,l="",c={},h,p=0;for(var d=0,v=r.length;d<v;d++){a=r[d];if(a[0]=="M")o=+a[1],u=+a[2];else{f=yn(o,u,a[1],a[2],a[3],a[4],a[5],a[6]);if(p+f>i){if(n&&!c.start){h=yn(o,u,a[1],a[2],a[3],a[4],a[5],a[6],i-p),l+=["C",h.start.x,h.start.y,h.m.x,h.m.y,h.x,h.y];if(s)return l;c.start=l,l=["M",h.x,h.y+"C",h.n.x,h.n.y,h.end.x,h.end.y,a[5],a[6]][S](),p+=f,o=+a[5],u=+a[6];continue}if(!e&&!n)return h=yn(o,u,a[1],a[2],a[3],a[4],a[5],a[6],i-p),{x:h.x,y:h.y,alpha:h.alpha}}p+=f,o=+a[5],u=+a[6]}l+=a}return c.end=l,h=e?p:n?c:t.findDotsAtSegment(o,u,a[1],a[2],a[3],a[4],a[5],a[6],1),h.alpha&&(h={x:h.x,y:h.y,alpha:h.alpha}),h}},wn=bn(1),En=bn(),Sn=bn(0,1);qt.getTotalLength=function(){if(this.type!="path")return;return this.node.getTotalLength?this.node.getTotalLength():wn(this.attrs.path)},qt.getPointAtLength=function(e){if(this.type!="path")return;return En(this.attrs.path,e)},qt.getSubpath=function(e,t){if(this.type!="path")return;if(L(this.getTotalLength()-t)<"1e-6")return Sn(this.attrs.path,e).end;var n=Sn(this.attrs.path,t,1);return e?Sn(n,e).end:n},t.easing_formulas={linear:function(e){return e},"<":function(e){return A(e,3)},">":function(e){return A(e-1,3)+1},"<>":function(e){return e*=2,e<1?A(e,3)/2:(e-=2,(A(e,3)+2)/2)},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){e-=1;var t=1.70158;return e*e*((t+1)*e+t)+1},elastic:function(e){if(e==0||e==1)return e;var t=.3,n=t/4;return A(2,-10*e)*N.sin((e-n)*2*O/t)+1},bounce:function(e){var t=7.5625,n=2.75,r;return e<1/n?r=t*e*e:e<2/n?(e-=1.5/n,r=t*e*e+.75):e<2.5/n?(e-=2.25/n,r=t*e*e+.9375):(e-=2.625/n,r=t*e*e+.984375),r}};var xn=[],Tn=function(){var e=+(new Date);for(var n=0;n<xn[x];n++){var r=xn[n];if(r.stop||r.el.removed)continue;var i=e-r.start,s=r.ms,u=r.easing,a=r.from,f=r.diff,l=r.to,c=r.t,h=r.el,p={},d;if(i<s){var v=u(i/s);for(var y in a)if(a[o](y)){switch(K[y]){case"along":d=v*s*f[y],l.back&&(d=l.len-d);var b=En(l[y],d);h.translate(f.sx-f.x||0,f.sy-f.y||0),f.x=b.x,f.y=b.y,h.translate(b.x-f.sx,b.y-f.sy),l.rot&&h.rotate(f.r+b.alpha,b.x,b.y);break;case M:d=+a[y]+v*s*f[y];break;case"colour":d="rgb("+[Cn(z(a[y].r+v*s*f[y].r)),Cn(z(a[y].g+v*s*f[y].g)),Cn(z(a[y].b+v*s*f[y].b))][S](",")+")";break;case"path":d=[];for(var w=0,E=a[y][x];w<E;w++){d[w]=[a[y][w][0]];for(var T=1,N=a[y][w][x];T<N;T++)d[w][T]=+a[y][w][T]+v*s*f[y][w][T];d[w]=d[w][S](g)}d=d[S](g);break;case"csv":switch(y){case"translation":var C=v*s*f[y][0]-c.x,k=v*s*f[y][1]-c.y;c.x+=C,c.y+=k,d=C+g+k;break;case"rotation":d=+a[y][0]+v*s*f[y][0],a[y][1]&&(d+=","+a[y][1]+","+a[y][2]);break;case"scale":d=[+a[y][0]+v*s*f[y][0],+a[y][1]+v*s*f[y][1],2 in l[y]?l[y][2]:m,3 in l[y]?l[y][3]:m][S](g);break;case"clip-rect":d=[],w=4;while(w--)d[w]=+a[y][w]+v*s*f[y][w]}break;default:var L=[].concat(a[y]);d=[],w=h.paper.customAttributes[y].length;while(w--)d[w]=+L[w]+v*s*f[y][w]}p[y]=d}h.attr(p),h._run&&h._run.call(h)}else l.along&&(b=En(l.along,l.len*!l.back),h.translate(f.sx-(f.x||0)+b.x-f.sx,f.sy-(f.y||0)+b.y-f.sy),l.rot&&h.rotate(f.r+b.alpha,b.x,b.y)),(c.x||c.y)&&h.translate(-c.x,-c.y),l.scale&&(l.scale+=m),h.attr(l),xn.splice(n--,1)}t.svg&&h&&h.paper&&h.paper.safari(),xn[x]&&setTimeout(Tn)},Nn=function(e,n,r,i,s){var o=r-i;n.timeouts.push(setTimeout(function(){t.is(s,"function")&&s.call(n),n.animate(e,o,e.easing)},i))},Cn=function(e){return C(k(e,255),0)},kn=function(e,t){if(e==null)return{x:this._.tx,y:this._.ty,toString:mn};this._.tx+=+e,this._.ty+=+t;switch(this.type){case"circle":case"ellipse":this.attr({cx:+e+this.attrs.cx,cy:+t+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+e+this.attrs.x,y:+t+this.attrs.y});break;case"path":var n=vt(this.attrs.path);n[0][1]+=+e,n[0][2]+=+t,this.attr({path:n})}return this};qt.animateWith=function(e,t,n,r,i){for(var s=0,o=xn.length;s<o;s++)xn[s].el.id==e.id&&(t.start=xn[s].start);return this.animate(t,n,r,i)},qt.animateAlong=Ln(),qt.animateAlongBack=Ln(1),qt.onAnimation=function(e){return this._run=e||0,this},qt.animate=function(e,r,i,s){var u=this;u.timeouts=u.timeouts||[];if(t.is(i,"function")||!i)s=i||null;if(u.removed)return s&&s.call(u),u;var a={},f={},l=!1,c={};for(var h in e)if(e[o](h))if(K[o](h)||u.paper.customAttributes[o](h)){l=!0,a[h]=u.attr(h),a[h]==null&&(a[h]=J[h]),f[h]=e[h];switch(K[h]){case"along":var p=wn(e[h]),d=En(e[h],p*!!e.back),v=u.getBBox();c[h]=p/r,c.tx=v.x,c.ty=v.y,c.sx=d.x,c.sy=d.y,f.rot=e.rot,f.back=e.back,f.len=p,e.rot&&(c.r=W(u.rotate())||0);break;case M:c[h]=(f[h]-a[h])/r;break;case"colour":a[h]=t.getRGB(a[h]);var m=t.getRGB(f[h]);c[h]={r:(m.r-a[h].r)/r,g:(m.g-a[h].g)/r,b:(m.b-a[h].b)/r};break;case"path":var g=St(a[h],f[h]);a[h]=g[0];var w=g[1];c[h]=[];for(var E=0,S=a[h][x];E<S;E++){c[h][E]=[0];for(var T=1,N=a[h][E][x];T<N;T++)c[h][E][T]=(w[E][T]-a[h][E][T])/r}break;case"csv":var C=y(e[h])[b](n),k=y(a[h])[b](n);switch(h){case"translation":a[h]=[0,0],c[h]=[C[0]/r,C[1]/r];break;case"rotation":a[h]=k[1]==C[1]&&k[2]==C[2]?k:[0,C[1],C[2]],c[h]=[(C[0]-a[h][0])/r,0,0];break;case"scale":e[h]=C,a[h]=y(a[h])[b](n),c[h]=[(C[0]-a[h][0])/r,(C[1]-a[h][1])/r,0,0];break;case"clip-rect":a[h]=y(a[h])[b](n),c[h]=[],E=4;while(E--)c[h][E]=(C[E]-a[h][E])/r}f[h]=C;break;default:C=[].concat(e[h]),k=[].concat(a[h]),c[h]=[],E=u.paper.customAttributes[h][x];while(E--)c[h][E]=((C[E]||0)-(k[E]||0))/r}}if(!l){var L=[],A;for(var O in e)e[o](O)&&G.test(O)&&(h={value:e[O]},O=="from"&&(O=0),O=="to"&&(O=100),h.key=X(O,10),L.push(h));L.sort(it),L[0].key&&L.unshift({key:0,value:u.attrs});for(E=0,S=L[x];E<S;E++)Nn(L[E].value,u,r/100*L[E].key,r/100*(L[E-1]&&L[E-1].key||0),L[E-1]&&L[E-1].value.callback);A=L[L[x]-1].value.callback,A&&u.timeouts.push(setTimeout(function(){A.call(u)},r))}else{var _=t.easing_formulas[i];if(!_){_=y(i).match(U);if(_&&_[x]==5){var D=_;_=function(e){return An(e,+D[1],+D[2],+D[3],+D[4],r)}}else _=function(e){return e}}xn.push({start:e.start||+(new Date),ms:r,easing:_,from:a,diff:c,to:f,el:u,t:{x:0,y:0}}),t.is(s,"function")&&(u._ac=setTimeout(function(){s.call(u)},r)),xn[x]==1&&setTimeout(Tn)}return this},qt.stop=function(){for(var e=0;e<xn.length;e++)xn[e].el.id==this.id&&xn.splice(e--,1);for(e=0,ii=this.timeouts&&this.timeouts.length;e<ii;e++)clearTimeout(this.timeouts[e]);return this.timeouts=[],clearTimeout(this._ac),delete this._ac,this},qt.translate=function(e,t){return this.attr({translation:e+" "+t})},qt[P]=function(){return"Raphaël’s object"},t.ae=xn;var On=function(e){this.items=[],this[x]=0,this.type="set";if(e)for(var t=0,n=e[x];t<n;t++)e[t]&&(e[t].constructor==It||e[t].constructor==On)&&(this[this.items[x]]=this.items[this.items[x]]=e[t],this[x]++)};On[s][F]=function(){var e,t;for(var n=0,r=arguments[x];n<r;n++)e=arguments[n],e&&(e.constructor==It||e.constructor==On)&&(t=this.items[x],this[t]=this.items[t]=e,this[x]++);return this},On[s].pop=function(){return delete this[this[x]--],this.items.pop()};for(var Mn in qt)qt[o](Mn)&&(On[s][Mn]=function(e){return function(){for(var t=0,n=this.items[x];t<n;t++)this.items[t][e][p](this.items[t],arguments);return this}}(Mn));On[s].attr=function(e,n){if(e&&t.is(e,D)&&t.is(e[0],"object"))for(var r=0,i=e[x];r<i;r++)this.items[r].attr(e[r]);else for(var s=0,o=this.items[x];s<o;s++)this.items[s].attr(e,n);return this},On[s].animate=function(e,n,r,i){(t.is(r,"function")||!r)&&(i=r||null);var s=this.items[x],o=s,u,a=this,f;i&&(f=function(){!--s&&i.call(a)}),r=t.is(r,_)?r:f,u=this.items[--o].animate(e,n,r,f);while(o--)this.items[o]&&!this.items[o].removed&&this.items[o].animateWith(u,e,n,r,f);return this},On[s].insertAfter=function(e){var t=this.items[x];while(t--)this.items[t].insertAfter(e);return this},On[s].getBBox=function(){var e=[],t=[],n=[],r=[];for(var i=this.items[x];i--;){var s=this.items[i].getBBox();e[F](s.x),t[F](s.y),n[F](s.x+s.width),r[F](s.y+s.height)}return e=k[p](0,e),t=k[p](0,t),{x:e,y:t,width:C[p](0,n)-e,height:C[p](0,r)-t}},On[s].clone=function(e){e=new On;for(var t=0,n=this.items[x];t<n;t++)e[F](this.items[t].clone());return e},t.registerFont=function(e){if(!e.face)return e;this.fonts=this.fonts||{};var t={w:e.w,face:{},glyphs:{}},n=e.face["font-family"];for(var r in e.face)e.face[o](r)&&(t.face[r]=e.face[r]);this.fonts[n]?this.fonts[n][F](t):this.fonts[n]=[t];if(!e.svg){t.face["units-per-em"]=X(e.face["units-per-em"],10);for(var i in e.glyphs)if(e.glyphs[o](i)){var s=e.glyphs[i];t.glyphs[i]={w:s.w,k:{},d:s.d&&"M"+s.d[Q](/[mlcxtrv]/g,function(e){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[e]||"M"})+"z"};if(s.k)for(var u in s.k)s[o](u)&&(t.glyphs[i].k[u]=s.k[u])}}return e},c.getFont=function(e,n,r,i){i=i||"normal",r=r||"normal",n=+n||{normal:400,bold:700,lighter:300,bolder:800}[n]||400;if(!t.fonts)return;var s=t.fonts[e];if(!s){var u=new RegExp("(^|\\s)"+e[Q](/[^\w\d\s+!~.:_-]/g,m)+"(\\s|$)","i");for(var a in t.fonts)if(t.fonts[o](a)&&u.test(a)){s=t.fonts[a];break}}var f;if(s)for(var l=0,c=s[x];l<c;l++){f=s[l];if(f.face["font-weight"]==n&&(f.face["font-style"]==r||!f.face["font-style"])&&f.face["font-stretch"]==i)break}return f},c.print=function(e,r,i,s,o,u,a){u=u||"middle",a=C(k(a||0,1),-1);var f=this.set(),l=y(i)[b](m),c=0,h=m,p;t.is(s,i)&&(s=this.getFont(s));if(s){p=(o||16)/s.face["units-per-em"];var d=s.face.bbox.split(n),v=+d[0],g=+d[1]+(u=="baseline"?d[3]-d[1]+ +s.face.descent:(d[3]-d[1])/2);for(var w=0,E=l[x];w<E;w++){var S=w&&s.glyphs[l[w-1]]||{},T=s.glyphs[l[w]];c+=w?(S.w||s.w)+(S.k&&S.k[l[w]]||0)+s.w*a:0,T&&T.d&&f[F](this.path(T.d).attr({fill:"#000",stroke:"none",translation:[c,0]}))}f.scale(p,p,v,g).translate(e-v,r-g)}return f},t.format=function(e,n){var r=t.is(n,D)?[0][d](n):arguments;return e&&t.is(e,_)&&r[x]-1&&(e=e[Q](i,function(e,t){return r[++t]==null?m:r[t]})),e||m},t.ninja=function(){return f.was?a.Raphael=f.is:delete Raphael,t},t.el=qt,t.st=On[s],f.was?a.Raphael=t:Raphael=t}(),define("../perseus/ke/third_party/raphael.js",function(){}),define("../perseus/ke/utils/math.js",["require","../third_party/raphael.js","./knumber.js"],function(e){e("../third_party/raphael.js");var t=e("./knumber.js");$.extend(KhanUtil,{cleanMath:function(e){return typeof e=="string"?e.replace(/\+\s*-/g,"- ").replace(/-\s*-/g,"+ ").replace(/\^1/g,""):e},rand:function(e){return Math.floor(e*KhanUtil.random())},digits:function(e){if(e===0)return[0];var t=[];while(e>0)t.push(e%10),e=Math.floor(e/10);return t},integerToDigits:function(e){return KhanUtil.digits(e).reverse()},decimalDigits:function(e){var t=""+Math.abs(e);t=t.replace(".","");var n=[];for(var r=t.length;r>0;r--)n.push(t.charAt(r-1));return n},decimalPlaces:function(e){var t=""+Math.abs(e);return t=t.split("."),t.length===1?0:t[1].length},digitsToInteger:function(e){var t=Math.floor(Math.pow(10,e.length-1)),n=0;return $.each(e,function(e,r){n+=r*t,t/=10}),n},padDigitsToNum:function(e,t){e=e.slice(0);while(e.length<t)e.push(0);return e},placesLeftOfDecimal:[$._("one"),$._("ten"),$._("hundred"),$._("thousand")],placesRightOfDecimal:[$._("one"),$._("tenth"),$._("hundredth"),$._("thousandth"),$._("ten thousandth")],powerToPlace:function(e){return e<0?KhanUtil.placesRightOfDecimal[-1*e]:KhanUtil.placesLeftOfDecimal[e]},roundTowardsZero:function(e){return e<0?Math.ceil(e-.001):Math.floor(e+.001)},bound:function(e){return e===0?e:e<0?-KhanUtil.bound(-e):Math.max(1e-6,Math.min(e,1e20))},factorial:function(e){return e<=1?e:e*KhanUtil.factorial(e-1)},getGCD:function(e,t){if(arguments.length>2){var n=[].slice.call(arguments,1);return KhanUtil.getGCD(e,KhanUtil.getGCD.apply(KhanUtil,n))}var r;e=Math.abs(e),t=Math.abs(t);while(t)r=e%t,e=t,t=r;return e},getLCM:function(e,t){if(arguments.length>2){var n=[].slice.call(arguments,1);return KhanUtil.getLCM(e,KhanUtil.getLCM.apply(KhanUtil,n))}return Math.abs(e*t)/KhanUtil.getGCD(e,t)},primes:[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97],denominators:[2,3,4,5,6,8,10,12,100],smallDenominators:[2,3,4,5,6,8,10,12],getPrime:function(){return KhanUtil.primes[KhanUtil.rand(KhanUtil.primes.length)]},isPrime:function(e){if(e<=1)return!1;if(e<101)return!!$.grep(KhanUtil.primes,function(t,n){return Math.abs(t-e)<=.5}).length;if(e<=1||e>2&&e%2===0)return!1;for(var t=3,n=Math.sqrt(e);t<=n;t+=2)if(e%t===0)return!1;return!0},isOdd:function(e){return e%2===1},isEven:function(e){return e%2===0},getOddComposite:function(e,t){e===undefined&&(e=0),t===undefined&&(t=100);var n=[9,15,21,25,27,33,35,39,45,49,51,55];n=n.concat([57,63,65,69,75,77,81,85,87,91,93,95,99]);var r=-1;while(r<e||r>t)r=n[KhanUtil.rand(n.length)];return r},getEvenComposite:function(e,t){e===undefined&&(e=0),t===undefined&&(t=100);var n=[4,6,8,10,12,14,16,18,20,22,24,26];n=n.concat([28,30,32,34,36,38,40,42,44,46,48]),n=n.concat([50,52,54,56,58,60,62,64,66,68,70,72]),n=n.concat([74,76,78,80,82,84,86,88,90,92,94,96,98]);var r=-1;while(r<e||r>t)r=n[KhanUtil.rand(n.length)];return r},getComposite:function(){return KhanUtil.randRange(0,1)?KhanUtil.getEvenComposite():KhanUtil.getOddComposite()},getPrimeFactorization:function(e){if(e===1)return[];if(KhanUtil.isPrime(e))return[e];var t=Math.sqrt(e);for(var n=2;n<=t;n++)if(e%n===0)return $.merge(KhanUtil.getPrimeFactorization(n),KhanUtil.getPrimeFactorization(e/n))},getFactors:function(e){var t=[],n=function(e){_(t).indexOf(e)===-1&&t.push(e)},r=e;for(var i=1;i*i<=r;i++)e%i===0&&(n(i),n(e/i));return KhanUtil.sortNumbers(t)},getNontrivialFactor:function(e){var t=KhanUtil.getFactors(e);return t[KhanUtil.randRange(1,t.length-2)]},getMultiples:function(e,t){var n=[];for(var r=1;r*e<=t;r++)n.push(r*e);return n},splitRadical:function(e){if(e===0)return[0,1];var t=1,n=e;for(var r=2;r*r<=e;r++)while(n%(r*r)===0)n/=r*r,t*=r;return[t,n]},splitCube:function(e){if(e===0)return[0,1];var t=1,n=e;for(var r=2;r*r*r<=e;r++)while(n%(r*r*r)===0)n/=r*r*r,t*=r;return[t,n]},randRange:function(e,t){var n=[].slice.call(arguments,2);if(n.length===0)return Math.floor(KhanUtil.rand(t-e+1))+e;var r=[e,t].concat(n.slice(1));return $.map(new Array(n[0]),function(){return[KhanUtil.randRange.apply(null,r)]})},randRangeUnique:function(e,t,n){if(n==null)return KhanUtil.randRange(e,t);var r=[];for(var i=e;i<=t;i++)r.push(i);return KhanUtil.shuffle(r,n)},randRangeUniqueNonZero:function(e,t,n){if(n==null)return KhanUtil.randRangeNonZero(e,t);var r=[];for(var i=e;i<=t;i++){if(i===0)continue;r.push(i)}return KhanUtil.shuffle(r,n)},randRangeWeighted:function(e,t,n,r){return KhanUtil.random()<r||n===e&&n===t?n:KhanUtil.randRangeExclude(e,t,[n])},randRangeExclude:function(e,t,n){var r;do r=KhanUtil.randRange(e,t);while(_(n).indexOf(r)!==-1);return r},randRangeWeightedExclude:function(e,t,n,r,i){var s;do s=KhanUtil.randRangeWeighted(e,t,n,r);while(_(i).indexOf(s)!==-1);return s},randRangeNonZero:function(e,t){return KhanUtil.randRangeExclude(e,t,[0])},randFromArray:function(e,t){return t==null?e[KhanUtil.rand(e.length)]:$.map(new Array(t),function(){return KhanUtil.randFromArray(e)})},randFromArrayExclude:function(e,t){var n=[];for(var r=0;r<e.length;r++)_(t).indexOf(e[r])===-1&&n.push(e[r]);return KhanUtil.randFromArray(n)},roundToNearest:function(e,t){return Math.round(t/e)*e},roundTo:function(e,t){var n=Math.pow(10,e).toFixed(5);return Math.round((t*n).toFixed(5))/n},toFixedApprox:function(e,n){var r=e.toFixed(n);return t.equal(+r,e)?r:"\\approx "+r},roundToApprox:function(e,n){var r=KhanUtil.roundTo(n,e);return t.equal(r,e)?String(r):KhanUtil.toFixedApprox(e,n)},floorTo:function(e,t){var n=Math.pow(10,e).toFixed(5);return Math.floor((t*n).toFixed(5))/n},ceilTo:function(e,t){var n=Math.pow(10,e).toFixed(5);return Math.ceil((t*n).toFixed(5))/n},toFraction:function(e,t){t==null&&(t=Math.pow(2,-46));if(e<0||e>1){var n=e%1;n+=n<0?1:0;var r=KhanUtil.toFraction(n,t);return r[0]+=Math.round(e-n)*r[1],r}if(Math.abs(Math.round(Number(e))-e)<=t)return[Math.round(e),1];var i=0,s=1,o=1,u=1,a=1,f=2;for(;;){if(Math.abs(Number(a/f)-e)<=t)return[a,f];a/f<e?(i=a,s=f):(o=a,u=f),a=i+o,f=s+u}},getNumericFormat:function(e){e=$.trim(e),e=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1");if(e.match(/^[+-]?\d+$/))return"integer";if(e.match(/^[+-]?\d+\s+\d+\s*\/\s*\d+$/))return"mixed";var t=e.match(/^[+-]?(\d+)\s*\/\s*(\d+)$/);return t?parseFloat(t[1])>parseFloat(t[2])?"improper":"proper":e.replace(/[,. ]/g,"").match(/^\d+$/)?"decimal":e.match(/(pi?|\u03c0|t(?:au)?|\u03c4|pau)/)?"pi":null},toNumericString:function(e,n){if(e==null)return"";if(e===0)return"0";if(n==="percent")return e*100+"%";if(n==="pi"){var r=t.toFraction(e/Math.PI),i=Math.abs(r[0]),s=r[1];if(t.isInteger(i)){var o=e<0?"-":"",u="π";return o+(i===1?"":i)+u+(s===1?"":"/"+s)}}if(_(["proper","improper","mixed","fraction"]).contains(n)){var r=t.toFraction(e),i=Math.abs(r[0]),s=r[1],o=e<0?"-":"";if(s===1)return o+i;if(n==="mixed"){var a=i%s,f=(i-a)/s;return o+(f?f+" ":"")+a+"/"+s}return o+i+"/"+s}return String(e)},shuffle:function(e,t){e=[].slice.call(e,0);var n=typeof t=="undefined"||t>e.length?0:e.length-t;for(var r=e.length;r>n;r--){var i=Math.floor(KhanUtil.random()*r),s=e[i];e[i]=e[r-1],e[r-1]=s}return e.slice(n)},sortNumbers:function(e){return e.slice(0).sort(function(e,t){return e-t})},truncate_to_max:function(e,t){return parseFloat(e.toFixed(t))},isInt:function(e){return parseFloat(e)===parseInt(e,10)&&!isNaN(e)},colorMarkup:function(e,t){return"\\color{"+t+"}{"+e+"}"},contains:function(e,t){return _.any(e,function(e){return _.isEqual(t,e)?!0:!1})},BLUE:"#6495ED",ORANGE:"#FFA500",PINK:"#FF00AF",GREEN:"#28AE7B",PURPLE:"#9D38BD",RED:"#DF0030",GRAY:"gray",BLACK:"black",LIGHT_BLUE:"#9AB8ED",LIGHT_ORANGE:"#EDD19B",LIGHT_PINK:"#ED9BD3",LIGHT_GREEN:"#9BEDCE",LIGHT_PURPLE:"#DA9BED",LIGHT_RED:"#ED9AAC",LIGHT_GRAY:"#ED9B9B",LIGHT_BLACK:"#ED9B9B",GRAY10:"#D6D6D6",GRAY20:"#CDCDCD",GRAY30:"#B3B3B3",GRAY40:"#9A9A9A",GRAY50:"#808080",GRAY60:"#666666",GRAY70:"#4D4D4D",GRAY80:"#333333",GRAY90:"#1A1A1A",_BACKGROUND:"#FDFDFD"}),$.extend(KhanUtil,{INTERACTING:KhanUtil.ORANGE,INTERACTIVE:KhanUtil.ORANGE,DYNAMIC:KhanUtil.BLUE})}),define("../perseus/ke-deps",["require","./ke/utils/answer-types.js","./ke/utils/graphie.js","./ke/utils/interactive.js","./ke/utils/math.js"],function(e){e("./ke/utils/answer-types.js"),e("./ke/utils/graphie.js"),e("./ke/utils/interactive.js"),e("./ke/utils/math.js")}),function(t,n){typeof exports=="object"&&typeof module=="object"?module.exports=n():typeof define=="function"&&define.amd?define("../perseus/build/perseus-3",n):typeof exports=="object"?exports.Perseus=n():t.Perseus=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,t,n){n(1);var r=n(50);e.exports={apiVersion:r.apiVersion,itemDataVersion:r.itemDataVersion,itemVersion:n(2),init:n(3),renderability:n(6),accessibility:n(4),AnswerAreaRenderer:n(7),ArticleEditor:n(8),ArticleRenderer:n(9),Editor:n(10),EditorPage:n(11),ItemRenderer:n(12),HintsRenderer:n(13),Renderer:n(14),RevisionDiff:n(17),StatefulEditorPage:n(15),ClassNames:n(16).ClassNames,Util:n(5)}},function(e,t,n){var r=n(62),i=n(18);r.each([n(19),n(20),n(21),n(22),n(23),n(24),n(25),n(26),n(27),n(28),n(29),n(30),n(31),n(32),n(33),n(34),n(35),n(36),n(37),n(38),n(39),n(40),n(41),n(42),n(43),n(44),n(45),n(46),n(47),n(48),n(49)],function(e){i.register(e.name,e)})},function(e,t,n){n(1);var r=n(50),i=n(18),s=_.clone(i.getVersionVector());s["::renderer::"]=r.itemDataVersion,e.exports=s},function(e,t,n){var r=n(62),i=function(e){r.defaults(e,{skipMathJax:!1});var t=$.Deferred();return e.skipMathJax?t.resolve():(MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:"none","HTML-CSS":{availableFonts:["TeX"],imageFont:null,scale:100,showMathMenu:!1}}),MathJax.Hub.Configured(),MathJax.Hub.Queue(t.resolve)),t};e.exports=i},function(e,t,n){var r=n(62),i=n(51),s=n(18);e.exports={violatingWidgets:function(e){var t=[];return i.traverseRendererDeep(e.question,function(e){e.type&&!s.isAccessible(e)&&t.push(e.type)}),r.uniq(t)}}},function(e,t,n){var r=n(62),i=function(e,t,n){return r.isArray(e)?r.map(e,function(e){return i(e,t)}):t.call(n,e)},s={nestedMap:i,rWidgetParts:/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]$/,rWidgetRule:/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/,rTypeFromWidgetId:/^([a-z-]+) ([0-9]+)$/,snowman:"☃",noScore:{type:"points",earned:0,total:0,message:null},seededRNG:function(e){var t=e;return function(){var e=t;return e=e+2127912214+(e<<12)&4294967295,e=(e^3345072700^e>>>19)&4294967295,e=e+374761393+(e<<5)&4294967295,e=(e+3550635116^e<<9)&4294967295,e=e+4251993797+(e<<3)&4294967295,e=(e^3042594569^e>>>16)&4294967295,(t=e&268435455)/268435456}},shuffle:function(e,t,n){var i=r.clone(e);if(!i.length||r.all(i,function(e){return r.isEqual(e,i[0])}))return i;var o;r.isFunction(t)?o=t:o=s.seededRNG(t);do for(var u=i.length;u>0;u--){var a=Math.floor(o()*u),f=i[a];i[a]=i[u-1],i[u-1]=f}while(n&&r.isEqual(e,i));return i},split:"x".split(/(.)/g).length?function(e,t){return e.split(t)}:function(e,t){var n=[],r=t.lastIndex=0,i;while(i=t.exec(e))n.push(e.slice(r,i.index)),n.push.apply(n,i.slice(1)),r=i.index+i[0].length;return n.push(e.slice(r)),n},combineScores:function(e,t){var n;if(e.type==="points"&&t.type==="points")return e.message&&t.message&&e.message!==t.message?n=null:n=e.message||t.message,{type:"points",earned:e.earned+t.earned,total:e.total+t.total,message:n};if(e.type==="points"&&t.type==="invalid")return t;if(e.type==="invalid"&&t.type==="points")return e;if(e.type==="invalid"&&t.type==="invalid")return e.message&&t.message&&e.message!==t.message?n=null:n=e.message||t.message,{type:"invalid",message:n}},keScoreFromPerseusScore:function(e,t){if(e.type==="points")return{empty:!1,correct:e.earned>=e.total,message:e.message,guess:t};if(e.type==="invalid")return{empty:!0,correct:!1,message:e.message,guess:t};throw new Error("Invalid score type: "+e.type)},firstNumericalParse:function(e){var t,n=Khan.answerTypes.predicate.createValidatorFunctional(function(e){return t=e,!0},{simplify:"optional",inexact:!0,forms:"integer, proper, improper, pi, log, mixed, decimal"});return n(e),t},stringArrayOfSize:function(e){return r(e).times(function(){return""})},gridDimensionConfig:function(e,t,n,r){var i=s.scaleFromExtent(t,n),o=e*i,u=o>30;return{scale:i,tickStep:e/r,unityLabel:u}},getGridStep:function(e,t,n){return r(2).times(function(r){var i=s.scaleFromExtent(e[r],n),o=s.gridStepFromTickStep(t[r],i);return o})},snapStepFromGridStep:function(e){return r.map(e,function(e){return e/2})},scaleFromExtent:function(e,t){var n=e[1]-e[0],r=t/n;return r},tickStepFromExtent:function(e,t){var n=e[1]-e[0],r;15<n&&n<=20?r=23:n>100||n<5?r=10:r=16;var i=t/500,o=r*i;return s.tickStepFromNumTicks(n,o)},gridStepFromTickStep:function(e,t){var n=e*t,r=e,i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),s=Math.floor(r/i);if(n<25)return e;if(n<50)return s===5?e:e/2;if(s===1)return e/2;if(s===2)return e/4;if(s===5)return e/5},tickStepFromNumTicks:function(e,t){var n=Math.pow(10,Math.floor(Math.log(e/t)/Math.LN10)),r=t/e*n;return r<=.15?n*=10:r<=.35?n*=5:r<=.75&&(n*=2),n},DeprecationMixin:{componentWillMount:function(){var e={};r.each(this.deprecatedProps,function(t,n){r.has(this.props,n)&&r.extend(e,t(this.props))},this),r.isEmpty(e)||(r.extend(this.props,e),setTimeout(this.props.onChange,0,e))}},eq:function(e,t){return r.isNumber(e)&&r.isNumber(t)?Math.abs(e-t)<1e-9:e===t},deepEq:function(e,t){if(r.isArray(e)&&r.isArray(t)){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!s.deepEq(e[n],t[n]))return!1;return!0}return r.isArray(e)||r.isArray(t)?!1:r.isFunction(e)&&r.isFunction(t)?s.eq(e,t):r.isFunction(e)||r.isFunction(t)?!1:r.isObject(e)&&r.isObject(t)?e===t||r.all(e,function(e,n){return s.deepEq(t[n],e)})&&r.all(t,function(t,n){return s.deepEq(e[n],t)}):r.isObject(e)||r.isObject(t)?!1:s.eq(e,t)},parseQueryString:function(e){e=e||window.location.search.substring(1);var t={},n,r=/\+/g,i=/([^&=]+)=?([^&]*)/g,s=function(e){return decodeURIComponent(e.replace(r," "))};while(n=i.exec(e))t[s(n[1])]=s(n[2]);return t},updateQueryString:function(e,t,n){n=encodeURIComponent(n);var r=new RegExp("([?&])"+t+"=.*?(&|$)","i"),i=e.indexOf("?")!==-1?"&":"?";return e.match(r)?e.replace(r,"$1"+t+"="+n+"$2"):e+i+t+"="+n},strongEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/['()!]/g,window.escape).replace(/\*/g,"%2A")},widgetShouldHighlight:function(e){if(!e)return!1;var t=["measurer","protractor"];return!r.contains(t,e.type)},scoreIsEmpty:function(e){return e.type==="invalid"},touchHandlers:{pointerDown:!1,currentTouchIdentifier:null},resetTouchHandlers:function(){r.extend(s.touchHandlers,{pointerDown:!1,currentTouchIdentifier:null})},extractPointerLocation:function(e){var t;if(s.touchHandlers.pointerDown){if(s.touchHandlers.currentTouchIdentifier!=null){var n=e.changedTouches?e.changedTouches.length:0;for(var r=0;r<n;r++)e.changedTouches[r].identifier===s.touchHandlers.currentTouchIdentifier&&(t=e.changedTouches[r])}else t=e;var i=e.type==="touchend"||e.type==="touchcancel";t&&i&&(s.touchHandlers.pointerDown=!1,s.touchHandlers.currentTouchIdentifier=null)}else s.touchHandlers.pointerDown=!0,e.changedTouches?(t=e.changedTouches[0],s.touchHandlers.currentTouchIdentifier=t.identifier):t=e;if(t)return{left:t.pageX,top:t.pageY}},captureScratchpadTouchStart:function(e){e.stopPropagation()},getImageSize:function(e,t){var i=new Image;i.onload=function(){i.width===0&&i.height===0?(document.body.appendChild(i),r.defer(function(){t(i.clientWidth,i.clientHeight),document.body.removeChild(i)})):t(i.width,i.height)};var s=n(63);i.src=s.getRealImageUrl(e)},textarea:{getWordBeforeCursor:function(e){var t=e.value,n=e.selectionStart-1,r=Math.max(t.lastIndexOf("\n",n),t.lastIndexOf(" ",n))+1;return{string:t.substring(r,n+1),pos:{start:r,end:n}}},moveCursor:function(e,t){e.selectionStart=t,e.selectionEnd=t}}};s.random=s.seededRNG((new Date).getTime()&4294967295),e.exports=s},function(e,t,n){var r=n(62),i=n(51),s=n(18),o=function(e,t){if(t==null)return!1;var n=e.version||{major:0,minor:0};return t.major>n.major?!0:t.major<n.major?!1:t.minor>=n.minor},u=function(e,t){if(e==null||e.type==null)return!0;var n=s.upgradeWidgetInfoToLatestVersion(e);return o(n,t[n.type])},a=function(e,t){var n=!0;return i.traverseRendererDeep(e,function(e){n=n&&u(e,t)}),n},f=function(e,t){if(e==null||t==null)throw new Error("missing parameter to Perseus.isRenderable.item");return a(e.question,t)};e.exports={isItemRenderableByVersion:f}},function(e,t,n){var r=n(66),i=n(62),s=n(14),o=n(52),u=n(53),a=n(18),f=n(5),l=n(54),c=n(16).Options,h="answer-area",p=r.PropTypes,d=r.createClass({displayName:"AnswerAreaRenderer",propTypes:{type:p.string,options:p.object,calculator:p.bool,problemNum:p.number,onInteractWithWidget:p.func.isRequired,enabledFeatures:l.propTypes,highlightedWidgets:p.array.isRequired,apiOptions:c.propTypes},getDefaultProps:function(){return{problemNum:0,onInteractWithWidget:function(){},enabledFeatures:l.defaults,highlightedWidgets:[],apiOptions:c.defaults}},getInitialState:function(){return{widget:{},cls:this.getClass(this.props.type)}},componentWillReceiveProps:function(e){this.setState({cls:this.getClass(e.type)})},getWidgetInstance:function(){return this.props.type==="multiple"?this.refs.widget:this.refs.container.getWidget()},getClass:function(e){return e==="multiple"?s:a.getWidget(e,this.props.enabledFeatures)},render:function(){return this.props.type==="multiple"?this.renderMultiple():this.renderSingle()},emptyWidgets:function(){return this.props.type==="multiple"?this.getWidgetInstance().emptyWidgets():f.scoreIsEmpty(this.getWidgetInstance().simpleValidate(this.props.options))?[h]:[]},_getAnswerAreaFocusObj:function(e){if(e==null)return e;var t=["answer-"+i.first(e)].concat(i.rest(e));return t},renderMultiple:function(){var e=this.props.apiOptions.onFocusChange,t=i.extend({},c.defaults,this.props.apiOptions,e&&{onFocusChange:function(t,n){e(this._getAnswerAreaFocusObj(t),this._getAnswerAreaFocusObj(n))}.bind(this)});return r.createElement(this.state.cls,r.__spread({ref:"widget",problemNum:this.props.problemNum,onChange:this.handleChangeRenderer,onInteractWithWidget:this.props.onInteractWithWidget,highlightedWidgets:this.props.highlightedWidgets,enabledFeatures:i.extend({},this.props.enabledFeatures,{toolTipFormats:!1}),apiOptions:t},this.props.options,this.state.widget))},renderSingle:function(){var e=i.contains(this.props.highlightedWidgets,h);return r.createElement(o,null,r.createElement(u,{ref:"container",key:this.props.type,type:this.state.cls,initialProps:this.getSingleWidgetProps(),shouldHighlight:e}))},getSingleWidgetProps:function(){var e=i.extend({},c.defaults,this.props.apiOptions),t=function(t,n){this._isFocused=!0,e.onFocusChange([h].concat(t),null)}.bind(this),n=function(t,n){this._isFocused=!1,e.onFocusChange(null,[h].concat(t))}.bind(this),r=a.getRendererPropsForWidgetInfo(this.props,this.props.problemNum);return i.extend({widgetId:h,problemNum:this.props.problemNum,onChange:this.handleChangeRenderer,enabledFeatures:i.extend({},this.props.enabledFeatures,{toolTipFormats:!1}),apiOptions:e,onFocus:t,onBlur:n},r,this.state.widget)},_setWidgetProps:function(e,t,n){e==="area"&&this.props.type!=="multiple"?this.handleChangeRenderer(t,n):this.props.type==="multiple"?this.getWidgetInstance()._setWidgetProps(e,t,n):typeof console!="undefined"&&console.error&&console.error("Sent invalid widget id `answer-"+e+"` to an answerArea of type `"+this.props.type+"`.")},handleChangeRenderer:function(e,t){var n=i.extend({},this.state.widget,e);this.setState({widget:n},function(){if(this.props.type!=="multiple"){var e=t&&t();this.props.onInteractWithWidget(h),e!==!1&&this.props.apiOptions.onFocusChange&&!this._isFocused&&(this._isFocused=!0,this.props.apiOptions.onFocusChange([h],null))}}.bind(this))},componentDidMount:function(){this._isFocused=!1,this.update()},componentDidUpdate:function(e){this.update(),this.props.type!=="multiple"&&e.type===this.props.type&&this.refs.container.replaceWidgetProps(this.getSingleWidgetProps())},update:function(){$("#calculator").toggle(this.props.calculator)},componentWillUnmount:function(){this.props.calculator&&$("#calculator").hide()},getDOMNodeForPath:function(e){var t=i.first(e),n=i.rest(e);if(this.props.type==="multiple"){var r=t.replace("answer-",""),s=[r].concat(n);return this.getWidgetInstance().getDOMNodeForPath(s)}var o=this.getWidgetInstance(),u=o.getDOMNodeForPath;if(u)return u(n);if(n.length===0)return o.getDOMNode()},getGrammarTypeForPath:function(e){var t=i.first(e),n=i.rest(e);if(this.props.type==="multiple"){var r=t.replace("answer-",""),s=[r].concat(n);return this.getWidgetInstance().getGrammarTypeForPath(s)}var o=this.getWidgetInstance();return o.getGrammarTypeForPath(n)},getInputPaths:function(){if(this.props.type==="multiple"){var e=this.getWidgetInstance().getInputPaths();return i.map(e,function(e){var t="answer-"+i.first(e);return[t].concat(i.rest(e))})}var t="answer-area",e=[],n=this.getWidgetInstance();if(n.getInputPaths){var r=n.getInputPaths();r===n?e.push([t]):i.each(r,function(n){var r=[t].concat(n);e.push(r)})}return e},focusPath:function(e){var t=i.first(e),n=i.rest(e);if(this.props.type==="multiple"){var r=t.replace("answer-",""),s=[r].concat(n);this.getWidgetInstance().focusPath(s)}else{var o=this.getWidgetInstance().focusInputPath;o&&o(n)}},blurPath:function(e){var t=i.first(e),n=i.rest(e);if(this.props.type==="multiple"){var r=t.replace("answer-",""),s=[r].concat(n);this.getWidgetInstance().blurPath(s)}else{var o=this.getWidgetInstance().blurInputPath;o&&o(n)}},focus:function(){var e=this.getWidgetInstance().focus;e&&e()},blur:function(){var e=this.getWidgetInstance().blur;e&&e()},setInputValue:function(e,t,n){var r=i.first(e),s=i.rest(e),o;if(this.props.type==="multiple"){var u=r.replace("answer-",""),a=[u].concat(s);o=a}else o=s;this.getWidgetInstance().setInputValue(o,t,n)},guessAndScore:function(){if(this.props.type==="multiple")return this.getWidgetInstance().guessAndScore();var e=this.getWidgetInstance().getUserInput(),t;return this.props.graded==null||this.props.graded?t=this.getWidgetInstance().simpleValidate(this.props.options):t=f.noScore,[e,t]}});e.exports=d},function(e,t,n){var r=n(66),i=n(62),s=n(16).Options,o=n(9),u=n(10),a=n(54),f=n(55),l=n(14),c=r.PropTypes.shape({content:r.PropTypes.string,widgets:r.PropTypes.object,images:r.PropTypes.object}),h=r.createClass({displayName:"SectionControlButton",render:function(){return r.createElement("a",{href:"#",className:"section-control-button simple-button simple-button--small orange",onClick:function(e){e.preventDefault(),this.props.onClick()}.bind(this)},r.createElement("span",{className:this.props.icon}))}}),p=r.createClass({displayName:"ArticleEditor",propTypes:{json:r.PropTypes.oneOfType([c,r.PropTypes.arrayOf(c)]),apiOptions:r.PropTypes.object,developerMode:r.PropTypes.bool,enabledFeatures:a.propTypes,imageUploader:r.PropTypes.func,onChange:r.PropTypes.func.isRequired},getDefaultProps:function(){return{developerMode:!1,json:[{}],enabledFeatures:{toolTipFormats:!0,useMathQuill:!0}}},getInitialState:function(){return{mode:"edit"}},render:function(){return r.createElement("div",{className:"framework-perseus perseus-article"},r.createElement("div",null,r.createElement("label",null,"Mode:"," ",r.createElement("select",{value:this.state.mode,onChange:this._changeMode},r.createElement("option",{value:"edit"},"Edit"),r.createElement("option",{value:"preview"},"Preview"),this.props.developerMode&&r.createElement("option",{value:"json"},"Dev-only JSON")))),this.state.mode==="edit"&&this._renderEditor(),this.state.mode==="preview"&&this._renderPreviewMode(),this.props.developerMode&&this.state.mode==="json"&&r.createElement("div",null,r.createElement(f,{multiLine:!0,value:this.props.json,onChange:this._handleJsonChange})))},_sections:function(){return i.isArray(this.props.json)?this.props.json:[this.props.json]},_renderEditor:function(){return r.createElement("div",null,this._renderSections(),this._renderAddSection())},_renderSections:function(){var e=i.extend({},s.defaults,this.props.apiOptions),t=this._sections();return r.createElement("div",{className:"perseus-editor-table"},t.map(function(n,s){return[r.createElement("div",{className:"perseus-editor-row"},r.createElement("div",{className:"perseus-editor-left-cell"},r.createElement("div",{className:"pod-title"},"Section ",s+1,r.createElement("div",{style:{display:"inline-block","float":"right"}},s+1<t.length&&r.createElement(h,{icon:"icon-circle-arrow-down",onClick:function(){this._handleMoveSectionLater(s)}.bind(this)}),s>0&&r.createElement(h,{icon:"icon-circle-arrow-up",onClick:function(){this._handleMoveSectionEarlier(s)}.bind(this)}),r.createElement(h,{icon:"icon-trash",onClick:function(){var e="Are you sure you want to remove section "+(s+1)+"?";confirm(e)&&this._handleRemoveSection(s)}.bind(this)}),r.createElement(h,{icon:"icon-plus",onClick:function(){this._handleAddSectionAfter(s)}.bind(this)}))),r.createElement(u,r.__spread({},n,{ref:"editor"+s,placeholder:"Type your section text here...",imageUploader:this.props.imageUploader,onChange:i.partial(this._handleEditorChange,s),apiOptions:e,enabledFeatures:this.props.enabledFeatures}))),r.createElement("div",{className:"perseus-editor-right-cell"},r.createElement(l,r.__spread({},n,{ref:"renderer"+s,apiOptions:e,enabledFeatures:this.props.enabledFeatures}))))]}.bind(this)))},_renderAddSection:function(){return r.createElement("div",{className:"perseus-editor-row"},r.createElement("div",{className:"perseus-editor-left-cell"},r.createElement("a",{href:"#",className:"simple-button orange",onClick:function(){this._handleAddSectionAfter(this._sections().length-1)}.bind(this)},r.createElement("span",{className:"icon-plus"})," Add a section")),r.createElement("div",{className:"perseus-editor-right-cell"}))},_renderPreviewMode:function(){return r.createElement(o,{json:this.props.json,apiOptions:this.props.apiOptions,enabledFeatures:this.props.enabledFeatures})},_changeMode:function(e){var t=e.target.value;this.props.onChange({json:this.serialize()},function(){this.setState({mode:t})}.bind(this))},_handleJsonChange:function(e){this.props.onChange({json:e})},_handleEditorChange:function(e,t){var n=i.clone(this._sections());n[e]=i.extend({},n[e],t),this.props.onChange({json:n})},_handleMoveSectionEarlier:function(e){if(e===0)return;var t=i.clone(this._sections()),n=t[e];t.splice(e,1),t.splice(e-1,0,n),this.props.onChange({json:t})},_handleMoveSectionLater:function(e){var t=i.clone(this._sections());if(e+1===t.length)return;var n=t[e];t.splice(e,1),t.splice(e+1,0,n),this.props.onChange({json:t})},_handleAddSectionAfter:function(e){var t=i.clone(this.serialize()),n=e>=0?{widgets:t[e].widgets}:{};t.splice(e+1,0,n),this.props.onChange({json:t})},_handleRemoveSection:function(e){var t=i.clone(this._sections());t.splice(e,1),this.props.onChange({json:t})},serialize:function(){if(this.state.mode==="edit")return this._sections().map(function(e,t){return this.refs["editor"+t].serialize()}.bind(this));if(this.state.mode==="preview"||this.state.mode==="json")return this.props.json;throw new Error("Could not serialize; mode "+this.state.mode+" not found")}});e.exports=p},function(e,t,n){var r=n(66),i=n(16).Options,s=n(14),o=n(5),u=r.createClass({displayName:"ArticleRenderer",shouldComponentUpdate:function(e,t){return e!==this.props||t!==this.state},render:function(){var e=this._sections().map(function(e,t){return"[["+o.snowman+" group "+t+"]]"}).join("\n\n"),t={};return _.each(this._sections(),function(e,n){var r="group "+n;t[r]={type:"group",graded:!0,version:{major:0,minor:0},options:e}}),r.createElement(s,{content:e,widgets:t,apiOptions:this.props.apiOptions,enabledFeatures:this.props.enabledFeatures})},_sections:function(){return _.isArray(this.props.json)?this.props.json:[this.props.json]}});e.exports=u},function(e,t,n){var r=n(66),i=n(62),s=n(16).Options,o=n(69),u=n(54),a=n(56),f=n(64),l=n(5),c=n(18),h=n(67),p="[[☃ {id}]]",d="(\\[\\[☃ {id}\\]\\])",v=new RegExp(d.replace("{id}","[a-z-]+ [0-9]+"),"g"),m=/^\[\[([a-z\-]+)$/,g=/(?:\n{2,}|^\n*)$/,y=/(\n*)$/,b=/^(\n*)/,w=function(e){var t=e.toString();return t.length>=5&&(t=t.replace(/(\d)(?=(\d{3})+$)/g,"$1{,}")),t},E=function(e){if(!g.test(e)){var t=y.exec(e)[1];return e+"\n\n".slice(0,2-t.length)}return e},S=function(e){var t=b.exec(e)[1];return"\n\n".slice(0,2-t.length)+e},x=r.createClass({displayName:"WidgetSelect",shouldComponentUpdate:function(){return!1},render:function(){var e=c.getPublicWidgets(),t=i.sortBy(i.keys(e),function(t){return e[t].displayName});return r.createElement("select",{value:"",onChange:this.handleChange},r.createElement("option",{value:""},"Add a widget","…"),r.createElement("option",{disabled:!0},"--"),i.map(t,function(t){return r.createElement("option",{key:t,value:t},e[t].displayName)}))},handleChange:function(e){var t=e.target.value;if(t==="")return;this.props.onChange&&this.props.onChange(t)}}),T=r.createClass({displayName:"WidgetEditor",propTypes:{type:r.PropTypes.string,id:r.PropTypes.string,graded:r.PropTypes.bool,onChange:r.PropTypes.func,apiOptions:s.propTypes},getDefaultProps:function(){return{graded:!0,options:{}}},getInitialState:function(){return{showWidget:!0}},render:function(){var e=c.upgradeWidgetInfoToLatestVersion(this.props),t=e.type,n=c.getEditor(t),i=t==="transformer",s=this.state.showWidget?"down":"right",o=r.createElement(f,{label:"Graded:",graded:e.graded,onChange:this.props.onChange});return r.createElement("div",{className:"perseus-widget-editor"},r.createElement("div",{className:"perseus-widget-editor-title "+(this.state.showWidget?"open":"closed")},r.createElement("a",{href:"#",onClick:this.toggleWidget},this.props.id,r.createElement("i",{className:"icon-chevron-"+s})),r.createElement("a",{href:"#",className:"remove-widget simple-button simple-button--small orange",onClick:function(e){e.preventDefault(),this.props.onRemove()}.bind(this)},r.createElement("span",{className:"icon-trash"}))),r.createElement("div",{className:"perseus-widget-editor-content "+(this.state.showWidget?"enter":"leave")},i&&o,r.createElement(n,r.__spread({ref:"widget",onChange:this._handleWidgetChange,apiOptions:this.props.apiOptions},e.options))))},toggleWidget:function(e){e.preventDefault(),this.setState({showWidget:!this.state.showWidget})},_handleWidgetChange:function(e,t,n){var r=i.extend(i.omit(this.props,h),{options:this.refs.widget.serialize()}),s=c.upgradeWidgetInfoToLatestVersion(r);s.options=i.extend(s.options,e),this.props.onChange(s,t,n)},getSaveWarnings:function(){var e=this.refs.widget.getSaveWarnings;return e?e():[]},serialize:function(){return{type:this.props.type,graded:this.props.graded,options:this.refs.widget.serialize(),version:c.getVersion(this.props.type)}}}),N=/!\[[^\]]*\]\(([^\s\)]+)[^\)]*\)/g,C=function(e,t){var n=[];for(;;){var r=e.exec(t);if(!r)break;n.push(r)}return n},k=function(e){return i.map(C(N,e),function(e){return e[1]})},L=r.createClass({displayName:"Editor",propTypes:{imageUploader:r.PropTypes.func,apiOptions:s.propTypes},getDefaultProps:function(){return{content:"",placeholder:"",widgets:{},images:{},disabled:!1,widgetEnabled:!0,immutableWidgets:!1,showWordCount:!1,apiOptions:s.defaults}},getWidgetEditor:function(e,t){if(!c.getEditor(t))return;return r.createElement(T,r.__spread({ref:e,id:e,type:t,onChange:this._handleWidgetEditorChange.bind(this,e),onRemove:this._handleWidgetEditorRemove.bind(this,e),apiOptions:this.props.apiOptions},this.props.widgets[e]))},_handleWidgetEditorChange:function(e,t,n,r){var s=i.clone(this.props.widgets);s[e]=i.extend({},s[e],t),this.props.onChange({widgets:s},n,r)},_handleWidgetEditorRemove:function(e){var t=new RegExp(d.replace("{id}",e),"gm"),n=this.refs.textarea.getDOMNode();this.props.onChange({content:n.value.replace(t,"")})},_sizeImages:function(e){var t=k(e.content),n=i.pick(e.images,t),r=i.filter(t,function(e){return!n[e]});i.each(r,function(t){l.getImageSize(t,function(r,s){n[t]={width:r,height:s},e.onChange({images:i.clone(n)},null,!0)})})},render:function(){var e,t,n,s,u,f,c;if(this.props.showWordCount){var h=a.characterCount(this.props.content),p=Math.floor(h/6);c=r.createElement("span",{className:"perseus-editor-word-count",title:"~"+w(p)+" words ("+w(h)+" characters)"},w(p))}if(this.props.widgetEnabled){e=l.split(this.props.content,v),t={},n=[];for(var d=0;d<e.length;d++){var m=d%2;if(m===0)n.push(e[d]);else{var g=l.rWidgetParts.exec(e[d]),y=g[1],m=g[2],b=!1,E=y in t;t[y]=this.getWidgetEditor(y,m);var S=(E||!t[y]?"error ":"")+(b?"selected ":""),T=E?d:y;n.push(r.createElement("b",{className:S,key:T},e[d]))}}this.widgetIds=i.keys(t),s=r.createElement(x,{ref:"widgetSelect",onChange:this._addWidget}),u=r.createElement("select",{onChange:this.addTemplate},r.createElement("option",{value:""},"Insert template","…"),r.createElement("option",{disabled:!0},"--"),r.createElement("option",{value:"table"},"Table"),r.createElement("option",{value:"titledTable"},"Titled table"),r.createElement("option",{value:"alignment"},"Aligned equations"),r.createElement("option",{value:"piecewise"},"Piecewise function")),this.props.immutableWidgets||(f=r.createElement("div",{className:"perseus-editor-widgets"},r.createElement("div",{className:"perseus-editor-widgets-selectors"},s,u,c),r.addons.createFragment(t)),c=null)}else n=[this.props.content];n.push(r.createElement("br",{key:"end"}));var N=[r.createElement("div",{className:"perseus-textarea-underlay",ref:"underlay",key:"underlay"},n),r.createElement("textarea",{ref:"textarea",key:"textarea",onChange:this.handleChange,onKeyDown:this._handleKeyDown,placeholder:this.props.placeholder,disabled:this.props.disabled,value:this.props.content})],C;return this.props.imageUploader?C=r.createElement(o,{onDrop:this.handleDrop,className:"perseus-textarea-pair"},N):C=r.createElement("div",{className:"perseus-textarea-pair"},N),r.createElement("div",{className:"perseus-single-editor "+(this.props.className||"")},C,c,f)},componentDidMount:function(){this._sizeImages(this.props)},componentDidUpdate:function(e){var t=this.refs.textarea.getDOMNode();t.value=this.props.content,this.props.content!==e.content&&this._sizeImages(this.props)},handleDrop:function(e){var t=this.props.content,n=e.nativeEvent.dataTransfer,r=n.files;if(r.length===0){var s=n.getData("URL");if(s){var o=t+"\n\n![]("+s+")";this.props.onChange({content:o})}return}i(r).chain().map(function(e){if(!e.type.match("image.*"))return null;var n="☃ "+i.uniqueId("image_");return t+="\n\n![]("+n+")",{file:e,sentinel:n}}).reject(i.isNull).tap(function(){this.props.onChange({content:t})}.bind(this)).each(function(e){this.props.imageUploader(e.file,function(t){this.props.onChange({content:this.props.content.replace(e.sentinel,t)})}.bind(this))}.bind(this))},handleChange:function(){var e=this.refs.textarea.getDOMNode();this.props.onChange({content:e.value})},_handleKeyDown:function(e){if(e.key==="Tab"){var t=this.refs.textarea.getDOMNode(),n=l.textarea.getWordBeforeCursor(t),r=n.string.toLowerCase().match(m);if(r!=null){var s=r[1],o=c.getAllWidgetTypes(),u=i.filter(o,function(e){return e.substring(0,s.length)===s});if(u.length===1){var a=u[0];this._addWidgetToContent(this.props.content,[n.pos.start,n.pos.end+1],a)}e.preventDefault()}}},_addWidgetToContent:function(e,t,n){var r=this.refs.textarea.getDOMNode(),s=i.map(e.match(v),function(e){var t=l.rWidgetParts.exec(e),n=t[2],r=+t[3];return[n,r]}),o=i.reduce(s,function(e,t){var r=t,i=r[0],s=r[1];return i===n?Math.max(s+1,e):e},1),a=n+" "+o,f=p.replace("{id}",a),h=c.getWidget(n,u.defaults),d=h.displayMode==="block",m=e.slice(0,t[0]),g=e.slice(t[1]),y=d?E(m):m,b=d?S(g):g,w=y+f+b;this.props.onChange({content:w},function(){l.textarea.moveCursor(r,w.length-g.length)})},_addWidget:function(e){var t=this.refs.textarea.getDOMNode();this._addWidgetToContent(this.props.content,[t.selectionStart,t.selectionEnd],e),t.focus()},addTemplate:function(e){var t=e.target.value;if(t==="")return;e.target.value="";var n=this.props.content;n=n.replace(/\n*$/,"\n\n");var r;if(t==="table")r="header 1 | header 2 | header 3\n- | - | -\ndata 1 | data 2 | data 3\ndata 4 | data 5 | data 6\ndata 7 | data 8 | data 9";else if(t==="titledTable")r="|| **Table title** ||\nheader 1 | header 2 | header 3\n- | - | -\ndata 1 | data 2 | data 3\ndata 4 | data 5 | data 6\ndata 7 | data 8 | data 9";else if(t==="alignment")r="$\\begin{align} x+5 &= 30 \\\\\nx+5-5 &= 30-5 \\\\\nx &= 25 \\end{align}$";else{if(t!=="piecewise")throw new Error("Invalid template type: "+t);r="$f(x) = \\begin{cases}\n7 & \\text{if $x=1$} \\\\\nf(x-1)+5 & \\text{if $x > 1$}\n\\end{cases}$"}var i=n+r;this.props.onChange({content:i},this.focusAndMoveToEnd)},getSaveWarnings:function(){var e=a.parse(this.props.content),t=[];a.traverseContent(e,function(e){if(e.type==="image"&&!e.alt){var n=e.target.length<9?e.target:e.target.slice(0,3)+"..."+e.target.slice(-3);t.push("Image '"+e.target+"' doesn't have alt text: ![add alt text here]("+n+")")}});var n=i.intersection(this.widgetIds,i.keys(this.refs)),r=i(n).chain().map(function(e){var t=this.refs[e].getSaveWarnings,n=t?t():[];return i.map(n,function(t){return e+": "+t})}.bind(this)).flatten(!0).value();return t.concat(r)},serialize:function(e){var t={},n=i.intersection(this.widgetIds,i.keys(this.refs));return i.each(n,function(e){t[e]=this.refs[e].serialize()}.bind(this)),e&&e.keepDeletedWidgets&&i.chain(this.props.widgets).keys().reject(function(e){return i.contains(n,e)}).each(function(e){t[e]=this.props.widgets[e]}.bind(this)),{content:this.props.content,images:this.props.images,widgets:t}},focus:function(){this.refs.textarea.getDOMNode().focus()},focusAndMoveToEnd:function(){this.focus();var e=this.refs.textarea.getDOMNode();e.selectionStart=e.value.length,e.selectionEnd=e.value.length}});e.exports=L},function(e,t,n){var r=n(66),i=n(62),s=n(57),o=n(54),u=n(58),a=n(12),f=n(55),l=n(16).Options,c=r.createClass({displayName:"EditorPage",propTypes:{imageUploader:r.PropTypes.func,enabledFeatures:o.propTypes,apiOptions:r.PropTypes.object},getDefaultProps:function(){return{developerMode:!1,jsonMode:!1,enabledFeatures:{toolTipFormats:!0,useMathQuill:!0},apiOptions:{}}},getInitialState:function(){return{json:{question:this.props.question,answer:this.props.answerArea,hints:this.props.hints},gradeMessage:"",wasAnswered:!1}},render:function(){return r.createElement("div",{id:"perseus",className:"framework-perseus"},this.props.developerMode&&r.createElement("div",null,r.createElement("label",null," ","Developer JSON Mode:"," ",r.createElement("input",{type:"checkbox",checked:this.props.jsonMode,onChange:this.toggleJsonMode}))),this.props.developerMode&&this.props.jsonMode&&r.createElement("div",null,r.createElement(f,{multiLine:!0,value:this.state.json,onChange:this.changeJSON})),(!this.props.developerMode||!this.props.jsonMode)&&r.createElement(u,{ref:"itemEditor",rendererOnly:this.props.jsonMode,question:this.props.question,answerArea:this.props.answerArea,imageUploader:this.props.imageUploader,onChange:this.handleChange,wasAnswered:this.state.wasAnswered,gradeMessage:this.state.gradeMessage,onCheckAnswer:this.handleCheckAnswer,apiOptions:this._apiOptions()}),(!this.props.developerMode||!this.props.jsonMode)&&r.createElement(s,{ref:"hintsEditor",hints:this.props.hints,imageUploader:this.props.imageUploader,onChange:this.handleChange}))},handleCheckAnswer:function(){var e=this.scorePreview();this.setState({gradeMessage:e.message,wasAnswered:e.correct})},toggleJsonMode:function(){this.setState({json:this.serialize({keepDeletedWidgets:!0})},function(){this.props.onChange({jsonMode:!this.props.jsonMode})})},componentDidMount:function(){this.rendererMountNode=document.createElement("div"),this.updateRenderer()},componentDidUpdate:function(){this.updateRenderer()},updateRenderer:function(e){if(this.rendererMountNode==null||this.props.jsonMode)return;var t=i({item:this.serialize(),enabledFeatures:{toolTipFormats:!0},apiOptions:this._apiOptions(),initialHintsVisible:0}).extend(i(this.props).pick("workAreaSelector","solutionAreaSelector","hintsAreaSelector","problemNum","enabledFeatures"));this.renderer=r.render(r.createElement(a,r.__spread({},t)),this.rendererMountNode,e)},_apiOptions:function(){return i.extend({},l.defaults,this.props.apiOptions)},handleChange:function(e,t,n){var r=i(this.props).pick("question","hints","answerArea");i(r).extend(e),this.props.onChange(r,t,n)},changeJSON:function(e){this.setState({json:e}),this.props.onChange(e)},scorePreview:function(){return this.renderer?this.renderer.scoreInput():null},getSaveWarnings:function(){var e=this.refs.itemEditor.getSaveWarnings(),t=this.refs.hintsEditor.getSaveWarnings();return e.concat(t)},serialize:function(e){return this.props.jsonMode?this.state.json:i.extend(this.refs.itemEditor.serialize(e),{hints:this.refs.hintsEditor.serialize(e)})}});e.exports=c},function(e,t,n){var r=n(66),i=n(62),s=n(7),o=n(16).Options,u=n(54),a=n(13),f=n(14),l=n(5),c=n(68),h=c.mapObject,p=r.createClass({displayName:"ItemRenderer",getDefaultProps:function(){return{initialHintsVisible:0,workAreaSelector:"#workarea",solutionAreaSelector:"#solutionarea",hintsAreaSelector:"#hintsarea",enabledFeatures:{},apiOptions:{}}},getInitialState:function(){return{hintsVisible:this.props.initialHintsVisible,questionCompleted:!1,questionHighlightedWidgets:[],answerHighlightedWidgets:[]}},componentWillReceiveProps:function(e){this.setState({questionHighlightedWidgets:[],answerHighlightedWidgets:[]})},componentDidMount:function(){Khan.scratchpad&&Khan.scratchpad.enable(),this._currentFocus=null,this.update()},componentDidUpdate:function(){this.update()},update:function(){var e=i.extend({},u.defaults,this.props.enabledFeatures),t=i.extend({},o.defaults,this.props.apiOptions,{onFocusChange:this._handleFocusChange});this.questionRenderer=r.render(r.createElement(f,r.__spread({problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,enabledFeatures:e,apiOptions:t,questionCompleted:this.state.questionCompleted,savedState:this.props.savedState},this.props.item.question)),document.querySelector(this.props.workAreaSelector)),this.answerAreaRenderer=r.render(r.createElement(s,{type:this.props.item.answerArea.type,options:this.props.item.answerArea.options,calculator:this.props.item.answerArea.calculator||!1,problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithAnswerWidget,highlightedWidgets:this.state.answerHighlightedWidgets,enabledFeatures:e,apiOptions:t}),document.querySelector(this.props.solutionAreaSelector)),this.hintsRenderer=r.render(r.createElement(a,{hints:this.props.item.hints,hintsVisible:this.state.hintsVisible,enabledFeatures:e,apiOptions:t}),document.querySelector(this.props.hintsAreaSelector))},_handleFocusChange:function(e,t){e!=null?this._setCurrentFocus(e):this._onRendererBlur(t)},_setCurrentFocus:function(e){var t=this._currentFocus;this._currentFocus=e,this.props.apiOptions.onFocusChange!=null&&this.props.apiOptions.onFocusChange(this._currentFocus,t)},_onRendererBlur:function(e){var t=this._currentFocus;if(!i.isEqual(e,t))return;i.defer(function(){i.isEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}.bind(this))},_setWidgetProps:function(e,t,n){var r=e.match(/^answer-(.*)$/);if(r){var i=r[1];this.answerAreaRenderer._setWidgetProps(i,t,n)}else this.questionRenderer._setWidgetProps(e,t,n)},_handleAPICall:function(e,t){var n=i.rest(arguments),r,s=t[0].match(/^answer-(.*)$/);return s?r=this.answerAreaRenderer:r=this.questionRenderer,r[e].apply(r,n)},setInputValue:function(e,t,n){return this._handleAPICall("setInputValue",e,t,n)},focusPath:function(e){if(e&&e.length>0){var t=e[0].match(/^answer-(.*)$/);t?this.questionRenderer.blur():this.answerAreaRenderer.blur()}return this._handleAPICall("focusPath",e)},blurPath:function(e){return this._handleAPICall("blurPath",e)},getDOMNodeForPath:function(e){return this._handleAPICall("getDOMNodeForPath",e)},getGrammarTypeForPath:function(e){return this._handleAPICall("getGrammarTypeForPath",e)},getInputPaths:function(){var e=this.questionRenderer.getInputPaths(),t=this.answerAreaRenderer.getInputPaths();return e.concat(t)},handleInteractWithWidget:function(e){var t=i.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t})},handleInteractWithAnswerWidget:function(e){var t=i.difference(this.state.answerHighlightedWidgets,[e]);this.setState({answerHighlightedWidgets:t})},render:function(){return r.createElement("div",null)},focus:function(){return this.questionRenderer.focus()||this.answerAreaRenderer.focus()},componentWillUnmount:function(){r.unmountComponentAtNode(document.querySelector(this.props.workAreaSelector)),r.unmountComponentAtNode(document.querySelector(this.props.solutionAreaSelector)),r.unmountComponentAtNode(document.querySelector(this.props.hintsAreaSelector))},showHint:function(){this.state.hintsVisible<this.getNumHints()&&this.setState({hintsVisible:this.state.hintsVisible+1})},getNumHints:function(){return this.props.item.hints.length},scoreInput:function(){var e=this.questionRenderer.guessAndScore(),t=this.answerAreaRenderer.guessAndScore(),n=e[0],r=e[1],i=t[0],s=t[1],o=this.questionRenderer.emptyWidgets(),u=this.answerAreaRenderer.emptyWidgets();this.setState({questionHighlightedWidgets:o,answerHighlightedWidgets:u});var a,f;n.length===0?(a=i,f=s):(a=[n,i],f=l.combineScores(r,s));var c=l.keScoreFromPerseusScore(f,a);return this.setState({questionCompleted:c.correct}),c},getWidgetIds:function(){return this.questionRenderer.getWidgetIds()},scoreWidgets:function(){var e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets();return h(e,function(e,n){return l.keScoreFromPerseusScore(e,t[n])})},getSerializedState:function(){return{question:this.questionRenderer.getSerializedState(),hints:this.hintsRenderer.getSerializedState()}},restoreSerializedState:function(e,t){var n=2,r=function(){--n,t&&n===0&&t()};this.questionRenderer.restoreSerializedState(e.question,r),this.hintsRenderer.restoreSerializedState(e.hints,r)}});e.exports=p},function(e,t,n){var r=n(66),i=n(62),s=n(59),o=n(63),u=r.createClass({displayName:"HintsRenderer",render:function(){var e=this._hintsVisible(),t=this.props.hints.slice(0,e).map(function(e,t){var n=t===this.props.hints.length-1&&!/\*\*/.test(e.content);return r.createElement(s,{bold:n,hint:e,ref:"hintRenderer"+t,key:"hintRenderer"+t,enabledFeatures:this.props.enabledFeatures,apiOptions:this.props.apiOptions})},this);return r.createElement("div",null,t)},_hintsVisible:function(){return this.props.hintsVisible==null||this.props.hintsVisible===-1?this.props.hints.length:this.props.hintsVisible},componentDidMount:function(){this._cacheHintImages()},componentDidUpdate:function(e,t){(!i.isEqual(e.hints,this.props.hints)||e.hintsVisible!==this.props.hintsVisible)&&this._cacheHintImages()},_cacheImagesInHint:function(e){i.each(e.images,function(e,t){var n=new Image;n.src=o.getRealImageUrl(t)})},_cacheHintImages:function(){this._hintsVisible()>0?i.each(this.props.hints,this._cacheImagesInHint):this.props.hints.length>0&&this._cacheImagesInHint(this.props.hints[0])},getSerializedState:function(){return i.times(this._hintsVisible(),function(e){return this.refs["hintRenderer"+e].getSerializedState()}.bind(this))},restoreSerializedState:function(e,t){var n=1,r=function(){--n,t&&n===0&&t()};i.each(e,function(e,t){var i=this.refs["hintRenderer"+t];i&&(++n,i.restoreSerializedState(e,r))}.bind(this)),r()}});e.exports=u},function(e,t,n){var r=n(66),i=n(62),s=n(56),o=n(52),u=n(63),a=n(70),f=n(53),l=n(18),c=n(5),h=n(54),p=n(16).Options,d=n(16).ClassNames,v=n(68),m=v.mapObject,g=v.mapObjectFromArray,y={"\\a":"","\\b":"\b","\\t":"	","\\n":"\n","\\v":"","\\f":"\f","\\r":"\r","\\\\":"\\"},b=/\\a|\\b|\\t|\\n|\\v|\\f|\\r|\\\\/g,w=/\S/;typeof KA!="undefined"&&KA.language==="en-pt"&&(window.PerseusTranslationComponents=[],KA.jipt_dom_insert_checks||(KA.jipt_dom_insert_checks=[]),KA.jipt_dom_insert_checks.push(function(e,t,n){var r=$(t).data("perseus-component-index");if(t&&typeof r!="undefined"){var i=window.PerseusTranslationComponents[r];return i?(e=e.replace(b,function(e){return y[e]}),i.setState({jiptContent:e}),!1):!1}return e}));var E=["content","problemNum","widgets"],S=function(e,t){return e===null||t===null?e===t:i.every(e,function(e,n){return i.isEqual(e,t[n])})},x=r.createClass({displayName:"Renderer",propTypes:{highlightedWidgets:r.PropTypes.array,enabledFeatures:h.propTypes,apiOptions:r.PropTypes.object,questionCompleted:r.PropTypes.bool,onInteractWithWidget:r.PropTypes.func,interWidgets:r.PropTypes.func,alwaysUpdate:r.PropTypes.bool,reviewMode:r.PropTypes.bool},componentWillReceiveProps:function(e){i.isEqual(i.pick(this.props,E),i.pick(e,E))||this.setState(this._getInitialWidgetState(e))},getDefaultProps:function(){return{content:"",widgets:{},images:{},ignoreMissingWidgets:!0,highlightedWidgets:[],enabledFeatures:h.defaults,apiOptions:{},questionCompleted:!1,onRender:function(){},onInteractWithWidget:function(){},interWidgets:function(){return null},alwaysUpdate:!1,reviewMode:!1}},getInitialState:function(){return i.extend({jiptContent:null},this._getInitialWidgetState())},_getInitialWidgetState:function(e){e=e||this.props;var t=this._getAllWidgetsInfo(e);return{widgetInfo:t,widgetProps:this._getAllWidgetsStartProps(t,e)}},_getAllWidgetsInfo:function(e){return e=e||this.props,m(e.widgets,function(e,t){if(!e.type){var n=t.split(" ")[0];e=i.extend({},e,{type:n})}return l.upgradeWidgetInfoToLatestVersion(e)})},_getAllWidgetsStartProps:function(e,t){return m(e,function(e){return l.getRendererPropsForWidgetInfo(e,t.problemNum)})},shouldComponentUpdate:function(e,t){if(this.props.alwaysUpdate)return!0;var n=!i.isEqual(this.state,t),r=!i.isEqual(this.props,e);return r||n},_getDefaultWidgetInfo:function(e){var t=c.rTypeFromWidgetId.exec(e);return t==null?{}:{type:t[1],graded:!0,options:{}}},_getWidgetInfo:function(e){return this.state.widgetInfo[e]||this._getDefaultWidgetInfo(e)},renderWidget:function(e,t){var n=this.state.widgetInfo[t];if(n||this.props.ignoreMissingWidgets){var s=n&&n.type||e,o=l.getWidget(s,this.props.enabledFeatures),u=i.contains(this.props.highlightedWidgets,t);return r.createElement(f,{ref:"container:"+t,key:"container:"+t,type:o,initialProps:this.getWidgetProps(t),shouldHighlight:u})}return null},getApiOptions:function(e){return i.extend({},p.defaults,e.apiOptions)},getWidgetProps:function(e){var t=this.state.widgetProps[e]||{},n=null;return this.props.reviewMode&&this.state.widgetInfo[e]&&(n=this.state.widgetInfo[e].options),i.extend({},t,{ref:e,widgetId:e,problemNum:this.props.problemNum,enabledFeatures:this.props.enabledFeatures,apiOptions:this.getApiOptions(this.props),questionCompleted:this.props.questionCompleted,onFocus:i.partial(this._onWidgetFocus,e),onBlur:i.partial(this._onWidgetBlur,e),interWidgets:this.interWidgets,reviewModeRubric:n,onChange:function(t,n){this._setWidgetProps(e,t,n)}.bind(this)})},getSerializedState:function(){return m(this.state.widgetProps,function(e,t){var n=this.getWidgetInstance(t);return n&&n.getSerializedState?n.getSerializedState():e}.bind(this))},restoreSerializedState:function(e,t){var n=1,r=function(){--n,t&&n===0&&t()};this.setState({widgetProps:m(e,function(e,t){var s=this.getWidgetInstance(t);if(s&&s.restoreSerializedState){++n;var o=s.restoreSerializedState(e,r);return i.extend({},this.state.widgetProps[t],o)}return e}.bind(this))},r)},interWidgets:function(e){var t;if(typeof e=="string")if(e.indexOf(" ")!==-1){var n=e;t=function(e,t){return e===n}}else{var r=e;t=function(e,t){return t.type===r}}else t=e;var i=this.widgetIds.filter(function(e){var n=this._getWidgetInfo(e),r=this.getWidgetInstance(e);return t(e,n,r)}.bind(this)).map(this.getWidgetInstance),s=this.props.interWidgets(e,i);return s?s:i},getWidgetInstance:function(e){var t=this.refs["container:"+e];return t?t.getWidget():null},_onWidgetFocus:function(e,t){if(t===undefined)t=[];else if(!i.isArray(t))throw new Error("widget props.onFocus focusPath must be an Array, but was"+JSON.stringify(t));this._setCurrentFocus([e].concat(t))},_onWidgetBlur:function(e,t){var n=this._currentFocus,r=[e].concat(t);if(!i.isEqual(r,n))return;i.defer(function(){i.isEqual(this._currentFocus,n)&&this._setCurrentFocus(null)}.bind(this))},componentWillUpdate:function(e,t){var n=this.shouldRenderJiptPlaceholder(this.props,this.state),r=this.shouldRenderJiptPlaceholder(e,t),i=this.getContent(this.props,this.state),s=this.getContent(e,t),o=this.props.highlightedWidgets,u=e.highlightedWidgets;this.reuseMarkdown=!n&&!r&&i===s&&o===u},componentDidUpdate:function(e,t){this.handleRender(e),i.each(this.widgetIds,function(e){var t=this.refs["container:"+e];t.replaceWidgetProps(this.getWidgetProps(e))}.bind(this))},getContent:function(e,t){return t.jiptContent||e.content},shouldRenderJiptPlaceholder:function(e,t){return typeof KA!="undefined"&&KA.language==="en-pt"&&t.jiptContent==null&&e.content.indexOf("crwdns")!==-1},render:function(){if(this.reuseMarkdown)return this.lastRenderedMarkdown;var e=this.getContent(this.props,this.state);this.widgetIds=[];if(this.shouldRenderJiptPlaceholder(this.props,this.state))return this.translationIndex||(this.translationIndex=window.PerseusTranslationComponents.push(this)-1),r.createElement("div",{"data-perseus-component-index":this.translationIndex},e);this._isTwoColumn=!1;var t=s.parse(e),n=this.outputMarkdown(t),i=this._isTwoColumn?d.RENDERER+" "+d.TWO_COLUMN_RENDERER:d.RENDERER;return this.lastRenderedMarkdown=r.createElement("div",{className:i},n),this.lastRenderedMarkdown},outputMarkdown:function(e){if(i.isArray(e)){var t={};return i.each(e,function(e,n){t["k"+n]=this.outputMarkdown(e)}.bind(this)),r.addons.createFragment(t)}this._foundTextNodes=!1;var n=this.outputNested(e),s=this._foundTextNodes?"":"perseus-paragraph-centered";return r.createElement(o,{className:s},n)},outputNested:function(e){if(i.isArray(e)){var t={};return i.each(e,function(e,n){t["k"+n]=this.outputNested(e)}.bind(this)),r.addons.createFragment(t)}return this.outputNode(e,this.outputNested)},outputNode:function(e,t){if(e.type==="widget")return this._foundTextNodes=!0,i.contains(this.widgetIds,e.id)?r.createElement("span",{className:"renderer-widget-error"},"Widget [[","☃"," ",e.id,"]] already exists."):(this.widgetIds.push(e.id),this.renderWidget(e.widgetType,e.id));if(e.type==="math")return r.createElement("span",{style:{whiteSpace:"nowrap"}},r.createElement("span",null),r.createElement(a,{onRender:this.props.onRender},e.content),r.createElement("span",null));if(e.type==="image"){var n=i.has(this.props.images,e.target)?this.props.images[e.target]:null;return r.createElement(u,r.__spread({src:s.sanitizeUrl(e.target),alt:e.alt,title:e.title},n))}return e.type==="columns"?(this._isTwoColumn=!0,s.ruleOutput(e,t)):e.type==="text"?(w.test(e.content)&&(this._foundTextNodes=!0),e.content):s.ruleOutput(e,t)},handleRender:function(e){var t=this.props.onRender,n=e.onRender,r=$(this.getDOMNode()).find("img");n&&r.off("load",n),r.on("load",t),t()},componentDidMount:function(){this.handleRender({}),this._currentFocus=null},componentWillUnmount:function(){this.translationIndex!=null&&(window.PerseusTranslationComponents[this.translationIndex]=null)},_setCurrentFocus:function(e){if(!S(e,this._currentFocus)){var t=this._currentFocus;t&&this.blurPath(t),this._currentFocus=e,this.props.apiOptions.onFocusChange!=null&&this.props.apiOptions.onFocusChange(this._currentFocus,t)}},focus:function(){var e,t;for(var n=0;n<this.widgetIds.length;n++){var r=this.widgetIds[n],s=this.getWidgetInstance(r),o=s&&s.focus&&s.focus();if(o){e=r,t=o;break}}if(e){var u;return i.isObject(t)?u=[e].concat(t.path||[]):u=[e],this._setCurrentFocus(u),!0}},getDOMNodeForPath:function(e){var t=i.first(e),n=i.rest(e),r=this.getWidgetInstance(t),s=r.getDOMNodeForPath;if(s)return s(n);if(n.length===0)return r.getDOMNode()},getGrammarTypeForPath:function(e){var t=i.first(e),n=i.rest(e),r=this.getWidgetInstance(t);return r.getGrammarTypeForPath(n)},getInputPaths:function(){var e=[];return i.each(this.widgetIds,function(t){var n=this.getWidgetInstance(t);if(n.getInputPaths){var r=n.getInputPaths();i.each(r,function(n){var r=[t].concat(n);e.push(r)})}}.bind(this)),e},focusPath:function(e){if(i.isEqual(this._currentFocus,e))return;this._currentFocus&&this.blurPath(this._currentFocus);var t=i.first(e),n=i.rest(e),r=this.getWidgetInstance(t).focusInputPath;r&&r(n)},blurPath:function(e){if(!i.isEqual(this._currentFocus,e))return;var t=i.first(e),n=i.rest(e),r=this.getWidgetInstance(t);if(r){var s=this.getWidgetInstance(t).blurInputPath;s&&s(n)}},blur:function(){this._currentFocus&&this.blurPath(this._currentFocus)},serialize:function(){var e={};return i.each(this.state.widgetInfo,function(t,n){var r=this.getWidgetInstance(n),s=r.serialize();i.isEmpty(s)||(e[n]=s)},this),e},emptyWidgets:function(){return i.filter(this.widgetIds,function(e){var t=this._getWidgetInfo(e),n=this.getWidgetInstance(e).simpleValidate(t.options,null);return c.scoreIsEmpty(n)}.bind(this))},_setWidgetProps:function(e,t,n){var r=i.clone(this.state.widgetProps);r[e]=i.extend({},r[e],t),this.setState({widgetProps:r},function(){var t=n&&n();this.props.onInteractWithWidget(e),t!==!1&&this._setCurrentFocus([e])}.bind(this))},setInputValue:function(e,t,n){var r=i.first(e),s=i.rest(e),o=this.getWidgetInstance(r);o.setInputValue(s,t,n)},getUserInput:function(){return i.map(this.widgetIds,function(e){return this.getWidgetInstance(e).getUserInput()}.bind(this))},getWidgetIds:function(){return this.widgetIds},getAllWidgetIds:function(){return i.map(this.getWidgetIds(),function(e){var t="group";return e.substring(0,t.length)===t&&this.getWidgetInstance(e)?{id:e,children:this.getWidgetInstance(e).getRenderer().getAllWidgetIds()}:{id:e,children:[]}}.bind(this))},getUserInputForWidgets:function(){return g(this.widgetIds,function(e){return this.getWidgetInstance(e).getUserInput()}.bind(this))},scoreWidgets:function(){var e=this.state.widgetInfo,t=this.props.apiOptions.onInputError||function(){},n=i.filter(this.widgetIds,function(t){var n=e[t];return n.graded==null||n.graded}),r={};return i.each(n,function(n){var i=e[n],s=this.getWidgetInstance(n);if(!s)return;r[n]=s.simpleValidate(i.options,t)}.bind(this)),r},score:function(){return i.reduce(this.scoreWidgets(),c.combineScores,c.noScore)},guessAndScore:function(){var e=this.getUserInput(),t=this.score();return[e,t]},examples:function(){var e=this.widgetIds,t=i.compact(i.map(e,function(e){return e.examples?e.examples():null}));if(!t.length)return null;var n=i.all(t,function(e){return i.isEqual(t[0],e)});return n?t[0]:null}});e.exports=x},function(e,t,n){var r=n(66),i=n(62),s=n(11),o=r.createClass({displayName:"StatefulEditorPage",propTypes:{componentClass:r.PropTypes.func},getDefaultProps:function(){return{componentClass:s}},render:function(){return r.createElement(this.props.componentClass,r.__spread({},this.state))},getInitialState:function(){return i({}).extend(i.omit(this.props,"componentClass"),{onChange:this.handleChange,ref:"editor"})},componentWillReceiveProps:function(e){this.setState(i(e).omit("onChange","ref"))},getSaveWarnings:function(){return this.refs.editor.getSaveWarnings()},serialize:function(){return this.refs.editor.serialize()},handleChange:function(e,t){this.isMounted()&&this.setState(e,t)},scorePreview:function(){return this.refs.editor.scorePreview()}});e.exports=o},function(e,t,n){var r=n(65);e.exports={Options:{propTypes:React.PropTypes.shape({fancyDropdowns:React.PropTypes.bool.isRequired,onInputError:React.PropTypes.func.isRequired,onFocusChange:React.PropTypes.func.isRequired,staticRender:React.PropTypes.bool.isRequired,GroupMetadataEditor:React.PropTypes.func.isRequired,enableOldAnswerTypes:React.PropTypes.bool.isRequired,readOnly:React.PropTypes.bool.isRequired,groupAnnotator:React.PropTypes.func.isRequired}).isRequired,defaults:{fancyDropdowns:!1,onInputError:function(){},onFocusChange:function(){},staticRender:!1,GroupMetadataEditor:r,enableOldAnswerTypes:!1,readOnly:!1,groupAnnotator:function(){return null}}},ClassNames:{RENDERER:"perseus-renderer",TWO_COLUMN_RENDERER:"perseus-renderer-two-columns",INPUT:"perseus-input",FOCUSED:"perseus-focused",RADIO:{OPTION:"perseus-radio-option",SELECTED:"perseus-radio-selected",OPTION_CONTENT:"perseus-radio-option-content"},INTERACTIVE:"perseus-interactive",CORRECT:"perseus-correct",INCORRECT:"perseus-incorrect",UNANSWERED:"perseus-unanswered"}}},function(e,t,n){var r=n(60),i=n(61),s=function(e,t,n){var r=!1,i=_(t).reduce(function(e,t){return r||!e.hasOwnProperty(t)?(r=!0,n):e[t]},e);return i},o=function(e){var t=e.question||{},n=t.widgets||{};return _.keys(n)},u=function(e){return _.isObject(e)&&!("content"in e)},a=React.createClass({displayName:"RevisionDiff",propTypes:{beforeItem:React.PropTypes.object.isRequired,afterItem:React.PropTypes.object.isRequired},render:function(){var e=this.props.beforeItem,t=this.props.afterItem,n=0;_(e).has("hints")&&_(t).has("hints")&&(n=Math.max(e.hints.length,t.hints.length));var a=_.union(o(e),o(t)),f=[{title:"Question Area",path:["question"]},{title:"Answer Area",path:["answerArea","options"]}].concat(_.times(n,function(e){return{title:"Hint #"+(e+1),path:["hints",e]}})).concat(_.map(a,function(e){return{title:e,path:["question","widgets",e,"options"]}})),l=[];return _(f).each(function(n,o){var a=n.path,f=s(e,a,""),c=s(t,a,""),h;u(f)||u(c)?(u(f)||(f={}),u(c)||(c={}),h=React.createElement(i,{key:n.title,title:n.title,before:f,after:c})):h=React.createElement(r,{key:n.title,title:n.title,before:f.content,after:c.content}),l.push(React.createElement("div",{key:o},React.createElement("div",{className:"diff-header"},n.title),React.createElement("div",{className:"diff-header"},n.title),React.createElement("div",{className:"diff-body ui-helper-clearfix"},h)))}),React.createElement("div",null,l)}});e.exports=a},function(e,t,n){var r=n(62),i={},s={register:function(e,t){i[e]=t},getWidget:function(e,t){return r.has(i,e)?i[e].getWidget?i[e].getWidget(t):i[e].widget:null},getEditor:function(e){return r.has(i,e)?i[e].editor:null},getTransform:function(e){return r.has(i,e)?i[e].transform||r.identity:null},getVersion:function(e){var t=i[e];return t?i[e].version||{major:0,minor:0}:null},getVersionVector:function(){var e={};return r.each(r.keys(i),function(t){e[t]=s.getVersion(t)}),e},getPublicWidgets:function(){return r.pick(i,r.reject(r.keys(i),function(e){return i[e].hidden}))},isAccessible:function(e){var t=i[e.type].accessible;return typeof t=="function"?t(e.options):!!t},getAllWidgetTypes:function(){return r.keys(i)},upgradeWidgetInfoToLatestVersion:function(e){var t=e.type;if(!r.isString(t))throw new Error("widget type must be a string, but was: "+t);var n=i[t];if(n==null)return e;var s=e.version||{major:0,minor:0},o=n.version||{major:0,minor:0},u=s,a=r.clone(e.options)||{},f=n.propUpgrades||{};if(r.keys(a).length!==0)for(var l=s.major+1;l<=o.major;l++)f[l]?a=f[l](a):typeof console!="undefined"&&console.warn&&console.warn("No upgrade found for widget `"+t+"` from "+"major version `"+(l-1)+"` to "+"major version `"+l+"` found. This "+"is necessary to render this `"+t+"` correctly."),u=o;return r.extend({},e,{version:u,graded:e.graded!=null?e.graded:!0,options:a})},getRendererPropsForWidgetInfo:function(e,t){var n=e.type,s=i[n];if(s==null)return e.options;var o=s.transform||r.identity;return o(e.options,t)},traverseChildWidgets:function(e,t,n){if(!e||!e.type||!i[e.type])return;var r=i[e.type],s=r.traverseChildWidgets,o=e.options;s&&o&&s(o,t,n)}};e.exports=s},function(e,t,n){var r=n(66),i=n(71),s=n(72),o=n(73),u=n(62),a=n(16).ClassNames,f=n(74),l=n(64),c=n(14),h=n(75),p=n(5),d=r.createClass({displayName:"Categorizer",mixins:[o,i],propTypes:{items:r.PropTypes.arrayOf(r.PropTypes.string),categories:r.PropTypes.arrayOf(r.PropTypes.string),values:r.PropTypes.arrayOf(r.PropTypes.number)},getDefaultProps:function(){return{items:[],categories:[],values:[]}},getInitialState:function(){return{uniqueId:u.uniqueId("perseus_radio_")}},render:function(){var e=this,t=u.map(this.props.items,function(e,t){return[e,t]});return this.props.randomizeItems&&(t=p.shuffle(t,this.props.problemNum)),r.createElement("div",{className:"categorizer-container clearfix"},r.createElement("table",null,r.createElement("thead",null,r.createElement("tr",null,r.createElement("th",null," "),u.map(this.props.categories,function(e,t){return r.createElement("th",{className:"category",key:t},r.createElement(c,{content:e}))}))),r.createElement("tbody",null,u.map(t,function(t){var n=t[0],i=t[1],s=e.state.uniqueId+"_"+i;return r.createElement("tr",{key:i},r.createElement("td",null,r.createElement(c,{content:n})),u.range(e.props.categories.length).map(function(t){return r.createElement("td",{className:"category",key:t},r.createElement("div",{className:a.INTERACTIVE,onClick:this.onChange.bind(this,i,t)},r.createElement("input",{type:"radio",name:s,checked:e.props.values[i]===t,onChange:this.onChange.bind(this,i,t),onClick:function(e){return e.stopPropagation()}}),r.createElement("span",null)))}.bind(this)))}.bind(this)))))},onChange:function(e,t){var n=u.clone(this.props.values);n[e]=t,this.change("values",n)},simpleValidate:function(e){return d.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});u.extend(d,{validate:function(e,t){var n=!0,r=!0;return u.each(t.values,function(t,i){e.values[i]==null&&(n=!1),e.values[i]!==t&&(r=!1)}),n?{type:"points",earned:r?1:0,total:1,message:null}:{type:"invalid",message:"Make sure you select something for every row."}}});var v=r.createClass({displayName:"CategorizerEditor",mixins:[s,i],propTypes:{items:r.PropTypes.arrayOf(r.PropTypes.string),categories:r.PropTypes.arrayOf(r.PropTypes.string),values:r.PropTypes.arrayOf(r.PropTypes.number),randomizeItems:r.PropTypes.bool},getDefaultProps:function(){return{items:[],categories:[],values:[],randomizeItems:!1}},render:function(){return r.createElement("div",null,r.createElement("div",{className:"perseus-widget-row"},r.createElement(l,{label:"Randomize item order",labelAlignment:"right",randomizeItems:this.props.randomizeItems,onChange:this.props.onChange})),"Categories:",r.createElement(h,{options:this.props.categories,onChange:function(e){this.change("categories",e)}.bind(this),layout:"horizontal"}),"Items:",r.createElement(h,{options:this.props.items,onChange:function(e){this.change({items:e,values:u.first(this.props.values,e.length)})}.bind(this),layout:"vertical"}),r.createElement(d,{items:this.props.items,categories:this.props.categories,values:this.props.values,onChange:function(e){this.props.onChange(e)}.bind(this)}))}});e.exports={name:"categorizer",displayName:"Categorizer",widget:d,editor:v,transform:function(e){return u.pick(e,"items","categories","randomizeItems")}}},function(e,t,n){var r=n(109),i=n(77),s=n(74),o=n(66),u=n(62),a=i.Option,f=n(72),l=n(16).ClassNames,c=n(16).Options,h=n(5).captureScratchpadTouchStart,p=o.createClass({displayName:"Dropdown",propTypes:{choices:o.PropTypes.arrayOf(o.PropTypes.string),selected:o.PropTypes.number,placeholder:o.PropTypes.string,apiOptions:c.propTypes},getDefaultProps:function(){return{choices:[],selected:0,placeholder:"",apiOptions:c.defaults}},render:function(){var e=this.props.choices.slice(),t=r({"perseus-widget-dropdown":!0,"perseus-fancy-dropdown":this.props.apiOptions.fancyDropdowns});return this.props.apiOptions.fancyDropdowns?o.createElement(i,{onChange:this._handleChange,className:t+" "+l.INTERACTIVE,value:this.props.selected},o.createElement(a,{value:0,visible:!1},o.createElement("span",{className:"placeholder"},this.props.placeholder)),e.map(function(e,t){return o.createElement(a,{key:t+1,value:t+1,visible:!0},e)})):o.createElement("select",{onChange:this._handleChangeEvent,onTouchStart:h,className:t+" "+l.INTERACTIVE,value:this.props.selected},o.createElement("option",{value:0,disabled:!0},this.props.placeholder),e.map(function(e,t){return o.createElement("option",{key:""+(t+1),value:t+1},e)}))},focus:function(){return this.getDOMNode().focus(),!0},_handleChangeEvent:function(e){this._handleChange(parseInt(e.target.value))},_handleChange:function(e){this.props.onChange({selected:e})},getUserInput:function(){return{value:this.props.selected}},simpleValidate:function(e){return p.validate(this.getUserInput(),e)},statics:{displayMode:"inline-block"}});u.extend(p,{validate:function(e,t){var n=e.value;if(n===0)return{type:"invalid",message:null};var r=t.choices[n-1].correct;return{type:"points",earned:r?1:0,total:1,message:null}}});var d=o.createClass({displayName:"DropdownEditor",mixins:[f],propTypes:{choices:o.PropTypes.arrayOf(o.PropTypes.shape({content:o.PropTypes.string,correct:o.PropTypes.bool})),placeholder:o.PropTypes.string},getDefaultProps:function(){return{placeholder:"",choices:[{content:"",correct:!1}]}},render:function(){var e=u.uniqueId("perseus_dropdown_");return o.createElement("div",{className:"perseus-widget-dropdown"},o.createElement("div",null,"Dropdown",o.createElement(s,null,o.createElement("p",null,"The drop down is useful for making inequalities in a custom format. We normally use the symbols ","<",", ",">",', ≤, ≥ (in that order) which you can copy into the choices. When possible, use the "multiple choice" answer type instead.'))),o.createElement("input",{type:"text",placeholder:"Placeholder value",value:this.props.placeholder,onChange:this.onPlaceholderChange}),o.createElement(s,null,o.createElement("p",null,"This value will appear as the drop down default. It should give the user some indication of the values available in the drop down itself, e.g., Yes/No/Maybe.")),o.createElement("ul",null,this.props.choices.map(function(t,n){return o.createElement("li",{key:""+n},o.createElement("div",null,o.createElement("input",{ref:"radio"+n,type:"radio",name:e,checked:t.correct?"checked":"",onChange:this.onCorrectChange.bind(this,n),value:n}),o.createElement("input",{type:"text",ref:"editor"+n,onChange:this.onContentChange.bind(this,n),value:t.content}),o.createElement("a",{href:"#",className:"simple-button orange",onClick:this.removeChoice.bind(this,n)},o.createElement("span",{className:"icon-trash remove-choice"}))))},this)),o.createElement("div",{className:"add-choice-container"},o.createElement("a",{href:"#",className:"simple-button orange",onClick:this.addChoice},o.createElement("span",{className:"icon-plus"})," ","Add a choice"," ")))},onPlaceholderChange:function(e){var t=e.target.value;this.props.onChange({placeholder:t})},onCorrectChange:function(e){var t=u.map(this.props.choices,function(t,n){return u.extend({},t,{correct:n===e})});this.props.onChange({choices:t})},onContentChange:function(e,t){var n=this.props.choices.slice(),r=u.clone(n[e]);r.content=t.target.value,n[e]=r,this.props.onChange({choices:n})},addChoice:function(e){e.preventDefault();var t=this.props.choices,n={content:"",correct:!1};this.props.onChange({choices:t.concat([n])},this.focus.bind(this,t.length))},removeChoice:function(e,t){t.preventDefault();var n=u(this.props.choices).clone();n.splice(e,1),this.props.onChange({choices:n})},focus:function(e){return this.refs["editor"+e].getDOMNode().focus(),!0}}),v=function(e){return{placeholder:e.placeholder,choices:u.map(e.choices,function(e){return e.content})}};e.exports={name:"dropdown",displayName:"Drop down",accessible:!0,widget:p,editor:d,transform:v}},function(e,t,n){var r=n(66),i=n(71),s=n(72),o=n(62),u=r.createClass({displayName:"TextInput",render:function(){return r.createElement("input",{ref:"input",value:this.props.value||"",onChange:this.changeValue})},focus:function(){return this.refs.input.focus(),!0},changeValue:function(e){this.props.onChange(e.target.value)}}),a=r.createClass({displayName:"ExampleWidget",propTypes:{value:r.PropTypes.string},getDefaultProps:function(){return{value:""}},mixins:[i],render:function(){return r.createElement(u,{ref:"input",value:this.props.value,onChange:this.change("value")})},getUserInput:function(){return this.props.value},focus:function(){return this.refs.input.focus(),!0},simpleValidate:function(e){return a.validate(this.getUserInput(),e)},statics:{displayMode:"inline-block"}});o.extend(a,{validate:function(e,t){return e===""?{type:"invalid",message:"It looks like you haven't answered all of the question yet."}:e===t.correct?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}}});var f=r.createClass({displayName:"ExampleWidgetEditor",mixins:[i,s],getDefaultProps:function(){return{correct:""}},handleAnswerChange:function(e){this.change({correct:e.target.value})},render:function(){return r.createElement("div",null,r.createElement("label",null,"Correct answer:",r.createElement("input",{value:this.props.correct,onChange:this.handleAnswerChange,ref:"input"})))},focus:function(){return this.refs.input.focus(),!0}});e.exports={name:"example-widget",displayName:"Example Widget",hidden:!0,widget:a,editor:f}},function(e,t,n){var r=n(66),i=n(62),s=n(5),o=n(71),u=n(72),a=n(73),f=n(76),l=f.MovablePoint,c=n(108).number,h=n(108).point,p=r.createClass({displayName:"ExampleGraphieWidget",mixins:[o,a],propTypes:{graph:r.PropTypes.object.isRequired,coord:r.PropTypes.arrayOf(r.PropTypes.number)},getDefaultProps:function(){return{coord:null,graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],valid:!0,backgroundImage:null,markings:"grid",showProtractor:!1}}},render:function(){return r.createElement(f,{ref:"graphie",box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this.setupGraphie},r.createElement(l,{pointSize:5,coord:this.props.coord||[0,0],constraints:[l.constraints.snap(),l.constraints.bound()],onMove:this.movePoint}))},movePoint:function(e){this.change({coord:e})},_getGridConfig:function(e){return i.map(e.step,function(t,n){return s.gridDimensionConfig(t,e.range[n],e.box[n],e.gridStep[n])})},setupGraphie:function(e,t){var n=this._getGridConfig(t);e.graphInit({range:t.range,scale:i.pluck(n,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,tickStep:i.pluck(n,"tickStep"),labelStep:1,unityLabels:i.pluck(n,"unityLabel")}),e.label([0,t.range[1][1]],t.labels[1],"above")},simpleValidate:function(e){return p.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});i.extend(p,{validate:function(e,t){return e.coord==null?{type:"invalid",message:null}:h.equal(e.coord,t.correct)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}}});var d=r.createClass({displayName:"ExampleGraphieWidgetEditor",mixins:[o,u],getDefaultProps:function(){return{correct:[4,4],graph:{box:[340,340],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],valid:!0,backgroundImage:null,markings:"grid",showProtractor:!1}}},render:function(){return r.createElement("div",null,r.createElement(p,{graph:this.props.graph,coord:this.props.correct,onChange:this.handleChange}))},handleChange:function(e){e.coord&&this.change({correct:e.coord})}});e.exports={name:"example-graphie-widget",displayName:"Example Graphie Widget",hidden:!0,widget:p,editor:d}},function(e,t,n){var r=n(109),i=n(74),s=n(66),o=n(78),u=n(79),a=n(62),f=n(16).Options,l=n(71),c=n(72),h=n(73),f=n(16).Options,p=n(16).ClassNames,d=n(54),v=n(64),m=n(80),g=n(81),y=n(70),b=n(82),d=n(54),w=n(110),E=$._("Sorry, I don't understand that!"),S=["An expression without an answer","is no expression to me.","Who can learn from an input","like the one that I see?","Put something in there","won't you please?","A few digits will do -","might I suggest some threes?"].join("\n"),x="This question is probably going to be too hard because the expression has no correct answer.",T=function(e){return'"'+e+'" is required to be simplified but is not considered '+"simplified by our fancy computer algebra system. This will be "+"graded as incorrect."},N=function(e){return'"'+e+"\" <- you sure that's math?"},C=function(e){return"mind filling in answer "+e+"? (the blank one)"},k=s.createClass({displayName:"Expression",mixins:[l],propTypes:{value:s.PropTypes.string,times:s.PropTypes.bool,functions:s.PropTypes.arrayOf(s.PropTypes.string),buttonSets:b.buttonSetsType,buttonsVisible:s.PropTypes.oneOf(["always","never","focused"]),enabledFeatures:d.propTypes,apiOptions:f.propTypes},getDefaultProps:function(){return{value:"",times:!1,functions:[],buttonSets:["basic","trig","prealgebra","logarithms"],onFocus:function(){},onBlur:function(){},enabledFeatures:d.defaults,apiOptions:f.defaults}},getInitialState:function(){return{showErrorTooltip:!1,showErrorText:!1}},parse:function(e,t){var n=a.pick(t||this.props,"functions");return window.icu&&window.icu.getDecimalFormatSymbols&&a.extend(n,window.icu.getDecimalFormatSymbols()),KAS.parse(e,n)},render:function(){if(this.props.apiOptions.staticRender)return s.createElement(m,{ref:"input",value:this.props.value,type:"tex",examples:[],shouldShowExamples:!1,onChange:this.change("value"),onFocus:this._handleFocus,onBlur:this._handleBlur});var e=s.createElement("span",{className:"error-tooltip"},s.createElement(u,{className:"error-text-container",horizontalPosition:"right",horizontalAlign:"left",verticalPosition:"top",arrowSize:10,borderColor:"#fcc335",show:this.state.showErrorText},s.createElement("i",{className:"icon-exclamation-sign error-icon",onMouseEnter:function(){this.setState({showErrorText:!0})}.bind(this),onMouseLeave:function(){this.setState({showErrorText:!1})}.bind(this),onClick:function(){this.setState({showErrorText:!this.state.showErrorText})}.bind(this)}),s.createElement("div",{className:"error-text"},E))),t=r({"perseus-widget-expression":!0,"show-error-tooltip":this.state.showErrorTooltip});return s.createElement("span",{className:t},s.createElement(g,{ref:"input",className:p.INTERACTIVE,value:this.props.value,onChange:this.change("value"),convertDotToTimes:this.props.times,buttonsVisible:this.props.buttonsVisible||"focused",buttonSets:this.props.buttonSets,onFocus:this._handleFocus,onBlur:this._handleBlur}),this.state.showErrorTooltip&&e)},_handleFocus:function(){this.props.onFocus([])},_handleBlur:function(){this.props.onBlur([])},errorTimeout:null,componentWillReceiveProps:function(e){if(!a.isEqual(this.props.value,e.value)||!a.isEqual(this.props.functions,e.functions))clearTimeout(this.errorTimeout),this.parse(e.value,e).parsed?this.setState({showErrorTooltip:!1}):this.errorTimeout=setTimeout(function(){var e=this.props.apiOptions.onInputError(null,this.props.value,E);e!==!1&&this.setState({showErrorTooltip:!0})}.bind(this),2e3)},componentWillUnmount:function(){clearTimeout(this.errorTimeout)},focus:function(){return!0},focusInputPath:function(e){this.refs.input.focus()},blurInputPath:function(e){this.refs.input.blur()},insert:function(e){this.props.apiOptions.staticRender||this.refs.input.insert(e)},getInputPaths:function(){return[[]]},getGrammarTypeForPath:function(e){return"expression"},setInputValue:function(e,t,n){this.props.onChange({value:t},n)},getAcceptableFormatsForInputPath:function(){return null},getUserInput:function(){return this.props.value},simpleValidate:function(e,t){return t=t||function(){},k.validate(this.getUserInput(),e,t)},statics:{displayMode:"inline-block"}});a.extend(k,{validate:function(e,t,n){var r=a.clone(t);window.icu&&window.icu.getDecimalFormatSymbols&&a.extend(r,window.icu.getDecimalFormatSymbols());var i=function(e){return Khan.answerTypes.expression.createValidatorFunctional(KAS.parse(e.value,t).expr,a({}).extend(r,{simplify:e.simplify,form:e.form}))},s,o,u=!0,f=!!a(t.answerForms).find(function(t){var n=i(t);return s=n(e),o=t,u=u&&s.empty,s.correct}),l=s&&s.message;if(!f)return u?{type:"invalid",message:null}:{type:"points",earned:0,total:1};if(o.considered==="ungraded"){var c=n(null,e,l);return{type:"invalid",message:c===!1?null:l}}return{type:"points",earned:o.considered==="correct"?1:0,total:1,message:l}}});var L=s.createClass({displayName:"OldExpression",propTypes:{value:s.PropTypes.string,times:s.PropTypes.bool,functions:s.PropTypes.arrayOf(s.PropTypes.string),enabledFeatures:d.propTypes},getDefaultProps:function(){return{value:"",times:!1,functions:[],onFocus:function(){},onBlur:function(){},enabledFeatures:d.defaults,apiOptions:f.defaults}},getInitialState:function(){return{lastParsedTex:""}},parse:function(e,t){var n=a.pick(t||this.props,"functions");return window.icu&&window.icu.getDecimalFormatSymbols&&a.extend(n,window.icu.getDecimalFormatSymbols()),KAS.parse(e,n)},componentWillMount:function(){this.updateParsedTex(this.props.value)},componentWillReceiveProps:function(e){this.updateParsedTex(e.value,e)},render:function(){var e=this.parse(this.props.value),t=this.props.enabledFeatures.toolTipFormats;return s.createElement("span",{className:"perseus-widget-expression-old"},s.createElement("span",{className:"output"},s.createElement("span",{className:"tex",style:{opacity:e.parsed?1:.5}},s.createElement(y,null,this.state.lastParsedTex)),s.createElement("span",{className:"placeholder"},s.createElement("span",{ref:"error",className:"error",style:{display:"none"}},s.createElement("span",{className:"buddy"}),s.createElement("span",{className:"message"},s.createElement("span",null,E))))),s.createElement(m,{ref:"input",value:this.props.value,onKeyDown:this.handleKeyDown,onKeyPress:this.handleKeyPress,onChange:this.handleChange,examples:this.examples(),shouldShowExamples:t,onFocus:this._handleFocus,onBlur:this._handleBlur}))},_handleFocus:function(){this.props.onFocus([])},_handleBlur:function(){this.props.onBlur([])},errorTimeout:null,componentDidMount:function(){this.componentDidUpdate()},componentDidUpdate:function(){clearTimeout(this.errorTimeout),this.parse(this.props.value).parsed?this.hideError():this.errorTimeout=setTimeout(this.showError,2e3)},componentWillUnmount:function(){clearTimeout(this.errorTimeout)},showError:function(){var e=this.props.apiOptions.onInputError(null,this.props.value,E);if(e!==!1){var t=$(this.refs.error.getDOMNode());t.is(":visible")||t.css({top:50,opacity:.1}).show().animate({top:0,opacity:1},300)}else this.hideError()},hideError:function(){var e=$(this.refs.error.getDOMNode());e.is(":visible")&&e.animate({top:50,opacity:.1},300,function(){$(this).hide()})},handleKeyDown:function(e){var t=this.refs.input.getDOMNode(),n=t.value,r=t.selectionStart,i=t.selectionEnd,s=r!==undefined,o=e.nativeEvent.keyCode;if(s&&o===8&&r===i&&n.slice(r-1,r+1)==="()"){e.preventDefault();var u=n.slice(0,r-1)+n.slice(r+1);t.value=u,t.selectionStart=r-1,t.selectionEnd=i-1,this.props.onChange({value:u})}},handleKeyPress:function(e){var t=this.refs.input.getDOMNode(),n=t.value,r=t.selectionStart,i=t.selectionEnd,s=r!==undefined,o=e.nativeEvent.charCode;if(s&&o===40){e.preventDefault();var u;if(r===i){var f=a.any([" ",")",""],function(e){return n.charAt(r)===e});u=n.slice(0,r)+(f?"()":"(")+n.slice(i)}else u=n.slice(0,r)+"("+n.slice(r,i)+")"+n.slice(i);t.value=u,t.selectionStart=r+1,t.selectionEnd=i+1,this.props.onChange({value:u})}else s&&o===41&&r===i&&n.charAt(r)===")"&&(e.preventDefault(),t.selectionStart=r+1,t.selectionEnd=i+1)},handleChange:function(e){this.props.onChange({value:e})},focus:function(){return this.refs.input.focus(),!0},getInputPaths:function(){return[[]]},getGrammarTypeForPath:function(e){return"expression"},getUserInput:function(){return this.props.value},updateParsedTex:function(e,t){var n=this.parse(e,t),r=a.pick(this.props,"times");n.parsed&&this.setState({lastParsedTex:n.expr.asTex(r)})},simpleValidate:function(e,t){return t=t||function(){},k.validate(this.getUserInput(),e,t)},examples:function(){var e=$._("For $2\\cdot2$, enter **2*2**");return this.props.times&&(e=e.replace(/\\cdot/g,"\\times")),[$._("**Acceptable Formats**"),e,$._("For $3y$, enter **3y** or **3*y**"),$._("For $\\dfrac{1}{x}$, enter **1/x**"),$._("For $\\dfrac{1}{xy}$, enter **1/(xy)**"),$._("For $\\dfrac{2}{x + 3}$, enter **2/(x + 3)**"),$._("For $x^{y}$, enter **x^y**"),$._("For $x^{2/3}$, enter **x^(2/3)**"),$._("For $\\sqrt{x}$, enter **sqrt(x)**"),$._("For $\\pi$, enter **pi**"),$._("For $\\sin \\theta$, enter **sin(theta)**"),$._("For $\\le$ or $\\ge$, enter **<=** or **>=**"),$._("For $\\neq$, enter **=/=**")]},statics:{displayMode:"block"}}),A=["correct","wrong","ungraded"],O=s.PropTypes.shape({considered:s.PropTypes.oneOf(A).isRequired,value:s.PropTypes.string.isRequired,form:s.PropTypes.bool.isRequired,simplify:s.PropTypes.bool.isRequired}),M=s.createClass({displayName:"ExpressionEditor",mixins:[l],propTypes:{answerForms:s.PropTypes.arrayOf(O),times:s.PropTypes.bool,buttonSets:b.buttonSetsType,functions:s.PropTypes.arrayOf(s.PropTypes.string)},getDefaultProps:function(){return{answerForms:[],times:!1,buttonSets:["basic"],functions:["f","g","h"]}},getInitialState:function(){var e;return this.props.answerForms.length===0?e=!0:e=a(this.props.answerForms).any(function(e){var t=e,n=t.value;return a.indexOf(n,"\\")!==-1||a.indexOf(n,"{")!==-1}),{isTex:e}},render:function(){var e=this.state.isTex?k:L,t=this.props.answerForms.map(function(e,t){var n={times:this.props.times,functions:this.props.functions,buttonSets:this.props.buttonSets,buttonsVisible:"focused",form:e.form,simplify:e.simplify,value:e.value,onChange:function(e){return this.updateForm(t,e)}.bind(this)};return w(e).merge([],{draggable:!0,onChange:function(e){return this.updateForm(t,e)}.bind(this),onDelete:function(){return this.handleRemoveForm(t)}.bind(this),expressionProps:n}).freeze()}.bind(this)).map(function(e){return s.createElement(D,s.__spread({},e))}),n=s.createElement(o,{components:t,onReorder:this.handleReorder,className:"answer-options-list"}),r=this.state.isTex?k:L,u=a(b.buttonSets).map(function(e,t){var n=t==="basic",r=a.contains(this.props.buttonSets,t)||n,i=n?"button-set-label-float":"button-set-label";return s.createElement("label",{className:i,key:t},s.createElement("input",{type:"checkbox",checked:r,disabled:n,onChange:function(){return this.handleButtonSet(t)}.bind(this)}),t)}.bind(this));return u.splice(1,1,s.createElement("label",{key:"show-div"},s.createElement("input",{type:"checkbox",onChange:this.handleToggleDiv}),s.createElement("span",{className:"show-div-button"},"show ",s.createElement(y,null,"\\div")," button"))),s.createElement("div",{className:"perseus-widget-expression-editor"},s.createElement("h3",{className:"expression-editor-h3"},"Global Options"),s.createElement("div",null,s.createElement(v,{times:this.props.times,onChange:this.props.onChange,labelAlignment:"right",label:"Use × for rendering multiplication instead of a center dot."}),s.createElement(i,null,s.createElement("p",null,"For pre-algebra problems this option displays multiplication as \\times instead of \\cdot in both the rendered output and the acceptable formats examples."))),s.createElement("div",null,s.createElement("label",null,"Function variables: ",s.createElement("input",{type:"text",defaultValue:this.props.functions.join(" "),onChange:this.handleFunctions})),s.createElement(i,null,s.createElement("p",null,'Single-letter variables listed here will be interpreted as functions. This let us know that f(x) means "f of x" and not "f times x".'))),s.createElement("div",null,s.createElement("div",null,"Button sets:"),u),this.state.isTex&&s.createElement(b,{className:"math-input-buttons",sets:this.props.buttonSets,convertDotToTimes:this.props.times,onInsert:this.handleTexInsert}),s.createElement("h3",{className:"expression-editor-h3"},"Answers"),s.createElement("p",{style:{margin:"4px 0"}},"student responses area matched against these from top to bottom"),n,s.createElement("div",null,s.createElement("button",{className:"simple-button orange",style:{fontSize:13},onClick:this.newAnswer,type:"button"},"Add new answer")))},serialize:function(){var e=["value","form","simplify","considered","key"],t=["answerForms","buttonSets","functions","times"],n=this.props.answerForms.map(function(t){return a(t).pick(e)});return w(this.props).set(["answerForms"],n).mod([],function(e){return a(e).pick(t)}).freeze()},getSaveWarnings:function(){var e=[];if(this.props.answerForms.length===0)e.push("No answers specified");else{var t=!!a(this.props.answerForms).find(function(e){return e.considered==="correct"});t||e.push("No correct answer specified"),a(this.props.answerForms).each(function(t,n){if(this.props.value==="")e.push("Answer "+(n+1)+" is empty");else{var r=KAS.parse(t.value);r.parsed?t.simplify&&!r.expr.isSimplified()&&e.push(t.value+' isn\'t simplified, but is required" +\n                            " to be'):e.push("Couldn't parse "+t.value)}}.bind(this))}return e},_newEmptyAnswerForm:function(){return{considered:"correct",form:!1,key:this.props.answerForms.length,simplify:!1,value:""}},newAnswer:function(){var e=this.props.answerForms.slice();e.push(this._newEmptyAnswerForm()),this.change({answerForms:e})},handleRemoveForm:function(e){var t=this.props.answerForms.slice(0,-1);this.change({answerForms:t})},updateForm:function(e,t){var n=w(this.props.answerForms).merge([e],t).freeze();this.change({answerForms:n})},handleReorder:function(e){var t=a(e).map(function(e){var t=a(e.props).pick("considered","form","simplify","value");return t.key=e.key,t});this.change({answerForms:t})},handleButtonSet:function(e){var t=a(b.buttonSets).keys(),n=a(t).filter(function(t){return a(this.props.buttonSets).contains(t)!==(t===e)}.bind(this));this.props.onChange({buttonSets:n})},handleToggleDiv:function(){var e,t;a(this.props.buttonSets).contains("basic+div")?(e="basic",t="basic+div"):(e="basic+div",t="basic");var n=a(this.props.buttonSets).reject(function(e){return e===t}).concat(e);this.change("buttonSets",n)},handleTexInsert:function(e){this.refs.expression.insert(e)},handleFunctions:function(e){var t={};t.functions=a.compact(e.target.value.split(/[ ,]+/)),this.props.onChange(t)}}),_=function(e,t){var n=a(e).indexOf(t);return n=(n+1)%e.length,e[n]},D=s.createClass({displayName:"AnswerOption",mixins:[l],propTypes:{considered:s.PropTypes.oneOf(A).isRequired,expressionProps:s.PropTypes.object.isRequired,form:s.PropTypes.bool.isRequired,simplify:s.PropTypes.bool.isRequired,onChange:s.PropTypes.func.isRequired,onDelete:s.PropTypes.func.isRequired},getInitialState:function(){return{deleteFocused:!1}},handleDeleteBlur:function(){this.setState({deleteFocused:!1})},render:function(){var e=null;return this.state.deleteFocused?e=s.createElement("button",{type:"button",className:"simple-button orange",onClick:this.handleImSure,onBlur:this.handleDeleteBlur},"I'm sure!"):e=s.createElement("button",{type:"button",className:"simple-button orange",onClick:this.handleDelete},"Delete"),s.createElement("div",{className:"expression-answer-option"},s.createElement("div",{className:"answer-handle"}),s.createElement("div",{className:"answer-body"},s.createElement("div",{className:"answer-considered"},s.createElement("div",{onClick:this.toggleConsidered,className:"answer-status "+this.props.considered},this.props.considered),s.createElement("div",{className:"answer-expression"},s.createElement(k,s.__spread({},this.props.expressionProps)))),s.createElement("div",{className:"answer-option"},s.createElement(v,{form:this.props.form,onChange:this.props.onChange,labelAlignment:"right",label:"Answer expression must have the same form."}),s.createElement(i,null,s.createElement("p",null,"The student's answer must be in the same form. Commutativity and excess negative signs are ignored."))),s.createElement("div",{className:"answer-option"},s.createElement(v,{simplify:this.props.simplify,onChange:this.props.onChange,labelAlignment:"right",label:"Answer expression must be fully expanded and simplified."}),s.createElement(i,null,s.createElement("p",null,'The student\'s answer must be fully expanded and simplified. Answering this equation (x^2+2x+1) with this factored equation (x+1)^2 will render this response "Your answer is not fully expanded and simplified."'))),s.createElement("div",{className:"remove-container"},e)))},handleImSure:function(){this.props.onDelete()},handleDelete:function(){this.setState({deleteFocused:!0})},toggleConsidered:function(){var e=_(A,this.props.considered);this.change({considered:e})}});propUpgrades={1:function(e){return{times:e.times,buttonSets:e.buttonSets,functions:e.functions,buttonsVisible:e.buttonsVisible,answerForms:[{considered:"correct",form:e.form,simplify:e.simplify,value:e.value,key:0}]}}},e.exports={name:"expression",displayName:"Expression / Equation",getWidget:function(e){return e.useMathQuill?k:L},editor:M,transform:function(e){return a.pick(e,"times","functions","buttonSets","buttonsVisible","answerForms")},version:{major:1,minor:0},propUpgrades:propUpgrades}},function(e,t,n){function x(e){var t=e.charAt(0).toUpperCase()+e.substring(1);return{value:e,title:t,content:React.createElement("img",{src:I(e).url,alt:t})}}function T(e,t,n){var r=function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])};return r(n[0],n[1],t)>0!=r(n[0],n[1],e)>0}function N(e){var t=e[0],n=e[1],r=e[2],i=e[3];t<0&&(t*=-1,n*=-1,r*=-1);var s=2*Math.PI;n<0&&(n*=-1,r*=-1,r+=s/2);while(r>0)r-=s;while(r<0)r+=s;return[t,n,r,i]}function C(e){var t=e[0],n=e[1],r=e[2],i=e[3];t<0&&(t*=-1,n*=-1,r*=-1);var s=Math.PI;n<0&&(n*=-1,r*=-1,r+=s/2);while(r>0)r-=s;while(r<0)r+=s;return[t,n,r,i]}function I(e){return j[e]}var r=n(62),i=n(83),s=n(84),o=n(74),u=n(85),a=n(86),f=n(63),l=n(5),c=n(76),h=c.MovablePoint,p=c.Plot,d=c.MovableLine,v=n(108).number,m=n(108).vector,g=n(108).point,y=n(71),b=400,w=340,E={url:null},S="linear",k={padding:"5px 5px"},L=React.createClass({displayName:"FunctionGrapher",mixins:[y],_coords:function(e){e=e||this.props;var t=e.model&&e.model.defaultCoords&&q.pointsFromNormalized(e.graph.range,e.graph.step,e.graph.snapStep,e.model.defaultCoords);return e.coords||t||null},_asymptote:function(e){e=e||this.props;var t=e.model&&e.model.defaultAsymptote&&q.pointsFromNormalized(e.graph.range,e.graph.step,e.graph.snapStep,e.model.defaultAsymptote);return e.asymptote||t||null},getDefaultProps:function(){return{graph:{range:[[-10,10],[-10,10]],step:[1,1]},coords:null,asymptote:null}},render:function(){var e=function(e,t){return React.createElement(h,{key:t,coord:e,constraints:[u.MovablePoint.constraints.bound(),u.MovablePoint.constraints.snap(),function(e){var n=r.all(this._coords(),function(n,r){return t===r||!n||!v.equal(e[0],n[0])});if(!n)return!1;if(this.props.model&&this.props.model.extraCoordConstraint){var i=this.props.model.extraCoordConstraint,s=r.clone(this._coords()),o=r.clone(s[t]);return s[t]=e,i(e,o,s,this._asymptote(),this.props.graph)}return n}.bind(this)],onMove:function(e,n){var i,s=this._asymptote();s&&this.props.model.allowReflectOverAsymptote&&T(e,n,s)?i=r.map(this._coords(),function(e){return g.reflectOverLine(e,s)}):i=r.clone(this._coords()),i[t]=e,this.props.onChange({coords:i})}.bind(this)})}.bind(this),t=r.map(this._coords(),e),n=this.props.graph.box,i=this.props.graph.backgroundImage,s=null;if(i.url){var o=n[0]/b;s=React.createElement(f,{src:i.url,width:i.width,height:i.height,scale:o})}return React.createElement("div",{className:"perseus-widget perseus-widget-grapher",style:{width:n[0],height:this.props.flexibleType?"auto":n[1]}},React.createElement("div",{className:"graphie-container above-scratchpad",style:{width:n[0],height:n[1]}},s,React.createElement(c,React.__spread({},this.props.graph),this.props.model&&this.renderPlot(),this.props.model&&this.renderAsymptote(),this.props.model&&t)))},renderPlot:function(){var e=this.props.model,t=this.props.graph.range[0],n={stroke:KhanUtil.DYNAMIC},r=e.getCoefficients(this._coords(),this._asymptote());if(!r)return;var i=e.getPropsForCoeffs(r,t);return React.createElement(e.Movable,React.__spread({},i,{key:this.props.model.url,range:t,style:n}))},renderAsymptote:function(){var e=this.props.model,t=this.props.graph,n=this._asymptote(),i={strokeDasharray:"- "};return n&&React.createElement(d,{onMove:function(e,t){var n=m.subtract(e,t),i=r.map(this._asymptote(),function(e){return m.add(e,n)});this.props.onChange({asymptote:i})}.bind(this),constraints:[u.MovableLine.constraints.bound(),u.MovableLine.constraints.snap(),function(n,i){var s=m.subtract(n,i),o=r.map(this._asymptote(),function(e){return m.add(e,s)});return e.extraAsymptoteConstraint?e.extraAsymptoteConstraint(n,i,this._coords(),o,t):!0}.bind(this)],normalStyle:i,highlightStyle:i},r.map(n,function(e){return React.createElement(h,{coord:e,"static":!0,draw:null,extendLine:!0})}))}}),A={areEqual:function(e,t){return l.deepEq(e,t)},Movable:p,getPropsForCoeffs:function(e){return{fn:r.partial(this.getFunctionForCoeffs,e)}}},O=r.extend({},A,{url:"https://ka-perseus-graphie.s3.amazonaws.com/67aaf581e6d9ef9038c10558a1f70ac21c11c9f8.png",defaultCoords:[[.25,.75],[.75,.75]],getCoefficients:function(e){var t=e[0],n=e[1],r=n[0]-t[0],i=n[1]-t[1];if(r===0)return;var s=i/r,o=n[1]-s*n[0];return[s,o]},getFunctionForCoeffs:function(e,t){var n=e[0],r=e[1];return n*t+r},getEquationString:function(e){var t=this.getCoefficients(e),n=t[0],r=t[1];return"y = "+n.toFixed(3)+"x + "+r.toFixed(3)}}),M=r.extend({},A,{url:"https://ka-perseus-graphie.s3.amazonaws.com/e23d36e6fc29ee37174e92c9daba2a66677128ab.png",defaultCoords:[[.5,.5],[.75,.75]],Movable:c.Parabola,getCoefficients:function(e){var t=e[0],n=e[1],r=t[0],i=t[1],s=(n[1]-i)/((n[0]-r)*(n[0]-r)),o=-2*r*s,u=s*r*r+i;return[s,o,u]},getFunctionForCoeffs:function(e,t){var n=e[0],r=e[1],i=e[2];return(n*t+r)*t+i},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2]}},getEquationString:function(e){var t=this.getCoefficients(e),n=t[0],r=t[1],i=t[2];return"y = "+n.toFixed(3)+"x^2 + "+r.toFixed(3)+"x + "+i.toFixed(3)}}),_=r.extend({},A,{url:"https://ka-perseus-graphie.s3.amazonaws.com/3d68e7718498475f53b206c2ab285626baf8857e.png",defaultCoords:[[.5,.5],[.6,.6]],Movable:c.Sinusoid,getCoefficients:function(e){var t=e[0],n=e[1],r=n[1]-t[1],i=Math.PI/(2*(n[0]-t[0])),s=t[0]*i,o=t[1];return[r,i,s,o]},getFunctionForCoeffs:function(e,t){var n=e[0],r=e[1],i=e[2],s=e[3];return n*Math.sin(r*t-i)+s},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2],d:e[3]}},getEquationString:function(e){var t=this.getCoefficients(e),n=t[0],r=t[1],i=t[2],s=t[3];return"y = "+n.toFixed(3)+" sin("+r.toFixed(3)+"x - "+i.toFixed(3)+") + "+s.toFixed(3)},areEqual:function(e,t){return l.deepEq(N(e),N(t))}}),D=r.extend({},A,{url:"https://ka-perseus-graphie.s3.amazonaws.com/7db80d23c35214f98659fe1cf0765811c1bbfbba.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){var t=e[0],n=e[1],r=n[1]-t[1],i=Math.PI/(4*(n[0]-t[0])),s=t[0]*i,o=t[1];return[r,i,s,o]},getFunctionForCoeffs:function(e,t){var n=e[0],r=e[1],i=e[2],s=e[3];return n*Math.tan(r*t-i)+s},getEquationString:function(e){var t=this.getCoefficients(e),n=t[0],r=t[1],i=t[2],s=t[3];return"y = "+n.toFixed(3)+" sin("+r.toFixed(3)+"x - "+i.toFixed(3)+") + "+s.toFixed(3)},areEqual:function(e,t){return l.deepEq(C(e),C(t))}}),P=r.extend({},A,{url:"https://ka-perseus-graphie.s3.amazonaws.com/9cbfad55525e3ce755a31a631b074670a5dad611.png",defaultCoords:[[.5,.55],[.75,.75]],defaultAsymptote:[[0,.5],[1,.5]],extraCoordConstraint:function(e,t,n,i,s){var o=r.head(i)[1];return r.all(n,function(e){return e[1]!==o})},extraAsymptoteConstraint:function(e,t,n,i,s){var o=e[1],u=r.all(n,function(e){return e[1]>o})||r.all(n,function(e){return e[1]<o});if(u)return[t[0],o];var a=t[1],f=r.all(n,function(e){return e[1]>a});if(f){var l=r.min(r.map(n,function(e){return e[1]}));return[t[0],l-s.snapStep[1]]}var c=r.max(r.map(n,function(e){return e[1]}));return[t[0],c+s.snapStep[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){var n=e[0],i=e[1],s=r.head(t)[1],o=Math.log((n[1]-s)/(i[1]-s))/(n[0]-i[0]),u=(n[1]-s)/Math.exp(o*n[0]);return[u,o,s]},getFunctionForCoeffs:function(e,t){var n=e[0],r=e[1],i=e[2];return n*Math.exp(r*t)+i},getEquationString:function(e,t){if(!t)return null;var n=this.getCoefficients(e,t),r=n[0],i=n[1],s=n[2];return"y = "+r.toFixed(3)+"e^("+i.toFixed(3)+"x) + "+s.toFixed(3)}}),H=r.extend({},A,{url:"https://ka-perseus-graphie.s3.amazonaws.com/f6491e99d34af34d924bfe0231728ad912068dc3.png",defaultCoords:[[.55,.5],[.75,.75]],defaultAsymptote:[[.5,0],[.5,1]],extraCoordConstraint:function(e,t,n,i,s){var o=r.head(i)[0];return r.all(n,function(e){return e[0]!==o})&&n[0][1]!==n[1][1]},extraAsymptoteConstraint:function(e,t,n,i,s){var o=e[0],u=r.all(n,function(e){return e[0]>o})||r.all(n,function(e){return e[0]<o});if(u)return[o,t[1]];var a=t[0],f=r.all(n,function(e){return e[0]>a});if(f){var l=r.min(r.map(n,function(e){return e[0]}));return[l-s.snapStep[0],t[1]]}var c=r.max(r.map(n,function(e){return e[0]}));return[c+s.snapStep[0],t[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){var n=function(e){return[e[1],e[0]]},i=P.getCoefficients(r.map(e,n),r.map(t,n)),s=-i[2]/i[0],o=1/i[0],u=1/i[1];return[u,o,s]},getFunctionForCoeffs:function(e,t,n){var r=e[0],i=e[1],s=e[2];return r*Math.log(i*t+s)},getEquationString:function(e,t){if(!t)return null;var n=this.getCoefficients(e,t),r=n[0],i=n[1],s=n[2];return"y = ln("+r.toFixed(3)+"x + "+i.toFixed(3)+") + "+s.toFixed(3)}}),B=r.extend({},A,{url:"https://ka-perseus-graphie.s3.amazonaws.com/8256a630175a0cb1d11de223d6de0266daf98721.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){var t=e[0],n=e[1],r=n[0]-t[0],i=n[1]-t[1];if(r===0)return;var s=Math.abs(i/r);n[1]<t[1]&&(s*=-1);var o=t[0],u=t[1];return[s,o,u]},getFunctionForCoeffs:function(e,t){var n=e[0],r=e[1],i=e[2];return n*Math.abs(t-r)+i},getEquationString:function(e){var t=this.getCoefficients(e),n=t[0],r=t[1],i=t[2];return"y = "+n.toFixed(3)+"| x - "+r.toFixed(3)+"| + "+i.toFixed(3)}}),j={linear:O,quadratic:M,sinusoid:_,tangent:D,exponential:P,logarithm:H,absolute_value:B},F=r.keys(j),q=React.createClass({displayName:"Grapher",getDefaultProps:function(){return{plot:{type:S,coords:null,asymptote:null},graph:{box:[b,b],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:E,markings:"graph",rulerLabel:"",rulerTicks:10,valid:!0},availableTypes:[S]}},render:function(){var e=this.props.plot.type,t=this.props.plot.coords,n=this.props.plot.asymptote,s=React.createElement("div",{style:k,className:"above-scratchpad"},React.createElement(i,{value:e,allowEmpty:!0,buttons:r.map(this.props.availableTypes,x),onChange:this.handleActiveTypeChange})),o=this.props.graph.box,u=r.extend({},this.props.graph,this._getGridAndSnapSteps(this.props.graph));r.extend(u,{gridConfig:this._getGridConfig(u)});var a={graph:{box:o,range:u.range,step:u.step,snapStep:u.snapStep,backgroundImage:u.backgroundImage,options:u,setup:this._setupGraphie},onChange:this.handlePlotChanges,model:e&&I(e),coords:t,asymptote:n};return React.createElement("div",null,React.createElement(L,React.__spread({},a)),this.props.availableTypes.length>1&&s)},handlePlotChanges:function(e){var t=r.extend({},this.props.plot,e);this.props.onChange({plot:t})},handleActiveTypeChange:function(e){var t=r.extend({},this.props.plot,{type:e,coords:null,asymptote:null});this.props.onChange({plot:t})},_getGridAndSnapSteps:function(e){var t=e.gridStep||l.getGridStep(e.range,e.step,b),n=e.snapStep||l.snapStepFromGridStep(t);return{gridStep:t,snapStep:n}},_getGridConfig:function(e){return r.map(e.step,function(t,n){return l.gridDimensionConfig(t,e.range[n],e.box[n],e.gridStep[n])})},_setupGraphie:function(e,t){t.markings==="graph"?(e.graphInit({range:t.range,scale:r.pluck(t.gridConfig,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,snapStep:t.snapStep,tickStep:r.pluck(t.gridConfig,"tickStep"),labelStep:1,unityLabels:r.pluck(t.gridConfig,"unityLabel")}),e.label([0,t.range[1][1]],t.labels[1],"above"),e.label([t.range[0][1],0],t.labels[0],"right")):t.markings==="grid"?e.graphInit({range:t.range,scale:r.pluck(t.gridConfig,"scale"),gridStep:t.gridStep,axes:!1,ticks:!1,labels:!1}):t.markings==="none"&&e.init({range:t.range,scale:r.pluck(t.gridConfig,"scale")})},simpleValidate:function(e){return q.validate(this.getUserInput(),e)},getUserInput:function(){return this.props.plot},focus:$.noop,statics:{displayMode:"block"}});r.extend(q,{validate:function(e,t){if(e.type!==t.correct.type)return{type:"points",earned:0,total:1,message:null};if(e.coords==null)return{type:"invalid",message:null};var n=I(e.type),r=n.getCoefficients(e.coords,e.asymptote),i=n.getCoefficients(t.correct.coords,t.correct.asymptote);return r==null||i==null?{type:"invalid",message:null}:n.areEqual(r,i)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}},getEquationString:function(e){var t=e.plot;if(t.type&&t.coords){var n=I(t.type),r=n.getEquationString(t.coords,t.asymptote);return r||""}return""},pointsFromNormalized:function(e,t,n,i){var s=function(e,t){return Math.floor((e[1]-e[0])/t)};return r.map(i,function(i){var o=r.map(i,function(n,r){var i=e[r],o=t[r],u=s(i,o),a=Math.round(n*u);return i[0]+o*a});return g.roundTo(o,n)})}});var R=React.createClass({displayName:"GrapherEditor",mixins:[y],getDefaultProps:function(){return{correct:{type:S,coords:null,asymptote:null},graph:{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:E,markings:"graph",rulerLabel:"",rulerTicks:10,valid:!0},availableTypes:[S]}},render:function(){var e,t,e=r.extend(this.props.graph,{box:[w,w]});if(this.props.graph.valid===!0){var n={graph:this.props.graph,plot:this.props.correct,availableTypes:this.props.availableTypes,onChange:function(e,t){var n=this.props.correct;n.type===e.plot.type?n=r.extend({},n,e.plot):n=e.plot,this.props.onChange({correct:n},t)}.bind(this)};e=React.createElement(q,React.__spread({},n)),t=q.getEquationString(n)}else e=React.createElement("div",{className:"perseus-error"},this.props.graph.valid);return React.createElement("div",null,React.createElement("div",null,"Correct answer"," ",React.createElement(o,null,React.createElement("p",null,"Graph the correct answer in the graph below and ensure the equation or point coordinates displayed represent the correct answer."))," ",": ",t),React.createElement(s,{editableSettings:["graph","snap","image"],box:this.props.graph.box,range:this.props.graph.range,labels:this.props.graph.labels,step:this.props.graph.step,gridStep:this.props.graph.gridStep,snapStep:this.props.graph.snapStep,valid:this.props.graph.valid,backgroundImage:this.props.graph.backgroundImage,markings:this.props.graph.markings,rulerLabel:this.props.graph.rulerLabel,rulerTicks:this.props.graph.rulerTicks,onChange:this.change("graph")}),React.createElement("div",{className:"perseus-widget-row"},React.createElement("label",null,"Available functions:"," "," "),React.createElement(a,{allowEmpty:!1,values:this.props.availableTypes,buttons:r.map(F,x),onChange:this.handleAvailableTypesChange})),e)},handleAvailableTypesChange:function(e){var t=this.props.correct;if(!r.contains(e,this.props.correct.type))var t={type:r.first(e),coords:null,asymptote:null};this.props.onChange({availableTypes:e,correct:t})},serialize:function(){return r.chain(this.props).pick("correct","availableTypes").extend({graph:r.omit(this.props.graph,"box")}).value()}}),U=function(e){var t=r.pick(e,"availableTypes");t.graph=r.extend(e.graph,{box:[b,b]});if(t.availableTypes.length===1){var n={type:r.first(t.availableTypes),coords:null,asymptote:null};t.plot=n}return t};e.exports={name:"grapher",displayName:"Grapher",widget:q,editor:R,transform:U}},function(e,t,n){var r=n(16).Options,i=n(71),s=n(10),o=n(14),u=React.createClass({displayName:"Group",mixins:[i],propTypes:{content:React.PropTypes.string,widgets:React.PropTypes.object,images:React.PropTypes.object,icon:React.PropTypes.object,reviewModeRubric:React.PropTypes.object},getDefaultProps:function(){return{content:"",widgets:{},images:{},icon:null}},componentDidMount:function(){this.forceUpdate()},render:function(){var e=_.extend({},r.defaults,this.props.apiOptions,{onFocusChange:function(e,t){t&&this.props.onBlur(t),e&&this.props.onFocus(e)}.bind(this)}),t=_.indexOf(this.props.interWidgets("group"),this),n=this.props.apiOptions.groupAnnotator(t,this.props.widgetId),i=function(e){this.refs.renderer&&this.change("widgets",this.refs.renderer.props.widgets)}.bind(this);return React.createElement("div",{className:"perseus-group"},n,React.createElement(o,React.__spread({},this.props,{ref:"renderer",apiOptions:e,interWidgets:this._interWidgets,reviewMode:!!this.props.reviewModeRubric,onInteractWithWidget:i})),this.props.icon&&React.createElement("div",{className:"group-icon"},this.props.icon))},_interWidgets:function(e,t){return t.length?t:this.props.interWidgets(e)},getUserInput:function(){return this.refs.renderer.getUserInput()},getSerializedState:function(){return this.refs.renderer.getSerializedState()},restoreSerializedState:function(e,t){return this.refs.renderer.restoreSerializedState(e,t),null},simpleValidate:function(e){return this.refs.renderer.score()},getInputPaths:function(){return this.refs.renderer.getInputPaths()},setInputValue:function(e,t,n){return this.refs.renderer.setInputValue(e,t,n)},getAcceptableFormatsForInputPath:function(e){return this.refs.renderer.getAcceptableFormatsForInputPath(e)},getRenderer:function(){return this.refs.renderer},focus:function(e){if(e==null)return this.refs.renderer.focus();this.refs.renderer.focusPath(e)},blur:function(e){this.refs.renderer.blurPath(e)},statics:{displayMode:"block"}}),a=React.createClass({displayName:"GroupEditor",mixins:[i],propTypes:{content:React.PropTypes.string,widgets:React.PropTypes.object,images:React.PropTypes.object,metadata:React.PropTypes.any,apiOptions:r.propTypes},getDefaultProps:function(){return{content:"",widgets:{},images:{},metadata:undefined}},render:function(){return React.createElement("div",{className:"perseus-group-editor"},React.createElement("div",null,this._renderMetadataEditor()),React.createElement(s,{ref:"editor",content:this.props.content,widgets:this.props.widgets,images:this.props.images,widgetEnabled:!0,immutableWidgets:!1,onChange:this.props.onChange}))},_renderMetadataEditor:function(){var e=this.props.apiOptions.GroupMetadataEditor;return React.createElement(e,{value:this.props.metadata,onChange:this.change("metadata")})},serialize:function(){return _.extend({},this.refs.editor.serialize(),{metadata:this.props.metadata})}}),f=function(e,t,n){n(e,t)};e.exports={name:"group",displayName:"Group",widget:u,editor:a,traverseChildWidgets:f,hidden:!1}},function(e,t,n){var r=n(66),i=n(62),s=n(87),o=n(71),u=n(72),a=n(73),f=n(5).updateQueryString,l=r.createClass({displayName:"Iframe",mixins:[o,a],propTypes:{width:r.PropTypes.string,height:r.PropTypes.string,url:r.PropTypes.string,settings:r.PropTypes.array,status:r.PropTypes.oneOf(["incomplete","incorrect","correct"]),message:r.PropTypes.string},getDefaultProps:function(){return{status:"incomplete",message:null}},handleMessageEvent:function(e){var t={};try{t=JSON.parse(e.originalEvent.data)}catch(n){return}if(i.isUndefined(t.testsPassed))return;var r=t.testsPassed?"correct":"incorrect";this.change({status:r,message:t.message})},componentDidMount:function(){$(window).on("message",this.handleMessageEvent)},componentWillUnmount:function(){$(window).off("message",this.handleMessageEvent)},render:function(){var e={width:this.props.width,height:this.props.height},t=this.props.url;t&&t.length&&t.indexOf("http")!==0&&(t="https://www.khanacademy.org/computer-programming/program/"+t+"/embedded?buttons=no&embed=yes&editor=no&author=no",t=f(t,"width",this.props.width),t=f(t,"height",this.props.height),t=f(t,"origin",window.location.origin));if(this.props.settings){var n={};i.each(this.props.settings,function(e){e.name&&e.value&&(n[e.name]=e.value)}),t=f(t,"settings",JSON.stringify(n))}return r.createElement("iframe",{sandbox:"allow-same-origin allow-scripts",style:e,src:t})},simpleValidate:function(e){return l.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});i.extend(l,{validate:function(e,t){return e.status==="correct"?{type:"points",earned:1,total:1,message:e.message||null}:e.status==="incorrect"?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}});var c=r.createClass({displayName:"PairEditor",mixins:[o,u],propTypes:{name:r.PropTypes.string,value:r.PropTypes.string},getDefaultProps:function(){return{name:"",value:""}},render:function(){return r.createElement("fieldset",null,r.createElement("label",null,"Name:",r.createElement(s,{value:this.props.name,onChange:this.change("name")})),r.createElement("label",null,"Value:",r.createElement(s,{value:this.props.value,onChange:this.change("value")})))}}),h=r.createClass({displayName:"PairsEditor",mixins:[o,u],propTypes:{pairs:r.PropTypes.arrayOf(r.PropTypes.shape({name:r.PropTypes.string,value:r.PropTypes.string})).isRequired},render:function(){var e=i.map(this.props.pairs,function(e,t){return r.createElement(c,{key:t,name:e.name,value:e.value,onChange:this.handlePairChange.bind(this,t)})}.bind(this));return r.createElement("div",null,e)},handlePairChange:function(e,t){var n=this.props.pairs.slice();n[e]=t;var r=n[n.length-1];r.name&&r.value&&n.push({name:"",value:""}),this.change("pairs",n)}}),p=r.createClass({displayName:"IframeEditor",mixins:[o,u],getDefaultProps:function(){return{url:"",settings:[{name:"",value:""}],width:400,height:400}},render:function(){return r.createElement("div",null,r.createElement("label",null,"Url or Program ID:",r.createElement(s,{name:"url",value:this.props.url,onChange:this.change("url")})),r.createElement("br",null),r.createElement("label",null,"Settings:",r.createElement(h,{name:"settings",pairs:this.props.settings,onChange:this.handleSettingsChange})),r.createElement("br",null),r.createElement("label",null,"Width:",r.createElement(s,{name:"width",value:this.props.width,onChange:this.change("width")})),r.createElement("label",null,"Height:",r.createElement(s,{name:"height",value:this.props.height,onChange:this.change("height")})))},handleSettingsChange:function(e){this.change({settings:e.pairs})}});e.exports={name:"iframe",displayName:"Iframe",widget:l,hidden:!0,editor:p}},function(e,t,n){function w(){return{content:"",coordinates:[0,0],alignment:"center"}}var r=n(62),i=n(5),s=n(87),o=n(10),u=n(74),a=n(14),f=n(71),l=n(72),c=n(73),h=n(76),p=n(88),d=n(63),v=n(89),m=400,g=[0,10],y={url:null,width:0,height:0},b=["center","above","above right","right","below right","below","below left","left","above left"],E=React.createClass({displayName:"ImageWidget",mixins:[f,c],propTypes:{title:React.PropTypes.string,range:React.PropTypes.arrayOf(React.PropTypes.arrayOf(React.PropTypes.number)),box:React.PropTypes.arrayOf(React.PropTypes.number),backgroundImage:React.PropTypes.shape({url:React.PropTypes.string,width:React.PropTypes.number,height:React.PropTypes.number}),labels:React.PropTypes.arrayOf(React.PropTypes.shape({content:React.PropTypes.string,coordinates:React.PropTypes.arrayOf(React.PropTypes.number),alignment:React.PropTypes.string})),alt:React.PropTypes.string,caption:React.PropTypes.string},getDefaultProps:function(){return{title:"",range:[g,g],box:[m,m],backgroundImage:y,labels:[],alt:"",caption:""}},render:function(){var e,t=this.props.backgroundImage;t.url&&(e=React.createElement(d,{src:t.url,alt:this.props.alt,width:t.width,height:t.height}));var n=this.props.box;return React.createElement("div",{className:"perseus-image-widget"},this.props.title&&React.createElement("div",{className:"perseus-image-title"},React.createElement(a,{content:this.props.title})),React.createElement("div",{className:"graphie-container",style:{width:n[0],height:n[1]}},e,React.createElement(h,{ref:"graphie",box:this.props.box,range:this.props.range,options:r.pick(this.props,"box","range","labels"),setup:this.setupGraphie})),this.props.caption&&React.createElement("div",{className:"perseus-image-caption"},React.createElement(a,{content:this.props.caption})))},setupGraphie:function(e,t){r.map(t.labels,function(t){e.label(t.coordinates,t.content,t.alignment)})},simpleValidate:function(e){return E.validate(this.getUserInput(),e)},focus:$.noop,statics:{displayMode:"block"}});r.extend(E,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var S=React.createClass({displayName:"ImageEditor",mixins:[f,l],componentDidMount:function(){r.defer(function(){var e=this.props.backgroundImage.url;this.onUrlChange(e,!0)}.bind(this))},getDefaultProps:function(){return{title:"",range:[g,g],box:[m,m],backgroundImage:y,labels:[],alt:"",caption:""}},render:function(){var e=React.createElement("div",{className:"image-settings"},React.createElement("div",null,"Background image:"),React.createElement("div",null,React.createElement("label",null,"Url:"," ",React.createElement(s,{value:this.props.backgroundImage.url||"",onChange:function(e){return this.onUrlChange(e,!1)}.bind(this)}),React.createElement(u,null,React.createElement("p",null,'Create an image in graphie, or use the "Add image" function to create a background.')))),this.props.backgroundImage.url&&React.createElement("div",null,React.createElement("div",null,React.createElement("label",null,"Graphie X range:"," ",React.createElement(p,{value:this.props.range[0],onChange:r.partial(this.onRangeChange,0)}))),React.createElement("div",null,React.createElement("label",null,"Graphie Y range:"," ",React.createElement(p,{value:this.props.range[1],onChange:r.partial(this.onRangeChange,1)}))),React.createElement("div",null,React.createElement("label",null,"Alt text:"," ",React.createElement(v,{value:this.props.alt,onChange:this.change("alt")}),React.createElement(u,null,React.createElement("p",null,"Add alt text to the image")))))),t=React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"add-label"},React.createElement("button",{onClick:this.addLabel}," ","Add a label"," ")),this.props.labels.length>0&&React.createElement("table",{className:"label-settings"},React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",null,"Coordinates"),React.createElement("th",null,"Content"),React.createElement("th",null,"Alignment"),React.createElement("th",null))),React.createElement("tbody",null,this.props.labels.map(this._renderRowForLabel))));return React.createElement("div",{className:"perseus-image-editor"},React.createElement("div",null,"Title:"),React.createElement(o,{content:this.props.title,onChange:function(e){e.content!=null&&this.change("title",e.content)}.bind(this),widgetEnabled:!1}),e,t,React.createElement("div",null,"Caption:"),React.createElement(o,{content:this.props.caption,onChange:function(e){e.content!=null&&this.change("caption",e.content)}.bind(this),widgetEnabled:!1}))},_renderRowForLabel:function(e,t){return React.createElement("tr",{key:t},React.createElement("td",null,React.createElement(p,{value:e.coordinates,onChange:this.onCoordinateChange.bind(this,t)})),React.createElement("td",{style:{verticalAlign:"bottom",width:"5px"}},React.createElement("input",{type:"text",className:"graph-settings-axis-label",value:e.content,onChange:this.onContentChange.bind(this,t)})),React.createElement("td",null,React.createElement("select",{className:"perseus-widget-dropdown",value:e.alignment,onChange:this.onAlignmentChange.bind(this,t)},b.map(function(e,t){return React.createElement("option",{key:""+t,value:e},e)},this))),React.createElement("td",null,React.createElement("a",{href:"#",className:"simple-button orange delete-label",title:"Remove this label",onClick:this.removeLabel.bind(this,t)},React.createElement("span",{className:"icon-trash"}))))},addLabel:function(e){e.preventDefault();var t=this.props.labels.slice(),n=w();t.push(n),this.props.onChange({labels:t})},removeLabel:function(e,t){t.preventDefault();var n=r(this.props.labels).clone();n.splice(e,1),this.props.onChange({labels:n})},onCoordinateChange:function(e,t){var n=this.props.labels.slice();n[e]=r.extend({},n[e],{coordinates:t}),this.props.onChange({labels:n})},onContentChange:function(e,t){var n=t.target.value,i=this.props.labels.slice();i[e]=r.extend({},i[e],{content:n}),this.props.onChange({labels:i})},onAlignmentChange:function(e,t){var n=t.target.value,i=this.props.labels.slice();i[e]=r.extend({},i[e],{alignment:n}),this.props.onChange({labels:i})},setUrl:function(e,t,n,i){if(!this.isMounted())return;var s=r.clone(this.props.backgroundImage);s.url=e,s.width=t,s.height=n;var o=[s.width,s.height];this.props.onChange({backgroundImage:s,box:o},null,i)},onUrlChange:function(e,t){var n=0,r=0;e&&i.getImageSize(e,function(t,n){this.setUrl(e,t,n,!0)}.bind(this)),this.setUrl(e,n,r,t)},onRangeChange:function(e,t){var n=this.props.range.slice();n[e]=t,this.props.onChange({range:n})},getSaveWarnings:function(){var e=[];return this.props.backgroundImage.url&&!this.props.alt&&e.push("No alt text"),e}});e.exports={name:"image",accessible:function(e){return!e.backgroundImage.url||!!e.alt},displayName:"Image",widget:E,editor:S}},function(e,t,n){var r=n(109),i=n(66),s=n(62),o=n(87),u=n(74),a=n(80),f=n(90).parseTex,l=n(16).ClassNames,c=n(16).Options,h=n(5),p=n(54),d={number:{name:"Numbers",forms:"integer, decimal, proper, improper, mixed"},decimal:{name:"Decimals",forms:"decimal"},integer:{name:"Integers",forms:"integer"},rational:{name:"Fractions and mixed numbers",forms:"integer, proper, improper, mixed"},improper:{name:"Improper numbers (no mixed)",forms:"integer, proper, improper"},mixed:{name:"Mixed numbers (no improper)",forms:"integer, proper, mixed"},percent:{name:"Numbers or percents",forms:"integer, decimal, proper, improper, mixed, percent"},pi:{name:"Numbers with pi",forms:"pi"}},v={integer:function(e){return $._("an integer, like $6$")},proper:function(e){return e.simplify==="optional"?$._("a *proper* fraction, like $1/2$ or $6/10$"):$._("a *simplified proper* fraction, like $3/5$")},improper:function(e){return e.simplify==="optional"?$._("an *improper* fraction, like $10/7$ or $14/8$"):$._("a *simplified improper* fraction, like $7/4$")},mixed:function(e){return $._("a mixed number, like $1\\ 3/4$")},decimal:function(e){return $._("an *exact* decimal, like $0.75$")},percent:function(e){return $._("a percent, like $12.34\\%$")},pi:function(e){return $._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")}},m=i.createClass({displayName:"InputNumber",propTypes:{currentValue:i.PropTypes.string,enabledFeatures:p.propTypes,reviewModeRubric:i.PropTypes.object},getDefaultProps:function(){return{currentValue:"",size:"normal",answerType:"number",enabledFeatures:p.defaults,apiOptions:c.defaults}},shouldShowExamples:function(){return this.props.enabledFeatures.toolTipFormats&&this.props.answerType!=="number"&&!this.props.apiOptions.staticRender},render:function(){var e=this.props.reviewModeRubric,t=null,n=null;if(e){var s=this.simpleValidate(e);t=s.type==="points"&&s.earned===s.total;if(!t){var o=String(e.value);e.inexact&&e.maxError&&(o+=" ± "+e.maxError),n=i.createElement("span",{className:"perseus-possible-answers"},i.createElement("span",{className:"perseus-possible-answer"},o))}}var u={};u["perseus-input-size-"+this.props.size]=!0,u[l.CORRECT]=e&&t&&this.props.currentValue,u[l.INCORRECT]=e&&!t&&this.props.currentValue,u[l.UNANSWERED]=e&&!this.props.currentValue;var f=i.createElement(a,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:r(u),type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur});return n?i.createElement("span",{className:"perseus-input-with-answer-blurb"},f,n):f},handleChange:function(e){this.props.onChange({currentValue:e})},_getInputType:function(){return this.props.apiOptions.staticRender?"tex":"text"},_handleFocus:function(){this.props.onFocus([])},_handleBlur:function(){this.props.onBlur([])},focus:function(){return this.refs.input.focus(),!0},focusInputPath:function(e){this.refs.input.focus()},blurInputPath:function(e){this.refs.input.blur()},getInputPaths:function(){return[[]]},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,n){this.props.onChange({currentValue:t},n)},getUserInput:function(){return{currentValue:this.props.currentValue}},simpleValidate:function(e,t){return t=t||function(){},m.validate(this.getUserInput(),e,t)},examples:function(){var e=this.props.answerType,t=d[e].forms.split(/\s*,\s*/),n=s.map(t,function(e){return v[e](this.props)},this);return[$._("**Acceptable Formats**")].concat(n)},statics:{displayMode:"inline-block"}});s.extend(m,{validate:function(e,t,n){t.answerType==null&&(t.answerType="number");var r=Khan.answerTypes.number.createValidatorFunctional(t.value,{simplify:t.simplify,inexact:t.inexact||undefined,maxError:t.maxError,forms:d[t.answerType].forms}),i=f(e.currentValue),s=r(i);if(s.empty){var o=n(null,e.currentValue,s.message);return{type:"invalid",message:o===!1?null:s.message}}return{type:"points",earned:s.correct?1:0,total:1,message:s.message}}});var g=i.createClass({displayName:"InputNumberEditor",propTypes:{value:i.PropTypes.number,simplify:i.PropTypes.oneOf(["required","optional","enforced"]),size:i.PropTypes.oneOf(["normal","small"]),inexact:i.PropTypes.bool,maxError:i.PropTypes.number,answerType:i.PropTypes.string},getDefaultProps:function(){return{value:0,simplify:"required",size:"normal",inexact:!1,maxError:.1,answerType:"number"}},handleAnswerChange:function(e){var t=h.firstNumericalParse(e)||0;this.props.onChange({value:t})},render:function(){var e=s.map(d,function(e,t){return i.createElement("option",{value:t,key:t},e.name)},this);return i.createElement("div",null,i.createElement("div",null,i.createElement("label",null,"Correct answer:"," ",i.createElement(o,{value:""+this.props.value,onChange:this.handleAnswerChange,ref:"input"}))),i.createElement("div",null,i.createElement("label",null,"Unsimplified answers"," ",i.createElement("select",{value:this.props.simplify,onChange:function(e){this.props.onChange({simplify:e.target.value})}.bind(this)},i.createElement("option",{value:"required"},"will not be graded"),i.createElement("option",{value:"optional"},"will be accepted"),i.createElement("option",{value:"enforced"},"will be marked wrong"))),i.createElement(u,null,i.createElement("p",null,'Normally select "will not be graded". This will give the user a message saying the answer is correct but not simplified. The user will then have to simplify it and re-enter, but will not be penalized. (5th grade and anything after)'),i.createElement("p",null,'Select "will be accepted" only if the user is not expected to know how to simplify fractions yet. (Anything prior to 5th grade)'),i.createElement("p",null,'Select "will be marked wrong" only if we are specifically assessing the ability to simplify.'))),i.createElement("div",null,i.createElement("label",null,i.createElement("input",{type:"checkbox",checked:this.props.inexact,onChange:function(e){this.props.onChange({inexact:e.target.checked})}.bind(this)})," ","Allow inexact answers"),i.createElement("label",null,i.createElement("input",{type:"checkbox",style:{visibility:"hidden"}}),"Max error:"," ",i.createElement("input",{type:"text",disabled:!this.props.inexact,defaultValue:this.props.maxError,onBlur:function(e){var t=""+(h.firstNumericalParse(e.target.value)||0);e.target.value=t,this.props.onChange({maxError:t})}.bind(this)}))),i.createElement("div",null,"Answer type:"," ",i.createElement("select",{value:this.props.answerType,onChange:function(e){this.props.onChange({answerType:e.target.value})}.bind(this)},e),i.createElement(u,null,i.createElement("p",null,'Use the default "Numbers" unless the answer must be in a specific form (e.g., question is about converting decimals to fractions).'))),i.createElement("div",null,i.createElement("label",null,"Width"," ",i.createElement("select",{value:this.props.size,onChange:function(e){this.props.onChange({size:e.target.value})}.bind(this)},i.createElement("option",{value:"normal"},"Normal (80px)"),i.createElement("option",{value:"small"},"Small (40px)"))),i.createElement(u,null,i.createElement("p",null,'Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them.'))))},focus:function(){return this.refs.input.getDOMNode().focus(),!0},serialize:function(){return s.pick(this.props,"value","simplify","size","inexact","maxError","answerType")}}),y=function(e){return s.pick(e,"simplify","size","answerType")};e.exports={name:"input-number",displayName:"Number text box (old)",hidden:!0,widget:m,editor:g,transform:y}},function(e,t,n){var r=n(62),i=n(71),s=n(72),o=n(101),u=n(102),a=n(103),f=n(104),l=n(105),c=n(76),h=n(84),p=n(81),d=n(91),v=n(70),m=n(89),g=c.Label,y=c.Line,b=c.MovablePoint,w=c.MovableLine,E=c.Plot,S=c.PlotParametric,x=c.Point,T=c.Rect,N=n(108).vector,C=function(e,t){t=t||{};var n=e+"||"+t.decimal_separatpr+"||",r=t.functions,i=r?r.length:0;for(var s=0;s<i;s++)n+=r[s]+"|";return n},k=Object.create(null),L=function(e,t){var n=C(e,t),r=k[n];return r?r:(r=KAS.parse(e,t),k[n]=r,r)};_compileCache=Object.create(null);var A=function(e,t){var n=C(e,t),r=_compileCache[n];if(r)return r;var i=KAS.parse(e,t).expr;return r=i?i.compile():function(){return 0},_compileCache[n]=r,r},O={graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]},M=React.createClass({displayName:"Interaction",mixins:[i],propTypes:{graph:React.PropTypes.object,elements:React.PropTypes.arrayOf(React.PropTypes.object)},getDefaultProps:function(){return O},getInitialState:function(){return{variables:this._getInitialVariables(this.props.elements),functions:this._getInitialFunctions(this.props.elements)}},_getInitialVariables:function(e){var t={};return r.each(r.where(e,{type:"movable-point"}),function(e){var n=e.options.varSubscript,r=L(e.options.startX||"0").expr,i=L(e.options.startY||"0").expr,s=0,o=0;r&&(s=r.eval({})||0),i&&(o=i.eval({})||0),t["x_"+n]=s,t["y_"+n]=o},this),r.each(r.where(e,{type:"movable-line"}),function(e){var n=e.options.startSubscript,r=e.options.endSubscript,i=L(e.options.startX||"0").expr,s=L(e.options.startY||"0").expr,o=L(e.options.endX||"0").expr,u=L(e.options.endY||"0").expr,a=0,f=0,l=0,c=0;i&&(a=i.eval({})||0),s&&(f=s.eval({})||0),o&&(l=o.eval({})||0),u&&(c=u.eval({})||0),t["x_"+n]=a,t["y_"+n]=f,t["x_"+r]=l,t["y_"+r]=c},this),r.each(r.where(e,{type:"function"}),function(e){t[e.options.funcName]=e.options.value}),t},_getInitialFunctions:function(e){return r.map(r.where(e,{type:"function"}),function(e){return e.options.funcName})},componentWillReceiveProps:function(e){this.setState({variables:this._getInitialVariables(e.elements),functions:this._getInitialFunctions(e.elements)})},_setupGraphie:function(e,t){e.graphInit(r.extend({},t,{grid:r.contains(["graph","grid"],this.props.graph.markings),axes:r.contains(["graph"],this.props.graph.markings),ticks:r.contains(["graph"],this.props.graph.markings),labels:r.contains(["graph"],this.props.graph.markings),labelFormat:function(e){return"\\small{"+e+"}"},axisArrows:"<->",unityLabels:!1}));if(this.props.graph.markings==="graph"){var n=this.props.graph.labels,i=this.props.graph.range;e.label([0,i[1][1]],n[1],"above"),e.label([i[0][1],0],n[0],"right")}},_updatePointLocation:function(e,t){var n=r.clone(this.state.variables);n["x_"+e]=t[0],n["y_"+e]=t[1],this.setState({variables:n})},_updateLineLocation:function(e,t){var n=this._eval("("+e.endX+")-("+e.startX+")"),i=this._eval("("+e.endY+")-("+e.startY+")"),s=N.add(t,[n,i]),o=r.clone(this.state.variables);o["x_"+e.startSubscript]=t[0],o["y_"+e.startSubscript]=t[1],o["x_"+e.endSubscript]=s[0],o["y_"+e.endSubscript]=s[1],this.setState({variables:o})},_eval:function(e,t){var n=A(e,{functions:this.state.functions}),i=r.extend({},this.state.variables,t);return r.each(r.keys(i),function(e){if(r.isString(i[e])){var t=A(i[e],{functions:this.state.functions});i[e]=function(e){return t(r.extend({},i,{x:e}))}}}.bind(this)),val=n(i),val||0},_extractVars:function(e){if(e==null)return[];var t=[];return r.each(e.args(),function(e){e&&e.constructor.name==="Expr"&&(t=t.concat(this._extractVars(e)))},this),e.name()==="Var"&&t.push(e.prettyPrint()),t},render:function(){return React.createElement(c,{box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this._setupGraphie},r.map(this.props.elements,function(e,t){if(e.type==="point")return React.createElement(x,{key:e.key,coord:[this._eval(e.options.coordX),this._eval(e.options.coordY)],color:e.options.color});if(e.type==="line"){var n=[this._eval(e.options.startX),this._eval(e.options.startY)],i=[this._eval(e.options.endX),this._eval(e.options.endY)];return React.createElement(y,{key:e.key,start:n,end:i,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,arrows:e.options.arrows}})}if(e.type==="movable-point"){var s=[function(t){var n=Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),r=Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]));return[n,r]}.bind(this)];return e.options.constraint==="snap"?s.push(b.constraints.snap(e.options.snap)):e.options.constraint==="x"?s.push(function(t){return[this._eval(e.options.constraintFn,{y:t[1]}),t[1]]}.bind(this)):e.options.constraint==="y"&&s.push(function(t){return[t[0],this._eval(e.options.constraintFn,{x:t[0]})]}.bind(this)),React.createElement(b,{key:e.key,coord:[this.state.variables["x_"+e.options.varSubscript],this.state.variables["y_"+e.options.varSubscript]],constraints:s,foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap,onMove:r.partial(this._updatePointLocation,e.options.varSubscript)})}if(e.type==="movable-line"){var s=[function(t){var n=Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),r=Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]));return[n,r]}.bind(this)];e.options.constraint==="snap"?s.push(b.constraints.snap(e.options.snap)):e.options.constraint==="x"?s.push(function(t){return[this._eval(e.options.constraintFn,{y:t[1]}),t[1]]}.bind(this)):e.options.constraint==="y"&&s.push(function(t){return[t[0],this._eval(e.options.constraintFn,{x:t[0]})]}.bind(this));var n=[this.state.variables["x_"+e.options.startSubscript],this.state.variables["y_"+e.options.startSubscript]],i=[this.state.variables["x_"+e.options.endSubscript],this.state.variables["y_"+e.options.endSubscript]];return React.createElement(w,{key:e.key,constraints:s,onMove:r.bind(this._updateLineLocation,this,e.options),foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap},React.createElement(b,{coord:n,"static":!0,normalStyle:{stroke:"none",fill:"none"}}),React.createElement(b,{coord:i,"static":!0,normalStyle:{stroke:"none",fill:"none"}}))}if(e.type==="function"){var o=function(t){return this._eval(e.options.value,{x:t})}.bind(this),u=r.without(this._extractVars(L(e.options.value).expr),"x"),a=r.object(u,r.map(u,function(e){return this.state.variables[e]}.bind(this))),f=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return React.createElement(E,{key:e.key,fn:o,foo_fn:e.options.value,foo_varvalues:a,range:f,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if(e.type==="parametric"){var o=function(t){return[this._eval(e.options.x,{t:t}),this._eval(e.options.y,{t:t})]}.bind(this),u=r.without(this._extractVars(L(e.options.x).expr).concat(this._extractVars(L(e.options.y).expr)),"t"),a=r.object(u,r.map(u,function(e){return this.state.variables[e]}.bind(this))),f=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return React.createElement(S,{key:e.key,fn:o,foo_fnx:e.options.x,foo_fny:e.options.y,foo_varvalues:a,range:f,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if(e.type==="label"){var l=[this._eval(e.options.coordX),this._eval(e.options.coordY)];return React.createElement(g,{key:t+1,coord:l,text:e.options.label,style:{color:e.options.color}})}if(e.type==="rectangle")return React.createElement(T,{key:t+1,x:this._eval(e.options.coordX),y:this._eval(e.options.coordY),width:r.max([this._eval(e.options.width),0]),height:r.max([this._eval(e.options.height),0]),style:{stroke:"none",fill:e.options.color}})},this))},getUserInput:function(){return{}},simpleValidate:function(e){return M.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});r.extend(M,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var _=React.createClass({displayName:"PointEditor",mixins:[s,i],propTypes:{coordX:React.PropTypes.string,coordY:React.PropTypes.string,color:React.PropTypes.string},getDefaultProps:function(){return{coordX:"0",coordY:"0",color:KhanUtil.BLACK}},render:function(){return React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},"Coordinate: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,{value:this.props.color,onChange:this.change("color")})))}}),D=React.createClass({displayName:"LineEditor",mixins:[s,i],propTypes:{startX:React.PropTypes.string,startY:React.PropTypes.string,endX:React.PropTypes.string,endY:React.PropTypes.string,color:React.PropTypes.string,strokeDasharray:React.PropTypes.string,arrows:React.PropTypes.string,strokeWidth:React.PropTypes.number},getDefaultProps:function(){return{startX:"-5",startY:"5",endX:"5",endY:"5",color:KhanUtil.BLACK,strokeDasharray:"",arrows:"",strokeWidth:2}},render:function(){return React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},"Start: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},"End: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.endX,onChange:this.change("endX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.endY,onChange:this.change("endY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,{value:this.props.color,onChange:this.change("color")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement(f,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")}),"   ",React.createElement(o,{value:this.props.arrows,onChange:this.change("arrows")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement("div",{className:"perseus-widget-left-col"},"Width: ",React.createElement(d,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}),P=React.createClass({displayName:"MovablePointEditor",mixins:[s,i],propTypes:{startX:React.PropTypes.string,startY:React.PropTypes.string,constraint:React.PropTypes.string,snap:React.PropTypes.number,constraintFn:React.PropTypes.string},getDefaultProps:function(){return{startX:"0",startY:"0",constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"}},render:function(){return React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},"Start: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},"Update ",React.createElement(v,null,"(x_n, y_n)")," for ",React.createElement(v,null,"n =")," ",React.createElement(d,{value:this.props.varSubscript,placeholder:0,onChange:this.change("varSubscript")})),React.createElement(a,React.__spread({},this.props)))}}),H=React.createClass({displayName:"MovableLineEditor",mixins:[s,i],propTypes:{startX:React.PropTypes.string,startY:React.PropTypes.string,endX:React.PropTypes.string,endY:React.PropTypes.string,constraint:React.PropTypes.string,snap:React.PropTypes.number,constraintFn:React.PropTypes.string},getDefaultProps:function(){return{startX:"-5",startY:"5",endX:"5",endY:"5",constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"}},render:function(){return React.createElement("div",{className:"graph-settings"},"Initial position:",React.createElement("div",{className:"perseus-widget-row"},"Start: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},"End: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.endX,onChange:this.change("endX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.endY,onChange:this.change("endY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},"Start updates ",React.createElement(v,null,"(x_n, y_n)")," for ",React.createElement(v,null,"n ="),React.createElement(d,{value:this.props.startSubscript,placeholder:0,onChange:this.change("startSubscript")})),React.createElement("div",{className:"perseus-widget-row"},"End updates ",React.createElement(v,null,"(x_m, y_m)")," for ",React.createElement(v,null,"m ="),React.createElement(d,{value:this.props.endSubscript,placeholder:0,onChange:this.change("endSubscript")})),React.createElement("div",{className:"perseus-widget-row"},"All constraints are applied to the start point."),React.createElement(a,React.__spread({},this.props)))}}),B=React.createClass({displayName:"FunctionEditor",mixins:[s,i],propTypes:{value:React.PropTypes.string,rangeMin:React.PropTypes.string,rangeMax:React.PropTypes.string,color:React.PropTypes.string,strokeDashArray:React.PropTypes.string,strokeWidth:React.PropTypes.number},getDefaultProps:function(){return{value:"x",rangeMin:"-10",rangeMax:"10",color:KhanUtil.BLUE,strokeDasharray:"",strokeWidth:2}},render:function(){return React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},React.createElement(v,null,this.props.funcName+"(x)=")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.value,onChange:this.change("value")})),React.createElement("div",{className:"perseus-widget-row"},"Range: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMin,onChange:this.change("rangeMin")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMax,onChange:this.change("rangeMax")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,{value:this.props.color,onChange:this.change("color")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement(f,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement("div",{className:"perseus-widget-left-col"},"Width: ",React.createElement(d,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}),j=React.createClass({displayName:"ParametricEditor",mixins:[s,i],propTypes:{x:React.PropTypes.string,y:React.PropTypes.string,rangeMin:React.PropTypes.string,rangeMax:React.PropTypes.string,color:React.PropTypes.string,strokeDashArray:React.PropTypes.string,strokeWidth:React.PropTypes.number},getDefaultProps:function(){return{x:"cos(t)",y:"sin(t)",rangeMin:"0",rangeMax:"2\\pi",color:KhanUtil.BLUE,strokeDasharray:"",strokeWidth:2}},render:function(){return React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},React.createElement(v,null,"X(t) =")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.x,onChange:this.change("x")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement(v,null,"Y(t) =")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.y,onChange:this.change("y")})),React.createElement("div",{className:"perseus-widget-row"},"Range: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMin,onChange:this.change("rangeMin")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMax,onChange:this.change("rangeMax")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,{value:this.props.color,onChange:this.change("color")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement(f,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement("div",{className:"perseus-widget-left-col"},"Width: ",React.createElement(d,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}),F=React.createClass({displayName:"LabelEditor",mixins:[s,i],propTypes:{},getDefaultProps:function(){return{coordX:"0",coordY:"0",color:KhanUtil.BLACK,label:"\\phi"}},render:function(){return React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},React.createElement(m,{value:this.props.label,onChange:this.change("label"),style:{width:"100%"}})),React.createElement("div",{className:"perseus-widget-row"},"Location: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,{value:this.props.color,onChange:this.change("color")})))}}),I=React.createClass({displayName:"RectangleEditor",mixins:[s,i],propTypes:{},getDefaultProps:function(){return{coordX:"-5",coordY:"5",width:"2",height:"3",color:KhanUtil.LIGHT_BLUE}},render:function(){return React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},"Top left: ",React.createElement(v,null,"\\Large("),React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),React.createElement(v,null,",")," ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),React.createElement(v,null,"\\Large)")),React.createElement("div",{className:"perseus-widget-row"},"Width: ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.width,onChange:this.change("width")})),React.createElement("div",{className:"perseus-widget-row"},"Height: ",React.createElement(p,{buttonSets:[],buttonsVisible:"never",value:this.props.height,onChange:this.change("height")})),React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,{value:this.props.color,lightColors:!0,onChange:this.change("color")})),React.createElement("div",{className:"perseus-widget-row"},"You want a border? Sorry, draw your own."))}}),q=React.createClass({displayName:"InteractionEditor",mixins:[s,i],propTypes:{graph:React.PropTypes.object,elements:React.PropTypes.arrayOf(React.PropTypes.object)},getDefaultProps:function(){return O},getInitialState:function(){return{usedVarSubscripts:this._getAllVarSubscripts(this.props.elements),usedFunctionNames:this._getAllFunctionNames(this.props.elements)}},componentWillReceiveProps:function(e){this.setState({usedVarSubscripts:this._getAllVarSubscripts(e.elements),usedFunctionNames:this._getAllFunctionNames(e.elements)})},_getAllVarSubscripts:function(e){return r.map(r.where(e,{type:"movable-point"}),function(e){return e.options.varSubscript}).concat(r.map(r.where(e,{type:"movable-line"}),function(e){return e.options.startSubscript})).concat(r.map(r.where(e,{type:"movable-line"}),function(e){return e.options.endSubscript}))},_getAllFunctionNames:function(e){return r.map(r.where(e,{type:"function"}),function(e){return e.options.funcName})},_updateGraphProps:function(e){this.change({graph:r.extend(r.omit(e,"step"),{tickStep:e.step})})},_addNewElement:function(e){var t=e.target.value;if(t==="")return;e.target.value="";var n={type:t,key:t+"-"+(Math.random()*16777215<<0).toString(16),options:t==="point"?r.clone(_.defaultProps):t==="line"?r.clone(D.defaultProps):t==="movable-point"?r.clone(P.defaultProps):t==="movable-line"?r.clone(H.defaultProps):t==="function"?r.clone(B.defaultProps):t==="parametric"?r.clone(j.defaultProps):t==="label"?r.clone(F.defaultProps):t==="rectangle"?r.clone(I.defaultProps):{}};if(t==="movable-point"){var i=r.max([r.max(this.state.usedVarSubscripts),-1])+1;n.options.varSubscript=i}else if(t==="movable-line"){var i=r.max([r.max(this.state.usedVarSubscripts),-1])+1;n.options.startSubscript=i,n.options.endSubscript=i+1}else if(t==="function"){var s=String.fromCharCode(r.max([r.max(r.map(this.state.usedFunctionNames,function(e){return e.charCodeAt(0)})),"e".charCodeAt(0)])+1);n.options.funcName=s}this.change({elements:this.props.elements.concat(n)})},_deleteElement:function(e){var t=this.props.elements[e];this.change({elements:r.without(this.props.elements,t)})},_moveElementUp:function(e){var t=this.props.elements[e],n=r.without(this.props.elements,t);n.splice(e-1,0,t),this.change({elements:n})},_moveElementDown:function(e){var t=this.props.elements[e],n=r.without(this.props.elements,t);n.splice(e+1,0,t),this.change({elements:n})},render:function(){return React.createElement("div",{className:"perseus-widget-interaction-editor"},React.createElement(l,{title:"Grid settings"},React.createElement(h,{editableSettings:["canvas","graph"],box:this.props.graph.box,labels:this.props.graph.labels,range:this.props.graph.range,step:this.props.graph.tickStep,gridStep:this.props.graph.gridStep,markings:this.props.graph.markings,onChange:this._updateGraphProps}),this.props.graph.valid===!0||React.createElement("div",null,this.props.graph.valid)),r.map(this.props.elements,function(e,t){if(e.type==="movable-point")return React.createElement(l,{title:React.createElement("span",null,"Movable point ",React.createElement(v,null,"(x_{"+e.options.varSubscript+"}, y_{"+e.options.varSubscript+"})")),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement.bind(this,t),key:e.key},React.createElement(P,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})));if(e.type==="movable-line")return React.createElement(l,{title:React.createElement("span",null,"Movable line ",React.createElement(v,null,"(x_{"+e.options.startSubscript+"}, y_{"+e.options.startSubscript+"})")," to ",React.createElement(v,null,"(x_{"+e.options.endSubscript+"}, y_{"+e.options.endSubscript+"})")),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement.bind(this,t),key:e.key},React.createElement(H,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})));if(e.type==="point")return React.createElement(l,{title:React.createElement("span",null,"Point ",React.createElement(v,null,"("+e.options.coordX+", "+e.options.coordY+")")),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement.bind(this,t),key:e.key},React.createElement(_,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})));if(e.type==="line")return React.createElement(l,{title:React.createElement("span",null,"Line ",React.createElement(v,null,"("+e.options.startX+", "+e.options.startY+")")," to ",React.createElement(v,null,"("+e.options.endX+", "+e.options.endY+")")),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement.bind(this,t),key:e.key},React.createElement(D,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})));if(e.type==="function")return React.createElement(l,{title:React.createElement("span",null,"Function ",React.createElement(v,null,e.options.funcName+"(x) = "+e.options.value)),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement,key:e.key},React.createElement(B,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})));if(e.type==="parametric")return React.createElement(l,{title:React.createElement("span",null,"Parametric"),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement,key:e.key},React.createElement(j,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})));if(e.type==="label")return React.createElement(l,{title:React.createElement("span",null,"Label ",React.createElement(v,null,e.options.label)," "),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement,key:e.key},React.createElement(F,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})));if(e.type==="rectangle")return React.createElement(l,{title:React.createElement("span",null,"Rectangle ",React.createElement(v,null,"("+e.options.coordX+", "+e.options.coordY+")")," — ",React.createElement(v,null,e.options.width+" \\times "+e.options.height)),onUp:t===0?null:this._moveElementUp.bind(this,t),onDown:t===this.props.elements.length-1?null:this._moveElementDown.bind(this,t),onDelete:this._deleteElement,key:e.key},React.createElement(I,React.__spread({},e.options,{onChange:function(e){var n=JSON.parse(JSON.stringify(this.props.elements));r.extend(n[t].options,e),this.change({elements:n})}.bind(this)})))},this),React.createElement("div",{className:"perseus-widget-interaction-editor-select-element"},React.createElement("select",{onChange:this._addNewElement},React.createElement("option",{value:""},"Add an element","…"),React.createElement("option",{disabled:!0},"--"),React.createElement("option",{value:"point"},"Point"),React.createElement("option",{value:"line"},"Line segment"),React.createElement("option",{value:"function"},"Function plot"),React.createElement("option",{value:"parametric"},"Parametric plot"),React.createElement("option",{value:"label"},"Label"),React.createElement("option",{value:"rectangle"},"Rectangle"),React.createElement("option",{value:"movable-point"},"★ Movable point"),React.createElement("option",{value:"movable-line"},"★ Movable line segment"))))}});e.exports={name:"interaction",displayName:"Interaction",widget:M,editor:q,transform:r.identity}},function(e,t,n){function E(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])}function S(e,t,n){return y(E(e,t,n),0)}function x(e){return y(e,0)?0:e>0?1:-1}function T(e,t){return e==null?t:e}function N(e,t,n){return n[0]<=Math.max(e[0],t[0])&&n[0]>=Math.min(e[0],t[0])&&n[1]<=Math.max(e[1],t[1])&&n[1]>=Math.min(e[1],t[1])}function C(e,t){var n=[[e[0],e[1],t[0]],[e[0],e[1],t[1]],[t[0],t[1],e[0]],[t[0],t[1],e[1]]],r=i.map(n,function(e){return x(E.apply(null,e))});if(r[0]!==r[1]&&r[2]!==r[3])return!0;for(var s=0;s<4;s++)if(r[s]===0&&N.apply(null,n[s]))return!0;return!1}function k(e,t){return i.map(i.zip(e,t),function(e){return e[0]-e[1]})}function L(e){return Math.sqrt(i.reduce(e,function(e,t){return e+Math.pow(t,2)},0))}function A(e,t){return i.reduce(i.zip(e,t),function(e,t){return e+t[0]*t[1]},0)}function O(e){var t=i.zip(e,B(e));return i.map(t,function(e){return L(k.apply(null,e))})}function M(e){var t=i.zip(B(e,-1),e,B(e,1)),n=i.map(t,function(e){var t=k(e[1],e[0]),n=k(e[2],e[1]),r=Math.acos(A(t,n)/(L(t)*L(n)));return x(E.apply(null,e))>0?r:-r}),r=i.reduce(n,function(e,t){return e+t},0);return i.map(n,function(e){return r>0?Math.PI-e:Math.PI+e})}function _(e,t,n){if(e.length!==t.length)return!1;var r=e.length,s=M(e),o=M(t),u=O(e),a=O(t);for(var f=0;f<2*r;f++){var l=o.slice(),h=a.slice();f>=r&&(l.reverse(),h.reverse(),h=B(h,1)),l=B(l,f),h=B(h,f);if(b(s,l)){var p=i.zip(u,h),d=i.map(p,function(e){return e[0]/e[1]}),v=i.all(d,function(e){return y(d[0],e)}),m=i.all(p,function(e){return c.equal(e[0],e[1],n)});if(v&&m)return!0}}return!1}function D(e,t){return e<t||y(e,t)}function P(e,t,n){return Math.acos((e*e+t*t-n*n)/(2*e*t))*180/Math.PI}function H(e){var t=e[0],n=e[1],r=e[2],i=e[3];t<0&&(t*=-1,n*=-1,r*=-1);var s=2*Math.PI;n<0&&(n*=-1,r*=-1,r+=s/2);while(r>0)r-=s;while(r<0)r+=s;return[t,n,r,i]}function B(e,t){return t=typeof t=="undefined"?1:t%e.length,e.slice(t).concat(e.slice(0,t))}function j(e){return e.replace(/(?:^|-)(.)/g,function(e,t){return t.toUpperCase()})}function F(e,t){if(y(e[0],t[0]))return"x = "+e[0].toFixed(3);var n=(t[1]-e[1])/(t[0]-e[0]),r=e[1]-n*e[0];return"y = "+n.toFixed(3)+"x + "+r.toFixed(3)}function I(e,t){var n=e[0][0],r=e[0][1],i=e[1][0],s=e[1][1],o=t[0][0],u=t[0][1],a=t[1][0],f=t[1][1],l=(n-i)*(u-f)-(r-s)*(o-a);if(Math.abs(l)<1e-9)return"Lines are parallel";var c=((n*s-r*i)*(o-a)-(n-i)*(o*f-u*a))/l,h=((n*s-r*i)*(u-f)-(r-s)*(o*f-u*a))/l;return"Intersection: ("+c.toFixed(3)+", "+h.toFixed(3)+")"}function q(e,t){return Math.floor((e[1]-e[0])/t)}var r=n(66),i=n(62),s=n(94),o=n(84),u=n(74),a=n(85),f=n(91),l=n(5),c=n(108).number,h=n(108).point,p=l.DeprecationMixin,d="https://ka-perseus-graphie.s3.amazonaws.com/b1452c0d79fd0f7ff4c3af9488474a0a0decb361.png",v=400,m=340,g={url:null},y=l.eq,b=l.deepEq,w="unlimited",R={showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},U=r.createClass({displayName:"InteractiveGraph",getInitialState:function(){return{shouldShowInstructions:this._getShouldShowInstructions()}},getDefaultProps:function(){return{labels:["x","y"],range:[[-10,10],[-10,10]],box:[v,v],step:[1,1],backgroundImage:g,markings:"graph",showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,graph:{type:"linear"}}},mixins:[p],deprecatedProps:R,_getShouldShowInstructions:function(e){return e=e||this.props,this.isClickToAddPoints(e)&&(e.graph.coords==null||e.graph.coords.length===0)},componentDidUpdate:function(e,t){var n=e.graph.type,r=this.props.graph.type;if(n!==r||e.graph.allowReflexAngles!==this.props.graph.allowReflexAngles||e.graph.angleOffsetDeg!==this.props.graph.angleOffsetDeg||e.graph.numPoints!==this.props.graph.numPoints||e.graph.numSides!==this.props.graph.numSides||e.graph.numSegments!==this.props.graph.numSegments||e.graph.showAngles!==this.props.graph.showAngles||e.graph.showSides!==this.props.graph.showSides||e.graph.snapTo!==this.props.graph.snapTo||e.graph.snapDegrees!==this.props.graph.snapDegrees)this["remove"+j(n)+"Controls"](),this["add"+j(r)+"Controls"]();this.shouldResetGraphie&&this.resetGraphie()},render:function(){var e,t;if(this.props.flexibleType){e=r.createElement("select",{value:this.props.graph.type,onChange:function(e){var t=e.target.value;this.props.onChange({graph:{type:t}})}.bind(this)},r.createElement("option",{value:"linear"},"Linear function"),r.createElement("option",{value:"quadratic"},"Quadratic function"),r.createElement("option",{value:"sinusoid"},"Sinusoid function"),r.createElement("option",{value:"circle"},"Circle"),r.createElement("option",{value:"point"},"Point(s)"),r.createElement("option",{value:"linear-system"},"Linear System"),r.createElement("option",{value:"polygon"},"Polygon"),r.createElement("option",{value:"segment"},"Line Segment(s)"),r.createElement("option",{value:"ray"},"Ray"),r.createElement("option",{value:"angle"},"Angle"));if(this.props.graph.type==="point")t=r.createElement("select",{key:"point-select",value:this.props.graph.numPoints||1,onChange:function(e){var t=+e.target.value||e.target.value;this.props.onChange({graph:{type:"point",numPoints:t,coords:null}})}.bind(this)},i.map(i.range(1,7),function(e){return r.createElement("option",{value:e},e," point",e>1&&"s")}),r.createElement("option",{value:w},"unlimited"));else if(this.props.graph.type==="polygon")t=r.createElement("div",null,r.createElement("div",null,r.createElement("select",{key:"polygon-select",value:this.props.graph.numSides||3,onChange:function(e){var t=+e.target.value||e.target.value,n=i.extend({},this.props.graph,{numSides:t,coords:null,snapTo:"grid"});this.props.onChange({graph:n})}.bind(this)},i.map(i.range(3,13),function(e){return r.createElement("option",{value:e},e," sides")}),r.createElement("option",{value:w},"unlimited sides"))),r.createElement("div",null,r.createElement("label",null," Snap to"," ",r.createElement("select",{key:"polygon-snap",value:this.props.graph.snapTo,onChange:function(e){var t=i.extend({},this.props.graph,{snapTo:e.target.value,coords:null});this.props.onChange({graph:t})}.bind(this)},r.createElement("option",{value:"grid"},"grid"),this.props.graph.numSides!==w&&[r.createElement("option",{value:"angles"}," ","interior angles"," "),r.createElement("option",{value:"sides"}," ","side measures"," ")])),r.createElement(u,null,r.createElement("p",null,"These options affect the movement of the vertex points. The grid option will guide the points to the nearest half step along the grid."),r.createElement("p",null,"The interior angle and side measure options guide the points to the nearest whole angle or side")," measure respectively."," ")),r.createElement("div",null,r.createElement("label",null,"Show angle measures:"," ",r.createElement("input",{type:"checkbox",checked:this.props.graph.showAngles,onChange:this.toggleShowAngles})),r.createElement(u,null,r.createElement("p",null,"Displays the interior angle measures."))),r.createElement("div",null,r.createElement("label",null,"Show side measures:"," ",r.createElement("input",{type:"checkbox",checked:this.props.graph.showSides,onChange:this.toggleShowSides})),r.createElement(u,null,r.createElement("p",null,"Displays the side lengths."))));else if(this.props.graph.type==="segment")t=r.createElement("select",{key:"segment-select",value:this.props.graph.numSegments||1,onChange:function(e){var t=+e.target.value;this.props.onChange({graph:{type:"segment",numSegments:t,coords:null}})}.bind(this)},i.map(i.range(1,7),function(e){return r.createElement("option",{value:e},e," segment",e>1&&"s")}));else if(this.props.graph.type==="angle"){var n=T(this.props.graph.allowReflexAngles,!0);t=r.createElement("div",null,r.createElement("div",null,r.createElement("label",null,"Show angle measure:"," ",r.createElement("input",{type:"checkbox",checked:this.props.graph.showAngles,onChange:this.toggleShowAngles}))),r.createElement("div",null,r.createElement("label",null,"Allow reflex angles:"," ",r.createElement("input",{type:"checkbox",checked:n,onChange:function(e){this.props.onChange({graph:i.extend({},this.props.graph,{allowReflexAngles:!n,coords:null})})}.bind(this)})),r.createElement(u,null,r.createElement("p",null,"Reflex angles are angles with a measure greater than 180 degrees."),r.createElement("p",null,"By default, these should remain enabled."))),r.createElement("div",null,r.createElement("label",null,"Snap to increments of"," ",r.createElement(f,{key:"degree-snap",placeholder:1,value:this.props.graph.snapDegrees,onChange:function(e){this.props.onChange({graph:i.extend({},this.props.graph,{snapDegrees:Math.abs(e),coords:null})})}.bind(this)})," ","degrees"," ")),r.createElement("div",null,r.createElement("label",null," ","With an offset of"," ",r.createElement(f,{key:"angle-offset",placeholder:0,value:this.props.graph.angleOffsetDeg,onChange:function(e){this.props.onChange({graph:i.extend({},this.props.graph,{angleOffsetDeg:e,coords:null})})}.bind(this)})," ","degrees"," ")))}}var o=this.props.box,a;this.isClickToAddPoints()&&this.state.shouldShowInstructions?this.props.graph.type==="point"?a=$._("Click to add points"):this.props.graph.type==="polygon"&&(a=$._("Click to add vertices")):a=undefined;var c=this.isClickToAddPoints()?this.handleAddPointsMouseDown:null,h=this.props.gridStep||l.getGridStep(this.props.range,this.props.step,v),p=this.props.snapStep||l.snapStepFromGridStep(h);return r.createElement("div",{className:"perseus-widget perseus-widget-interactive-graph",style:{width:o[0],height:this.props.flexibleType?"auto":o[1]}},r.createElement(s,{instructions:a,ref:"graph",box:this.props.box,labels:this.props.labels,range:this.props.range,step:this.props.step,gridStep:h,snapStep:p,markings:this.props.markings,backgroundImage:this.props.backgroundImage,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,onMouseDown:c,onGraphieUpdated:this.setGraphie}),e,t)},componentDidMount:function(){this.setGraphie(this.refs.graph.graphie())},setGraphie:function(e){this.graphie=e,this.setupGraphie()},handleAddPointsMouseDown:function(e){if(!this.isClickToAddPoints())throw new Error("handleAddPointsClick should not be registeredwhen isClickToAddPoints() is false");if(!this.isCoordInTrash(e)){var t;if(this.props.graph.type==="point"){t=this.createPointForPointsType(e,this.points.length);if(!t.constrain()){t.remove();return}this.points.push(t);var n=this.points.length-1;this.points[n].grab(e),this.updateCoordsFromPoints()}else if(this.props.graph.type==="polygon"){if(this.polygon.closed())return;t=this.createPointForPolygonType(e,this.points.length),this.points.push(t);var n=this.points.length-1;this.points[n].grab(e),this.updatePolygon()}this.setState({shouldShowInstructions:!1})}},resetGraphie:function(){this.shouldResetGraphie=!1,this.refs.graph.reset()},setupGraphie:function(){this.setTrashCanVisibility(0),this.isClickToAddPoints()&&this.setTrashCanVisibility(.5);var e=this.props.graph.type;this["add"+j(e)+"Controls"]()},setTrashCanVisibility:function(e){var t=this.graphie;c.equal(e,0)?this.trashCan&&(this.trashCan.remove(),this.trashCan=null):(this.trashCan||(this.trashCan=t.raphael.image(d,t.xpixels-40,t.ypixels-40,40,40)),this.trashCan.attr({opacity:e}))},componentWillReceiveProps:function(e){this.isClickToAddPoints()!==this.isClickToAddPoints(e)&&(this.shouldResetGraphie=!0,this.setState({shouldShowInstructions:this._getShouldShowInstructions(e)}))},isClickToAddPoints:function(e){return e=e||this.props,e.graph.type==="point"&&e.graph.numPoints===w||e.graph.type==="polygon"&&e.graph.numSides===w},addLine:function(e){var t=this,n=t.graphie,r=U.getLineCoords(t.props.graph,t.props),s=t.points=i.map(r,function(e){return a.addMovablePoint(n,{coord:e,constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap()],onMove:function(){var e=i.extend({},t.props.graph,{coords:i.invoke(s,"coord")});t.props.onChange({graph:e})},normalStyle:{stroke:KhanUtil.INTERACTIVE,fill:KhanUtil.INTERACTIVE}})}),o={points:s,"static":!0};e==="line"?o.extendLine=!0:e==="ray"&&(o.extendRay=!0);var u=t.line=a.addMovableLine(n,o);s[0].listen("constraints","isLine",function(e){return!h.equal(e,s[1].coord())}),s[1].listen("constraints","isLine",function(e){return!h.equal(e,s[0].coord())})},removeLine:function(){i.invoke(this.points,"remove"),this.line.remove()},addLinearControls:function(){this.addLine("line")},removeLinearControls:function(){this.removeLine()},addQuadraticControls:function(){var e=this.graphie,t=this.props.graph.coords;t||(t=U.defaultQuadraticCoords(this.props));var n,r,s,o=function(){var e=i.extend({},this.props.graph,{coords:[n.coord(),r.coord(),s.coord()]});this.props.onChange({graph:e}),this.updateQuadratic()}.bind(this);n=this.pointA=a.addMovablePoint(e,{coord:t[0],constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){return!n||e[0]!==r.coord()[0]&&e[0]!==s.coord()[0]}],onMove:o}),r=this.pointB=a.addMovablePoint(e,{coord:t[1],constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){return!r||e[0]!==n.coord()[0]&&e[0]!==s.coord()[0]}],onMove:o}),s=this.pointC=a.addMovablePoint(e,{coord:t[2],constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){return!s||e[0]!==n.coord()[0]&&e[0]!==r.coord()[0]}],onMove:o}),this.updateQuadratic()},updateQuadratic:function(){var e=U.getCurrentQuadraticCoefficients(this.props);if(!e)return;var t=e[0],n=e[1],r=e[2];if(this.parabola){var i=this.graphie.svgParabolaPath(t,n,r);this.parabola.attr({path:i})}else this.parabola=this.graphie.parabola(t,n,r),this.parabola.attr({stroke:KhanUtil.DYNAMIC}),this.parabola.toBack()},removeQuadraticControls:function(){this.pointA.remove(),this.pointB.remove(),this.pointC.remove(),this.parabola&&(this.parabola.remove(),this.parabola=null)},addSinusoidControls:function(){var e=this.graphie,t=this.props.graph.coords;t||(t=U.defaultSinusoidCoords(this.props));var n,r,s=function(){var e=i.extend({},this.props.graph,{coords:[n.coord(),r.coord()]});this.props.onChange({graph:e}),this.updateSinusoid()}.bind(this);n=this.pointA=a.addMovablePoint(e,{coord:t[0],constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){return!n||e[0]!==r.coord()[0]}],onMove:s}),r=this.pointB=a.addMovablePoint(e,{coord:t[1],constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){return!n||e[0]!==n.coord()[0]}],onMove:s}),this.updateSinusoid()},updateSinusoid:function(){var e=U.getCurrentSinusoidCoefficients(this.props);if(!e)return;var t=e[0],n=e[1],r=e[2],i=e[3];if(this.sinusoid){var s=this.graphie.svgSinusoidPath(t,n,r,i);this.sinusoid.attr({path:s})}else this.sinusoid=this.graphie.sinusoid(t,n,r,i),this.sinusoid.attr({stroke:KhanUtil.DYNAMIC}),this.sinusoid.toBack()},removeSinusoidControls:function(){this.pointA.remove(),this.pointB.remove(),this.sinusoid&&(this.sinusoid.remove(),this.sinusoid=null)},addCircleControls:function(){var e=this.graphie,t=i.min(e.snap),n=this.circle=e.addCircleGraph({center:this.props.graph.center||[0,0],radius:this.props.graph.radius||i.min(this.props.step),snapX:e.snap[0],snapY:e.snap[1],minRadius:t*2,snapRadius:t});$(n).on("move",function(){var e=i.extend({},this.props.graph,{center:n.center,radius:n.radius});this.props.onChange({graph:e})}.bind(this))},removeCircleControls:function(){this.circle.remove()},addLinearSystemControls:function(){var e=this.graphie,t=U.getLinearSystemCoords(this.props.graph,this.props),n=[KhanUtil.INTERACTIVE,KhanUtil.GREEN],r=this.points=i.map(t,function(t,r){var s=i.map(t,function(t,o){return a.addMovablePoint(e,{coord:t,constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){if(!s)return;return!h.equal(e,s[1-o].coord())}],onMove:function(){var e=i.extend({},this.props.graph,{coords:i.map(this.points,function(e){return i.invoke(e,"coord")})});this.props.onChange({graph:e})}.bind(this),normalStyle:{stroke:n[r],fill:n[r]}})}.bind(this));return s}.bind(this)),s=this.lines=i.map(r,function(t,r){return a.addMovableLine(e,{points:t,"static":!0,extendLine:!0,normalStyle:{stroke:n[r]}})})},removeLinearSystemControls:function(){i.invoke(this.lines,"remove"),i.map(this.points,function(e){return i.invoke(e,"remove")})},isCoordInTrash:function(e){var t=this.graphie,n=t.scalePoint(e);return n[0]>=t.xpixels-40&&n[1]>=t.ypixels-40},createPointForPointsType:function(e,t){var n=this,r=n.graphie,s=a.addMovablePoint(r,{coord:e,constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){return i.all(n.points,function(t){return s===t||!h.equal(e,t.coord())})}],onMoveStart:function(){n.isClickToAddPoints()&&n.setTrashCanVisibility(1)},onMove:n.updateCoordsFromPoints,onMoveEnd:function(e){n.isClickToAddPoints()&&(n.isCoordInTrash(e)&&(n.points=i.filter(n.points,function(e){return e!==s}),n.updateCoordsFromPoints(),setTimeout(s.remove.bind(s),0)),n.setTrashCanVisibility(.5))},normalStyle:{stroke:KhanUtil.INTERACTIVE,fill:KhanUtil.INTERACTIVE}});return s},removePoint:function(e){var t=null;return this.points=i.filter(this.points,function(n,r){return n===e?(t=r,!1):!0}),t},createPointForPolygonType:function(e,t){var n=this.graphie,r=!i.contains(["angles","sides"],this.props.graph.snapTo),s=function(e){return(t+e+this.points.length)%this.points.length}.bind(this),o=function(e){if(this.isClickToAddPoints()){if(this.isCoordInTrash(e)){var t=this.removePoint(f);this.polygon.closed()&&(this.points=B(this.points,t),this.polygon.update({closed:!1})),this.updatePolygon(),this.clearCoords(),setTimeout(f.remove.bind(f),0)}else if(this.points.length>1&&(f===this.points[0]&&h.equal(e,i.last(this.points).coord())||f===i.last(this.points)&&h.equal(e,this.points[0].coord()))){var n=this.points.pop();this.points.length>2?(this.polygon.update({closed:!0}),this.updateCoordsFromPoints()):(this.polygon.update({closed:!1}),this.clearCoords()),this.updatePolygon(),setTimeout(n.remove.bind(n),0)}else{var r=i.any(this.points,function(t){return t!==f&&h.equal(t.coord(),e)});r?(this.removePoint(f),this.points.length<3?(this.polygon.update({closed:!1}),this.clearCoords()):this.polygon.closed()&&this.updateCoordsFromPoints(),this.updatePolygon(),setTimeout(f.remove.bind(f),0)):(f===this.points[0]||f===i.last(this.points))&&!f.hasMoved()&&!f.state.isInitialMove&&!this.polygon.closed()&&this.points.length>2&&(this.polygon.update({closed:!0}),this.updatePolygon(),this.updateCoordsFromPoints())}this.setTrashCanVisibility(.5)}f.state.isInitialMove=!1}.bind(this),u=function(e){if(this.points==null||this.points.length===0)return!0;var n=i.invoke(this.points,"coord");n[t]=e;if(!this.isClickToAddPoints()){if(S(n[s(-2)],n[s(-1)],n[t])||S(n[s(-1)],n[t],n[s(1)])||S(n[t],n[s(1)],n[s(2)]))return!1;var r=i.zip(n,B(n));if(this.points.length>3)for(var o=-1;o<=0;o++){var u=r[s(o)],a=i.without(r,u,r[s(o-1)],r[s(o+1)]);for(var f=0;f<a.length;f++){var l=a[f];if(C(u,l))return!1}}}if(this.props.graph.snapTo==="angles"&&this.points.length>2){var c=i.map(M(n),function(e){return e*180/Math.PI});i.each([-1,1],function(e){c[s(e)]=Math.round(c[s(e)])});var h=function(e,t,r){var i=KhanUtil.findAngle(n[s(e)],n[s(r)],n[s(t)]);return(i+360)%360},p=[c[s(-1)]-h(-2,-1,1),c[s(1)]-h(-1,1,2)];p[2]=180-(p[0]+p[1]);if(i.any(p,function(e){return D(e,1)}))return!1;var d=L(k(n[s(-1)],n[s(1)])),v=x(E(n[s(-1)],n[s(1)],n[t]))===1,m=Math.sin(p[1]*Math.PI/180)/Math.sin(p[2]*Math.PI/180)*d,g=KhanUtil.findAngle(n[s(1)],n[s(-1)]),y=this.graphie.polar(m,g+(v?1:-1)*p[0]);return this.graphie.addPoints(n[s(-1)],y)}if(this.props.graph.snapTo==="sides"&&this.points.length>1){var b=i.map([[n[s(-1)],n[t]],[n[t],n[s(1)]],[n[s(-1)],n[s(1)]]],function(e){return L(k.apply(null,e))});i.each([0,1],function(e){b[e]=Math.round(b[e])});if(D(b[1]+b[2],b[0])||D(b[0]+b[2],b[1])||D(b[0]+b[1],b[2]))return!1;var w=P(b[0],b[2],b[1]),g=KhanUtil.findAngle(n[s(1)],n[s(-1)]),v=x(E(n[s(-1)],n[s(1)],n[t]))===1,y=this.graphie.polar(b[0],g+(v?1:-1)*w);return this.graphie.addPoints(n[s(-1)],y)}return!0}.bind(this),f=a.addMovablePoint(n,{coord:e,constraints:[a.MovablePoint.constraints.bound(),r?a.MovablePoint.constraints.snap():null,u],onMoveStart:function(){this.isClickToAddPoints()&&this.setTrashCanVisibility(1)}.bind(this),onMove:function(){this.polygon.closed()&&this.updateCoordsFromPoints()}.bind(this),onMoveEnd:o,normalStyle:{stroke:KhanUtil.INTERACTIVE,fill:KhanUtil.INTERACTIVE}});return f.state.isInitialMove=!0,f},updateCoordsFromPoints:function(){var e=i.extend({},this.props.graph,{coords:i.map(this.points,function(e){return i.result(e,"coord")})});this.props.onChange({graph:e})},clearCoords:function(){var e=i.extend({},this.props.graph,{coords:null});this.props.onChange({graph:e})},addPointControls:function(){var e=U.getPointCoords(this.props.graph,this.props);this.points=[],this.points=i.map(e,this.createPointForPointsType,this)},removePointControls:function(){i.invoke(this.points,"remove")},addSegmentControls:function(){var e=this,t=this.graphie,n=U.getSegmentCoords(this.props.graph,this.props);this.points=[],this.lines=i.map(n,function(n,r){var s=function(){var t=i.extend({},e.props.graph,{coords:i.invoke(e.lines,"coords")});e.props.onChange({graph:t})},o=i.map(n,function(e,n){return a.addMovablePoint(t,{coord:e,normalStyle:{stroke:KhanUtil.INTERACTIVE,fill:KhanUtil.INTERACTIVE},constraints:[a.MovablePoint.constraints.bound(),a.MovablePoint.constraints.snap(),function(e){if(!o)return;return!h.equal(e,o[1-n].coord())}],onMove:s})});e.points=e.points.concat(o);var u=a.addMovableLine(t,{points:o,"static":!1,constraints:[a.MovableLine.constraints.bound(),a.MovableLine.constraints.snap()],onMove:[a.MovableLine.onMove.updatePoints,s],normalStyle:{stroke:KhanUtil.INTERACTIVE},highlightStyle:{stroke:KhanUtil.INTERACTING}});return i.invoke(o,"toFront"),u},this)},removeSegmentControls:function(){i.invoke(this.points,"remove"),i.invoke(this.lines,"remove")},addRayControls:function(){this.addLine("ray")},removeRayControls:function(){this.removeLine()},addPolygonControls:function(){this.polygon=null;var e=U.getPolygonCoords(this.props.graph,this.props);this.points=[],this.points=i.map(e,this.createPointForPolygonType,this),this.updatePolygon()},updatePolygon:function(){var e;this.polygon?e=this.polygon.closed():this.points.length>=3?e=!0:e=!1;var t=this.graphie,n=this.points.length,r=!i.contains(["angles","sides"],this.props.graph.snapTo),s=i.times(n,function(t){return!this.props.graph.showAngles||!e&&(t===0||t===n-1)?"":this.props.graph.snapTo==="angles"?"$deg0":"$deg1"},this),o=i.times(n,function(t){return e||t!==0&&t!==n-1},this),u=i.times(n,function(t){return this.props.graph.showAngles&&(e||t!==0&&t!==n-1)?1:0},this),f=i.times(n,function(t){return!this.props.graph.showSides||!e&&t===n-1?"":this.props.graph.snapTo==="sides"?"$len0":"$len1"},this);if(this.polygon==null){var l=this;l.polygon=a.addMovablePolygon(t,{constraints:[a.MovablePolygon.constraints.bound(),r?a.MovablePolygon.constraints.snap():null],closed:e,points:l.points,angleLabels:s,showRightAngleMarkers:o,numArcs:u,sideLabels:f,onMove:[a.MovablePolygon.onMove.updatePoints,function(){this.closed()&&l.updateCoordsFromPoints()}]})}else this.polygon.update({closed:e,points:this.points,angleLabels:s,showRightAngleMarkers:o,numArcs:u,sideLabels:f})},removePolygonControls:function(){i.invoke(this.points,"remove"),this.polygon.remove()},addAngleControls:function(){var e=this.graphie,t=U.getAngleCoords(this.props.graph,this.props);this.points=i.map(t,function(t,n){return e.addMovablePoint(i.extend({coord:t,normalStyle:{stroke:KhanUtil.INTERACTIVE,fill:KhanUtil.INTERACTIVE}},n===1?{snapX:e.snap[0],snapY:e.snap[1]}:{}))}),this.angle=e.addMovableAngle({points:this.points,snapDegrees:this.props.graph.snapDegrees||1,snapOffsetDeg:this.props.graph.angleOffsetDeg||0,angleLabel:this.props.graph.showAngles?"$deg0":"",pushOut:2,allowReflex:T(this.props.graph.allowReflexAngles,!0)}),$(this.angle).on("move",function(){var e=i.extend({},this.props.graph,{coords:this.angle.getClockwiseCoords()});this.props.onChange({graph:e})}.bind(this))},removeAngleControls:function(){i.invoke(this.points,"remove"),this.angle.remove()},toggleShowAngles:function(){var e=i.extend({},this.props.graph,{showAngles:!this.props.graph.showAngles});this.props.onChange({graph:e})},toggleShowSides:function(){var e=i.extend({},this.props.graph,{showSides:!this.props.graph.showSides});this.props.onChange({graph:e})},getUserInput:function(){return this.props.graph},simpleValidate:function(e){return U.validate(this.getUserInput(),e,this)},focus:$.noop,statics:{displayMode:"block"}});i.extend(U,{getQuadraticCoefficients:function(e){var t=e[0],n=e[1],r=e[2],i=(t[0]-n[0])*(t[0]-r[0])*(n[0]-r[0]);if(i===0)return;var s=(r[0]*(n[1]-t[1])+n[0]*(t[1]-r[1])+t[0]*(r[1]-n[1]))/i,o=(r[0]*r[0]*(t[1]-n[1])+n[0]*n[0]*(r[1]-t[1])+t[0]*t[0]*(n[1]-r[1]))/i,u=(n[0]*r[0]*(n[0]-r[0])*t[1]+r[0]*t[0]*(r[0]-t[0])*n[1]+t[0]*n[0]*(t[0]-n[0])*r[1])/i;return[s,o,u]},getSinusoidCoefficients:function(e){var t=e[0],n=e[1],r=n[1]-t[1],i=Math.PI/(2*(n[0]-t[0])),s=t[0]*i,o=t[1];return[r,i,s,o]},getLineCoords:function(e,t){return e.coords||U.pointsFromNormalized(t,[[.25,.75],[.75,.75]])},getPointCoords:function(e,t){var n=e.numPoints||1,r=e.coords;if(r)return r;switch(n){case 1:r=[e.coord||[0,0]];break;case 2:r=[[-5,0],[5,0]];break;case 3:r=[[-5,0],[0,0],[5,0]];break;case 4:r=[[-6,0],[-2,0],[2,0],[6,0]];break;case 5:r=[[-6,0],[-3,0],[0,0],[3,0],[6,0]];break;case 6:r=[[-5,0],[-3,0],[-1,0],[1,0],[3,0],[5,0]];break;case w:r=[]}var i=[[-10,10],[-10,10]];r=U.normalizeCoords(r,i);var r=U.pointsFromNormalized(t,r);return r},getLinearSystemCoords:function(e,t){return e.coords||i.map([[[.25,.75],[.75,.75]],[[.25,.25],[.75,.25]]],function(e){return U.pointsFromNormalized(t,e)})},getPolygonCoords:function(e,t){var n=e.coords;if(n)return n;var r=e.numSides||3;if(r===w)n=[];else{var s=2*Math.PI/r,o=(1/r-.5)*Math.PI,u=e.snapTo==="sides"?Math.sqrt(3)/3*7:4;n=i.times(r,function(e){return[u*Math.cos(e*s+o),u*Math.sin(e*s+o)]})}var a=[[-10,10],[-10,10]];n=U.normalizeCoords(n,a);var f=!i.contains(["angles","sides"],e.snapTo);return n=U.pointsFromNormalized(t,n,!f),n},getSegmentCoords:function(e,t){var n=e.coords;if(n)return n;var r=e.numSegments||1,s={1:[5],2:[5,-5],3:[5,0,-5],4:[6,2,-2,-6],5:[6,3,0,-3,-6],6:[5,3,1,-1,-3,-5]}[r],o=[[-10,10],[-10,10]];return i.map(s,function(e){var n=[[-5,e],[5,e]];return n=U.normalizeCoords(n,o),n=U.pointsFromNormalized(t,n),n})},getAngleCoords:function(e,t){var n=e.coords;if(n)return n;var r=e.snapDegrees||1,i=r;while(i<20)i+=r;i=i*Math.PI/180;var s=(e.angleOffsetDeg||0)*Math.PI/180;n=U.pointsFromNormalized(t,[[.85,.5],[.5,.5]]);var o=L(k.apply(null,n));return n[0]=[n[1][0]+o*Math.cos(s),n[1][1]+o*Math.sin(s)],n[2]=[n[1][0]+o*Math.cos(i+s),n[1][1]+o*Math.sin(i+s)],n},normalizeCoords:function(e,t){return i.map(e,function(e){return i.map(e,function(e,n){var r=t[n][1]-t[n][0];return(e+t[n][1])/r})})},getEquationString:function(e){var t=e.graph.type,n="get"+j(t)+"EquationString";return U[n](e)},pointsFromNormalized:function(e,t,n){return i.map(t,function(t){return i.map(t,function(t,r){var i=e.range[r];if(n)return i[0]+(i[1]-i[0])*t;var s=e.step[r],o=q(i,s),u=Math.round(t*o);return i[0]+s*u})})},getLinearEquationString:function(e){var t=U.getLineCoords(e.graph,e);if(y(t[0][0],t[1][0]))return"x = "+t[0][0].toFixed(3);var n=(t[1][1]-t[0][1])/(t[1][0]-t[0][0]),r=t[0][1]-n*t[0][0];return y(n,0)?"y = "+r.toFixed(3):"y = "+n.toFixed(3)+"x + "+r.toFixed(3)},getCurrentQuadraticCoefficients:function(e){var t=e.graph.coords||U.defaultQuadraticCoords(e);return U.getQuadraticCoefficients(t)},defaultQuadraticCoords:function(e){var t=[[.25,.75],[.5,.25],[.75,.75]];return U.pointsFromNormalized(e,t)},getQuadraticEquationString:function(e){var t=U.getCurrentQuadraticCoefficients(e);return"y = "+t[0].toFixed(3)+"x^2 + "+t[1].toFixed(3)+"x + "+t[2].toFixed(3)},getCurrentSinusoidCoefficients:function(e){var t=e.graph.coords||U.defaultSinusoidCoords(e);return U.getSinusoidCoefficients(t)},defaultSinusoidCoords:function(e){var t=[[.5,.5],[.65,.6]];return U.pointsFromNormalized(e,t)},getSinusoidEquationString:function(e){var t=U.getCurrentSinusoidCoefficients(e);return"y = "+t[0].toFixed(3)+"sin("+t[1].toFixed(3)+"x - "+t[2].toFixed(3)+") + "+t[3].toFixed(3)},getCircleEquationString:function(e){var t=e.graph,n=t.center||[0,0],r=t.radius||2;return"center ("+n[0]+", "+n[1]+"), radius "+r},getLinearSystemEquationString:function(e){var t=U.getLinearSystemCoords(e.graph,e);return"\n"+F(t[0][0],t[0][1])+"\n"+F(t[1][0],t[1][1])+"\n"+I(t[0],t[1])},getPointEquationString:function(e){var t=U.getPointCoords(e.graph,e);return t.map(function(e){return"("+e[0]+", "+e[1]+")"}).join(", ")},getSegmentEquationString:function(e){var t=U.getSegmentCoords(e.graph,e);return i.map(t,function(e){return"["+i.map(e,function(e){return"("+e.join(", ")+")"}).join(" ")+"]"}).join(" ")},getRayEquationString:function(e){var t=U.getLineCoords(e.graph,e),n=t[0],r=t[1],i=U.getLinearEquationString(e);return n[0]>r[0]?i+=" (for x <= "+n[0].toFixed(3)+")":n[0]<r[0]?i+=" (for x >= "+n[0].toFixed(3)+")":n[1]>r[1]?i+=" (for y <= "+n[1].toFixed(3)+")":i+=" (for y >= "+n[1].toFixed(3)+")",i},getPolygonEquationString:function(e){var t=U.getPolygonCoords(e.graph,e);return i.map(t,function(e){return"("+e.join(", ")+")"}).join(" ")},getAngleEquationString:function(e){var t=U.getAngleCoords(e.graph,e),n=KhanUtil.findAngle(t[2],t[0],t[1]);return n.toFixed(0)+"° angle"+" at ("+t[1].join(", ")+")"},validate:function(e,t,n){if(e.type===t.correct.type&&e.coords)if(e.type==="linear"){var r=e.coords,s=t.correct.coords;if(S(s[0],s[1],r[0])&&S(s[0],s[1],r[1]))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="linear-system"){var r=e.coords,s=t.correct.coords;if(S(s[0][0],s[0][1],r[0][0])&&S(s[0][0],s[0][1],r[0][1])&&S(s[1][0],s[1][1],r[1][0])&&S(s[1][0],s[1][1],r[1][1])||S(s[0][0],s[0][1],r[1][0])&&S(s[0][0],s[0][1],r[1][1])&&S(s[1][0],s[1][1],r[0][0])&&S(s[1][0],s[1][1],r[0][1]))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="quadratic"){var o=this.getQuadraticCoefficients(e.coords),u=this.getQuadraticCoefficients(t.correct.coords);if(b(o,u))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="sinusoid"){var o=this.getSinusoidCoefficients(e.coords),u=this.getSinusoidCoefficients(t.correct.coords),a=H(o),f=H(u);if(b(a,f))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="circle"){if(b(e.center,t.correct.center)&&y(e.radius,t.correct.radius))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="point"){var r=e.coords,s=U.getPointCoords(t.correct,n);r=r.slice(),s=s.slice(),r.sort(),s.sort();if(b(r,s))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="polygon"){var r=e.coords.slice(),s=t.correct.coords.slice(),l;t.correct.match==="similar"?l=_(r,s,Number.POSITIVE_INFINITY):t.correct.match==="congruent"?l=_(r,s,c.DEFAULT_TOLERANCE):t.correct.match==="approx"?l=_(r,s,.1):(r.sort(),s.sort(),l=b(r,s));if(l)return{type:"points",earned:1,total:1,message:null}}else if(e.type==="segment"){var r=e.coords.slice(),s=t.correct.coords.slice();r=i.invoke(r,"sort").sort(),s=i.invoke(s,"sort").sort();if(b(r,s))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="ray"){var r=e.coords,s=t.correct.coords;if(b(r[0],s[0])&&S(s[0],s[1],r[1]))return{type:"points",earned:1,total:1,message:null}}else if(e.type==="angle"){var r=e.coords,s=t.correct.coords,l;if(t.correct.match==="congruent"){var h=i.map([r,s],function(e){var t=KhanUtil.findAngle(e[2],e[0],e[1]);return(t+360)%360});l=y.apply(null,h)}else l=b(r[1],s[1])&&S(s[1],s[0],r[0])&&S(s[1],s[2],r[2]);if(l)return{type:"points",earned:1,total:1,message:null}}return!e.coords||i.isEqual(e,t.graph)?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}});var z=r.createClass({displayName:"InteractiveGraphEditor",className:"perseus-widget-interactive-graph",getDefaultProps:function(){return{box:[m,m],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],valid:!0,backgroundImage:g,markings:"graph",showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,correct:{type:"linear",coords:null}}},mixins:[p],deprecatedProps:R,render:function(){var e,t,n=this.props.gridStep||l.getGridStep(this.props.range,this.props.step,v),s=this.props.snapStep||l.snapStepFromGridStep(n);if(this.props.valid===!0){var a={ref:"graph",box:this.props.box,range:this.props.range,labels:this.props.labels,step:this.props.step,gridStep:n,snapStep:s,graph:this.props.correct,backgroundImage:this.props.backgroundImage,markings:this.props.markings,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,flexibleType:!0,onChange:function(e){var t=this.props.correct;t.type===e.graph.type?t=i.extend({},t,e.graph):t=e.graph,this.props.onChange({correct:t})}.bind(this)};e=r.createElement(U,r.__spread({},a)),t=U.getEquationString(a)}else e=r.createElement("div",{className:"perseus-error"},this.props.valid);return r.createElement("div",{className:"perseus-widget-interactive-graph"},r.createElement("div",null,"Correct answer"," ",r.createElement(u,null,r.createElement("p",null,"Graph the correct answer in the graph below and ensure the equation or point coordinates displayed represent the correct answer."))," ",": ",t),r.createElement(o,{box:this.props.box,range:this.props.range,labels:this.props.labels,step:this.props.step,gridStep:n,snapStep:s,valid:this.props.valid,backgroundImage:this.props.backgroundImage,markings:this.props.markings,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,onChange:this.props.onChange}),this.props.correct.type==="polygon"&&r.createElement("div",{className:"type-settings"},r.createElement("label",null," ","Student answer must"," ",r.createElement("select",{value:this.props.correct.match,onChange:this.changeMatchType},r.createElement("option",{value:"exact"},"match exactly"),r.createElement("option",{value:"congruent"},"be congruent"),r.createElement("option",{value:"approx"},"be approximately congruent"),r.createElement("option",{value:"similar"},"be similar"))),r.createElement(u,null,r.createElement("ul",null,r.createElement("li",null,r.createElement("p",null,r.createElement("b",null,"Match Exactly:")," Match exactly in size, orientation, and location on the grid even if it is not shown in the background.")),r.createElement("li",null,r.createElement("p",null,r.createElement("b",null,"Be Congruent:")," Be congruent in size and shape, but can be located anywhere on the grid.")),r.createElement("li",null,r.createElement("p",null,r.createElement("b",null,"Be Approximately Congruent:")," Be exactly similar, and congruent in size and shape to within 0.1 units, but can be located anywhere on the grid. ",r.createElement("em",null,"Use this with snapping to angle measure."))),r.createElement("li",null,r.createElement("p",null,r.createElement("b",null,"Be Similar:")," Be similar with matching interior angles, and side measures that are matching or a multiple of the correct side measures. The figure can be located anywhere on the grid."))))),this.props.correct.type==="angle"&&r.createElement("div",{className:"type-settings"},r.createElement("div",null,r.createElement("label",null," ","Student answer must"," ",r.createElement("select",{value:this.props.correct.match,onChange:this.changeMatchType},r.createElement("option",{value:"exact"},"match exactly"),r.createElement("option",{value:"congruent"},"be congruent"))),r.createElement(u,null,r.createElement("p",null,"Congruency requires only that the angle measures are the same. An exact match implies congruency, but also requires that the angles have the same orientation and that the vertices are in the same position.")))),e)},changeMatchType:function(e){var t=i.extend({},this.props.correct,{match:e.target.value});this.props.onChange({correct:t})},serialize:function(){var e=i.pick(this.props,"step","backgroundImage","markings","labels","showProtractor","showRuler","rulerLabel","rulerTicks","range","gridStep","snapStep"),t=this.refs.graph;if(t){var n=t&&t.getUserInput();i.extend(e,{graph:{type:n.type},correct:n}),i.each(["allowReflexAngles","angleOffsetDeg","numPoints","numSides","numSegments","showAngles","showSides","snapTo","snapDegrees"],function(t){i.has(n,t)&&(e.graph[t]=n[t])})}return e}});e.exports={name:"interactive-graph",displayName:"Interactive graph",widget:U,editor:z}},function(e,t,n){var r=n(66),i=n(71),s=n(72),o=n(73),u=n(91),a=n(64),f=n(74),l=8,c=5,h={display:"table",tableLayout:"fixed"},p={display:"table-row"},d={display:"table-cell",padding:c},v={borderRadius:10,cursor:"pointer"},m={padding:c,display:"inline-block"},g={"float":"right",paddingRight:c},y=50,b=function(e,t){return _.map(e,function(e,n){return _.map(e,function(e,r){return t(e,n,r)})})},w=function(e,t,n){return _.times(e,function(e){return _.times(t,function(t){return n(e,t)})})},E={plus:function(){return[[!1,!0,!1],[!0,!0,!0],[!1,!0,!1]]},x:function(){return[[!0,!1,!0],[!1,!0,!1],[!0,!1,!0]]},"plus/x":function(e){return e%2?E.x():E.plus()}},S=function(e,t,n){return e=Math.floor(e),e=Math.max(e,t),e=Math.min(e,n),e},x=r.createClass({displayName:"Tile",propTypes:{value:r.PropTypes.bool.isRequired,size:r.PropTypes.number.isRequired},render:function(){var e=this.props.value?"#55dd55":"#115511",t=_.extend({},v,{width:this.props.size,height:this.props.size,backgroundColor:e});return r.createElement("div",{style:t,onClick:this._flip})},_flip:function(){this.props.onChange(!this.props.value)}}),T=r.createClass({displayName:"TileGrid",propTypes:{cells:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.bool)).isRequired,size:r.PropTypes.number.isRequired},render:function(){return r.createElement("div",{style:h,className:"no-select"},_.map(this.props.cells,function(e,t){return r.createElement("div",{key:t,style:p},_.map(e,function(e,n){return r.createElement("div",{key:n,style:d},r.createElement(x,{value:e,size:this.props.size,onChange:_.partial(this.props.onChange,t,n)}))}.bind(this)))}.bind(this)))}}),N=function(e,t){return _.map(e,function(e,n){return _.map(e,function(e,r){return t(n,r)?!e:e})})},C=function(e,t,n,r){return N(e,function(e,i){var s=e-t,o=i-n;return Math.abs(s)<=1&&Math.abs(o)<=1?r[s+1][o+1]:!1})},k=r.createClass({displayName:"LightsPuzzle",mixins:[i,o],propTypes:{cells:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.bool)),startCells:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.bool)),flipPattern:r.PropTypes.string.isRequired,moveCount:r.PropTypes.number.isRequired},getDefaultProps:function(){return{cells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",moveCount:0}},render:function(){var e=this._width(),t=y,n=e*(t+2*c);return r.createElement("div",null,r.createElement(T,{cells:this.props.cells,size:t,onChange:this._flipTile}),r.createElement("div",{style:{width:n}},r.createElement("div",{style:m},"Moves: ",this.props.moveCount),r.createElement("div",{style:g},r.createElement("input",{type:"button",value:"Reset",onClick:this._reset,className:"simple-button"}))),r.createElement("div",{className:"clearfix"}))},_width:function(){return this.props.cells.length!==0?this.props.cells[0].length:0},componentDidMount:function(){this._initNextPatterns()},componentDidUpdate:function(e){e.flipPattern!==this.props.flipPattern&&this._initNextPatterns()},_initNextPatterns:function(){this._currPattern=E[this.props.flipPattern](0),this._nextPattern=E[this.props.flipPattern](1),this._patternIndex=2},_shiftPatterns:function(){this._currPattern=this._nextPattern,this._nextPattern=E[this.props.flipPattern](this._patternIndex),this._patternIndex++},_flipTile:function(e,t){var n=C(this.props.cells,e,t,this._currPattern);this._shiftPatterns(),this.change({cells:n,moveCount:this.props.moveCount+1})},_reset:function(){this.change({cells:this.props.startCells,moveCount:0})},simpleValidate:function(e){return A(e,this.getUserInput())},statics:{displayMode:"block"}}),L=r.createClass({displayName:"LightsPuzzleEditor",mixins:[i,s],propTypes:{startCells:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.bool)),flipPattern:r.PropTypes.string.isRequired,gradeIncompleteAsWrong:r.PropTypes.bool.isRequired},getDefaultProps:function(){return{startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",gradeIncompleteAsWrong:!1}},_height:function(){return this.props.startCells.length},_width:function(){return this.props.startCells.length!==0?this.props.startCells[0].length:0},render:function(){return r.createElement("div",null,r.createElement("div",null,"Width:",r.createElement(u,{value:this._width(),placeholder:5,onChange:this._changeWidth}),", ","Height:",r.createElement(u,{value:this._height(),placeholder:5,onChange:this._changeHeight})),r.createElement("div",null,"Flip pattern:",r.createElement("select",{value:this.props.flipPattern,onChange:this._handlePatternChange},_.map(_.keys(E),function(e,t){return r.createElement("option",{value:e,key:t},e)}))),r.createElement("div",null,"Grade incomplete puzzles as wrong:"," ",r.createElement(a,{gradeIncompleteAsWrong:this.props.gradeIncompleteAsWrong,onChange:this.props.onChange}),r.createElement(f,null,"By default, incomplete puzzles are graded as empty.")),r.createElement("div",null,"Starting configuration:"),r.createElement("div",{style:{overflowX:"auto"}},r.createElement(T,{cells:this.props.startCells,size:50,onChange:this._switchTile})))},_handlePatternChange:function(e){this.change("flipPattern",e.target.value)},_changeWidth:function(e){e=S(e,1,l),this._truncateCells(e,this._height())},_changeHeight:function(e){e=S(e,1,l),this._truncateCells(this._width(),e)},_truncateCells:function(e,t){var n=_.times(t,function(t){return _.times(e,function(e){return!!this.props.startCells[t]&&!!this.props.startCells[t][e]}.bind(this))}.bind(this));this.change({startCells:n})},_switchTile:function(e,t){var n=N(this.props.startCells,function(n,r){return n===e&&r===t});this.change({startCells:n})}}),A=function(e,t){var n=_.all(t.cells,function(t,n){return _.all(t,function(t,r){return t===e.startCells[n][r]})});if(n)return{type:"invalid",message:$._("Click on the tiles to change the lights.")};var r=_.all(t.cells,function(e){return _.all(e,function(e){return e})});return r?{type:"points",earned:1,total:1,message:null}:e.gradeIncompleteAsWrong?{type:"points",earned:0,total:1,message:null}:{type:"invalid",message:$._("You must turn on all of the lights to continue.")}},O=function(e){return{cells:e.startCells,startCells:e.startCells,flipPattern:e.flipPattern}};e.exports={name:"lights-puzzle",displayName:"Lights Puzzle",hidden:!0,widget:k,editor:L,transform:O}},function(e,t,n){var r=n(109),i=n(66),s=n(62),o=n(71),u=n(72),a=n(10),f=n(91),l=n(88),c=n(14),h=n(89),p=n(92),d=n(16).Options,v=n(93).assert,m=n(5).stringArrayOfSize,g=6,y={INPUT_MARGIN:4,INPUT_HEIGHT:38,INPUT_WIDTH:82},b={INPUT_MARGIN:3,INPUT_HEIGHT:30,INPUT_WIDTH:40},w=function(e,t){return[""+e,""+t]},E=function(){return w(0,0)},S=function(e){return v(s.isArray(e)&&e.length===2),+e[0]},x=function(e){return v(s.isArray(e)&&e.length===2),+e[1]},T=function(e){var t=S(e),n=x(e);return"answer"+t+","+n},N=function(e){var t=[1,1];return s(e).each(function(e,n){var r=0;s(e).each(function(e,t){e!=null&&e.toString().length&&(r=t+1)}),t[1]=Math.max(t[1],r),r>0&&(t[0]=Math.max(t[0],n+1))}),t},C=i.createClass({displayName:"Matrix",propTypes:{matrixBoardSize:i.PropTypes.arrayOf(i.PropTypes.number).isRequired,answers:i.PropTypes.arrayOf(i.PropTypes.arrayOf(i.PropTypes.oneOfType([i.PropTypes.string,i.PropTypes.number]))),prefix:i.PropTypes.string,suffix:i.PropTypes.string,cursorPosition:i.PropTypes.arrayOf(i.PropTypes.number)},getDefaultProps:function(){return{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0],apiOptions:d.defaults}},getInitialState:function(){return{enterTheMatrix:0}},componentDidMount:function(){this.cursorPosition=[0,0]},render:function(){var e=this.props.apiOptions.staticRender?y:b,t=e,n=t.INPUT_MARGIN,o=t.INPUT_HEIGHT,u=t.INPUT_WIDTH,a=N(this.props.answers),l=this.props.matrixBoardSize[0],d=this.props.matrixBoardSize[1],v=this.props.cursorPosition[0],m=this.props.cursorPosition[1],g=Math.max(v,a[0]-1),E=Math.max(m,a[1]-1),S=(g+1)*(o+2*n),x=(E+1)*(u+2*n),C=r({"perseus-matrix":!0,"the-matrix":this.state.enterTheMatrix>=5});return i.createElement("div",{className:C},this.props.prefix&&i.createElement("div",{className:"matrix-prefix"},i.createElement(c,{content:this.props.prefix})),i.createElement("div",{className:"matrix-input"},i.createElement("div",{className:"matrix-bracket bracket-left",style:{height:S}}),i.createElement("div",{className:"matrix-bracket bracket-right",style:{height:S,left:x}}),s(l).times(function(e){var t=this.props.answers[e];return i.createElement("div",{className:"matrix-row",key:e},s(d).times(function(r){var s=e>g||r>E,a={className:s?"outside":"inside",ref:T(w(e,r)),value:t?t[r]:null,style:{height:o,width:u,margin:n},onFocus:function(){this.cursorPosition=[e,r],this.props.onChange({cursorPosition:[e,r]},function(){return!1}),this._handleFocus(e,r)}.bind(this),onBlur:function(){e===this.cursorPosition[0]&&r===this.cursorPosition[1]&&this.props.onChange({cursorPosition:[0,0]},function(){return!1}),this._handleBlur(e,r)}.bind(this),onKeyDown:function(t){this.handleKeyDown(e,r,t)}.bind(this),onChange:function(t){this.onValueChange(e,r,t)}.bind(this)},l;return this.props.apiOptions.staticRender?l=i.createElement(p,i.__spread({},a)):this.props.numericInput?l=i.createElement(f,i.__spread({},a)):l=i.createElement(h,i.__spread({},a)),i.createElement("span",{key:r,className:"matrix-input-field"},l)}.bind(this)))}.bind(this))),this.props.suffix&&i.createElement("div",{className:"matrix-suffix"},i.createElement(c,{content:this.props.suffix})))},getInputPaths:function(){var e=[],t=this.props.matrixBoardSize[0],n=this.props.matrixBoardSize[1];return s(t).times(function(t){s(n).times(function(n){var r=w(t,n);e.push(r)})}),e},getGrammarTypeForPath:function(e){return"number"},_handleFocus:function(e,t){this.props.onFocus(w(e,t))},_handleBlur:function(e,t){this.props.onBlur(w(e,t))},focus:function(){return this.focusInputPath(E()),!0},focusInputPath:function(e){var t=T(e);this.refs[t].focus()},blurInputPath:function(e){e.length===0&&(e=E());var t=T(e);this.refs[t].blur()},getDOMNodeForPath:function(e){var t=T(e);return this.refs[t].getDOMNode()},setInputValue:function(e,t,n){var r=S(e),i=x(e);this.onValueChange(r,i,t,n)},handleKeyDown:function(e,t,n){var r=this.props.matrixBoardSize[0],i=this.props.matrixBoardSize[1],s=null,o=this.refs[T(w(e,t))],u=o.getStringValue(),a=o.getSelectionStart(),f=o.getSelectionEnd(),l=null;n.key==="ArrowUp"&&e>0?l=w(e-1,t):n.key==="ArrowDown"&&e+1<r?l=w(e+1,t):n.key==="ArrowLeft"&&t>0?a===0&&f===0&&(l=w(e,t-1)):n.key==="ArrowRight"&&t+1<i?a===u.length&&(l=w(e,t+1)):n.key==="Enter"?s=this.state.enterTheMatrix+1:n.key==="Escape"&&(s=0);if(l){n.preventDefault();var c=this.refs[T(l)],h=c.getStringValue(),p=h.length*2;c.focus(),n.key==="ArrowRight"?c.setSelectionRange(0,0):c.setSelectionRange(p,p)}s!=null&&this.setState({enterTheMatrix:s})},onValueChange:function(e,t,n,r){var i=s.map(this.props.answers,s.clone);i[e]||(i[e]=[]),i[e][t]=n,this.props.onChange({answers:i},r)},getUserInput:function(){return{answers:this.props.answers}},simpleValidate:function(e){return C.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});s.extend(C,{validate:function(e,t){var n=t.answers,r=e.answers,i=N(n),o=N(r),u=i[0]!==o[0]||i[1]!==o[1],a=Khan.answerTypes.number.createValidatorFunctional,f=null,l=!1,c=!1;return s(o[0]).times(function(e){s(o[1]).times(function(t){if(r[e][t]==null||r[e][t].toString().length===0)l=!0;var i=a(n[e][t],{simplify:!0}),s=i(r[e][t]);s.message&&(f=s.message),s.correct||(c=!0)})}),l?{type:"invalid",message:$._("Make sure you fill in all cells in the matrix.")}:u?{type:"points",earned:0,total:1,message:null}:{type:"points",earned:c?0:1,total:1,message:f}}});var k=i.createClass({displayName:"MatrixEditor",mixins:[u,o],propTypes:{matrixBoardSize:i.PropTypes.arrayOf(i.PropTypes.number).isRequired,answers:i.PropTypes.arrayOf(i.PropTypes.arrayOf(i.PropTypes.number)),prefix:i.PropTypes.string,suffix:i.PropTypes.string,cursorPosition:i.PropTypes.arrayOf(i.PropTypes.number)},getDefaultProps:function(){return{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]}},render:function(){var e=s.extend({numericInput:!0,onBlur:function(){},onFocus:function(){}},this.props);return i.createElement("div",{className:"perseus-matrix-editor"},i.createElement("div",{className:"perseus-widget-row"}," ","Max matrix size:"," ",i.createElement(l,{value:this.props.matrixBoardSize,onChange:this.onMatrixBoardSizeChange,format:this.props.labelStyle,useArrowKeys:!0})),i.createElement("div",{className:"perseus-widget-row"},i.createElement(C,i.__spread({},e))),i.createElement("div",{className:"perseus-widget-row"}," ","Matrix prefix:"," ",i.createElement(a,{ref:"prefix",content:this.props.prefix,widgetEnabled:!1,onChange:function(e){this.change({prefix:e.content})}.bind(this)})),i.createElement("div",{className:"perseus-widget-row"}," ","Matrix suffix:"," ",i.createElement(a,{ref:"suffix",content:this.props.suffix,widgetEnabled:!1,onChange:function(e){this.change({suffix:e.content})}.bind(this)})))},onMatrixBoardSizeChange:function(e){var t=N(this.props.answers);if(e[0]!==null&&e[1]!==null){e=[Math.round(Math.min(Math.max(e[0],1),g)),Math.round(Math.min(Math.max(e[1],1),g))];var n=s(Math.min(e[0],t[0])).times(function(n){return s(Math.min(e[1],t[1])).times(function(e){return this.props.answers[n][e]}.bind(this))}.bind(this));this.props.onChange({matrixBoardSize:e,answers:n})}}}),L=function(e){var t=s(e.matrixBoardSize[0]).times(function(){return m(e.matrixBoardSize[1])});return e=s.pick(e,"matrixBoardSize","prefix","suffix"),s.extend(e,{answers:t})};e.exports={name:"matrix",displayName:"Matrix",widget:C,editor:k,transform:L}},function(e,t,n){var r=n(66),i=n(62),s=n(74),o=n(64),u=n(14),a=n(95),f=n(75),l=n(5).shuffle,c=n(5).seededRNG,h=r.createClass({displayName:"Matcher",propTypes:{left:r.PropTypes.array,right:r.PropTypes.array,labels:r.PropTypes.array,orderMatters:r.PropTypes.bool,padding:r.PropTypes.bool,problemNum:r.PropTypes.number,onChange:r.PropTypes.func},getDefaultProps:function(){return{left:[],right:[],labels:["",""],orderMatters:!1,padding:!0,problemNum:0,onChange:function(){}}},getInitialState:function(){return{leftHeight:0,rightHeight:0}},render:function(){var e=c(this.props.problemNum),t;this.props.orderMatters?t=l(this.props.left,e,!0):t=this.props.left;var n=l(this.props.right,e,!0),s=i.any(this.props.labels),o={height:i.max([this.state.leftHeight,this.state.rightHeight])};return r.createElement("div",{className:"perseus-widget-matcher ui-helper-clearfix"},r.createElement("div",{className:"column"},s&&r.createElement("div",{className:"column-label"},r.createElement(u,{content:this.props.labels[0]||"..."})),r.createElement(a,{options:t,layout:"vertical",padding:this.props.padding,disabled:!this.props.orderMatters,constraints:o,onMeasure:this.onMeasureLeft,onChange:this.props.onChange,ref:"left"})),r.createElement("div",{className:"column"},s&&r.createElement("div",{className:"column-label"},r.createElement(u,{content:this.props.labels[1]||"..."})),r.createElement(a,{options:n,layout:"vertical",padding:this.props.padding,constraints:o,onMeasure:this.onMeasureRight,onChange:this.props.onChange,ref:"right"})))},onMeasureLeft:function(e){var t=i.max(e.heights);this.setState({leftHeight:t})},onMeasureRight:function(e){var t=i.max(e.heights);this.setState({rightHeight:t})},getUserInput:function(){return{left:this.refs.left.getOptions(),right:this.refs.right.getOptions()}},simpleValidate:function(e){return h.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});i.extend(h,{validate:function(e,t){var n=i.isEqual(e.left,t.left)&&i.isEqual(e.right,t.right);return{type:"points",earned:n?1:0,total:1,message:null}}});var p=r.createClass({displayName:"MatcherEditor",propTypes:{left:r.PropTypes.array,right:r.PropTypes.array,labels:r.PropTypes.array,orderMatters:r.PropTypes.bool,padding:r.PropTypes.bool},getDefaultProps:function(){return{left:["$x$","$y$","$z$"],right:["$1$","$2$","$3$"],labels:["test","label"],orderMatters:!1,padding:!0}},render:function(){return r.createElement("div",{className:"perseus-matcher-editor"},r.createElement("div",null," ","Correct answer:"," ",r.createElement(s,null,r.createElement("p",null,"Enter the correct answers here. The preview on the right will show the cards in a randomized order, which is how the student will see them."))),r.createElement("div",{className:"ui-helper-clearfix"},r.createElement(f,{options:this.props.left,onChange:function(e,t){this.props.onChange({left:e},t)}.bind(this),layout:"vertical"}),r.createElement(f,{options:this.props.right,onChange:function(e,t){this.props.onChange({right:e},t)}.bind(this),layout:"vertical"})),r.createElement("span",null," ","Labels:"," ",r.createElement(s,null,r.createElement("p",null,"These are entirely optional."))),r.createElement("div",null,r.createElement("input",{type:"text",defaultValue:this.props.labels[0],onChange:this.onLabelChange.bind(this,0)}),r.createElement("input",{type:"text",defaultValue:this.props.labels[1],onChange:this.onLabelChange.bind(this,1)})),r.createElement("div",null,r.createElement(o,{label:"Order of the matched pairs matters:",orderMatters:this.props.orderMatters,onChange:this.props.onChange}),r.createElement(s,null,r.createElement("p",null,"With this option enabled, only the order provided above will be treated as correct. This is useful when ordering is significant, such as in the context of a proof."),r.createElement("p",null,"If disabled, pairwise matching is sufficient. To make this clear, the left column becomes fixed in the provided order and only the cards in the right column can be moved."))),r.createElement("div",null,r.createElement(o,{label:"Padding:",padding:this.props.padding,onChange:this.props.onChange}),r.createElement(s,null,r.createElement("p",null,"Padding is good for text, but not needed for images."))))},onLabelChange:function(e,t){var n=i.clone(this.props.labels);n[e]=t.target.value,this.props.onChange({labels:n})},getSaveWarnings:function(){return this.props.left.length!==this.props.right.length?["The two halves of the matcher have different numbers of cards."]:[]},serialize:function(){return i.pick(this.props,"left","right","labels","orderMatters","padding")}});e.exports={name:"matcher",displayName:"Two column matcher",widget:h,editor:p}},function(e,t,n){var r=n(66),i=n(62),s=n(71),o=n(72),u=n(74),a=n(91),f=n(64),l=n(88),c={url:null,top:0,left:0},h=r.createClass({displayName:"Measurer",propTypes:{box:r.PropTypes.arrayOf(r.PropTypes.number),image:r.PropTypes.shape({url:r.PropTypes.string,top:r.PropTypes.number,left:r.PropTypes.number}),showProtractor:r.PropTypes.bool,protractorX:r.PropTypes.number,protractorY:r.PropTypes.number,showRuler:r.PropTypes.bool,rulerLabel:r.PropTypes.string,rulerTicks:r.PropTypes.number,rulerPixels:r.PropTypes.number,rulerLength:r.PropTypes.number},getDefaultProps:function(){return{box:[480,480],image:{},showProtractor:!0,protractorX:7.5,protractorY:.5,showRuler:!1,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10}},getInitialState:function(){return{}},render:function(){var e=i.extend({},c,this.props.image);return r.createElement("div",{className:"perseus-widget perseus-widget-measurer graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]}},e.url&&r.createElement("img",{src:e.url,style:{top:e.top,left:e.left}}),r.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this.setupGraphie()},componentDidUpdate:function(e){var t=i.any(["box","showProtractor","showRuler","rulerLabel","rulerTicks","rulerPixels","rulerLength"],function(t){return e[t]!==this.props[t]},this);t&&this.setupGraphie()},setupGraphie:function(){var e=this.refs.graphieDiv.getDOMNode();$(e).empty();var t=this.graphie=KhanUtil.createGraphie(e),n=[40,40],r=[[0,this.props.box[0]/n[0]],[0,this.props.box[1]/n[1]]];t.init({range:r,scale:n}),t.addMouseLayer({allowScratchpad:!0}),this.protractor&&this.protractor.remove(),this.props.showProtractor&&(this.protractor=t.protractor([this.props.protractorX,this.props.protractorY])),this.ruler&&this.ruler.remove(),this.props.showRuler&&(this.ruler=t.ruler({center:[(r[0][0]+r[0][1])/2,(r[1][0]+r[1][1])/2],label:this.props.rulerLabel,pixelsPerUnit:this.props.rulerPixels,ticksPerUnit:this.props.rulerTicks,units:this.props.rulerLength}))},getUserInput:function(){return{}},simpleValidate:function(e){return h.validate(this.getUserInput(),e)},focus:$.noop,statics:{displayMode:"block"}});i.extend(h,{validate:function(e,t){return{type:"points",earned:1,total:1,message:null}}});var p=r.createClass({displayName:"MeasurerEditor",mixins:[s,o],className:"perseus-widget-measurer",propTypes:{box:r.PropTypes.arrayOf(r.PropTypes.number),image:r.PropTypes.shape({url:r.PropTypes.string,top:r.PropTypes.number,left:r.PropTypes.number}),showProtractor:r.PropTypes.bool,showRuler:r.PropTypes.bool,rulerLabel:r.PropTypes.string,rulerTicks:r.PropTypes.number,rulerPixels:r.PropTypes.number,rulerLength:r.PropTypes.number},getDefaultProps:function(){return{box:[480,480],image:{},showProtractor:!0,showRuler:!1,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10}},render:function(){var e=i.extend({},c,this.props.image);return r.createElement("div",{className:"perseus-widget-measurer"},r.createElement("div",null,"Image displayed under protractor and/or ruler:"),r.createElement("div",null,"URL:"," ",r.createElement("input",{type:"text",className:"perseus-widget-measurer-url",ref:"image-url",defaultValue:e.url,onChange:this._changeUrl}),r.createElement(u,null,r.createElement("p",null,'Create an image in graphie, or use the "Add image" function to create a background.'))),e.url&&r.createElement("div",{className:"perseus-widget-row"},r.createElement("label",{className:"perseus-widget-left-col"},"Pixels from top:"," ",r.createElement(a,{placeholder:0,onChange:this._changeTop,value:e.top,useArrowKeys:!0})),r.createElement("label",{className:"perseus-widget-right-col"},"Pixels from left:"," ",r.createElement(a,{placeholder:0,onChange:this._changeLeft,value:e.left,useArrowKeys:!0}))),r.createElement("div",null,"Containing area [width, height]:"," ",r.createElement(l,{onChange:this.change("box"),value:this.props.box,useArrowKeys:!0})),r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},r.createElement(f,{label:"Show ruler",showRuler:this.props.showRuler,onChange:this.props.onChange})),r.createElement("div",{className:"perseus-widget-right-col"},r.createElement(f,{label:"Show protractor",showProtractor:this.props.showProtractor,onChange:this.props.onChange}))),this.props.showRuler&&r.createElement("div",null,r.createElement("div",null,r.createElement("label",null," ","Ruler label:"," ",r.createElement("select",{onChange:function(e){return this.change("rulerLabel",e.target.value)}.bind(this),value:this.props.rulerLabel},r.createElement("option",{value:""},"None"),r.createElement("optgroup",{label:"Metric"},this.renderLabelChoices([["milimeters","mm"],["centimeters","cm"],["meters","m"],["kilometers","km"]])),r.createElement("optgroup",{label:"Imperial"},this.renderLabelChoices([["inches","in"],["feet","ft"],["yards","yd"],["miles","mi"]]))))),r.createElement("div",null,r.createElement("label",null," ","Ruler ticks:"," ",r.createElement("select",{onChange:function(e){return this.change("rulerTicks",+e.target.value)}.bind(this),value:this.props.rulerTicks},i.map([1,2,4,8,10,16],function(e){return r.createElement("option",{key:e,value:e},e)})))),r.createElement("div",null,r.createElement("label",null,"Ruler pixels per unit:"," ",r.createElement(a,{placeholder:40,onChange:this.change("rulerPixels"),value:this.props.rulerPixels,useArrowKeys:!0}))),r.createElement("div",null,r.createElement("label",null,"Ruler length in units:"," ",r.createElement(a,{placeholder:10,onChange:this.change("rulerLength"),value:this.props.rulerLength,useArrowKeys:!0})))))},_changeUrl:function(e){this._changeImage("url",e.target.value)},_changeTop:function(e){this._changeImage("top",e)},_changeLeft:function(e){this._changeImage("left",e)},_changeImage:function(e,t){var n=i.clone(this.props.image);n[e]=t,this.change("image",n)},renderLabelChoices:function(e){return i.map(e,function(e){var t=e,n=t[0],i=t[1];return r.createElement("option",{key:i,value:i},n)})}});propUpgrades={1:function(e){var t=i(e).chain().omit("imageUrl","imageTop","imageLeft").extend({image:{url:e.imageUrl,top:e.imageTop,left:e.imageLeft}}).value();return t}},e.exports={name:"measurer",displayName:"Measurer",widget:h,editor:p,version:{major:1,minor:0},propUpgrades:propUpgrades}},function(e,t,n){function L(e,t){return t===1?""+e:e+"/"+t}function A(e,t){if(e<0)return"-"+A(-e,t);var n=Math.floor(e/t);return n===0?L(e,t):e-n*t===0?""+n:n+"\\:"+L(e-n*t,t)}function O(e,t,n){var r=Math.floor(n/t);return L(e*r,n)}var r=n(66),i=n(62),s=n(71),o=n(72),u=n(83),a=n(74),f=n(85),l=n(91),c=n(64),h=n(88),p=n(92),d=n(16).Options,v=n(76),m=v.MovablePoint,g=v.Line,y=v.Label,b=n(108).number,w=n(108).point,E=function(e,t,n){return Math.min(Math.max(e,t),n)},S=n(5).deepEq,T=n(93).assert,N="–",C={ge:"le",gt:"lt",le:"ge",lt:"gt"},k={ge:"gt",gt:"ge",le:"lt",lt:"le"};_label=function(e,t,n,r,i){r=r||n;if(t==="decimal"||t==="decimal ticks")return e.label([n,-0.53],Math.round(r*100)/100,"center");if(t==="improper"){var s=KhanUtil.toFraction(r);return e.label([n,-0.53],L(s[0],s[1]),"center")}if(t==="mixed"){var s=KhanUtil.toFraction(r);return e.label([n,-0.53],A(s[0],s[1]),"center")}if(t==="non-reduced"){var s=KhanUtil.toFraction(r);return e.label([n,-0.53],O(s[0],s[1],i),"center")}},TickMarks=v.createSimpleClass(function(e,t){if(!i.isFinite(t.tickStep)||t.tickStep<=0)return[];var n=[],r=t.range,s=t.labelRange,r=t.range,o=s[0]==null?r[0]:s[0],u=s[1]==null?r[1]:s[1],a;if(t.labelStyle==="non-reduced"){var f=[o,u];for(var l=0;l<=t.numDivisions;l++){var c=r[0]+l*t.tickStep;f.push(c)}var h=function(e){return b.toFraction(e)[1]},p=i.map(f,h);a=i.reduce(p,function(e,t){return KhanUtil.getLCM(e,t)})}else a=undefined;for(var l=0;l<=t.numDivisions;l++){var c=r[0]+l*t.tickStep;n.push(e.line([c,-0.2],[c,.2]));var d=t.labelTicks;(d||t.labelStyle==="decimal ticks")&&n.push(_label(e,t.labelStyle,c,c,a))}return e.style({color:KhanUtil.DYNAMIC},function(){n.push(_label(e,t.labelStyle,o,o,a)),n.push(_label(e,t.labelStyle,u,u,a))}),e.style({stroke:KhanUtil.DYNAMIC,strokeWidth:3.5},function(){n.push(e.line([o,-0.2],[o,.2])),n.push(e.line([u,-0.2],[u,.2]))}),n});var M=r.createClass({displayName:"NumberLine",mixins:[s],propTypes:{range:r.PropTypes.arrayOf(r.PropTypes.number).isRequired,labelRange:r.PropTypes.array.isRequired,labelStyle:r.PropTypes.string.isRequired,labelTicks:r.PropTypes.bool.isRequired,divisionRange:r.PropTypes.arrayOf(r.PropTypes.number).isRequired,numDivisions:r.PropTypes.number.isRequired,snapDivisions:r.PropTypes.number.isRequired,isTickCtrl:r.PropTypes.bool.isRequired,isInequality:r.PropTypes.bool.isRequired,numLinePosition:r.PropTypes.number.isRequired,rel:r.PropTypes.oneOf(["lt","gt","le","ge"])},getDefaultProps:function(){return{range:[0,10],labelStyle:"decimal",labelRange:[null,null],divisionRange:[1,12],labelTicks:!0,isTickCtrl:!1,isInequality:!1,numLinePosition:0,snapDivisions:2,rel:"ge",apiOptions:d.defaults}},isValid:function(){var e=this.props.range,t=this.props.numLinePosition,n=this.props.divisionRange;return t=t==null?e[0]:t,e[0]<e[1]&&t>=e[0]&&t<=e[1]&&n[0]<n[1]&&0<this.props.numDivisions&&0<this.props.snapDivisions},render:function(){var e=this.props.range,t=e[1]-e[0],n=this.props.divisionRange,s=n[0]+N+n[1],o=this.props.numDivisions<n[0]||this.props.numDivisions>n[1],u=r.createElement("div",null,r.createElement("input",{type:"button",className:"simple-button",value:$._("Switch direction"),onClick:this.handleReverse}),r.createElement("input",{type:"button",className:"simple-button",value:i(["le","ge"]).contains(this.props.rel)?$._("Make circle open"):$._("Make circle filled"),onClick:this.handleToggleStrict})),a;if(this.props.isTickCtrl){var f;this.props.apiOptions.staticRender?f=p:f=l,a=r.createElement("label",null,$_(null,"Number of divisions:")," ",r.createElement(f,{ref:"tick-ctrl",value:this.props.numDivisions||n[0],checkValidity:function(e){return e>=n[0]&&e<=n[1]},onChange:this.onNumDivisionsChange,onFocus:this._handleTickCtrlFocus,onBlur:this._handleTickCtrlBlur,useArrowKeys:!0}))}return r.createElement("div",{className:"perseus-widget perseus-widget-interactive-number-line"},a,this.isValid()?this.props.isTickCtrl&&o?r.createElement("div",{className:"perseus-error"},$_({divRangeString:s},"Please make sure the number of divisions is in the range %(divRangeString)s.")):this._renderGraphie():r.createElement("div",{className:"perseus-error"},"Invalid number line configuration."),this.props.isInequality&&u)},onNumDivisionsChange:function(e,t){var n=this.props.divisionRange.slice(),r=this.props.range[1]-this.props.range[0];e=Math.round(e),e=e<0?e*-1:e;if(e){var s=i.extend({},this.props,{tickStep:r/e}),o=this.snapNumLinePosition(s,this.props.numLinePosition);this.props.onChange({divisionRange:n,numDivisions:e,numLinePosition:o},t)}},_handleTickCtrlFocus:function(){this.props.onFocus(["tick-ctrl"])},_handleTickCtrlBlur:function(){this.props.onBlur(["tick-ctrl"])},focus:function(){if(this.props.isTickCtrl)return this.refs["tick-ctrl"].focus(),!0},focusInputPath:function(e){e.length===1&&this.refs[e[0]].focus()},blurInputPath:function(e){e.length===1&&this.refs[e[0]].blur()},getInputPaths:function(){return this.props.isTickCtrl?[["tick-ctrl"]]:[]},getDOMNodeForPath:function(e){if(e.length===1)return this.refs[e[0]].getDOMNode()},getGrammarTypeForPath:function(e){if(e.length===1&&e[0]==="tick-ctrl")return"number"},setInputValue:function(e,t,n){e.length===1&&e[0]==="tick-ctrl"&&this.onNumDivisionsChange(t,n)},_renderGraphie:function(){var e=400,t=this.props.range,n=t[1]-t[0],s=n/e,o=30*s,u=t[0]-o,a=t[1]+o,f=-1,l=1,c=i.pick(this.props,["range","isTickCtrl"]),h=i.extend({},this.props,{tickStep:n/this.props.numDivisions});return r.createElement(v,{ref:"graphie",box:[460,80],options:c,onMouseDown:function(e){this.refs.graphie.movables.numberLinePoint.grab(e)}.bind(this),setup:this._setupGraphie},r.createElement(TickMarks,r.__spread({},i.pick(h,["range","numDivisions","labelTicks","labelStyle","labelRange","tickStep"]))),this._renderInequality(h),this._renderNumberLinePoint(h))},snapNumLinePosition:function(e,t){var n=e.range[0],r=e.range[1],s=e.tickStep/e.snapDivisions;return x=E(t,n,r),x=n+b.roundTo(x-n,s),T(i.isFinite(x)),x},_renderNumberLinePoint:function(e){var t=i(["lt","gt"]).contains(e.rel),n={fill:t?KhanUtil._BACKGROUND:KhanUtil.INTERACTIVE,"stroke-width":t?3:1},s={fill:t?KhanUtil._BACKGROUND:KhanUtil.INTERACTING,"stroke-width":t?3:1};return r.createElement(m,{ref:"numberLinePoint",pointSize:6,coord:[e.numLinePosition,0],constraints:[function(e,t){return[e[0],t[1]]},function(t,n){var r=this.snapNumLinePosition(e,t[0]);return[r,t[1]]}.bind(this)],normalStyle:n,highlightStyle:s,onMove:function(e){this.change({numLinePosition:e[0]})}.bind(this)})},handleReverse:function(){var e=C[this.props.rel];this.props.onChange({rel:e})},handleToggleStrict:function(){var e=k[this.props.rel];this.props.onChange({rel:e})},_getInequalityEndpoint:function(e){var t=i(["ge","gt"]).contains(e.rel),n=400,r=e.range,s=(r[1]-r[0])/n,o=30*s,u=r[0]-o,a=r[1]+o,f=t?[a,0]:[u,0];return f},_renderInequality:function(e){if(e.isInequality){var t=this._getInequalityEndpoint(e),n={arrows:"->",stroke:KhanUtil.DYNAMIC,strokeWidth:3.5};return r.createElement(g,{start:[e.numLinePosition,0],end:t,style:n})}return null},_setupGraphie:function(e,t){if(!this.isValid())return;var n=400,r=t.range,i=(r[1]-r[0])/n,s=30*i,o=r[0]-s,u=r[1]+s,a=-1,f=1;e.init({range:[[o,u],[a,f]],scale:[1/i,40]});var l=(r[0]+r[1])/2;e.line([l,0],[u,0],{arrows:"->"}),e.line([l,0],[o,0],{arrows:"->"})},getUserInput:function(){return{numLinePosition:this.props.numLinePosition,rel:this.props.isInequality?this.props.rel:"eq",numDivisions:this.props.numDivisions,divisionRange:this.props.divisionRange}},simpleValidate:function(e){return M.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});i.extend(M,{validate:function(e,t){var n=t.range,r=e.divisionRange,i=t.initialX!=null?t.initialX:n[0],s=t.isInequality?"ge":"eq",o=t.correctRel||"eq",u=b.equal(e.numLinePosition,t.correctX||0),a=e.numDivisions>r[1]||e.numDivisions<r[0];return e.isTickCrtl&&a?{type:"invalid",message:"Number of divisions is outside the allowed range."}:u&&o===e.rel?{type:"points",earned:1,total:1,message:null}:e.numLinePosition===i&&e.rel===s?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}});var _=r.createClass({displayName:"NumberLineEditor",getDefaultProps:function(){return{range:[0,10],labelRange:[null,null],divisionRange:[1,12],labelStyle:"decimal",labelTicks:!0,numDivisions:5,tickStep:null,snapDivisions:2,correctRel:"eq",correctX:null,initialX:null}},mixins:[o],render:function(){var e=this.props.range,t=this.props.labelRange,n=this.props.divisionRange;e[0]=+e[0],e[1]=+e[1];var i=e[1]-e[0],s=this.props.numDivisions,o=this.props.snapDivisions,f=this.props.tickStep,p=this.props.isTickCtrl;p?step=null:step=f?f/o:i/s/o;var d=[{value:"decimal",content:"0.75",title:"Decimals"},{value:"improper",content:"⁷⁄₄",title:"Improper fractions"},{value:"mixed",content:"1¾",title:"Mixed numbers"},{value:"non-reduced",content:"⁸⁄₄",title:"Non-reduced"}];return r.createElement("div",{className:"perseus-widget-number-line-editor"},r.createElement("div",{className:"perseus-widget-row"},"Correct x"," ",r.createElement("select",{value:this.props.correctRel,onChange:this.onChangeRelation},r.createElement("option",{value:"eq"}," = "),r.createElement("option",{value:"lt"}," < "),r.createElement("option",{value:"gt"}," > "),r.createElement("option",{value:"le"}," ≤ "),r.createElement("option",{value:"ge"}," ≥ "))," ",r.createElement(l,{value:this.props.correctX,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"correctX"),checkValidity:function(t){return t>=e[0]&&t<=e[1]&&(!step||b.isInteger((t-e[0])/step))},placeholder:"answer",size:"normal",useArrowKeys:!0}),r.createElement(a,null,r.createElement("p",null,"This is the correct answer. The answer is validated (as right or wrong) by using only the end position of the point and the relation (=, <, >, ≤, ≥)"))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("label",null,"Position:"," ",r.createElement(l,{value:this.props.initialX,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"initialX"),placeholder:e[0],checkValidity:function(t){return t>=e[0]&&t<=e[1]},useArrowKeys:!0}))," ∈ ",r.createElement(h,{value:e,onChange:this.onRangeChange,format:this.props.labelStyle,useArrowKeys:!0}),r.createElement(a,null,r.createElement("p",null,"This controls the initial position of the point along the number line and the ",r.createElement("strong",null,"range"),", the position of the endpoints of the number line. Setting the range constrains the position of the answer and the labels."))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},"Labels:"," ",r.createElement(l,{value:t[0],placeholder:e[0],format:this.props.labelStyle,checkValidity:function(t){return t>=e[0]&&t<=e[1]},onChange:this.onLabelRangeChange.bind(this,0),useArrowKeys:!0}),r.createElement("span",null," & "),r.createElement(l,{value:t[1],placeholder:e[1],format:this.props.labelStyle,checkValidity:function(t){return t>=e[0]&&t<=e[1]},onChange:this.onLabelRangeChange.bind(this,1),useArrowKeys:!0}),r.createElement(a,null,r.createElement("p",null,"This controls the position of the left / right labels. By default, the labels are set by the range ",r.createElement("br",null),r.createElement("strong",null,"Note:")," Ensure that the labels line up with the tick marks, or it may be confusing for users.")))),r.createElement("div",{className:"perseus-widget-row"},"Style:"," ",r.createElement(u,{allowEmpty:!1,value:this.props.labelStyle,buttons:d,onChange:this.onLabelStyleChange}),r.createElement(a,null,r.createElement("p",null,"This controls the styling of the labels for the two main labels as well as all the tick mark labels, if applicable. Your choices are decimal, improper fractions, mixed fractions, and non-reduced fractions."))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},r.createElement(c,{label:"Show tick controller",isTickCtrl:this.props.isTickCtrl,onChange:this.props.onChange})),r.createElement("div",{className:"perseus-widget-right-col"},r.createElement(c,{label:"Show label ticks",labelTicks:this.props.labelTicks,onChange:this.props.onChange}))),r.createElement("div",{className:"perseus-widget-row"},p&&r.createElement("span",null,r.createElement("label",null,"Start num divisions at"," ",r.createElement(l,{value:this.props.numDivisions||null,format:"decimal",onChange:this.onNumDivisionsChange,checkValidity:function(e){return e>=n[0]&&e<=n[1]},placeholder:i/this.props.tickStep,useArrowKeys:!0})),r.createElement(a,null,r.createElement("p",null,"This controls the number (and position) of the tick marks. The number of divisions is constrained to"," "+n[0]+N+n[1],".",r.createElement("br",null),r.createElement("strong",null,"Note:")," The user will be able to specify the number of divisions in a number input."))),!p&&r.createElement("span",null,r.createElement("label",null,"Num divisions:"," ",r.createElement(l,{value:this.props.numDivisions||null,format:"decimal",onChange:this.onNumDivisionsChange,checkValidity:function(e){return e>=n[0]&&e<=n[1]},placeholder:i/this.props.tickStep,useArrowKeys:!0}))," ",r.createElement("label",null,"or tick step:"," ",r.createElement(l,{value:this.props.tickStep||null,format:this.props.labelStyle,onChange:this.onTickStepChange,checkValidity:function(e){return e>0&&e<=i},placeholder:i/this.props.numDivisions,useArrowKeys:!0})),r.createElement(a,null,r.createElement("p",null,"This controls the number (and position) of the tick marks; you can either set the number of divisions (2 divisions would split the entire range in two halves), or the tick step (the distance between ticks) and the other value will be updated accordingly. ",r.createElement("br",null),r.createElement("strong",null,"Note:")," There is no check to see if labels coordinate with the tick marks, which may be confusing for users if the blue labels and black ticks are off-step.")))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("label",null,"Snap increments per tick:"," ",r.createElement(l,{value:o,checkValidity:function(e){return e>0},format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"snapDivisions"),useArrowKeys:!0})),r.createElement(a,null,r.createElement("p",null,"This determines the number of different places the point will snap between two adjacent tick marks. ",r.createElement("br",null),r.createElement("strong",null,"Note:"),"Ensure the required number of snap increments is provided to answer the question."))))},onRangeChange:function(e){this.props.onChange({range:e})},onLabelRangeChange:function(e,t){var n=this.props.range.slice(),r=this.props.labelRange.slice(),i=r[1-e];t==null||i==null?r[e]=t:r=[Math.min(t,i),Math.max(t,i)],this.props.onChange({labelRange:r})},onDivisionRangeChange:function(e){var t=this.props.numDivisions;t=E(t,e[0],e[1]),this.props.onChange({divisionRange:e,numDivisions:t})},onNumChange:function(e,t){var n={};n[e]=t,this.props.onChange(n)},onNumDivisionsChange:function(e){var t=this.props.divisionRange.slice();i.isFinite(e)||(e=null),e=Math.round(e),e=e<0?e*-1:e,e&&(e=Math.min(t[1],Math.max(t[0],e)),this.props.onChange({tickStep:null,divisionRange:t,numDivisions:e}))},onTickStepChange:function(e){this.props.onChange({numDivisions:null,tickStep:e})},onChangeRelation:function(e){value=e.target.value,this.props.onChange({correctRel:value,isInequality:value!=="eq"})},onLabelStyleChange:function(e){this.props.onChange({labelStyle:e})}}),D=function(e){var t=i.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isTickCtrl","isInequality"]),n=e.initialX!=null?e.initialX:e.range[0],r=e.range[1]-e.range[0],s;return e.numDivisions!=null?s=e.numDivisions:e.tickStep!=null?s=r/e.tickStep:s=undefined,i.extend(t,{numLinePosition:n,numDivisions:s}),t};e.exports={name:"number-line",displayName:"Number line",widget:M,editor:_,transform:D}},function(e,t,n){var r=n(109),i=n(66),s=n(62),o=n(71),u=n(72),a=n(83),f=n(74),l=n(80),c=n(86),h=n(91),p=n(90).parseTex,d=n(64),v=n(89),m=n(16).ClassNames,g=n(16).Options,y=n(54),b=n(10),w=n(5).firstNumericalParse,E=[{title:"Integers",value:"integer",content:"6"},{title:"Decimals",value:"decimal",content:"0.75"},{title:"Proper fractions",value:"proper",content:"⅗"},{title:"Improper fractions",value:"improper",content:"⁷⁄₄"},{title:"Mixed numbers",value:"mixed",content:"1¾"},{title:"Numbers with π",value:"pi",content:"π"}],S={integer:function(e){return $._("an integer, like $6$")},proper:function(e){return e.simplify==="optional"?$._("a *proper* fraction, like $1/2$ or $6/10$"):$._("a *simplified proper* fraction, like $3/5$")},improper:function(e){return e.simplify==="optional"?$._("an *improper* fraction, like $10/7$ or $14/8$"):$._("a *simplified improper* fraction, like $7/4$")},mixed:function(){return $._("a mixed number, like $1\\ 3/4$")},decimal:function(){return $._("an *exact* decimal, like $0.75$")},pi:function(){return $._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")}},x=i.createClass({displayName:"NumericInput",propTypes:{currentValue:i.PropTypes.string,size:i.PropTypes.oneOf(["normal","small"]),enabledFeatures:y.propTypes,apiOptions:g.propTypes,coefficient:i.PropTypes.bool,answerForms:i.PropTypes.arrayOf(i.PropTypes.string),labelText:i.PropTypes.string,reviewModeRubric:i.PropTypes.object},getDefaultProps:function(){return{currentValue:"",size:"normal",enabledFeatures:y.defaults,apiOptions:g.defaults,coefficient:!1,answerForms:[],labelText:""}},render:function(){var e=this.props.reviewModeRubric;if(e){var t=this.simpleValidate(e),n=t.type==="points"&&t.earned===t.total,o=null;if(!n){var u=s.filter(e.answers,function(e){return e.status==="correct"}),a=s.map(u,function(e,t){var n="decimal";e.answerForms&&e.answerForms[0]&&(n=e.answerForms[0]);var r=KhanUtil.toNumericString(e.value,n);return e.maxError&&(r+=" ± "+KhanUtil.toNumericString(e.maxError,n)),i.createElement("span",{key:t,className:"perseus-possible-answer"},r)});o=i.createElement("span",{className:"perseus-possible-answers"},a)}}var f={};f["perseus-input-size-"+this.props.size]=!0,f[m.CORRECT]=e&&n&&this.props.currentValue,f[m.INCORRECT]=e&&!n&&this.props.currentValue,f[m.UNANSWERED]=e&&!this.props.currentValue;var c=i.createElement(l,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:r(f),type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur}),h;return this.props.labelText?h=i.createElement("label",null,i.createElement("span",{className:"perseus-sr-only"},this.props.labelText),c):h=c,o?i.createElement("span",{className:"perseus-input-with-answer-blurb"},h,o):h},handleChange:function(e){this.props.apiOptions.readOnly||this.props.onChange({currentValue:e})},_getInputType:function(){return this.props.apiOptions.staticRender?"tex":"text"},_handleFocus:function(){this.props.onFocus([])},_handleBlur:function(){this.props.onBlur([])},focus:function(){return this.refs.input.focus(),!0},focusInputPath:function(e){this.refs.input.focus()},blurInputPath:function(e){this.refs.input.blur()},getInputPaths:function(){return[[]]},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,n){this.props.onChange({currentValue:t},n)},getUserInput:function(){return{currentValue:this.props.currentValue}},simpleValidate:function(e){return x.validate(this.getUserInput(),e)},shouldShowExamples:function(){var e=this.props.answerForms.length===0,t=this.props.answerForms.length>=s.size(S);return this.props.enabledFeatures.toolTipFormats&&!e&&!t},examples:function(){var e=this.props.answerForms.length!==0?this.props.answerForms:s.keys(S);return s.map(e,function(e){return S[e](this.props)}.bind(this))},statics:{displayMode:"inline-block"}});s.extend(x,{validate:function(e,t){var n=s.pluck(E,"value"),r=function(e){return Khan.answerTypes.number.createValidatorFunctional(e.value,{message:e.message,simplify:e.status==="correct"?e.simplify:"optional",inexact:!0,maxError:e.maxError,forms:e.strict&&e.answerForms.length!==0?e.answerForms:n})},i=p(e.currentValue),o=s.where(t.answers,{status:"correct"}),u=s.find(s.map(o,function(e){var n=i;t.coefficient&&(n==""?n=1:n=="-"&&(n=-1));var s=r(e);return s(n)}),function(e){return e.correct||e.empty});if(!u){var a=[].concat(s.where(t.answers,{status:"ungraded"}),s.where(t.answers,{status:"wrong"}));match=s.find(a,function(e){var t=r(e);return t(i).correct}),u={empty:match?match.status==="ungraded":!1,correct:match?match.status==="correct":!1,message:match?match.message:null,guess:i}}return u.empty?{type:"invalid",message:u.message}:{type:"points",earned:u.correct?1:0,total:1,message:u.message}}});var T=function(e){return{value:null,status:e,message:"",simplify:"required",answerForms:[],strict:!1,maxError:null}},N=i.createClass({displayName:"NumericInputEditor",mixins:[u,o],getDefaultProps:function(){return{answers:[T("correct")],size:"normal",coefficient:!1,labelText:""}},getInitialState:function(){return{lastStatus:"wrong",showOptions:s.map(this.props.answers,function(){return!1})}},render:function(){var e=this.state.lastStatus,t=this.props.answers,n=function(e){return i.createElement("div",{className:"perseus-widget-row"},i.createElement("label",null,"Unsimplified answers are"),i.createElement(a,{value:t[e].simplify,allowEmpty:!1,buttons:[{value:"required",content:"ungraded"},{value:"optional",content:"accepted"},{value:"enforced",content:"wrong"}],onChange:this.updateAnswer(e,"simplify")}),i.createElement(f,null,i.createElement("p",null,'Normally select "ungraded". This will give the user a message saying the answer is correct but not simplified. The user will then have to simplify it and re-enter, but will not be penalized. (5th grade and after)'),i.createElement("p",null,'Select "accepted" only if the user is not expected to know how to simplify fractions yet. (Anything prior to 5th grade)'),i.createElement("p",null,'Select "wrong" ',i.createElement("em",null,"only")," if we are specifically assessing the ability to simplify.")))}.bind(this),r=function(e){return i.createElement("div",null,i.createElement("div",{className:"perseus-widget-row"},i.createElement("label",null,"Choose the suggested answer formats"),i.createElement(c,{buttons:E,values:t[e].answerForms,onChange:this.updateAnswer(e,"answerForms")}),i.createElement(f,null,i.createElement("p",null,'Formats will be autoselected for you based on the given answer; to show no suggested formats and accept all types, simply have a decimal/integer be the answer. Values with π will have format "pi", and values that are fractions will have some subset (mixed will be "mixed" and "proper"; improper/proper will both be "improper" and "proper"). If you would like to specify that it is only a proper fraction (or only a mixed/improper fraction), deselect the other format. Except for specific cases, you should not need to change the autoselected formats.'),i.createElement("p",null,"To restrict the answer to ",i.createElement("em",null,"only"),' an improper fraction (i.e. 7/4), select the improper fraction and toggle "strict" to true. This ',i.createElement("b",null,"will not")," accept 1.75 as an answer. "),i.createElement("p",null,"Unless you are testing that specific skill, please do not restrict the answer format."))),i.createElement("div",{className:"perseus-widget-row"},i.createElement(d,{label:"Strictly match only these formats",strict:t[e].strict,onChange:this.updateAnswer.bind(this,e)})))}.bind(this),o=function(e){return i.createElement("div",{className:"perseus-widget-row"},i.createElement("label",null,"Max error"," ",i.createElement(h,{className:"max-error",value:t[e].maxError,onChange:this.updateAnswer(e,"maxError"),placeholder:"0"})))}.bind(this),u=i.createElement("div",{className:"perseus-widget-row"},i.createElement("label",null,"Width:"," "," "),i.createElement(a,{value:this.props.size,allowEmpty:!1,buttons:[{value:"normal",content:"Normal (80px)"},{value:"small",content:"Small (40px)"}],onChange:this.change("size")}),i.createElement(f,null,i.createElement("p",null,'Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them.'))),l=i.createElement("div",{className:"perseus-widget-row"},i.createElement("label",null,"Label text:"," ",i.createElement(v,{value:this.props.labelText,onChange:this.change("labelText")})),i.createElement(f,null,i.createElement("p",null,"Text to describe this input. This will be shown to users using screenreaders."))),p=i.createElement("div",null,i.createElement("div",{className:"perseus-widget-row"},i.createElement(d,{label:"Coefficient",coefficient:this.props.coefficient,onChange:this.props.onChange}),i.createElement(f,null,i.createElement("p",null,"A coefficient style number allows the student to use - for -1 and an empty string to mean 1.")))),m=i.createElement("div",null,i.createElement("a",{href:"javascript:void(0)",className:"simple-button orange",onClick:function(){return this.addAnswer()}.bind(this),onKeyDown:function(e){return this.onSpace(e,this.addAnswer)}.bind(this)},i.createElement("span",null,"Add new answer"))),g={wrong:"(address the mistake/misconception)",ungraded:"(explain in detail to avoid confusion)",correct:"(reinforce the user's understanding)"},y=function(){return t.map(function(e,u){var a=i.createElement(b,{content:e.message||"",placeholder:"Why is this answer "+e.status+"?	"+g[e.status],widgetEnabled:!1,onChange:function(e){"content"in e&&this.updateAnswer(u,{message:e.content})}.bind(this)});return i.createElement("div",{className:"perseus-widget-row",key:u},i.createElement("div",{className:"input-answer-editor-value-container"+(e.maxError?" with-max-error":"")},i.createElement(h,{value:e.value,className:"numeric-input-value",placeholder:"answer",format:s.last(e.answerForms),onFormatChange:function(e,t){var n;if(t==="pi")n=["pi"];else if(t==="mixed")n=["proper","mixed"];else if(t==="proper"||t==="improper")n=["proper","improper"];this.updateAnswer(u,{value:w(e),answerForms:n})}.bind(this),onChange:function(e){this.updateAnswer(u,{value:w(e)})}.bind(this)}),e.strict&&i.createElement("div",{className:"is-strict-indicator",title:"strictly equivalent to"},"≡"),e.simplify!=="required"&&e.status==="correct"&&i.createElement("div",{className:"simplify-indicator "+e.simplify,title:"accepts unsimplified answers"},"‰"),e.maxError?i.createElement("div",{className:"max-error-container"},i.createElement("div",{className:"max-error-plusmn"},"±"),i.createElement(h,{placeholder:0,value:t[u].maxError,format:s.last(e.answerForms),onChange:this.updateAnswer(u,"maxError")})):null,i.createElement("div",{className:"value-divider"}),i.createElement("a",{href:"javascript:void(0)",className:"answer-status "+e.status,onClick:function(){return this.onStatusChange(u)}.bind(this),onKeyDown:function(e){return this.onSpace(e,this.onStatusChange,u)}.bind(this)},e.status),i.createElement("a",{href:"javascript:void(0)",className:"answer-trash",onClick:function(){return this.onTrashAnswer(u)}.bind(this),onKeyDown:function(e){return this.onSpace(e,this.onTrashAnswer,u)}.bind(this)},i.createElement("span",{className:"icon-trash"})),i.createElement("a",{href:"javascript:void(0)",className:"options-toggle",onClick:function(){return this.onToggleOptions(u)}.bind(this),onKeyDown:function(e){return this.onSpace(e,this.onToggleOptions,u)}.bind(this)},i.createElement("i",{className:"icon-gear"}))),i.createElement("div",{className:"input-answer-editor-message"},a),this.state.showOptions[u]&&i.createElement("div",{className:"options-container"},o(u),e.status==="correct"&&n(u),r(u)))}.bind(this))}.bind(this);return i.createElement("div",{className:"perseus-input-number-editor"},i.createElement("div",{className:"ui-title"},"User input"),i.createElement("div",{className:"msg-title"},"Message shown to user on attempt"),y(),m,u,p,l)},onToggleOptions:function(e){var t=this.state.showOptions.slice();t[e]=!t[e],this.setState({showOptions:t})},onTrashAnswer:function(e){if(e>=0&&e<this.props.answers.length){var t=this.props.answers.slice(0);t.splice(e,1),this.props.onChange({answers:t})}},onSpace:function(e,t){if(e.key===" "){e.preventDefault();var n=s.toArray(arguments).slice(2);t.apply(this,n)}},onStatusChange:function(e){var t=["wrong","ungraded","correct"],n=this.props.answers,r=s.indexOf(t,n[e].status),i=t[(r+1)%t.length];this.updateAnswer(e,{status:i,simplify:i==="correct"?"required":"accepted"})},updateAnswer:function(e,t){if(!s.isObject(t))return s.partial(function(e,t,n){var r={};r[t]=n,this.updateAnswer(e,r)}.bind(this),e,t);var n=s.clone(this.props.answers);if(e==n.length)var r=T(this.state.lastStatus),n=n.concat(r);n[e]=s.extend({},n[e],t),this.props.onChange({answers:n})},addAnswer:function(){var e=T(this.state.lastStatus),t=this.props.answers.concat(e);this.props.onChange({answers:t})},getSaveWarnings:function(){var e=[];return s.contains(s.pluck(this.props.answers,"value"),"")&&e.push("One or more answers is empty"),this.props.labelText===""&&e.push("No label is specified"),e}}),C=function(e){var t={};return s.each(e,function(e){s.each(e,function(e){t[e]=!0})}),s.filter(s.keys(S),function(e){return t[e]===!0})},k=function(e){var t=s.extend(s.omit(e,"answers"),{answerForms:C(s.pluck(e.answers,"answerForms"))});return t};e.exports={name:"numeric-input",displayName:"Number text box",accessible:!0,widget:x,editor:N,transform:k}},function(e,t,n){var r=n(74),i=n(66),s=n(62),o=n(14),u=n(75),a=n(5),f=n(16).ClassNames,l=i.createClass({displayName:"PlaceholderCard",propTypes:{width:i.PropTypes.number.isRequired,height:i.PropTypes.number.isRequired},render:function(){return i.createElement("div",{className:"card-wrap "+f.INTERACTIVE,style:{width:this.props.width}},i.createElement("div",{className:"card placeholder",style:{height:this.props.height}}))}}),c=i.createClass({displayName:"DragHintCard",render:function(){return i.createElement("div",{className:"card-wrap "+f.INTERACTIVE},i.createElement("div",{className:"card drag-hint"}))}}),h={position:i.PropTypes.shape({left:i.PropTypes.number,top:i.PropTypes.number})},p=i.createClass({displayName:"Card",propTypes:{floating:i.PropTypes.bool.isRequired,animating:i.PropTypes.bool,width:i.PropTypes.number,stack:i.PropTypes.bool,onMouseDown:i.PropTypes.func,onMouseMove:i.PropTypes.func,onMouseUp:i.PropTypes.func,startMouse:h.position,startOffset:h.position,animateTo:h.position,onAnimationEnd:i.PropTypes.func},getDefaultProps:function(){return{stack:!1,animating:!1}},render:function(){var e={};this.props.floating&&(e={position:"absolute",left:this.props.startOffset.left,top:this.props.startOffset.top}),this.props.width&&(e.width=this.props.width);var t=["card"];this.props.stack&&t.push("stack"),this.props.floating&&!this.props.animating&&(t.push("dragging"),e.left+=this.props.mouse.left-this.props.startMouse.left,e.top+=this.props.mouse.top-this.props.startMouse.top);var n=s.pick(this.props,"content"),r=this.props.animating?$.noop:this.onMouseDown;return i.createElement("div",{className:"card-wrap "+f.INTERACTIVE,style:e,onMouseDown:r,onTouchStart:r,onTouchMove:this.onMouseMove,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},i.createElement("div",{className:t.join(" ")},i.createElement(o,i.__spread({},n))))},shouldComponentUpdate:function(e,t){return this.props.floating||e.floating||this.props.content!==e.content||this.props.fakeRef!==e.fakeRef},componentDidMount:function(){this.mouseMoveUpBound=!1},componentDidUpdate:function(e,t){if(this.props.animating&&!e.animating){var n=15*Math.sqrt(Math.sqrt(Math.pow(this.props.animateTo.left-this.props.startOffset.left,2)+Math.pow(this.props.animateTo.top-this.props.startOffset.top,2)));$(this.getDOMNode()).animate(this.props.animateTo,Math.max(n,1),this.props.onAnimationEnd)}},componentWillUnmount:function(){this.mouseMoveUpBound&&(console.warn("Removing an element with bound event handlers."),this.unbindMouseMoveUp(),a.resetTouchHandlers())},bindMouseMoveUp:function(){this.mouseMoveUpBound=!0,$(document).on("mousemove",this.onMouseMove),$(document).on("mouseup",this.onMouseUp)},unbindMouseMoveUp:function(){this.mouseMoveUpBound=!1,$(document).off("mousemove",this.onMouseMove),$(document).off("mouseup",this.onMouseUp)},onMouseDown:function(e){e.preventDefault();var t=a.extractPointerLocation(e);t&&(this.bindMouseMoveUp(),this.props.onMouseDown&&this.props.onMouseDown(t,this))},onMouseMove:function(e){e.preventDefault();var t=a.extractPointerLocation(e);t&&this.props.onMouseMove&&this.props.onMouseMove(t)},onMouseUp:function(e){e.preventDefault();var t=a.extractPointerLocation(e);t&&(this.unbindMouseMoveUp(),this.props.onMouseUp&&this.props.onMouseUp(t))}}),d="normal",v="auto",m="horizontal",g="vertical",y=i.createClass({displayName:"Orderer",propTypes:{current:i.PropTypes.array,options:i.PropTypes.array,correctOptions:i.PropTypes.array,height:i.PropTypes.oneOf([d,v]),layout:i.PropTypes.oneOf([m,g])},getDefaultProps:function(){return{current:[],options:[],correctOptions:[],height:d,layout:m}},getInitialState:function(){return{current:[],dragging:!1,placeholderIndex:null}},componentWillReceiveProps:function(e){s.isEqual(this.props.current,e.current)||this.setState({current:e.current})},render:function(){var e=this.state.dragging&&i.createElement(p,{ref:"dragging",floating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,startMouse:this.state.grabPos,mouse:this.state.mousePos,width:this.state.dragWidth,onMouseUp:this.onRelease,onMouseMove:this.onMouseMove,key:this.state.dragKey||"draggingCard"}),t=this.state.animating&&i.createElement(p,{floating:!0,animating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,width:this.state.dragWidth,animateTo:this.state.animateTo,onAnimationEnd:this.state.onAnimationEnd,key:this.state.dragKey||"draggingCard"}),n=s.map(this.state.current,function(e,t){return i.createElement(p,{ref:"sortable"+t,fakeRef:"sortable"+t,floating:!1,content:e.content,width:e.width,key:e.key,onMouseDown:this.state.animating?$.noop:this.onClick.bind(null,"current",t)})},this);if(this.state.placeholderIndex!=null){var r=i.createElement(l,{ref:"placeholder",width:this.state.dragWidth,height:this.state.dragHeight,key:"placeholder"});n.splice(this.state.placeholderIndex,0,r)}var o=n.length>0;n.push(e,t);var u=i.createElement("div",{className:"ui-helper-clearfix draggable-box"},!o&&i.createElement(c,null),i.createElement("div",{ref:"dragList"},n)),a=i.createElement("div",{ref:"bank",className:"bank ui-helper-clearfix"},s.map(this.props.options,function(e,t){return i.createElement(p,{ref:"bank"+t,floating:!1,content:e.content,stack:!0,key:t,onMouseDown:this.state.animating?$.noop:this.onClick.bind(null,"bank",t),onMouseMove:this.onMouseMove,onMouseUp:this.onRelease})}.bind(this),this));return i.createElement("div",{className:"draggy-boxy-thing orderer height-"+this.props.height+" "+"layout-"+this.props.layout+" "+"above-scratchpad blank-background "+"ui-helper-clearfix "+f.INTERACTIVE,ref:"orderer"},a,u)},onClick:function(e,t,n,r){var i=$(r.getDOMNode()),s=this.state.current.slice(),o,u=null;e==="current"?(s.splice(t,1),o=this.state.current[t],u=t):e==="bank"&&(o=this.props.options[t]),this.setState({current:s,dragging:!0,placeholderIndex:u,dragKey:o.key,dragContent:o.content,dragWidth:i.width(),dragHeight:i.height(),grabPos:n,mousePos:n,offsetPos:i.position()})},onRelease:function(e){var t=this.refs.dragging;if(t==null)return;var n=this.isCardInBank(t),r=this.state.placeholderIndex,i=function(){var e=this.state.current.slice();if(!n){var t={content:this.state.dragContent,key:s.uniqueId("perseus_draggable_card_"),width:this.state.dragWidth};e.splice(r,0,t)}this.props.onChange({current:e}),this.setState({current:e,dragging:!1,placeholderIndex:null,animating:!1})}.bind(this),o=$(t.getDOMNode()).position(),u=null;n?s.each(this.props.options,function(e,t){if(e.content===this.state.dragContent){var n=this.refs["bank"+t].getDOMNode();u=$(n).position()}},this):this.refs.placeholder!=null&&(u=$(this.refs.placeholder.getDOMNode()).position()),u==null?i():this.setState({offsetPos:o,animateTo:u,onAnimationEnd:i,animating:!0,dragging:!1})},onMouseMove:function(e){var t=this.refs.dragging;if(t==null)return;var n;this.isCardInBank(t)?n=null:n=this.findCorrectIndex(t,this.state.current),this.setState({mousePos:e,placeholderIndex:n})},findCorrectIndex:function(e,t){var n=this.props.layout===m,r=$(this.refs.dragList.getDOMNode()),i=r.offset().left,o=r.offset().top,u=$(e.getDOMNode()).offset().left-i,a=$(e.getDOMNode()).offset().top-o,f=0,l=0,c=0;return n?s.each(t,function(e,t){var n=this.refs["sortable"+t].getDOMNode(),r=$(n).outerWidth(!0);u>l+r/2&&(f+=1),l+=r},this):s.each(t,function(e,t){var n=this.refs["sortable"+t].getDOMNode(),r=$(n).outerHeight(!0);a>c+r/2&&(f+=1),c+=r},this),f},isCardInBank:function(e){if(e==null)return!1;var t=this.props.layout===m,n=$(e.getDOMNode()),r=$(this.refs.bank.getDOMNode()),i=n.offset(),s=r.offset(),o=n.outerHeight(!0),u=r.outerHeight(!0),a=r.outerWidth(!0),f=this.refs.dragList.getDOMNode(),l=$(f).width(),c=n.outerWidth(!0);return t?i.top+o/2<s.top+u:i.left+c/2<s.left+a},getUserInput:function(){return{current:s.map(this.props.current,function(e){return e.content})}},simpleValidate:function(e){return y.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});s.extend(y,{validate:function(e,t){if(e.current.length===0)return{type:"invalid",message:null};var n=s.isEqual(e.current,s.pluck(t.correctOptions,"content"));return{type:"points",earned:n?1:0,total:1,message:null}}});var b=i.createClass({displayName:"OrdererEditor",propTypes:{correctOptions:i.PropTypes.array,otherOptions:i.PropTypes.array,height:i.PropTypes.oneOf([d,v]),layout:i.PropTypes.oneOf([m,g]),onChange:i.PropTypes.func.isRequired},getDefaultProps:function(){return{correctOptions:[{content:"$x$"}],otherOptions:[{content:"$y$"}],height:d,layout:m}},render:function(){var e=this;return i.createElement("div",{className:"perseus-widget-orderer"},i.createElement("div",null," ","Correct answer:"," ",i.createElement(r,null,i.createElement("p",null,"Place the cards in the correct order. The same card can be used more than once in the answer but will only be displayed once at the top of a stack of identical cards."))),i.createElement(u,{options:s.pluck(this.props.correctOptions,"content"),onChange:this.onOptionsChange.bind(this,"correctOptions"),layout:this.props.layout}),i.createElement("div",null," ","Other cards:"," ",i.createElement(r,null,i.createElement("p",null,"Create cards that are not part of the answer."))),i.createElement(u,{options:s.pluck(this.props.otherOptions,"content"),onChange:this.onOptionsChange.bind(this,"otherOptions"),layout:this.props.layout}),i.createElement("div",null,i.createElement("label",null," ","Layout:"," ",i.createElement("select",{value:this.props.layout,onChange:this.onLayoutChange},i.createElement("option",{value:m},"Horizontal"),i.createElement("option",{value:g},"Vertical"))),i.createElement(r,null,i.createElement("p",null,"Use the horizontal layout for short text and small images. The vertical layout is best for longer text (e.g. proofs)."))),i.createElement("div",null,i.createElement("label",null," ","Height:"," ",i.createElement("select",{value:this.props.height,onChange:this.onHeightChange},i.createElement("option",{value:d},"Normal"),i.createElement("option",{value:v},"Automatic"))),i.createElement(r,null,i.createElement("p",null,'Use "Normal" for text, "Automatic" for images.'))))},onOptionsChange:function(e,t,n){var r={};r[e]=s.map(t,function(e){return{content:e}}),this.props.onChange(r,n)},onLayoutChange:function(e){this.props.onChange({layout:e.target.value})},onHeightChange:function(e){this.props.onChange({height:e.target.value})},serialize:function(){var e=s.chain(s.pluck(this.props.correctOptions,"content")).union(s.pluck(this.props.otherOptions,"content")).uniq().reject(function(e){return e===""}).sort().sortBy(function(e){return/\d/.test(e)?0:/^\$?[a-zA-Z]+\$?$/.test(e)?2:1}).map(function(e){return{content:e}}).value();return{options:e,correctOptions:this.props.correctOptions,otherOptions:this.props.otherOptions,height:this.props.height,layout:this.props.layout}}});e.exports={name:"orderer",displayName:"Orderer",widget:y,editor:b}},function(e,t,n){var r=n(66),i=n(62),s=n(71),o=n(72),u=n(73),a=n(10),f=n(14),l=n(74),c=n(64),h=n(106),p=r.createClass({displayName:"Passage",mixins:[u,s],propTypes:{passageTitle:r.PropTypes.string,passageText:r.PropTypes.string,footnotes:r.PropTypes.string,showLineNumbers:r.PropTypes.bool},getDefaultProps:function(){return{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0}},getInitialState:function(){return{nLines:null,startLineNumbersAfter:0}},shouldComponentUpdate:function(e,t){return!i.isEqual(this.props,e)||!i.isEqual(this.state,t)},render:function(){var e,t=this.state.nLines;return this.props.showLineNumbers&&t&&(e=i.range(1,t+1).map(function(e){return e===4&&t>4?r.createElement("span",{key:"line-marker",className:"line-marker"},"Line"):e%5===0?e+this.state.startLineNumbersAfter:"\n"}.bind(this))),r.createElement("div",{className:"perseus-widget-passage"},r.createElement("div",{className:"passage-title"},r.createElement(f,{content:this.props.passageTitle})),e&&r.createElement("div",{className:"line-numbers"},e),r.createElement("div",{className:"passage-text"},this._renderContent()),r.createElement("div",{className:"footnotes"},this._renderFootnotes()))},componentDidMount:function(){this._updateState()},componentDidUpdate:function(){this._updateState()},_updateState:function(){this.setState({nLines:this._measureLines(),startLineNumbersAfter:this._getInitialLineNumber()})},_measureLines:function(){var e=$(this.refs.content.getDOMNode()),t=e.height(),n=parseInt(e.css("line-height")),r=Math.round(t/n);return r},_getInitialLineNumber:function(){var e=!0,t=this.props.interWidgets(function(t,n){return n.type!=="passage"?!1:(t===this.props.widgetId&&(e=!1),e)}.bind(this));return t.map(function(e){return e.getLineCount()}).reduce(function(e,t){return e+t},0)},getLineCount:function(){return this.state.nLines!=null?this.state.nLines:this._measureLines()},_renderContent:function(){var e=this.props.passageText,t=h.parse(e);return r.createElement("div",{ref:"content"},h.output(t))},_renderFootnotes:function(){var e=this.props.footnotes,t=h.parse(e);return h.output(t)},_getStartRefLineNumber:function(e){var t=h.START_REF_PREFIX+e,n=this.refs[t];if(!n)return null;var r=$(n.getDOMNode()),i=r.next();i.length===0&&(i=r);var s=i.offset().top;return this.state.startLineNumbersAfter+1+this._convertPosToLineNumber(s)},_getEndRefLineNumber:function(e){var t=h.END_REF_PREFIX+e,n=this.refs[t];if(!n)return null;var r=$(n.getDOMNode()),i=r.prev();i.length===0&&(i=r);var s=i.height(),o=i.offset().top,u=this._convertPosToLineNumber(o+s);return s===0&&(u+=1),this.state.startLineNumbersAfter+u},_convertPosToLineNumber:function(e){var t=$(this.refs.content.getDOMNode()),n=e-t.offset().top,r=parseInt(t.css("line-height")),i=Math.round(n/r);return i},getReference:function(e){var t=this._getStartRefLineNumber(e),n=this._getEndRefLineNumber(e);return t==null||n==null?null:[t,n]},simpleValidate:function(e){return p.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});i.extend(p,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var d=r.createClass({displayName:"PassageEditor",mixins:[o,s],propTypes:{passageTitle:r.PropTypes.string,passageText:r.PropTypes.string,footnotes:r.PropTypes.string,showLineNumbers:r.PropTypes.bool},getDefaultProps:function(){return{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0}},render:function(){var e=r.createElement(a,{ref:"passage-editor",content:this.props.passageText,widgetEnabled:!1,placeholder:"Type passage here...",onChange:function(e){this.change({passageText:e.content})}.bind(this),showWordCount:!0}),t=r.createElement(a,{ref:"passage-footnotes-editor",content:this.props.footnotes,widgetEnabled:!1,placeholder:"Type footnotes here...",onChange:function(e){this.change({footnotes:e.content})}.bind(this)});return r.createElement("div",{className:"perseus-widget-passage-editor"},r.createElement("div",{className:"perseus-widget-row"},r.createElement(c,{label:"Show line numbers",labelAlignment:"right",showLineNumbers:this.props.showLineNumbers,onChange:this.props.onChange})),r.createElement("div",null,"Passage title:",r.createElement(l,null,r.createElement("p",null,"An optional title that will appear directly above the passage in the same font style. (E.g. Passage 1)")),r.createElement("div",null,r.createElement("input",{type:"text",defaultValue:this.props.passageTitle,onChange:function(e){this.change({passageTitle:e.target.value})}.bind(this)}))),r.createElement("div",null,"Passage Text:",e),r.createElement("div",null,"Footnotes:",r.createElement(l,null,r.createElement("p",null,"To add footnotes, add ^ characters where they belong in the passage. Then, add ^ in the footnotes area to reference the footnotes in the passage.")),t))}});e.exports={name:"passage",displayName:"Passage",widget:p,editor:d,transform:function(e){return i.pick(e,"passageTitle","passageText","footnotes","showLineNumbers")}}},function(e,t,n){var r=n(66),i=n(62),s=n(71),o=n(72),u=n(73),a=n(91),f="–",l=r.createClass({displayName:"PassageRef",mixins:[u,s],propTypes:{passageNumber:r.PropTypes.number,referenceNumber:r.PropTypes.number},getDefaultProps:function(){return{passageNumber:1,referenceNumber:1}},getInitialState:function(){return{lineRange:null}},shouldComponentUpdate:function(e,t){return!i.isEqual(this.props,e)||!i.isEqual(this.state,t)},render:function(){var e=this.state.lineRange;return e?e[0]===e[1]?r.createElement("span",null,$_({lineNumber:e[0]},"line %(lineNumber)s")):r.createElement("span",null,$_({lineRange:e[0]+f+e[1]},"lines %(lineRange)s")):r.createElement("span",null,$_({lineRange:"?"+f+"?"},"lines %(lineRange)s"))},componentDidMount:function(){i.defer(this._updateRange)},componentDidUpdate:function(){i.defer(this._updateRange)},_updateRange:function(){var e=this.props.interWidgets("passage "+this.props.passageNumber)[0],t=null;e&&(t=e.getReference(this.props.referenceNumber)),this.isMounted()&&this.setState({lineRange:t})},simpleValidate:function(e){return l.validate(this.getUserInput(),e)},statics:{displayMode:"inline"}});i.extend(l,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var c=r.createClass({displayName:"PassageRefEditor",mixins:[o,s],propTypes:{passageNumber:r.PropTypes.number,referenceNumber:r.PropTypes.number},getDefaultProps:function(){return{passageNumber:1,referenceNumber:1}},render:function(){return r.createElement("div",null,r.createElement("div",null,"Passage Number:",r.createElement(a,{value:this.props.passageNumber,onChange:this.change("passageNumber")})),r.createElement("div",null,"Reference Number:",r.createElement(a,{value:this.props.referenceNumber,onChange:this.change("referenceNumber")})))}});e.exports={name:"passage-ref",displayName:"PassageRef",widget:l,editor:c,transform:function(e){return i.pick(e,"passageNumber","referenceNumber")},version:{major:0,minor:0}}},function(e,t,n){var r=n(66),i=n(62),s=n(71),o=n(72),u=n(73),a=n(14),f=r.createClass({displayName:"PassageRefTarget",mixins:[u,s],propTypes:{content:r.PropTypes.string},getDefaultProps:function(){return{content:""}},render:function(){return r.createElement(a,{content:this.props.content,inline:!0,enabledFeatures:this.props.enabledFeatures,apiOptions:this.props.apiOptions})},simpleValidate:function(e){return f.validate(this.getUserInput(),e)},statics:{displayMode:"inline"}});i.extend(f,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var l=r.createClass({displayName:"PassageRefTargetEditor",mixins:[o,s],propTypes:{content:r.PropTypes.string},getDefaultProps:function(){return{content:""}},render:function(){return r.createElement("div",null,"Content:",r.createElement("input",{type:"text",value:this.props.content,onChange:this.handleContentChange}))},handleContentChange:function(e){this.change({content:e.target.value})}});e.exports={name:"passage-ref-target",displayName:"PassageRefTarget",widget:f,editor:l,hidden:!0,transform:function(e){return i.pick(e,"content")},version:{major:0,minor:0}}},function(e,t,n){function T(e,t,n){var r=o.clone(e);r.length=t;for(var i=e.length;i<t;i++)r[i]=n;return r}var r=n(66),i=n(74),s=n(87),o=n(62),u=n(91),a=n(75),f=n(88),l=n(63),c=n(16).ClassNames,h=n(5).deepEq,p=n(108).number,d="bar",v="line",m="pic",g="histogram",y="dotplot",b=4,w=8,E={type:r.PropTypes.oneOf([d,v,m,g,y]),labels:r.PropTypes.arrayOf(r.PropTypes.string),categories:r.PropTypes.arrayOf(r.PropTypes.oneOfType([r.PropTypes.number,r.PropTypes.string])),scaleY:r.PropTypes.number,maxY:r.PropTypes.number,snapsPerLine:r.PropTypes.number,picSize:r.PropTypes.number,pixBoxHeight:r.PropTypes.number,picUrl:r.PropTypes.string,plotDimensions:r.PropTypes.arrayOf(r.PropTypes.number),labelInterval:r.PropTypes.number},S=function(e){return"$"+p.round(e,2)+"$"},x=r.createClass({displayName:"Plotter",propTypes:E,getDefaultProps:function(){return{type:d,labels:["",""],categories:[""],scaleY:1,maxY:10,snapsPerLine:2,picSize:40,picBoxHeight:48,picUrl:"",plotDimensions:[380,300],labelInterval:1}},getInitialState:function(){return{values:this.props.starting||[1]}},render:function(){return r.createElement("div",{className:"perseus-widget-plotter graphie "+c.INTERACTIVE,ref:"graphieDiv"})},componentDidUpdate:function(e,t){this.shouldSetupGraphie&&this.setupGraphie(t)},componentDidMount:function(){this.setupGraphie(this.state)},componentWillReceiveProps:function(e){var t=["type","labels","categories","scaleY","maxY","snapsPerLine","picUrl","labelInterval"];this.shouldSetupGraphie=o.any(t,function(t){return!o.isEqual(this.props[t],e[t])},this),!o.isEqual(this.props.starting,e.starting)&&!o.isEqual(this.state.values,e.starting)&&(this.shouldSetupGraphie=!0,this.setState({values:e.starting}))},setupGraphie:function(e){var t=this;t.shouldSetupGraphie=!1;var n=t.refs.graphieDiv.getDOMNode();$(n).empty();var r=KhanUtil.createGraphie(n);t.graphie=r,t.graphie.pics=[];var i=t.props.type===d,s=t.props.type===v,u=t.props.type===m,a=t.props.type===g,f=t.props.type===y,l=u||f,c={},h=c;h.graph={lines:[],bars:[],points:[],dividers:[]},h.scaleY=t.props.scaleY,h.dimX=t.props.categories.length;var p=t.props.plotDimensions;if(s)h.dimX+=1;else if(a)h.barPad=0,h.barWidth=1;else if(i)h.barPad=.15,h.barWidth=1-2*h.barPad,h.dimX+=2*h.barPad;else if(l){h.picBoxHeight=t.props.picBoxHeight,h.picBoxWidthPx=p[0]/t.props.categories.length;var E=p[0]-h.dimX*h.picBoxWidthPx;h.picPad=E/(2*h.dimX+2);var S=h.picBoxWidthPx+2*h.picPad;h.picPad=h.picPad/S,h.picBoxWidth=h.picBoxWidthPx/S,h.dimX+=2*h.picPad}f&&(h.picBoxHeight=b*2+w),h.dimY=Math.ceil(t.props.maxY/h.scaleY)*h.scaleY,h.scale=o.map([h.dimX,h.dimY],function(e,t){return p[t]/e}),l&&(h.scale[1]=h.picBoxHeight/h.scaleY);var x=25/h.scale[0],T=25/h.scale[1];f&&(x/=2),r.init({range:[[-3*x,h.dimX+x],[-3*T,h.dimY+T]],scale:h.scale}),r.addMouseLayer({allowScratchpad:!0});if(!l)for(var N=0;N<=h.dimY;N+=h.scaleY)r.label([0,N],KhanUtil.roundToApprox(N,2),"left",!0),r.style({stroke:"#000",strokeWidth:1,opacity:.3},function(){r.line([0,N],[h.dimX,N])});t.setupCategories(c),l&&t.drawPicHeights(t.state.values,e.values),r.style({stroke:"#000",strokeWidth:2,opacity:1},function(){f?r.line([.5,0],[h.dimX-.5,0]):(r.line([0,0],[h.dimX,0]),r.line([0,0],[0,h.dimY]))}),r.label([h.dimX/2,-35/h.scale[1]],t.props.labels[0],"below",!1).css("font-weight","bold"),r.label([-60/h.scale[0],h.dimY/2],t.props.labels[1],"center",!1).css("font-weight","bold").addClass("rotate")},labelCategory:function(e,t){var n=this.graphie;t+="";var r=!1,i=t.match(/^\$(.*)\$$/);i&&(t=i[1],r=!0),n.label([e,0],t,"below",r)},setupCategories:function(e){var t=this,n=e,r=t.graphie;t.props.type===g?(o.times(t.props.categories.length-1,function(n){t.setupBar({index:n,startHeight:t.state.values[n],config:e,isHistogram:!0})}),o.each(t.props.categories,function(e,i){var s=.5+i*n.barWidth;t.labelCategory(s,e);var o=6/n.scale[1];r.style({stroke:"#000",strokeWidth:2,opacity:1},function(){r.line([s,-o],[s,0])})})):o.each(t.props.categories,function(i,s){var o=t.state.values[s],u;t.props.type===d?u=t.setupBar({index:s,startHeight:o,config:e,isHistogram:!1}):t.props.type===v?u=t.setupLine(s,o,e):t.props.type===m?u=t.setupPic(s,e):t.props.type===y&&(u=t.setupDotplot(s,e));var a=0,f=-6/n.scale[1];t.props.type===y&&(a=-f);if(t.props.type===y){if(s%t.props.labelInterval===0||s===t.props.categories.length-1)t.labelCategory(u,i),a*=1.5,f*=1.5}else t.labelCategory(u,i);r.style({stroke:"#000",strokeWidth:2,opacity:1},function(){r.line([u,a],[u,f])})})},setupBar:function(e){var t=e.index,n=e.startHeight,r=e.config,i=e.isHistogram,s=this,u=s.graphie,a=r.barWidth/2,f;i?f=.5+t*r.barWidth+a:f=.5+t+r.barPad;var l=function(e,t){var n=u.scalePoint(0);r.graph.bars[e].scale(1,Math.max(.01,t/r.scaleY),n[0],n[1]);if(i){var o=r.graph.dividers[e-1],a=r.graph.dividers[e];if(o){var f=Math.min(s.state.values[e-1],t);o.scale(1,Math.max(.01,f/r.scaleY),n[0],n[1])}if(a){var f=Math.min(s.state.values[e+1],t);a.scale(1,Math.max(.01,f/r.scaleY),n[0],n[1])}}};return u.style({stroke:"none",fill:KhanUtil.LIGHT_BLUE,opacity:1},function(){r.graph.bars[t]=u.path([[f-a,0],[f-a,r.scaleY],[f+a,r.scaleY],[f+a,0],[f-a,0]])}),i&&t>0&&u.style({stroke:"#000",strokeWidth:1,opacity:.3},function(){r.graph.dividers.push(u.path([[f-a,0],[f-a,r.scaleY]]))}),r.graph.lines[t]=u.addMovableLineSegment({coordA:[f-a,n],coordZ:[f+a,n],snapY:r.scaleY/s.props.snapsPerLine,constraints:{constrainX:!0},normalStyle:{stroke:KhanUtil.INTERACTIVE,"stroke-width":4}}),r.graph.lines[t].onMove=function(e,n){var i=this.coordA[1];if(i<0||i>r.dimY)i=Math.min(Math.max(i,0),r.dimY),this.coordA[1]=this.coordZ[1]=i,this.transform();var u=o.clone(s.state.values);u[t]=i,s.setState({values:u}),s.props.onChange({values:u}),l(t,i)},l(t,n),f},setupLine:function(e,t,n){var r=this,i=n,s=r.graphie,u=e+1;return i.graph.points[e]=s.addMovablePoint({coord:[u,t],constraints:{constrainX:!0},normalStyle:{fill:KhanUtil.INTERACTIVE,stroke:KhanUtil.INTERACTIVE},snapY:i.scaleY/r.props.snapsPerLine}),i.graph.points[e].onMove=function(t,n){n=Math.min(Math.max(n,0),i.dimY);var s=o.clone(r.state.values);return s[e]=n,r.setState({values:s}),r.props.onChange({values:s}),[t,n]},e>0&&(i.graph.lines[e]=s.addMovableLineSegment({pointA:i.graph.points[e-1],pointZ:i.graph.points[e],constraints:{fixed:!0},normalStyle:{stroke:"#9ab8ed","stroke-width":2}})),u},setupDotplot:function(e,t){var n=this.graphie;return this.setupTiledPlot(e,1,t,function(e,t){return n.ellipse([e,t],[b/n.scale[0],b/n.scale[1]],{fill:KhanUtil.INTERACTIVE,stroke:KhanUtil.INTERACTIVE})})},setupPic:function(e,t){var n=this.graphie;return this.setupTiledPlot(e,0,t,function(e,t){var r=n.scalePoint([e,t]),i=this.props.picSize;return n.raphael.image(this.props.picUrl,r[0]-i/2,r[1]-i/2,i,i)}.bind(this))},setupTiledPlot:function(e,t,n,r){var i=this,s=n,u=i.graphie,a=u.pics,f=e+.5+s.picPad;a[e]=[];var l=Math.round(s.dimY/s.scaleY)+1;return o(l).times(function(n){n-=1;var o=(n+.5)*s.scaleY,l=f-s.picBoxWidth/2,c=o+.5*s.scaleY,h=u.scalePoint([l,c+t]),p=u.mouselayer.rect(h[0],h[1],s.picBoxWidthPx,s.picBoxHeight);$(p[0]).css({fill:"#000",opacity:0,cursor:"pointer"}).on("vmousedown",function(n){n.preventDefault(),i.whichPicClicked=e,i.setPicHeight(e,c),$(document).on("vmouseup.plotTile",function(e){$(document).unbind(".plotTile")}),$(document).on("vmousemove.plotTile",function(e){e.preventDefault();var n=u.getMouseCoord(e)[1],r=Math.floor(n-t),o=Math.max(-1,Math.floor(r/s.scaleY)),a=(o+.5)*s.scaleY,f=a+.5*s.scaleY;i.setPicHeight(i.whichPicClicked,f)})});if(n<0)return;a[e][n]=r(f,o+t)}),f},setPicHeight:function(e,t){var n=o.clone(this.state.values);n[e]=t,this.drawPicHeights(n,this.state.values),this.setState({values:n}),this.props.onChange({values:n})},drawPicHeights:function(e,t){var n=this,r=n.graphie,i=r.pics;o.each(i,function(r,i){o.each(r,function(r,s){var o=(s+1)*n.props.scaleY,u=o<=e[i];if(n.props.type===y){var a=o<=t[i],f=u&&!a;f&&r.animate({"stroke-width":8},75,function(){return r.animate({"stroke-width":2},75)})}$(r[0]).css({display:u?"inline":"none"})})})},getUserInput:function(){return this.state.values},simpleValidate:function(e){return x.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});o.extend(x,{validate:function(e,t){return h(e,t.starting)?{type:"invalid",message:null}:{type:"points",earned:h(e,t.correct)?1:0,total:1,message:null}}});var N={scaleY:1,maxY:10,snapsPerLine:2},C=r.createClass({displayName:"PlotterEditor",propTypes:E,getDefaultProps:function(){return o.extend({},N,{correct:[1],starting:[1],type:d,labels:["",""],categories:[""],picSize:30,picBoxHeight:36,picUrl:Khan.imageBase+"badges/earth-small.png",plotDimensions:[275,200],labelInterval:1})},getInitialState:function(){return{editing:"correct",pic:null,loadedUrl:null,minX:null,maxX:null,tickStep:null}},componentWillMount:function(){this.fetchPic(this.props.picUrl)},componentWillReceiveProps:function(e){this.fetchPic(e.picUrl)},fetchPic:function(e){if(this.state.loadedUrl!==e){var t=new Image;t.src=e,t.onload=function(){this.setState({pic:t,loadedUrl:e})}.bind(this)}},render:function(){var e=o.contains([v,g,y],this.props.type),t=!o.contains([m,y],this.props.type);return r.createElement("div",{className:"perseus-widget-plotter-editor"},r.createElement("div",null,"Chart type:"," ",o.map([d,v,m,g,y],function(e){return r.createElement("label",{key:e},r.createElement("input",{type:"radio",name:"chart-type",checked:this.props.type===e,onChange:o.partial(this.changeType,e)}),e)},this)),r.createElement("div",null,"Labels:"," ",o.map(["x","y"],function(e,t){return r.createElement("label",{key:e},e+":",r.createElement("input",{type:"text",onChange:o.partial(this.changeLabel,t),defaultValue:this.props.labels[t]}))},this)),e&&r.createElement("div",{className:"set-from-scale-box"},r.createElement("span",{className:"categories-title"},"Set Categories From Scale"),r.createElement("div",null,r.createElement("label",null,"Tick Step:"," ",r.createElement(u,{placeholder:1,useArrowKeys:!0,value:this.state.tickStep,onChange:this.handleChangeTickStep})),r.createElement(i,null,r.createElement("p",null,"The difference between adjacent ticks."))),r.createElement("div",null,r.createElement("label",null,"Range:"," ",r.createElement(f,{placeholder:[0,10],useArrowKeys:!0,value:[this.state.minX,this.state.maxX],onChange:this.handleChangeRange}))),r.createElement("div",null,r.createElement("button",{onClick:this.setCategoriesFromScale},"Set Categories"," "))),r.createElement("div",null,r.createElement("label",null,"Label Interval:"," ",r.createElement(u,{useArrowKeys:!0,value:this.props.labelInterval,onChange:this.changeLabelInterval})),r.createElement(i,null,r.createElement("p",null,'Which ticks to display the labels for. For instance, setting this to "4" will only show every 4th label (plus the last one)'))),this.props.type===m&&r.createElement("div",null,r.createElement("label",null,"Picture:"," ",r.createElement(s,{className:"pic-url",value:this.props.picUrl,onChange:this.changePicUrl}),r.createElement(i,null,r.createElement("p",null,'Use the default picture of Earth, or insert the URL for a different picture using the "Add image" function.'))),this.state.pic&&this.state.pic.width!==this.state.pic.height&&r.createElement("p",{className:"warning"},r.createElement("b",null,"Warning"),": You are using a picture which is not square.  This means the image will get distorted. You should probably crop it to be square.")),r.createElement("div",null,r.createElement("label",null,"Categories:"," ",r.createElement(a,{ref:"categories",layout:"horizontal",options:this.props.categories,onChange:this.changeCategories}))),r.createElement("div",null,r.createElement("label",null,"Scale (y):"," ",r.createElement("input",{type:"text",onChange:this.changeScale,defaultValue:this.props.scaleY}))),r.createElement("div",null,r.createElement("label",null,"Max y:"," ",r.createElement("input",{type:"text",ref:"maxY",onChange:this.changeMax,defaultValue:this.props.maxY}))),t&&r.createElement("div",null,r.createElement("label",null,"Snaps per line:"," ",r.createElement("input",{type:"text",onChange:this.changeSnaps,defaultValue:this.props.snapsPerLine})),r.createElement(i,null,r.createElement("p",null,"Creates the specified number of divisions between the horizontal lines. Fewer snaps between lines makes the graph easier for the student to create correctly."))),r.createElement("div",null,"Editing values:"," ",o.map(["correct","starting"],function(e){return r.createElement("label",{key:e},r.createElement("input",{type:"radio",name:"editing",checked:this.state.editing===e,onChange:o.partial(this.changeEditing,e)}),e)},this),r.createElement(i,null,r.createElement("p",null,"Use this toggle to switch between editing the correct answer (what the student will be graded on) and the starting values (what the student will see plotted when they start the problem). Note: These cannot be the same."))),r.createElement(x,r.__spread({},this.props,{starting:this.props[this.state.editing],onChange:this.handlePlotterChange})))},handleChangeTickStep:function(e){this.setState({tickStep:e})},handleChangeRange:function(e){this.setState({minX:e[0],maxX:e[1]})},changeLabelInterval:function(e){this.props.onChange({labelInterval:e})},handlePlotterChange:function(e){var t={};t[this.state.editing]=e.values,this.props.onChange(t)},changeType:function(e){var t;e===g?(t=[S(0)].concat(this.props.categories),this.props.onChange({type:e,categories:t})):this.props.type===g?(t=this.props.categories.slice(1),this.props.onChange({type:e,categories:t})):this.props.onChange({type:e}),t&&(this.refs.categories.getDOMNode().value=t.join(", "))},changeLabel:function(e,t){var n=o.clone(this.props.labels);n[e]=t.target.value,this.props.onChange({labels:n})},changePicUrl:function(e){var t=l.getRealImageUrl(e);this.props.onChange({picUrl:t})},changeCategories:function(e){var t=e.length;this.props.type===g&&t--;var n=this.props.scaleY;this.props.onChange({categories:e,correct:T(this.props.correct,t,n),starting:T(this.props.starting,t,n)})},changeScale:function(e){var t=this.props.scaleY,n=+e.target.value||N.scaleY,r=function(e){return e*n/t},i=r(this.props.maxY);this.props.onChange({scaleY:n,maxY:i,correct:o.map(this.props.correct,r),starting:o.map(this.props.starting,r)}),this.refs.maxY.getDOMNode().value=i},changeMax:function(e){this.props.onChange({maxY:+e.target.value||N.maxY})},changeSnaps:function(e){this.props.onChange({snapsPerLine:+e.target.value||N.snapsPerLine})},changeEditing:function(e){this.setState({editing:e})},setCategoriesFromScale:function(){var e=this.state.tickStep||1,t=this.state.minX||0,n=this.state.maxX||0,r=Math.floor((n-t)/e)*e,i;this.props.type===g||this.props.type===y?i=o.range(0,r+e,e):i=o.range(e,r+e,e),i=o.map(i,function(e){return e+t}),i=o.map(i,S),this.changeCategories(i),this.refs.categories.getDOMNode().value=i.join(", ")},serialize:function(){var e=o.pick(this.props,"correct","starting","type","labels","categories","scaleY","maxY","snapsPerLine","labelInterval");return this.props.type===m&&(e.picUrl=this.props.picUrl),e}});e.exports={name:"plotter",displayName:"Plotter",widget:x,editor:C}},function(e,t,n){var r=n(66),i=n(62),s=n(71),o=n(16).ClassNames,u=n(10),a=n(64),f=n(14),l=n(39),c=n(5),h=n(74),p=n(5).shuffle,d=n(5).seededRNG,v=n(5).captureScratchpadTouchStart,m=n(109),g=r.createClass({displayName:"Choice",propTypes:{checked:r.PropTypes.bool,className:r.PropTypes.string,clue:r.PropTypes.object,content:r.PropTypes.node,disabled:r.PropTypes.bool,groupName:r.PropTypes.string,showClue:r.PropTypes.bool,type:r.PropTypes.string,onChecked:r.PropTypes.func},getDefaultProps:function(){return{checked:!1,classSet:{},disabled:!1,showClue:!1,type:"radio"}},render:function(){return r.createElement("label",{className:this.props.className,onClick:function(e){e.preventDefault()}},r.createElement("span",{className:"checkbox"},r.createElement("input",{type:this.props.type,name:this.props.groupName,checked:this.props.checked,disabled:this.props.disabled,onClick:function(e){e.stopPropagation()},onChange:function(e){this.props.onChecked(e.target.checked)}.bind(this)})),r.createElement("span",{className:o.RADIO.OPTION_CONTENT+" "+o.INTERACTIVE,style:{cursor:"default"}},r.createElement("div",null,this.props.content)),this.props.showClue&&r.createElement("div",{className:"perseus-radio-clue"},this.props.clue))}}),y=r.createClass({displayName:"ChoiceNoneAbove",propTypes:{showContent:r.PropTypes.bool},getDefaultProps:function(){return{showContent:!0}},render:function(){var e=i.extend({},this.props,{className:m(this.props.className,"none-of-above"),content:this.props.showContent?this.props.content:r.createElement(f,{key:"noneOfTheAboveRenderer",content:$._("None of the above")})});return r.createElement(g,r.__spread({},e))}}),b=r.createClass({displayName:"ChoiceEditor",propTypes:{choice:r.PropTypes.object,showDelete:r.PropTypes.bool,onClueChange:r.PropTypes.func,onContentChange:r.PropTypes.func,onDelete:r.PropTypes.func},render:function(){var e=this.props.choice.correct?"correct":"incorrect",t="Type a choice here...";this.props.choice.isNoneOfTheAbove&&(t=this.props.choice.correct?"Type the answer to reveal to the user...":"None of the above");var n=r.createElement(u,{ref:"content-editor",content:this.props.choice.content||"",widgetEnabled:!1,placeholder:t,disabled:this.props.choice.isNoneOfTheAbove&&!this.props.choice.correct,onChange:this.props.onContentChange}),i=r.createElement(u,{ref:"clue-editor",content:this.props.choice.clue||"",widgetEnabled:!1,placeholder:$._("Why is this choice "+e+"?"),onChange:this.props.onClueChange}),s=r.createElement("a",{href:"#",className:"simple-button orange delete-choice",title:"Remove this choice",onClick:this.props.onDelete},r.createElement("span",{className:"icon-trash"}));return r.createElement("div",{className:"choice-clue-editors"},r.createElement("div",{className:"choice-editor "+e},n),r.createElement("div",{className:"clue-editor"},i),this.props.showDelete&&s)}}),w=r.createClass({displayName:"BaseRadio",propTypes:{labelWrap:r.PropTypes.bool,multipleSelect:r.PropTypes.bool,onCheckedChange:r.PropTypes.func,onePerLine:r.PropTypes.bool,apiOptions:r.PropTypes.object,reviewModeRubric:r.PropTypes.object,deselectEnabled:r.PropTypes.bool},getDefaultProps:function(){return{onePerLine:!0}},render:function(){var e=i.uniqueId("perseus_radio_"),t=this.props.multipleSelect?"checkbox":"radio",n=this.props.reviewModeRubric;return r.createElement("ul",{className:"perseus-widget-radio above-scratchpad blank-background"},this.props.multipleSelect&&r.createElement("div",{className:"instructions"},$_(null,"Select all that apply.")),this.props.choices.map(function(s,u){var a=!!n&&!!n.choices[u].clue,f=s.checked&&a,l=g,c={ref:"radio"+u,checked:s.checked,clue:s.clue,content:s.content,disabled:this.props.apiOptions.readOnly,groupName:e,showClue:f,type:t,onChecked:function(e){this.checkOption(u,e)}.bind(this)};s.isNoneOfTheAbove&&(l=y,i.extend(c,{showContent:s.correct}));var h=m(o.RADIO.OPTION,s.checked&&o.RADIO.SELECTED,!this.props.onePerLine&&"inline",n&&n.choices[u].correct&&o.CORRECT,n&&!n.choices[u].correct&&o.INCORRECT);return r.createElement("li",{className:h,key:u,onTouchStart:this.props.labelWrap?v:null,onClick:this.props.labelWrap?function(e){e.preventDefault();if(!this.props.apiOptions.readOnly){var t=this.props.multipleSelect||this.props.deselectEnabled;this.checkOption(u,t?!s.checked:!0)}}.bind(this):null},r.createElement(l,r.__spread({},c)))},this))},checkOption:function(e,t){var n;this.props.multipleSelect?n=i.map(this.props.choices,function(n,r){return r===e?t:n.checked}):n=i.map(this.props.choices,function(n,r){return r===e&&t}),this.props.onCheckedChange(n)},focus:function(e){return this.refs["radio"+(e||0)].getDOMNode().focus(),!0}}),E=r.createClass({displayName:"Radio",getDefaultProps:function(){return{choices:[{}],displayCount:null,multipleSelect:!1,deselectEnabled:!1}},render:function(){var e=this.props.choices,t=this.props.values||i.map(e,function(){return!1});return e=i.map(e,function(e,n){var r=e.isNoneOfTheAbove&&!e.content?$._("None of the above"):e.content;return{content:this._renderRenderer(r),checked:t[n],correct:this.props.questionCompleted&&t[n],clue:this._renderRenderer(e.clue),isNoneOfTheAbove:e.isNoneOfTheAbove}}.bind(this)),e=this.enforceOrdering(e),r.createElement(w,{ref:"baseRadio",labelWrap:!0,onePerLine:this.props.onePerLine,multipleSelect:this.props.multipleSelect,choices:e,onCheckedChange:this.onCheckedChange,reviewModeRubric:this.props.reviewModeRubric,deselectEnabled:this.props.deselectEnabled,apiOptions:this.props.apiOptions})},_renderRenderer:function(e){e=e||"";var t=1,n={},i=e.replace(/\{\{passage-ref (\d+) (\d+)\}\}/g,function(e,r,i){var s="passage-ref "+t;return t++,n[s]={type:"passage-ref",graded:!1,options:{passageNumber:parseInt(r),referenceNumber:parseInt(i)},version:l.version},"[["+c.snowman+" "+s+"]]"});return r.createElement(f,{key:"choiceContentRenderer",content:i,widgets:n,interWidgets:this._interWidgets,alwaysUpdate:!0})},_interWidgets:function(e,t){return t.length?t:this.props.interWidgets(e)},focus:function(e){return this.refs.baseRadio.focus(e)},onCheckedChange:function(e){this.props.onChange({values:e})},getUserInput:function(){if(this.props.values){var e=null,t=!1,n=this.props.values.slice();for(var r=0;r<this.props.values.length;r++){var s=this.props.choices[r].originalIndex;n[s]=this.props.values[r],this.props.choices[r].isNoneOfTheAbove&&(e=s,n[r]&&(t=!0))}return i.extend({},this.props,{values:n,noneOfTheAboveIndex:e,noneOfTheAboveSelected:t})}return{values:i.map(this.props.choices,function(){return!1})}},simpleValidate:function(e){return E.validate(this.getUserInput(),e)},enforceOrdering:function(e){var t=i.pluck(e,"content");return i.isEqual(t,[$._("False"),$._("True")])||i.isEqual(t,[$._("No"),$._("Yes")])?[e[1]].concat([e[0]]):e},statics:{displayMode:"block"}});i.extend(E,{validate:function(e,t){var n=i.reduce(e.values,function(e,t){return e+(t?1:0)},0);if(n===0)return{type:"invalid",message:null};if(e.noneOfTheAboveSelected&&n>1)return{type:"invalid",message:$._("'None of the above' may not be selected when other answers are selected.")};var r=i.all(e.values,function(n,r){var s;return e.noneOfTheAboveIndex===r?s=i.all(t.choices,function(e,t){return r===t||!e.correct}):s=!!t.choices[r].correct,s===n});return{type:"points",earned:r?1:0,total:1,message:null}}});var S=r.createClass({displayName:"RadioEditor",mixins:[s],propTypes:{choices:r.PropTypes.arrayOf(r.PropTypes.shape({content:r.PropTypes.string,clue:r.PropTypes.string,correct:r.PropTypes.bool})),displayCount:r.PropTypes.number,randomize:r.PropTypes.bool,hasNoneOfTheAbove:r.PropTypes.bool,multipleSelect:r.PropTypes.bool,onePerLine:r.PropTypes.bool,deselectEnabled:r.PropTypes.bool},getDefaultProps:function(){return{choices:[{},{}],displayCount:null,randomize:!1,hasNoneOfTheAbove:!1,multipleSelect:!1,onePerLine:!0,deselectEnabled:!1}},render:function(){return r.createElement("div",null,r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},r.createElement("div",null,r.createElement(a,{label:"One answer per line",labelAlignment:"right",onePerLine:this.props.onePerLine,onChange:this.props.onChange}),r.createElement(h,null,r.createElement("p",null,"Use one answer per line unless your question has images that might cause the answers to go off the page.")))),r.createElement("div",{className:"perseus-widget-right-col"},r.createElement(a,{label:"Multiple selections",labelAlignment:"right",multipleSelect:this.props.multipleSelect,onChange:this.onMultipleSelectChange})),r.createElement("div",{className:"perseus-widget-left-col"},r.createElement(a,{label:"Randomize order",labelAlignment:"right",randomize:this.props.randomize,onChange:this.props.onChange})),r.createElement("div",{className:"perseus-widget-right-col"},r.createElement(a,{label:"Radio deselect enabled",labelAlignment:"right",deselectEnabled:this.props.deselectEnabled,onChange:this.props.onChange}))),r.createElement(w,{ref:"baseRadio",multipleSelect:this.props.multipleSelect,onePerLine:!0,labelWrap:!1,apiOptions:this.props.apiOptions,choices:this.props.choices.map(function(e,t){return{content:r.createElement(b,{ref:"choice-editor"+t,choice:e,onContentChange:function(e){"content"in e&&this.onContentChange(t,e.content)}.bind(this),onClueChange:function(e){"content"in e&&this.onClueChange(t,e.content)}.bind(this),onDelete:this.onDelete.bind(this,t),showDelete:this.props.choices.length>=2}),isNoneOfTheAbove:e.isNoneOfTheAbove,checked:e.correct}},this),onCheckedChange:this.onCheckedChange}),r.createElement("div",{className:"add-choice-container"},r.createElement("a",{href:"#",className:"simple-button orange",onClick:this.addChoice.bind(this,!1)},r.createElement("span",{className:"icon-plus"})," ","Add a choice"," "),!this.props.hasNoneOfTheAbove&&r.createElement("a",{href:"#",className:"simple-button",onClick:this.addChoice.bind(this,!0)},r.createElement("span",{className:"icon-plus"})," ","None of the above"," ")))},onMultipleSelectChange:function(e){e=e.multipleSelect;var t=i.reduce(this.props.choices,function(e,t){return t.correct?e+1:e},0);if(!e&&t>1){var n=i.map(this.props.choices,function(e){return i.defaults({correct:!1},e)});this.props.onChange({multipleSelect:e,choices:n})}else this.props.onChange({multipleSelect:e})},onCheckedChange:function(e){var t=i.map(this.props.choices,function(t,n){return i.extend({},t,{correct:e[n],content:t.isNoneOfTheAbove&&!e[n]?"":t.content})});this.props.onChange({choices:t})},onContentChange:function(e,t){var n=this.props.choices.slice();n[e]=i.extend({},n[e],{content:t}),this.props.onChange({choices:n})},onClueChange:function(e,t){var n=this.props.choices.slice();n[e]=i.extend({},n[e],{clue:t}),t===""&&delete n[e].clue,this.props.onChange({choices:n})},onDelete:function(e,t){t.preventDefault();var n=this.props.choices.slice(),r=n[e];n.splice(e,1),this.props.onChange({choices:n,hasNoneOfTheAbove:this.props.hasNoneOfTheAbove&&!r.isNoneOfTheAbove})},addChoice:function(e,t){t.preventDefault();var n=this.props.choices.slice(),r={isNoneOfTheAbove:e},i=n.length-(this.props.hasNoneOfTheAbove?1:0);n.splice(i,0,r),this.props.onChange({choices:n,hasNoneOfTheAbove:e||this.props.hasNoneOfTheAbove},function(){this.refs["choice-editor"+i].refs["content-editor"].focus()}.bind(this))},setDisplayCount:function(e){this.props.onChange({displayCount:e})},focus:function(){return this.refs["choice-editor0"].refs["content-editor"].focus(),!0},getSaveWarnings:function(){return i.some(i.pluck(this.props.choices,"correct"))?[]:["No choice is marked as correct."]},serialize:function(){return i.pick(this.props,"choices","randomize","multipleSelect","displayCount","hasNoneOfTheAbove","onePerLine","deselectEnabled")}}),x=function(e,t){var n=function(n){return e.randomize?p(n,t):n},r=function(e){var t=null;return e=i.reject(e,function(e,n){if(e.isNoneOfTheAbove)return t=e,!0}),t&&e.push(t),e},s=e.choices.slice();return s=i.map(s,function(e,t){return i.extend({},i.omit(e,"correct"),{originalIndex:t})}),s=r(n(s)),e=i.extend({},e,{choices:s}),i.pick(e,"choices","hasNoneOfTheAbove","onePerLine","multipleSelect","correctAnswer","deselectEnabled")},T={1:function(e){var t,n;if(!e.noneOfTheAbove)t=e.choices,n=!1;else{t=i.clone(e.choices);var r=i.random(0,e.choices.length-1),s=i.extend({},e.choices[r],{isNoneOfTheAbove:!0});t.splice(r,1),t.push(s),n=!0}return i.extend(i.omit(e,"noneOfTheAbove"),{choices:t,hasNoneOfTheAbove:n})}};e.exports={name:"radio",displayName:"Multiple choice",accessible:!0,widget:E,editor:S,transform:x,version:{major:1,minor:0},propUpgrades:T}},function(e,t,n){var r=n(16).Options,i=n(71),s=n(10),o=n(14),u=n(5),a=React.createClass({displayName:"StepControlButton",render:function(){return React.createElement("a",{href:"#",className:"step-control-button simple-button simple-button--small orange",onClick:function(e){e.preventDefault(),this.props.onClick()}.bind(this)},React.createElement("span",{className:this.props.icon}))}}),f=React.createClass({displayName:"Sequence",mixins:[i],propTypes:{json:React.PropTypes.arrayOf(React.PropTypes.shape({content:React.PropTypes.string,widgets:React.PropTypes.object,images:React.PropTypes.object})),apiOptions:r.propTypes},getDefaultProps:function(){return{json:[{content:"",widgets:{},images:{}}]}},getInitialState:function(){return{visible:1}},shouldComponentUpdate:function(e,t){return e!==this.props||t!==this.state},render:function(){var e=React.createElement("div",{className:"icon-ok",style:{color:"green"}}),t=_.chain(this.props.json).first(this.state.visible).map(function(e,t){return"[["+u.snowman+" group "+t+"]]"}).join("\n\n").value(),n={};return _.each(this.props.json,function(t,r){var i="group "+r;n[i]={type:"group",graded:!0,version:{major:0,minor:0},options:_.extend({},t,{onInteractWithWidget:_.partial(this._handleInteraction,r),icon:r<this.state.visible-1?e:null})}}.bind(this)),React.createElement("div",{className:"perseus-sequence"},React.createElement(o,{ref:"renderer",content:t,widgets:n,apiOptions:this.props.apiOptions,enabledFeatures:this.props.enabledFeatures}))},_handleInteraction:function(e){if(e===this.state.visible-1){var t=this.refs.renderer.getWidgetInstance("group "+e),n=t.simpleValidate();n.type==="points"&&n.total===n.earned&&this.setState({visible:this.state.visible+1})}},statics:{displayMode:"block"}}),l=React.createClass({displayName:"SequenceEditor",propTypes:{json:React.PropTypes.arrayOf(React.PropTypes.shape({content:React.PropTypes.string,widgets:React.PropTypes.object,images:React.PropTypes.object})),apiOptions:r.propTypes,onChange:React.PropTypes.func.isRequired},getDefaultProps:function(){return{json:[{content:"",widgets:{},images:{}}]}},render:function(){return React.createElement("div",{className:"perseus-sequence-editor"},_.map(this.props.json,function(e,t){return React.createElement("div",null,"Step ",t+1,React.createElement("div",{style:{display:"inline-block","float":"right"}},t+1<this.props.json.length&&React.createElement(a,{icon:"icon-circle-arrow-down",onClick:function(){this._handleMoveStepLater(t)}.bind(this)}),t>0&&React.createElement(a,{icon:"icon-circle-arrow-up",onClick:function(){this._handleMoveStepEarlier(t)}.bind(this)}),React.createElement(a,{icon:"icon-trash",onClick:function(){var e="Are you sure you want to remove step "+(t+1)+"?";confirm(e)&&this._handleRemoveStep(t)}.bind(this)}),React.createElement(a,{icon:"icon-plus",onClick:function(){this._handleAddStepAfter(t)}.bind(this)})),React.createElement(s,{ref:"editor"+t,content:e.content,widgets:e.widgets,images:e.images,widgetEnabled:!0,immutableWidgets:!1,onChange:_.partial(this._handleEditorChange,t)}))}.bind(this)))},_handleEditorChange:function(e,t){var n=_.clone(this.props.json);n[e]=_.extend({},n[e],t),this.props.onChange({json:n})},serialize:function(){return{json:_.times(this.props.json.length,function(e){return this.refs["editor"+e].serialize()}.bind(this))}},_handleMoveStepEarlier:function(e){if(e===0)return;var t=_.clone(this.props.json),n=t[e];t.splice(e,1),t.splice(e-1,0,n),this.props.onChange({json:t})},_handleMoveStepLater:function(e){var t=_.clone(this.props.json);if(e+1===t.length)return;var n=t[e];t.splice(e,1),t.splice(e+1,0,n),this.props.onChange({json:t})},_handleAddStepAfter:function(e){var t=_.clone(this.props.json),n=e>=0?{widgets:t[e].widgets}:{};t.splice(e+1,0,n),this.props.onChange({json:t})},_handleRemoveStep:function(e){var t=_.clone(this.props.json);t.splice(e,1),this.props.onChange({json:t})}}),c=function(e,t,n){_.each(e.json,function(e){n(e,t)})};e.exports={name:"sequence",displayName:"Sequence",widget:f,editor:l,traverseChildWidgets:c,hidden:!0}},function(e,t,n){var r=n(74),i=n(62),s=n(71),o=n(72),u=n(16).Options,a=n(93).assert,f=n(76),l=f,c=l.Path,h=l.Arc,p=l.Circle,d=l.Label,v=l.Line,m=l.MovablePoint,g=l.MovableLine,y=n(91),b=n(92),w=n(5).seededRNG,E=n(5),S=n(108).number,x=400,T=1e3,N=5e3,C=React.createClass({displayName:"Histogram",propTypes:{data:React.PropTypes.arrayOf(React.PropTypes.number),xAxisLabel:React.PropTypes.string,yAxisLabel:React.PropTypes.string,box:React.PropTypes.arrayOf(React.PropTypes.number)},getDefaultProps:function(){return{data:null,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",box:[x,x]}},getInitialState:function(){return{threshold:this._getInitialThreshold(this._range())}},componentWillReceiveProps:function(e){var t=this._range(),n=this._range(e);E.deepEq(t,n)||this.setState({threshold:this._getInitialThreshold(n)})},_renderThresholdLine:function(){var e=[0,this._range()[1][1]],t=i.map(e,function(e){return[this.state.threshold,e]}.bind(this)),n=function(e,t){return React.createElement(m,{key:t,"static":!0,coord:e,normalStyle:{stroke:"none",fill:"none"}})};return React.createElement(g,{onMove:this.handleMouseInteraction},i.map(t,n))},_renderCircle:function(){var e=this.props.data,t=i.reduce(e,function(e,t){return e+t},0),n=i.reduce(e,function(e,t,n){return this.state.threshold!=null&&n<=this.state.threshold?e+t:e}.bind(this),0),r=n/t,s=1e-5,o=20,u=[this.props.box[0]-1.5*o,1.5*o],a=function(){var e={key:"below",center:u,radius:o,startAngle:0,endAngle:r<1?360*r:360-s,sector:r!==1,unscaled:!0,style:{fill:KhanUtil.LIGHT_RED,stroke:KhanUtil.RED}};return React.createElement(h,React.__spread({},e))},f=function(){var e={key:"above",center:u,radius:o,startAngle:r>0?360*r:s,endAngle:360,sector:r!==0,unscaled:!0,style:{fill:KhanUtil.LIGHT_BLUE,stroke:KhanUtil.BLUE}};return React.createElement(h,React.__spread({},e))},l=this._range()[0],c=Math.min(Math.max(this.state.threshold,l[0]),l[1]).toFixed(2),p=function(){var e={key:"label",coord:[u[0],u[1]+1.5*o],text:n+" of "+t+" results below "+c+"%",direction:"center",tex:!1,unscaled:!0,style:{fontSize:"12px"}};return React.createElement(d,React.__spread({},e))};return[r>0&&a(),r<1&&f(),p()]},_renderData:function(){var e=this.props.data,t=this._range(),n=1,r=function(e,t){if(!e)return;var r=this.state.threshold!=null&&t<=this.state.threshold,i={fill:r?KhanUtil.LIGHT_RED:KhanUtil.LIGHT_BLUE,stroke:r?KhanUtil.RED:KhanUtil.BLUE},s=[[t,0],[t,e],[t+n,e],[t+n,0]];return React.createElement(c,{key:t,coords:s,style:i})}.bind(this);return i.map(e,r)},render:function(){var e=this.props.data,t=this._range(),n={xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,box:this.props.box,range:t,data:e,scale:[E.scaleFromExtent(t[0],this.props.box[0]),E.scaleFromExtent(t[1],this.props.box[1])]},r={stroke:"#000",strokeWidth:1,opacity:1},i=[t[0][0],0],s=[t[0][1],0];return React.createElement(f,{box:n.box,range:n.range,options:n,setup:this._setupGraphie,onMouseMove:this.handleMouseInteraction,onMouseDown:this.handleMouseInteraction},React.createElement(v,{start:i,end:s,style:r}),e&&this._renderData(),e&&this._renderCircle(),e&&this._renderThresholdLine())},_setupGraphie:function(e,t){var n=t.data,r=t.range,s=t.scale,o=r[0][1]-r[0][0],u=r[1][1]-0,a=20,f=Math.ceil(u/a);i.each(i.range(0,r[1][1],f),function(t){n&&e.label([r[0][0],t],KhanUtil.roundToApprox(t,2),"left",!0),e.line([r[0][0],t],[r[0][1],t],{stroke:"#000",strokeWidth:1,opacity:.3})});if(n){var l=15,c=Math.ceil(o/l);i.each(i.range(r[0][0],r[0][1],c),function(t){e.label([t,0],S.round(t,2),"below",!0);var n=8;e.line([t,0],[t,-n/s[1]],{stroke:"#000",strokeWidth:1})})}var h={stroke:"#000",strokeWidth:2,opacity:1},p=[r[0][0],0],d=[r[0][0],r[1][1]];e.line(p,d,h);var v=r[0][0]+o/2,m=n?25:0;e.label([v,-m/s[1]],t.xAxisLabel,"below",!1).css("font-weight","bold");var g=0+u/2,y=n?55:28;e.label([r[0][0]-y/s[0],g],t.yAxisLabel,"center",!1).css("font-weight","bold").css("-webkit-transform","rotate(-90deg)")},handleMouseInteraction:function(e){this.setState({threshold:e[0]})},_range:function(e){var t=[[0,100],[-1,10]];return e=e||this.props,e.data?this._getRangeForData(e.data):t},_getRangeForData:function(e){var t=10,n=i.indexOf(e,i.find(e,function(e){return e>0})),r=Math.max(0,n-t),s=i.lastIndexOf(e,i.last(i.filter(e,function(e){return e>0}))),o=Math.min(101,s+1+t),u=-1,a=i.max(e);return[[r,o],[u,a]]},_getInitialThreshold:function(e){var t=e[0];return t[0]+(t[1]-t[0])/3}}),k=React.createClass({displayName:"Simulator",mixins:[s],propTypes:{data:React.PropTypes.arrayOf(React.PropTypes.number),userProportion:React.PropTypes.number,sampleSize:React.PropTypes.number,numTrials:React.PropTypes.number,randomSeed:React.PropTypes.number,xAxisLabel:React.PropTypes.string,yAxisLabel:React.PropTypes.string,proportionLabel:React.PropTypes.string,proportionOrPercentage:React.PropTypes.string,apiOptions:u.propTypes},getInitialState:function(){return{invalidInput:!1}},getDefaultProps:function(){return{data:null,userProportion:null,sampleSize:null,numTrials:null,randomSeed:0,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion",apiOptions:u.defaults}},componentWillMount:function(){this.props.randomSeed!=null&&(this.generateNumber=E.seededRNG(this.props.randomSeed))},componentWillReceiveProps:function(e){e.randomSeed!==this.props.randomSeed&&(this.generateNumber=E.seededRNG(e.randomSeed))},render:function(){var e={marginLeft:"5px"},t="0px 0px 9px 2px rgba(255, 165, 0, 1)",n=i.extend({},e,{WebkitBoxShadow:t,MozBoxShadow:t,boxShadow:t,transition:"all 0.15s"}),s=i.extend({},e,{transition:"all 0.15s"}),o=this.state.invalidInput?n:s,u=this.props.apiOptions.staticRender?b:y,a=React.createElement("div",null,React.createElement(u,{ref:"userProportion",style:o,value:this.calculateDisplayProportion(),checkValidity:this.checkProportionValidity,onChange:this.handleUserProportionChange,onFocus:function(){return this.props.onFocus(["userProportion"])}.bind(this),onBlur:function(){return this.props.onBlur(["userProportion"])}.bind(this)}),React.createElement(r,null,React.createElement("p",null,"This controls the proportion or percentage that will be used in your simulation."))),f=React.createElement("div",null,React.createElement(u,{ref:"sampleSize",style:o,value:this.props.sampleSize,checkValidity:function(e){return e>=0},onChange:this.handleSampleSizeChange,onFocus:function(){return this.props.onFocus(["sampleSize"])}.bind(this),onBlur:function(){return this.props.onBlur(["sampleSize"])}.bind(this)}),React.createElement(r,null,React.createElement("p",null,"This controls the sample size that will be used in your simulation. For example, if you set this to 100, then for each trial, responses from 100 participants will be simulated."))),l=React.createElement("div",{style:{"float":"right"}},React.createElement("b",null,this.props.numTrials),React.createElement(r,null,React.createElement("p",null,"This is the number of trials used in the simulation. For example, if set to 50, then the survey will be conducted 50 times."))),c=function(e){var t=React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",null,"Parameter"),React.createElement("th",null,"Value"))),n=React.createElement("tbody",null,i.map(e,function(e,t){return React.createElement("tr",{key:t},React.createElement("td",null,e.title),React.createElement("td",null,e.value))}));return React.createElement("table",null,t,n)},h=[{title:this.props.proportionLabel+":",value:a},{title:"Sample size:",value:f},{title:"Number of trials:",value:l}],p={margin:"20px 0"},d=React.createElement("button",{className:"simple-button",style:p,onClick:this.handleRunSimulation},$_(null,"Run simulation")),v={paddingBottom:this.props.data?40:0},m=React.createElement("div",{style:v},React.createElement(C,{data:this.props.data,xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel}));return React.createElement("div",null,c(h),d,m)},calculateDisplayProportion:function(){var e=this.props.userProportion;return this.props.proportionOrPercentage==="percentage"?Math.round(100*e):e},checkProportionValidity:function(e){return e>=0&&this.props.proportionOrPercentage==="proportion"&&e<=1||this.props.proportionOrPercentage==="percentage"&&e<=100},handleUserProportionChange:function(e,t){var n;this.props.proportionOrPercentage==="percentage"?n=e/100:n=e,n!=null&&(n=Math.min(1,Math.max(0,n))),this.props.onChange({userProportion:n},t)},handleSampleSizeChange:function(e,t){e!=null&&(e=Math.min(T,Math.max(0,Math.floor(e)))),this.props.onChange({sampleSize:e},t)},handleRunSimulation:function(){if(this.props.numTrials==null||this.props.userProportion==null||this.props.sampleSize==null){this.setState({invalidInput:!0});return}this.setState({invalidInput:!1}),this.props.onChange({data:this.generateData()})},generateData:function(e){e=e||this.props;var t=function(e,t,n){var r=function(){return this.generateNumber()<n}.bind(this),s=i.times(101,function(){return 0});return i.times(t,function(){var t=i.times(e,r),n=i.filter(t,i.identity).length,o=Math.floor(100*n/e);s[o]++}),s}.bind(this);return t(e.sampleSize,e.numTrials,e.userProportion)},getInputPaths:function(){return[["userProportion"],["sampleSize"]]},focus:function(){var e=i.head(this.getInputPaths());return this.focusInputPath(e),!0},focusInputPath:function(e){a(e.length>0);var t=i.head(e),n=this.refs[t];n.focus()},blurInputPath:function(e){a(e.length>0);var t=i.head(e),n=this.refs[t];n.blur()},getDOMNodeForPath:function(e){a(e.length>0);var t=i.head(e);return this.refs[t].getDOMNode()},getGrammarTypeForPath:function(e){return a(e.length>0),"number"},setInputValue:function(e,t,n){a(e.length>0);var r=i.head(e),s=r.charAt(0).toUpperCase()+r.slice(1),o="handle"+s+"Change";this[o](t,n)},getUserInput:function(){return null},simpleValidate:function(e){return k.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});i.extend(k,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var L=React.createClass({displayName:"SimulatorEditor",mixins:[s,o],propTypes:{xAxisLabel:React.PropTypes.string,yAxisLabel:React.PropTypes.string,numTrials:React.PropTypes.number,proportionLabel:React.PropTypes.string,proportionOrPercentage:React.PropTypes.string},getDefaultProps:function(){return{xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",numTrials:100,proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion"}},render:function(){return React.createElement("div",{className:"perseus-widget-simulator"},React.createElement("div",null,$_(null,"X-Axis Label"),":",React.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.xAxisLabel,onChange:i.partial(this.handleTargetValueChange,"xAxisLabel")})),React.createElement("div",null,$_(null,"Y-Axis Label"),":",React.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.yAxisLabel,onChange:i.partial(this.handleTargetValueChange,"yAxisLabel")})),React.createElement("div",null,$_(null,'"True Proportion" Label'),":",React.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.proportionLabel,onChange:i.partial(this.handleTargetValueChange,"proportionLabel")}),React.createElement(r,null,React.createElement("p",null,'This text will be displayed next to the box in which the user enters the sample proportion for their simulation. For example, if your question is about surveying for approval ratings, you might want this to say "Sample approval rating".'))),React.createElement("div",null,$_(null,"Proportion or Percentage"),":",React.createElement("select",{className:"perseus-widget-dropdown",value:this.props.proportionOrPercentage,onChange:i.partial(this.handleTargetValueChange,"proportionOrPercentage")},React.createElement("option",{key:"proportion",value:"proportion"},"Proportion"),React.createElement("option",{key:"percentage",value:"percentage"},"Percentage")),React.createElement(r,null,React.createElement("p",null,"Do you want the user to describe their simulation in terms of a proportion or a percentage?"))),React.createElement("div",null,$_(null,"Number of trials"),":",React.createElement(y,{value:this.props.numTrials,checkValidity:function(e){return e>=0&&e<=N},onChange:this.change("numTrials")}),React.createElement(r,null,React.createElement("p",null,"This controls the number of trials used in the simulation. For example, if you set this to 50, then the survey will be conducted 50 times. Warning: setting this too high (i.e., greater than 5000 or so) will freeze the page."))))},handleTargetValueChange:function(e,t){this.change(e,t.target.value)}}),A=function(e){var t=i.clone(e);return t.randomSeed=e.problemNum,t};e.exports={name:"simulator",displayName:"Simulator",widget:k,editor:L,transform:A}},function(e,t,n){var r=n(66),i=n(62),s=n(71),o=n(72),u=n(56),a=u.parse,f=u.testOutput,l=r.createClass({displayName:"TextArea",render:function(){return r.createElement("textarea",{ref:"input",value:this.props.value||"",onChange:this.changeValue})},focus:function(){return this.refs.input.focus(),!0},changeValue:function(e){this.props.onChange(e.target.value)}}),c=r.createClass({displayName:"SimpleMarkdownTester",propTypes:{value:r.PropTypes.string},getDefaultProps:function(){return{value:""}},mixins:[s],toJSON:function(){return{}},render:function(){var e=a(this.props.value),t=f(e);return r.createElement("div",null,t)},focus:function(){return this.refs.input.focus(),!0},simpleValidate:function(e){return c.validate(this.toJSON(),e)},statics:{displayMode:"block"}});i.extend(c,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var h=r.createClass({displayName:"SimpleMarkdownTesterEditor",mixins:[s,o],getDefaultProps:function(){return{value:""}},render:function(){return r.createElement("div",null,r.createElement("label",null,r.createElement("div",null,"Simple markdown contents:"),r.createElement("div",null,r.createElement(l,{value:this.props.value,onChange:this.change("value"),ref:"input"}))))},focus:function(){return this.refs.input.focus(),!0}});e.exports={name:"simple-markdown-tester",displayName:"Simple Markdown Tester",hidden:!0,widget:c,editor:h,transform:i.identity}},function(e,t,n){var r=n(66),i=n(74),s=n(62),o=n(64),u=n(95),a=n(75),f=n(5).shuffle,l="horizontal",c="vertical",h=r.createClass({displayName:"Sorter",propTypes:{correct:r.PropTypes.array,layout:r.PropTypes.oneOf([l,c]),padding:r.PropTypes.bool,problemNum:r.PropTypes.number,onChange:r.PropTypes.func},getDefaultProps:function(){return{correct:[],layout:l,padding:!0,problemNum:0,onChange:function(){}}},render:function(){var e=f(this.props.correct,this.props.problemNum,!0);return r.createElement("div",{className:"perseus-widget-sorter ui-helper-clearfix"},r.createElement(u,{options:e,layout:this.props.layout,padding:this.props.padding,onChange:this.props.onChange,ref:"sortable"}))},getUserInput:function(){return{options:this.refs.sortable.getOptions()}},simpleValidate:function(e){return h.validate(this.getUserInput(),e)},statics:{displayMode:"block"}});s.extend(h,{validate:function(e,t){var n=s.isEqual(e.options,t.correct);return{type:"points",earned:n?1:0,total:1,message:null}}});var p=r.createClass({displayName:"SorterEditor",propTypes:{correct:r.PropTypes.array,layout:r.PropTypes.oneOf([l,c]),padding:r.PropTypes.bool},getDefaultProps:function(){return{correct:["$x$","$y$","$z$"],layout:l,padding:!0}},render:function(){var e=this;return r.createElement("div",null,r.createElement("div",null," ","Correct answer:"," ",r.createElement(i,null,r.createElement("p",null,"Enter the correct answer (in the correct order) here. The preview on the right will have the cards in a randomized order, which is how the student will see them."))),r.createElement(a,{options:this.props.correct,onChange:function(t,n){e.props.onChange({correct:t},n)},layout:this.props.layout}),r.createElement("div",null,r.createElement("label",null," ","Layout:"," ",r.createElement("select",{value:this.props.layout,onChange:this.onLayoutChange},r.createElement("option",{value:l},"Horizontal"),r.createElement("option",{value:c},"Vertical"))),r.createElement(i,null,r.createElement("p",null,"Use the horizontal layout for short text and small images. The vertical layout is best for longer text and larger images."))),r.createElement("div",null,r.createElement(o,{label:"Padding:",padding:this.props.padding,onChange:this.props.onChange}),r.createElement(i,null,r.createElement("p",null,"Padding is good for text, but not needed for images."))))},onLayoutChange:function(e){this.props.onChange({layout:e.target.value})},serialize:function(){return s.pick(this.props,"correct","layout","padding")}});e.exports={name:"sorter",displayName:"Sorter",widget:h,editor:p}},function(e,t,n){var r=n(66),i=n(62),s=n(10),o=n(74),u=n(92),a=n(91),f=n(14),l=n(5),c=n(16).Options,h=n(93).assert,p=function(e,t){return[""+e,""+t]},d=function(){return p(0,0)},v=function(e){return h(i.isArray(e)&&e.length===2),+e[0]},m=function(e){return h(i.isArray(e)&&e.length===2),+e[1]},g=function(e){var t=v(e),n=m(e);return"answer"+t+","+n},y=r.createClass({displayName:"Table",propTypes:{editableHeaders:r.PropTypes.bool,headers:r.PropTypes.arrayOf(r.PropTypes.string),answers:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.string))},getDefaultProps:function(){var e=4,t=1,n=i(e).times(function(){return l.stringArrayOfSize(t)});return{apiOptions:c.defaults,headers:[""],editableHeaders:!1,rows:e,columns:t,answers:n}},_getRows:function(){return this.props.answers.length},_getColumns:function(){return this.props.answers[0].length},render:function(){var e=this._getRows(),t=this._getColumns(),n=this.props.headers,o;return this.props.apiOptions.staticRender?o=u:o="input",r.createElement("table",{className:"perseus-widget-table-of-values non-markdown"},r.createElement("thead",null,r.createElement("tr",null,i.map(n,function(e,t){return this.props.editableHeaders?r.createElement("th",{key:t},r.createElement(s,{ref:"columnHeader"+t,content:e,widgetEnabled:!1,onChange:i.partial(this.onHeaderChange,t)})):r.createElement("th",{key:t},r.createElement(f,{content:e}))}.bind(this)))),r.createElement("tbody",null,i(e).times(function(e){return r.createElement("tr",{key:e},i(t).times(function(t){return r.createElement("td",{key:t},r.createElement(o,{ref:g(p(e,t)),type:"text",value:this.props.answers[e][t],onFocus:i.partial(this._handleFocus,p(e,t)),onBlur:i.partial(this._handleBlur,p(e,t)),onChange:i.partial(this.onValueChange,e,t)}))}.bind(this)))}.bind(this))))},getUserInput:function(){return i.map(this.props.answers,i.clone)},onValueChange:function(e,t,n){var r=i.map(this.props.answers,i.clone);r[e][t]=n.target.value,this.props.onChange({answers:r})},onHeaderChange:function(e,t){var n=this.props.headers.slice();n[e]=t.content,this.props.onChange({headers:n})},simpleValidate:function(e){return y.validate(this.getUserInput(),e)},_handleFocus:function(e){this.props.onFocus(e)},_handleBlur:function(e){this.props.onBlur(e)},focus:function(){return this.focusInputPath(d()),!0},focusInputPath:function(e){var t=g(e),n=this.refs[t];this.props.apiOptions.staticRender?n.focus():n.getDOMNode().focus()},blurInputPath:function(e){var t=g(e),n=this.refs[t];this.props.apiOptions.staticRender?n.blur():n.getDOMNode().blur()},getDOMNodeForPath:function(e){var t=g(e);return this.refs[t].getDOMNode()},getInputPaths:function(){var e=this._getRows(),t=this._getColumns(),n=[];return i(e).times(function(e){i(t).times(function(t){var r=p(e,t);n.push(r)})}),n},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,n){var r=v(e),s=m(e),o=i.map(this.props.answers,i.clone);o[r][s]=t,this.props.onChange({answers:o},n)},statics:{displayMode:"block"}});i.extend(y,{validate:function(e,t){var n=function(e){return i.filter(e,function(e){return i.some(e,i.identity)})},r=n(t.answers),s=n(e),o=i.some(s,function(e){return i.some(e,function(e){return e===""})});if(o||!s.length)return{type:"invalid",message:null};if(s.length!==r.length)return{type:"points",earned:0,total:1,message:null};var u=Khan.answerTypes.number.createValidatorFunctional,a=null,f=i.every(r,function(e){var t;for(t=0;t<s.length;t++){var n=s[t],r=i.every(n,function(t,n){var r=e[n],i=u(r,{simplify:!0}),s=i(t);return s.message&&(a=s.message),s.correct});if(r)return s.splice(t,1),!0}return!1});return{type:"points",earned:f?1:0,total:1,message:a}}});var b=r.createClass({displayName:"TableEditor",propTypes:{rows:r.PropTypes.number,columns:r.PropTypes.number,headers:r.PropTypes.arrayOf(r.PropTypes.string),answers:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.string))},getDefaultProps:function(){var e=4,t=1,n=i(e).times(function(){return l.stringArrayOfSize(t)});return{headers:[""],rows:e,columns:t,answers:n}},focus:function(){this.refs.numberOfColumns.getDOMNode().focus()},render:function(){var e=this.props.rows,t=this.props.columns,n=i.pick(this.props,"headers","answers","onChange");return i.extend(n,{editableHeaders:!0}),r.createElement("div",null,r.createElement("div",{className:"perseus-widget-row"},r.createElement("label",null,"Number of columns:"," ",r.createElement(a,{ref:"numberOfColumns",value:this.props.columns,onChange:function(e){e&&this.onSizeInput(this.props.rows,e)}.bind(this),useArrowKeys:!0}))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("label",null,"Number of rows:"," ",r.createElement(a,{ref:"numberOfRows",value:this.props.rows,onChange:function(e){e&&this.onSizeInput(e,this.props.columns)}.bind(this),useArrowKeys:!0}))),r.createElement("div",null," ","Table of answers:"," ",r.createElement(o,null,r.createElement("p",null,"The student has to fill out all cells in the table.  For partially filled tables create a table using the template, and insert text input boxes as desired."))),r.createElement("div",null,r.createElement(y,r.__spread({},n))))},onSizeInput:function(e,t){function a(e){r<=s?e.length=r:i(r-s).times(function(){e.push("")})}var n=+e||0,r=+t||0;n=Math.min(Math.max(1,n),30),r=Math.min(Math.max(1,r),6);var s=this.props.columns,o=this.props.rows,u=this.props.answers;n<=o?u.length=n:i(n-o).times(function(){u.push(l.stringArrayOfSize(s))});var f=this.props.headers;a(f),i.each(u,a),this.props.onChange({rows:n,columns:r,answers:u,headers:f})},serialize:function(){var e=i.pick(this.props,"headers","rows","columns");return i.extend({},e,{answers:i.map(this.props.answers,i.clone)})}}),w=function(e){var t=e.answers.length,n=e.answers[0].length,r=i(t).times(function(){return l.stringArrayOfSize(n)});return i.extend({},e,{answers:r})};e.exports={name:"table",displayName:"Table of values",accessible:!0,widget:y,editor:b,transform:w}},function(e,t,n){function O(e){return i.reduce(e,function(e,t){return e+t},0)}function M(e,t){return i.object(i.map(e,function(e,n){return[n,e[t]]}))}function P(e){return e.constraints.fixed?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE}function H(e,t){var n=t[0][1]-t[0][0],r=t[1][1]-t[1][0];return e*Math.max(n,r)/20}function B(e,t,n){var r=x.subtract(e,t),i=x.scale(r,n),s=x.add(t,i);return s}function j(e){return String(KhanUtil.roundTo(9,e))}function F(e){var t=KhanUtil.toFraction(e,S.DEFAULT_TOLERANCE);return t[1]===1?j(e):j(t[0])+"/"+j(t[1])}function I(e){return[r.createElement(c,null,"("),j(e[0]),r.createElement(c,null,", {}"),j(e[1]),r.createElement(c,null,")")]}function q(e){return[r.createElement(c,null,"\\langle"),j(e[0]),r.createElement(c,null,", {}"),j(e[1]),r.createElement(c,null,"\\rangle")]}function R(e){return j(e)+d}function U(e,t){return e=i.clone(e).sort(T.compare),t=i.clone(t).sort(T.compare),i.all(i.map(e,function(e,n){var r=t[n];return T.equal(e,r)}))}var r=n(66),i=n(62),s=n(94),o=n(84),u=n(74),a=n(91),f=n(92),l=n(64),c=n(70),h=n(16).Options,p=15,d="°",v=300,m=1.5,g=2,y=1,b=n(5).deepEq,w=n(5).getGridStep,E=n(5).captureScratchpadTouchStart,S=n(108).number,x=n(108).vector,T=n(108).point,N=n(108).ray,C=n(108).line,k=n(93).assert,L=400,A={url:null},_=function(e,t){e=e||{};var n=e.labels||["x","y"],r=e.range||[[-10,10],[-10,10]],i=e.step||[1,1],s=e.gridStep||w(r,i,t);return{box:[t,t],labels:n,range:r,step:i,gridStep:s,valid:!0,backgroundImage:A,markings:"grid",showProtractor:!1}},D={apiOptions:h.defaults,gradeEmpty:!1,graphMode:"interactive",listMode:"dynamic",graph:{},tools:{translation:{enabled:!0,required:!1,constraints:{}},rotation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[1,6]},reflection:{enabled:!0,required:!1,constraints:{fixed:!1},coords:[[2,-4],[2,2]]},dilation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[6,6]}},drawSolutionShape:!0,starting:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]},correct:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]}},z={apply:function(e){return W[e.type].isValid(e)?W[e.type].apply(e):i.identity},append:function(e,t){var n=z._appendAndCollapseLastTwo(e,t);return z._collapseFinalNoOps(n)},_collapseFinalNoOps:function(e){return e.length&&z.isNoOp(i.last(e))?i.initial(e):e},_appendAndCollapseLastTwo:function(e,t){if(!e.length)return[t];var n=z.collapse(i.last(e),t);return i.initial(e).concat(n)},isNoOp:function(e){return W[e.type].isNoOp(e)},collapse:function(e,t){return e.type!==t.type?[e,t]:z.isEmpty(e)&&z.isEmpty(t)?[]:!z.isValid(e)||!z.isValid(t)?[e,t]:z._collapseValidMonotypedTransforms(e,t)},isValid:function(e){return W[e.type].isValid(e)},isEmpty:function(e){return W[e.type].isEmpty(e)},_collapseValidMonotypedTransforms:function(e,t){var n=W[e.type].collapse(e,t);return n?(i.isArray(n)||(n=[n]),i.each(n,function(t){t.type=e.type}),n):[e,t]},toTeX:function(e){return W[e.type].toTeX(e)},ListItem:r.createClass({displayName:"ListItem",render:function(){if(this.props.mode==="dynamic")return r.createElement("div",null,z.toTeX(this.props.transform));if(this.props.mode==="interactive"){var e=W[this.props.transform.type].Input;return r.createElement(e,r.__spread({ref:"transform",onChange:this.handleChange,onFocus:this.props.onFocus,onBlur:this.props.onBlur,apiOptions:this.props.apiOptions},this.props.transform))}throw new Error("Invalid mode: "+this.props.mode)},value:function(){return this.props.mode==="interactive"?i.extend({type:this.props.transform.type},this.refs.transform.value()):this.props.transform},handleChange:i.debounce(function(e){this.props.onChange(this.value(),e)},v),_getComponentAtPath:function(e){var t=this.refs.transform,n=i.head(e);return t.refs[n]},focus:function(){var e=this.refs.transform,t=i.head(e.getInputPaths());t&&this.focusInputPath(t)},focusInputPath:function(e){this._getComponentAtPath(e).focus()},blurInputPath:function(e){this._getComponentAtPath(e).blur()},getDOMNodeForPath:function(e){return this._getComponentAtPath(e).getDOMNode()},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,n){this.refs.transform.setInputValue(e,t,n)},getInputPaths:function(){return this.refs.transform.getInputPaths()},statics:{displayMode:"block"}})},W={translation:{verbName:$._("Translate"),nounName:$._("Translation"),lowerNounName:$._("translation"),apply:function(e){return function(t){return x.add(t,e.vector)}},isValid:function(e){return i.isFinite(e.vector[0])&&i.isFinite(e.vector[1])},isEmpty:function(e){return e.vector[0]===null&&e.vector[1]===null},isNoOp:function(e){return x.equal(e.vector,[0,0])},collapse:function(e,t){return{vector:x.add(e.vector,t.vector)}},toTeX:function(e){return $_({vector:q(e.vector)},"Translation by %(vector)s")},Input:r.createClass({displayName:"Input",getInitialState:function(){return{vector:this.props.vector||[null,null]}},componentDidUpdate:function(e){b(this.props,e)||this.setState({vector:this.props.vector})},render:function(){var e=this.props.apiOptions.staticRender?f:a,t=[r.createElement(c,null,"\\langle"),r.createElement(e,{ref:"x",placeholder:0,value:this.state.vector[0],useArrowKeys:!0,onChange:function(e){var t=this.state.vector[1];this.setState({vector:[e,t]},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"x"),onBlur:i.partial(this.props.onBlur,"x")}),r.createElement(c,null,", {}"),r.createElement(e,{ref:"y",placeholder:0,value:this.state.vector[1],useArrowKeys:!0,onChange:function(e){var t=this.state.vector[0];this.setState({vector:[t,e]},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"y"),onBlur:i.partial(this.props.onBlur,"y")}),r.createElement(c,null,"\\rangle")];return r.createElement("div",null,$_({vector:t},"Translation by %(vector)s"))},value:function(){var e=this.refs.x.getValue(),t=this.refs.y.getValue();return{vector:[e,t]}},setInputValue:function(e,t,n){var r=i.first(e),s=i.clone(this.state.vector);r==="x"?s[0]=t:r==="y"&&(s[1]=t),this.setState({vector:s},function(){this.props.onChange(n)}.bind(this))},getInputPaths:function(){return[["x"],["y"]]}})},rotation:{verbName:$._("Rotate"),nounName:$._("Rotation"),lowerNounName:$._("rotation"),apply:function(e){return function(t){return T.rotateDeg(t,e.angleDeg,e.center)}},isValid:function(e){return i.isFinite(e.angleDeg)&&i.isFinite(e.center[0])&&i.isFinite(e.center[1])},isEmpty:function(e){return e.angleDeg===null&&e.center[0]===null&&e.center[1]===null},isNoOp:function(e){return S.equal(e.angleDeg,0)},collapse:function(e,t){return T.equal(e.center,t.center)?{center:e.center,angleDeg:e.angleDeg+t.angleDeg}:!1},toTeX:function(e){return $_({degrees:R(e.angleDeg),point:I(e.center)},"Rotation by %(degrees)s about %(point)s")},Input:r.createClass({displayName:"Input",getInitialState:function(){return{center:this.props.center||[null,null],angleDeg:this.props.angleDeg||null}},componentDidUpdate:function(e){b(this.props,e)||this.setState({center:this.props.center,angleDeg:this.props.angleDeg})},render:function(){var e=this.props.apiOptions.staticRender?f:a,t=[r.createElement(c,null,"("),r.createElement(e,{ref:"centerX",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:function(e){var t=this.state.center[1];this.setState({center:[e,t]},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"centerX"),onBlur:i.partial(this.props.onBlur,"centerX")}),r.createElement(c,null,", {}"),r.createElement(e,{ref:"centerY",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:function(e){var t=this.state.center[0];this.setState({center:[t,e]},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"centerY"),onBlur:i.partial(this.props.onBlur,"centerY")}),r.createElement(c,null,")")],n=[r.createElement(e,{ref:"angleDeg",placeholder:0,value:this.state.angleDeg,useArrowKeys:!0,onChange:function(e){this.setState({angleDeg:e},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"angleDeg"),onBlur:i.partial(this.props.onBlur,"angleDeg")}),d],s=$_({point:t,degrees:n},"Rotation about %(point)s by %(degrees)s");return r.createElement("div",null,s)},value:function(){var e=this.refs.angleDeg.getValue(),t=this.refs.centerX.getValue(),n=this.refs.centerY.getValue();return{angleDeg:e,center:[t,n]}},setInputValue:function(e,t,n){var r=i.first(e),s=i.clone(this.state.angleDeg),o=i.clone(this.state.center);r==="angleDeg"?s=t:r==="centerX"?o[0]=t:r==="centerY"&&(o[1]=t),this.setState({angleDeg:s,center:o},function(){this.props.onChange(n)}.bind(this))},getInputPaths:function(){return[["centerX"],["centerY"],["angleDeg"]]}})},reflection:{verbName:$._("Reflect"),nounName:$._("Reflection"),lowerNounName:$._("reflection"),apply:function(e){return function(t){return T.reflectOverLine(t,e.line)}},isValid:function(e){return i.all(i.flatten(e.line),i.isFinite)&&!T.equal(e.line[0],e.line[1])},isEmpty:function(e){return i.all(i.flatten(e.line),i.isNull)},isNoOp:function(e){return!1},collapse:function(e,t){return C.equal(e.line,t.line)?[]:!1},toTeX:function(e){var t=e.line[0],n=e.line[1];return $_({point1:I(t),point2:I(n)},"Reflection over the line from %(point1)s to %(point2)s")},Input:r.createClass({displayName:"Input",getInitialState:function(){return{line:this.props.line||[[null,null],[null,null]]}},componentDidUpdate:function(e){b(this.props,e)||this.setState({line:this.props.line})},render:function(){var e=this.props.apiOptions.staticRender?f:a,t=[r.createElement(c,null,"("),r.createElement(e,{ref:"x1",value:this.state.line[0][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,0),onFocus:i.partial(this.props.onFocus,"x1"),onBlur:i.partial(this.props.onBlur,"x1")}),r.createElement(c,null,", {}"),r.createElement(e,{ref:"y1",value:this.state.line[0][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,1),onFocus:i.partial(this.props.onFocus,"y1"),onBlur:i.partial(this.props.onBlur,"y1")}),r.createElement(c,null,")")],n=[r.createElement(c,null,"("),r.createElement(e,{ref:"x2",value:this.state.line[1][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,0),onFocus:i.partial(this.props.onFocus,"x2"),onBlur:i.partial(this.props.onBlur,"x2")}),r.createElement(c,null,", {}"),r.createElement(e,{ref:"y2",value:this.state.line[1][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,1),onFocus:i.partial(this.props.onFocus,"y2"),onBlur:i.partial(this.props.onBlur,"y2")}),r.createElement(c,null,")")];return r.createElement("div",null,$_({point1:t,point2:n},"Reflection over the line from %(point1)s to %(point2)s"))},changePoint:function(e,t,n,r){var s=i.map(this.state.line,i.clone);s[e][t]=n,this.setState({line:s},function(){this.props.onChange(r)}.bind(this))},value:function(){var e=this.refs.x1.getValue(),t=this.refs.y1.getValue(),n=this.refs.x2.getValue(),r=this.refs.y2.getValue();return{line:[[e,t],[n,r]]}},setInputValue:function(e,t,n){var r=i.first(e),s;r[0]==="x"?s=0:r[0]==="y"&&(s=1);var o;r[1]==="1"?o=0:r[1]==="2"&&(o=1),this.changePoint(o,s,t,n)},getInputPaths:function(){return[["x1"],["y1"],["x2"],["y2"]]}})},dilation:{verbName:$._("Dilate"),nounName:$._("Dilation"),lowerNounName:$._("dilation"),apply:function(e){return function(t){return B(t,e.center,e.scale)}},isValid:function(e){return i.isFinite(e.scale)&&i.isFinite(e.center[0])&&i.isFinite(e.center[1])},isEmpty:function(e){return e.scale===null&&e.center[0]===null&&e.center[1]===null},isNoOp:function(e){return S.equal(e.scale,1)},collapse:function(e,t){return T.equal(e.center,t.center)?{center:e.center,scale:e.scale*t.scale}:!1},toTeX:function(e){var t=F(e.scale);return $_({scale:t,point:I(e.center)},"Dilation of scale %(scale)s about %(point)s")},Input:r.createClass({displayName:"Input",getInitialState:function(){return{center:this.props.center||[null,null],scale:this.props.scale||null}},componentDidUpdate:function(e){b(this.props,e)||this.setState({center:this.props.center,scale:this.props.scale})},render:function(){var e=this.props.apiOptions.staticRender?f:a,t=[r.createElement(c,null,"("),r.createElement(e,{ref:"x",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:function(e){var t=this.state.center[1];this.setState({center:[e,t]},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"x"),onBlur:i.partial(this.props.onBlur,"x")}),r.createElement(c,null,", {}"),r.createElement(e,{ref:"y",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:function(e){var t=this.state.center[0];this.setState({center:[t,e]},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"y"),onBlur:i.partial(this.props.onBlur,"y")}),r.createElement(c,null,")")],n=r.createElement(e,{ref:"scale",placeholder:1,value:this.state.scale,useArrowKeys:!0,onChange:function(e){this.setState({scale:e},function(){this.props.onChange()}.bind(this))}.bind(this),onFocus:i.partial(this.props.onFocus,"scale"),onBlur:i.partial(this.props.onBlur,"scale")});return r.createElement("div",null,$_({point:t,scale:n},"Dilation about %(point)s by %(scale)s"))},value:function(){var e=this.refs.scale.getValue(),t=this.refs.x.getValue(),n=this.refs.y.getValue();return{scale:e,center:[t,n]}},setInputValue:function(e,t,n){var r=i.first(e),s=this.state.scale,o=i.clone(this.state.center);r==="x"?o[0]=t:r==="y"?o[1]=t:r==="scale"&&(s=t),this.setState({scale:s,center:o},function(){this.props.onChange(n)}.bind(this))},getInputPaths:function(){return[["x"],["y"],["scale"]]}})}},X={getPointCountForType:function(e){var t=e.split("-");if(t[0]==="polygon")return t[1]||3;if(t[0]==="line"||t[0]==="lineSegment")return 2;if(t[0]==="angle")return 3;if(t[0]==="circle")return 2;if(t[0]==="point")return 1},addMovableShape:function(e,t){if(t.editable&&t.translatable)throw new Error("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously. options: "+JSON.stringify(t));var n,r=i.map(t.shape.coords,function(s){var o,u=!1,a=s,f=function(e,s){u||(a=o.coord,u=!0);var f=x.subtract([e,s],o.coord);t.onMove&&(f=t.onMove(f[0],f[1])),t.translatable&&i.each(r,function(e){e!==o&&e.setCoord(x.add(e.coord,f))});var l=o.coord,c=x.add(o.coord,f);return o.coord=c,n.update(),o.coord=l,c},l=function(){if(t.onMoveEnd&&u){u=!1;var e=x.subtract(o.coord,a);t.onMoveEnd(e[0],e[1])}n.update()};return o=e.addMovablePoint({coord:s,normalStyle:t.normalPointStyle,highlightStyle:t.highlightPointStyle,constraints:{fixed:!t.translatable&&!t.editable},visible:t.showPoints,snapX:t.snap&&t.snap[0]||0,snapY:t.snap&&t.snap[1]||0,bounded:!1,onMove:f,onMoveEnd:l}),o.bounded=!0,o});n=X.addShape(e,t,r);var s=n.remove;return n.remove=function(){s.apply(n),i.invoke(r,"remove")},n},addShape:function(e,t,n){n=n||t.shape.coords;var r=X._typesOf(t.shape),s=t.shape.options||X.defaultOptions(r),o=X._mapTypes(r,n,function(n,r,o){var u=i.extend({},t,s[o]);return X._addType(e,n,r,u)}),u=i.filter(i.pluck(o,"update"),i.identity),a=function(){i.invoke(u,"call")},f=i.filter(i.pluck(o,"remove"),i.identity),l=function(){i.invoke(f,"call")},c=function(){return i.map(o,function(e){return e.getOptions?e.getOptions():{}})},h=function(){var e=i.map(n,function(e){return i.isArray(e)?e:e.coord});return{type:r,coords:e,options:c()}};return{type:r,points:n,update:a,remove:l,toJSON:h,getOptions:c}},equal:function(e,t){var n=X._typesOf(e),r=X._typesOf(t);if(n.length!==r.length)return!1;var s=X._mapTypes(n,e.coords,X._combine),o=X._mapTypes(r,t.coords,X._combine);return i.all(i.map(s,function(e,t){var n=o[t];return e.type!==n.type?!1:X._forType(e.type).equal(e.coords,n.coords)}))},_typesOf:function(e){var t=e.type;return i.isArray(t)||(t=[t]),i.map(t,function(e){return e==="polygon"?"polygon-3":e})},defaultOptions:function(e){return i.map(e,function(e){var t=X._forType(e).defaultOptions;return i.extend({},t)})},_forType:function(e){var t=e.split("-")[0];return X[t]},_mapTypes:function(e,t,n,r){return i.map(e,function(e,s){var o=X.getPointCountForType(e),u=i.first(t,o);return t=i.rest(t,o),n.call(r,e,u,s)})},_addType:function(e,t,n,r){var s=i.isArray(n[0])?{coordA:n[0],coordZ:n[1]}:{pointA:n[0],pointZ:n[1]};t=t.split("-")[0];if(t==="polygon"){var o=e.addMovablePolygon(i.extend({},r,{fixed:!r.editable,snapX:r.snap&&r.snap[0]||0,snapY:r.snap&&r.snap[1]||0,points:n,constrainToGraph:!1}));return{update:o.transform.bind(o),remove:o.remove.bind(o)}}if(t==="line"||t==="lineSegment"){var u=e.addMovableLineSegment(i.extend({},r,s,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:t==="line"}));return{update:u.transform.bind(u,!0),remove:u.remove.bind(u)}}if(t==="angle"){var a=r.editable?null:!1,f=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:n,normalStyle:r.normalStyle,reflex:r.reflex});return!i.isArray(n[0])&&!r.editable&&(n[0].remove(),n[2].remove()),{update:f.update.bind(f,a),remove:f.remove.bind(f),getOptions:function(){return{reflex:f.isReflex()}}}}if(t==="circle"){var l={remove:i.identity},c=function(){var t=n[0].coord||n[0],s=n[1].coord||n[1],o=T.distanceToPoint(t,s);l.remove(),l=e.circle(t,o,i.extend({stroke:KhanUtil.DYNAMIC,"stroke-width":2},r.normalStyle))};return c(),n[1].remove&&!r.editable&&n[1].remove(),{update:c,remove:function(){l.remove()}}}if(t==="point")return{update:null,remove:null};throw new Error("Invalid shape type "+t)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:U},line:{equal:C.equal},lineSegment:{equal:U},angle:{equal:function(e,t){if(!T.equal(e[1],t[1]))return!1;var n=[e[1],e[0]],r=[e[1],e[2]],i=[t[1],t[0]],s=[t[1],t[2]],o=N.equal(n,i)&&N.equal(r,s),u=N.equal(n,s)&&N.equal(r,i);return o||u},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){var n=T.distanceToPoint(e[0],e[1]),r=T.distanceToPoint(t[0],t[1]);return T.equal(e[0],t[0])&&S.equal(n,r)}},point:{equal:T.equal}},V=r.createClass({displayName:"ToolSettings",getDefaultProps:function(){return{allowFixed:!0}},render:function(){return r.createElement("div",null,this.props.name,":"," "," ",r.createElement(l,{label:"enabled:",enabled:this.props.settings.enabled,onChange:this.props.onChange})," ",this.props.settings.enabled&&r.createElement(l,{label:"required:",required:this.props.settings.required,onChange:this.props.onChange}),this.props.settings.enabled&&r.createElement(u,null,"'Required' will only grade the answer as correct if the student has used at least one such transformation.")," ",this.props.allowFixed&&this.props.settings.enabled&&r.createElement(l,{label:"fixed:",fixed:this.props.settings.constraints.fixed,onChange:this.changeConstraints}),this.props.allowFixed&&this.props.settings.enabled&&r.createElement(u,null,"Enable 'fixed' to prevent the student from repositioning the tool. The tool will appear in the position at which it is placed in the editor below."))},changeConstraints:function(e){var t=i.extend({},this.props.constraints,e);this.props.onChange({constraints:t})}}),J=r.createClass({displayName:"TransformationExplorerSettings",render:function(){return r.createElement("div",{className:"transformer-settings"},r.createElement("div",null," ","Mode:"," ",r.createElement("select",{value:this.getMode(),onChange:this.changeMode},r.createElement("option",{value:"interactive,dynamic"}," ","Exploration with text"," "),r.createElement("option",{value:"interactive,static"}," ","Exploration without text"," "),r.createElement("option",{value:"dynamic,interactive"}," ","Formal with movement"," "),r.createElement("option",{value:"static,interactive"}," ","Formal without movement"," ")),r.createElement(u,null,r.createElement("ul",null,r.createElement("li",null,r.createElement("b",null,"Exploration:")," Students create transformations with tools on the graph."," "),r.createElement("li",null,r.createElement("b",null,"Formal with movement:")," Students specify transformations mathematically in the transformation list. Graph shows the results of these transformations."," "),r.createElement("li",null,r.createElement("b",null,"Formal without movement:")," Students specify transformations mathematically in the transformation list. Graph does not update."," ")))),r.createElement(V,{name:"Translations",settings:this.props.tools.translation,allowFixed:!1,onChange:this.changeHandlerFor("translation")}),r.createElement(V,{name:"Rotations",settings:this.props.tools.rotation,onChange:this.changeHandlerFor("rotation")}),r.createElement(V,{name:"Reflections",settings:this.props.tools.reflection,onChange:this.changeHandlerFor("reflection")}),r.createElement(V,{name:"Dilations",settings:this.props.tools.dilation,onChange:this.changeHandlerFor("dilation")}),r.createElement(l,{label:"Draw Solution:",drawSolutionShape:this.props.drawSolutionShape,onChange:this.props.onChange}))},getMode:function(){return this.props.graphMode+","+this.props.listMode},changeMode:function(e){var t=e.target.value,n=t.split(",");this.props.onChange({graphMode:n[0],listMode:n[1]})},changeHandlerFor:function(e){return function(t){var n=i.clone(this.props.tools);n[e]=i.extend({},this.props.tools[e],t),this.props.onChange({tools:n})}.bind(this)}}),K=r.createClass({displayName:"TransformationsShapeEditor",render:function(){return r.createElement("div",null,r.createElement(s,{ref:"graph",box:this.props.graph.box,range:this.props.graph.range,labels:this.props.graph.labels,step:this.props.graph.step,gridStep:this.props.graph.gridStep,markings:this.props.graph.markings,backgroundImage:this.props.graph.backgroundImage,onGraphieUpdated:this.setupGraphie}),r.createElement("select",{key:"type-select",value:this.getTypeString(this.props.shape.type),onChange:this.changeType},r.createElement("option",{value:"polygon-3"},"Triangle"),r.createElement("option",{value:"polygon-4"},"Quadrilateral"),r.createElement("option",{value:"polygon-5"},"Pentagon"),r.createElement("option",{value:"polygon-6"},"Hexagon"),r.createElement("option",{value:"line"},"Line"),r.createElement("option",{value:"line,line"},"2 lines"),r.createElement("option",{value:"lineSegment"},"Line segment"),r.createElement("option",{value:"lineSegment,lineSegment"}," ","2 line segments"," "),r.createElement("option",{value:"angle"},"Angle"),r.createElement("option",{value:"circle"},"Circle")))},getTypeString:function(e){return i.isArray(e)?i.map(e,this.getTypeString).join(","):e==="polygon"?"polygon-"+this.props.shape.coords.length:e},changeType:function(e){var t=String(e.target.value).split(","),n=O(i.map(t,X.getPointCountForType)),r=H(4,this.refs.graph.props.range),s=(.5-1/n)*180,o=i.times(n,function(e){return T.rotateDeg([r,0],360*e/n+s)});this.props.onChange({shape:{type:t,coords:o,options:X.defaultOptions(t)}})},componentDidMount:function(){this.setupGraphie(this.refs.graph.graphie())},componentDidUpdate:function(e){b(e.shape,this.props.shape)||this.refs.graph.reset()},updateCoords:function(){this.props.onChange({shape:this.shape.toJSON()})},setupGraphie:function(e){this.shape=X.addMovableShape(e,{editable:!0,snap:e.snap,shape:this.props.shape,onMoveEnd:this.updateCoords})}}),Q=z.ListItem,G=r.createClass({displayName:"TransformationList",render:function(){if(this.props.mode==="static")return r.createElement("span",null);var e=i.map(this.props.transformations,function(e,t){return r.createElement(Q,{ref:"transformation"+t,key:"transformation"+t,transform:e,mode:this.props.mode,onChange:this.handleChange,onFocus:i.partial(this.props.onFocus,""+t),onBlur:i.partial(this.props.onBlur,""+t),apiOptions:this.props.apiOptions})},this);return r.createElement("div",{className:"perseus-transformation-list"},e)},_transformationRefs:function(){return i.times(this.props.transformations.length,function(e){return this.refs["transformation"+e]}.bind(this))},value:function(){return i.invoke(this._transformationRefs(),"value")},handleChange:function(e,t){this.props.onChange(this.value(),t)},focusLast:function(){var e=this._transformationRefs();e.length!==0&&i.last(e).focus()}}),Y=r.createClass({displayName:"ToolButton",render:function(){var e=this.props.toggled?"simple-button exercise-orange toggled highlighted-tool-button":"simple-button";return r.createElement("button",{type:"button",className:e,onClick:this.props.onClick,onTouchStart:E},this.props.children)}}),Z=r.createClass({displayName:"ToolsBar",getInitialState:function(){return{selected:null}},render:function(){var e=i.map(W,function(e,t){if(this.props.enabled[t])return r.createElement(Y,{key:t,toggled:this.state.selected===t,onClick:this.changeSelected.bind(this,t)},e.verbName)},this);return r.createElement("div",{className:"transformer-tools-bar"},r.createElement("span",{className:"simple-button-group"},e),r.createElement("button",{className:"transformer-undo-button simple-button",type:"button",onClick:this.props.onUndoClick,onTouchStart:E},r.createElement("span",{className:"icon-undo"})," ","Undo"),r.createElement("div",{className:"clear"}))},changeSelected:function(e){this.props.removeTool(this.state.selected),!e||e===this.state.selected?this.setState({selected:null}):(this.props.addTool(e),this.setState({selected:e}))}}),et=r.createClass({displayName:"AddTransformBar",render:function(){var e=i.map(W,function(e,t){if(this.props.enabled[t])return r.createElement(Y,{key:t,toggled:!1,onClick:this.changeSelected.bind(this,t)},r.createElement("span",{className:"icon-plus"})," ",e.nounName)},this);return r.createElement("div",{className:"transformer-tools-bar"},e,r.createElement("button",{className:"transformer-undo-button simple-button",type:"button",onClick:this.props.onUndoClick,onTouchStart:E},r.createElement("span",{className:"icon-undo"})," ","Undo"),r.createElement("div",{className:"clear"}))},changeSelected:function(e){e&&this.props.addTool(e)}}),tt=r.createClass({displayName:"Transformer",getDefaultProps:function(){return i.defaults({transformations:[]},D)},render:function(){var e=i.extend(_(this.props.graph,L),this.props.graph),t=this.props.graphMode==="interactive",n=t?Z:et,o=r.createElement("div",{style:{width:e.box[0]}},r.createElement(n,{ref:"toolsBar",enabled:M(this.props.tools,"enabled"),addTool:this.addTool,removeTool:this.removeTool,onUndoClick:this.handleUndoClick}));return r.createElement("div",{className:"perseus-widget perseus-widget-transformer"},r.createElement(s,{ref:"graph",box:e.box,range:e.range,labels:e.labels,step:e.step,gridStep:e.gridStep,markings:e.markings,backgroundImage:e.backgroundImage,showProtractor:e.showProtractor,onGraphieUpdated:this.setupGraphie}),!t&&"Add transformations below:",this.props.graphMode==="static"&&[r.createElement("br",{key:"static-br"}),r.createElement("em",{key:"static-nomove"}," ","Note: For this question, the shape will not move."," ")],t&&o,r.createElement(G,{ref:"transformationList",mode:this.props.listMode,transformations:this.props.transformations,onChange:this.setTransformationProps,onFocus:this._handleFocus,onBlur:this._handleBlur,apiOptions:this.props.apiOptions}),!t&&o)},componentDidMount:function(){this.setupGraphie(this.graphie())},componentDidUpdate:function(e){this.shouldSetupGraphie(this.props,e)?this.refs.graph.reset():b(this.props.transformations,this.transformations)||this.setTransformations(this.props.transformations)},shouldSetupGraphie:function(e,t){return b(t.starting,e.starting)?t.graphMode!==e.graphMode?!0:t.listMode!==e.listMode?!0:t.drawSolutionShape!==e.drawSolutionShape?!0:e.drawSolutionShape&&!b(t.correct.shape,e.correct.shape)?!0:b(this.tools,e.tools)?!1:!0:!0},graphie:function(){return this.refs.graph.graphie()},setupGraphie:function(e){this.props.drawSolutionShape&&this.props.correct.shape&&this.props.correct.shape.coords&&X.addShape(e,{fixed:!0,shape:this.props.correct.shape,normalStyle:{stroke:KhanUtil.GRAY,"stroke-dasharray":"","stroke-width":2}}),this.currentTool=null,this.refs.toolsBar.changeSelected(null),this.addTransformerShape(this.props.starting.shape,!1),this.setTransformations(this.props.transformations),this.tools={translation:i.clone(this.props.tools.translation),rotation:i.clone(this.props.tools.rotation),reflection:i.clone(this.props.tools.reflection),dilation:i.clone(this.props.tools.dilation)}},setTransformations:function(e){this.resetCoords(),this.transformations=i.clone(e),i.each(this.transformations,this.applyTransform)},addTransformerShape:function(e,t){var n=this,r=this.graphie();this.shape=X.addMovableShape(r,{shape:e,editable:!1,showPoints:this.props.graphMode!=="static",translatable:t,onMove:function(e,t){return e=KhanUtil.roundToNearest(r.snap[0],e),t=KhanUtil.roundToNearest(r.snap[1],t),n.addTransform({type:"translation",vector:[e,t]}),[e,t]},normalPointStyle:{fill:t?KhanUtil.INTERACTIVE:KhanUtil.DYNAMIC,stroke:t?KhanUtil.INTERACTIVE:KhanUtil.DYNAMIC},highlightPointStyle:{fill:KhanUtil.INTERACTING,stroke:KhanUtil.INTERACTING}})},addTool:function(e){var t=this;if(this.props.graphMode==="interactive")if(e==="translation")this.currentTool=this.addTranslationTool();else if(e==="rotation")this.currentTool=this.addRotationTool();else if(e==="reflection")this.currentTool=this.addReflectionTool();else{if(e!=="dilation")throw new Error("Invalid tool id: "+e);this.currentTool=this.addDilationTool()}else{var n;if(e==="translation")n={type:e,vector:[null,null]};else if(e==="rotation")n={type:e,center:[null,null],angleDeg:null};else if(e==="reflection")n={type:e,line:[[null,null],[null,null]]};else{if(e!=="dilation")throw new Error("Invalid tool id: "+e);n={type:e,center:[null,null],scale:null}}this.doTransform(n,function(){t.refs.transformationList.focusLast()})}},removeTool:function(e){this.currentTool&&this.currentTool.remove(),this.currentTool=null},addTranslationTool:function(){var e=this;return this.shape.remove(),this.addTransformerShape(this.shape.toJSON(),!0),{remove:function(){e.shape.remove(),e.addTransformerShape(e.shape.toJSON(),!1)}}},snapCoord:function(e){var t=this.graphie();return i.map(e,function(e,n){return KhanUtil.roundToNearest(t.snap[n],e)})},normalizeReflectionCoords:function(e){var t=this.snapCoord(C.midpoint(e)),n=x.polarDegFromCart(x.subtract(e[0],e[1])),r=[1,KhanUtil.roundToNearest(45,n[1])],s=x.cartFromPolarDeg(r),o=i.map([-1,1],function(e){var n=x.add(t,x.scale(s,e*this.scaleToCurrentRange(g)));return this.snapCoord(n)},this);return o},addReflectionTool:function(){var e=this.props.tools.reflection;if(!e.enabled)return;var t=this,n=this.refs.graph.graphie(),r=function(){t.changeTool("reflection",{coords:i.pluck(o,"coord")})},s=this.normalizeReflectionCoords(e.coords),o=i.map(s,function(e){return n.addMovablePoint({coord:e,visible:!1})},this),u,a=P(e);n.style({},function(){u=n.addMovableLineSegment({fixed:e.constraints.fixed,constraints:e.constraints,pointA:o[0],pointZ:o[1],snapX:n.snap[0],snapY:n.snap[1],extendLine:!0,normalStyle:{stroke:a,"stroke-width":2,"stroke-dasharray":"- "},highlightStyle:{stroke:KhanUtil.INTERACTING,"stroke-width":2,"stroke-dasharray":"- "},movePointsWithLine:!0,onMoveEnd:r})});var f=n.addReflectButton({fixed:e.constraints.fixed,line:u,size:this.scaleToCurrentRange(y),onClick:function(){t.doTransform({type:"reflection",line:i.pluck(o,"coord")}),l&&(l.setCoord(x.add(f.coord,x.subtract(f.coord,l.coord))),l.update())},normalStyle:{stroke:a,"stroke-width":2,fill:a},highlightStyle:{stroke:KhanUtil.INTERACTING,"stroke-width":3,fill:KhanUtil.INTERACTING},onMoveEnd:r}),l=null;if(!e.constraints.fixed){var c=x.polarDegFromCart(x.subtract(o[1].coord,o[0].coord))[1]+90;l=n.addRotateHandle({center:f,radius:this.scaleToCurrentRange(g),angleDeg:c,width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),lengthAngle:17,onMove:function(e){return KhanUtil.roundToNearest(45,e)},onMoveEnd:r})}return $(u).on("move",function(){f.update(),$(f).trigger("move")}),l&&$(l).on("move",function(){var e=t.snapCoord(l.coord),n=x.subtract(e,f.coord),r=f.isFlipped()?1:0;o[r].setCoord(x.add(f.coord,x.rotateDeg(n,90))),o[1-r].setCoord(x.add(f.coord,x.rotateDeg(n,-90))),u.transform(!0),f.update()}),{remove:function(){f.remove(),l&&l.remove(),u.remove(),o[0].remove(),o[1].remove()}}},scaleToCurrentRange:function(e){return H(e,this.refs.graph.props.range)},addRotationTool:function(){var e=this.props.tools.rotation;if(!e.enabled)return;var t=this,n=this.refs.graph.graphie(),r=P(e);return this.rotatePoint=n.addMovablePoint({constraints:e.constraints,coord:e.coord,snapX:n.snap[0],snapY:n.snap[1],normalStyle:{"stroke-dasharray":"",stroke:r,fill:r},highlightStyle:{"stroke-dasharray":"",stroke:KhanUtil.INTERACTING,fill:KhanUtil.INTERACTING}}),this.rotateHandle=n.addRotateHandle({center:this.rotatePoint,radius:this.scaleToCurrentRange(m),width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),onMove:function(e,n){var r=t.getRotationTransformFromAngle(t.rotatePoint.coord,e-n);return t.doTransform(r),n+r.angleDeg}}),this.rotatePoint.onMoveEnd=function(e,n){t.changeTool("rotation",{coord:[e,n]})},{remove:function(){t.rotateHandle.remove(),t.rotatePoint.remove()}}},addDilationTool:function(){var e=this.props.tools.dilation;if(!e.enabled)return;var t=this,n=this.refs.graph.graphie(),r=P(e);t.dilationCircle=n.addCircleGraph({centerConstraints:e.constraints,center:e.coord,radius:t.scaleToCurrentRange(2),snapX:n.snap[0],snapY:n.snap[1],minRadius:t.scaleToCurrentRange(1),snapRadius:t.scaleToCurrentRange(.5),onResize:function(e,n){t.doTransform({type:"dilation",center:t.dilationCircle.centerPoint.coord,scale:e/n})},circleNormalStyle:{stroke:r,"stroke-width":2,"stroke-dasharray":"- ","fill-opacity":0},circleHighlightStyle:{stroke:KhanUtil.INTERACTING,"stroke-width":2,"stroke-dasharray":"",fill:KhanUtil.INTERACTING,"fill-opacity":.05},centerNormalStyle:{stroke:r,fill:r,"stroke-width":2,"stroke-dasharray":""},centerHighlightStyle:{stroke:r,fill:r,"stroke-width":2,"stroke-dasharray":""}});var s=this.dilationCircle.centerPoint.onMoveEnd;return this.dilationCircle.centerPoint.onMoveEnd=function(){s&&s.apply(this,i.toArray(arguments)),t.changeTool("dilation",{coord:t.dilationCircle.centerPoint.coord})},{remove:function(){t.dilationCircle.remove()}}},getRotationTransformFromAngle:function(e,t){t=(t+360)%360,t>180&&(t-=360);var n=Math.round(t/p)*p;return{type:"rotation",center:e,angleDeg:n}},doTransform:function(e,t){this.applyTransform(e),this.addTransform(e,t)},applyTransform:function(e){if(this.props.graphMode!=="static"){var t=z.apply(e);this.applyCoordTransformation(t)}},applyCoordTransformation:function(e){i.each(this.shape.points,function(t){var n=e(t.coord);t.setCoord(n)}),this.shape.update()},resetCoords:function(){var e=this.props.starting.shape.coords;i.each(this.shape.points,function(t,n){t.setCoord(e[n])}),this.shape.update()},handleUndoClick:function(){this.refs.toolsBar.changeSelected(null),this.props.transformations.length&&this.props.onChange({transformations:i.initial(this.props.transformations)})},setTransformationProps:function(e,t){this.props.onChange({transformations:e},t)},addTransform:function(e,t){this.transformations=z.append(this.transformations,e),this.props.onChange({transformations:i.clone(this.transformations)},t)},changeTool:function(e,t){var n=i.clone(this.props.tools);n[e]=i.extend({},this.props.tools[e],t),this.tools[e]=i.clone(n[e]),this.props.onChange({tools:n})},simpleValidate:function(e){return tt.validate(this.getUserInput(),e)},getCoords:function(){var e=this.props.starting.shape.coords,t=this.props.transformations;return i.reduce(t,function(e,t){return i.map(e,z.apply(t))},e)},getEditorJSON:function(){var e=i.pick(this.props,"grading","starting","graphMode","listMode","tools","drawSolutionShape","gradeEmpty");return e.graph=this.refs.graph.toJSON(),e.version=1.2,e.answer=this.getUserInput(),e},getUserInput:function(){return{transformations:this.props.transformations,shape:{type:this.shape.type,coords:this.getCoords(),options:this.shape.getOptions()}}},statics:{displayMode:"block"},_handleFocus:function(){var e=Array.prototype.slice.call(arguments);this.props.onFocus(e)},_handleBlur:function(){var e=Array.prototype.slice.call(arguments);this.props.onBlur(e)},_getTransformationForID:function(e){var t=["transformationList","transformation"+e],n=this;return i.each(t,function(e){n=n.refs[e]}),n},getInputPaths:function(){var e=[];return i.each(this.props.transformations,function(t,n){var t=this._getTransformationForID(n),r=t.getInputPaths(),s=i.map(r,function(e){return[""+n].concat(e)});e=e.concat(s)}.bind(this)),e},_passToInner:function(e,t){if(!t||!t.length)return;var n=i.rest(t),r=[n].concat(i.rest(arguments,2)),s=i.head(t),o=this._getTransformationForID(s);return o[e].apply(o,r)},focus:function(){var e=this.getInputPaths();return e.length>0?(this.focusInputPath(e[0]),!0):!1},focusInputPath:function(e){return k(e.length>=2),this._passToInner("focusInputPath",e)},blurInputPath:function(e){return k(e.length>=2),this._passToInner("blurInputPath",e)},setInputValue:function(e,t,n){return k(e.length>=2),this._passToInner("setInputValue",e,t,n)},getDOMNodeForPath:function(e){return k(e.length>=2),this._passToInner("getDOMNodeForPath",e)},getGrammarTypeForPath:function(e){return k(e.length>=2),this._passToInner("getGrammarTypeForPath",e)}});i.extend(tt,{validate:function(e,t){for(var n in W)if(t.tools[n].required){var r=i.any(i.map(e.transformations,function(e){return e.type===n&&!z.isEmpty(e)&&!z.isNoOp(e)}));if(!r)return{type:"invalid",message:$._("Your transformation must use a %(type)s.",{type:W[n].lowerNounName})}}return X.equal(e.shape,t.correct.shape)?{type:"points",earned:1,total:1,message:null}:!t.gradeEmpty&&b(e.shape.coords,t.starting.shape.coords)?{type:"invalid",message:$._("Use the interactive graph to define a correct transformation.")}:{type:"points",earned:0,total:1,message:null}}});var nt=r.createClass({displayName:"TransformerEditor",getDefaultProps:function(){return D},render:function(){var e=i.extend(_(this.props.graph,340),this.props.graph);return r.createElement("div",null,r.createElement("div",null,r.createElement(l,{label:"Grade empty answers as wrong:",gradeEmpty:this.props.gradeEmpty,onChange:this.props.onChange}),r.createElement(u,null,r.createElement("p",null,"We generally do not grade empty answers. This usually works well, but sometimes can result in giving away part of an answer in a multi-part question."),r.createElement("p",null,"If this is a multi-part question (there is another widget), you probably want to enable this option. Otherwise, you should leave it disabled."),r.createElement("p",null,"Confused? Talk to Elizabeth."))),r.createElement("div",null,"Graph settings:"),r.createElement(o,{box:e.box,labels:e.labels,range:e.range,step:e.step,gridStep:e.gridStep,valid:e.valid,backgroundImage:e.backgroundImage,markings:e.markings,showProtractor:e.showProtractor,onChange:this.changeGraph}),r.createElement("div",null,"Transformation settings:"),r.createElement(J,{ref:"transformationSettings",graphMode:this.props.graphMode,listMode:this.props.listMode,tools:this.props.tools,drawSolutionShape:this.props.drawSolutionShape,onChange:this.props.onChange}),r.createElement("div",null,"Starting location:"),r.createElement(K,{ref:"shapeEditor",graph:e,shape:this.props.starting.shape,onChange:this.changeStarting}),r.createElement("div",null,"Solution transformations:"),r.createElement(tt,{ref:"explorer",graph:e,graphMode:this.props.graphMode,listMode:this.props.listMode,gradeEmpty:this.props.gradeEmpty,tools:this.props.tools,drawSolutionShape:this.props.drawSolutionShape,starting:this.props.starting,correct:this.props.starting,transformations:this.props.correct.transformations,onChange:this.changeTransformer}))},changeGraph:function(e,t){var n=i.extend({},this.props.graph,e);this.props.onChange({graph:n},t)},changeStarting:function(e){var t=i.extend({},this.props.starting,e);this.props.onChange({starting:t})},changeTransformer:function(e,t){e.transformations&&(e.correct={transformations:e.transformations},delete e.transformations),this.props.onChange(e,t)},serialize:function(){var e=this.refs.explorer.getEditorJSON();return e.correct=e.answer,delete e.answer,e}});e.exports={name:"transformer",displayName:"Transformer",widget:tt,editor:nt}},function(e,t,n){var r=n(62),i=n(110),s=n(16).ClassNames,o=n(16).Options,u=n(71),a=n(72),f=n(92),l=n(91),c=n(96),h=c.SignificantFigures,p=c.displaySigFigs,d="all",v="some",m=10,g=function(e){return(new h(e)).sigFigs},y=function(e,t){return p(e,t,-m,!1)},b=React.createClass({displayName:"OldUnitInput",mixins:[u],propTypes:{value:React.PropTypes.string},getDefaultProps:function(){return{apiOptions:o.defaults,value:""}},render:function(){var e=this.props.apiOptions.staticRender?React.createFactory(f):React.DOM.input,t=e({onChange:this.handleChange,ref:"input",className:s.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur});return React.createElement("div",{className:"old-unit-input"},t,React.createElement("div",{ref:"error",className:"error",style:{display:"none"}},$_(null,"I don't understand that")))},_errorTimeout:null,_showError:function(){if(this.props.value==="")return;var e=$(this.refs.error.getDOMNode());e.is(":visible")||e.css({top:50,opacity:.1}).show().animate({top:0,opacity:1},300)},_hideError:function(){var e=$(this.refs.error.getDOMNode());e.is(":visible")&&e.animate({top:50,opacity:.1},300,function(){$(this).hide()})},componentDidUpdate:function(){clearTimeout(this._errorTimeout),KAS.unitParse(this.props.value).parsed?this._hideError():this._errorTimeout=setTimeout(this._showError,2e3)},componentWillUnmount:function(){clearTimeout(this._errorTimeout)},handleBlur:function(){this.props.onBlur([]),clearTimeout(this._errorTimeout),KAS.unitParse(this.props.value).parsed||this._showError()},handleChange:function(e){this._hideError(),this.props.onChange({value:e.target.value})},simpleValidate:function(e,t){return t=t||function(){},b.validate(this.getUserInput(),e)},getUserInput:function(){return this.props.value},getInputPaths:function(){return[[]]},focusInputPath:function(e){this.refs.input.getDOMNode().focus()},handleFocus:function(){this.props.onFocus([])},blurInputPath:function(e){this.refs.input.getDOMNode().blur()},setInputValue:function(e,t,n){this.props.onChange({value:t},n)},getDOMNodeForPath:function(){return this.refs.input.getDOMNode()},getGrammarTypeForPath:function(e){return"unit"},statics:{displayMode:"inline-block"}}),w=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()};r.extend(b,{validate:function(e,t){var n=KAS.unitParse(t.value).expr,i=KAS.unitParse(e);if(!i.parsed)return{type:"invalid",message:$._("I couldn't understand those units.")};var s=null,o=t.sigfigs,u=g(i.coefficient)===o;u||(s=$._("Check your significant figures."));var a;try{var f=new KAS.Var("x"),l=new KAS.Eq(n.simplify(),"=",new KAS.Mul(f,i.expr.simplify())),c=l.solveLinearEquationForVariable(f);a=Number(c.eval()).toPrecision(o)===Number(1).toPrecision(o)}catch(h){a=!1}a||(s=$._("That answer is numerically incorrect."));var p,v=w(i.expr.simplify()),m=w(n.simplify());t.accepting===d?p=KAS.compare(v,m).equal:p=r(t.acceptingUnits).any(function(e){var t=w(KAS.unitParse(e).unit.simplify());return KAS.compare(t,v).equal});if(!p)var s=$._("Check your units.");var y=p&&a&&u;return{type:"points",earned:y?1:0,total:1,message:s}}});var E=React.createClass({displayName:"UnitExample",render:function(){var e;return this.state.valid?e=React.createElement("span",null,React.createElement("i",{className:"icon-ok unit-example-okay"}),this.state.solvedExample):e=React.createElement("i",{className:"icon-remove unit-example-not-okay"}),React.createElement("div",null,e," ",this.props.name)},componentWillReceiveProps:function(e){this._checkValidity(e)},componentWillMount:function(){this._checkValidity(this.props)},_checkValidity:function(e){var t=e.name,n=e.original,r=e.sigfigs,i=KAS.unitParse(t),s="",o=!0;if(i.parsed&&n){var u=new KAS.Var("x"),a=i,f=a.unit,l=new KAS.Eq(n,"=",new KAS.Mul(u,f));try{var c=l.solveLinearEquationForVariable(u);s=y(c.eval(),r),o=KAS.compare(w(n),w(f)).equal}catch(h){o=!1}}else o=!1;this.setState({valid:o,solvedExample:s})}}),S=React.createClass({displayName:"UnitInputEditor",mixins:[u,a],propTypes:{value:React.PropTypes.string,acceptingUnits:React.PropTypes.arrayOf(React.PropTypes.string),accepting:React.PropTypes.oneOf([d,v]),sigfigs:React.PropTypes.number},getDefaultProps:function(){return{value:"5x10^5 kg m / s^2",accepting:d,sigfigs:3}},render:function(){var e=this.props,t=e.acceptingUnits,n=e.accepting;t=t||[];var r=null;if(n===v){var i=t.map(function(e){return React.createElement(E,{name:e,original:this.original||null,sigfigs:this.props.sigfigs})}.bind(this));r=React.createElement("div",null,React.createElement("input",{type:"text",defaultValue:t.join(", "),onChange:this.handleAcceptingUnitsChange})," ","(comma-separated)",i)}return React.createElement("div",{className:"unit-editor"},React.createElement("div",null,React.createElement("input",{value:this.props.value,className:"unit-editor-canonical",onBlur:this._handleBlur,onKeyPress:this._handleBlur,onChange:this.onChange})," ",this.parsed?React.createElement("i",{className:"icon-ok unit-example-okay"}):React.createElement("i",{className:"icon-remove unit-example-not-okay"})),React.createElement("div",null,"Significant Figures:"," ",React.createElement(l,{value:this.props.sigfigs,onChange:this.handleSigfigChange,checkValidity:this._checkSigfigValidity,useArrowKeys:!0})),React.createElement("div",null,React.createElement("label",null,React.createElement("input",{type:"radio",name:this.groupId,onChange:function(){return this._setAccepting(d)}.bind(this),checked:this.props.accepting===d})," Any equivalent unit "),React.createElement("label",null,React.createElement("input",{type:"radio",name:this.groupId,onChange:function(){return this._setAccepting(v)}.bind(this),checked:this.props.accepting===v})," Only these units ")),r)},handleAcceptingUnitsChange:function(e){var t=e.target.value.split(",").map(function(e){return e.trim()}).filter(function(e){return e!==""});this.change({acceptingUnits:t})},handleSigfigChange:function(e){this.change({sigfigs:e})},_checkSigfigValidity:function(e){return e>0&&e<=m},_setAccepting:function(e){this.change({accepting:e})},componentWillMount:function(){this.groupId=r.uniqueId("accepting"),this._doOriginal(this.props)},componentWillReceiveProps:function(e){this._doOriginal(e)},_doOriginal:function(e){var t=KAS.unitParse(e.value);this.parsed=!1,t.parsed&&t.type==="unitMagnitude"&&(this.original=t.expr,this.parsed=!0)},onChange:function(e){this.props.onChange({value:e.target.value})},getSaveWarnings:function(){var e=this.props,t=e.value,n=e.accepting,r=e.acceptingUnits,i=[],s=KAS.unitParse(t);return s.parsed||i.push("Answer did not parse"),n===v&&r.length===0&&i.push("There are no accepted units"),i}});e.exports={name:"unit-input",displayName:"Unit",getWidget:function(e){return b},editor:S,transform:function(e){return i(e).del(["value"]).freeze()},version:{major:0,minor:1},countSigfigs:g,sigfigPrint:y,hidden:!0}},function(e,t,n){e.exports={apiVersion:{major:3,minor:0},itemDataVersion:{major:0,minor:1}}},function(e,t,n){var r=n(62),i=n(18),s=function(e){var t=function(n,r){e(n,r);var s=i.upgradeWidgetInfoToLatestVersion(n),u=i.getVersion(s.type);u&&s.version.major===u.major&&i.traverseChildWidgets(n,t,o)};return t},o=function(e,t){r.each(e.widgets,function(e,n){if(e==null||e.type==null)return;t(e,n)})},u=function(e,t){o(e,s(t))};e.exports={traverseRendererDeep:u}},function(e,t,n){var r=n(66),i=r.createClass({displayName:"QuestionParagraph",render:function(){var e=this.props.className?"paragraph "+this.props.className:"paragraph";return r.createElement("div",{className:e},this.props.children)}});e.exports=i},function(e,t,n){var r=n(109),i=n(66),s=i.createClass({displayName:"WidgetContainer",propTypes:{shouldHighlight:i.PropTypes.bool.isRequired,type:i.PropTypes.func,initialProps:i.PropTypes.object.isRequired},getInitialState:function(){return{widgetProps:this.props.initialProps}},render:function(){var e=r({"perseus-widget-container":!0,"widget-highlight":this.props.shouldHighlight,"widget-nohighlight":!this.props.shouldHighlight}),t=this.props.type;if(t==null)return i.createElement("div",{className:e});if(t.displayMode==null)throw new Error("You didn't specify a displayMode in the statics for "+t.displayName+".");return i.createElement("div",{className:e,style:{display:t.displayMode}},i.createElement(t,i.__spread({},this.state.widgetProps,{ref:"widget"})))},componentWillReceiveProps:function(e){if(this.props.type!==e.type)throw new Error("WidgetContainer can't change widget type; set a different key instead to recreate the container.")},shouldComponentUpdate:function(e,t){return this.props.shouldHighlight!==e.shouldHighlight||this.props.type!==e.type||this.state.widgetProps!==t.widgetProps},getWidget:function(){return this.refs.widget},replaceWidgetProps:function(e){this.setState({widgetProps:e})}});e.exports=s},function(e,t,n){var r=n(66);e.exports={propTypes:r.PropTypes.shape({toolTipFormats:r.PropTypes.bool.isRequired,useMathQuill:r.PropTypes.bool.isRequired}).isRequired,defaults:{toolTipFormats:!0,useMathQuill:!1}}},function(e,t,n){var r=React.createClass({displayName:"JsonEditor",getInitialState:function(){return{currentValue:JSON.stringify(this.props.value,null,4),valid:!0}},componentWillReceiveProps:function(e){var t=!this.state.valid||!_.isEqual(e.value,JSON.parse(this.state.currentValue));t&&this.setState(this.getInitialState())},render:function(){var e="perseus-json-editor "+(this.state.valid?"valid":"invalid");return React.createElement("textarea",{className:e,value:this.state.currentValue,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onBlur:this.handleBlur})},handleKeyDown:function(e){if(e.key==="Tab"){var t=e.target.selectionStart,n=e.target.value,r=n.substring(0,t),i=n.substring(t,n.length);e.target.value=r+"    "+i,e.target.selectionStart=r.length+4,e.target.selectionEnd=r.length+4,e.preventDefault(),this.handleChange(e)}},handleChange:function(e){var t=e.target.value;try{var n=JSON.parse(t);_.isString(n)&&(n=JSON.parse(n)),this.setState({currentValue:t,valid:!0},function(){this.props.onChange(n)})}catch(r){this.setState({currentValue:t,valid:!1})}},handleBlur:function(e){var t=e.target.value;try{var n=JSON.parse(t);_.isString(n)&&(n=JSON.parse(n)),this.setState({currentValue:JSON.stringify(n,null,4),valid:!0},function(){this.props.onChange(n)})}catch(r){this.setState({currentValue:JSON.stringify(this.props.value,null,4),valid:!0})}}});e.exports=r},function(e,t,n){var r=n(62),i=n(119),s=n(70),o=n(5),u=i.parseInline,a=function(e){var t=e.length;if(t===0||e[0]!=="$")return null;var n=1,r=0;while(n<t){var i=e[n];if(i==="\\")n++;else{if(r<=0&&i==="$")return[e.substring(0,n+1),e.substring(1,n)];if(i==="{")r++;else if(i==="}")r--;else if(i==="\n"&&e[n-1]==="\n")return null}n++}return null},f=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n("+i.defaultRules.nptable.match.regex.source.substring(1)+")"),l=r.extend({},i.defaultRules,{columns:{order:-1,match:i.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:function(e,t,n){return{col1:t(e[1],n),col2:t(e[2],n)}},output:function(e,t){return React.createElement("div",{className:"perseus-two-columns"},React.createElement("div",{className:"perseus-column"},t(e.col1)),React.createElement("div",{className:"perseus-column"},t(e.col2)))}},titledTable:{order:i.defaultRules.nptable.order-.5,match:i.blockRegex(f),parse:function(e,t,n){var s=u(t,e[1],n),o=r.rest(e,2),a=i.defaultRules.nptable.parse(o,t,n);return{title:s,table:a}},output:function(e,t){var n=e.table?i.defaultRules.table.output(e.table,t):"//invalid table//";return React.createElement("div",{className:"perseus-titled-table"},React.createElement("div",{className:"perseus-table-title"},t(e.title)),React.createElement("div",null,n))}},widget:{order:i.defaultRules.link.order-.75,match:i.inlineRegex(o.rWidgetRule),parse:function(e,t,n){return{id:e[1],widgetType:e[2]}},output:function(e,t){return React.createElement("em",null,"[Widget: ",e.id,"]")}},math:{order:i.defaultRules.link.order-.25,match:a,parse:function(e,t,n){return{content:e[1]}},output:function(e,t){return React.createElement(s,null,e.content)}}}),c=i.parserFor(l),h=function(e){var t=e+"\n\n";return c(t,{inline:!1})},p=function(e,t){r.isArray(e)?r.each(e,function(e){return p(e,t)}):r.isObject(e)&&(t(e),e.type==="table"?(p(e.header,t),p(e.cells,t)):e.type==="list"?p(e.items,t):e.type==="titledTable"?p(e.table,t):e.type==="columns"?(p(e.col1,t),p(e.col2,t)):r.isArray(e.content)&&p(e.content,t))},d=function(e){if(r.isArray(e))return r.flatten(r.map(e,d));if(e.content&&r.isString(e.content))return e.type.toLowerCase().indexOf("code")!==-1?["",e.content,""]:[e.content.replace(/\s+/g," ")];var t=r.chain(e).values().flatten().filter(function(e){return e!=null&&r.has(e,"type")}).value();if(!t.length)return[];var n=d(t);if(e.type==="paragraph"&&n.length){n[0]=n[0].replace(/^\s+/,"");var i=n.length-1;n[i]=n[i].replace(/\s+$/,"")}return n},v=function(e){var t=h(e),n=d(t).join("");return n.length};e.exports={characterCount:v,traverseContent:p,parse:h,outputFor:i.outputFor,ruleOutput:i.ruleOutput(l),testOutput:i.outputFor(i.ruleOutput(l)),sanitizeUrl:i.sanitizeUrl}},function(e,t,n){var r=n(66),i=n(62),s=n(10),o=n(59),u=n(74),a=r.createClass({displayName:"HintEditor",propTypes:{imageUploader:r.PropTypes.func},getDefaultProps:function(){return{content:""}},render:function(){return r.createElement("div",{className:"perseus-hint-editor perseus-editor-left-cell"},r.createElement("div",{className:"pod-title"},"Hint"),r.createElement(s,{ref:"editor",widgets:this.props.widgets,content:this.props.content,images:this.props.images,placeholder:"Type your hint here...",imageUploader:this.props.imageUploader,onChange:this.props.onChange}),r.createElement("div",{className:"hint-controls-container clearfix"},r.createElement("span",{className:"reorder-hints"},r.createElement("button",{type:"button",className:this.props.isLast?"hidden":"",onClick:i.partial(this.props.onMove,1)},r.createElement("span",{className:"icon-circle-arrow-down"}))," ",r.createElement("button",{type:"button",className:this.props.isFirst?"hidden":"",onClick:i.partial(this.props.onMove,-1)},r.createElement("span",{className:"icon-circle-arrow-up"}))," ",this.props.isLast&&r.createElement(u,null,r.createElement("p",null,"The last hint is automatically bolded."))),r.createElement("button",{type:"button",className:"remove-hint simple-button orange",onClick:this.props.onRemove},r.createElement("span",{className:"icon-trash"})," Remove this hint"," ")))},focus:function(){this.refs.editor.focus()},getSaveWarnings:function(){return this.refs.editor.getSaveWarnings()},serialize:function(e){return this.refs.editor.serialize(e)}}),f=r.createClass({displayName:"CombinedHintEditor",propTypes:{imageUploader:r.PropTypes.func},render:function(){var e=this.props.isLast&&!/\*\*/.test(this.props.hint.content);return r.createElement("div",{className:"perseus-combined-hint-editor perseus-editor-row"},r.createElement(a,{ref:"editor",isFirst:this.props.isFirst,isLast:this.props.isLast,widgets:this.props.hint.widgets,content:this.props.hint.content,images:this.props.hint.images,imageUploader:this.props.imageUploader,onChange:this.props.onChange,onRemove:this.props.onRemove,onMove:this.props.onMove}),r.createElement("div",{className:"perseus-editor-right-cell"},r.createElement(o,{hint:this.props.hint,bold:e})))},getSaveWarnings:function(){return this.refs.editor.getSaveWarnings()},serialize:function(e){return this.refs.editor.serialize(e)},focus:function(){this.refs.editor.focus()}}),l=r.createClass({displayName:"CombinedHintsEditor",propTypes:{imageUploader:r.PropTypes.func},getDefaultProps:function(){return{onChange:function(){},hints:[]}},render:function(){var e=this.props.hints,t=i.map(e,function(t,n){return r.createElement(f,{ref:"hintEditor"+n,key:"hintEditor"+n,isFirst:n===0,isLast:n+1===e.length,hint:t,imageUploader:this.props.imageUploader,onChange:this.handleHintChange.bind(this,n),onRemove:this.handleHintRemove.bind(this,n),onMove:this.handleHintMove.bind(this,n)})},this);return r.createElement("div",{className:"perseus-hints-editor perseus-editor-table"},t,r.createElement("div",{className:"perseus-editor-row"},r.createElement("div",{className:"add-hint-container perseus-editor-left-cell"},r.createElement("button",{type:"button",className:"add-hint simple-button orange",onClick:this.addHint},r.createElement("span",{className:"icon-plus"})," ","Add a hint")),r.createElement("div",{className:"perseus-editor-right-cell"})))},handleHintChange:function(e,t,n,r){var s=i(this.props.hints).clone();s[e]=i.extend({},this.serializeHint(e,{keepDeletedWidgets:!0}),t),this.props.onChange({hints:s},n,r)},handleHintRemove:function(e){var t=i(this.props.hints).clone();t.splice(e,1),this.props.onChange({hints:t})},handleHintMove:function(e,t){var n=i(this.props.hints).clone(),r=n.splice(e,1)[0];n.splice(e+t,0,r),this.props.onChange({hints:n},function(){this.refs["hintEditor"+(e+t)].focus()}.bind(this))},addHint:function(){var e=i(this.props.hints).clone().concat([{content:""}]);this.props.onChange({hints:e},function(){var t=e.length-1;this.refs["hintEditor"+t].focus()}.bind(this))},getSaveWarnings:function(){return i.chain(this.props.hints).map(function(e,t){return i.map(this.refs["hintEditor"+t].getSaveWarnings(),function(e){return"Hint "+(t+1)+": "+e})}.bind(this)).flatten(!0).value()},serialize:function(e){return this.props.hints.map(function(t,n){return this.serializeHint(n,e)}.bind(this))},serializeHint:function(e,t){return this.refs["hintEditor"+e].serialize(t)}});e.exports=l},function(e,t,n){var r=n(66),i=n(62),s=n(97),o=n(10),u=n(16).Options,a=n(50).itemDataVersion,f=r.createClass({displayName:"ItemEditor",propTypes:{imageUploader:r.PropTypes.func,wasAnswered:r.PropTypes.bool,gradeMessage:r.PropTypes.string,apiOptions:u.propTypes},getDefaultProps:function(){return{onChange:function(){},question:{},answerArea:{},apiOptions:u.defaults}},updateProps:function(e,t,n){var r=i(this.props).pick("question","answerArea");this.props.onChange(i(r).extend(e),t,n)},render:function(){return r.createElement("div",{className:"perseus-editor-table"},r.createElement("div",{className:"perseus-editor-row perseus-question-container"},r.createElement("div",{className:"perseus-editor-left-cell"},r.createElement("div",{className:"pod-title"},"Question"),r.createElement(o,r.__spread({ref:"questionEditor",placeholder:"Type your question here...",className:"perseus-question-editor",imageUploader:this.props.imageUploader,onChange:this.handleEditorChange,apiOptions:this.props.apiOptions,showWordCount:!0},this.props.question))),r.createElement("div",{className:"perseus-editor-right-cell"},r.createElement("div",{id:"problemarea"},r.createElement("div",{id:"workarea",className:"workarea"}),r.createElement("div",{id:"hintsarea",className:"hintsarea",style:{display:"none"}})))),r.createElement("div",{className:"perseus-editor-row perseus-answer-container"},r.createElement("div",{className:"perseus-editor-left-cell"},r.createElement("div",{className:"pod-title"},"Answer"),r.createElement(s,r.__spread({ref:"answerAreaEditor",onChange:this.handleAnswerAreaChange,apiOptions:this.props.apiOptions},this.props.answerArea))),r.createElement("div",{className:"perseus-editor-right-cell"},r.createElement("div",{id:"answer_area"},r.createElement("div",{id:"solutionarea",className:"solutionarea"}),r.createElement("div",{className:"answer-buttons"},r.createElement("input",{type:"button",className:"simple-button green",onClick:this.props.onCheckAnswer,value:"Check Answer"}),this.props.wasAnswered&&r.createElement("img",{src:"/images/face-smiley.png",className:"smiley"}),this.props.gradeMessage&&r.createElement("span",null,this.props.gradeMessage))))))},handleEditorChange:function(e,t,n){var r=i.extend({},this.props.question,e);this.updateProps({question:r},t,n)},handleAnswerAreaChange:function(e,t,n){var r=i.extend({},this.props.answerArea,e);this.updateProps({answerArea:r},t,n)},getSaveWarnings:function(){var e=this.refs.questionEditor.getSaveWarnings(),t=this.refs.answerAreaEditor.getSaveWarnings();return e.concat(t)},serialize:function(e){return{question:this.refs.questionEditor.serialize(e),answerArea:this.refs.answerAreaEditor.serialize(e),itemDataVersion:a}},focus:function(){this.questionEditor.focus()}});e.exports=f},function(e,t,n){var r=n(66),i=n(14),s=r.createClass({displayName:"HintRenderer",render:function(){var e=this.props.bold,t=this.props.hint,n;return e?n="perseus-hint-renderer last-hint":n="perseus-hint-renderer",r.createElement("div",{className:n},r.createElement(i,{ref:"renderer",widgets:this.props.hint.widgets,content:this.props.hint.content||"",images:this.props.hint.images}))},getSerializedState:function(){return this.refs.renderer.getSerializedState()},restoreSerializedState:function(e,t){this.refs.renderer.restoreSerializedState(e,t)}});e.exports=s},function(e,t,n){var r=n(109),i=n(107),s=n(98),o=n(99),u="before",a="after",f=/http.*?\.png/g,l=function(e){return e.match(f)||[]},c=function(e,t,n){return e.added?t:e.removed?n:""},h=React.createClass({displayName:"ImageDiffSide",propTypes:{side:React.PropTypes.oneOf([u,a]).isRequired,images:React.PropTypes.array.isRequired},render:function(){return React.createElement("div",null,this.props.images.length>0&&React.createElement("div",{className:"diff-header"},"Images"),_.map(this.props.images,function(e){var t=r({image:!0,"image-unchanged":e.status==="unchanged","image-added":e.status==="added","image-removed":e.status==="removed"});return React.createElement("div",null,React.createElement("img",{src:e.value,title:e.value,className:t}))}))}}),p=React.createClass({displayName:"TextDiff",propTypes:{before:React.PropTypes.string,after:React.PropTypes.string,title:React.PropTypes.string},getDefaultProps:function(){return{before:"",after:"",title:""}},getInitialState:function(){return{collapsed:this.props.before===this.props.after}},componentWillReceiveProps:function(e){this.setState({collapsed:e.before===e.after})},render:function(){var e=i.diffWords(this.props.before,this.props.after),t=s(e);beforeImages=l(this.props.before),afterImages=l(this.props.after);var n=o(beforeImages,afterImages),f=_.map(t,function(e){var t={};return t.before=_(e).map(function(e,t){var n=c(e,"not-present","removed dark");return React.createElement("span",{key:t,className:n},e.value)}),t.after=_(e).map(function(e,t){var n=c(e,"added dark","not-present");return React.createElement("span",{key:t,className:n},e.value)}),t}),p=r({"diff-row":!0,collapsed:this.state.collapsed});return React.createElement("div",null,React.createElement("div",{className:"ui-helper-clearfix"},_.map([u,a],function(e){return React.createElement("div",{className:"diff-row "+e},!this.state.collapsed&&_.map(f,function(t){var n=t[e].length>1,i=r({"diff-line":!0,added:e===a&&n,removed:e===u&&n});return React.createElement("div",{className:i},t[e])}),!this.state.collapsed&&React.createElement(h,{side:e,images:n[e]}))}.bind(this))),_.map([u,a],function(e){return React.createElement("div",{className:p+" "+e,onClick:this.handleExpand},this.state.collapsed&&React.createElement("span",null,React.createElement("span",{className:"expand-button"}," ","[ show unmodified ]")))}.bind(this)))},handleExpand:function(){this.setState({collapsed:!1})}});e.exports=p},function(e,t,n){var r=n(109),i=n(100),s=function(e){return(e-1)*20},o="before",u="after",a="unchanged",f=React.createClass({displayName:"DiffSide",propTypes:{side:React.PropTypes.oneOf([o,u]).isRequired,className:React.PropTypes.string.isRequired,showKey:React.PropTypes.bool.isRequired,propKey:React.PropTypes.string.isRequired,value:React.PropTypes.string,depth:React.PropTypes.number.isRequired},render:function(){var e=r(this.props.className,{"diff-row":!0,before:this.props.side===o,after:this.props.side===u});return React.createElement("div",{className:e},React.createElement("div",{style:{paddingLeft:s(this.props.depth)}},this.props.showKey&&this.props.propKey+": ",React.createElement("span",{className:"inner-value dark "+this.props.className},this.props.value)))}}),l=React.createClass({displayName:"CollapsedRow",propTypes:{depth:React.PropTypes.number,onClick:React.PropTypes.func.isRequired},getDefaultProps:function(){return{depth:0}},render:function(){var e=this;return React.createElement("div",{onClick:e.props.onClick},_.map([o,u],function(t){return React.createElement("div",{className:"diff-row collapsed "+t,key:t},React.createElement("div",{style:{paddingLeft:s(e.props.depth)}},React.createElement("span",null," [ show unmodified ] ")))}))}}),c=React.createClass({displayName:"DiffEntry",propTypes:{entry:React.PropTypes.shape({key:React.PropTypes.string,children:React.PropTypes.array,before:React.PropTypes.string,after:React.PropTypes.string}),depth:React.PropTypes.number,expanded:React.PropTypes.bool},getDefaultProps:function(){return{depth:0}},getInitialState:function(){return{expanded:this.props.expanded}},render:function(){var e=this.props.entry,t=e.status==="removed",n=e.status==="added",i=e.status==="changed",s=e.children.length>0,h=r({removed:(t||i)&&!s,dark:t,"blank-space":n}),p=r({added:(n||i)&&!s,dark:n,"blank-space":t}),d;this.state.expanded?d=e.children:d=_(e.children).select(function(e){return e.status!==a});var v=d.length<e.children.length;e.children.length===d.length+1&&(d=e.children,v=!1);var m=this;return React.createElement("div",null,e.key&&React.createElement("div",null,React.createElement(f,{side:o,className:h,depth:this.props.depth,propKey:e.key,showKey:!n,value:e.before}),React.createElement(f,{side:u,className:p,depth:this.props.depth,propKey:e.key,showKey:!t,value:e.after})),_.map(d,function(e){return React.createElement(c,{key:e.key,depth:m.props.depth+1,entry:e,expanded:m.state.expanded})}),v&&React.createElement(l,{depth:this.props.depth+1,onClick:this.expand}))},expand:function(){this.setState({expanded:!0})}}),h=React.createClass({displayName:"WidgetDiff",propTypes:{before:React.PropTypes.shape({options:React.PropTypes.object}).isRequired,after:React.PropTypes.shape({options:React.PropTypes.object}).isRequired,title:React.PropTypes.string.isRequired},render:function(){var e=i(this.props.before,this.props.after);return React.createElement("div",null,React.createElement("div",{className:"ui-helper-clearfix"},React.createElement(c,{entry:e})))}});e.exports=h},function(e,t,n){e.exports=window._},function(e,t,n){function f(e){return u.test(e)}function l(e){var t=window.location.protocol==="http:"?"http:":"https:";return e.replace(u,t)}function c(e){return l(e)+".svg"}function h(e){return l(e)+"-data.json"}function p(e){var t=e.match(a);return t&&t[1]}var r=n(62),i=n(76),s=n(5),o={},u=/^web\+graphie\:/,a=/\/([^/]+)$/,d=React.createClass({displayName:"SvgImage",statics:{getRealImageUrl:function(e){return f(e)?c(e):e}},propTypes:{src:React.PropTypes.string.isRequired,alt:React.PropTypes.string,title:React.PropTypes.string,bottom:React.PropTypes.number,left:React.PropTypes.number,width:React.PropTypes.number,height:React.PropTypes.number,scale:React.PropTypes.number},getDefaultProps:function(){return{src:"",bottom:0,left:0,scale:1}},getInitialState:function(){return{imageLoaded:!1,imageDimensions:null,dataLoaded:!1,labels:[],range:[[0,0],[0,0]]}},isLoadedInState:function(e){return e.imageLoaded&&e.dataLoaded},shouldComponentUpdate:function(e,t){if(!r.isEqual(this.props,e))return!0;if(!f(e.src))return!1;var n=this.isLoadedInState(this.state),i=this.isLoadedInState(t);return n!==i},render:function(){var e={alt:this.props.alt,title:this.props.title},t=this.props.width&&this.props.width*this.props.scale,n=this.props.height&&this.props.height*this.props.scale,s={width:t,height:n,bottom:this.props.bottom,left:this.props.left};if(!f(this.props.src))return React.createElement("img",React.__spread({style:s,src:this.props.src},e));var o=c(this.props.src),u=React.createElement("img",React.__spread({style:{width:s.width,height:s.height},src:o,ref:"image",onLoad:this.onImageLoad},e)),a;if(this.isLoadedInState(this.state)){var l;this.sizeProvided()?l=[t,n]:l=[this.state.imageDimensions[0]*this.props.scale,this.state.imageDimensions[1]*this.props.scale];var h=[40*this.props.scale,40*this.props.scale];a=React.createElement(i,{ref:"graphie",box:l,scale:h,range:this.state.range,options:r.pick(this.state,"labels"),setup:this.setupGraphie})}return React.createElement("div",{className:"svg-image",style:s},u,a)},componentWillReceiveProps:function(e){this.props.src!==e.src&&this.setState({imageLoaded:!1,dataLoaded:!1})},componentDidMount:function(){f(this.props.src)&&this.loadResources()},componentDidUpdate:function(){f(this.props.src)&&!this.isLoadedInState(this.state)&&this.loadResources()},loadResources:function(){var e=p(this.props.src);if(o[e])o[e].loaded?this.onDataLoaded(o[e].data):o[e].dataCallbacks.push(this.onDataLoaded);else{var t={loaded:!1,dataCallbacks:[this.onDataLoaded],data:null};o[e]=t;var n=h(this.props.src);$.ajax({url:n,dataType:"jsonp",jsonp:!1,jsonpCallback:"svgData"+e,success:function(e){t.data=e,t.loaded=!0,r.each(t.dataCallbacks,function(e){e(t.data)})},error:function(e,t,n){console.error("Data load failed:",urls.data,n)}})}},onDataLoaded:function(e){this.setState({dataLoaded:!0,labels:e.labels,range:e.range})},sizeProvided:function(){return this.props.width!=null&&this.props.height!=null},onImageLoad:function(){this.sizeProvided()?this.setState({imageLoaded:!0}):s.getImageSize(this.props.src,function(e,t){this.setState({imageLoaded:!0,imageDimensions:[e,t]})}.bind(this))},setupGraphie:function(e,t){r.map(t.labels,function(t){var n=e.label(t.coordinates,t.content,t.alignment,t.typesetAsMath,{"font-size":100*this.props.scale+"%"});r.each(t.style,function(e,t){n.css(t,e)})}.bind(this))}});e.exports=d},function(e,t,n){var r=n(66),i=n(62),s=r.createClass({displayName:"PropCheckBox",propTypes:{labelAlignment:r.PropTypes.oneOf(["left","right"])},DEFAULT_PROPS:{label:null,onChange:null,labelAlignment:"left"},getDefaultProps:function(){return this.DEFAULT_PROPS},propName:function(){var e=i.find(i.keys(this.props),function(e){return!i.has(this.DEFAULT_PROPS,e)},this);if(!e)throw new Error("Attempted to create a PropCheckBox with no prop!");return e},_labelAlignLeft:function(){return this.props.labelAlignment==="left"},render:function(){var e=this.propName();return r.createElement("label",null,this._labelAlignLeft()&&this.props.label,r.createElement("input",{type:"checkbox",checked:this.props[e],onChange:this.toggle}),!this._labelAlignLeft()&&this.props.label)},toggle:function(){var e=this.propName(),t={};t[e]=!this.props[e],this.props.onChange(t)}});e.exports=s},function(e,t,n){var r=n(75),i=[],s=React.createClass({displayName:"StubTagEditor",propTypes:{value:React.PropTypes.arrayOf(React.PropTypes.string),onChange:React.PropTypes.func.isRequired},getDefaultProps:function(){return{value:i}},render:function(){return React.createElement("div",null,React.createElement("div",{style:{fontSize:14}},"Tags:"),React.createElement(r,{options:this.props.value||i,layout:"vertical",onChange:this.props.onChange}))}});e.exports=s},function(e,t,n){e.exports=window.React},function(e,t,n){e.exports=["key","ref","widgetId","onChange","problemNum","enabledFeatures","apiOptions","questionCompleted","interWidgets","onRemove"]},function(e,t,n){var r=n(62),i=function(e,t){return r.object(r.map(e,function(e,n){return[n,e[t]]}))},s=function(e,t){var n={};return r.each(r.keys(e),function(r){n[r]=t(e[r],r)}),n},o=function(e,t){var n={};return r.each(e,function(e){n[e]=t(e)}),n};e.exports={pluck:i,mapObject:s,mapObjectFromArray:o}},function(e,t,n){var r=n(66),i=n(62),s=r.createClass({displayName:"DragTarget",propTypes:{onDrop:r.PropTypes.func.isRequired,component:r.PropTypes.any,shouldDragHighlight:r.PropTypes.func},render:function(){var e=this.state.dragHover?{opacity:.3}:{},t=this.props.component;return r.createElement(t,r.__spread({},this.props,{style:i.extend({},this.props.style,e),onDrop:this.handleDrop,onDragEnd:this.handleDragEnd,onDragOver:this.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave}))},getInitialState:function(){return{dragHover:!1}},getDefaultProps:function(){return{component:"div",shouldDragHighlight:function(){return!0}}},handleDrop:function(e){e.stopPropagation(),e.preventDefault(),this.setState({dragHover:!1}),this.props.onDrop(e)},handleDragEnd:function(){this.setState({dragHover:!1})},handleDragOver:function(e){e.preventDefault()},handleDragLeave:function(){this.setState({dragHover:!1})},handleDragEnter:function(e){this.setState({dragHover:this.props.shouldDragHighlight(e)})}});e.exports=s},function(e,t,n){function u(e,t){i.push(e),s||(s=!0,o=setTimeout(a,0,t))}function a(e){MathJax.Hub.Queue(function(){var t=MathJax.Hub.elementScripts;MathJax.Hub.elementScripts=function(e){var t=i;return i=[],s=!1,t};try{return MathJax.Hub.Process(null,e)}catch(n){throw n}finally{MathJax.Hub.elementScripts=t}})}var r=n(66),i=[],s=!1,o=null,f=r.createClass({displayName:"TeX",getDefaultProps:function(){return{onRender:function(){},onClick:null}},render:function(){return r.createElement("span",{style:this.props.style,onClick:this.props.onClick},r.createElement("span",{ref:"mathjax"}),r.createElement("span",{ref:"katex"}))},componentDidMount:function(){var e=this.props.children,t=this.props.onRender;try{var n=this.refs.katex.getDOMNode();katex.render(e,n),t();return}catch(r){if(r.__proto__!==katex.ParseError.prototype)throw r}this.setScriptText(e),u(this.script,t)},componentDidUpdate:function(e,t){var n=e.children,r=this.props.children,i=this.props.onRender;if(n!==r){try{var s=this.refs.katex.getDOMNode();katex.render(r,s);if(this.script){var o=MathJax.Hub.getJaxFor(this.script);o&&o.Remove()}i();return}catch(a){if(a.__proto__!==katex.ParseError.prototype)throw a}$(this.refs.katex.getDOMNode()).empty();if(this.script){var f=this;MathJax.Hub.Queue(function(){var e=MathJax.Hub.getJaxFor(f.script);if(e)return e.Text(r,i);f.setScriptText(r),u(f.script,i)})}else this.setScriptText(r),u(this.script,i)}},setScriptText:function(e){this.script||(this.script=document.createElement("script"),this.script.type="math/tex",this.refs.mathjax.getDOMNode().appendChild(this.script)),"text"in this.script?this.script.text=e:this.script.textContent=e},componentWillUnmount:function(){if(this.script){var e=MathJax.Hub.getJaxFor(this.script);e&&e.Remove()}}});e.exports=f},function(e,t,n){var r=n(62),i=n(67),s='Usage:\n  this.change({propName: 5}, callback);\n  this.change("propName", 5, callback);\n  this.change("propName")',o=function(e,t,n){var s=r.omit(e.props,i),o=r.extend(s,t);e.props.onChange(o,n)},u=function(e,t,n,i){if(n===undefined)return r.partial(u,e,t);var s={};s[t]=n,o(e,s,i)},a=function(e,t,n){if(r.isObject(e)&&n===undefined)return n=t,o(this,e,n);if(r.isString(e))return u(this,e,t,n);throw new Error("Invalid types sent to this.change(): "+r.toArray(arguments).join()+"\n"+s)},f={propTypes:{onChange:React.PropTypes.func.isRequired},change:a};e.exports=f},function(e,t,n){var r=n(62),i=n(67),s={serialize:function(){return r.omit(this.props,i)}};e.exports=s},function(e,t,n){var r=n(67),i={getUserInput:function(){return _.omit(this.props,r)}};e.exports=i},function(e,t,n){var r=n(66),i=n(120),s=n(62),o={grayLight:"#aaa",basicBorderColor:"#ccc",white:"#fff"},u={display:"inline-block",marginLeft:"5px",position:"relative"},a={cursor:"pointer"},f={position:"absolute",top:"-12px",left:"22px",zIndex:"1000"},l={borderBottom:"9px solid transparent",borderTop:"9px solid transparent",content:" ",height:"0",position:"absolute",top:"0",width:"0"},c={height:"10px",left:"0",position:"absolute",top:"8px",width:"0",zIndex:"1",":before":s.extend({},l,{borderRight:"9px solid #bbb",right:"0"}),":after":s.extend({},l,{borderRight:"9px solid "+o.white,right:"-1px"})},h={border:"1px solid "+o.basicBorderColor},p=function(e){return{boxShadow:e}},d=i.merge(h,p("0 1px 3px "+o.basicBorderColor),{borderBottom:"1px solid "+o.grayLight}),v=i.merge(d,{background:o.white,padding:"5px 10px",width:"240px"});i.createClass(u),i.createClass(a),i.createClass(c),i.createClass(d),i.createClass(f),i.createClass(v);var m="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo2N2M3NTAxYS04YmVlLTQ0M2MtYmRiNS04OGM2N2IxN2NhYzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUJCRTk4Qjc4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUJCRTk4QjY4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NGE5ZDI0OTMtODk1NC00OGFkLTlhMTgtZDAwM2MwYWNjNDJlIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjY3Yzc1MDFhLThiZWUtNDQzYy1iZGI1LTg4YzY3YjE3Y2FjMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pqm89uYAAADMSURBVHjaXJA9DoJAEIUH1M4TUHIFsCMGen9OwCGw1YRGW2ntKel0exsojHIBC0ouQAyUviFDstmXfNmZeS+zm7XSNCXRFiRgJf0bXIHixpbhGdxBBJYC1w/xaA424MhNEATkui71fU9KqfEU78UbD9PdbJRlOdae55GmhIP+1NV1TcMwkOM41DSNHvRtMhTHMRVFQW3b6mOLgx99kue5GRp/gIOZuZGvNpTNwjD8oliANU+qqqKu6/TQBdymN57AHjzBT+B6Jx79BRgAvc49kQA4yxgAAAAASUVORK5CYII=",g=r.createClass({displayName:"InfoTip",getInitialState:function(){return{hover:!1}},render:function(){return r.createElement("div",{className:u.className},r.createElement("img",{width:10,height:10,src:m,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave}),r.createElement("div",{className:f.className,style:{display:this.state.hover?"block":"none"}},r.createElement("div",{className:c.className}),r.createElement("div",{className:v.className},this.props.children)))},handleMouseEnter:function(){this.setState({hover:!0})},handleMouseLeave:function(){this.setState({hover:!1})}});e.exports=g},function(e,t,n){function s(e){if(!i[e]){var t=$("<span>").text(e).appendTo("body");i[e]=t.width()+5,t.remove()}return i[e]}var r=n(62),i={},o=React.createClass({displayName:"TextListEditor",propTypes:{options:React.PropTypes.array,layout:React.PropTypes.string,onChange:React.PropTypes.func.isRequired},getDefaultProps:function(){return{options:[],layout:"horizontal"}},getInitialState:function(){return{items:this.props.options.concat("")}},componentWillReceiveProps:function(e){this.setState({items:e.options.concat("")})},render:function(){var e=["perseus-text-list-editor","ui-helper-clearfix","layout-"+this.props.layout].join(" "),t=r.map(this.state.items,function(e,t){return React.createElement("li",{key:t},React.createElement("input",{ref:"input_"+t,type:"text",value:e,onChange:this.onChange.bind(this,t),onKeyDown:this.onKeyDown.bind(this,t),style:{width:s(e)}}))},this);return React.createElement("ul",{className:e},t)},onChange:function(e,t){var n=r.clone(this.state.items);n[e]=t.target.value,e===n.length-1&&(n=n.concat("")),this.setState({items:n}),this.props.onChange(r.compact(n))},onKeyDown:function(e,t){var n=t.nativeEvent.keyCode;if(n===8&&this.state.items[e]===""){t.preventDefault();var i=r.clone(this.state.items),s=e===0?0:e-1;e!==i.length-1||e!==0&&i[s]===""?(i.splice(e,1),this.setState({items:i},function(){this.refs["input_"+s].getDOMNode().focus()})):this.refs["input_"+s].getDOMNode().focus()}else if(n===8&&this.state.items[e].length===1&&e===this.state.items.length-2){t.preventDefault();var i=r.clone(this.state.items);i.splice(e,1),this.setState({items:i}),this.props.onChange(r.compact(i))}else if(n===13){t.preventDefault();var i=r.clone(this.state.items),s=e+1;e===i.length-2?this.refs["input_"+s].getDOMNode().focus():(i.splice(s,0,""),this.setState({items:i},function(){this.refs["input_"+s].getDOMNode().focus()}))}}});e.exports=o},function(e,t,n){var r=n(62),i=n(111),s=n(112),o=i.GraphieMovable,u=n(5).deepEq,a=n(5).nestedMap,f=n(93).assert,l=KhanUtil.createGraphie,c=React.createClass({displayName:"Graphie",propTypes:{box:React.PropTypes.arrayOf(React.PropTypes.number).isRequired,range:React.PropTypes.arrayOf(React.PropTypes.arrayOf(React.PropTypes.number)),options:React.PropTypes.object,setup:React.PropTypes.func.isRequired,onClick:React.PropTypes.func,onMouseDown:React.PropTypes.func,onMouseUp:React.PropTypes.func,onMouseMove:React.PropTypes.func},getDefaultProps:function(){return{range:[[-10,10],[-10,10]],options:{}}},render:function(){return React.createElement("div",{className:"graphie-container"},React.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this._setupGraphie(),this._updateMovables()},shouldComponentUpdate:function(e){return!u(this.props,e)},componentDidUpdate:function(e){this.props.setup!==e.setup&&window.console&&window.console.warn&&window.console.warn("<Graphie> was given a new setup function. This is a bad idea; please refactor your code to give the same setup function reference to <Graphie> on every render."),(!u(this.props.options,e.options)||!u(this.props.box,e.box)||!u(this.props.range,e.range))&&this._setupGraphie(),this._updateMovables()},getGraphie:function(){return this._graphie},_range:function(){return r.map(this.props.range,function(e){return e[0]>=e[1]?[-10,10]:e})},_box:function(){return r.map(this.props.box,function(e){return e>0?e:340})},_scale:function(){var e=this._box(),t=this._range();return r.map(e,function(e,n){var r=t[n][1]-t[n][0];return e/r})},_setupGraphie:function(){this._removeMovables();var e=this.refs.graphieDiv.getDOMNode();$(e).empty();var t=this._graphie=l(e);t.init({range:this._range(),scale:this._scale()}),t.addMouseLayer({onClick:this.props.onClick,onMouseDown:this.props.onMouseDown,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove}),t.snap=this.props.options.snapStep||[1,1],this.props.setup(t,r.extend({range:this._range(),scale:this._scale()},this.props.options))},_removeMovables:function(){r.invoke(this._movables,"remove"),this._movables={}},_renderMovables:function(e,t){var n=t.graphie,i=t.oldMovables,s=t.newMovables,u=function(e){r.each(e.movableProps,function(n){e.props[n]=this._renderMovables(e.props[n],t)}.bind(this))}.bind(this),l=!1;return a(e,function(e){if(!e)return t.nextKey++,e;var r=new e.type(e.props);f(r instanceof o,"All children of a Graphie component must be Graphie movables");var a=e.key,c=a==null?"_no_id_"+t.nextKey:a;t.nextKey++;var h=e.ref;u(r);var p=i[c];if(!p)r.add(n),l=!0,s[c]=r;else if(r.constructor===p.constructor){p.props=r.props;var d=p.modify(n);d==="reordered"&&(l=!0),s[c]=p}else a==null&&typeof console!="undefined"&&console.warn&&console.warn("Replacing a <Graphie> child with a child of a different type. Please add keys to your <Graphie> children"),p.remove(),r.add(n),l=!0,s[c]=r;return l&&s[c].toFront(),h&&(this.movables[h]=s[c]),s[c]}.bind(this))},_updateMovables:function(){var e=this._graphie,t=this._movables,n={};this._movables=n,this.movables={},this._renderMovables(this.props.children,{nextKey:1,graphie:e,oldMovables:t,newMovables:n}),r.each(t,function(e,t){n[t]||e.remove()})}});r.extend(c,i),r.extend(c,s),e.exports=c},function(e,t,n){var r=n(109),i=n(66),s=76,o=i.createClass({displayName:"FancyOption",render:function(){throw new Error("FancyOption shouldn't ever be actually rendered")}}),u=i.createClass({displayName:"FancySelect",propTypes:{value:i.PropTypes.any.isRequired,className:i.PropTypes.string,onChange:i.PropTypes.func},getDefaultProps:function(){return{onChange:function(){}}},getInitialState:function(){return{active:!1,closed:!1,selectorNamespace:_.uniqueId("fancy")}},render:function(){var e=i.createElement("span",{style:{display:"inline-block","float":"left",visibility:"hidden",height:0}},i.Children.map(this.props.children,function(e){return i.createElement("div",{className:"fancy-select-value-hidden",style:{height:0}},e.props.children)})),t=0,n;i.Children.forEach(this.props.children,function(e){t++,e.props.value===this.props.value&&(n=e)}.bind(this));var o=r({"fancy-select":!0,active:this.state.active,closed:this.state.closed}),u=i.createElement("div",{className:o,onClick:this._swapActive},e,i.createElement("span",{className:"fancy-select-value",style:{position:"absolute"}},n.props.children)),a=i.Children.map(this.props.children,function(e,t){var n=e.props.visible!=null?e.props.visible:this.state.active;if(!n)return null;var o=r({"fancy-option":!0,active:this.state.active,closed:this.state.closed,selected:e.props.value===this.props.value});e.props.className&&(o+=" "+e.props.className);var u,a;if(this.state.active){var f=s*t;u="translate3d(0, "+f+"px, 0)",a="0.35s ease-in"}else u="translate3d(0, 0, 0)",a="0.35s ease-out";var l=_.extend({},e.props.style,{WebkitTransform:u,transform:u,WebkitTransition:a,transition:a});return i.createElement("li",{className:o,style:l,onClick:function(){this._unbindClickHandler(),this.props.onChange(e.props.value,e),this.setState({active:!1,closed:!0})}.bind(this)},e.props.children)}.bind(this)),f=r({"fancy-select-options":!0,active:this.state.active,closed:this.state.closed}),l=s*t,c={clip:"rect(0, auto, "+l+"px, 0)"};return i.createElement("div",{className:this.props.className},u,i.createElement("div",{className:"fancy-select-options-wrapper"},i.createElement("ul",{className:f,style:c},a)))},_swapActive:function(){var e=!this.state.active,t=!e;e?this._bindClickHandler():this._unbindClickHandler(),this.setState({active:e,closed:t})},_bindClickHandler:function(){$(document).on("vclick."+this.state.selectorNamespace,function(e){var t=$(this.getDOMNode()),n=$(e.target).closest(t);n.length||this._swapActive()}.bind(this))},_unbindClickHandler:function(){$(document).off("."+this.state.selectorNamespace)},componentWillUnmount:function(){this._unbindClickHandler()}});u.Option=o,e.exports=u},function(e,t,n){var r=n(66),i=n(62),s=r.PropTypes,o={cursor:"ns-resize"},u={cursor:"pointer"},a=function(e){return{"-webkit-user-select":e,"-khtml-user-drag":e,"-khtml-user-select":e,"-moz-user-select":e,"-ms-user-select":e,userSelect:e}},f=a("none"),l=r.createClass({displayName:"SortableArea",propTypes:{components:s.arrayOf(s.node).isRequired,onReorder:s.func.isRequired,verify:s.func},render:function(){var e=i(this.state.components).map(function(e,t){return r.createElement(c,{index:t,component:e,area:this,key:e.key,draggable:e.props.draggable,dragging:t===this.state.dragging})}.bind(this));return r.createElement("ol",{className:this.props.className,style:this.props.style},e)},getDefaultProps:function(){return{verify:function(){return!0}}},getInitialState:function(){return{dragging:null,components:this.props.components}},componentWillReceiveProps:function(e){this.setState({components:e.components})},onDragStart:function(e){this.setState({dragging:e})},onDrop:function(){this.setState({dragging:null}),this.props.onReorder(this.state.components)},onDragEnter:function(e){if(this.state.dragging===e)return;var t=this.state.components.slice(),n=t.splice(this.state.dragging,1);t.splice(e,0,n[0]);var r=this.props.verify(t);return r&&this.setState({dragging:e,components:t}),r},componentDidMount:function(){this._setDragEvents()},componentDidUpdate:function(){this._setDragEvents()},_listenEvent:function(e){e.dataTransfer.setData("hackhackhack","because browsers!")},_cancelEvent:function(e){e.preventDefault()},_setDragEvents:function(){this._dragItems=this._dragItems||[];var e=this.getDOMNode().querySelectorAll("[draggable=true]"),t=i(this._dragItems).difference(e),n=i(e).difference(this._dragItems);i(n).each(function(e){e.addEventListener("dragstart",this._listenEvent),e.addEventListener("drop",this._cancelEvent)}.bind(this)),i(t).each(function(e){e.removeEventListener("dragstart",this._listenEvent),e.removeEventListener("drop",this._cancelEvent)}.bind(this))}}),c=r.createClass({displayName:"SortableItem",propTypes:{},render:function(){var e="sortable-disabled";return this.props.dragging?e="sortable-dragging":this.props.draggable&&(e="sortable-enabled"),r.createElement("li",{draggable:this.props.draggable,className:e,onDragStart:this.handleDragStart,onDrop:this.handleDrop,onDragEnter:this.handleDragEnter,onDragOver:this.handleDragOver},this.props.component)},handleDragStart:function(e){e.nativeEvent.dataTransfer.effectAllowed="move",this.props.area.onDragStart(this.props.index)},handleDrop:function(){this.props.area.onDrop(this.props.index)},handleDragEnter:function(e){var t=this.props.area.onDragEnter(this.props.index);e.nativeEvent.dataTransfer.effectAllowed=t?"move":"none"},handleDragOver:function(e){e.preventDefault()}});e.exports=l},function(e,t,n){var r=n(66),i=n(62),s=10,o=r.createClass({displayName:"Triangle",propTypes:{color:r.PropTypes.string.isRequired,left:r.PropTypes.number.isRequired,top:r.PropTypes.number.isRequired,width:r.PropTypes.number.isRequired,height:r.PropTypes.number.isRequired,horizontalDirection:r.PropTypes.oneOf(["left","right"]).isRequired,verticalDirection:r.PropTypes.oneOf(["top","bottom"]).isRequired},render:function(){var e,t,n,i,s=this.props.width+"px solid transparent";this.props.horizontalDirection==="right"?e=s:t=s;var o=this.props.height+"px solid "+this.props.color;return this.props.verticalDirection==="top"?n=o:i=o,r.createElement("div",{style:{display:"block",height:0,width:0,position:"absolute",left:this.props.left,top:this.props.top,borderLeft:e,borderRight:t,borderTop:n,borderBottom:i}})}}),u=r.createClass({displayName:"TooltipArrow",propTypes:{position:r.PropTypes.string,visibility:r.PropTypes.string,left:r.PropTypes.number,top:r.PropTypes.number,color:r.PropTypes.string.isRequired,border:r.PropTypes.string.isRequired,width:r.PropTypes.number.isRequired,height:r.PropTypes.number.isRequired,horizontalDirection:r.PropTypes.oneOf(["left","right"]).isRequired,verticalDirection:r.PropTypes.oneOf(["top","bottom"]).isRequired},getDefaultProps:function(){return{position:"relative",visibility:"visible",left:0,top:0}},render:function(){var e=this.props.horizontalDirection==="right",t=this.props.verticalDirection==="top",n=t?0:1,i=t?0:-1;return r.createElement("div",{style:{display:"block",position:this.props.position,visibility:this.props.visibility,left:this.props.left,top:this.props.top,width:this.props.width+2,height:this.props.height+1,marginTop:-1,marginBottom:-2,zIndex:s}},r.createElement(o,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.border,left:0,top:i,width:this.props.width+2,height:this.props.height+2}),r.createElement(o,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.color,left:1,top:n,width:this.props.width,height:this.props.height}))}}),a={top:{top:"-100%"},bottom:{top:0}},f={left:{targetLeft:0},right:{targetLeft:"100%"}},l={left:{tooltipLeft:0,arrowLeft:function(e){return 0}},right:{tooltipLeft:"-100%",arrowLeft:function(e){return-e-2}}},c=r.createClass({displayName:"Tooltip",propTypes:{show:r.PropTypes.bool.isRequired,className:r.PropTypes.string,arrowSize:r.PropTypes.number,borderColor:r.PropTypes.string,verticalPosition:r.PropTypes.oneOf(i.keys(a)),horizontalPosition:r.PropTypes.oneOf(i.keys(f)),horizontalAlign:r.PropTypes.oneOf(i.keys(l)),children:r.PropTypes.arrayOf(r.PropTypes.element).isRequired},getDefaultProps:function(){return{className:"",arrowSize:10,borderColor:"#ccc",verticalPosition:"bottom",horizontalPosition:"left",horizontalAlign:"left"}},getInitialState:function(){return{height:null}},componentWillReceiveProps:function(){this.setState({height:null})},render:function(){var e=this.props.verticalPosition==="top";return r.createElement("span",null,e&&this._renderToolTipDiv(e),r.createElement("div",null,i.first(this.props.children)),!e&&this._renderToolTipDiv())},_renderToolTipDiv:function(e){var t=i.extend({},f[this.props.horizontalPosition],l[this.props.horizontalAlign],a[this.props.verticalPosition]),n,o;return e?(n=r.createElement(u,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,position:"absolute",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-this.props.arrowSize+2,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:s}),o=r.createElement(u,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,visibility:"hidden",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:s})):(n=r.createElement(u,{verticalDirection:"bottom",horizontalDirection:this.props.horizontalAlign,color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:s}),o=null),r.createElement("div",{style:{position:"relative",height:0,display:this.props.show?"block":"none"}},r.createElement("div",{ref:"tooltipContainer",className:"tooltipContainer",style:{position:"absolute",height:this.state.height||undefined,left:t.targetLeft}},n,r.createElement("div",{className:this.props.className,ref:"tooltipContent",style:{position:"relative",top:t.top,left:t.tooltipLeft,border:"1px solid "+this.props.borderColor,WebkitBoxShadow:"0 1px 3px "+this.props.borderColor,MozBoxShadow:"0 1px 3px "+this.props.borderColor,boxShadow:"0 1px 3px "+this.props.borderColor,zIndex:s-1}},i.rest(this.props.children)),o))},componentDidMount:function(){this._updateHeight()},componentDidUpdate:function(){this._updateHeight()},_updateHeight:function(){var e=this.refs.tooltipContainer.getDOMNode().offsetHeight;e!==this.state.height&&this.setState({height:e})}});e.exports=c},function(e,t,n){var r=n(66),i=n(79),s=n(62),o=n(16).ClassNames,u=n(81),a=n(14),f=n(89),l=n(92),c=n(5).captureScratchpadTouchStart,h="math",p="text",d="tex",v=r.createClass({displayName:"InputWithExamples",propTypes:{type:r.PropTypes.oneOf([h,p,d]),value:r.PropTypes.string,onChange:r.PropTypes.func.isRequired,className:r.PropTypes.string,examples:r.PropTypes.arrayOf(r.PropTypes.string).isRequired,shouldShowExamples:r.PropTypes.bool,convertDotToTimes:r.PropTypes.bool,buttonSet:r.PropTypes.string,buttonsVisible:r.PropTypes.oneOf(["always","never","focused"]),onFocus:r.PropTypes.func,onBlur:r.PropTypes.func},getDefaultProps:function(){return{type:p,shouldShowExamples:!0,onFocus:function(){},onBlur:function(){}}},getInitialState:function(){return{focused:!1,showExamples:!1}},_getInputClassName:function(){if(this.props.type===d)return this.props.className;var e=o.INPUT+" "+o.INTERACTIVE;return this.state.focused&&(e+=" "+o.FOCUSED),this.props.className&&(e+=" "+this.props.className),e},_getPropsForInputType:function(){var e={ref:"input",className:this._getInputClassName(),value:this.props.value,onFocus:this._handleFocus,onBlur:this._handleBlur};if(this.props.type===d)return e;s.extend(e,{buttonSet:this.props.buttonSet,buttonsVisible:this.props.buttonsVisible,onChange:this.props.onChange,onTouchStart:c});if(this.props.type===h)return s.extend({convertDotToTimes:this.props.convertDotToTimes},e);if(this.props.type===p)return s.extend({autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:"false"},e)},_getComponentForInputType:function(){switch(this.props.type){case d:return l;case h:return u;case p:return f;default:return null}},_renderInput:function(){var e=this._getPropsForInputType(),t=this._getComponentForInputType();return r.createElement(t,r.__spread({},e))},render:function(){var e=this._renderInput();if(this.props.type===d)return e;var t=s.map(this.props.examples,function(e){return"- "+e}).join("\n"),n=this.props.shouldShowExamples&&this.state.showExamples;return r.createElement(i,{ref:"tooltip",className:"perseus-formats-tooltip",horizontalPosition:"left",horizontalAlign:"left",verticalPosition:"bottom",arrowSize:10,borderColor:"#ccc",show:n},e,r.createElement(a,{content:t}))},_handleFocus:function(){this.props.onFocus(),this.setState({focused:!0,showExamples:!0})},show:function(){this.setState({showExamples:!0})},hide:function(){this.setState({showExamples:!1})},_handleBlur:function(){this.props.onBlur(),this.setState({focused:!1,showExamples:!1})},focus:function(){this.refs.input.focus()},blur:function(){this.refs.input.blur()},handleChange:function(e){this.props.onChange(e.target.value)}});e.exports=v},function(e,t,n){var r=n(109),i=n(66),s=n(62),o=n(82),u=window.MathQuill,a=i.PropTypes,f=i.createClass({displayName:"MathInput",propTypes:{value:a.string,onChange:a.func.isRequired,convertDotToTimes:a.bool,buttonsVisible:a.oneOf(["always","never","focused"]),buttonSets:o.buttonSetsType.isRequired,onFocus:a.func,onBlur:a.func},render:function(){var e=r({"perseus-math-input":!0,"mq-editable-field":!0,"mq-math-mode":!0});this.props.className&&(e=e+" "+this.props.className);var t=null;return this._shouldShowButtons()&&(t=i.createElement(o,{sets:this.props.buttonSets,className:"math-input-buttons absolute",convertDotToTimes:this.props.convertDotToTimes,onInsert:this.insert})),i.createElement("div",{style:{display:"inline-block"}},i.createElement("div",{style:{display:"inline-block"}},i.createElement("span",{className:e,ref:"mathinput",onFocus:this.handleFocus,onBlur:this.handleBlur})),i.createElement("div",{style:{position:"relative"}},t))},handleFocus:function(){this.setState({focused:!0})},handleMouseDown:function(e){var t=this.getDOMNode().contains(e.target);this.mouseDown=t,t||this.setState({focused:!1})},handleMouseUp:function(){this.mouseDown&&this.focus(),this.mouseDown=!1},handleBlur:function(){this.mouseDown||this.setState({focused:!1})},_shouldShowButtons:function(){return this.props.buttonsVisible==="always"?!0:this.props.buttonsVisible==="never"?!1:this.state.focused},getDefaultProps:function(){return{value:"",convertDotToTimes:!1,buttonsVisible:"focused"}},getInitialState:function(){return{focused:!1}},insert:function(e){var t=this.mathField();s(e).isFunction()?e(t):e[0]==="\\"?t.cmd(e).focus():t.write(e).focus(),t.focus()},mathField:function(e){return u.MathField(this.refs.mathinput.getDOMNode(),e)},componentWillUnmount:function(){window.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)},componentDidMount:function(){window.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp),u.addAutoCommands("pi theta phi sqrt"),u.addCharsThatBreakOutOfSupSub("+-*/=<>≠≤≥"),u.disableCharsWithoutOperand("^_/");var e=!1;this.mathField({spaceBehavesLikeTab:!0,handlers:{edited:function(t){var n=t.latex();n=n.replace(/<>/g,"\\ne");if(this.props.convertDotToTimes){n=n.replace(/\\cdot/g,"\\times");var r=t.controller.cursor[u.L];r&&r.ctrlSeq==="\\cdot "&&(t.controller.backspace(),t.cmd("\\times"))}else n=n.replace(/\\times/g,"\\cdot");e&&this.props.value!==n&&this.props.onChange(n)}.bind(this),enter:function(){$(this.refs.mathinput.getDOMNode()).submit()}.bind(this),upOutOf:function(e){e.typedText("^")}}}),this.mathField().latex(this.props.value),e=!0},componentDidUpdate:function(){s.isEqual(this.mathField().latex(),this.props.value)||this.mathField().latex(this.props.value)},focus:function(){this.mathField().focus(),this.setState({focused:!0})},blur:function(){this.mathField().blur(),this.setState({focused:!1})}});e.exports=f},function(e,t,n){var r=n(66),i=n(62),s=n(70),o={fontSize:"150%"},u={fontSize:"120%"},a={fontSize:"130%"},f=[function(){return[r.createElement("span",{key:"plus",style:u},"+"),"+"]},function(){return[r.createElement("span",{key:"minus",style:o},"-"),"-"]},function(e){return e.convertDotToTimes?[r.createElement(s,{key:"times",style:o},"\\times"),"\\times"]:[r.createElement(s,{key:"times",style:o},"\\cdot"),"\\cdot"]},function(){return[r.createElement(s,{key:"frac",style:o},"\\frac{□}{□}"),function(e){var t=e.latex();e.typedText("/"),e.latex()===t&&e.cmd("\\frac")}]}],l={basic:f,"basic+div":f.concat([function(){return[r.createElement(s,{key:"div"},"\\div"),"\\div"]}]),trig:[function(){return[r.createElement(s,{key:"sin"},"\\sin"),"\\sin"]},function(){return[r.createElement(s,{key:"cos"},"\\cos"),"\\cos"]},function(){return[r.createElement(s,{key:"tan"},"\\tan"),"\\tan"]},function(){return[r.createElement(s,{key:"theta",style:a},"\\theta"),"\\theta"]},function(){return[r.createElement(s,{key:"pi",style:a},"\\phi"),"\\phi"]}],prealgebra:[function(){return[r.createElement(s,{key:"sqrt"},"\\sqrt{x}"),"\\sqrt"]},function(){return[r.createElement(s,{key:"pow",style:u},"□^a"),function(e){var t=e.latex();e.keystroke("Up"),e.latex()===t&&e.typedText("a^b")}]},function(){return[r.createElement(s,{key:"pi",style:u},"\\pi"),"\\pi"]},function(){return[r.createElement(s,{key:"div"},"\\div"),"\\div"]}],logarithms:[function(){return[r.createElement(s,{key:"log"},"\\log"),"\\log"]},function(){return[r.createElement(s,{key:"ln"},"\\ln"),"\\ln"]}],"basic relations":[function(){return[r.createElement(s,{key:"eq"},"="),"="]},function(){return[r.createElement(s,{key:"lt"},"\\lt"),"\\lt"]},function(){return[r.createElement(s,{key:"gt"},"\\gt"),"\\gt"]}],"advanced relations":[function(){return[r.createElement(s,{key:"neq"},"\\neq"),"\\neq"]},function(){return[r.createElement(s,{key:"leq"},"\\leq"),"\\leq"]},function(){return[r.createElement(s,{key:"geq"},"\\geq"),"\\geq"]}]},c=r.PropTypes.arrayOf(r.PropTypes.oneOf(i(l).keys())),h=r.createClass({displayName:"TexButtons",propTypes:{sets:c.isRequired,onInsert:r.PropTypes.func.isRequired},render:function(){var e=i(this.props.sets).map(function(e){return l[e]}),t=i(e).map(function(e){return e.map(function(e){var t=e(this.props);return r.createElement("button",{onClick:function(){return this.props.onInsert(t[1])}.bind(this),className:"tex-button",key:t[0].key,tabIndex:-1,type:"button"},t[0])}.bind(this))}.bind(this)),n=i(t).map(function(e,t){return r.createElement("div",{className:"clearfix tex-button-row",key:this.props.sets[t]},e)}.bind(this));return r.createElement("div",{className:this.props.className},n)},statics:{buttonSets:l,buttonSetsType:c}});e.exports=h},function(e,t,n){var r=n(66),i=n(120),s=n(62),o=n(117),u=o.button.buttonStyle,a=o.button.selectedStyle;i.createClass(u),i.createClass(a);var f=r.createClass({displayName:"ButtonGroup",propTypes:{value:r.PropTypes.any,buttons:r.PropTypes.arrayOf(r.PropTypes.shape({value:r.PropTypes.any.isRequired,content:r.PropTypes.node,title:r.PropTypes.string})).isRequired,onChange:r.PropTypes.func.isRequired,allowEmpty:r.PropTypes.bool},getDefaultProps:function(){return{value:null,allowEmpty:!0}},render:function(){var e=this.props.value,t=s(this.props.buttons).map(function(t,n){var i=t.value===e?a.className:"";return r.createElement("button",{title:t.title,type:"button",id:""+n,ref:"button"+n,key:""+n,className:u.className+" "+i,onClick:this.toggleSelect.bind(this,t.value)},t.content||""+t.value)}.bind(this)),n={display:"inline-block"};return r.createElement("div",{style:n},t)},focus:function(){return this.getDOMNode().focus(),!0},toggleSelect:function(e){var t=this.props.value;this.props.allowEmpty?this.props.onChange(t!==e?e:null):this.props.onChange(e)}});e.exports=f},function(e,t,n){function v(e,t){return Math.floor((e[1]-e[0])/t)}var r=n(66),i=n(62),s=n(71),o=n(83),u=n(74),a=n(91),f=n(64),l=n(88),c=n(70),h=n(5),p=340,d={url:null,width:0,height:0},m=r.createClass({displayName:"GraphSettings",mixins:[s],propTypes:{editableSettings:r.PropTypes.arrayOf(r.PropTypes.oneOf(["canvas","graph","snap","image","measure"])),box:r.PropTypes.arrayOf(r.PropTypes.number),labels:r.PropTypes.arrayOf(r.PropTypes.string),range:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.number)),step:r.PropTypes.arrayOf(r.PropTypes.number),gridStep:r.PropTypes.arrayOf(r.PropTypes.number),snapStep:r.PropTypes.arrayOf(r.PropTypes.number),valid:r.PropTypes.oneOfType([r.PropTypes.bool,r.PropTypes.string]),backgroundImage:r.PropTypes.object,markings:r.PropTypes.oneOf(["graph","grid","none"]),showProtractor:r.PropTypes.bool,showRuler:r.PropTypes.bool,rulerLabel:r.PropTypes.string,rulerTicks:r.PropTypes.number},getInitialState:function(){return{labelsTextbox:this.props.labels,gridStepTextbox:this.props.gridStep,snapStepTextbox:this.props.snapStep,stepTextbox:this.props.step,rangeTextbox:this.props.range,backgroundImage:i.clone(this.props.backgroundImage)}},getDefaultProps:function(){return{editableSettings:["graph","snap","image","measure"],box:[p,p],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[1,1],valid:!0,backgroundImage:d,markings:"graph",showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10}},render:function(){var e=[KhanUtil.roundTo(2,h.scaleFromExtent(this.props.range[0],this.props.box[0])),KhanUtil.roundTo(2,h.scaleFromExtent(this.props.range[1],this.props.box[1]))];return r.createElement("div",null,i.contains(this.props.editableSettings,"canvas")&&r.createElement("div",{className:"graph-settings"},r.createElement("div",{className:"perseus-widget-row"},"Canvas size (x,y pixels)",r.createElement(l,{value:this.props.box,onChange:function(e){this.change({box:e})}.bind(this)})),r.createElement("div",{className:"perseus-widget-row"},"Scale (px per div): ",r.createElement(c,null,"("+e[0]+", "+e[1]+")"))),i.contains(this.props.editableSettings,"graph")&&r.createElement("div",{className:"graph-settings"},r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"}," x Label",r.createElement("input",{type:"text",className:"graph-settings-axis-label",ref:"labels-0",onChange:function(e){return this.changeLabel(0,e)}.bind(this),value:this.state.labelsTextbox[0]})),r.createElement("div",{className:"perseus-widget-right-col"},"y Label",r.createElement("input",{type:"text",className:"graph-settings-axis-label",ref:"labels-1",onChange:function(e){return this.changeLabel(1,e)}.bind(this),value:this.state.labelsTextbox[1]}))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},"x Range",r.createElement(l,{value:this.state.rangeTextbox[0],onChange:function(e){return this.changeRange(0,e)}.bind(this)})),r.createElement("div",{className:"perseus-widget-right-col"},"y Range",r.createElement(l,{value:this.state.rangeTextbox[1],onChange:function(e){return this.changeRange(1,e)}.bind(this)}))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},"Tick Step",r.createElement(l,{value:this.state.stepTextbox,onChange:this.changeStep})),r.createElement("div",{className:"perseus-widget-right-col"},"Grid Step",r.createElement(l,{value:this.state.gridStepTextbox,onChange:this.changeGridStep}))),i.contains(this.props.editableSettings,"snap")&&r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},"Snap Step",r.createElement(l,{value:this.state.snapStepTextbox,onChange:this.changeSnapStep}))),r.createElement("div",{className:"perseus-widget-row"},r.createElement("label",null,"Markings:"," "," "),r.createElement(o,{value:this.props.markings,allowEmpty:!1,buttons:[{value:"graph",content:"Graph"},{value:"grid",content:"Grid"},{value:"none",content:"None"}],onChange:this.change("markings")}))),i.contains(this.props.editableSettings,"image")&&r.createElement("div",{className:"image-settings"},r.createElement("div",null,"Background image:"),r.createElement("div",null,"Url:"," ",r.createElement("input",{type:"text",className:"graph-settings-background-url",ref:"bg-url",defaultValue:this.state.backgroundImage.url,onKeyPress:this.changeBackgroundUrl,onBlur:this.changeBackgroundUrl}),r.createElement(u,null,r.createElement("p",null,'Create an image in graphie, or use the "Add image" function to create a background.')))),i.contains(this.props.editableSettings,"measure")&&r.createElement("div",{className:"misc-settings"},r.createElement("div",{className:"perseus-widget-row"},r.createElement("div",{className:"perseus-widget-left-col"},r.createElement(f,{label:"Show ruler",showRuler:this.props.showRuler,onChange:this.change})),r.createElement("div",{className:"perseus-widget-right-col"},r.createElement(f,{label:"Show protractor",showProtractor:this.props.showProtractor,onChange:this.change}))),this.props.showRuler&&r.createElement("div",null,r.createElement("div",null,r.createElement("label",null," ","Ruler label:"," ",r.createElement("select",{onChange:this.changeRulerLabel,value:this.props.rulerLabel},r.createElement("option",{value:""},"None"),r.createElement("optgroup",{label:"Metric"},this.renderLabelChoices([["milimeters","mm"],["centimeters","cm"],["meters","m"],["kilometers","km"]])),r.createElement("optgroup",{label:"Imperial"},this.renderLabelChoices([["inches","in"],["feet","ft"],["yards","yd"],["miles","mi"]]))))),r.createElement("div",null,r.createElement("label",null," ","Ruler ticks:"," ",r.createElement("select",{onChange:this.changeRulerTicks,value:this.props.rulerTicks},i.map([1,2,4,8,10,16],function(e){return r.createElement("option",{value:e},e)})))))))},renderLabelChoices:function(e){return i.map(e,function(e){return r.createElement("option",{value:e[1]},e[0])})},componentDidMount:function(){this.changeGraph=i.debounce(this.changeGraph,300)},validRange:function(e){var t=i.every(e,function(e){return i.isFinite(e)});return t?e[0]>=e[1]?"Range must have a higher number on the right":!0:"Range must be a valid number"},validateStepValue:function(e){var t=e,n=t.step,r=t.range,s=t.name,o=t.minTicks,u=t.maxTicks;if(!i.isFinite(n))return s+" must be a valid number";var a=v(r,n);return a<o?s+" is too large, there must be at least "+o+" ticks.":a>u?s+" is too small, there can be at most "+u+" ticks.":!0},validSnapStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Snap step",minTicks:5,maxTicks:60})},validGridStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Grid step",minTicks:3,maxTicks:60})},validStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Step",minTicks:3,maxTicks:20})},validBackgroundImageSize:function(e){if(!e.url)return!0;var t=e.width<=450&&e.height<=450;return t?!0:"Image must be smaller than 450px x 450px."},validateGraphSettings:function(e,t,n,r,s){var o=this,u,a=i.every(e,function(e){return u=o.validRange(e),u===!0});if(!a)return u;var f=i.every(t,function(t,n){return u=o.validStep(t,e[n]),u===!0});if(!f)return u;var l=i.every(n,function(t,n){return u=o.validGridStep(t,e[n]),u===!0});if(!l)return u;var c=i.every(r,function(t,n){return u=o.validSnapStep(t,e[n]),u===!0});if(!c)return u;var h=this.validBackgroundImageSize(s);return h!==!0?(u=h,u):!0},changeLabel:function(e,t){var n=t.target.value,r=this.state.labelsTextbox.slice();r[e]=n,this.setState({labelsTextbox:r},this.changeGraph)},changeRange:function(e,t){var n=this.state.rangeTextbox.slice();n[e]=t;var r=this.state.stepTextbox.slice(),i=this.state.gridStepTextbox.slice(),s=this.state.snapStepTextbox.slice(),o=h.scaleFromExtent(n[e],this.props.box[e]);this.validRange(n[e])===!0&&(r[e]=h.tickStepFromExtent(n[e],this.props.box[e]),i[e]=h.gridStepFromTickStep(r[e],o),s[e]=i[e]/2),this.setState({stepTextbox:r,gridStepTextbox:i,snapStepTextbox:s,rangeTextbox:n},this.changeGraph)},changeStep:function(e){this.setState({stepTextbox:e},this.changeGraph)},changeSnapStep:function(e){this.setState({snapStepTextbox:e},this.changeGraph)},changeGridStep:function(e){this.setState({gridStepTextbox:e,snapStepTextbox:i.map(e,function(e){return e/2})},this.changeGraph)},changeGraph:function(){var e=this.state.labelsTextbox,t=i.map(this.state.rangeTextbox,function(e){return i.map(e,Number)}),n=i.map(this.state.stepTextbox,Number),r=this.state.gridStepTextbox,s=this.state.snapStepTextbox,o=this.state.backgroundImage,u=this.validateGraphSettings(t,n,r,s,o);u===!0?this.change({valid:!0,labels:e,range:t,step:n,gridStep:r,snapStep:s,backgroundImage:o}):this.change({valid:u})},changeBackgroundUrl:function(e){if(e.type==="keypress"&&e.key!=="Enter")return;var t=function(e,t,n){var r=i.clone(this.props.backgroundImage);r.url=e,r.width=t,r.height=n,this.setState({backgroundImage:r},this.changeGraph)}.bind(this),n=this.refs["bg-url"].getDOMNode().value;n?h.getImageSize(n,function(e,r){t(n,e,r)}):t(null,0,0)},changeRulerLabel:function(e){this.change({rulerLabel:e.target.value})},changeRulerTicks:function(e){this.change({rulerTicks:+e.target.value})}});e.exports=m},function(e,t,n){var r=n(113),i=n(114),s=n(115),o=n(116),u={MovablePoint:i,addMovablePoint:function(e,t){var n=new r(e,{});return new i(e,n,t)},MovableLine:s,addMovableLine:function(e,t){var n=new r(e,{});return new s(e,n,t)},MovablePolygon:o,addMovablePolygon:function(e,t){var n=new r(e,{});return new o(e,n,t)}};e.exports=u},function(e,t,n){var r=n(66),i=n(120),s=n(62),o=n(117),u=o.button.buttonStyle,a=o.button.selectedStyle;i.createClass(u),i.createClass(a);var f=r.createClass({displayName:"MultiButtonGroup",propTypes:{values:r.PropTypes.arrayOf(r.PropTypes.any),buttons:r.PropTypes.arrayOf(r.PropTypes.shape({value:r.PropTypes.any.isRequired,content:r.PropTypes.node,title:r.PropTypes.string})).isRequired,onChange:r.PropTypes.func.isRequired,allowEmpty:r.PropTypes.bool},getDefaultProps:function(){return{values:[],allowEmpty:!0}},render:function(){var e=this.props.values,t=s(this.props.buttons).map(function(t,n){var i=s.contains(e,t.value)?a.className:"";return r.createElement("button",{title:t.title,type:"button",id:""+n,key:""+n,ref:"button"+n,className:u.className+" "+i,onClick:this.toggleSelect.bind(this,t.value)},t.content||""+t.value)}.bind(this)),n={display:"inline-block"};return r.createElement("div",{style:n},t)},focus:function(){return this.getDOMNode().focus(),!0},toggleSelect:function(e){var t=this.props.values,n=this.props.allowEmpty;s.contains(t,e)&&(t.length>1||n)?this.props.onChange(s.without(t,e)):this.props.onChange(s.union(t,[e]))}});e.exports=f},function(e,t,n){var r=n(66),i=r.createClass({displayName:"BlurInput",propTypes:{value:r.PropTypes.string.isRequired,onChange:r.PropTypes.func.isRequired},getInitialState:function(){return{value:this.props.value}},render:function(){return r.createElement("input",r.__spread({},this.props,{type:"text",value:this.state.value,onChange:this.handleChange,onBlur:this.handleBlur}))},componentWillReceiveProps:function(e){this.setState({value:e.value})},handleChange:function(e){this.setState({value:e.target.value})},handleBlur:function(e){this.props.onChange(e.target.value)}});e.exports=i},function(e,t,n){var r=n(66),i=n(91),s=function(){return!0},o=r.createClass({displayName:"RangeInput",propTypes:{value:r.PropTypes.array.isRequired,onChange:r.PropTypes.func.isRequired,placeholder:r.PropTypes.array,checkValidity:r.PropTypes.func},getDefaultProps:function(){return{placeholder:[null,null]}},render:function(){var e=this.props.value,t=this.props.checkValidity||s;return r.createElement("div",{className:"range-input"},r.createElement(i,r.__spread({},this.props,{value:e[0],checkValidity:function(n){return t([n,e[1]])},onChange:this.onChange.bind(this,0),placeholder:this.props.placeholder[0]})),r.createElement(i,r.__spread({},this.props,{value:e[1],checkValidity:function(n){return t([e[0],n])},onChange:this.onChange.bind(this,1),placeholder:this.props.placeholder[1]})))},onChange:function(e,t){var n=this.props.value;e===0?this.props.onChange([t,n[1]]):this.props.onChange([n[0],t])}});e.exports=o},function(e,t,n){var r=React.createClass({displayName:"TextInput",propTypes:{value:React.PropTypes.string,onChange:React.PropTypes.func.isRequired,className:React.PropTypes.string,onFocus:React.PropTypes.func,onBlur:React.PropTypes.func},getDefaultProps:function(){return{value:""}},render:function(){return React.createElement("input",React.__spread({},this.props,{type:"text",onChange:function(e){return this.props.onChange(e.target.value)}.bind(this)}))},focus:function(){this.getDOMNode().focus()},blur:function(){this.getDOMNode().blur()},getValue:function(){return this.getDOMNode().value},getStringValue:function(){return this.getDOMNode().value.toString()},setSelectionRange:function(e,t){this.getDOMNode().setSelectionRange(e,t)},getSelectionStart:function(){return this.getDOMNode().selectionStart},getSelectionEnd:function(){return this.getDOMNode().selectionEnd}});e.exports=r},function(e,t,n){function r(e,t){var n=0;for(var r=t,i=e.length;r<i;r++){var s=e[r];s==="{"?n++:s==="}"&&n--;if(n<0)return r}return e.length}function i(e,t,n){var i=e.indexOf("{",t),s=i+1,u=r(e,s),a=e.substring(s,u),f=o(a,n);return{endpoint:u,expression:f}}function s(e,t){var n="\\dfrac",r="\\frac",i=e.indexOf(r,t),s=e.indexOf(n,t);return i>-1&&s>-1?Math.min(i,s):i>-1?i:s>-1?s:-1}function o(e,t){var n="",r=0,o=s(e,r);while(o>-1){n+=e.substring(r,o),r=o;var u=i(e,r,t);r=u.endpoint+1;var a=i(e,r,t);r=a.endpoint+1,n.length&&(n+=" "),n+=t(u.expression,a.expression),o=s(e,r)}return n+=e.slice(r),n}function u(e){function t(e){return e.indexOf("\\frac")>-1||e.indexOf("\\dfrac")>-1}var n=function(e,n){var r;return t(e)||t(n)?r="\\dfrac":r="\\frac",r+" {"+e+"}{"+n+"}"};return o(e,n)}function a(e){var t=function(e,t){return e+"/"+t};return o(e,t)}e.exports={parseTex:a,modifyTex:u}},function(e,t,n){var r=n(109),i=n(66),s=n(62),o=n(5).firstNumericalParse,u=n(5).captureScratchpadTouchStart,a=n(108).number,f=KhanUtil.toNumericString,l=KhanUtil.getNumericFormat,c=i.createClass({displayName:"NumberInput",propTypes:{value:i.PropTypes.number,format:i.PropTypes.string,placeholder:i.PropTypes.oneOfType([i.PropTypes.string,i.PropTypes.number]),onChange:i.PropTypes.func.isRequired,onFormatChange:i.PropTypes.func,checkValidity:i.PropTypes.func,size:i.PropTypes.string,label:i.PropTypes.oneOf(["put your labels outside your inputs!"])},getDefaultProps:function(){return{value:null,placeholder:null,format:null,onFormatChange:function(){return null},checkValidity:function(){return!0},useArrowKeys:!1}},getInitialState:function(){return{format:this.props.format}},render:function(){var e=r({"number-input":!0,"invalid-input":!this._checkValidity(this.props.value),mini:this.props.size==="mini",small:this.props.size==="small",normal:this.props.size==="normal"});return this.props.className!=null&&(e=e+" "+this.props.className),i.createElement("input",i.__spread({},this.props,{className:e,type:"text",ref:"input",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,onKeyPress:this._handleBlur,onKeyDown:this._onKeyDown,onTouchStart:u,defaultValue:f(this.props.value,this.state.format),value:undefined}))},componentDidUpdate:function(e){a.equal(this.getValue(),this.props.value)||this._setValue(this.props.value,this.state.format)},getValue:function(){return this.parseInputValue(this.refs.input.getDOMNode().value)},getStringValue:function(){return this.refs.input.getDOMNode().value.toString()},parseInputValue:function(e){if(e==="")return placeholder=this.props.placeholder,s.isFinite(placeholder)?+placeholder:null;var t=o(e);return s.isFinite(t)?t:this.props.value},focus:function(){this.refs.input.getDOMNode().focus(),this._handleFocus()},blur:function(){this.refs.input.getDOMNode().blur(),this._handleBlur()},setSelectionRange:function(e,t){this.getDOMNode().setSelectionRange(e,t)},getSelectionStart:function(){return this.getDOMNode().selectionStart},getSelectionEnd:function(){return this.getDOMNode().selectionEnd},_checkValidity:function(e){if(e==null)return!0;var t=o(e),n=this.props.checkValidity;return s.isFinite(t)&&n(t)},_handleChange:function(e){var t=e.target.value,n=this.parseInputValue(t),r=l(t);this.props.onChange(n),r&&(this.props.onFormatChange(n,r),this.setState({format:r}))},_handleFocus:function(){this.props.onFocus&&this.props.onFocus()},_handleBlur:function(e){if(e&&e.type==="keypress"&&e.keyCode!==13)return;this._setValue(this.props.value,this.state.format),this.props.onBlur&&this.props.onBlur()},_onKeyDown:function(e){this.props.onKeyDown&&this.props.onKeyDown(e);if(!this.props.useArrowKeys||!s.contains(["ArrowUp","ArrowDown"],e.key))return;var t=this.getValue();if(t!==Math.floor(t))return;e.key==="ArrowUp"?t+=1:e.key==="ArrowDown"&&(t-=1),this._checkValidity(t)&&this.props.onChange(t)},_setValue:function(e,t){$(this.refs.input.getDOMNode()).val(f(e,t))}});e.exports=c},function(e,t,n){var r=n(66),i=n(70),s=n(16).ClassNames,o=n(79),u=n(90).modifyTex,a=r.createClass({displayName:"MathOutput",propTypes:{value:r.PropTypes.oneOfType([r.PropTypes.string,r.PropTypes.number]),className:r.PropTypes.string,onFocus:r.PropTypes.func,onBlur:r.PropTypes.func},getDefaultProps:function(){return{value:"",onFocus:function(){},onBlur:function(){}}},getInitialState:function(){return{focused:!1,selectorNamespace:_.uniqueId("math-output")}},_getInputClassName:function(){var e="math-output "+s.INPUT+" "+s.INTERACTIVE;return this.state.focused&&(e+=" "+s.FOCUSED),this.props.className&&(e+=" "+this.props.className),e},_getDisplayValue:function(e){var t;return e!=null?t=""+e:t="",u(t)},render:function(){var e={textAlign:"center"};return r.createElement("span",{ref:"input",className:this._getInputClassName(),onMouseDown:this.focus,onTouchStart:this.focus},r.createElement("div",{style:e},r.createElement(i,null,this._getDisplayValue(this.props.value))))},getValue:function(){return this.props.value},focus:function(){this.state.focused||(this.props.onFocus(),this._bindBlurHandler(),this.setState({focused:!0}))},blur:function(){this.state.focused&&(this.props.onBlur(),this._unbindBlurHandler(),this.setState({focused:!1}))},_bindBlurHandler:function(){$(document).bind("vclick."+this.state.selectorNamespace,function(e){var t=$(e.target).closest(this.getDOMNode());t.length||this.blur()}.bind(this))},_unbindBlurHandler:function(){$(document).unbind("."+this.state.selectorNamespace)},componentWillUnmount:function(){this._unbindBlurHandler()}});e.exports=a},function(e,t,n){function o(){var e=document.createElement("div"),t=["transform","msTransform","MozTransform","WebkitTransform","OTransform"],n=null;return r.each(t,function(t){typeof e.style[t]!="undefined"&&(n=t)}),n}function a(){var e=document.createElement("div"),t=f.getPrefixedTransform();return e.style[t]="translateZ(0px)",!!e.style[t]}var r=n(62),i=n(118),s=null,u=null,f={assert:function(e,t){if(!e)throw new Error("Assertion Error"+(t?": "+t:""))},createGettersFor:function(e,t){r.each(r.keys(t),function(t){e.prototype[t]===undefined&&(e.prototype[t]=function(){return this.state[t]})})},addMovableHelperMethodsTo:function(e){r.each(i,function(t,n){e.prototype[n]===undefined&&(e.prototype[n]=t)})},arrayify:function(e){return e==null?[]:r.isArray(e)?r.filter(r.flatten(e),r.identity):[e]},normalizeOptions:function(e,t){var n=r.clone(t);return r.each(e,function(e){var r=t[e];if(r!==undefined){var i=f.arrayify(r);n[e]=i}}),n},getPrefixedTransform:function(){return s=s||o(),s},getCanUse3dTransform:function(){return u==null&&(u=a()),u}};e.exports=f},function(e,t,n){function c(e,t){return Math.floor((e[1]-e[0])/t)}var r=n(66),i=n(62),s=n(5),o=n(63),u=400,a={url:null},f={fontStyle:"italic",fontWeight:"bold",fontSize:"32px",width:"100%",height:"100%",textAlign:"center",backgroundColor:"white",position:"absolute",zIndex:1,transition:"opacity .25s ease-in-out","-moz-transition":"opacity .25s ease-in-out","-webkit-transition":"opacity .25s ease-in-out"},l={position:"relative",top:"25%"},h=r.createClass({displayName:"Graph",propTypes:{box:r.PropTypes.array.isRequired,labels:r.PropTypes.arrayOf(r.PropTypes.string),range:r.PropTypes.arrayOf(r.PropTypes.arrayOf(r.PropTypes.number)),step:r.PropTypes.arrayOf(r.PropTypes.number),gridStep:r.PropTypes.arrayOf(r.PropTypes.number),snapStep:r.PropTypes.arrayOf(r.PropTypes.number),markings:r.PropTypes.string,backgroundImage:r.PropTypes.shape({url:r.PropTypes.string}),showProtractor:r.PropTypes.bool,showRuler:r.PropTypes.bool,rulerLabel:r.PropTypes.string,rulerTicks:r.PropTypes.number,onGraphieUpdated:r.PropTypes.func,instructions:r.PropTypes.string,onClick:r.PropTypes.func},getDefaultProps:function(){return{box:[u,u],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[.5,.5],markings:"graph",backgroundImage:a,showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,instructions:null,onGraphieUpdated:null,onClick:null,onMouseDown:null}},render:function(){var e,t=this.props.backgroundImage;if(t.url){var n=this.props.box[0]/u;e=r.createElement(o,{src:t.url,width:t.width,height:t.height,scale:n})}else e=null;return r.createElement("div",{className:"graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]},onMouseOut:this.onMouseOut,onMouseOver:this.onMouseOver,onClick:this.onClick},e,r.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this._setupGraphie(!0)},componentDidUpdate:function(){this._hasSetupGraphieThisUpdate=!1,this._shouldSetupGraphie&&(this._setupGraphie(!1),this._shouldSetupGraphie=!1)},componentWillReceiveProps:function(e){var t=["labels","range","step","markings","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep"],n=this;i.each(t,function(t){i.isEqual(n.props[t],e[t])||(n._shouldSetupGraphie=!0)})},reset:function(){this._setupGraphie(!1)},graphie:function(){return this._graphie},pointsFromNormalized:function(e,t){var n=this;return i.map(e,function(e){return i.map(e,function(e,r){var i=n.props.range[r];if(t)return i[0]+(i[1]-i[0])*e;var s=n.props.step[r],o=c(i,s),u=Math.round(e*o);return i[0]+s*u})})},_setupGraphie:function(e){if(this._hasSetupGraphieThisUpdate)return;var t=this.refs.graphieDiv.getDOMNode();$(t).empty();var n=this.props.labels,r=this.props.range,s=this._graphie=KhanUtil.createGraphie(t),o=this._getGridConfig();s.snap=this.props.snapStep,this.props.markings==="graph"?(s.graphInit({range:r,scale:i.pluck(o,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:this.props.gridStep,tickStep:i.pluck(o,"tickStep"),labelStep:1,unityLabels:i.pluck(o,"unityLabel")}),s.label([0,r[1][1]],n[1],"above"),s.label([r[0][1],0],n[0],"right")):this.props.markings==="grid"?s.graphInit({range:r,scale:i.pluck(o,"scale"),gridStep:this.props.gridStep,axes:!1,ticks:!1,labels:!1}):this.props.markings==="none"&&s.init({range:r,scale:i.pluck(o,"scale")});var u=.5,a=0,c;if(this.props.instructions){var c=$("<div/>");i.each(f,function(e,t){c.css(t,e)}),c.css("opacity",u);var h=$("<span/>",{text:this.props.instructions});i.each(l,function(e,t){h.css(t,e)}),c.append(h),$(t).append(c)}else c=undefined;var p=c||this.props.onMouseDown?i.bind(function(e){c&&(c.remove(),c=null),this.props.onMouseDown(e)},this):null,d=c?function(){c&&c.css("opacity",a)}:null,v=c?function(){c&&c.css("opacity",u)}:null;s.addMouseLayer({onClick:this.props.onClick,onMouseDown:p,onMouseOver:d,onMouseOut:v,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,allowScratchpad:!0}),this._updateProtractor(),this._updateRuler(),this._hasSetupGraphieThisUpdate=!0,!e&&this.props.onGraphieUpdated&&this.props.onGraphieUpdated(s)},_getGridConfig:function(){var e=this;return i.map(e.props.step,function(t,n){return s.gridDimensionConfig(t,e.props.range[n],e.props.box[n],e.props.gridStep[n])})},_updateProtractor:function(){this.protractor&&this.protractor.remove();if(this.props.showProtractor){var e=this.pointsFromNormalized([[.5,.05]])[0];this.protractor=this._graphie.protractor(e)}},_updateRuler:function(){this.ruler&&this.ruler.remove();if(this.props.showRuler){var e=this.pointsFromNormalized([[.5,.25]])[0],t=this._graphie.range[0][1]-this._graphie.range[0][0];this.ruler=this._graphie.ruler({center:e,label:this.props.rulerLabel,pixelsPerUnit:this._graphie.scale[0],ticksPerUnit:this.props.rulerTicks,units:Math.round(.8*t)})}},toJSON:function(){return i.pick(this.props,"range","step","markings","labels","backgroundImage","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep")}});e.exports=h},function(e,t,n){var r=n(66),i=n(62),s=n(5),o=n(14),u=n(16).ClassNames,a="perseus-sortable",f=r.createClass({displayName:"Placeholder",propTypes:{width:r.PropTypes.number.isRequired,height:r.PropTypes.number.isRequired},render:function(){var e=[a+"-card",a+"-placeholder"].join(" "),t={width:this.props.width,height:this.props.height};return this.props.margin!=null&&(t.margin=this.props.margin),r.createElement("li",{className:e,style:t})}}),l="static",c="dragging",h="animating",p="disabled",d=r.createClass({displayName:"Draggable",propTypes:{type:r.PropTypes.oneOf([l,c,h,p]),content:r.PropTypes.string.isRequired,endPosition:r.PropTypes.object.isRequired,onRender:r.PropTypes.func.isRequired,onMouseDown:r.PropTypes.func.isRequired,onMouseMove:r.PropTypes.func.isRequired,onMouseUp:r.PropTypes.func.isRequired,onAnimationEnd:r.PropTypes.func.isRequired},getDefaultProps:function(){return{type:l}},getInitialState:function(){return{startPosition:{left:0,top:0},startMouse:{left:0,top:0},mouse:{left:0,top:0}}},componentDidMount:function(){this.isMouseMoveUpBound=!1},componentWillUnmount:function(){this.isMouseMoveUpBound&&this.unbindMouseMoveUp()},getCurrentPosition:function(){return{left:this.state.startPosition.left+this.state.mouse.left-this.state.startMouse.left,top:this.state.startPosition.top+this.state.mouse.top-this.state.startMouse.top}},render:function(){var e=[a+"-card",a+"-draggable",a+"-"+this.props.type,u.INTERACTIVE].join(" "),t={position:"static"};return(this.props.type===c||this.props.type===h)&&i.extend(t,{position:"absolute"},this.getCurrentPosition()),this.props.width&&(t.width=this.props.width+1),this.props.height&&(t.height=this.props.height),this.props.margin!=null&&(t.margin=this.props.margin),r.createElement("li",{className:e,style:t,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,onTouchMove:this.onMouseMove,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},r.createElement(o,{content:this.props.content,onRender:this.props.onRender}))},componentDidUpdate:function(e){if(this.props.type===e.type)return;if(this.props.type===h){var t=this.getCurrentPosition(),n=15*Math.sqrt(Math.sqrt(Math.pow(this.props.endPosition.left-t.left,2)+Math.pow(this.props.endPosition.top-t.top,2)));$(this.getDOMNode()).animate(this.props.endPosition,{duration:Math.max(n,1),complete:this.props.onAnimationEnd})}else this.props.type===l&&$(this.getDOMNode()).finish()},bindMouseMoveUp:function(){this.isMouseMoveUpBound=!0,$(document).on("mousemove",this.onMouseMove),$(document).on("mouseup",this.onMouseUp)},unbindMouseMoveUp:function(){this.isMouseMoveUpBound=!1,$(document).off("mousemove",this.onMouseMove),$(document).off("mouseup",this.onMouseUp)},onMouseDown:function(e){if(this.props.type!==l)return;if(e.button!==0&&(e.touches==null||e.touches.length!==1))return;e.preventDefault();var t=s.extractPointerLocation(e);t&&this.setState({startPosition:$(this.getDOMNode()).position(),startMouse:t,mouse:t},function(){this.bindMouseMoveUp(),this.props.onMouseDown()})},onMouseMove:function(e){if(this.props.type!==c)return;e.preventDefault();var t=s.extractPointerLocation(e);t&&this.setState({mouse:t},this.props.onMouseMove)},onMouseUp:function(e){if(this.props.type!==c)return;e.preventDefault();var t=s.extractPointerLocation(e);t&&(this.unbindMouseMoveUp(),this.props.onMouseUp())}}),v="horizontal",m="vertical",g=r.createClass({displayName:"Sortable",propTypes:{options:r.PropTypes.array.isRequired,layout:r.PropTypes.oneOf([v,m]),padding:r.PropTypes.bool,disabled:r.PropTypes.bool,constraints:r.PropTypes.object,onMeasure:r.PropTypes.func,margin:r.PropTypes.number,onChange:r.PropTypes.func},getDefaultProps:function(){return{layout:v,padding:!0,disabled:!1,constraints:{},onMeasure:function(){},margin:5,onChange:function(){}}},getInitialState:function(){return{items:this.itemsFromProps(this.props)}},componentWillReceiveProps:function(e){var t=this.props;i.isEqual(e.options,t.options)?(e.layout!==t.layout||e.padding!==t.padding||e.disabled!==t.disabled||!i.isEqual(e.constraints,t.constraints))&&this.setState({items:this.clearItemMeasurements(this.state.items)}):this.setState({items:this.itemsFromProps(e)})},componentDidUpdate:function(e){this.state.items.length&&!this.state.items[0].width&&this.measureItems()},itemsFromProps:function(e){var t=e.disabled?p:l;return i.map(e.options,function(e,n){return{option:e,key:n,type:t,endPosition:{},width:0,height:0}})},clearItemMeasurements:function(e){return i.map(e,function(e){return i.extend(e,{width:0,height:0})})},measureItems:function(){var e=i.clone(this.state.items),t=i.map(e,function(e){return $(this.refs[e.key].getDOMNode())},this),n=i.invoke(t,"outerWidth"),r=i.invoke(t,"outerHeight"),s=this.props.constraints,o=this.props.layout,u;s.width?u=i.max(n.concat(s.width)):o===m&&(u=i.max(n));var a;s.height?a=i.max(r.concat(s.height)):o===v&&(a=i.max(r)),e=i.map(e,function(e,t){return e.width=u||n[t],e.height=a||r[t],e}),this.setState({items:e},function(){this.props.onMeasure({widths:n,heights:r})}.bind(this))},remeasureItems:i.debounce(function(){this.setState({items:this.clearItemMeasurements(this.state.items)},this.measureItems)},20),render:function(){var e=[a,"layout-"+this.props.layout].join(" "),t=[];return e+=this.props.padding?"":" unpadded",i.each(this.state.items,function(e,n,i){var s=n===i.length-1,o=e.type===l||e.type===p,u;this.props.layout===v?u="0 "+this.props.margin+"px 0 0":this.props.layout===m&&(u="0 0 "+this.props.margin+"px 0"),t.push(r.createElement(d,{content:e.option,key:e.key,type:e.type,ref:e.key,width:e.width,height:e.height,margin:s&&o?0:u,endPosition:e.endPosition,onRender:this.remeasureItems,onMouseDown:this.onMouseDown.bind(this,e.key),onMouseMove:this.onMouseMove.bind(this,e.key),onMouseUp:this.onMouseUp.bind(this,e.key),onTouchMove:this.onMouseMove.bind(this,e.key),onTouchEnd:this.onMouseUp.bind(this,e.key),onTouchCancel:this.onMouseUp.bind(this,e.key),onAnimationEnd:this.onAnimationEnd.bind(this,e.key)})),(e.type===c||e.type===h)&&t.push(r.createElement(f,{key:"placeholder_"+e.key,ref:"placeholder_"+e.key,width:e.width,height:e.height,margin:s?0:u}))},this),r.createElement("ul",{className:e},t)},onMouseDown:function(e){var t=i.map(this.state.items,function(t){return t.key===e&&(t.type=c),t});this.setState({items:t})},onMouseMove:function(e){var t=$(this.refs[e].getDOMNode()),n=$(this.getDOMNode()),r=i.clone(this.state.items),s=i.findWhere(this.state.items,{key:e}),o=this.props.margin,u=i.indexOf(r,s),a=0;r.splice(u,1);if(this.props.layout===v){var f=t.offset().left-n.offset().left,l=0,c;i.each(r,function(e){c=e.width,f>l+c/2&&(a+=1),l+=c+o})}else{var h=t.offset().top-n.offset().top,p=0,d;i.each(r,function(e){d=e.height,h>p+d/2&&(a+=1),p+=d+o})}a!==u&&(r.splice(a,0,s),this.setState({items:r}))},onMouseUp:function(e){var t=i.map(this.state.items,function(t){return t.key===e&&(t.type=h,t.endPosition=$(this.refs["placeholder_"+e].getDOMNode()).position()),t},this);this.setState({items:t}),this.props.onChange({})},onAnimationEnd:function(e){var t=i.map(this.state.items,function(t){return t.key===e&&(t.type=l),t});this.setState({items:t})},getOptions:function(){return i.pluck(this.state.items,"option")}});e.exports=g},function(e,t,n){function r(e){this.order=a(e),this.mantissa=u(e),this.positive=o(e),this.sigFigs=this.mantissa.length,this.sigDecs=this.order-this.mantissa.length}function i(e,t,n,r){var i=""+e,l=a(i),c=u(i),h=o(i),p,d,v,m=!1;if(e==0||c==""||c=="0"){c="";for(x=0;x<t;x++)c+="0";l=t+n,n<0&&-n>=t&&(m=!0)}else{d=l-c.length-n,v=t-c.length,p=Math.min(v,d);if(p<0){var g=f(c,-p);g.length>c.length+p&&(l++,d>v&&(g=f(g,1))),c=g}else if(p>0)for(x=0;x<p;x++)c+="0";if(c==""||c=="0")c="0",h=!0,l=1+n,l!=0&&(m=!0)}var y=r||c.length>20||l>4||l<-2||l-c.length>0&&s(c)>0||m,b="";h||(b+="-");if(y)b+=c.charAt(0),c.length>1&&(b+="."+c.substring(1,c.length)),l-1!=0&&(b+=" x 10^"+(l-1));else{var w="",E="",S=!0;if(l>0)if(c.length>l)w=c.substring(0,l),E=c.substring(l,c.length);else{w=c,S=s(c)!=0;for(var x=0;x<l-c.length;x++)w+="0"}else{for(x=0;x<-l;x++)E+="0";E+=c}b+=(w==""?"0":w)+(S?".":"")+E}return b}function s(e){var t=0;for(var n=e.length-1;n>=0;n--){var r=e.charAt(n);if(r!="0")return t;t++}return t}function o(e){var t=!0,n=!1,r=!1,i="",s="",o="",u=0,a=0,f=!0;for(var l=0;l<e.length;l++){var c=e.charAt(l);if(c>="1"&&c<="9")o+=i+c,i="",r=!0,n||(a++,u++),t=!1;else if(c=="0")n?r?(o+=i+c,i=""):(s+=c,u--):(a++,r?(s+=c,u++,i+=c):s+=c),t=!1;else if(!n&&c==".")o+=i,i="",n=!0,t=!1;else if(c=="e"||c=="E"&&l+1<e.length){var h=parseInt(e.substring(l+1,e.length));u+=h,a+=h,l=e.length}else t&&(c=="+"||c=="-")&&c=="-"&&(f=!f)}return o==""?!0:f}function u(e){var t=!0,n=!1,r=!1,i="",s="",o="",u=0,a=0,f=!0;for(var l=0;l<e.length;l++){var c=e.charAt(l);if(c>="1"&&c<="9")o+=i+c,i="",r=!0,n||(a++,u++),t=!1;else if(c=="0")n?r?(o+=i+c,i=""):(s+=c,u--):(a++,r?(s+=c,u++,i+=c):s+=c),t=!1;else if(!n&&c==".")o+=i,i="",n=!0,t=!1;else if(c=="e"||c=="E"&&l+1<e.length){var h=parseInt(e.substring(l+1,e.length));u+=h,a+=h,l=e.length}else t&&(c=="+"||c=="-")&&c=="-"&&(f=!f)}return o==""?s:o}function a(e){var t=!0,n=!1,r=!1,i="",s="",o="",u=0,a=0,f=!0;for(var l=0;l<e.length;l++){var c=e.charAt(l);if(c>="1"&&c<="9")o+=i+c,i="",r=!0,n||(a++,u++),t=!1;else if(c=="0")n?r?(o+=i+c,i=""):(s+=c,u--):(a++,r?(s+=c,u++,i+=c):s+=c),t=!1;else if(!n&&c==".")o+=i,i="",n=!0,t=!1;else if(c=="e"||c=="E"&&l+1<e.length){var h=parseInt(e.substring(l+1,e.length));u+=h,a+=h,l=e.length}else t&&(c=="+"||c=="-")&&c=="-"&&(f=!f)}return o==""?a:u}function f(e,t){var n=e.length-t-1;if(n<0)return"";if(n>=e.length-1)return e;var r=e.charAt(n+1),i=e.charAt(n),s=!1;if(r>"5")s=!0;else if(r=="5"){for(var o=n+2;o<e.length;o++)e.charAt(o)!="0"&&(s=!0);i%2==1&&(s=!0)}var u="";for(var a=n;a>=0;a--){var f=e.charAt(a);if(s){var l;if(f=="9")l="0";else{switch(f){case"0":l="1";break;case"1":l="2";break;case"2":l="3";break;case"3":l="4";break;case"4":l="5";break;case"5":l="6";break;case"6":l="7";break;case"7":l="8";break;case"8":l="9"}s=!1}u=l+u}else u=f+u}return s&&(u="1"+u),u}e.exports={SignificantFigures:r,displaySigFigs:i}},function(e,t,n){var r=n(16).Options,i=n(109),s=n(10),o=n(74),u=n(66),a=n(18),f=u.createClass({displayName:"AnswerTypeSelector",render:function(){return u.createElement("div",null,u.createElement("label",null,"Answer type:"," ",u.createElement("select",{value:this.props.type,onChange:function(e){return this.props.onChange(e.target.value)}.bind(this)},u.createElement("option",{value:"radio"},"Multiple choice"),u.createElement("option",{value:"table"},"Table of values"),u.createElement("option",{value:"input-number"},"Text input (number)"),u.createElement("option",{value:"expression"},"Expression / Equation"),u.createElement("option",{value:"multiple"},"Custom format"))),u.createElement(o,null,u.createElement("p",null,"Use the custom format if the question is in the question area, and tell the students how to complete the problem.")))}}),l=u.createClass({displayName:"AnswerAreaEditor",getDefaultProps:function(){return{type:"multiple",options:{},calculator:!1,apiOptions:r.defaults}},getInitialState:function(){return{showEditor:!!this.props.options.content,showTypeSelector:this.props.type!=="multiple"}},render:function(){var e;this.props.type==="multiple"?e=s:e=a.getEditor(this.props.type);var t=i({"perseus-answer-widget":this.props.type!=="multiple","perseus-answer-none":!(this.state.showEditor||this.state.showTypeSelector||this.props.apiOptions.enableOldAnswerTypes)}),n=u.createElement("div",{className:t},u.createElement(e,u.__spread({ref:"editor",placeholder:"This answer area is deprecated. Please use the widgets in the question area for your answer.",apiOptions:this.props.apiOptions,onChange:function(e,t){var n=_.extend({},this.props.options,e);this.props.onChange({options:n},t)}.bind(this)},this.props.options)));return u.createElement("div",{className:"perseus-answer-editor"},u.createElement("div",{className:"perseus-answer-options"},u.createElement("div",null,u.createElement("label",null,"Show calculator:"," ",u.createElement("input",{type:"checkbox",checked:this.props.calculator,onChange:function(e){this.props.onChange({calculator:e.target.checked})}.bind(this)})),u.createElement(o,null,u.createElement("p",null,"Use the calculator when completing difficult calculations is NOT the intent of the question. DON’T use the calculator when testing the student’s ability to complete different types of computations."))),(this.state.showTypeSelector||this.props.apiOptions.enableOldAnswerTypes)&&u.createElement(f,{type:this.props.type,onChange:function(e){this.props.onChange({type:e,options:{}},function(){this.refs.editor.focus()}.bind(this))}.bind(this)})),n)},getSaveWarnings:function(){var e=this.refs.editor.getSaveWarnings,t=e?e():[];return _.map(t,function(e){return"Answer area: "+e})},serialize:function(e){return{type:this.props.type,options:this.refs.editor.serialize(e),calculator:this.props.calculator}}});e.exports=l},function(e,t,n){var r=function(e){var t=[],n=[];return _.each(e,function(e){var r=e.value.split("\n");_.each(r,function(r,i){var s=i>0;s&&(t.push(n),n=[]);var o=_.extend({},e,{value:r});n.push(o)})}),n.length&&t.push(n),t};e.exports=r},function(e,t,n){var r=n(107),i=n(62),s=function(e){return e.added?"added":e.removed?"removed":"unchanged"},o=function(e){return i.map(e.value,function(t){return{value:t,status:s(e)}})},u=function(e,t){return i.flatten(i.map(e,t),!0)},a=new r.Diff;a.tokenize=function(e){return i.map(e,function(e){return[e]})},a.join=function(e,t){return e.concat(t)},a.equals=i.isEqual;var f=function(e){return u(e,o)},l=function(e,t){var n=a.diff(e,t),r=f(n);return{before:i.filter(r,function(e){return e.status!=="added"}),after:i.filter(r,function(e){return e.status!=="removed"})}};e.exports=l},function(e,t,n){var r="unchanged",i="changed",s="added",o="removed",u=function(e,t,n){var u;return e===t?u=r:e===undefined?u=s:t===undefined?u=o:u=i,{after:JSON.stringify(t),before:JSON.stringify(e),children:[],key:n,status:u}},a=function(e,t,n){var u=_.isObject(e)?_(e).keys():[],a=_.isObject(t)?_(t).keys():[],l=_.union(u,a),c=_.map(l,function(n){return f((e||{})[n],(t||{})[n],n)}),h;if(e===undefined)h=s;else if(t===undefined)h=o;else{var p=_.any(c,function(e){return e.status!==r});h=p?i:r}return{after:"",before:"",children:c,key:n,status:h}},f=function(e,t,n){return typeof e=="object"||typeof t=="object"?a(e,t,n):u(e,t,n)};e.exports=f},function(e,t,n){var r=n(83),i=React.createClass({displayName:"ArrowPicker",propTypes:{value:React.PropTypes.string,onChange:React.PropTypes.func.isRequired},getDefaultProps:function(){return{value:""}},render:function(){return React.createElement(r,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:React.createElement("span",null,"—")},{value:"->",content:React.createElement("span",null,"→")}],onChange:this.props.onChange})}});e.exports=i},function(e,t,n){var r=n(83),i=React.createClass({displayName:"ColorPicker",COLORS:[KhanUtil.BLACK,KhanUtil.BLUE,KhanUtil.GREEN,KhanUtil.PINK,KhanUtil.PURPLE,KhanUtil.RED,KhanUtil.GRAY],LIGHT_COLORS:[KhanUtil.LIGHT_BLUE,KhanUtil.LIGHT_ORANGE,KhanUtil.LIGHT_PINK,KhanUtil.LIGHT_GREEN,KhanUtil.LIGHT_PURPLE,KhanUtil.LIGHT_RED,"#fff"],propTypes:{value:React.PropTypes.string,lightColors:React.PropTypes.bool,onChange:React.PropTypes.func.isRequired},getDefaultProps:function(){return{value:KhanUtil.BLACK,lightColors:!1}},render:function(){return React.createElement(r,{value:this.props.value,allowEmpty:!1,buttons:_.map(this.props.lightColors?this.LIGHT_COLORS:this.COLORS,function(e){return{value:e,content:React.createElement("span",null,React.createElement("span",{className:"colorpicker-circle",style:{background:e}})," ")}}),onChange:this.props.onChange})}});e.exports=i},function(e,t,n){var r=n(83),i=n(71),s=n(81),o=n(91),u=n(70),a=React.createClass({displayName:"ConstraintEditor",mixins:[i],propTypes:{constraint:React.PropTypes.string,snap:React.PropTypes.number,constraintFn:React.PropTypes.string,onChange:React.PropTypes.func.isRequired,constraintXMin:React.PropTypes.string,constraintXMax:React.PropTypes.string,constraintYMin:React.PropTypes.string,constraintYMax:React.PropTypes.string},getDefaultProps:function(){return{constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"}},render:function(){return React.createElement("div",null,React.createElement("div",{className:"perseus-widget-row"},"Constraint: ",React.createElement(r,{value:this.props.constraint,allowEmpty:!1,buttons:[{value:"none",content:"None"},{value:"snap",content:"Snap"},{value:"x",content:"x="},{value:"y",content:"y="}],onChange:this.change("constraint")})),this.props.constraint==="snap"&&React.createElement("div",{className:"perseus-widget-row"},"Snap: ",React.createElement(o,{value:this.props.snap,placeholder:0,onChange:this.change("snap")})),this.props.constraint==="x"&&React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,null,"x=")," ",React.createElement(s,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintFn,onChange:this.change("constraintFn")}))),this.props.constraint==="y"&&React.createElement("div",{className:"graph-settings"},React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,null,"y=")," ",React.createElement(s,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintFn,onChange:this.change("constraintFn")}))),"Ensure these are set so nothing can be dragged off the canvas:",React.createElement("div",{className:"perseus-widget-row"},React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,null,"x \\in \\Large[")," ",React.createElement(s,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintXMin,onChange:this.change("constraintXMin")}),React.createElement(u,null,", ")," ",React.createElement(s,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintXMax,onChange:this.change("constraintXMax")})," ",React.createElement(u,null,"\\Large]"))),React.createElement("div",{className:"perseus-widget-row"},React.createElement("div",{className:"perseus-widget-row"},React.createElement(u,null,"y \\in \\Large[")," ",React.createElement(s,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintYMin,onChange:this.change("constraintYMin")}),React.createElement(u,null,", ")," ",React.createElement(s,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintYMax,onChange:this.change("constraintYMax")})," ",React.createElement(u,null,"\\Large]"))))}});e.exports=a},function(e,t,n){var r=n(83),i=React.createClass({displayName:"DashPicker",propTypes:{value:React.PropTypes.string,onChange:React.PropTypes.func.isRequired},getDefaultProps:function(){return{value:""}},render:function(){return React.createElement(r,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:React.createElement("span",null,"—")},{value:"-",content:React.createElement("span",null,"–––")},{value:"- ",content:React.createElement("span",null,"–  –")},{value:".",content:React.createElement("span",null,"····")},{value:". ",content:React.createElement("span",null,"· · ·")}],onChange:this.props.onChange})}});e.exports=i},function(e,t,n){var r=React.createClass({displayName:"ElementContainer",propTypes:{initiallVisible:React.PropTypes.bool,title:React.PropTypes.node},getDefaultProps:function(){return{initiallyVisible:!1,title:"More"}},getInitialState:function(){return{show:this.props.initiallyVisible,title:"More",onUp:null,onDown:null,onDelete:null}},render:function(){return React.createElement("div",{className:"perseus-interaction-element"},React.createElement("a",{href:"#",className:"perseus-interaction-element-title "+(this.state.show?"open":"closed"),onClick:this.toggle},React.createElement("i",{className:"icon-chevron-"+(this.state.show?"down":"right")}),this.props.title),React.createElement("div",{className:"perseus-interaction-element-content "+(this.state.show?"enter":"leave")},this.props.children,(this.props.onUp!=null||this.props.onDown!=null||this.props.onDelete!=null)&&React.createElement("div",{className:"edit-controls"},this.props.onUp!=null&&React.createElement("button",{onClick:this.props.onUp},React.createElement("i",{className:"icon-circle-arrow-up"})),this.props.onDown!=null&&React.createElement("button",{onClick:this.props.onDown},React.createElement("i",{className:"icon-circle-arrow-down"})),this.props.onDelete!=null&&React.createElement("button",{onClick:this.props.onDelete},React.createElement("i",{className:"icon-trash"})))))},toggle:function(e){e.preventDefault(),this.setState({show:!this.state.show})}});e.exports=r},function(e,t,n){var r=n(119),i="start-ref-",s="end-ref-",o={display:"inline-block",width:0,visibility:"hidden"},u={display:"inline",whiteSpace:"nowrap"},a={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",paddingLeft:10,paddingRight:10,userSelect:"none",WebkitUserSelect:"none"},f={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",userSelect:"none",WebkitUserSelect:"none",width:22,height:22,borderRadius:"50%",textAlign:"center"},l={newline:r.defaultRules.newline,paragraph:r.defaultRules.paragraph,escape:r.defaultRules.escape,passageFootnote:{order:r.defaultRules.escape.order+.1,regex:/^\^/,parse:function(e,t,n){var r=n.lastFootnote.id+1,i={id:r,text:r===1?"*":""+r};return n.lastFootnote.text==="*"&&(n.lastFootnote.text=""+n.lastFootnote.id),n.lastFootnote=i,i},output:function(e,t){return React.createElement("sup",null,e.text)}},refStart:{order:r.defaultRules.escape.order+.2,regex:/^\{\{/,parse:function(e,t,n){var r=n.lastRef+1;return n.lastRef=r,n.currentRef.push(r),{ref:r}},output:function(e,t){return React.createElement("span",{ref:i+e.ref,style:o},"_")}},refEnd:{order:r.defaultRules.escape.order+.3,regex:/^\}\}/,parse:function(e,t,n){var r=n.currentRef.pop()||null;return{ref:r}},output:function(e,t){return e.ref!=null?React.createElement("span",{ref:s+e.ref,style:o},"_"):React.createElement("span",{style:o},"_")}},squareLabel:{order:r.defaultRules.escape.order+.4,regex:/^\[\[(\w+)\]\]( *)/,parse:function(e,t,n){return{content:t(e[1],n),space:e[2].length>0}},output:function(e,t){return[React.createElement("span",{style:u},React.createElement("span",{style:a},t(e.content))),e.space?" ":null]}},circleLabel:{order:r.defaultRules.escape.order+.5,regex:/^\(\((\w+)\)\)( *)/,parse:function(e,t,n){return{content:t(e[1],n),space:e[2].length>0}},output:function(e,t){return[React.createElement("span",{style:u},React.createElement("span",{style:f},t(e.content))),e.space?" ":null]}},strong:r.defaultRules.strong,u:r.defaultRules.u,em:r.defaultRules.em,del:r.defaultRules.del,text:r.defaultRules.text},c=r.parserFor(l),h=function(e){var t=e+"\n\n";return c(t,{currentRef:[],lastRef:0,lastFootnote:{id:0,text:""}})};e.exports={parse:h,output:r.outputFor(r.ruleOutput(l)),START_REF_PREFIX:i,END_REF_PREFIX:s,_rulesForTesting:l}},function(e,t,n){var r=function(){function e(e){return{newPos:e.newPos,components:e.components.slice(0)}}function t(e){var t=[];for(var n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}function n(e){var t=e;return t=t.replace(/&/g,"&amp;"),t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(/"/g,"&quot;"),t}var r=function(e){this.ignoreWhitespace=e};r.prototype={diff:function(t,n){if(n===t)return[{value:n}];if(!n)return[{value:t,removed:!0}];if(!t)return[{value:n,added:!0}];n=this.tokenize(n),t=this.tokenize(t);var r=n.length,i=t.length,s=r+i,o=[{newPos:-1,components:[]}],u=this.extractCommon(o[0],n,t,0);if(o[0].newPos+1>=r&&u+1>=i)return o[0].components;for(var a=1;a<=s;a++)for(var f=-1*a;f<=a;f+=2){var l,c=o[f-1],h=o[f+1];u=(h?h.newPos:0)-f,c&&(o[f-1]=undefined);var p=c&&c.newPos+1<r,d=h&&0<=u&&u<i;if(!p&&!d){o[f]=undefined;continue}!p||d&&c.newPos<h.newPos?(l=e(h),this.pushComponent(l.components,t[u],undefined,!0)):(l=e(c),l.newPos++,this.pushComponent(l.components,n[l.newPos],!0,undefined));var u=this.extractCommon(l,n,t,f);if(l.newPos+1>=r&&u+1>=i)return l.components;o[f]=l}},pushComponent:function(e,t,n,r){var i=e[e.length-1];i&&i.added===n&&i.removed===r?e[e.length-1]={value:this.join(i.value,t),added:n,removed:r}:e.push({value:t,added:n,removed:r})},extractCommon:function(e,t,n,r){var i=t.length,s=n.length,o=e.newPos,u=o-r;while(o+1<i&&u+1<s&&this.equals(t[o+1],n[u+1]))o++,u++,this.pushComponent(e.components,t[o],undefined,undefined);return e.newPos=o,u},equals:function(e,t){var n=/\S/;return this.ignoreWhitespace&&!n.test(e)&&!n.test(t)?!0:e===t},join:function(e,t){return e+t},tokenize:function(e){return e}};var i=new r,s=new r(!0),o=new r;s.tokenize=o.tokenize=function(e){return t(e.split(/(\s+|\b)/))};var u=new r(!0);u.tokenize=function(e){return t(e.split(/([{}:;,]|\s+)/))};var a=new r;return a.tokenize=function(e){var t=[],n=e.split(/^/m);for(var r=0;r<n.length;r++){var i=n[r],s=n[r-1];i=="\n"&&s&&s[s.length-1]==="\r"?t[t.length-1]+="\n":i&&t.push(i)}return t},{Diff:r,diffChars:function(e,t){return i.diff(e,t)},diffWords:function(e,t){return s.diff(e,t)},diffWordsWithSpace:function(e,t){return o.diff(e,t)},diffLines:function(e,t){return a.diff(e,t)},diffCss:function(e,t){return u.diff(e,t)},createPatch:function(e,t,n,r,i){function u(e){return e.map(function(e){return" "+e})}function f(e,t,n){var r=o[o.length-2],i=t===o.length-2,s=t===o.length-3&&(n.added!==r.added||n.removed!==r.removed);!/\n$/.test(n.value)&&(i||s)&&e.push("\\ No newline at end of file")}var s=[];s.push("Index: "+e),s.push("==================================================================="),s.push("--- "+e+(typeof r=="undefined"?"":"	"+r)),s.push("+++ "+e+(typeof i=="undefined"?"":"	"+i));var o=a.diff(t,n);o[o.length-1].value||o.pop(),o.push({value:"",lines:[]});var l=0,c=0,h=[],p=1,d=1;for(var v=0;v<o.length;v++){var m=o[v],g=m.lines||m.value.replace(/\n$/,"").split("\n");m.lines=g;if(m.added||m.removed){if(!l){var y=o[v-1];l=p,c=d,y&&(h=u(y.lines.slice(-4)),l-=h.length,c-=h.length)}h.push.apply(h,g.map(function(e){return(m.added?"+":"-")+e})),f(h,v,m),m.added?d+=g.length:p+=g.length}else{if(l)if(g.length<=8&&v<o.length-2)h.push.apply(h,u(g));else{var b=Math.min(g.length,4);s.push("@@ -"+l+","+(p-l+b)+" +"+c+","+(d-c+b)+" @@"),s.push.apply(s,h),s.push.apply(s,u(g.slice(0,b))),g.length<=4&&f(s,v,m),l=0,c=0,h=[]}p+=g.length,d+=g.length}}return s.join("\n")+"\n"},applyPatch:function(e,t){var n=t.split("\n"),r=[],i=!1,s=!1;for(var o=n[0][0]==="I"?4:0;o<n.length;o++)if(n[o][0]==="@"){var u=n[o].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);r.unshift({start:u[3],oldlength:u[2],oldlines:[],newlength:u[4],newlines:[]})}else n[o][0]==="+"?r[0].newlines.push(n[o].substr(1)):n[o][0]==="-"?r[0].oldlines.push(n[o].substr(1)):n[o][0]===" "?(r[0].newlines.push(n[o].substr(1)),r[0].oldlines.push(n[o].substr(1))):n[o][0]==="\\"&&(n[o-1][0]==="+"?i=!0:n[o-1][0]==="-"&&(s=!0));var a=e.split("\n");for(var o=r.length-1;o>=0;o--){var f=r[o];for(var l=0;l<f.oldlength;l++)if(a[f.start-1+l]!==f.oldlines[l])return!1;Array.prototype.splice.apply(a,[f.start-1,+f.oldlength].concat(f.newlines))}if(i)while(!a[a.length-1])a.pop();else s&&a.push("");return a.join("\n")},convertChangesToXML:function(e){var t=[];for(var r=0;r<e.length;r++){var i=e[r];i.added?t.push("<ins>"):i.removed&&t.push("<del>"),t.push(n(i.value)),i.added?t.push("</ins>"):i.removed&&t.push("</del>")}return t.join("")},convertChangesToDMP:function(e){var t=[],n;for(var r=0;r<e.length;r++)n=e[r],t.push([n.added?1:n.removed?-1:0,n.value]);return t}}}();e.exports=r},function(e,t,n){e.exports={number:n(121),vector:n(122),point:n(123),line:n(124),ray:n(125)}},function(e,t,n){function r(){var e=arguments,t=[];for(var n=0;n<e.length;n++){var r=e[n];if(!r)continue;if("string"==typeof r||"number"==typeof r)t.push(r);else if("object"==typeof r)for(var i in r){if(!r.hasOwnProperty(i)||!r[i])continue;t.push(i)}}return t.join(" ")}typeof e!="undefined"&&e.exports&&(e.exports=r)},function(e,t,n){var r=n(126),i=r.clone,s=r.isObject,o=r.merge,u=n(127),a=n(128),f=n(129),l=function(e){if(Array.isArray(e))return u;if(s(e))return a;if(typeof e=="string")return f},c=function(e){if(e instanceof c)return e;if(!(this instanceof c))return new c(e);var t=l(e);this._wrapped=t.thaw?t.thaw(e):e};c.prototype.freeze=function(){var e=this._wrapped,t=l(e);return t.freeze?t.freeze(e):e},c.prototype.zoom=function(e){return this._zoomStack===undefined&&(this._zoomStack=[]),this._zoomStack.push({zoom:e,wrapped:this._wrapped}),this._wrapped=c(this._wrapped).get(e),this},c.prototype.deZoom=function(){var e=this._zoomStack.pop();return this._wrapped=c(e.wrapped).set(e.zoom,this._wrapped).freeze(),this},c.prototype.get=function(e){var t=this._wrapped;for(var n=0;n<e.length;n++)t=l(t).get(t,e[n]);return t},c.prototype.mod=function(e,t){var n=this._wrapped,r=i(n),s=l(n);if(e.length===0)this._wrapped=t(this._wrapped);else if(e.length===1)this._wrapped=s.mod(r,e[0],t);else{var o=e[0],u=e.slice(1);r[o]=c(n[o]).mod(u,t).freeze(),this._wrapped=r}return this},c.prototype.merge=function(e,t){return this._wrapped=c(this._wrapped).mod(e,function(e){return o(e,t)}).freeze(),this},c.prototype.del=function(e){var t=this._wrapped,n=l(t);if(e.length===1)this._wrapped=n.del(t,e[0]);else{var r=e[0],i=e.slice(1),s=n.get(t,r);this._wrapped=n.set(t,r,n.del(s,i))}return this},c.prototype.set=function(e,t){return this.mod(e,function(){return t})},e.exports=c},function(e,t,n){function u(e){o.extend(this,e)}var r=n(5),i=r.nestedMap,s=r.deepEq,o=n(62),a=function(){throw new Error("Abstract method! Must be implemented by Graphie Movable"+this.constructor.displayName)};o.extend(u.prototype,{movableProps:[],add:a,modify:a,remove:a,toFront:function(){}});var f=function(e,t){return o.extend({},e,{children:o.filter(o.flatten(t),o.identity)})},l=function(e){var t=function(e){if(this instanceof t)return this.props=f(e,e.children||[]),this;throw new Error("Use createElement or JSX with graphie movables")};return e.displayName=e.displayName||o.uniqueId("GraphieClass"),t.displayName=e.displayName,t.prototype=new u(e),t.prototype.constructor=t,t},c=function(e){return l({displayName:e.name||o.uniqueId("GraphieSimpleClass"),movableProps:["children"],add:function(t){this._elements=e(t,this.props),this._prevProps=this.props},modify:function(e){if(!s(this.props,this._prevProps))return this.remove(),this.add(e),this._prevProps=this.props,"reordered"},remove:function(){i(this._elements,function(e){e&&e.remove()}),this._elements=null,this._prevProps=null},toFront:function(){i(this._elements,function(e){o.isFunction(e.toFront)&&e.toFront()})}})};e.exports={GraphieMovable:u,createClass:l,createSimpleClass:c}},function(e,t,n){var r=n(62),i=n(111),s=n(85),o=n(93),u=o.assert,a=i.createClass({displayName:"MovablePoint",movableProps:["children"],add:function(e){this.point=s.addMovablePoint(e,this.props)},modify:function(){this.point.modify(this.props)},remove:function(){this.point.remove()},toFront:function(){this.point.toFront()},grab:function(e){this.point.grab(e)}});r.extend(a,s.MovablePoint);var f=i.createClass({displayName:"MovableLine",movableProps:["children"],add:function(e){var t=r.pluck(this.props.children,"point"),n=r.extend({},this.props,{points:t});this.line=s.addMovableLine(e,n)},modify:function(){var e=r.pluck(this.props.children,"point"),t=r.extend({},this.props,{points:e});this.line.modify(t)},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}});r.extend(f,s.MovableLine);var l=i.createSimpleClass(function(e,t){var n=t.coord;return t.unscaled&&(n=e.unscalePoint(n)),e.label(n,t.text,t.direction,t.tex,t.style)}),c=i.createClass({displayName:"Line",movableProps:["children"],add:function(e){var t=this.props;this.graphie=e,this.line=this.graphie.line(t.start,t.end,t.style)},modify:function(){var e=this.props,t=this.graphie.svgPath([e.start,e.end]);this.line.attr(r.extend({},e.style,{path:t}))},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}}),h=i.createClass({displayName:"Parabola",movableProps:["children"],add:function(e){var t=this.props;this.graphie=e,this.parabola=this.graphie.parabola(t.a,t.b,t.c,t.style)},modify:function(){var e=this.props,t=this.graphie.svgParabolaPath(e.a,e.b,e.c);this.parabola.attr(r.extend({},e.style,{path:t}))},remove:function(){this.parabola.remove()},toFront:function(){this.parabola.toFront()}}),p=i.createClass({displayName:"Sinusoid",movableProps:["children"],add:function(e){var t=this.props;this.graphie=e,this.sinusoid=this.graphie.sinusoid(t.a,t.b,t.c,t.d,t.style)},modify:function(){var e=this.props,t=this.graphie.svgSinusoidPath(e.a,e.b,e.c,e.d);this.sinusoid.attr(r.extend({},e.style,{path:t}))},remove:function(){this.sinusoid.remove()},toFront:function(){this.sinusoid.toFront()}}),d=i.createSimpleClass(function(e,t){return e.plot(t.fn,t.range,t.style)}),v=i.createSimpleClass(function(e,t){return e.plotParametric(t.fn,t.range,t.style)}),m=i.createSimpleClass(function(e,t){return e.ellipse(t.coord,e.unscaleVector([4,4]),{fill:t.color||KhanUtil.BLACK,stroke:t.color||KhanUtil.BLACK})}),g=i.createClass({displayName:"Path",movableProps:["children"],add:function(e){var t=this.props;this.graphie=e,this.path=this.graphie.path(t.coords,t.style)},modify:function(){var e=this.props,t=this.graphie.svgPath(e.coords);this.path.attr({path:t})},remove:function(){this.path.remove()},toFront:function(){this.path.toFront()}}),y=i.createSimpleClass(function(e,t){var n=t.center,r=t.radius;return t.unscaled&&(n=e.unscalePoint(n),r=e.unscaleVector(r)),e.arc(n,r,t.startAngle,t.endAngle,t.sector,t.style)}),b=i.createSimpleClass(function(e,t){return e.circle(t.center,t.radius,t.style)}),w=i.createSimpleClass(function(e,t){return e.rect(t.x,t.y,t.width,t.height,t.style)});e.exports={Arc:y,Circle:b,Label:l,Line:c,MovableLine:f,MovablePoint:a,Parabola:h,Path:g,Plot:d,PlotParametric:v,Point:m,Sinusoid:p,Rect:w}},function(e,t,n){var r=n(62),i=n(93),s=i.normalizeOptions,o=i.assert,u=n(108).point,a=["add","modify","draw","remove","onMoveStart","onMove","onMoveEnd","onClick"],f={cursor:null},l={added:!1,isHovering:!1,isMouseOver:!1,isDragging:!1,mouseTarget:null},c=function(e,t){r.extend(this,{graphie:e,state:{id:r.uniqueId("movable")}}),this.modify(r.extend({},l,t))};i.createGettersFor(c,r.extend({},f,l)),i.addMovableHelperMethodsTo(c),r.extend(c.prototype,{cloneState:function(){return r.clone(this.state)},_createDefaultState:function(){return r.extend({id:this.state.id,add:[],modify:[],draw:[],remove:[],onMoveStart:[],onMove:[],onMoveEnd:[],onClick:[]},f)},modify:function(e){this.update(r.extend({},this._createDefaultState(),e))},grab:function(e){o(u.is(e));var t=this,n=t.graphie,r=t.state;r.isHovering=!0,r.isDragging=!0,n.isDragging=!0;var i=e,s=i;t._fireEvent(r.onMoveStart,i,i);var a=function(e){e.preventDefault();var i=n.getMouseCoord(e);t._fireEvent(r.onMove,i,s),t.draw(),s=i},f=function(e){$(document).unbind("vmousemove",a),$(document).unbind("vmouseup",f),r.isHovering&&t._fireEvent(r.onClick,s,i),r.isHovering=t.state.isMouseOver,r.isDragging=!1,n.isDragging=!1,t._fireEvent(r.onMoveEnd,s,i),t.draw()};$(document).bind("vmousemove",a),$(document).bind("vmouseup",f)},update:function(e){var t=this,n=t.graphie,i=t.cloneState(),o=r.extend(t.state,s(a,e));if(o.mouseTarget&&!i.mouseTarget){var u;o.mouseTarget.getMouseTarget?u=$(o.mouseTarget.getMouseTarget()):u=$(o.mouseTarget[0]);var f=!("ontouchstart"in window);f&&(u.on("vmouseover",function(){o.isMouseOver=!0,n.isDragging||(o.isHovering=!0),t.state.added&&t.draw()}),u.on("vmouseout",function(){o.isMouseOver=!1,o.isDragging||(o.isHovering=!1),t.state.added&&t.draw()})),u.on("vmousedown",function(e){if(e.which!==0&&e.which!==1)return;e.preventDefault();var r=n.getMouseCoord(e);t.grab(r)})}if(o.mouseTarget&&o.cursor!==undefined){var u;o.mouseTarget.getMouseTarget?u=$(o.mouseTarget.getMouseTarget()):u=$(o.mouseTarget[0]),u.css("cursor",o.cursor||"")}o.added||(t._fireEvent(o.modify,t.cloneState(),{}),o.added=!0,t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.mouseTarget&&($(this.state.mouseTarget).off(),this.state.mouseTarget.remove(),this.state.mouseTarget=null)},toBack:function(){this.state.mouseTarget&&this.state.mouseTarget.toBack()},toFront:function(){this.state.mouseTarget&&this.state.mouseTarget.toFront()}}),e.exports=c},function(e,t,n){var r=n(62),i=n(130),s=n(131),o=n(93),u=n(68),a=o.assert,f=o.normalizeOptions,l=n(108).point,c=r.keys(i),h={coord:[0,0],pointSize:4,"static":!1,cursor:"move",normalStyle:null,highlightStyle:null},p={added:!1,hasMoved:!1,visibleShape:null,mouseTarget:null},d=function(e,t,n){r.extend(this,{graphie:e,movable:t,state:{id:r.uniqueId("movablePoint")}}),this.modify(r.extend({},p,n))};r.extend(d,i),o.createGettersFor(d,r.extend({},h,p)),o.addMovableHelperMethodsTo(d),r.extend(d.prototype,{cloneState:function(){return r.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return r.extend({id:this.state.id},f(c,u.pluck(i,"standard")),h)},modify:function(e){this.update(r.extend(this._createDefaultState(),e))},update:function(e){var t=this,n=t.graphie,i=r.extend(t.state,f(c,e));a(l.is(i.coord));var o=i.static?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE;i.normalStyle=r.extend({fill:o,stroke:o,scale:1},i.normalStyle),i.highlightStyle=r.extend({fill:KhanUtil.INTERACTING,stroke:KhanUtil.INTERACTING,scale:2},i.highlightStyle);if(!i.static&&!i.mouseTarget){var u=t.state.coord,h=n.unscaleVector(15),e={mouselayer:!0};i.mouseTarget=new s(n,u,h,e),i.mouseTarget.attr({fill:"#000",opacity:0})}var p=i.coord;t.movable.modify(r.extend({},i,{add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){i.hasMoved=!1,p=i.coord,t._fireEvent(i.onMoveStart,p,p),t.draw()},onMove:t.moveTo.bind(t),onMoveEnd:function(){t.isHovering()&&!i.hasMoved&&t._fireEvent(i.onClick,i.coord,p),t._fireEvent(i.onMoveEnd,i.coord,p),i.hasMoved=!1,t.draw()}})),i.added||(t.prevState={},t._fireEvent(i.add,t.cloneState(),t.prevState),i.added=!0,t.prevState=t.cloneState()),t._fireEvent(i.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){var e=this._applyConstraints(this.coord(),this.coord());return l.is(e)&&this.setCoord(e),e!==!1},setCoord:function(e){a(l.is(e,2)),this.state.coord=r.clone(e),this.draw()},setCoordConstrained:function(e){a(l.is(e,2));var t=this._applyConstraints(e,this.coord());t!==!1&&(this.state.coord=r.clone(t),this.draw())},moveTo:function(e){var t=this.state,n=this._applyConstraints(e,t.coord);if(n===!1)return;l.is(n)&&(e=n);if(!l.equal(e,t.coord)){var r=t.coord;t.coord=e,t.hasMoved=!0,this._fireEvent(t.onMove,t.coord,r),this.draw()}},normalStyle:function(){return r.clone(this.state.normalStyle)},highlightStyle:function(){return r.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()},grab:function(e){this.movable.grab(e),this.moveTo(e)}}),e.exports=d},function(e,t,n){var r=n(62),i=n(132),s=n(133),o=n(93),u=n(68),a=o.assert,f=o.normalizeOptions,l=n(108).vector,c=["add","draw","remove","onMoveStart","constraints","onMove","onMoveEnd"],h={points:null,"static":!1,cursor:"move",normalStyle:null,highlightStyle:null,extendLine:!1,extendRay:!1},p={visibleShape:null,mouseTarget:null},d=function(e,t,n){a(e!=null),a(n!=null),r.extend(this,{graphie:e,movable:t,state:{id:r.uniqueId("movableLine")}}),this.modify(r.extend({},p,n))};r.extend(d,i),o.createGettersFor(d,r.extend({},h,p)),o.addMovableHelperMethodsTo(d),r.extend(d.prototype,{cloneState:function(){return r.extend(this.movable.cloneState(),{coords:this.coords()},this.state)},_createDefaultState:function(){return r.extend({id:this.state.id},f(c,u.pluck(i,"standard")),h)},modify:function(e){this.update(r.extend(this._createDefaultState(),e))},update:function(e){var t=this,n=this.graphie,i=t.state=r.extend(t.state,f(c,e)),o=i.static?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE;i.normalStyle=r.extend({stroke:o,"stroke-width":2},i.normalStyle),i.highlightStyle=r.extend({stroke:KhanUtil.INTERACTING,"stroke-width":3},i.highlightStyle);if(!i.static&&!i.mouseTarget){var e={thickness:30,mouselayer:!0};i.mouseTarget=new s(n,this.coord(0),this.coord(1),e),i.mouseTarget.attr({fill:"#000",opacity:0})}i.static&&i.mouseTarget&&(i.mouseTarget.remove(),i.mouseTarget=null),t.movable.modify(r.extend({},i,{mouseTarget:i.mouseTarget,add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){var r=l.subtract(e,n);t._totalDelta=l.add(t._totalDelta,r);var i=l.add(t._initialRefCoord,t._totalDelta);i=t._applyConstraints(i,t._prevRefCoord);if(i===!1)return;t._fireEvent(t.state.onMove,i,t._prevRefCoord),t._prevRefCoord=i},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),i.added||(t.prevState={},t._fireEvent(i.add,t.cloneState(),t.prevState),i.added=!0,r.invoke(i.points,"listen","onMove",i.id,t.draw.bind(t)),t.prevState=t.cloneState()),t._fireEvent(i.modify,t.cloneState(),t.prevState)},coords:function(){return r.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.points&&r.invoke(this.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove()},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}}),e.exports=d},function(e,t,n){var r=n(134),i=n(93),s=n(68),o=i.assert,u=i.normalizeOptions,a=n(108).vector,f=_.keys(r),l={points:null,angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],closed:!0,"static":!1,cursor:"move",normalStyle:null,highlightStyle:null,labelStyle:null},c={added:!1,hasMoved:!1,visibleShape:null,mouseTarget:null},h=function(e,t,n){o(e!=null),o(n!=null),_.extend(this,{graphie:e,movable:t,state:{id:_.uniqueId("movablePolygon")}}),this.modify(_.extend({},c,n))};_.extend(h,r),i.createGettersFor(h,_.extend({},l,c)),i.addMovableHelperMethodsTo(h),_.extend(h.prototype,{cloneState:function(){return _.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return _.extend({id:this.state.id},u(f,s.pluck(r,"standard")),l)},modify:function(e){this.update(_.extend(this._createDefaultState(),e))},update:function(e){var t=this,n=t.graphie,r=_.extend(t.state,u(f,e)),i=r.static?KhanUtil.DYNAMIC:KhanUtil.INTERACTIVE;r.normalStyle=_.extend({},r.normalStyle,{"stroke-width":2,"fill-opacity":0,fill:i,stroke:i},e.normalStyle),r.highlightStyle=_.extend({},{stroke:KhanUtil.INTERACTING,"stroke-width":2,fill:KhanUtil.INTERACTING,"fill-opacity":.05},r.highlightStyle),r.labelStyle=_.extend({},{stroke:KhanUtil.DYNAMIC,"stroke-width":1,color:KhanUtil.DYNAMIC},r.labelStyle),r.static||r.mouseTarget||(r.mouseTarget=n.mouselayer.path(this.path()),r.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"})),t.movable.modify(_.extend({},r,{modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){var r=a.subtract(e,n);t._totalDelta=a.add(t._totalDelta,r);var i=a.add(t._initialRefCoord,t._totalDelta);i=t._applyConstraints(i,t._prevRefCoord);if(i===!1)return;t._fireEvent(t.state.onMove,i,t._prevRefCoord),t._prevRefCoord=i},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),_.invoke(r.points,"listen","onMove",r.id,t.draw.bind(t)),r.added||(t.prevState={},t._fireEvent(r.add,t.cloneState(),t.prevState),r.added=!0,t.prevState=t.cloneState()),t._fireEvent(r.modify,t.cloneState(),t.prevState)},path:function(e){var t=this.graphie;e=e||this.state;var n=_.map(e.points,function(e){return t.scalePoint(e.coord())});return e.closed?n.push(!0):n=n.concat(_.clone(n).reverse()),KhanUtil.unscaledSvgPath(n)},coords:function(){return _.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.points&&_.invoke(this.state.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){if(this.points==null||this.points.length===0)return;var e=this.coord(0),t=this._applyConstraints(e,e);t!==!1&&this._fireEvent(this.state.onMove,t,e)},normalStyle:function(){return _.clone(this.state.normalStyle)},highlightStyle:function(){return _.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}}),e.exports=h},function(e,t,n){var r={buttonStyle:{backgroundColor:"white",border:"1px solid #ccc",borderLeft:"0",cursor:"pointer",margin:"0",padding:"5px 10px",position:"relative",":first-child":{borderLeft:"1px solid #ccc",borderTopLeftRadius:"3px",borderBottomLeftRadius:"3px"},":last-child":{borderRight:"1px solid #ccc",borderTopRightRadius:"3px",borderBottomRightRadius:"3px"},":hover":{backgroundColor:"#ccc"},":focus":{zIndex:"2"}},selectedStyle:{backgroundColor:"#ddd"}};e.exports={button:r}},function(e,t,n){function s(e,t){return e+":"+t}function o(e){return e.split(":")[0]}var r=n(62),i=n(108).point,u={_fireEvent:function(e,t,n){r.invoke(e,"call",this,t,n)},_applyConstraints:function(e,t){return r.reduce(this.state.constraints,function(e,n){if(e===!1)return!1;var r=n.call(this,e,t);if(r===!1)return!1;if(i.is(r,2))return r;if(r===!0||r==null)return e;throw new Error("Constraint returned invalid result: "+r)},e,this)},draw:function(){var e=this.cloneState();u._fireEvent.call(this,this.state.draw,e,this.prevState),this.prevState=e},listen:function(e,t,n){this._listenerMap=this._listenerMap||{};var r=s(e,t),i=this._listenerMap[r]=this._listenerMap[r]||this.state[e].length;this.state[e][i]=n},unlisten:function(e,t){this._listenerMap=this._listenerMap||{};var n=s(e,t),i=this._listenerMap[n];if(i!==undefined){this.state[e].splice(i,1),delete this._listenerMap[n];var u=r.keys(this._listenerMap);r.each(u,function(t){o(t)===e&&this._listenerMap[t]>i&&this._listenerMap[t]--},this)}}};e.exports=u},function(e,t,n){(function(t){(function(){var r=function(e){return typeof window!="undefined"&&window[e]?window[e]:typeof t!="undefined"&&t[e]?t[e]:undefined},i=r("_")||n(62),s=r("React")||n(66),o=function(e){var t=i.keys(e);t.sort(function(t,n){var r=e[t].order,i=e[n].order;return r!==i?r-i:t<n?-1:t>n?1:0});var n=function(r,i){var s=[];i=i||{};var o="";while(r){var u=0;while(u<t.length){var a=t[u],f=e[a],l;f.match?l=f.match(r,i,o):l=f.regex.exec(r);if(l){var c=l[0];r=r.substring(c.length);var h=f.parse(l,n,i);h.type==null&&(h.type=a),s.push(h),o=c;break}u++}if(u===t.length)throw new Error("could not find rule to match content: "+r)}return s};return n},u=function(e){var t=function(t,n){return n.inline?e.exec(t):null};return t.regex=e,t},a=function(e){var t=function(t,n){return n.inline?null:e.exec(t)};return t.regex=e,t},f=function(e){var t=function(t,n){return e.exec(t)};return t.regex=e,t},l=function(e){var t=function(n){if(i.isArray(n)){var r={};return i.each(n,function(e,n){r["k"+n]=t(e)}),s.addons.createFragment(r)}return e(n,t)};return t},c=function(e){if(e==null)return null;try{var t=decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"").toLowerCase();if(t.indexOf("javascript:")===0)return null}catch(n){return null}return e},h=function(e,t,n){var r=n.inline||!1;n.inline=!0;var i=e(t,n);return n.inline=r,i},p=function(e,t,n){var r=n.inline||!1;n.inline=!1;var i=e(t+"\n\n",n);return n.inline=r,i},d=function(e,t,n){return{content:h(t,e[1],n)}},v=function(){return{}},m="(?:[*+-]|\\d+\\.)",g="( *)("+m+") +",y=new RegExp("^"+g),b=new RegExp(g+"[^\\n]*(?:\\n"+"(?!\\1"+m+" )[^\\n]*)*(\n|$)","gm"),w=/\n{2,}$/,E=w,S=/ *\n+$/,x=/\n{2,}./,T=new RegExp("^( *)("+m+") "+"[\\s\\S]+?(?:\n{2,}(?! )"+"(?!\\1"+m+" )\\n*"+"|\\s*\n*$)"),N=/^$|\n *$/,C=function(){var e=/^ *| *\| *$/g,t=/^ *|\| *$/g,n=/(?: *\| *)?\n$/,r=/\n$/,s=/^ *\| *| *\| *$/g,o=/ *\| */,u=/^ *-+: *$/,a=/^ *:-+: *$/,f=/^ *:-+ *$/,l=function(e){return u.test(e)?"right":a.test(e)?"center":f.test(e)?"left":null},c=function(t,n,r){var s=t[1].replace(e,"").split(o);return i.map(s,function(e){return n(e,r)})},h=function(e,n,r){var s=e[2].replace(t,"").split(o);return i.map(s,l)},p=function(e,t,r){var u=e[3].replace(n,"").split("\n");return i.map(u,function(e){var n=e.replace(s,"").split(o);return i.map(n,function(e){return t(e,r)})})},d=function(e,t,n){var s=e[3].replace(r,"").split("\n");return i.map(s,function(e){var r=e.split(o);return i.map(r,function(e){return t(e,n)})})},v=function(e,t,n){n.inline=!0;var r=c(e,t,n),i=h(e,t,n),s=p(e,t,n);return n.inline=!1,{type:"table",header:r,align:i,cells:s}},m=function(e,t,n){n.inline=!0;var r=c(e,t,n),i=h(e,t,n),s=d(e,t,n);return n.inline=!1,{type:"table",header:r,align:i,cells:s}};return{parseTable:v,parseNpTable:m,NPTABLE_REGEX:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/}}(),k="(?:\\[[^\\]]*\\]|[^\\]]|\\](?=[^\\[]*\\]))*",L="\\s*<?([^\\s]*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*",A=/mailto:/i,O=function(e,t,n){var r=(e[2]||e[1]).replace(/\s+/g," ").toLowerCase();return t._defs&&t._defs[r]&&i.extend(n,t._defs[r]),t._refs=t._refs||{},t._refs[r]=t._refs[r]||[],t._refs[r].push(n),n},M={heading:{match:a(/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n *)+\n/),parse:function(e,t,n){return{level:e[1].length,content:h(t,e[2],n)}},output:function(e,t){return s.DOM["h"+e.level](null,t(e.content))}},nptable:{match:a(C.NPTABLE_REGEX),regex:C.NPTABLE_REGEX,parse:C.parseNpTable},lheading:{match:a(/^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/),parse:function(e,t,n){return{type:"heading",level:e[2]==="="?1:2,content:h(t,e[1],n)}}},hr:{match:a(/^( *[-*_]){3,} *(?:\n *)+\n/),parse:v,output:function(){return s.DOM.hr(null)}},codeBlock:{match:a(/^(?:    [^\n]+\n*)+(?:\n *)+\n/),parse:function(e,t,n){var r=e[0].replace(/^    /gm,"").replace(/\n+$/,"");return{lang:undefined,content:r}},output:function(e,t){var n=e.lang?"markdown-code-"+e.lang:undefined;return s.DOM.pre(null,s.DOM.code({className:n},e.content))}},fence:{match:a(/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n *)+\n/),parse:function(e,t,n){return{type:"codeBlock",lang:e[2]||undefined,content:e[3]}}},blockQuote:{match:a(/^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/),parse:function(e,t,n){var r=e[0].replace(/^ *> ?/gm,"");return{content:t(r,n)}},output:function(e,t){return s.DOM.blockquote(null,t(e.content))}},list:{match:function(e,t,n){var r=N.test(n),i=t._list||!t.inline;return r&&i?T.exec(e):null},parse:function(e,t,n){var r=e[2],s=r.length>1,o=s?+r:undefined,u=e[0].replace(E,"\n").match(b),a=!1,f=i.map(u,function(e,r){var s=y.exec(e)[0].length,o=new RegExp("^ {1,"+s+"}","gm"),f=e.replace(o,"").replace(y,""),l=r===u.length-1,c=f.indexOf("\n\n")!==-1,h=c||l&&a;a=h;var p=f.replace(S,"");return h?t(p+"\n\n",i.defaults({inline:!1,_list:!0},n)):t(p,i.defaults({inline:!0,_list:!0},n))});return{ordered:s,start:o,items:f}},output:function(e,t){var n=e.ordered?"ol":"ul";return s.DOM[n]({start:e.start},i.map(e.items,function(e,n){return s.DOM.li({key:n},t(e))}))}},def:{match:a(/^ *\[([^\]]+)\]: *<?([^\s>]*)>?(?: +["(]([^\n]+)[")])? *\n(?: *\n)?/),parse:function(e,t,n){var r=e[1].replace(/\s+/g," ").toLowerCase(),s=e[2],o=e[3],u={target:s,title:o};return n._refs&&n._refs[r]&&i.each(n._refs[r],function(e){i.extend(e,u)}),n._defs=n._defs||{},n._defs[r]=u,i.extend({def:r},u)},output:function(){return null}},table:{match:a(/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/),parse:C.parseTable,output:function(e,t){var n=function(t){return e.align[t]==null?{}:{textAlign:e.align[t]}},r=i.map(e.header,function(e,r){return s.DOM.th({style:n(r)},t(e))}),o=i.map(e.cells,function(e,r){return s.DOM.tr(null,i.map(e,function(e,r){return s.DOM.td({style:n(r)},t(e))}))});return s.DOM.table(null,s.DOM.thead(null,s.DOM.tr(null,r)),s.DOM.tbody(null,o))}},newline:{match:a(/^(?:\n *)*\n/),parse:v,output:function(e,t){return"\n"}},paragraph:{match:a(/^((?:[^\n]|\n(?! *\n))+)(?:\n *)+\n/),parse:d,output:function(e,t){return s.DOM.div({className:"paragraph"},t(e.content))}},escape:{match:u(/^\\([^0-9A-Za-z\s])/),parse:function(e,t,n){return{type:"text",content:e[1]}}},autolink:{match:u(/^<([^ >]+:\/[^ >]+)>/),parse:function(e,t,n){return{type:"link",content:[{type:"text",content:e[1]}],target:e[1]}}},mailto:{match:u(/^<([^ >]+@[^ >]+)>/),parse:function(e,t,n){var r=e[1],i=e[1];return A.test(i)||(i="mailto:"+i),{type:"link",content:[{type:"text",content:r}],target:i}}},url:{match:u(/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/),parse:function(e,t,n){return{type:"link",content:[{type:"text",content:e[1]}],target:e[1],title:undefined}}},link:{match:u(new RegExp("^\\[("+k+")\\]\\("+L+"\\)")),parse:function(e,t,n){var r={content:t(e[1],n),target:e[2],title:e[3]};return r},output:function(e,t){return s.DOM.a({href:c(e.target),title:e.title},t(e.content))}},image:{match:u(new RegExp("^!\\[("+k+")\\]\\("+L+"\\)")),parse:function(e,t,n){var r={alt:e[1],target:e[2],title:e[3]};return r},output:function(e,t){return s.DOM.img({src:c(e.target),alt:e.alt,title:e.title})}},reflink:{match:u(new RegExp("^\\[("+k+")\\]"+"\\s*\\[([^\\]]*)\\]")),parse:function(e,t,n){return O(e,n,{type:"link",content:t(e[1],n)})}},refimage:{match:u(new RegExp("^!\\[("+k+")\\]"+"\\s*\\[([^\\]]*)\\]")),parse:function(e,t,n){return O(e,n,{type:"image",alt:e[1]})}},strong:{match:u(/^\*\*([\s\S]+?)\*\*(?!\*)/),parse:d,output:function(e,t){return s.DOM.strong(null,t(e.content))}},u:{match:u(/^__([\s\S]+?)__(?!_)/),parse:d,output:function(e,t){return s.DOM.u(null,t(e.content))}},em:{match:u(new RegExp("^\\b_((?:__|[\\s\\S])+?)_\\b|^\\*(?=\\S)((?:\\*\\*|\\s+[^\\*\\s]|[^\\s\\*])+?[^\\s\\*])\\*(?!\\*)")),parse:function(e,t,n){return{content:t(e[2]||e[1],n)}},output:function(e,t){return s.DOM.em(null,t(e.content))}},del:{match:u(/^~~(?=\S)([\s\S]*?\S)~~/),parse:d,output:function(e,t){return s.DOM.del(null,t(e.content))}},inlineCode:{match:u(/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/),parse:function(e,t,n){return{content:e[2]}},output:function(e,t){return s.DOM.code(null,e.content)}},br:{match:f(/^ {2,}\n/),parse:v,output:function(){return s.DOM.br(null)}},text:{match:u(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00ff-\uffff]|\n\n| {2,}\n|\w+:|$)/),parse:function(e,t,n){return{content:e[0]}},output:function(e,t){return e.content}}};i.each(Object.keys(M),function(e,t){M[e].order=t});var _=function(e){var t=function(t,n){return e[t.type].output(t,n)};return t},D=o(M),P=function(e){return D(e+"\n\n",{inline:!1})},H=function(e){return D(e,{inline:!0})},B=function(e){return D(e,{inline:!w.test(e)})},j=l(_(M)),F={parserFor:o,outputFor:l,defaultRules:M,ruleOutput:_,inlineRegex:u,blockRegex:a,anyScopeRegex:f,parseInline:h,parseBlock:p,defaultRawParse:D,defaultBlockParse:P,defaultInlineParse:H,defaultImplicitParse:B,defaultParse:B,defaultOutput:j,sanitizeUrl:c};typeof e!="undefined"&&e.exports?e.exports=F:typeof t!="undefined"?t.SimpleMarkdown=F:window.SimpleMarkdown=F})()}).call(t,function(){return this}())},function(e,t,n){function c(){return"c"+f++ +"-"+l}function h(e){var t="";for(var n in e){if(n=="className")continue;var r=s.hyphenateProp(n);if(!i.isValidProp(r)){console.warn("%s (transformed into %s) is not a valid CSS property name.",n,r);continue}var o=e[n];if(!i.isValidValue(o))continue;o!==null&&(t+=r+":",t+=s.escapeValueForProp(o,r)+";")}return t||null}function p(){var e=document.createElement("style");return document.getElementsByTagName("head")[0].appendChild(e),e}function d(e){var t="."+e.className+"{";return t+=h(e.value),t+="}",e.media&&(o(e.media)||console.log("%s is not a valid media query.",e.media),t=e.media+"{"+t+"}"),t}function v(e,t){var n={className:e,value:{}},r=[n];return Object.keys(t).forEach(function(i){if(i[0]===":"){r.push({className:e+i,value:t[i]});return}if(i.substring(0,6)==="@media"){r.push({className:e,value:t[i],media:i});return}n.value[i]=t[i]}),r}function m(e,t){var n=v(e,t),r=n.map(d).join("");a.innerHTML+=r}var r=n(139),i=n(135),s=n(136),o=n(140),u={},a=p(),f=0,l=Math.random().toString(36).slice(-5),g={merge:function(e,t,n,i,s){return r({},e,t,n,i,s)},createClass:function(e){var t=JSON.stringify(e),n;return u[t]?n=u[t]:(n=c(),u[t]=n,m(n,e)),e.className=n,e}};e.exports=g},function(e,t,n){var r=n(62),i=1e-9,s=Math.pow(2,-42),o={DEFAULT_TOLERANCE:i,EPSILON:s,is:function(e){return r.isNumber(e)&&!r.isNaN(e)},equal:function(e,t,n){return e==null||t==null?e===t:e===t?!0:(n==null&&(n=i),Math.abs(e-t)<n)},sign:function(e,t){return o.equal(e,0,t)?0:Math.abs(e)/e},isInteger:function(e,t){return o.equal(Math.round(e),e,t)},round:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n},roundTo:function(e,t){return Math.round(e/t)*t},floorTo:function(e,t){return Math.floor(e/t)*t},ceilTo:function(e,t){return Math.ceil(e/t)*t},toFraction:function(e,t,n){n=n||1e3,t=t||s;var r=[1,0],i=[0,1],u=Math.floor(e),a,f=e-u;while(i[0]<=n){if(o.equal(r[0]/i[0],e,t))return[r[0],i[0]];r=[u*r[0]+r[1],r[0]],i=[u*i[0]+i[1],i[0]],u=Math.floor(1/f),f=1/f-u}return[e,1]}};e.exports=o},function(e,t,n){function s(e){return r.reduce(e,function(e,t){return e+t},0)}function o(e){return r.reduce(e,function(e,t){return e*t},1)}var r=n(62),i=n(121),u={is:function(e,t){return r.isArray(e)?t!==undefined&&e.length!==t?!1:r.all(e,i.is):!1},normalize:function(e){return u.scale(e,1/u.length(e))},length:function(e){return Math.sqrt(u.dot(e,e))},dot:function(e,t){var n=r.toArray(arguments),i=r.zip.apply(r,n),u=r.map(i,o);return s(u)},add:function(){var e=r.toArray(arguments),t=r.zip.apply(r,e);return r.map(t,s)},subtract:function(e,t){return r.map(r.zip(e,t),function(e){return e[0]-e[1]})},negate:function(e){return r.map(e,function(e){return-e})},scale:function(e,t){return r.map(e,function(e){return e*t})},equal:function(e,t,n){return r.all(r.zip(e,t),function(e){return i.equal(e[0],e[1],n)})},codirectional:function(e,t,n){return i.equal(u.length(e),0,n)||i.equal(u.length(t),0,n)?!0:(e=u.normalize(e),t=u.normalize(t),u.equal(e,t,n))},collinear:function(e,t,n){return u.codirectional(e,t,n)||u.codirectional(e,u.negate(t),n)},polarRadFromCart:function(e){var t=u.length(e),n=Math.atan2(e[1],e[0]);return n<0&&(n+=2*Math.PI),[t,n]},polarDegFromCart:function(e){var t=u.polarRadFromCart(e);return[t[0],t[1]*180/Math.PI]},cartFromPolarRad:function(e,t){return r.isUndefined(t)&&(t=e[1],e=e[0]),[e*Math.cos(t),e*Math.sin(t)]},cartFromPolarDeg:function(e,t){return r.isUndefined(t)&&(t=e[1],e=e[0]),u.cartFromPolarRad(e,t*Math.PI/180)},rotateRad:function(e,t){var n=u.polarRadFromCart(e),r=n[1]+t;return u.cartFromPolarRad(n[0],r)},rotateDeg:function(e,t){var n=u.polarDegFromCart(e),r=n[1]+t;return u.cartFromPolarDeg(n[0],r)},angleRad:function(e,t){return Math.acos(u.dot(e,t)/(u.length(e)*u.length(t)))},angleDeg:function(e,t){return u.angleRad(e,t)*180/Math.PI},projection:function(e,t){var n=u.dot(e,t)/u.dot(t,t);return u.scale(t,n)},round:function(e,t){return r.map(e,function(e,n){return i.round(e,t[n]||t)})},roundTo:function(e,t){return r.map(e,function(e,n){return i.roundTo(e,t[n]||t)})},floorTo:function(e,t){return r.map(e,function(e,n){return i.floorTo(e,t[n]||t)})},ceilTo:function(e,t){return r.map(e,function(e,n){return i.ceilTo(e,t[n]||t)})}};e.exports=u},function(e,t,n){var r=n(62),i=n(122),s=n(121),o={rotateRad:function(e,t,n){return n===undefined?i.rotateRad(e,t):i.add(n,i.rotateRad(i.subtract(e,n),t))},rotateDeg:function(e,t,n){return n===undefined?i.rotateDeg(e,t):i.add(n,i.rotateDeg(i.subtract(e,n),t))},distanceToPoint:function(e,t){return i.length(i.subtract(e,t))},distanceToLine:function(e,t){var n=i.subtract(t[1],t[0]),r=i.subtract(e,t[0]),s=i.projection(r,n),o=i.subtract(s,r);return i.length(o)},reflectOverLine:function(e,t){var n=i.subtract(t[1],t[0]),r=i.subtract(e,t[0]),s=i.projection(r,n),o=i.subtract(i.scale(s,2),r);return i.add(t[0],o)},compare:function(e,t,n){if(e.length!==t.length)return e.length-t.length;for(var r=0;r<e.length;r++)if(!s.equal(e[r],t[r],n))return e[r]-t[r];return 0}};r.extend(o,{is:i.is,addVector:i.add,addVectors:i.add,subtractVector:i.subtract,equal:i.equal,polarRadFromCart:i.polarRadFromCart,polarDegFromCart:i.polarDegFromCart,cartFromPolarRad:i.cartFromPolarRad,cartFromPolarDeg:i.cartFromPolarDeg,round:i.round,roundTo:i.roundTo,floorTo:i.floorTo,ceilTo:i.ceilTo}),e.exports=o},function(e,t,n){var r=n(123),i=n(122),s={distanceToPoint:function(e,t){return r.distanceToLine(t,e)},reflectPoint:function(e,t){return r.reflectOverLine(t,e)},midpoint:function(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]},equal:function(e,t,n){var s=i.subtract(e[1],e[0]),o=i.subtract(t[1],t[0]);if(!i.collinear(s,o,n))return!1;if(r.equal(e[0],t[0]))return!0;var u=i.subtract(t[0],e[0]);return i.collinear(s,u,n)}};e.exports=s},function(e,t,n){var r=n(122),i=n(123),s={equal:function(e,t,n){var s=r.subtract(e[1],e[0]),o=r.subtract(t[1],t[0]),u=i.equal(e[0],t[0]),a=r.codirectional(s,o,n);return u&&a}};e.exports=s},function(e,t,n){var r=function(e){return e===Object(e)},i=function(){var e={};for(var t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var r in n)e[r]=n[r]}return e},s=function(e){return r(e)?Array.isArray(e)?e.slice():i(e):e};e.exports={isObject:r,merge:i,clone:s}},function(e,t,n){var r=function(e,t){return e[t]},i=function(e,t,n){var r=e.splice();return r[t]=n,r},s=function(e,t,n){var r=e.slice();return r[t]=n(e[t]),r},o=function(e,t){var n=e.slice();return n.splice(t,1),n};e.exports={get:r,set:i,mod:s,del:o}},function(e,t,n){var r=n(126).clone,i=function(e,t){return e[t]},s=function(e,t,n){var i=r(e);return i[t]=n,i},o=function(e,t,n){var i=r(e);return i[t]=n(e[t]),i},u=function(e,t){var n=r(e);return delete n[t],n};e.exports={get:i,set:s,mod:o,del:u}},function(e,t,n){var r=function(e,t){return e[t]},i=function(e,t,n){var r=e.splice();return r[t]=n,r},s=function(e,t,n){var r=e.splice();return r[t]=n(e[t]),r},o=function(e,t){var n=e.slice();return n.splice(t),n};e.exports={get:r,set:i,mod:s,del:o}},function(e,t,n){var r=n(62),i=n(131),s=n(108).point,o={constrain:function(){this.constrain()}};o.standard=[o.constrain];var u={draw:function(){this.draw()}};u.standard=[u.draw];var a={basic:function(e,t){var n=this.graphie;if(!this.state.visibleShape){var s=[this.pointSize()/n.scale[0],this.pointSize()/n.scale[1]],o={maxScale:Math.max(this.highlightStyle().scale,this.normalStyle().scale)};this.state.visibleShape=new i(n,this.coord(),s,o),this.state.visibleShape.attr(r.omit(this.normalStyle(),"scale")),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}e.normalStyle!==t.normalStyle&&!r.isEqual(e.normalStyle,t.normalStyle)&&this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.moveTo(this.coord()),this.mouseTarget()&&this.mouseTarget().moveTo(this.coord())},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};a.standard=[a.basic,a.highlight];var f={basic:function(){this.state.visibleShape&&(this.state.visibleShape.remove(),this.state.visibleShape=null)}};f.standard=f.basic;var l={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return e===null?!0:(e=e||this.graphie.snap,s.roundTo(t,e))}},bound:function(e,t,n){return n===undefined&&(e===undefined?n=10:n=0),function(r){var i=this.graphie;e=e||i.range,t===undefined&&(t=i.snap);var o=i.unscalePoint([n,i.ypixels-n]),u=i.unscalePoint([i.xpixels-n,n]);t&&(o=s.ceilTo(o,t),u=s.floorTo(u,t));var a=Math.max(o[0],Math.min(u[0],r[0])),f=Math.max(o[1],Math.min(u[1],r[1]));return[a,f]}}};l.standard=null,e.exports={add:o,modify:u,draw:a,remove:f,onMoveStart:{standard:null},constraints:l,onMove:{standard:null},onMoveEnd:{standard:null},onClick:{standard:null}}},function(e,t,n){var r=n(62),i=n(137),s={maxScale:1,mouselayer:!1},o=function(e,t,n,i){i=r.extend({},s,i),r.extend(this,e.fixedEllipse(t,n,i.maxScale),{graphie:e,initialPoint:t}),i.mouselayer?this.graphie.addToMouseLayerWrapper(this.wrapper):this.graphie.addToVisibleLayerWrapper(this.wrapper)};r.extend(o.prototype,i),e.exports=o},function(e,t,n){var r=n(62),i=n(133),s=n(138),o=n(108).vector,u=n(108).point,a=function(e){var t=e.graphie.scalePoint(e.coord(0)),n=e.graphie.scalePoint(e.coord(1));return o.polarDegFromCart(o.subtract(n,t))[1]},f=function(e,t,n){var r=e.range[0][1]-e.range[0][0],i=e.range[1][1]-e.range[1][0],s=r+i,u=e.unscaleVector(o.cartFromPolarDeg([1,n])),a=o.scale(o.normalize(u),s),f=o.add(t,a),l=o.polarDegFromCart(u)[1],c=e.constrainToBoundsOnAngle(f,4,l*Math.PI/180);return c},l=function(e,t){var n=[.75,0],i=[[-3,4],[-2.75,2.5],[0,.25],n,[0,-0.25],[-2.75,-2.5],[-3,-4]],u=1.4;i=r.map(i,function(e){var t=o.subtract(e,n),r=o.scale(t,u);return o.add(n,r)});var a=function(e){var t="M"+e[0][0]+" "+e[0][1];for(var n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t},l=r.map(i,e.unscalePoint),c={center:e.unscalePoint(n),createPath:a},h=new s(e,l,c);return h.attr(r.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),h.toCoordAtAngle=function(t,r){var i=e.scalePoint(f(e,t,r));h.transform("translateX("+(i[0]+u*n[0])+"px) "+"translateY("+(i[1]+u*n[1])+"px) "+"translateZ(0) "+"rotate("+(360-KhanUtil.bound(r))+"deg)")},h},c={draw:function(){this.draw()},pointsToFront:function(e){r.invoke(e.points,"toFront")}};c.standard=[c.draw,c.pointsToFront];var h={draw:function(){this.draw()}};h.standard=[h.draw];var p={basic:function(e){var t=this.graphie,n=this.coord(0),s=this.coord(1);if(!this.state.visibleShape){var o={thickness:10};this.state.visibleShape=new i(t,n,s,o),this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}var u=a(this);e.extendLine?(n=f(t,n,360-u),s=f(t,s,(540-u)%360)):e.extendRay&&(s=f(t,s,360-u));var l=[this.state.visibleShape];this.mouseTarget()&&l.push(this.mouseTarget()),r.each(l,function(e){e.moveTo(n,s)})},arrows:function(e){this._arrows==null&&(this._arrows=[],e.extendLine?(this._arrows.push(l(this.graphie,this.normalStyle())),this._arrows.push(l(this.graphie,this.normalStyle()))):e.extendRay&&this._arrows.push(l(this.graphie,this.normalStyle())));var t=a(this),n=[360-t,(540-t)%360];r.each(this._arrows,function(e,t){e.toCoordAtAngle(this.coord(t),n[t])},this)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(e.highlightStyle,50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(e.normalStyle,50)}};p.standard=[p.basic,p.arrows,p.highlight];var d={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},arrows:function(){this._arrows!=null&&r.invoke(this._arrows,"remove"),this._arrows=null}};d.standard=[d.basic,d.arrows];var v={fixed:function(){return function(){return!1}},snap:function(e){return function(t,n){if(e===null)return!0;var r=o.subtract(t,n);return e=e||this.graphie.snap,r=u.roundTo(r,e),o.add(n,r)}},bound:function(e,t,n){return n===undefined&&(e===undefined?n=10:n=0),function(e,i){var s=this.graphie,a=o.subtract(e,i),f=f||s.range;t===undefined&&(t=s.snap);var l=s.unscalePoint([n,s.ypixels-n]),c=s.unscalePoint([s.xpixels-n,n]);t&&(l=u.ceilTo(l,t),c=u.floorTo(c,t));var h=r.map(this.coords(),function(e,t){var n=o.subtract(c,e),r=o.subtract(l,e);return[r,n]}),p=r.reduce(h,function(e,t){var n=t[0],r=t[1],i=Math.max(n[0],Math.min(r[0],e[0])),s=Math.max(n[1],Math.min(r[1],e[1]));return[i,s]},a);return o.add(i,p)}}};v.standard=null;var m={updatePoints:function(e,t){var n=o.subtract(e,t);r.each(this.state.points,function(e){e.setCoord(o.add(e.coord(),n))})}};m.standard=null,e.exports={add:c,modify:h,draw:p,remove:d,onMoveStart:{standard:null},constraints:v,onMove:m,onMoveEnd:{standard:null}}},function(e,t,n){var r=n(62),i=n(93),s=n(137),o=n(108).point,u=n(108).vector,a={thickness:2,mouselayer:!1},f=function(e,t,n,i){i=r.extend({},a,i);var s=[e.range[0][0],0],u=[e.range[0][1],0];r.extend(this,e.fixedLine(s,u,i.thickness)),r.extend(this,{graphie:e,initialPoint:e.scalePoint(s),initialLength:o.distanceToPoint(e.scalePoint(s),e.scalePoint(u))}),i.mouselayer?this.graphie.addToMouseLayerWrapper(this.wrapper):this.graphie.addToVisibleLayerWrapper(this.wrapper),this.moveTo(t,n)};r.extend(f.prototype,s,{getMouseTarget:function(){return this.wrapper},moveTo:function(e,t){var n=this.graphie.scalePoint(e),r=this.graphie.scalePoint(t),s=u.polarDegFromCart(u.subtract(r,n)),o=s[0],a=KhanUtil.bound(s[1]),f=u.subtract(n,this.initialPoint),l=KhanUtil.bound(o/this.initialLength),c=i.getCanUse3dTransform(),h="translateX("+f[0]+"px) "+"translateY("+f[1]+"px) "+(c?" translateZ(0)":"")+"rotate("+a+"deg) "+"scaleX("+l+") scaleY(1)";this.transform(h)}}),e.exports=f},function(e,t,n){function s(e){return _.reduce(e,function(e,t){return e+t},0)}function o(e){var t=_.zip(e,e.slice(1).concat(e.slice(0,1))),n=_.map(t,function(e){var t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])});return s(n)>0}var r=n(108).point,i=n(108).vector,u={constrain:function(){this.constrain()},pointsToFront:function(e){_.invoke(e.points,"toFront")}};u.standard=[u.constrain,u.pointsToFront];var a={draw:function(){this.draw()}};a.standard=[a.draw];var f={basic:function(e,t){var n=this.graphie,r=this.path(e);this.state.visibleShape||(this.state.visibleShape=n.raphael.path(r),this.state.visibleShape.attr(this.normalStyle())),e.normalStyle!==t.normalStyle&&!_.isEqual(e.normalStyle,t.normalStyle)&&this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.attr({path:r}),this.mouseTarget()&&this.mouseTarget().attr({path:r})},labels:function(e,t){var n=this.graphie,r=this,i=_.invoke(e.points,"coord"),s=o(i),u=i.length;r.state._labelCache!=null&&_.invoke(r.state._labelCache,"remove"),r.state._labelCache=[];if(e.angleLabels.length||e.showRightAngleMarkers.length)r.state._labeledAngles==null&&(r.state._labeledAngles=_.times(Math.max(e.angleLabels.length,e.showRightAngleMarkers.length),function(){return n.label([0,0],"","center",e.labelStyle)})),_.each(r.state._labeledAngles,function(t,o){r.state._labelCache.push(n.labelAngle({point1:i[(o-1+u)%u],vertex:i[o],point3:i[(o+1)%u],label:t,text:e.angleLabels[o],showRightAngleMarker:e.showRightAngleMarkers[o],numArcs:e.numArcs[o],clockwise:s,style:e.labelStyle}))});e.sideLabels.length&&(r.state._labeledSides==null&&(r.state._labeledSides=_.map(e.sideLabels,function(t){return n.label([0,0],"","center",e.labelStyle)})),_.each(r.state._labeledSides,function(t,o){r.state._labelCache.push(n.labelSide({point1:i[o],point2:i[(o+1)%u],label:t,text:e.sideLabels[o],numArrows:e.numArrows[o],numTicks:e.numTicks[o],clockwise:s,style:e.labelStyle}))})),e.vertexLabels.length&&(r.state._labeledVertices==null&&(r.state._labeledVertices=_.map(e.vertexLabels,function(t){return n.label([0,0],"","center",e.labelStyle)})),_.each(labeledVertices,function(t,o){r.state._labelCache.push(n.labelVertex({point1:i[(o-1+u)%u],vertex:i[o],point3:i[(o+1)%u],label:t,text:e.vertexLabels[o],clockwise:s,style:e.labelStyle}))})),r.state._labelCache=_.flatten(r.state._labelCache)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};f.standard=[f.basic,f.labels,f.highlight];var l={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},labels:function(){var e=[this.state._labeledSides,this.state._labeledVertices,this.state._labeledAngles,this.state._labelCache];_.each(e,function(e){e!=null&&e.length&&_.invoke(e,"remove")})}};l.standard=[l.basic,l.labels];var c={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return e===null?!0:(e=e||this.graphie.snap,r.roundTo(t,e))}},bound:function(e,t,n){return n===undefined&&(e===undefined?n=10:n=0),function(e,s){var o=this.graphie,u=i.subtract(e,s),a=a||o.range;t===undefined&&(t=o.snap);var f=o.unscalePoint([n,o.ypixels-n]),l=o.unscalePoint([o.xpixels-n,n]);t&&(f=r.ceilTo(f,t),l=r.floorTo(l,t));var c=_.map(this.coords(),function(e,t){var n=i.subtract(l,e),r=i.subtract(f,e);return[r,n]}),h=_.reduce(c,function(e,t){var n=t[0],r=t[1],i=Math.max(n[0],Math.min(r[0],e[0])),s=Math.max(n[1],Math.min(r[1],e[1]));return[i,s]},u);return i.add(s,h)}}};c.standard=null;var h={updatePoints:function(e,t){var n=i.subtract(e,t);_.each(this.state.points,function(e){e.setCoord(i.add(e.coord(),n))})}};h.standard=null,e.exports={add:u,modify:a,draw:f,remove:l,onMoveStart:{standard:null},constraints:c,onMove:h,onMoveEnd:{standard:null},onClick:{standard:null}}},function(e,t,n){function i(e){return r(e)}function s(e){return e!=null&&typeof e!="boolean"&&e!==""}var r=n(141);e.exports={isValidProp:i,isValidValue:s}},function(e,t,n){function s(e){return e.replace(i,"-$1").toLowerCase()}function o(e,t){return t==="content"?'"'+e+'"':r(e)}var r=n(142),i=/([A-Z])/g;e.exports={hyphenateProp:s,escapeValueForProp:o}},function(e,t,n){var r=n(62),i=n(93),s=n(68),o=n(108).vector,u=["attr","animate"],a=r.extend({transform:function(e){var t=i.getPrefixedTransform();this.wrapper.style[t]=e},toFront:function(){var e=this.wrapper.parentNode;e.appendChild(this.wrapper)},toBack:function(){var e=this.wrapper.parentNode;e.firstChild!==this.wrapper&&e.insertBefore(this.wrapper,e.firstChild)},remove:function(){this.visibleShape.remove(),$(this.wrapper).remove()},getMouseTarget:function(){return this.visibleShape[0]},moveTo:function(e){var t=o.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),n=i.getCanUse3dTransform(),r="translateX("+t[0]+"px) "+"translateY("+t[1]+"px)"+(n?" translateZ(0)":"");this.transform(r)},hide:function(){this.visibleShape.hide()},show:function(){this.visibleShape.show()}},s.mapObjectFromArray(u,function(e){return function(){this.visibleShape[e].apply(this.visibleShape,arguments)}}));e.exports=a},function(e,t,n){var r=n(62),i=n(137),s={center:null,createPath:null,mouselayer:!1},o=function(e,t,n){n=r.extend({},s,n),r.extend(this,e.fixedPath(t,n.center,n.createPath)),r.extend(this,{graphie:e,initialPoint:e.scalePoint(r.head(t))}),n.mouselayer?this.graphie.addToMouseLayerWrapper(this.wrapper):this.graphie.addToVisibleLayerWrapper(this.wrapper)};r.extend(o.prototype,i),e.exports=o},function(e,t,n){var r=n(143),i=n(144),s=n(145),o=function(e,t,n){var o,u=e,a=u;if(!u)return a;var f=arguments,l=0,c=typeof n=="number"?2:f.length;if(c>3&&typeof f[c-2]=="function")var h=r(f[--c-1],f[c--],2);else c>2&&typeof f[c-1]=="function"&&(h=f[--c]);while(++l<c){u=f[l];if(u&&s[typeof u]){var p=-1,d=s[typeof u]&&i(u),v=d?d.length:0;while(++p<v)o=d[p],a[o]=h?h(a[o],u[o]):u[o]}}return a};e.exports=o},function(e,t,n){function i(e){var t=/\d+\/\d+/;return!!e.match(t)}function s(e){var t=/\d+/;return!!e.match(t)}function o(e){var t=/\d+(?:ex|em|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc)?$/;return!!e.match(t)}function u(e){return e==="landscape"||e==="portrait"}function a(e){return e==="progressive"||e==="interlace"}function f(e){var t=/(?:\+|-)?(?:\d+|\d*\.\d+)(?:e\d+)?(?:dpi|dpcm|dppx)$/;return!!e.match(t)}function l(e){return e!=null&&typeof e!="boolean"&&e!==""}function v(e){return!!h[e]}function m(e){return!!d[e]}function g(e){return!!p[e]}function y(e){var t=e.trim().split(/\s+/);switch(t.length){case 1:return g(t[0]);case 2:return m(t[0])&&g(t[1]);default:return!1}}function b(e){if(e.length<2)return!1;if(e[0]!=="("||e[e.length-1]!==")")return!1;e=e.substring(1,e.length-1);var t=e.split(/\s*:\s*/);switch(t.length){case 1:var n=t[0].trim();return v(n);case 2:var n=t[0].trim(),r=t[1].trim();return v(n)&&c[n](r);default:return!1}}function w(e){var t=/\s+and\s+/,n=e.split(t);return(y(n[0])||b(n[0]))&&r(n.slice(1),b)}function E(e){e=e.toLowerCase();if(e.substring(0,6)!=="@media")return!1;var t=/\s*,\s*/,n=e.substring(7,e.length).split(t);return r(n,w)}var r=n(146),c={width:o,"min-width":o,"max-width":o,height:o,"min-height":o,"max-height":o,"device-width":o,"min-device-width":o,"max-device-width":o,"device-height":o,"min-device-height":o,"max-device-height":o,"aspect-ratio":i,"min-aspect-ratio":i,"max-aspect-ratio":i,"device-aspect-ratio":i,"min-device-aspect-ratio":i,"max-device-aspect-ratio":i,color:l,"min-color":l,"max-color":l,"color-index":s,"min-color-index":s,"max-color-index":s,monochrome:s,"min-monochrome":s,"max-monochrome":s,resolution:f,"min-resolution":f,"max-resolution":f,scan:a,grid:s,orientation:u},h={width:!0,"min-width":!0,"max-width":!0,height:!0,"min-height":!0,"max-height":!0,"device-width":!0,"min-device-width":!0,"max-device-width":!0,"device-height":!0,"min-device-height":!0,"max-device-height":!0,"aspect-ratio":!0,"min-aspect-ratio":!0,"max-aspect-ratio":!0,"device-aspect-ratio":!0,"min-device-aspect-ratio":!0,"max-device-aspect-ratio":!0,color:!0,"min-color":!0,"max-color":!0,"color-index":!0,"min-color-index":!0,"max-color-index":!0,monochrome:!0,"min-monochrome":!0,"max-monochrome":!0,resolution:!0,"min-resolution":!0,"max-resolution":!0,scan:!0,grid:!0,orientation:!0},p={all:!0,aural:!0,braille:!0,handheld:!0,print:!0,projection:!0,screen:!0,tty:!0,tv:!0,embossed:!0},d={not:!0,only:!0};e.exports=E},function(e,t,n){var r={"alignment-adjust":!0,"alignment-baseline":!0,animation:!0,"animation-delay":!0,"animation-direction":!0,"animation-duration":!0,"animation-iteration-count":!0,"animation-name":!0,"animation-play-state":!0,"animation-timing-function":!0,appearance:!0,"backface-visibility":!0,background:!0,"background-attachment":!0,"background-clip":!0,"background-color":!0,"background-image":!0,"background-origin":!0,"background-position":!0,"background-repeat":!0,"background-size":!0,"baseline-shift":!0,"bookmark-label":!0,"bookmark-level":!0,"bookmark-target":!0,border:!0,"border-bottom":!0,"border-bottom-color":!0,"border-bottom-left-radius":!0,"border-bottom-right-radius":!0,"border-bottom-style":!0,"border-bottom-width":!0,"border-collapse":!0,"border-color":!0,"border-image":!0,"border-image-outset":!0,"border-image-repeat":!0,"border-image-slice":!0,"border-image-source":!0,"border-image-width":!0,"border-left":!0,"border-left-color":!0,"border-left-style":!0,"border-left-width":!0,"border-radius":!0,"border-right":!0,"border-right-color":!0,"border-right-style":!0,"border-right-width":!0,"border-spacing":!0,"border-style":!0,"border-top":!0,"border-top-color":!0,"border-top-left-radius":!0,"border-top-right-radius":!0,"border-top-style":!0,"border-top-width":!0,"border-width":!0,bottom:!0,"box-align":!0,"box-decoration-break":!0,"box-direction":!0,"box-flex":!0,"box-flex-group":!0,"box-lines":!0,"box-ordinal-group":!0,"box-orient":!0,"box-pack":!0,"box-shadow":!0,"box-sizing":!0,"caption-side":!0,clear:!0,clip:!0,color:!0,"color-profile":!0,"column-count":!0,"column-fill":!0,"column-gap":!0,"column-rule":!0,"column-rule-color":!0,"column-rule-style":!0,"column-rule-width":!0,"column-span":!0,"column-width":!0,columns:!0,content:!0,"counter-increment":!0,"counter-reset":!0,crop:!0,cursor:!0,direction:!0,display:!0,"dominant-baseline":!0,"drop-initial-after-adjust":!0,"drop-initial-after-align":!0,"drop-initial-before-adjust":!0,"drop-initial-before-align":!0,"drop-initial-size":!0,"drop-initial-value":!0,"empty-cells":!0,fit:!0,"fit-position":!0,"float":!0,"float-offset":!0,font:!0,"font-family":!0,"font-size":!0,"font-size-adjust":!0,"font-stretch":!0,"font-style":!0,"font-variant":!0,"font-weight":!0,"grid-columns":!0,"grid-rows":!0,"hanging-punctuation":!0,height:!0,"hyphenate-after":!0,"hyphenate-before":!0,"hyphenate-character":!0,"hyphenate-lines":!0,"hyphenate-resource":!0,hyphens:!0,icon:!0,"image-orientation":!0,"image-resolution":!0,"inline-box-align":!0,left:!0,"letter-spacing":!0,"line-height":!0,"line-stacking":!0,"line-stacking-ruby":!0,"line-stacking-shift":!0,"line-stacking-strategy":!0,"list-style":!0,"list-style-image":!0,"list-style-position":!0,"list-style-type":!0,margin:!0,"margin-bottom":!0,"margin-left":!0,"margin-right":!0,"margin-top":!0,mark:!0,"mark-after":!0,"mark-before":!0,marks:!0,"marquee-direction":!0,"marquee-play-count":!0,"marquee-speed":!0,"marquee-style":!0,"max-height":!0,"max-width":!0,"min-height":!0,"min-width":!0,"move-to":!0,"nav-down":!0,"nav-index":!0,"nav-left":!0,"nav-right":!0,"nav-up":!0,opacity:!0,orphans:!0,outline:!0,"outline-color":!0,"outline-offset":!0,"outline-style":!0,"outline-width":!0,overflow:!0,"overflow-style":!0,"overflow-x":!0,"overflow-y":!0,padding:!0,"padding-bottom":!0,"padding-left":!0,"padding-right":!0,"padding-top":!0,page:!0,"page-break-after":!0,"page-break-before":!0,"page-break-inside":!0,"page-policy":!0,perspective:!0,"perspective-origin":!0,phonemes:!0,position:!0,"punctuation-trim":!0,quotes:!0,"rendering-intent":!0,resize:!0,rest:!0,"rest-after":!0,"rest-before":!0,right:!0,rotation:!0,"rotation-point":!0,"ruby-align":!0,"ruby-overhang":!0,"ruby-position":!0,"ruby-span":!0,size:!0,"string-set":!0,"table-layout":!0,target:!0,"target-name":!0,"target-new":!0,"target-position":!0,"text-align":!0,"text-align-last":!0,"text-decoration":!0,"text-height":!0,"text-indent":!0,"text-justify":!0,"text-outline":!0,"text-overflow":!0,"text-shadow":!0,"text-transform":!0,"text-wrap":!0,top:!0,transform:!0,"transform-origin":!0,"transform-style":!0,transition:!0,"transition-delay":!0,"transition-duration":!0,"transition-property":!0,"transition-timing-function":!0,"unicode-bidi":!0,"user-select":!0,"vertical-align":!0,visibility:!0,"voice-balance":!0,"voice-duration":!0,"voice-pitch":!0,"voice-pitch-range":!0,"voice-rate":!0,"voice-stress":!0,"voice-volume":!0,"white-space":!0,widows:!0,width:!0,"word-break":!0,"word-spacing":!0,"word-wrap":!0,"z-index":!0},i=/^-.+-/;e.exports=function(e){return e[0]==="-"?!!r[e.replace(i,"")]:!!r[e]}},function(e,t,n){function o(e){return e==null?"":String(e).replace(s,r)}var r=n(147),i=n(148),s=n(149);e.exports=o},function(e,t,n){function l(e,t,n){if(typeof e!="function")return i;if(typeof t!="undefined"&&"prototype"in e){var l=e.__bindData__;if(typeof l=="undefined"){o.funcNames&&(l=!e.name),l=l||!o.funcDecomp;if(!l){var c=f.call(e);o.funcNames||(l=!u.test(c)),l||(l=a.test(c),s(e,l))}}if(l===!1||l!==!0&&l[1]&1)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,s){return e.call(t,n,r,i,s)}}return r(e,t)}return e}var r=n(150),i=n(151),s=n(152),o=n(153),u=/^\s*function[ \n\r\t]+\w/,a=/\bthis\b/,f=Function.prototype.toString;e.exports=l},function(e,t,n){var r=n(154),i=n(155),s=n(156),o=r(o=Object.keys)&&o,u=o?function(e){return i(e)?o(e):[]}:s;e.exports=u},function(e,t,n){var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1};e.exports=r},function(e,t,n){function s(e,t,n){var s=!0;t=r(t,n,3);var o=-1,u=e?e.length:0;if(typeof u=="number"){while(++o<u)if(!(s=!!t(e[o],o,e)))break}else i(e,function(e,n,r){return s=!!t(e,n,r)});return s}var r=n(157),i=n(158);e.exports=s},function(e,t,n){function i(e){return r[e]}var r=n(159);e.exports=i},function(e,t,n){var r=n(161),i=n(162),s=n(163),o=r(o=Object.keys)&&o,u=o?function(e){return i(e)?o(e):[]}:s;e.exports=u},function(e,t,n){var r=n(160),i=n(148),s=RegExp("["+i(r).join("")+"]","g");e.exports=s},function(e,t,n){function s(e,t){return arguments.length>2?r(e,17,i(arguments,2),null,t):r(e,1,null,null,t)}var r=n(164),i=n(165);e.exports=s},function(e,t,n){function r(e){return e}e.exports=r},function(e,t,n){var r=n(166),i=n(167),s={configurable:!1,enumerable:!1,value:null,writable:!1},o=function(){try{var e={},t=r(t=Object.defineProperty)&&t,n=t(e,e,e)&&t}catch(i){}return n}(),u=o?function(e,t){s.value=t,o(e,"__bindData__",s)}:i;e.exports=u},function(e,t,n){(function(t){var r=n(168),i=/\bthis\b/,s={};s.funcDecomp=!r(t.WinRTError)&&i.test(function(){return this}),s.funcNames=typeof Function.name=="string",e.exports=s}).call(t,function(){return this}())},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(145);e.exports=i},function(e,t,n){var r=n(145),i=Object.prototype,s=i.hasOwnProperty,o=function(e){var t,n=e,i=[];if(!n)return i;if(!r[typeof e])return i;for(t in n)s.call(n,t)&&i.push(t);return i};e.exports=o},function(e,t,n){function a(e,t,n){var a=typeof e;if(e==null||a=="function")return r(e,t,n);if(a!="object")return u(e);var f=o(e),l=f[0],c=e[l];return f.length==1&&c===c&&!s(c)?function(e){var t=e[l];return c===t&&(c!==0||1/c==1/t)}:function(t){var n=f.length,r=!1;while(n--)if(!(r=i(t[f[n]],e[f[n]],null,!0)))break;return r}}var r=n(169),i=n(170),s=n(171),o=n(172),u=n(173);e.exports=a},function(e,t,n){var r=n(174),i=n(175),s=n(176),o=function(e,t,n){var o,u=e,a=u;if(!u)return a;if(!s[typeof u])return a;t=t&&typeof n=="undefined"?t:r(t,n,3);var f=-1,l=s[typeof u]&&i(u),c=l?l.length:0;while(++f<c){o=l[f];if(t(u[o],o,e)===!1)return a}return a};e.exports=o},function(e,t,n){var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};e.exports=r},function(e,t,n){var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(177);e.exports=i},function(e,t,n){var r=n(178),i=Object.prototype,s=i.hasOwnProperty,o=function(e){var t,n=e,i=[];if(!n)return i;if(!r[typeof e])return i;for(t in n)s.call(n,t)&&i.push(t);return i};e.exports=o},function(e,t,n){function l(e,t,n,u,c,h){var p=t&1,d=t&2,v=t&4,m=t&8,g=t&16,y=t&32;if(!d&&!s(e))throw new TypeError;g&&!n.length&&(t&=-17,g=n=!1),y&&!u.length&&(t&=-33,y=u=!1);var b=e&&e.__bindData__;if(b&&b!==!0)return b=o(b),b[2]&&(b[2]=o(b[2])),b[3]&&(b[3]=o(b[3])),p&&!(b[1]&1)&&(b[4]=c),!p&&b[1]&1&&(t|=8),v&&!(b[1]&4)&&(b[5]=h),g&&a.apply(b[2]||(b[2]=[]),n),y&&f.apply(b[3]||(b[3]=[]),u),b[1]|=t,l.apply(null,b);var w=t==1||t===17?r:i;return w([e,t,n,u,c,h])}var r=n(179),i=n(180),s=n(181),o=n(165),u=[],a=u.push,f=u.unshift;e.exports=l},function(e,t,n){function r(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);var r=-1,i=n-t||0,s=Array(i<0?0:i);while(++r<i)s[r]=e[t+r];return s}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function l(e,t,n){if(typeof e!="function")return i;if(typeof t!="undefined"&&"prototype"in e){var l=e.__bindData__;if(typeof l=="undefined"){o.funcNames&&(l=!e.name),l=l||!o.funcDecomp;if(!l){var c=f.call(e);o.funcNames||(l=!u.test(c)),l||(l=a.test(c),s(e,l))}}if(l===!1||l!==!0&&l[1]&1)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,s){return e.call(t,n,r,i,s)}}return r(e,t)}return e}var r=n(182),i=n(183),s=n(184),o=n(185),u=/^\s*function[ \n\r\t]+\w/,a=/\bthis\b/,f=Function.prototype.toString;e.exports=l},function(e,t,n){function b(e,t,n,m,w,E){if(n){var S=n(e,t);if(typeof S!="undefined")return!!S}if(e===t)return e!==0||1/e==1/t;var x=typeof e,T=typeof t;if(e===e&&(!e||!o[x])&&(!t||!o[T]))return!1;if(e==null||t==null)return e===t;var N=g.call(e),C=g.call(t);N==a&&(N=p),C==a&&(C=p);if(N!=C)return!1;switch(N){case l:case c:return+e==+t;case h:return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case d:case v:return e==String(t)}var k=N==f;if(!k){var L=y.call(e,"__wrapped__"),A=y.call(t,"__wrapped__");if(L||A)return b(L?e.__wrapped__:e,A?t.__wrapped__:t,n,m,w,E);if(N!=p)return!1;var O=e.constructor,M=t.constructor;if(O!=M&&!(s(O)&&O instanceof O&&s(M)&&M instanceof M)&&"constructor"in e&&"constructor"in t)return!1}var _=!w;w||(w=i()),E||(E=i());var D=w.length;while(D--)if(w[D]==e)return E[D]==t;var P=0;S=!0,w.push(e),E.push(t);if(k){D=e.length,P=t.length,S=P==D;if(S||m)while(P--){var H=D,B=t[P];if(m){while(H--)if(S=b(e[H],B,n,m,w,E))break}else if(!(S=b(e[P],B,n,m,w,E)))break}}else r(t,function(t,r,i){if(y.call(i,r))return P++,S=y.call(e,r)&&b(e[r],t,n,m,w,E)}),S&&!m&&r(e,function(e,t,n){if(y.call(n,t))return S=--P>-1});return w.pop(),E.pop(),_&&(u(w),u(E)),S}var r=n(186),i=n(187),s=n(188),o=n(189),u=n(190),a="[object Arguments]",f="[object Array]",l="[object Boolean]",c="[object Date]",h="[object Number]",p="[object Object]",d="[object RegExp]",v="[object String]",m=Object.prototype,g=m.toString,y=m.hasOwnProperty;e.exports=b},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(191);e.exports=i},function(e,t,n){var r=n(192),i=n(171),s=n(193),o=r(o=Object.keys)&&o,u=o?function(e){return i(e)?o(e):[]}:s;e.exports=u},function(e,t,n){function r(e){return function(t){return t[e]}}e.exports=r},function(e,t,n){function l(e,t,n){if(typeof e!="function")return i;if(typeof t!="undefined"&&"prototype"in e){var l=e.__bindData__;if(typeof l=="undefined"){o.funcNames&&(l=!e.name),l=l||!o.funcDecomp;if(!l){var c=f.call(e);o.funcNames||(l=!u.test(c)),l||(l=a.test(c),s(e,l))}}if(l===!1||l!==!0&&l[1]&1)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,s){return e.call(t,n,r,i,s)}}return r(e,t)}return e}var r=n(194),i=n(195),s=n(196),o=n(197),u=/^\s*function[ \n\r\t]+\w/,a=/\bthis\b/,f=Function.prototype.toString;e.exports=l},function(e,t,n){var r=n(198),i=n(199),s=n(200),o=r(o=Object.keys)&&o,u=o?function(e){return i(e)?o(e):[]}:s;e.exports=u},function(e,t,n){var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1};e.exports=r},function(e,t,n){var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1};e.exports=r},function(e,t,n){var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1};e.exports=r},function(e,t,n){function f(e){function f(){if(n){var e=o(n);a.apply(e,arguments)}if(this instanceof f){var s=r(t.prototype),l=t.apply(s,e||arguments);return i(l)?l:s}return t.apply(u,e||arguments)}var t=e[0],n=e[2],u=e[4];return s(f,e),f}var r=n(201),i=n(202),s=n(152),o=n(165),u=[],a=u.push;e.exports=f},function(e,t,n){function f(e){function y(){var e=p?c:this;if(u){var s=o(u);a.apply(s,arguments)}if(l||v){s||(s=o(arguments)),l&&a.apply(s,l);if(v&&s.length<h)return n|=16,f([t,m?n:n&-4,s,null,c,h])}s||(s=arguments),d&&(t=e[g]);if(this instanceof y){e=r(t.prototype);var b=t.apply(e,s);return i(b)?b:e}return t.apply(e,s)}var t=e[0],n=e[1],u=e[2],l=e[3],c=e[4],h=e[5],p=n&1,d=n&2,v=n&4,m=n&8,g=t;return s(y,e),y}var r=n(203),i=n(204),s=n(152),o=n(165),u=[],a=u.push;e.exports=f},function(e,t,n){function r(e){return typeof e=="function"}e.exports=r},function(e,t,n){function s(e,t){return arguments.length>2?r(e,17,i(arguments,2),null,t):r(e,1,null,null,t)}var r=n(205),i=n(206);e.exports=s},function(e,t,n){function r(e){return e}e.exports=r},function(e,t,n){var r=n(207),i=n(208),s={configurable:!1,enumerable:!1,value:null,writable:!1},o=function(){try{var e={},t=r(t=Object.defineProperty)&&t,n=t(e,e,e)&&t}catch(i){}return n}(),u=o?function(e,t){s.value=t,o(e,"__bindData__",s)}:i;e.exports=u},function(e,t,n){(function(t){var r=n(209),i=/\bthis\b/,s={};s.funcDecomp=!r(t.WinRTError)&&i.test(function(){return this}),s.funcNames=typeof Function.name=="string",e.exports=s}).call(t,function(){return this}())},function(e,t,n){var r=n(169),i=n(189),s=function(e,t,n){var s,o=e,u=o;if(!o)return u;if(!i[typeof o])return u;t=t&&typeof n=="undefined"?t:r(t,n,3);for(s in o)if(t(o[s],s,e)===!1)return u;return u};e.exports=s},function(e,t,n){function i(){return r.pop()||[]}var r=n(212);e.exports=i},function(e,t,n){function r(e){return typeof e=="function"}e.exports=r},function(e,t,n){var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1};e.exports=r},function(e,t,n){function s(e){e.length=0,r.length<i&&r.push(e)}var r=n(210),i=n(211);e.exports=s},function(e,t,n){var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1};e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){var r=n(213),i=Object.prototype,s=i.hasOwnProperty,o=function(e){var t,n=e,i=[];if(!n)return i;if(!r[typeof e])return i;for(t in n)s.call(n,t)&&i.push(t);return i};e.exports=o},function(e,t,n){function s(e,t){return arguments.length>2?r(e,17,i(arguments,2),null,t):r(e,1,null,null,t)}var r=n(214),i=n(215);e.exports=s},function(e,t,n){function r(e){return e}e.exports=r},function(e,t,n){var r=n(216),i=n(217),s={configurable:!1,enumerable:!1,value:null,writable:!1},o=function(){try{var e={},t=r(t=Object.defineProperty)&&t,n=t(e,e,e)&&t}catch(i){}return n}(),u=o?function(e,t){s.value=t,o(e,"__bindData__",s)}:i;e.exports=u},function(e,t,n){(function(t){var r=n(218),i=/\bthis\b/,s={};s.funcDecomp=!r(t.WinRTError)&&i.test(function(){return this}),s.funcNames=typeof Function.name=="string",e.exports=s}).call(t,function(){return this}())},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(176);e.exports=i},function(e,t,n){var r=n(176),i=Object.prototype,s=i.hasOwnProperty,o=function(e){var t,n=e,i=[];if(!n)return i;if(!r[typeof e])return i;for(t in n)s.call(n,t)&&i.push(t);return i};e.exports=o},function(e,t,n){(function(t){function u(e,t){return i(e)?o(e):{}}var r=n(219),i=n(202),s=n(220),o=r(o=Object.create)&&o;o||(u=function(){function e(){}return function(n){if(i(n)){e.prototype=n;var r=new e;e.prototype=null}return r||t.Object()}}()),e.exports=u}).call(t,function(){return this}())},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(145);e.exports=i},function(e,t,n){(function(t){function u(e,t){return i(e)?o(e):{}}var r=n(221),i=n(204),s=n(222),o=r(o=Object.create)&&o;o||(u=function(){function e(){}return function(n){if(i(n)){e.prototype=n;var r=new e;e.prototype=null}return r||t.Object()}}()),e.exports=u}).call(t,function(){return this}())},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(145);e.exports=i},function(e,t,n){function l(e,t,n,u,c,h){var p=t&1,d=t&2,v=t&4,m=t&8,g=t&16,y=t&32;if(!d&&!s(e))throw new TypeError;g&&!n.length&&(t&=-17,g=n=!1),y&&!u.length&&(t&=-33,y=u=!1);var b=e&&e.__bindData__;if(b&&b!==!0)return b=o(b),b[2]&&(b[2]=o(b[2])),b[3]&&(b[3]=o(b[3])),p&&!(b[1]&1)&&(b[4]=c),!p&&b[1]&1&&(t|=8),v&&!(b[1]&4)&&(b[5]=h),g&&a.apply(b[2]||(b[2]=[]),n),y&&f.apply(b[3]||(b[3]=[]),u),b[1]|=t,l.apply(null,b);var w=t==1||t===17?r:i;return w([e,t,n,u,c,h])}var r=n(223),i=n(224),s=n(225),o=n(206),u=[],a=u.push,f=u.unshift;e.exports=l},function(e,t,n){function r(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);var r=-1,i=n-t||0,s=Array(i<0?0:i);while(++r<i)s[r]=e[t+r];return s}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){var r=[];e.exports=r},function(e,t,n){var r=40;e.exports=r},function(e,t,n){var r=[];e.exports=r},function(e,t,n){var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1};e.exports=r},function(e,t,n){function l(e,t,n,u,c,h){var p=t&1,d=t&2,v=t&4,m=t&8,g=t&16,y=t&32;if(!d&&!s(e))throw new TypeError;g&&!n.length&&(t&=-17,g=n=!1),y&&!u.length&&(t&=-33,y=u=!1);var b=e&&e.__bindData__;if(b&&b!==!0)return b=o(b),b[2]&&(b[2]=o(b[2])),b[3]&&(b[3]=o(b[3])),p&&!(b[1]&1)&&(b[4]=c),!p&&b[1]&1&&(t|=8),v&&!(b[1]&4)&&(b[5]=h),g&&a.apply(b[2]||(b[2]=[]),n),y&&f.apply(b[3]||(b[3]=[]),u),b[1]|=t,l.apply(null,b);var w=t==1||t===17?r:i;return w([e,t,n,u,c,h])}var r=n(226),i=n(227),s=n(228),o=n(215),u=[],a=u.push,f=u.unshift;e.exports=l},function(e,t,n){function r(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);var r=-1,i=n-t||0,s=Array(i<0?0:i);while(++r<i)s[r]=e[t+r];return s}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function f(e){function f(){if(n){var e=o(n);a.apply(e,arguments)}if(this instanceof f){var s=r(t.prototype),l=t.apply(s,e||arguments);return i(l)?l:s}return t.apply(u,e||arguments)}var t=e[0],n=e[2],u=e[4];return s(f,e),f}var r=n(232),i=n(171),s=n(184),o=n(206),u=[],a=u.push;e.exports=f},function(e,t,n){function f(e){function y(){var e=p?c:this;if(u){var s=o(u);a.apply(s,arguments)}if(l||v){s||(s=o(arguments)),l&&a.apply(s,l);if(v&&s.length<h)return n|=16,f([t,m?n:n&-4,s,null,c,h])}s||(s=arguments),d&&(t=e[g]);if(this instanceof y){e=r(t.prototype);var b=t.apply(e,s);return i(b)?b:e}return t.apply(e,s)}var t=e[0],n=e[1],u=e[2],l=e[3],c=e[4],h=e[5],p=n&1,d=n&2,v=n&4,m=n&8,g=t;return s(y,e),y}var r=n(229),i=n(171),s=n(184),o=n(206),u=[],a=u.push;e.exports=f},function(e,t,n){function r(e){return typeof e=="function"}e.exports=r},function(e,t,n){function f(e){function f(){if(n){var e=o(n);a.apply(e,arguments)}if(this instanceof f){var s=r(t.prototype),l=t.apply(s,e||arguments);return i(l)?l:s}return t.apply(u,e||arguments)}var t=e[0],n=e[2],u=e[4];return s(f,e),f}var r=n(230),i=n(231),s=n(196),o=n(215),u=[],a=u.push;e.exports=f},function(e,t,n){function f(e){function y(){var e=p?c:this;if(u){var s=o(u);a.apply(s,arguments)}if(l||v){s||(s=o(arguments)),l&&a.apply(s,l);if(v&&s.length<h)return n|=16,f([t,m?n:n&-4,s,null,c,h])}s||(s=arguments),d&&(t=e[g]);if(this instanceof y){e=r(t.prototype);var b=t.apply(e,s);return i(b)?b:e}return t.apply(e,s)}var t=e[0],n=e[1],u=e[2],l=e[3],c=e[4],h=e[5],p=n&1,d=n&2,v=n&4,m=n&8,g=t;return s(y,e),y}var r=n(233),i=n(234),s=n(196),o=n(215),u=[],a=u.push;e.exports=f},function(e,t,n){function r(e){return typeof e=="function"}e.exports=r},function(e,t,n){(function(t){function u(e,t){return i(e)?o(e):{}}var r=n(237),i=n(171),s=n(238),o=r(o=Object.create)&&o;o||(u=function(){function e(){}return function(n){if(i(n)){e.prototype=n;var r=new e;e.prototype=null}return r||t.Object()}}()),e.exports=u}).call(t,function(){return this}())},function(e,t,n){(function(t){function u(e,t){return i(e)?o(e):{}}var r=n(239),i=n(231),s=n(240),o=r(o=Object.create)&&o;o||(u=function(){function e(){}return function(n){if(i(n)){e.prototype=n;var r=new e;e.prototype=null}return r||t.Object()}}()),e.exports=u}).call(t,function(){return this}())},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(176);e.exports=i},function(e,t,n){(function(t){function u(e,t){return i(e)?o(e):{}}var r=n(235),i=n(171),s=n(236),o=r(o=Object.create)&&o;o||(u=function(){function e(){}return function(n){if(i(n)){e.prototype=n;var r=new e;e.prototype=null}return r||t.Object()}}()),e.exports=u}).call(t,function(){return this}())},function(e,t,n){(function(t){function u(e,t){return i(e)?o(e):{}}var r=n(241),i=n(234),s=n(242),o=r(o=Object.create)&&o;o||(u=function(){function e(){}return function(n){if(i(n)){e.prototype=n;var r=new e;e.prototype=null}return r||t.Object()}}()),e.exports=u}).call(t,function(){return this}())},function(e,t,n){function i(e){return!!e&&!!r[typeof e]}var r=n(176);e.exports=i},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r},function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype,i=r.toString,s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=o},function(e,t,n){function r(){}e.exports=r}])}),require(["../perseus/ke-deps","../perseus/build/perseus-3"],function(e,t){t.init({}).then(function(){window.Perseus=t,angular.bootstrap(document,["lkhan"])})}),define("ng-perseus",function(){});