@khanacademy/perseus 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -1,16 +1,8 @@
1
- import*as e from"@khanacademy/kas";import{KeypadInput as t,KeypadTypes as r,keypadElementPropType as i,Keypad as n}from"@khanacademy/math-input";import*as o from"@khanacademy/wonder-blocks-i18n";import s from"classnames";import*as a from"react";import l,{Component as p}from"react";import h,{debounce as c}from"underscore";import d from"prop-types";import u from"simple-markdown";import{StyleSheet as m,css as g}from"aphrodite";import*as f from"react-dom";import v from"react-dom";import y from"jquery";import{number as b,point as x,vector as w,line as C,ray as k}from"@khanacademy/kmath";import E from"create-react-class";import S from"mathquill";import _,{SemanticColor as M,mix as T,fade as I}from"@khanacademy/wonder-blocks-color";import{Text as P,UniqueIDProvider as N,View as A,addStyle as R}from"@khanacademy/wonder-blocks-core";import"intersection-observer";import F from"@khanacademy/wonder-blocks-spacing";import O from"@khanacademy/wonder-blocks-tooltip";import{OptionItem as D,SingleSelect as L}from"@khanacademy/wonder-blocks-dropdown";import{Popover as B,PopoverContentCore as z}from"@khanacademy/wonder-blocks-popover";import H from"@khanacademy/wonder-blocks-link";var W={major:11,minor:0},q={major:0,minor:1};function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?U(Object(r),!0).forEach((function(t){j(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function V(e,t,r,i,n,o,s){try{var a=e[o](s),l=a.value}catch(e){return void r(e)}a.done?t(l):Promise.resolve(l).then(i,n)}function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Y(){return Y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Y.apply(this,arguments)}function $(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},o=Object.keys(e);for(i=0;i<o.length;i++)r=o[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var X=e=>{var{path:t,width:r,height:i,style:n={},title:o}=e;return a.createElement("svg",{role:"img","aria-hidden":!o,style:G({verticalAlign:"middle"},n),width:"".concat(r/i,"em"),height:"1em",viewBox:"0 0 ".concat(r," ").concat(i)},!!o&&a.createElement("title",null,o),a.createElement("path",{d:t,fill:"currentColor"}))};X.propTypes={path:d.string.isRequired,height:d.number.isRequired,width:d.number.isRequired,style:d.object,title:d.string};var K="'Proxima Nova Semibold',sans-serif",Z="#FFFFFF",J="#BABEC2",Q="#888D93",ee="#21242c",te={defaultBoxSize:400,defaultBoxSizeSmall:288},re=Object.freeze({__proto__:null,baseFontFamily:"'Proxima Nova',sans-serif",boldFontFamily:K,green:"#76A005",kaGreen:"#71B307",blue:"#1C758A",gray:"#AAAAAA",red:"#FFBABA",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",learnstormBlue:"#4898FC",white:Z,gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:J,gray68:Q,gray41:"#626569",gray25:"#3B3e40",gray17:ee,black:"#000000",warning1:"#F86700",warning3:"#C75300",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1280px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1279px",tableBackgroundAccent:"#F9F9F9",gtpBlue:"#4c00ff",gtpIncorrectColor:"#babec2",gtpCorrectColor:"#ffbe26",satBlue:"#0084CE",satSelectedBackgroundColor:"#E4F3F9",satActiveBackgroundColor:"#D0EDF4",satCorrectColor:"#009900",satCorrectBorderColor:"#00CC00",satCorrectBackgroundColor:"#E4F7E4",satIncorrectColor:"#990000",satIncorrectBorderColor:"#CC5252",satIncorrectBackgroundColor:"#F2EBEB",zIndexScratchPad:1,zIndexAboveScratchpad:2,zIndexInteractiveComponent:3,zIndexCurrentlyDragging:4,zIndexCalculator:5,phoneMargin:16,negativePhoneMargin:-16,hintBorderWidth:4,baseUnitPx:16,interactiveSizes:te,circleSize:24,radioMarginWidth:2,warningColor:"#f86700",warningColorHover:"#df5c00",warningColorActive:"#c75300",publishBlockingErrorColor:"#be2612",radioBorderColor:"#BABEC2",checkedColor:"#71B307",articleMaxWidthInPx:688,articleMaxWidthTableInPx:512}),ie={path:"M6 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0-9a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z",height:12,width:12};class ne extends a.Component{constructor(){super(...arguments),j(this,"_positionTimeout",void 0),j(this,"state",{tooltipAbove:!0}),j(this,"getPosition",(()=>{var e=v.findDOMNode(this).getBoundingClientRect();this.setState({tooltipAbove:e.top>100})})),j(this,"renderLink",(e=>{var t,r,i,n=this.state.tooltipAbove;return 1===this.props.severity?(t=oe.indicatorError,r="Error",i=oe.publishBlockingError):2===this.props.severity?(t=oe.indicatorWarning,r="Warning",i=oe.warning):(t=oe.indicatorGuideline,r="Recommendation",i=oe.warning),a.createElement("a",{href:"https://khanacademy.org/r/linter-rules#".concat(this.props.ruleName),target:"lint-help-window",className:g(e)},a.createElement("span",{className:g(oe.indicator,t)},1===this.props.severity&&a.createElement(X,ie)),a.createElement("div",{className:g(oe.tooltip,n&&oe.tooltipAbove)},this.props.message.split("\n\n").map(((e,t)=>a.createElement("p",{key:t,className:g(oe.tooltipParagraph)},a.createElement("span",{className:g(i)},r,":"," "),e))),a.createElement("div",{className:g(oe.tail,n&&oe.tailAbove)})))}))}componentDidMount(){this._positionTimeout=window.setTimeout(this.getPosition)}componentWillUnmount(){window.clearTimeout(this._positionTimeout)}render(){var{children:e,inline:t,blockHighlight:r,insideTable:i}=this.props;return i?t?a.createElement("span",{"data-lint-inside-table":"true"},e):a.createElement("div",{"data-lint-inside-table":"true"},e):r?a.createElement("span",{className:g(oe.lintContainer,oe.lintContainerBlock)},this.renderLink(oe.radioWidgetHoverTarget),a.createElement("span",null,e)):t?a.createElement("span",{className:g(oe.lintContainer)},this.renderLink(oe.inlineHoverTarget),a.createElement("span",null,e)):a.createElement("div",{className:g(oe.lintContainer)},this.renderLink(oe.hoverTarget),a.createElement("div",null,e))}}j(ne,"propTypes",{children:d.node,inline:d.bool,message:d.string.isRequired,ruleName:d.string.isRequired,insideTable:d.bool.isRequired,blockHighlight:d.bool,severity:d.number});var oe=m.create({lintContainer:{position:"relative"},lintContainerBlock:{display:"block"},hoverTarget:{position:"absolute",top:0,right:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ div":{outline:"1px solid #f86700"},":hover ~ div div[data-lint-inside-table]":{outline:"1px solid #f86700"},":hover ~ div span[data-lint-inside-table]":{backgroundColor:"#f86700",color:Z}},inlineHoverTarget:{float:"right",position:"relative",marginRight:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ span":{backgroundColor:"#f86700",color:Z}},radioWidgetHoverTarget:{position:"absolute",left:-40,display:"block",width:24,height:24,minWidth:264,":hover > span":{backgroundColor:"#df5c00"},":hover > div":{display:"block",padding:8,width:280},":hover > div > div":{left:8},":hover ~ span":{backgroundColor:"#f86700",color:Z}},indicator:{alignItems:"center",borderRadius:4,color:"white",display:"flex",fontSize:12,height:8,justifyContent:"center",margin:8,width:8},indicatorError:{backgroundColor:"#be2612",borderRadius:8,height:16,width:16},indicatorWarning:{backgroundColor:"#f86700"},indicatorGuideline:{backgroundColor:"#ffbe26"},tooltip:{position:"absolute",right:-12,display:"none",zIndex:1e3,color:Z,backgroundColor:ee,opacity:.9,fontFamily:"'Proxima Nova',sans-serif",fontSize:"12px",lineHeight:"15px",width:"320px",borderRadius:"4px"},tooltipAbove:{bottom:32},tail:{position:"absolute",top:-12,right:16,width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:"12px solid #21242c"},tailAbove:{bottom:-12,borderBottom:"none",borderTop:"12px solid #21242c",top:"auto"},tooltipParagraph:{margin:12},warning:{color:"#f86700",fontFamily:K},publishBlockingError:{color:"#be2612"}}),se=null,ae=()=>{if(se)return se;throw new Error(["Perseus has not been provided required dependencies.","setDependencies(dependencies) must be called first.","Make sure Perseus is being imported from javascript/perseus/perseus.js."].join("\n"))},le=Object.freeze({__proto__:null,setDependencies:e=>{se=e},getDependencies:ae}),pe=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"}),he={log:(e,t)=>{ae().Log.log(e,t)},error:(e,t,r)=>{ae().Log.error(e,t,r)}};class ce extends Error{constructor(e,t,r){super(e),j(this,"kind",void 0),j(this,"metadata",void 0),this.kind=t,this.metadata=null==r?void 0:r.metadata}}var de={cleanMath:function(e){return"string"==typeof e?e.replace(/\+\s*-/g,"- ").replace(/-\s*-/g,"+ ").replace(/\^1/g,""):e},bound:function(e){return 0===e?e:e<0?-de.bound(-e):Math.max(1e-6,Math.min(e,1e20))},factorial:function(e){return e<=1?e:e*de.factorial(e-1)},getGCD:function(e,t){if(arguments.length>2){var r=[].slice.call(arguments,1);return de.getGCD(e,de.getGCD(...r))}var i;for(e=Math.abs(e),t=Math.abs(t);t;)i=e%t,e=t,t=i;return e},getLCM:function(e,t){if(arguments.length>2){var r=[].slice.call(arguments,1);return de.getLCM(e,de.getLCM(...r))}return Math.abs(e*t)/de.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],isPrime:function(e){if(e<=1)return!1;if(e<101)return!!y.grep(de.primes,(function(t,r){return Math.abs(t-e)<=.5})).length;if(e<=1||e>2&&e%2==0)return!1;for(var t=3,r=Math.sqrt(e);t<=r;t+=2)if(e%t==0)return!1;return!0},getPrimeFactorization:function(e){if(1===e)return[];if(de.isPrime(e))return[e];for(var t=Math.sqrt(e),r=2;r<=t;r++)if(e%r==0)return y.merge(de.getPrimeFactorization(r),de.getPrimeFactorization(e/r))},roundToNearest:function(e,t){return Math.round(t/e)*e},roundTo:function(e,t){var r=Math.pow(10,e).toFixed(5);return Math.round((t*r).toFixed(5))/r},toFixedApprox:function(e,t){var r=e.toFixed(t);return b.equal(+r,e)?r:"\\approx "+r},roundToApprox:function(e,t){var r=de.roundTo(t,e);return b.equal(r,e)?String(r):de.toFixedApprox(e,t)},toFraction:function(e,t){if(null==t&&(t=Math.pow(2,-46)),e<0||e>1){var r=e%1;r+=r<0?1:0;var i=de.toFraction(r,t);return i[0]+=Math.round(e-r)*i[1],i}if(Math.abs(Math.round(Number(e))-e)<=t)return[Math.round(e),1];for(var n=0,o=1,s=1,a=1,l=1,p=2;;){if(Math.abs(Number(l/p)-e)<=t)return[l,p];l/p<e?(n=l,o=p):(s=l,a=p),l=n+s,p=o+a}},getNumericFormat:function(e){if((e=(e=y.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1")).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,t){if(null==e)return"";if(0===e)return"0";if("percent"===t)return 100*e+"%";if("pi"===t){var r=b.toFraction(e/Math.PI),i=Math.abs(r[0]),n=r[1];if(b.isInteger(i)){return(e<0?"-":"")+(1===i?"":i)+"π"+(1===n?"":"/"+n)}}if(h(["proper","improper","mixed","fraction"]).contains(t)){var o=b.toFraction(e),s=Math.abs(o[0]),a=o[1],l=e<0?"-":"";if(1===a)return l+s;if("mixed"===t){var p=s%a,c=(s-p)/a;return l+(c?c+" ":"")+p+"/"+a}return l+s+"/"+a}return String(e)}},ue=Math.pow(2,-42),me={APPROXIMATED_PI_ERROR:o._("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>"),EXTRA_SYMBOLS_ERROR:o._("We could not understand your answer. Please check your answer for extra text or symbols."),NEEDS_TO_BE_SIMPLFIED_ERROR:o._("Your answer is almost correct, but it needs to be simplified."),MISSING_PERCENT_ERROR:o._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end."),MULTIPLICATION_SIGN_ERROR:o._("I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign."),WRONG_CASE_ERROR:o._("Your answer includes use of a variable with the wrong case."),WRONG_LETTER_ERROR:o._("Your answer includes a wrong variable letter.")},ge={predicate:{defaultForms:"integer, proper, improper, mixed, decimal",createValidatorFunctional:function(e,t){var r;t=h.extend({simplify:"required",ratio:!1,forms:ge.predicate.defaultForms},t),r=h.isArray(t.forms)?t.forms:t.forms.split(/\s*,\s*/),void 0===t.inexact&&(t.maxError=0),t.maxError=+t.maxError+ue,h.contains(r,"percent")&&(r=h.without(r,"percent")).push("percent");var i=function(e){var r=(e=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").replace(/(^\s*)|(\s*$)/gi,"")).match(/^([+-]?\d+)\s*\/\s*([+-]?\d+)$/),i=e.match(/^([+-]?)\\frac\{([+-]?\d+)\}\{([+-]?\d+)\}$/),n=parseInt(e,10);if(r||i){var o,s,a=!0;return r?(o=parseFloat(r[1]),s=parseFloat(r[2])):(o=parseFloat(i[2]),"-"===i[1]&&(o<0&&(a=!1),o=-o),s=parseFloat(i[3])),[{value:o/s,exact:a=a&&s>0&&(t.ratio||1!==s)&&1===de.getGCD(o,s)}]}return isNaN(n)||""+n!==e?[]:[{value:n,exact:!0}]},n={integer:function(e){var t=n.decimal(e),r=n.decimal(e,1);return null!=t[0].value&&t[0].value===r[0].value||null!=t[1].value&&t[1].value===r[1].value?t:[]},proper:function(e){return y.map(i(e),(function(e){return Math.abs(e.value)<1?[e]:[]}))},improper:function(e){return y.map(i(e),(function(e){return Math.abs(e.value)>=1?[e]:[]}))},pi:function(e){var t,r=[];if(t=(e=e.replace(/\u2212/,"-")).match(/^([+-]?)\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))r=[{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))r=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 o=parseFloat(t[1]+"1"),s=parseFloat(t[2]),a=parseFloat(t[3]),l=parseFloat(t[4]);r=[{value:o*(s+a/l),exact:a<l&&1===de.getGCD(a,l)}]}else if(t=e.match(/^([+-]?\s*\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\s*\d+))?$/i))r=i(t[1]+"/"+t[3]);else if(t=e.match(/^([+-]?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\d+))?$/i))r=i(t[1]+"1/"+t[3]);else if("0"===e)r=[{value:0,exact:!0}];else{if(!(t=e.match(/^(.+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))){r=h.reduce(ge.predicate.defaultForms.split(/\s*,\s*/),(function(t,r){return t.concat(n[r](e))}),[]);var p=!1,c=parseFloat(e);if(isNaN(c)||c===parseInt(e))e.match(/\/\s*7/)&&(p=!0);else{var d=Math.PI/12,u=d*Math.round(c/d);Math.abs(c-u)<.01&&(p=!0)}return p&&h.each(r,(function(e){e.piApprox=!0})),r}r=n.decimal(t[1])}var m=Math.PI;return e.match(/\\?tau|t|\u03c4/)&&(m=2*Math.PI),e.match(/pau/)&&(m=1.5*Math.PI),y.each(r,(function(e,t){t.value*=m})),r},coefficient:function(e){var t=[];return""===(e=e.replace(/\u2212/,"-"))?t=[{value:1,exact:!0}]:"-"===e&&(t=[{value:-1,exact:!0}]),t},log:function(e){var t,r=[];return(t=(e=(e=e.replace(/\u2212/,"-")).replace(/[ \(\)]/g,"")).match(/^log\s*(\S+)\s*$/i))?r=n.decimal(t[1]):"0"===e&&(r=[{value:0,exact:!0}]),r},percent:function(e){e=y.trim(e);var t=!1;e.indexOf("%")===e.length-1&&(e=y.trim(e.substring(0,e.length-1)),t=!0);var r=n.decimal(e);return y.each(r,(function(e,r){r.exact=t,r.value=r.value/100})),r},mixed:function(e){var t=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?)(\d+)\s+(\d+)\s*\/\s*(\d+)$/);if(t){var r=parseFloat(t[1]+"1"),i=parseFloat(t[2]),n=parseFloat(t[3]),o=parseFloat(t[4]);return[{value:r*(i+n/o),exact:n<o&&1===de.getGCD(n,o)}]}return[]},decimal:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e10,i=function(e){var i=(e=y.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?(?:\d{1,3}(?:[, ]?\d{3})*\.?|\d{0,3}(?:[, ]?\d{3})*\.(?:\d{3}[, ]?)*\d{1,3}))$/),n=e.match(/^0[0,]*,/);if(i&&!n){var o=parseFloat(i[1].replace(/[, ]/g,""));return void 0===t.inexact&&(o=Math.round(o*r)/r),o}},n=function(e){return e=e.replace(/([\.,])/g,(function(e,t){return"."===t?",":"."})),i(e)};return[{value:i(e),exact:!0},{value:n(e),exact:!0}]}};return function(i){var o=null!=t.fallback?""+t.fallback:"",s={empty:""===(i=y.trim(i)||o),correct:!1,message:null,guess:i};if(y.each(r,(function(r,o){for(var a=n[o](i),l=0,p=a.length;l<p;l++){var h=a[l].value,c=a[l].exact,d=a[l].piApprox;if(e(h,t.maxError))return c||"optional"===t.simplify?(s.correct=!0,s.message=t.message||null,s.empty=!1):"percent"===o?(s.empty=!0,s.message=me.MISSING_PERCENT_ERROR):("enforced"!==t.simplify&&(s.empty=!0),s.message=me.NEEDS_TO_BE_SIMPLFIED_ERROR),!1;d&&e(h,Math.abs(.001*h))&&(s.empty=!0,s.message=me.APPROXIMATED_PI_ERROR)}})),!1===s.correct){var a=!1;if(h.each(n,(function(e){h.any(e(i),(function(e){return null!=e.value&&!h.isNaN(e.value)}))&&(a=!0)})),!a)return s.empty=!0,s.message=me.EXTRA_SYMBOLS_ERROR,s}return s}}},number:{convertToPredicate:function(e,t){var r=parseFloat(y.trim(e));return[function(e,t){return Math.abs(e-r)<t},y.extend({},t,{type:"predicate"})]},createValidatorFunctional:function(e,t){return ge.predicate.createValidatorFunctional(...ge.number.convertToPredicate(e,t))}},expression:{parseSolution:function(t,r){var i=e.parse(t,r);if(!i.parsed)throw new ce("The provided solution ("+t+") didn't parse.",pe.InvalidInput);if(r.simplified&&!i.expr.isSimplified())throw new ce("The provided solution ("+t+") isn't fully expanded and simplified.",pe.InvalidInput);return i=i.expr},createValidatorFunctional:function(t,r){return function(i){var n={empty:!1,correct:!1,message:null,guess:i,ungraded:!1};if(!i)return n.empty=!0,n;var o=e.parse(i,r);if(!o.parsed)return n.empty=!0,n;"string"==typeof t&&(t=ge.expression.parseSolution(t,r));var s=e.compare(o.expr,t,r);if(s.equal)n.correct=!0;else if(s.wrongVariableNames||s.wrongVariableCase)n.ungraded=!0,n.message=s.wrongVariableCase?me.WRONG_CASE_ERROR:me.WRONG_LETTER_ERROR,n.suppressAlmostThere=!0;else if(s.message)n.message=s.message;else{var a=e.parse(i.replace(/[xX]/g,"*"),r);if(a.parsed){var l=e.compare(a.expr,t,r);l.equal?(n.ungraded=!0,n.message=me.MULTIPLICATION_SIGN_ERROR):l.message&&(n.message=l.message+" Also, I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign.")}}return n}}}},fe=!1,ve=/^web\+graphie:/,ye=/^file\+graphie:/;var be=/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/,xe=new RegExp(be.source+"$"),we=function(e){var t=e;return function(){var e=t;return(t=268435455&(e=4294967295&(3042594569^(e=(e=4294967295&((e=(e=4294967295&(3345072700^(e=e+2127912214+(e<<12)&4294967295)^e>>>19))+374761393+(e<<5)&4294967295)+3550635116^e<<9))+4251993797+(e<<3)&4294967295)^e>>>16)))/268435456}};var Ce="x".split(/(.)/g).length?function(e,t){return e.split(t)}:function(e,t){for(var r,i=[],n=t.lastIndex=0;r=t.exec(e);){var o=r;i.push(e.slice(n,o.index)),i.push(...o.slice(1)),n=o.index+o[0].length}return i.push(e.slice(n)),i};function ke(e,t){var r=e*t,i=e,n=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=Math.floor(i/n);return r<25?e:r<50?5===o?e:e/2:1===o?e/2:2===o?e/4:5===o?e/5:void 0}function Ee(e,t){return t/(e[1]-e[0])}function Se(e,t){var r=Math.pow(10,Math.floor(Math.log(e/t)/Math.LN10)),i=t/e*r;return i<=.15?r*=10:i<=.35?r*=5:i<=.75&&(r*=2),r}var _e=(e,t)=>{var r=t[1]-t[0],i=r/e;return i<=10?e:i<=20?2*e:Se(r,10)};var Me={UNSAFE_componentWillMount:function(){var e={};h.each(this.deprecatedProps,(function(t,r){h.has(this.props,r)&&h.extend(e,t(this.props))}),this),h.isEmpty(e)||(h.extend(this.props,e),setTimeout(this.props.onChange,0,e))}};function Te(e,t){return"number"==typeof e&&"number"==typeof t?Math.abs(e-t)<1e-9:e===t}var Ie={pointerDown:!1,currentTouchIdentifier:null};function Pe(e){return Ne(e)?Re(e):e}function Ne(e){return ve.test(e)||ye.test(e)}function Ae(e){return e.replace(ve,"https:").replace(ye,"file:")}function Re(e){return Ae(e)+".svg"}var Fe={getWordBeforeCursor:function(e){var t=e.value,r=e.selectionStart-1,i=Math.max(t.lastIndexOf("\n",r),t.lastIndexOf(" ",r))+1;return{string:t.substring(i,r+1),pos:{start:i,end:r}}},moveCursor:function(e,t){e.selectionStart=t,e.selectionEnd=t}},Oe=we(4294967295&(new Date).getTime()),De={inputPathsEqual:function(e,t){return null==e||null==t?null==e==(null==t):e.length===t.length&&e.every(((e,r)=>t[r]===e))},nestedMap:function e(t,r,i){return Array.isArray(t)?h.map(t,(function(t){return e(t,r)})):r.call(i,t)},rWidgetRule:be,rTypeFromWidgetId:/^([a-z-]+) ([0-9]+)$/,rWidgetParts:xe,snowman:"☃",noScore:{type:"points",earned:0,total:0,message:null},seededRNG:we,shuffle:function(e,t){var r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=h.clone(e);if(!n.length||h.all(n,(function(e){return h.isEqual(e,n[0])})))return n;r="function"==typeof t?t:we(t);do{for(var o=n.length;o>0;o--){var s=Math.floor(r()*o),a=n[s];n[s]=n[o-1],n[o-1]=a}}while(i&&h.isEqual(e,n));return n},split:Ce,combineScores:function(e,t){var r;if("points"===e.type&&"points"===t.type)return r=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"points",earned:e.earned+t.earned,total:e.total+t.total,message:r};if("points"===e.type&&"invalid"===t.type)return t;if("invalid"===e.type&&"points"===t.type)return e;if("invalid"===e.type&&"invalid"===t.type)return{type:"invalid",message:r=e.message&&t.message&&e.message!==t.message?null:e.message||t.message};throw new ce("PerseusScore with unknown type encountered",pe.InvalidInput,{metadata:{scoreA:JSON.stringify(e),scoreB:JSON.stringify(t)}})},keScoreFromPerseusScore:function(e,t,r){if("points"===e.type)return{empty:!1,correct:e.earned>=e.total,message:e.message,guess:t,state:r};if("invalid"===e.type)return{empty:!0,correct:!1,message:e.message,suppressAlmostThere:e.suppressAlmostThere,guess:t,state:r};throw new ce("Invalid score type: "+e.type,pe.InvalidInput,{metadata:{score:JSON.stringify(e),guess:JSON.stringify(t),state:JSON.stringify(r)}})},firstNumericalParse:function(e){var t;return ge.predicate.createValidatorFunctional((function(e){return t=e,!0}),{simplify:"optional",inexact:!0,forms:"integer, proper, improper, pi, log, mixed, decimal"})(e),t},stringArrayOfSize:function(e){return h(e).times((function(){return""}))},gridDimensionConfig:function(e,t,r,i){var n=Ee(t,r);return{scale:n,tickStep:e/i,unityLabel:e*n>30}},getGridStep:function(e,t,r){return h(2).times((function(i){var n=Ee(e[i],r);return ke(t[i],n)}))},snapStepFromGridStep:function(e){return[e[0]/2,e[1]/2]},scaleFromExtent:Ee,tickStepFromExtent:function(e,t){var r=e[1]-e[0];return Se(r,(15<r&&r<=20?23:r>100||r<5?10:16)*(t/500))},gridStepFromTickStep:ke,tickStepFromNumTicks:Se,constrainedTickStepsFromTickSteps:function(e,t){return[_e(e[0],t[0]),_e(e[1],t[1])]},DeprecationMixin:Me,eq:Te,deepEq:function e(t,r){if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return!1;for(var i=0;i<t.length;i++)if(!e(t[i],r[i]))return!1;return!0}return!Array.isArray(t)&&!Array.isArray(r)&&("function"==typeof t&&"function"==typeof r?Te(t,r):"function"!=typeof t&&"function"!=typeof r&&("object"==typeof t&&"object"==typeof r&&t&&r?t===r||h.all(t,(function(t,i){return e(r[i],t)}))&&h.all(r,(function(r,i){return e(t[i],r)})):!("object"==typeof t&&t||"object"==typeof r&&r)&&Te(t,r)))},parseQueryString:function(e){e=e||window.location.search.substring(1);for(var t,r={},i=/\+/g,n=/([^&=]+)=?([^&]*)/g,o=function(e){return decodeURIComponent(e.replace(i," "))};t=n.exec(e);){var s=t;r[o(s[1])]=o(s[2])}return r},updateQueryString:function(e,t,r){r=encodeURIComponent(r);var i=new RegExp("([?&])"+t+"=.*?(&|$)","i"),n=-1!==e.indexOf("?")?"&":"?";return e.match(i)?e.replace(i,"$1"+t+"="+r+"$2"):e+n+t+"="+r},strongEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/['()!]/g,window.escape).replace(/\*/g,"%2A")},widgetShouldHighlight:function(e){if(!e)return!1;switch(e.type){case"measurer":case"protractor":return!0;default:return!1}},scoreIsEmpty:function(e){return"invalid"===e.type&&(!e.message||0===e.message.length)},touchHandlers:Ie,resetTouchHandlers:function(){Object.assign(Ie,{pointerDown:!1,currentTouchIdentifier:null})},extractPointerLocation:function(e){var t;if(Ie.pointerDown){if(null!=Ie.currentTouchIdentifier)for(var r=e.changedTouches?e.changedTouches.length:0,i=0;i<r;i++)e.changedTouches[i].identifier===Ie.currentTouchIdentifier&&(t=e.changedTouches[i]);else t=e;var n="touchend"===e.type||"touchcancel"===e.type;t&&n&&(Ie.pointerDown=!1,Ie.currentTouchIdentifier=null)}else Ie.pointerDown=!0,e.changedTouches?(t=e.changedTouches[0],Ie.currentTouchIdentifier=t.identifier):t=e;if(t)return{left:t.pageX,top:t.pageY}},supportsPassiveEvents:()=>{try{var e=Object.defineProperty({},"passive",{get:function(){fe=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(e){}return fe},captureScratchpadTouchStart:function(e){e.stopPropagation()},getImageSize:function(e,t){var r=new Image;r.onload=function(){var e;0===r.width&&0===r.height?(null===(e=document.body)||void 0===e||e.appendChild(r),h.defer((function(){var e;t(r.clientWidth,r.clientHeight),null===(e=document.body)||void 0===e||e.removeChild(r)}))):t(r.width,r.height)},r.src=Pe(e)},getRealImageUrl:Pe,isLabeledSVG:Ne,getBaseUrl:Ae,getSvgUrl:Re,getDataUrl:function(e){return Ae(e)+"-data.json"},textarea:Fe,unescapeMathMode:e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e,random:Oe},Le=(e,t,r)=>{var i=e.length,n=0;if(r){if(t.inline)return null;for(;n<i&&" "===e[n];)n++}if(!(n<i&&"$"===e[n]))return null;for(var o=++n,s=0;n<i;){var a=e[n];if("\\"===a)n++;else{if(s<=0&&"$"===a){var l=n+1;if(r){var p=/^(?: *\n){2,}/.exec(e.slice(l));l=p?l+p[0].length:null}return l?[e.substring(0,l),e.substring(o,n)]:null}if("{"===a)s++;else if("}"===a)s--;else if("\n"===a&&"\n"===e[n-1])return null}n++}return null},Be=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n("+u.defaultRules.nptable.match.regex.source.substring(1)+")"),ze=u.blockRegex(/^(crwdns.*)\n\s*\n/),He=G(G({},u.defaultRules),{},{columns:{order:-2,match:u.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:(e,t,r)=>({col1:t(e[1],r),col2:t(e[2],r)})},crowdinId:{order:-1,match:(e,t,r)=>t.isJipt?ze(e,t,r):null,parse:(e,t,r)=>({id:e[1]})},titledTable:{order:u.defaultRules.nptable.order-.5,match:u.blockRegex(Be),parse:(e,t,r)=>{var i=u.parseInline(t,e[1],r),n=e.slice(2);return{title:i,table:u.defaultRules.nptable.parse(n,t,r)}}},widget:{order:u.defaultRules.link.order-.75,match:u.inlineRegex(De.rWidgetRule),parse:(e,t,r)=>({id:e[1],widgetType:e[2]})},blockMath:{order:u.defaultRules.codeBlock.order+.5,match:(e,t)=>Le(e,t,!0),parse:(e,t,r)=>({content:e[1]})},math:{order:u.defaultRules.link.order-.25,match:(e,t)=>Le(e,t,!1),parse:(e,t,r)=>({content:e[1]})},unescapedDollar:{order:u.defaultRules.link.order-.24,match:u.inlineRegex(/^(?!\\)\$/),parse:(e,t,r)=>({})},fence:G(G({},u.defaultRules.fence),{},{parse:(e,t,r)=>{var i=u.defaultRules.fence.parse(e,t,r);return"alt"===i.lang?{type:"codeBlock",lang:"alt",content:t(i.content+"\n\n",r)}:i}}),blockQuote:G(G({},u.defaultRules.blockQuote),{},{match:u.blockRegex(/^ *>[^\n]+(\n( *>)?[^\n]+)*\n{2,}/)}),list:G(G({},u.defaultRules.list),{},{match:(e,t,r)=>t.isJipt?null:u.defaultRules.list.match(e,t,r)}),lint:{order:1e3,match:e=>null,parse:(e,t,r)=>({})}});u.parserFor(He);var We=G(G({},He),{},{columns:G(G({},He.columns),{},{react:(e,t,r)=>a.createElement("div",{className:"perseus-two-columns",key:r.key},a.createElement("div",{className:"perseus-column"},a.createElement("div",{className:"perseus-column-content"},t(e.col1,r))),a.createElement("div",{className:"perseus-column"},a.createElement("div",{className:"sat-header-grafting-area"}),a.createElement("div",{className:"perseus-column-content"},a.createElement("div",{className:"sat-skill-subscore-grafting-area"}),t(e.col2,r),a.createElement("div",{className:"sat-grafting-area"}))))}),crowdinId:G(G({},He.crowdinId),{},{react:(e,t,r)=>e.id}),table:G(G({},He.table),{},{react:function(e,t,r){var i=u.defaultRules.table.react(e,t,r);return r.isMobile?a.cloneElement(i,{tabIndex:0}):i}}),titledTable:G(G({},He.titledTable),{},{react:(e,t,r)=>{var i;if(e.table)if("lint"===e.table.type){var n;i="table"===(null===(n=e.table.content)||void 0===n?void 0:n.type)?We.lint.react(G(G({},e.table),{},{content:G(G({},e),{},{table:e.table.content})}),t,G(G({},r),{},{unwrapTitledTableContents:!0})):We.lint.react(e.table,t,r)}else{var o=u.defaultRules.table.react(e.table,t,r),s=a.createElement("caption",{key:"caption",className:"perseus-table-title"},t(e.title,r));i=a.cloneElement(o,null,[s,...o.props.children])}else i="//invalid table//";return r.unwrapTitledTableContents?i:a.createElement("div",{className:"perseus-titled-table",key:r.key},i)}}),widget:G(G({},He.widget),{},{react:(e,t,r)=>a.createElement("em",{key:r.key},o.doNotTranslate("[Widget: ",e.id,"]"))}),blockMath:G(G({},He.blockMath),{},{react:(e,t,r)=>{var{TeX:i}=ae();return a.createElement(i,{key:r.key},e.content)}}),math:G(G({},He.math),{},{react:(e,t,r)=>{var{TeX:i}=ae();return a.createElement(i,{key:r.key},e.content)}}),unescapedDollar:G(G({},He.unescapedDollar),{},{react:(e,t,r)=>"$"}),link:G(G({},He.link),{},{react:function(e,t,r){var i=u.defaultRules.link.react(e,t,r),n=i.props.href,o=null;!!n&&n.match(/https?:\/\/[^\/]*khanacademy.org|^\//)||(o="noopener noreferrer");var s=G(G({},i.props),{},{target:"_blank",href:n,rel:o});return r.baseElements&&r.baseElements.Link?r.baseElements.Link(s):a.cloneElement(i,s)}}),codeBlock:G(G({},He.codeBlock),{},{react:(e,t,r)=>"alt"===e.lang?a.createElement("div",{key:r.key,className:"perseus-markdown-alt perseus-sr-only"},t(e.content,r)):u.defaultRules.codeBlock.react(e,t,r)}),lint:G(G({},He.lint),{},{react:(e,t,r)=>a.createElement(ne,{message:e.message,ruleName:e.ruleName,inline:qe(e.content),blockHighlight:e.blockHighlight,insideTable:e.insideTable,severity:e.severity},t(e.content,r))})});function qe(e){return!!(e&&e.type&&Ue.hasOwnProperty(e.type))}var Ue={text:!0,math:!0,unescapedDollar:!0,link:!0,img:!0,strong:!0,u:!0,em:!0,del:!0,code:!0},Ge=u.parserFor(We),Ve=(e,t)=>Ge(e+"\n\n",G(G({},t),{},{inline:!1})),je=(e,t)=>{h.isArray(e)?h.each(e,(e=>je(e,t))):h.isObject(e)&&(t(e),"table"===e.type?(je(e.header,t),je(e.cells,t)):"list"===e.type?je(e.items,t):"titledTable"===e.type?je(e.table,t):"columns"===e.type?(je(e.col1,t),je(e.col2,t)):h.isArray(e.content)&&je(e.content,t))},Ye=e=>{if(h.isArray(e))return h.flatten(h.map(e,Ye));if(e.content&&h.isString(e.content))return-1!==e.type.toLowerCase().indexOf("code")?["",e.content,""]:[e.content.replace(/\s+/g," ")];var t=h.chain(e).values().flatten().filter((e=>null!=e&&h.has(e,"type"))).value();if(!t.length)return[];var r=Ye(t);if("paragraph"===e.type&&r.length){r[0]=r[0].replace(/^\s+/,"");var i=r.length-1;r[i]=r[i].replace(/\s+$/,"")}return r},$e={characterCount:e=>{var t=Ve(e);return Ye(t).join("").length},traverseContent:je,parse:Ve,parseInline:(e,t)=>Ge(e,G(G({},t),{},{inline:!0})),reactFor:u.reactFor,ruleOutput:u.ruleOutput(We,"react"),basicOutput:u.reactFor(u.ruleOutput(We,"react")),sanitizeUrl:u.sanitizeUrl};class Xe{static parse(e){return new Ke(e).parse()}match(e){throw new ce("Selector subclasses must implement match()",pe.NotAllowed)}toString(){return"Unknown selector class"}}class Ke{constructor(e){j(this,"tokens",void 0),j(this,"tokenIndex",void 0),e=e.trim().replace(/\s+/g," "),this.tokens=e.match(Ke.TOKENS)||[],this.tokenIndex=0}nextToken(){return this.tokens[this.tokenIndex]||""}consume(){this.tokenIndex++}isIdentifier(){var e=this.tokens[this.tokenIndex][0];return e>="a"&&e<="z"||e>="A"&&e<="Z"}skipSpace(){for(;" "===this.nextToken();)this.consume()}parse(){var e=this.parseTreeSelector(),t=this.nextToken();if(!t)return e;for(var r=[e];t;){if(","!==t)throw new Ze("Expected comma");this.consume(),r.push(this.parseTreeSelector()),t=this.nextToken()}return new Je(r)}parseTreeSelector(){this.skipSpace();for(var e=this.parseNodeSelector();;){var t=this.nextToken();if(!t||","===t)break;if(" "===t)this.consume(),e=new rt(e,this.parseNodeSelector());else if(">"===t)this.consume(),e=new it(e,this.parseNodeSelector());else if("+"===t)this.consume(),e=new nt(e,this.parseNodeSelector());else{if("~"!==t)throw new Ze("Unexpected token: "+t);this.consume(),e=new ot(e,this.parseNodeSelector())}}return e}parseNodeSelector(){this.skipSpace();var e=this.nextToken();if("*"===e)return this.consume(),new Qe;if(this.isIdentifier())return this.consume(),new et(e);throw new Ze("Expected node type")}}j(Ke,"TOKENS",void 0),Ke.TOKENS=/([a-zA-Z][\w-]*)|(\d+)|[^\s]|(\s(?=[a-zA-Z\*]))/g;class Ze extends Error{constructor(e){super(e)}}class Je extends Xe{constructor(e){super(),j(this,"selectors",void 0),this.selectors=e}match(e){for(var t=0;t<this.selectors.length;t++){var r=this.selectors[t].match(e);if(r)return r}return null}toString(){for(var e="",t=0;t<this.selectors.length;t++)e+=t>0?", ":"",e+=this.selectors[t].toString();return e}}class Qe extends Xe{match(e){return[e.currentNode()]}toString(){return"*"}}class et extends Xe{constructor(e){super(),j(this,"type",void 0),this.type=e}match(e){var t=e.currentNode();return t.type===this.type?[t]:null}toString(){return this.type}}class tt extends Xe{constructor(e,t){super(),j(this,"left",void 0),j(this,"right",void 0),this.left=e,this.right=t}}class rt extends tt{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t)for(e=e.clone();e.hasParent();){e.goToParent();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" "+this.right.toString()}}class it extends tt{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t&&e.hasParent()){(e=e.clone()).goToParent();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" > "+this.right.toString()}}class nt extends tt{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t&&e.hasPreviousSibling()){(e=e.clone()).goToPreviousSibling();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" + "+this.right.toString()}}class ot extends tt{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t)for(e=e.clone();e.hasPreviousSibling();){e.goToPreviousSibling();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" ~ "+this.right.toString()}}class st{constructor(e,t,r,i,n,o){var s=this;if(j(this,"name",void 0),j(this,"severity",void 0),j(this,"selector",void 0),j(this,"pattern",void 0),j(this,"lint",void 0),j(this,"applies",void 0),j(this,"message",void 0),!r&&!i)throw new ce("Lint rules must have a selector or pattern",pe.InvalidInput,{metadata:{name:e}});this.name=e||"unnamed rule",this.severity=t||st.Severity.BULK_WARNING,this.selector=r||st.DEFAULT_SELECTOR,this.pattern=i||null,"function"==typeof n?(this.lint=n,this.message=null):(this.lint=function(){return s._defaultLintFunction(...arguments)},this.message=n),this.applies=o||function(){return!0}}static makeRule(e){return new st(e.name,e.severity,e.selector?Xe.parse(e.selector):null,st.makePattern(e.pattern),e.lint||e.message,e.applies)}check(e,t,r,i){var n,o=this.selector.match(t);if(!o)return null;if(!(n=this.pattern?r.match(this.pattern):st.FakePatternMatch(r,r,0)))return null;try{var s=this.lint(t,r,o,n,i);return s?"string"==typeof s?{rule:this.name,severity:this.severity,message:s,start:0,end:r.length}:{rule:this.name,severity:this.severity,message:s.message,start:s.start,end:s.end}:null}catch(e){return{rule:"lint-rule-failure",message:"Exception in rule ".concat(this.name,": ").concat(e.message,"\nStack trace:\n").concat(e.stack),start:0,end:r.length}}}_defaultLintFunction(e,t,r,i,n){return{message:this.message||"",start:i.index,end:i.index+i[0].length}}static makePattern(e){if(!e)return null;if(e instanceof RegExp)return e;if("/"===e[0]){var t=e.lastIndexOf("/"),r=e.substring(1,t),i=e.substring(t+1);return new RegExp(r,i)}return new RegExp(e)}static FakePatternMatch(e,t,r){var i=[t];return i.index=r,i.input=e,i}}j(st,"DEFAULT_SELECTOR",void 0),j(st,"Severity",{ERROR:1,WARNING:2,GUIDELINE:3,BULK_WARNING:4}),st.DEFAULT_SELECTOR=Xe.parse("text");var at=/\/\/([^\/]+)/;var lt=st.makeRule({name:"absolute-url",severity:st.Severity.GUIDELINE,selector:"link, image",lint:function(e,t,r,i){var n=function(e){if(!e)return"";var t=e.match(at);return t?t[1]:""}(r[0].target);if("khanacademy.org"===n||n.endsWith(".khanacademy.org"))return"Don't use absolute URLs:\nWhen linking to KA content or images, omit the\nhttps://www.khanacademy.org URL prefix.\nUse a relative URL beginning with / instead."}}),pt=st.makeRule({name:"blockquoted-math",severity:st.Severity.WARNING,selector:"blockQuote math, blockQuote blockMath",message:"Blockquoted math:\nmath should not be indented."}),ht=st.makeRule({name:"blockquoted-widget",severity:st.Severity.WARNING,selector:"blockQuote widget",message:"Blockquoted widget:\nwidgets should not be indented."}),ct=st.makeRule({name:"double-spacing-after-terminal",severity:st.Severity.BULK_WARNING,selector:"paragraph",pattern:/[.!\?] {2}/i,message:"Use a single space after a sentence-ending period, or\nany other kind of terminal punctuation."}),dt=st.makeRule({name:"extra-content-spacing",selector:"paragraph",pattern:/\s+$/,applies:function(e){return"article"===e.contentType},message:"No extra whitespace at the end of content blocks."}),ut=st.makeRule({name:"heading-level-1",severity:st.Severity.WARNING,selector:"heading",lint:function(e,t,r,i){if(1===r[0].level)return"Don't use level-1 headings:\nBegin headings with two or more # characters."}}),mt=st.makeRule({name:"heading-level-skip",severity:st.Severity.WARNING,selector:"heading ~ heading",lint:function(e,t,r,i){var n=r[1],o=r[0];if(n.level>o.level+1)return"Skipped heading level:\nthis heading is level ".concat(n.level," but\nthe previous heading was level ").concat(o.level)}}),gt=st.makeRule({name:"heading-sentence-case",severity:st.Severity.GUIDELINE,selector:"heading",pattern:/^\W*[a-z]/,message:"First letter is lowercase:\nthe first letter of a heading should be capitalized."}),ft={and:!0,nor:!0,but:!0,the:!0,for:!0};var vt=st.makeRule({name:"heading-title-case",severity:st.Severity.GUIDELINE,selector:"heading",pattern:/[^\s:]\s+[A-Z]+[a-z]/,locale:"en",lint:function(e,t,r,i){var n=t.trim().split(/\s+/);if(n.shift(),(n=n.filter((e=>e.length>2&&!ft.hasOwnProperty(e)))).length>=3&&n.every((e=>{return(t=e[0])===t.toUpperCase();var t})))return"Title-case heading:\nThis heading appears to be in title-case, but should be sentence-case.\nOnly capitalize the first letter and proper nouns."}}),yt=st.makeRule({name:"image-alt-text",severity:st.Severity.WARNING,selector:"image",lint:function(e,t,r,i){var n=r[0];return n.alt&&n.alt.trim()?n.alt.length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(n.alt.length," characters long."):void 0:"Images should have alt text:\nfor accessibility, all images should have alt text.\nSpecify alt text inside square brackets after the !."}}),bt=st.makeRule({name:"image-in-table",severity:st.Severity.BULK_WARNING,selector:"table image",message:"Image in table:\ndo not put images inside of tables."}),xt=st.makeRule({name:"image-spaces-around-urls",severity:st.Severity.ERROR,selector:"image",lint:function(e,t,r,i,n){var o=r[0].target;if(n&&n.content){var s=n.content.indexOf(o);if(-1===s)return;if("("!==n.content[s-1]||")"!==n.content[s+o.length])return"Whitespace before or after image url:\nFor images, don't include any space or newlines after '(' or before ')'.\nWhitespace in image URLs causes translation difficulties."}}}),wt=st.makeRule({name:"image-widget",severity:st.Severity.WARNING,selector:"widget",lint:function(e,t,r,i,n){if("image"===e.currentNode().widgetType){var o=n&&n.widgets&&n.widgets[e.currentNode().id];if(o){var s=o.options.alt;return s?s.trim().length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(s.trim().length," characters long."):o.options.caption&&o.options.caption.match(/[^\\]\$/)?"No math in image captions:\nDon't include math expressions in image captions.":void 0:'Images should have alt text:\nfor accessibility, all images should have a text description.\nAdd a description in the "Alt Text" box of the image widget.'}}}}),Ct=st.makeRule({name:"link-click-here",severity:st.Severity.WARNING,selector:"link",pattern:/click here/i,message:'Inappropriate link text:\nDo not use the words "click here" in links.'}),kt=st.makeRule({name:"long-paragraph",severity:st.Severity.GUIDELINE,selector:"paragraph",pattern:/^.{501,}/,lint:function(e,t,r,i){return"Paragraph too long:\nThis paragraph is ".concat(t.length," characters long.\nShorten it to 500 characters or fewer.")}}),Et=st.makeRule({name:"math-adjacent",severity:st.Severity.WARNING,selector:"blockMath+blockMath",message:"Adjacent math blocks:\ncombine the blocks between \\begin{align} and \\end{align}"}),St=st.makeRule({name:"math-align-extra-break",severity:st.Severity.WARNING,selector:"blockMath",pattern:/(\\{2,})\s*\\end{align}/,message:"Extra space at end of block:\nDon't end an align block with backslashes"}),_t=st.makeRule({name:"math-align-linebreaks",severity:st.Severity.WARNING,selector:"blockMath",pattern:/\\begin{align}[\s\S]*\\\\[\s\S]+\\end{align}/,lint:function(e,t,r,i){for(var n=i[0];n.length;){var o=n.indexOf("\\\\");if(-1===o)return null;var s=(n=n.substring(o+2)).match(/^\s*\\\\\s*(?!\\\\)/);if(!s)return"Use four backslashes between lines of an align block";n=n.substring(s[0].length)}}}),Mt=st.makeRule({name:"math-empty",severity:st.Severity.WARNING,selector:"math, blockMath",pattern:/^$/,message:"Empty math: don't use $$ in your markdown."}),Tt=st.makeRule({name:"math-font-size",severity:st.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\(tiny|Tiny|small|large|Large|LARGE|huge|Huge|scriptsize|normalsize)\s*{/,message:"Math font size:\nDon't change the default font size with \\Large{} or similar commands"}),It=st.makeRule({name:"math-frac",severity:st.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\frac[ {]/,message:"Use \\dfrac instead of \\frac in your math expressions."}),Pt=st.makeRule({name:"math-nested",severity:st.Severity.ERROR,selector:"math, blockMath",pattern:/\\text{[^$}]*\$[^$}]*\$[^}]*}/,message:"Nested math:\nDon't nest math expressions inside \\text{} blocks"}),Nt=st.makeRule({name:"math-starts-with-space",severity:st.Severity.GUIDELINE,selector:"math, blockMath",pattern:/^\s*(~|\\qquad|\\quad|\\,|\\;|\\:|\\ |\\!|\\enspace|\\phantom)/,message:"Math starts with space:\nmath should not be indented. Do not begin math expressions with\nLaTeX space commands like ~, \\;, \\quad, or \\phantom"}),At=st.makeRule({name:"math-text-empty",severity:st.Severity.WARNING,selector:"math, blockMath",pattern:/\\text{\s*}/,message:"Empty \\text{} block in math expression"}),Rt=st.makeRule({name:"math-without-dollars",severity:st.Severity.GUIDELINE,pattern:/\\\w+{[^}]*}|{|}/,message:"This looks like LaTeX:\ndid you mean to put it inside dollar signs?"}),Ft=st.makeRule({name:"nested-lists",severity:st.Severity.WARNING,selector:"list list",message:"Nested lists:\nnested lists are hard to read on mobile devices;\ndo not use additional indentation."}),Ot=st.makeRule({name:"profanity",pattern:/\b(shit|piss|fuck|cunt|cocksucker|motherfucker|tits)\b/i,message:"Avoid profanity"}),Dt=st.makeRule({name:"table-missing-cells",severity:st.Severity.WARNING,selector:"table",lint:function(e,t,r,i){for(var n=r[0],o=n.header.length,s=n.cells.map((e=>e.length)),a=0;a<s.length;a++)if(s[a]!==o)return"Table rows don't match header:\nThe table header has ".concat(o," cells, but\nRow ").concat(a+1," has ").concat(s[a]," cells.")}}),Lt=st.makeRule({name:"unbalanced-code-delimiters",severity:st.Severity.ERROR,pattern:/[`~]+/,message:"Unbalanced code delimiters:\ncode blocks should begin and end with the same type and number of delimiters"}),Bt=[lt,pt,ht,ct,dt,ut,mt,gt,vt,yt,bt,Ct,kt,Et,St,_t,Mt,Tt,It,Pt,Nt,At,Ft,Dt,st.makeRule({name:"unescaped-dollar",severity:st.Severity.ERROR,selector:"unescapedDollar",message:"Unescaped dollar sign:\nDollar signs must appear in pairs or be escaped as \\$"}),st.makeRule({name:"widget-in-table",severity:st.Severity.BULK_WARNING,selector:"table widget",message:"Widget in table:\ndo not put widgets inside of tables."}),Ot,Rt,Lt,xt,wt];class zt{constructor(e){j(this,"root",void 0),this.root=e}static isNode(e){return e&&"object"==typeof e&&"string"==typeof e.type}static isTextNode(e){return zt.isNode(e)&&"text"===e.type&&"string"==typeof e.content}traverse(e){this._traverse(this.root,new Ht(this.root),e)}_traverse(e,t,r){var i="";if(zt.isNode(e)){var n=e;t._containers.push(n),t._ancestors.push(n),"string"==typeof n.content&&(i=n.content),Object.keys(n).forEach((e=>{if("type"!==e){var o=n[e];o&&"object"==typeof o&&(t._indexes.push(e),i+=this._traverse(o,t,r),t._indexes.pop())}})),t._currentNode=t._ancestors.pop(),t._containers.pop(),r(n,t,i)}else if(Array.isArray(e)){var o=e;t._containers.push(o);for(var s=0;s<o.length;)t._indexes.push(s),i+=this._traverse(o[s],t,r),s=t._indexes.pop()+1;t._containers.pop()}return i}}class Ht{constructor(e){j(this,"root",void 0),j(this,"_currentNode",void 0),j(this,"_containers",void 0),j(this,"_indexes",void 0),j(this,"_ancestors",void 0),this.root=e,this._currentNode=null,this._containers=new Wt,this._indexes=new Wt,this._ancestors=new Wt}currentNode(){return this._currentNode||this.root}parent(){return this._ancestors.top()}ancestors(){return this._ancestors.values()}nextSibling(){var e=this._containers.top();if(!e||!Array.isArray(e))return null;var t=this._indexes.top();return e.length>t+1?e[t+1]:null}previousSibling(){var e=this._containers.top();if(!e||!Array.isArray(e))return null;var t=this._indexes.top();return t>0?e[t-1]:null}removeNextSibling(){var e=this._containers.top();if(e&&Array.isArray(e)){var t=this._indexes.top();if(e.length>t+1)return e.splice(t+1,1)[0]}return null}replace(){var e=this._containers.top();if(!e)throw new ce("Can't replace the root of the tree",pe.Internal);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(Array.isArray(e)){var n=this._indexes.top();e.splice(n,1,...r),this._indexes.pop(),this._indexes.push(n+r.length-1)}else{var o=this._indexes.top();0===r.length?delete e[o]:1===r.length?e[o]=r[0]:e[o]=r}}hasPreviousSibling(){return Array.isArray(this._containers.top())&&this._indexes.top()>0}goToPreviousSibling(){if(!this.hasPreviousSibling())throw new ce("goToPreviousSibling(): node has no previous sibling",pe.Internal);this._currentNode=this.previousSibling();var e=this._indexes.pop();this._indexes.push(e-1)}hasParent(){return 0!==this._ancestors.size()}goToParent(){if(!this.hasParent())throw new ce("goToParent(): node has no ancestor",pe.NotAllowed);for(this._currentNode=this._ancestors.pop();this._containers.size()&&this._containers.top()[this._indexes.top()]!==this._currentNode;)this._containers.pop(),this._indexes.pop()}clone(){var e=new Ht(this.root);return e._currentNode=this._currentNode,e._containers=this._containers.clone(),e._indexes=this._indexes.clone(),e._ancestors=this._ancestors.clone(),e}equals(e){return this.root===e.root&&this._currentNode===e._currentNode&&this._containers.equals(e._containers)&&this._indexes.equals(e._indexes)&&this._ancestors.equals(e._ancestors)}}class Wt{constructor(e){j(this,"stack",void 0),this.stack=e?e.slice(0):[]}push(e){this.stack.push(e)}pop(){return this.stack.pop()}top(){return this.stack[this.stack.length-1]}values(){return this.stack.slice(0)}size(){return this.stack.length}toString(){return this.stack.toString()}clone(){return new Wt(this.stack)}equals(e){if(!e||!e.stack||e.stack.length!==this.stack.length)return!1;for(var t=0;t<this.stack.length;t++)if(this.stack[t]!==e.stack[t])return!1;return!0}}var qt=Bt.filter((e=>e.severity<st.Severity.BULK_WARNING));var Ut={runLinter:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:qt,n=[],o=new zt(e);o.traverse(((e,t,r)=>{if(zt.isTextNode(e))for(var i=t.nextSibling();zt.isTextNode(i);)e.content+=i.content,t.removeNextSibling(),i=t.nextSibling()}));var s=[],a=!1;return o.traverse(((e,o,l)=>{var p=[],h=i.filter((e=>e.applies(t))),c=[...t.stack];c.push(e.type);var d=G(G({},t),{},{stack:c.join(".")});if(h.forEach((t=>{var i=t.check(e,o,l,d);i&&((i.start||i.end)&&(i.target=l.substring(i.start,i.end)),n.push(i),r&&p.push(i))})),r&&("table"===e.type?(s.length&&p.push(...s),a=!1,s=[]):a||(a=o.ancestors().some((e=>"table"===e.type))),a&&p.length&&s.push(...p),p.length))if(p.sort(((e,t)=>e.severity-t.severity)),"text"!==e.type||p.length>1)o.replace({type:"lint",content:e,message:p.map((e=>e.message)).join("\n\n"),ruleName:p[0].rule,blockHighlight:d.blockHighlight,insideTable:a,severity:p[0].severity});else{var u=e.content,m=p[0],g=m.start||0,f=m.end||u.length,v=u.substring(0,g),y=u.substring(g,f),b=u.substring(f),x=[];v&&x.push({type:"text",content:v}),x.push({type:"lint",content:{type:"text",content:y},message:m.message,ruleName:m.rule,insideTable:a,severity:m.severity}),b&&x.push({type:"text",content:b}),o.replace(...x)}})),n},parse:$e.parse,pushContextStack:function(e,t){var r=e.stack||[];return G(G({},e),{},{stack:r.concat(t)})},rules:qt},Gt=d.shape({contentType:d.string,highlightLint:d.bool,paths:d.arrayOf(d.string),stack:d.arrayOf(d.string)}),Vt={contentType:"",highlightLint:!1,paths:[],stack:[]},jt={};function Yt(e){if(!jt[e]){var t=y("<span>").text(e).appendTo("body");jt[e]=t.width()+5,t.remove()}return jt[e]}class $t extends a.Component{constructor(){super(...arguments),j(this,"state",{items:this.props.options.concat("")}),j(this,"onChange",((e,t)=>{var r=h.clone(this.state.items);r[e]=t.target.value,e===r.length-1&&(r=r.concat("")),this.setState({items:r}),this.props.onChange(h.compact(r))})),j(this,"onKeyDown",((e,t)=>{var r=t.nativeEvent.keyCode;if(8===r&&""===this.state.items[e]){t.preventDefault();var i=h.clone(this.state.items),n=0===e?0:e-1;e!==i.length-1||0!==e&&""===i[n]?(i.splice(e,1),this.setState({items:i},(function(){v.findDOMNode(this.refs["input_"+n]).focus()}))):v.findDOMNode(this.refs["input_"+n]).focus()}else if(8===r&&1===this.state.items[e].length&&e===this.state.items.length-2){t.preventDefault();var o=h.clone(this.state.items);o.splice(e,1),this.setState({items:o}),this.props.onChange(h.compact(o))}else if(13===r){t.preventDefault();var s=h.clone(this.state.items),a=e+1;e===s.length-2?v.findDOMNode(this.refs["input_"+a]).focus():(s.splice(a,0,""),this.setState({items:s},(function(){v.findDOMNode(this.refs["input_"+a]).focus()})))}}))}UNSAFE_componentWillReceiveProps(e){this.setState({items:e.options.concat("")})}render(){var e=["perseus-text-list-editor","perseus-clearfix","layout-"+this.props.layout].join(" "),t=h.map(this.state.items,(function(e,t){return a.createElement("li",{key:t},a.createElement("input",{ref:"input_"+t,type:"text",value:e,onChange:this.onChange.bind(this,t),onKeyDown:this.onKeyDown.bind(this,t),style:{width:Yt(e)}}))}),this);return a.createElement("ul",{className:e},t)}}j($t,"propTypes",{options:d.array,layout:d.string,onChange:d.func.isRequired}),j($t,"defaultProps",{options:[],layout:"horizontal"});var Xt=[];class Kt extends a.Component{render(){return a.createElement("div",null,this.props.showTitle&&a.createElement("div",{style:{fontSize:14}},"Tags:"),a.createElement($t,{options:this.props.value||Xt,layout:"vertical",onChange:this.props.onChange}))}}j(Kt,"propTypes",{value:d.arrayOf(d.string),onChange:d.func.isRequired,showTitle:d.bool.isRequired}),j(Kt,"defaultProps",{value:Xt,showTitle:!0});var Zt={propTypes:d.shape({isArticle:d.bool.isRequired,satStyling:d.bool.isRequired,onInputError:d.func.isRequired,onFocusChange:d.func.isRequired,staticRender:d.bool.isRequired,GroupMetadataEditor:d.func.isRequired,showAlignmentOptions:d.bool.isRequired,readOnly:d.bool.isRequired,answerableCallback:d.func,getAnotherHint:d.func,interactionCallback:d.func,groupAnnotator:d.func.isRequired,imagePlaceholder:d.node,widgetPlaceholder:d.node,baseElements:d.shape({Link:d.func}),imagePreloader:d.func,trackInteraction:d.func,customKeypad:d.bool,nativeKeypadProxy:d.func,isMobile:d.bool,setDrawingAreaAvailable:d.func,useDraftEditor:d.bool,styling:d.shape({radioStyleVersion:d.oneOf(["intermediate","final"])}),hintProgressColor:d.string,canScrollPage:d.bool,inModal:d.bool,crossOutEnabled:d.bool,editorChangeDelay:d.number}).isRequired,defaults:{isArticle:!1,isMobile:!1,satStyling:!1,onInputError:function(){},onFocusChange:function(){},staticRender:!1,GroupMetadataEditor:Kt,showAlignmentOptions:!1,readOnly:!1,groupAnnotator:function(){return null},baseElements:{Link:e=>a.createElement("a",e)},setDrawingAreaAvailable:function(){},useDraftEditor:!1,styling:{radioStyleVersion:"final"},canScrollPage:!1,inModal:!1,crossOutEnabled:!1,editorChangeDelay:0}},Jt={RENDERER:"perseus-renderer",TWO_COLUMN_RENDERER:"perseus-renderer-two-columns",RESPONSIVE_RENDERER:"perseus-renderer-responsive",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",MOBILE:"perseus-mobile"},Qt={assetStatuses:{},setAssetStatus:(e,t)=>{}},er=a.createContext(Qt);function tr(e,t){var r=window.scrollX,i=window.scrollY,n=document.querySelector("meta[name=viewport]");n?n.setAttribute("content",e):y("head").append('<meta name="viewport" content="'.concat(e,'">')),document.body.style.opacity=.9999,setTimeout((()=>{document.body.style.opacity=1,window.scrollTo(r,i),t&&setTimeout(t,0)}),0)}function rr(){}function ir(e,t){this._fullHeight=this._fullWidth=this._overlay=null,this._targetImage=e,this._enableMobilePinch=t,this._$body=y(document.body)}y.fn.emulateTransitionEnd=function(e){var t=!1,r=this;y(this).one("bsTransitionEnd",(function(){t=!0}));return setTimeout((function(){t||y(r).trigger(y.support.transition.end)}),e),this},y((function(){y.support.transition=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var r in t)if(void 0!==e.style[r])return{end:t[r]};return!1}(),y.support.transition&&(y.event.special.bsTransitionEnd={bindType:y.support.transition.end,delegateType:y.support.transition.end,handle:function(e){if(y(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})),rr.prototype._initialize=function(e){this._$document||(this._activeZoom=this._initialScrollPosition=this._initialTouchPosition=this._touchMoveListener=null,this._$document=y(document),this._$window=y(window),this._$body=y(document.body),this._boundClick=y.proxy(this._clickHandler,this),this._enableMobilePinch=e)},rr.prototype.handleZoomClick=function(e,t){this._initialize(t);var r=e.target;if(r&&"IMG"===r.tagName&&!this._$body.hasClass("zoom-overlay-open"))return e.metaKey||e.ctrlKey?window.open(e.target.src,"_blank"):void(!t&&r.width>=window.innerWidth-ir.getOffset()||(this._activeZoomClose(!0),t?tr("width=device-width, initial-scale=1, minimum-scale=1",(()=>this._zoom(r))):this._zoom(r),t||(this._$window.on("scroll.zoom",y.proxy(this._scrollHandler,this)),this._$document.on("keyup.zoom",y.proxy(this._keyHandler,this)),this._$document.on("touchstart.zoom",y.proxy(this._touchStart,this))),document.addEventListener("click",this._boundClick,!0),e.stopPropagation()))},rr.prototype._zoom=function(e){this._activeZoom=new ir(e,this._enableMobilePinch),this._activeZoom.zoomImage()},rr.prototype._activeZoomClose=function(e){this._activeZoom&&(e?(this._activeZoom.dispose(),this._disposeActiveZoom()):tr("width=device-width, initial-scale=1, minimum-scale=1,\n maximum-scale=1",(()=>{this._activeZoom&&(this._activeZoom.close(),this._disposeActiveZoom())})))},rr.prototype._disposeActiveZoom=function(){this._$window.off(".zoom"),this._$document.off(".zoom"),document.removeEventListener("click",this._boundClick,!0),this._activeZoom=null},rr.prototype._scrollHandler=function(e){null===this._initialScrollPosition&&(this._initialScrollPosition=window.scrollY);var t=this._initialScrollPosition-window.scrollY;Math.abs(t)>=40&&this._activeZoomClose()},rr.prototype._keyHandler=function(e){27===e.keyCode&&this._activeZoomClose()},rr.prototype._clickHandler=function(e){e.stopPropagation(),e.preventDefault(),this._activeZoomClose()},rr.prototype._touchStart=function(e){this._initialTouchPosition=e.originalEvent.touches[0].pageY,y(e.target).on("touchmove.zoom",y.proxy(this._touchMove,this))},rr.prototype._touchMove=function(e){Math.abs(e.originalEvent.touches[0].pageY-this._initialTouchPosition)>10&&(this._activeZoomClose(),y(e.target).off("touchmove.zoom"))},ir._OFFSET=80,ir._MAX_WIDTH=2560,ir._MAX_HEIGHT=4096,ir.getOffset=function(e){return e?0:ir._OFFSET},ir.prototype.getOffset=function(){return ir.getOffset(this._enableMobilePinch)},ir.prototype.zoomImage=function(){var e=document.createElement("img"),t=y(e);e.onload=function(){this._fullHeight=Number(e.height),this._fullWidth=Number(e.width);var r=this._imageOffset=y(this._targetImage).offset(),i=this._left=r.left-y(window).scrollLeft(),n=this._top=r.top-y(window).scrollTop();t.css({left:i,top:n,width:this._targetImage.width,height:this._targetImage.height}),this._zoomOriginal()}.bind(this),e.src=this._targetImage.src,this.$zoomedImage=t},ir.prototype._zoomOriginal=function(){var e,t,r;this.$zoomedImage.addClass("zoom-img").attr("data-action","zoom-out"),y(this._targetImage).css("visibility","hidden"),this._backdrop=document.createElement("div"),this._backdrop.className="zoom-backdrop",null===(e=document.body)||void 0===e||e.appendChild(this._backdrop),this._overlay=document.createElement("div"),this._overlay.className="zoom-overlay",null===(t=document.body)||void 0===t||t.appendChild(this._overlay),null===(r=this._overlay)||void 0===r||r.appendChild(this.$zoomedImage[0]),this._calculateZoom(),this._triggerAnimation()},ir.prototype._calculateZoom=function(){var e=this._fullWidth,t=this._fullHeight,r=window.innerHeight-this.getOffset(),i=window.innerWidth-this.getOffset(),n=e/this._targetImage.width,o=e/t,s=i/r;this._imgScaleFactor=e<i&&t<r?n:o<s?r/t*n:i/(null!=e?e:0)*n},ir.prototype._triggerAnimation=function(){var e=y(window).scrollTop()+window.innerHeight/2,t=y(window).scrollLeft()+window.innerWidth/2,r=this._imgScaleFactor,i=this._imageOffset.top+this._targetImage.height/2,n=this._imageOffset.left+this._targetImage.width/2;this._translateY=(e-i)/r,this._translateX=(t-n)/r,this._zoomedInTransformString="\n scale(".concat(r,")\n translate3d(").concat(this._translateX,"px, ").concat(this._translateY,"px, 0)\n "),this.$zoomedImage.css({transform:this._zoomedInTransformString}).addClass("zoom-transition").one(y.support.transition.end,y.proxy(this._onZoomInFinish,this)).emulateTransitionEnd(300),this._$body.addClass("zoom-overlay-open")},ir.prototype._onZoomInFinish=function(){var e=this._targetImage.height*this._imgScaleFactor,t=this._targetImage.width*this._imgScaleFactor,r=0,i=0,n=0,o=0,s=0,a=0;t<window.innerWidth?(r="50%",n=-t/2):s=(t-window.innerWidth)/2,e<window.innerHeight?(i="50%",o=-e/2):a=(e-window.innerHeight)/2,this.$zoomedImage.css({height:e,left:r,marginLeft:n,marginTop:o,top:i,transform:"",width:t}).removeClass("zoom-transition"),y(this._overlay).scrollLeft(s).scrollTop(a)},ir.prototype.close=function(){this._$body.removeClass("zoom-overlay-open").addClass("zoom-overlay-transitioning"),this.$zoomedImage.css({height:this._targetImage.height,left:this._left,marginLeft:0,marginTop:0,top:this._top,transform:this._zoomedInTransformString,width:this._targetImage.width}).removeClass("zoom-transition"),y(this._overlay).scrollLeft(0).scrollTop(0),setTimeout((()=>{this.$zoomedImage.css({transform:"scale(1)"}).addClass("zoom-transition").one(y.support.transition.end,y.proxy(this.dispose,this)).emulateTransitionEnd(300)}),10)},ir.prototype.dispose=function(){this.$zoomedImage&&this.$zoomedImage[0].parentNode&&(this.$zoomedImage.remove(),this.$zoomedImage=null,this._overlay.parentNode.removeChild(this._overlay),this._backdrop.parentNode.removeChild(this._backdrop),this._$body.removeClass("zoom-overlay-transitioning")),y(this._targetImage).css("visibility","visible"),this._targetImage.focus()};var nr=new rr,or=E({displayName:"FixedToResponsive",propTypes:{width:d.number.isRequired,height:d.number.isRequired,className:d.string,constrainHeight:d.bool,allowFullBleed:d.bool},getDefaultProps:function(){return{className:"",constrainHeight:!1,allowFullBleed:!1}},getInitialState:function(){return{viewportHeight:null,viewportWidth:null}},componentDidMount:function(){this._isMounted=!0,window.innerHeight<480?setTimeout(this._cacheViewportSize,800):this._cacheViewportSize()},componentWillUnmount:function(){this._isMounted=!1},_cacheViewportSize:function(){this._isMounted&&this.setState({viewportHeight:Math.max(480,window.innerHeight),viewportWidth:window.innerWidth})},render:function(){var e=this.props.width/this.props.height,t=a.createElement("div",{style:{paddingBottom:100*(1/e).toFixed(4)+"%"}}),{width:r,height:i}=this.props;if(this.props.constrainHeight&&this.state.viewportHeight){var n=2/3*this.state.viewportHeight;this.props.height>=n&&(i=n,r=n*e)}var o={maxWidth:r,maxHeight:i},l=s("fixed-to-responsive",this.props.className),p=a.createElement("div",{className:l,style:o},t,this.props.children);return this.props.allowFullBleed&&this.state.viewportWidth&&r>=this.state.viewportWidth?a.createElement("div",{style:{marginLeft:-16,marginRight:-16}},p):p}});function sr(e,t){return e+":"+t}var ar={_fireEvent:function(e,t,r){h.invoke(e,"call",this,t,r)},_applyConstraints:function(e,t,r){var i=!1;return h.reduce(this.state.constraints,((e,n)=>{if(!1===e)return!1;if(i)return e;var o=n.call(this,e,t,G({onSkipRemaining:()=>{i=!0}},r));if(!1===o)return!1;if(x.is(o,2))return o;if(!0===o||null==o)return e;throw new ce("Constraint returned invalid result: "+o,pe.Internal)}),e,this)},draw:function(){var e=this.cloneState();ar._fireEvent.call(this,this.state.draw,e,this.prevState),this.prevState=e},listen:function(e,t,r){this._listenerMap=this._listenerMap||{};var i=sr(e,t),n=this._listenerMap[i]=this._listenerMap[i]||this.state[e].length;this.state[e][n]=r},unlisten:function(e,t){this._listenerMap=this._listenerMap||{};var r=sr(e,t),i=this._listenerMap[r];if(void 0!==i){this.state[e].splice(i,1),delete this._listenerMap[r];var n=h.keys(this._listenerMap);h.each(n,(function(t){(function(e){return e.split(":")[0]})(t)===e&&this._listenerMap[t]>i&&this._listenerMap[t]--}),this)}}},lr=null;var pr=null;var hr={assert:function(e,t){if(!e)throw new ce("Assertion Error"+(t?": "+t:""),pe.Internal)},createGettersFor:function(e,t){h.each(h.keys(t),(function(t){void 0===e.prototype[t]&&(e.prototype[t]=function(){return this.state[t]})}))},addMovableHelperMethodsTo:function(e){h.each(ar,(function(t,r){void 0===e.prototype[r]&&(e.prototype[r]=t)}))},arrayify:function(e){return null==e?[]:h.isArray(e)?h.filter(h.flatten(e),h.identity):[e]},normalizeOptions:function(e,t){var r=h.clone(t);return h.each(e,(function(e){var i=t[e];if(void 0!==i){var n=hr.arrayify(i);r[e]=n}})),r},getPrefixedTransform:function(){var e,t;return lr=lr||(e=document.createElement("div"),t=null,h.each(["transform","msTransform","MozTransform","WebkitTransform","OTransform"],(function(r){void 0!==e.style[r]&&(t=r)})),t),lr},getCanUse3dTransform:function(){return null==pr&&(pr=function(){var e=document.createElement("div"),t=hr.getPrefixedTransform();return e.style[t]="translateZ(0px)",!!e.style[t]}()),pr}},cr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function dr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ur={exports:{}};
1
+ import*as e from"@khanacademy/kas";import{KeypadInput as t,KeypadTypes as r,keypadElementPropType as i,Keypad as n}from"@khanacademy/math-input";import*as s from"@khanacademy/wonder-blocks-i18n";import o from"classnames";import*as a from"react";import l,{debounce as p}from"underscore";import h from"prop-types";import c from"@khanacademy/simple-markdown";import{StyleSheet as d,css as u}from"aphrodite";import*as m from"react-dom";import g from"react-dom";import f from"jquery";import{number as v,point as b,vector as y,line as x,ray as C}from"@khanacademy/kmath";import w from"create-react-class";import k from"mathquill";import E from"@khanacademy/wonder-blocks-color";import{LabelLarge as S}from"@khanacademy/wonder-blocks-typography";import"intersection-observer";import{UniqueIDProvider as _,View as M,Text as T}from"@khanacademy/wonder-blocks-core";import I from"@khanacademy/wonder-blocks-spacing";import P from"@khanacademy/wonder-blocks-tooltip";import{OptionItem as A,SingleSelect as N}from"@khanacademy/wonder-blocks-dropdown";import R from"@khanacademy/wonder-blocks-button";import F from"lodash.debounce";import{Popover as D,PopoverContentCore as O}from"@khanacademy/wonder-blocks-popover";import{CircularSpinner as L}from"@khanacademy/wonder-blocks-progress-spinner";import{Strut as B}from"@khanacademy/wonder-blocks-layout";import z from"@khanacademy/wonder-blocks-link";var q={major:11,minor:0},H={major:0,minor:1};function W(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?W(Object(r),!0).forEach((function(t){V(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):W(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function G(e,t,r,i,n,s,o){try{var a=e[s](o),l=a.value}catch(e){return void r(e)}a.done?t(l):Promise.resolve(l).then(i,n)}function V(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(){return j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},j.apply(this,arguments)}function Y(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var X=e=>{var{path:t,width:r,height:i,style:n={},title:s}=e;return a.createElement("svg",{role:"img","aria-hidden":!s,style:U({verticalAlign:"middle"},n),width:"".concat(r/i,"em"),height:"1em",viewBox:"0 0 ".concat(r," ").concat(i)},!!s&&a.createElement("title",null,s),a.createElement("path",{d:t,fill:"currentColor"}))};X.propTypes={path:h.string.isRequired,height:h.number.isRequired,width:h.number.isRequired,style:h.object,title:h.string};var $="'Proxima Nova Semibold',sans-serif",K="#FFFFFF",Z="#BABEC2",J="#888D93",Q="#21242c",ee={defaultBoxSize:400,defaultBoxSizeSmall:288},te=Object.freeze({__proto__:null,baseFontFamily:"'Proxima Nova',sans-serif",boldFontFamily:$,green:"#76A005",kaGreen:"#71B307",blue:"#1C758A",gray:"#AAAAAA",red:"#FFBABA",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",learnstormBlue:"#4898FC",white:K,gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:Z,gray68:J,gray41:"#626569",gray25:"#3B3e40",gray17:Q,black:"#000000",warning1:"#F86700",warning3:"#C75300",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1280px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1279px",tableBackgroundAccent:"#F9F9F9",gtpBlue:"#4c00ff",gtpIncorrectColor:"#babec2",gtpCorrectColor:"#ffbe26",satBlue:"#0084CE",satSelectedBackgroundColor:"#E4F3F9",satActiveBackgroundColor:"#D0EDF4",satCorrectColor:"#009900",satCorrectBorderColor:"#00CC00",satCorrectBackgroundColor:"#E4F7E4",satIncorrectColor:"#990000",satIncorrectBorderColor:"#CC5252",satIncorrectBackgroundColor:"#F2EBEB",zIndexScratchPad:1,zIndexAboveScratchpad:2,zIndexInteractiveComponent:3,zIndexCurrentlyDragging:4,zIndexCalculator:5,phoneMargin:16,negativePhoneMargin:-16,hintBorderWidth:4,baseUnitPx:16,interactiveSizes:ee,circleSize:24,radioMarginWidth:2,warningColor:"#f86700",warningColorHover:"#df5c00",warningColorActive:"#c75300",publishBlockingErrorColor:"#be2612",radioBorderColor:"#BABEC2",checkedColor:"#71B307",articleMaxWidthInPx:688,articleMaxWidthTableInPx:512}),re={path:"M6 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0-9a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z",height:12,width:12};class ie extends a.Component{constructor(){super(...arguments),V(this,"_positionTimeout",void 0),V(this,"state",{tooltipAbove:!0}),V(this,"getPosition",(()=>{var e=g.findDOMNode(this).getBoundingClientRect();this.setState({tooltipAbove:e.top>100})})),V(this,"renderLink",(e=>{var t,r,i,n=this.state.tooltipAbove;return 1===this.props.severity?(t=ne.indicatorError,r="Error",i=ne.publishBlockingError):2===this.props.severity?(t=ne.indicatorWarning,r="Warning",i=ne.warning):(t=ne.indicatorGuideline,r="Recommendation",i=ne.warning),a.createElement("a",{href:"https://khanacademy.org/r/linter-rules#".concat(this.props.ruleName),target:"lint-help-window",className:u(e)},a.createElement("span",{className:u(ne.indicator,t)},1===this.props.severity&&a.createElement(X,re)),a.createElement("div",{className:u(ne.tooltip,n&&ne.tooltipAbove)},this.props.message.split("\n\n").map(((e,t)=>a.createElement("p",{key:t,className:u(ne.tooltipParagraph)},a.createElement("span",{className:u(i)},r,":"," "),e))),a.createElement("div",{className:u(ne.tail,n&&ne.tailAbove)})))}))}componentDidMount(){this._positionTimeout=window.setTimeout(this.getPosition)}componentWillUnmount(){window.clearTimeout(this._positionTimeout)}render(){var{children:e,inline:t,blockHighlight:r,insideTable:i}=this.props;return i?t?a.createElement("span",{"data-lint-inside-table":"true"},e):a.createElement("div",{"data-lint-inside-table":"true"},e):r?a.createElement("span",{className:u(ne.lintContainer,ne.lintContainerBlock)},this.renderLink(ne.radioWidgetHoverTarget),a.createElement("span",null,e)):t?a.createElement("span",{className:u(ne.lintContainer)},this.renderLink(ne.inlineHoverTarget),a.createElement("span",null,e)):a.createElement("div",{className:u(ne.lintContainer)},this.renderLink(ne.hoverTarget),a.createElement("div",null,e))}}V(ie,"propTypes",{children:h.node,inline:h.bool,message:h.string.isRequired,ruleName:h.string.isRequired,insideTable:h.bool.isRequired,blockHighlight:h.bool,severity:h.number});var ne=d.create({lintContainer:{position:"relative"},lintContainerBlock:{display:"block"},hoverTarget:{position:"absolute",top:0,right:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ div":{outline:"1px solid #f86700"},":hover ~ div div[data-lint-inside-table]":{outline:"1px solid #f86700"},":hover ~ div span[data-lint-inside-table]":{backgroundColor:"#f86700",color:K}},inlineHoverTarget:{float:"right",position:"relative",marginRight:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ span":{backgroundColor:"#f86700",color:K}},radioWidgetHoverTarget:{position:"absolute",left:-40,display:"block",width:24,height:24,minWidth:264,":hover > span":{backgroundColor:"#df5c00"},":hover > div":{display:"block",padding:8,width:280},":hover > div > div":{left:8},":hover ~ span":{backgroundColor:"#f86700",color:K}},indicator:{alignItems:"center",borderRadius:4,color:"white",display:"flex",fontSize:12,height:8,justifyContent:"center",margin:8,width:8},indicatorError:{backgroundColor:"#be2612",borderRadius:8,height:16,width:16},indicatorWarning:{backgroundColor:"#f86700"},indicatorGuideline:{backgroundColor:"#ffbe26"},tooltip:{position:"absolute",right:-12,display:"none",zIndex:1e3,color:K,backgroundColor:Q,opacity:.9,fontFamily:"'Proxima Nova',sans-serif",fontSize:"12px",lineHeight:"15px",width:"320px",borderRadius:"4px"},tooltipAbove:{bottom:32},tail:{position:"absolute",top:-12,right:16,width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:"12px solid #21242c"},tailAbove:{bottom:-12,borderBottom:"none",borderTop:"12px solid #21242c",top:"auto"},tooltipParagraph:{margin:12},warning:{color:"#f86700",fontFamily:$},publishBlockingError:{color:"#be2612"}}),se=null,oe=()=>{if(se)return se;throw new Error(["Perseus has not been provided required dependencies.","setDependencies(dependencies) must be called first.","Make sure Perseus is being imported from javascript/perseus/perseus.js."].join("\n"))},ae=Object.freeze({__proto__:null,setDependencies:e=>{se=e},getDependencies:oe}),le=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"}),pe={log:(e,t)=>{oe().Log.log(e,t)},error:(e,t,r)=>{oe().Log.error(e,t,r)}};class he extends Error{constructor(e,t,r){super(e),V(this,"kind",void 0),V(this,"metadata",void 0),this.kind=t,this.metadata=null==r?void 0:r.metadata}}var ce={cleanMath:function(e){return"string"==typeof e?e.replace(/\+\s*-/g,"- ").replace(/-\s*-/g,"+ ").replace(/\^1/g,""):e},bound:function(e){return 0===e?e:e<0?-ce.bound(-e):Math.max(1e-6,Math.min(e,1e20))},factorial:function(e){return e<=1?e:e*ce.factorial(e-1)},getGCD:function(e,t){if(arguments.length>2){var r=[].slice.call(arguments,1);return ce.getGCD(e,ce.getGCD(...r))}var i;for(e=Math.abs(e),t=Math.abs(t);t;)i=e%t,e=t,t=i;return e},getLCM:function(e,t){if(arguments.length>2){var r=[].slice.call(arguments,1);return ce.getLCM(e,ce.getLCM(...r))}return Math.abs(e*t)/ce.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],isPrime:function(e){if(e<=1)return!1;if(e<101)return!!f.grep(ce.primes,(function(t,r){return Math.abs(t-e)<=.5})).length;if(e<=1||e>2&&e%2==0)return!1;for(var t=3,r=Math.sqrt(e);t<=r;t+=2)if(e%t==0)return!1;return!0},getPrimeFactorization:function(e){if(1===e)return[];if(ce.isPrime(e))return[e];for(var t=Math.sqrt(e),r=2;r<=t;r++)if(e%r==0)return f.merge(ce.getPrimeFactorization(r),ce.getPrimeFactorization(e/r))},roundToNearest:function(e,t){return Math.round(t/e)*e},roundTo:function(e,t){var r=Math.pow(10,e).toFixed(5);return Math.round((t*r).toFixed(5))/r},toFixedApprox:function(e,t){var r=e.toFixed(t);return v.equal(+r,e)?r:"\\approx "+r},roundToApprox:function(e,t){var r=ce.roundTo(t,e);return v.equal(r,e)?String(r):ce.toFixedApprox(e,t)},toFraction:function(e,t){if(null==t&&(t=Math.pow(2,-46)),e<0||e>1){var r=e%1;r+=r<0?1:0;var i=ce.toFraction(r,t);return i[0]+=Math.round(e-r)*i[1],i}if(Math.abs(Math.round(Number(e))-e)<=t)return[Math.round(e),1];for(var n=0,s=1,o=1,a=1,l=1,p=2;;){if(Math.abs(Number(l/p)-e)<=t)return[l,p];l/p<e?(n=l,s=p):(o=l,a=p),l=n+o,p=s+a}},getNumericFormat:function(e){if((e=(e=f.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1")).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,t){if(null==e)return"";if(0===e)return"0";if("percent"===t)return 100*e+"%";if("pi"===t){var r=v.toFraction(e/Math.PI),i=Math.abs(r[0]),n=r[1];if(v.isInteger(i)){return(e<0?"-":"")+(1===i?"":i)+"π"+(1===n?"":"/"+n)}}if(l(["proper","improper","mixed","fraction"]).contains(t)){var s=v.toFraction(e),o=Math.abs(s[0]),a=s[1],p=e<0?"-":"";if(1===a)return p+o;if("mixed"===t){var h=o%a,c=(o-h)/a;return p+(c?c+" ":"")+h+"/"+a}return p+o+"/"+a}return String(e)}},de=Math.pow(2,-42),ue={APPROXIMATED_PI_ERROR:s._("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>"),EXTRA_SYMBOLS_ERROR:s._("We could not understand your answer. Please check your answer for extra text or symbols."),NEEDS_TO_BE_SIMPLFIED_ERROR:s._("Your answer is almost correct, but it needs to be simplified."),MISSING_PERCENT_ERROR:s._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end."),MULTIPLICATION_SIGN_ERROR:s._("I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign."),WRONG_CASE_ERROR:s._("Your answer includes use of a variable with the wrong case."),WRONG_LETTER_ERROR:s._("Your answer includes a wrong variable letter.")},me={predicate:{defaultForms:"integer, proper, improper, mixed, decimal",createValidatorFunctional:function(e,t){var r;t=l.extend({simplify:"required",ratio:!1,forms:me.predicate.defaultForms},t),r=l.isArray(t.forms)?t.forms:t.forms.split(/\s*,\s*/),void 0===t.inexact&&(t.maxError=0),t.maxError=+t.maxError+de,l.contains(r,"percent")&&(r=l.without(r,"percent")).push("percent");var i=function(e){var r=(e=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").replace(/(^\s*)|(\s*$)/gi,"")).match(/^([+-]?\d+)\s*\/\s*([+-]?\d+)$/),i=e.match(/^([+-]?)\\frac\{([+-]?\d+)\}\{([+-]?\d+)\}$/),n=parseInt(e,10);if(r||i){var s,o,a=!0;return r?(s=parseFloat(r[1]),o=parseFloat(r[2])):(s=parseFloat(i[2]),"-"===i[1]&&(s<0&&(a=!1),s=-s),o=parseFloat(i[3])),[{value:s/o,exact:a=a&&o>0&&(t.ratio||1!==o)&&1===ce.getGCD(s,o)}]}return isNaN(n)||""+n!==e?[]:[{value:n,exact:!0}]},n={integer:function(e){var t=n.decimal(e),r=n.decimal(e,1);return null!=t[0].value&&t[0].value===r[0].value||null!=t[1].value&&t[1].value===r[1].value?t:[]},proper:function(e){return f.map(i(e),(function(e){return Math.abs(e.value)<1?[e]:[]}))},improper:function(e){return f.map(i(e),(function(e){return Math.abs(e.value)>=1?[e]:[]}))},pi:function(e){var t,r=[];if(t=(e=e.replace(/\u2212/,"-")).match(/^([+-]?)\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))r=[{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))r=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 s=parseFloat(t[1]+"1"),o=parseFloat(t[2]),a=parseFloat(t[3]),p=parseFloat(t[4]);r=[{value:s*(o+a/p),exact:a<p&&1===ce.getGCD(a,p)}]}else if(t=e.match(/^([+-]?\s*\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\s*\d+))?$/i))r=i(t[1]+"/"+t[3]);else if(t=e.match(/^([+-]?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\d+))?$/i))r=i(t[1]+"1/"+t[3]);else if("0"===e)r=[{value:0,exact:!0}];else{if(!(t=e.match(/^(.+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))){r=l.reduce(me.predicate.defaultForms.split(/\s*,\s*/),(function(t,r){return t.concat(n[r](e))}),[]);var h=!1,c=parseFloat(e);if(isNaN(c)||c===parseInt(e))e.match(/\/\s*7/)&&(h=!0);else{var d=Math.PI/12,u=d*Math.round(c/d);Math.abs(c-u)<.01&&(h=!0)}return h&&l.each(r,(function(e){e.piApprox=!0})),r}r=n.decimal(t[1])}var m=Math.PI;return e.match(/\\?tau|t|\u03c4/)&&(m=2*Math.PI),e.match(/pau/)&&(m=1.5*Math.PI),f.each(r,(function(e,t){t.value*=m})),r},coefficient:function(e){var t=[];return""===(e=e.replace(/\u2212/,"-"))?t=[{value:1,exact:!0}]:"-"===e&&(t=[{value:-1,exact:!0}]),t},log:function(e){var t,r=[];return(t=(e=(e=e.replace(/\u2212/,"-")).replace(/[ \(\)]/g,"")).match(/^log\s*(\S+)\s*$/i))?r=n.decimal(t[1]):"0"===e&&(r=[{value:0,exact:!0}]),r},percent:function(e){e=f.trim(e);var t=!1;e.indexOf("%")===e.length-1&&(e=f.trim(e.substring(0,e.length-1)),t=!0);var r=n.decimal(e);return f.each(r,(function(e,r){r.exact=t,r.value=r.value/100})),r},mixed:function(e){var t=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?)(\d+)\s+(\d+)\s*\/\s*(\d+)$/);if(t){var r=parseFloat(t[1]+"1"),i=parseFloat(t[2]),n=parseFloat(t[3]),s=parseFloat(t[4]);return[{value:r*(i+n/s),exact:n<s&&1===ce.getGCD(n,s)}]}return[]},decimal:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e10,i=function(e){var i=(e=f.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?(?:\d{1,3}(?:[, ]?\d{3})*\.?|\d{0,3}(?:[, ]?\d{3})*\.(?:\d{3}[, ]?)*\d{1,3}))$/),n=e.match(/^0[0,]*,/);if(i&&!n){var s=parseFloat(i[1].replace(/[, ]/g,""));return void 0===t.inexact&&(s=Math.round(s*r)/r),s}},n=function(e){return e=e.replace(/([\.,])/g,(function(e,t){return"."===t?",":"."})),i(e)};return[{value:i(e),exact:!0},{value:n(e),exact:!0}]}};return function(i){var s=null!=t.fallback?""+t.fallback:"",o={empty:""===(i=f.trim(i)||s),correct:!1,message:null,guess:i};if(f.each(r,(function(r,s){for(var a=n[s](i),l=0,p=a.length;l<p;l++){var h=a[l].value,c=a[l].exact,d=a[l].piApprox;if(e(h,t.maxError))return c||"optional"===t.simplify?(o.correct=!0,o.message=t.message||null,o.empty=!1):"percent"===s?(o.empty=!0,o.message=ue.MISSING_PERCENT_ERROR):("enforced"!==t.simplify&&(o.empty=!0),o.message=ue.NEEDS_TO_BE_SIMPLFIED_ERROR),!1;d&&e(h,Math.abs(.001*h))&&(o.empty=!0,o.message=ue.APPROXIMATED_PI_ERROR)}})),!1===o.correct){var a=!1;if(l.each(n,(function(e){l.any(e(i),(function(e){return null!=e.value&&!l.isNaN(e.value)}))&&(a=!0)})),!a)return o.empty=!0,o.message=ue.EXTRA_SYMBOLS_ERROR,o}return o}}},number:{convertToPredicate:function(e,t){var r=parseFloat(f.trim(e));return[function(e,t){return Math.abs(e-r)<t},f.extend({},t,{type:"predicate"})]},createValidatorFunctional:function(e,t){return me.predicate.createValidatorFunctional(...me.number.convertToPredicate(e,t))}},expression:{parseSolution:function(t,r){var i=e.parse(t,r);if(!i.parsed)throw new he("The provided solution ("+t+") didn't parse.",le.InvalidInput);if(r.simplified&&!i.expr.isSimplified())throw new he("The provided solution ("+t+") isn't fully expanded and simplified.",le.InvalidInput);return i=i.expr},createValidatorFunctional:function(t,r){return function(i){var n={empty:!1,correct:!1,message:null,guess:i,ungraded:!1};if(!i)return n.empty=!0,n;var s=e.parse(i,r);if(!s.parsed)return n.empty=!0,n;"string"==typeof t&&(t=me.expression.parseSolution(t,r));var o=e.compare(s.expr,t,r);if(o.equal)n.correct=!0;else if(o.wrongVariableNames||o.wrongVariableCase)n.ungraded=!0,n.message=o.wrongVariableCase?ue.WRONG_CASE_ERROR:ue.WRONG_LETTER_ERROR,n.suppressAlmostThere=!0;else if(o.message)n.message=o.message;else{var a=e.parse(i.replace(/[xX]/g,"*"),r);if(a.parsed){var l=e.compare(a.expr,t,r);l.equal?(n.ungraded=!0,n.message=ue.MULTIPLICATION_SIGN_ERROR):l.message&&(n.message=l.message+" Also, I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign.")}}return n}}}},ge=!1,fe=/^web\+graphie:/,ve=/^file\+graphie:/;var be=/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/,ye=new RegExp(be.source+"$"),xe=function(e){var t=e;return function(){var e=t;return(t=268435455&(e=4294967295&(3042594569^(e=(e=4294967295&((e=(e=4294967295&(3345072700^(e=e+2127912214+(e<<12)&4294967295)^e>>>19))+374761393+(e<<5)&4294967295)+3550635116^e<<9))+4251993797+(e<<3)&4294967295)^e>>>16)))/268435456}};var Ce="x".split(/(.)/g).length?function(e,t){return e.split(t)}:function(e,t){for(var r,i=[],n=t.lastIndex=0;r=t.exec(e);){var s=r;i.push(e.slice(n,s.index)),i.push(...s.slice(1)),n=s.index+s[0].length}return i.push(e.slice(n)),i};function we(e,t){var r=e*t,i=e,n=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),s=Math.floor(i/n);return r<25?e:r<50?5===s?e:e/2:1===s?e/2:2===s?e/4:5===s?e/5:void 0}function ke(e,t){return t/(e[1]-e[0])}function Ee(e,t){var r=Math.pow(10,Math.floor(Math.log(e/t)/Math.LN10)),i=t/e*r;return i<=.15?r*=10:i<=.35?r*=5:i<=.75&&(r*=2),r}var Se=(e,t)=>{var r=t[1]-t[0],i=r/e;return i<=10?e:i<=20?2*e:Ee(r,10)};var _e={UNSAFE_componentWillMount:function(){var e={};l.each(this.deprecatedProps,(function(t,r){l.has(this.props,r)&&l.extend(e,t(this.props))}),this),l.isEmpty(e)||(l.extend(this.props,e),setTimeout(this.props.onChange,0,e))}};function Me(e,t){return"number"==typeof e&&"number"==typeof t?Math.abs(e-t)<1e-9:e===t}var Te={pointerDown:!1,currentTouchIdentifier:null};function Ie(e){return Pe(e)?Ne(e):e}function Pe(e){return fe.test(e)||ve.test(e)}function Ae(e){return e.replace(fe,"https:").replace(ve,"file:")}function Ne(e){return Ae(e)+".svg"}var Re={getWordBeforeCursor:function(e){var t=e.value,r=e.selectionStart-1,i=Math.max(t.lastIndexOf("\n",r),t.lastIndexOf(" ",r))+1;return{string:t.substring(i,r+1),pos:{start:i,end:r}}},moveCursor:function(e,t){e.selectionStart=t,e.selectionEnd=t}},Fe=xe(4294967295&(new Date).getTime()),De={inputPathsEqual:function(e,t){return null==e||null==t?null==e==(null==t):e.length===t.length&&e.every(((e,r)=>t[r]===e))},nestedMap:function e(t,r,i){return Array.isArray(t)?l.map(t,(function(t){return e(t,r)})):r.call(i,t)},rWidgetRule:be,rTypeFromWidgetId:/^([a-z-]+) ([0-9]+)$/,rWidgetParts:ye,snowman:"☃",noScore:{type:"points",earned:0,total:0,message:null},seededRNG:xe,shuffle:function(e,t){var r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=l.clone(e);if(!n.length||l.all(n,(function(e){return l.isEqual(e,n[0])})))return n;r="function"==typeof t?t:xe(t);do{for(var s=n.length;s>0;s--){var o=Math.floor(r()*s),a=n[o];n[o]=n[s-1],n[s-1]=a}}while(i&&l.isEqual(e,n));return n},split:Ce,combineScores:function(e,t){var r;if("points"===e.type&&"points"===t.type)return r=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"points",earned:e.earned+t.earned,total:e.total+t.total,message:r};if("points"===e.type&&"invalid"===t.type)return t;if("invalid"===e.type&&"points"===t.type)return e;if("invalid"===e.type&&"invalid"===t.type)return{type:"invalid",message:r=e.message&&t.message&&e.message!==t.message?null:e.message||t.message};throw new he("PerseusScore with unknown type encountered",le.InvalidInput,{metadata:{scoreA:JSON.stringify(e),scoreB:JSON.stringify(t)}})},keScoreFromPerseusScore:function(e,t,r){if("points"===e.type)return{empty:!1,correct:e.earned>=e.total,message:e.message,guess:t,state:r};if("invalid"===e.type)return{empty:!0,correct:!1,message:e.message,suppressAlmostThere:e.suppressAlmostThere,guess:t,state:r};throw new he("Invalid score type: "+e.type,le.InvalidInput,{metadata:{score:JSON.stringify(e),guess:JSON.stringify(t),state:JSON.stringify(r)}})},firstNumericalParse:function(e){var t;return me.predicate.createValidatorFunctional((function(e){return t=e,!0}),{simplify:"optional",inexact:!0,forms:"integer, proper, improper, pi, log, mixed, decimal"})(e),t},stringArrayOfSize:function(e){return l(e).times((function(){return""}))},gridDimensionConfig:function(e,t,r,i){var n=ke(t,r);return{scale:n,tickStep:e/i,unityLabel:e*n>30}},getGridStep:function(e,t,r){return l(2).times((function(i){var n=ke(e[i],r);return we(t[i],n)}))},snapStepFromGridStep:function(e){return[e[0]/2,e[1]/2]},scaleFromExtent:ke,tickStepFromExtent:function(e,t){var r=e[1]-e[0];return Ee(r,(15<r&&r<=20?23:r>100||r<5?10:16)*(t/500))},gridStepFromTickStep:we,tickStepFromNumTicks:Ee,constrainedTickStepsFromTickSteps:function(e,t){return[Se(e[0],t[0]),Se(e[1],t[1])]},DeprecationMixin:_e,eq:Me,deepEq:function e(t,r){if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return!1;for(var i=0;i<t.length;i++)if(!e(t[i],r[i]))return!1;return!0}return!Array.isArray(t)&&!Array.isArray(r)&&("function"==typeof t&&"function"==typeof r?Me(t,r):"function"!=typeof t&&"function"!=typeof r&&("object"==typeof t&&"object"==typeof r&&t&&r?t===r||l.all(t,(function(t,i){return e(r[i],t)}))&&l.all(r,(function(r,i){return e(t[i],r)})):!("object"==typeof t&&t||"object"==typeof r&&r)&&Me(t,r)))},parseQueryString:function(e){e=e||window.location.search.substring(1);for(var t,r={},i=/\+/g,n=/([^&=]+)=?([^&]*)/g,s=function(e){return decodeURIComponent(e.replace(i," "))};t=n.exec(e);){var o=t;r[s(o[1])]=s(o[2])}return r},updateQueryString:function(e,t,r){r=encodeURIComponent(r);var i=new RegExp("([?&])"+t+"=.*?(&|$)","i"),n=-1!==e.indexOf("?")?"&":"?";return e.match(i)?e.replace(i,"$1"+t+"="+r+"$2"):e+n+t+"="+r},strongEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/['()!]/g,window.escape).replace(/\*/g,"%2A")},widgetShouldHighlight:function(e){if(!e)return!1;switch(e.type){case"measurer":case"protractor":return!0;default:return!1}},scoreIsEmpty:function(e){return"invalid"===e.type&&(!e.message||0===e.message.length)},touchHandlers:Te,resetTouchHandlers:function(){Object.assign(Te,{pointerDown:!1,currentTouchIdentifier:null})},extractPointerLocation:function(e){var t;if(Te.pointerDown){if(null!=Te.currentTouchIdentifier)for(var r=e.changedTouches?e.changedTouches.length:0,i=0;i<r;i++)e.changedTouches[i].identifier===Te.currentTouchIdentifier&&(t=e.changedTouches[i]);else t=e;var n="touchend"===e.type||"touchcancel"===e.type;t&&n&&(Te.pointerDown=!1,Te.currentTouchIdentifier=null)}else Te.pointerDown=!0,e.changedTouches?(t=e.changedTouches[0],Te.currentTouchIdentifier=t.identifier):t=e;if(t)return{left:t.pageX,top:t.pageY}},supportsPassiveEvents:()=>{try{var e=Object.defineProperty({},"passive",{get:function(){ge=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(e){}return ge},captureScratchpadTouchStart:function(e){e.stopPropagation()},getImageSize:function(e,t){var r=new Image;r.onload=function(){var e;0===r.width&&0===r.height?(null===(e=document.body)||void 0===e||e.appendChild(r),l.defer((function(){var e;t(r.clientWidth,r.clientHeight),null===(e=document.body)||void 0===e||e.removeChild(r)}))):t(r.width,r.height)},r.src=Ie(e)},getRealImageUrl:Ie,isLabeledSVG:Pe,getBaseUrl:Ae,getSvgUrl:Ne,getDataUrl:function(e){return Ae(e)+"-data.json"},textarea:Re,unescapeMathMode:e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e,random:Fe},Oe=(e,t,r)=>{var i=e.length,n=0;if(r){if(t.inline)return null;for(;n<i&&" "===e[n];)n++}if(!(n<i&&"$"===e[n]))return null;for(var s=++n,o=0;n<i;){var a=e[n];if("\\"===a)n++;else{if(o<=0&&"$"===a){var l=n+1;if(r){var p=/^(?: *\n){2,}/.exec(e.slice(l));l=p?l+p[0].length:null}return l?[e.substring(0,l),e.substring(s,n)]:null}if("{"===a)o++;else if("}"===a)o--;else if("\n"===a&&"\n"===e[n-1])return null}n++}return null},Le=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n("+c.defaultRules.nptable.match.regex.source.substring(1)+")"),Be=c.blockRegex(/^(crwdns.*)\n\s*\n/),ze=U(U({},c.defaultRules),{},{columns:{order:-2,match:c.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:(e,t,r)=>({col1:t(e[1],r),col2:t(e[2],r)})},crowdinId:{order:-1,match:(e,t,r)=>t.isJipt?Be(e,t,r):null,parse:(e,t,r)=>({id:e[1]})},titledTable:{order:c.defaultRules.nptable.order-.5,match:c.blockRegex(Le),parse:(e,t,r)=>{var i=c.parseInline(t,e[1],r),n=e.slice(2);return{title:i,table:c.defaultRules.nptable.parse(n,t,r)}}},widget:{order:c.defaultRules.link.order-.75,match:c.inlineRegex(De.rWidgetRule),parse:(e,t,r)=>({id:e[1],widgetType:e[2]})},blockMath:{order:c.defaultRules.codeBlock.order+.5,match:(e,t)=>Oe(e,t,!0),parse:(e,t,r)=>({content:e[1]})},math:{order:c.defaultRules.link.order-.25,match:(e,t)=>Oe(e,t,!1),parse:(e,t,r)=>({content:e[1]})},unescapedDollar:{order:c.defaultRules.link.order-.24,match:c.inlineRegex(/^(?!\\)\$/),parse:(e,t,r)=>({})},fence:U(U({},c.defaultRules.fence),{},{parse:(e,t,r)=>{var i=c.defaultRules.fence.parse(e,t,r);return"alt"===i.lang?{type:"codeBlock",lang:"alt",content:t(i.content+"\n\n",r)}:i}}),blockQuote:U(U({},c.defaultRules.blockQuote),{},{match:c.blockRegex(/^ *>[^\n]+(\n( *>)?[^\n]+)*\n{2,}/)}),list:U(U({},c.defaultRules.list),{},{match:(e,t,r)=>t.isJipt?null:c.defaultRules.list.match(e,t,r)}),lint:{order:1e3,match:e=>null,parse:(e,t,r)=>({})}});c.parserFor(ze);var qe=U(U({},ze),{},{columns:U(U({},ze.columns),{},{react:(e,t,r)=>a.createElement("div",{className:"perseus-two-columns",key:r.key},a.createElement("div",{className:"perseus-column"},a.createElement("div",{className:"perseus-column-content"},t(e.col1,r))),a.createElement("div",{className:"perseus-column"},a.createElement("div",{className:"sat-header-grafting-area"}),a.createElement("div",{className:"perseus-column-content"},a.createElement("div",{className:"sat-skill-subscore-grafting-area"}),t(e.col2,r),a.createElement("div",{className:"sat-grafting-area"}))))}),crowdinId:U(U({},ze.crowdinId),{},{react:(e,t,r)=>e.id}),table:U(U({},ze.table),{},{react:function(e,t,r){var i=c.defaultRules.table.react(e,t,r);return r.isMobile?a.cloneElement(i,{tabIndex:0}):i}}),titledTable:U(U({},ze.titledTable),{},{react:(e,t,r)=>{var i;if(e.table)if("lint"===e.table.type){var n;i="table"===(null===(n=e.table.content)||void 0===n?void 0:n.type)?qe.lint.react(U(U({},e.table),{},{content:U(U({},e),{},{table:e.table.content})}),t,U(U({},r),{},{unwrapTitledTableContents:!0})):qe.lint.react(e.table,t,r)}else{var s=c.defaultRules.table.react(e.table,t,r),o=a.createElement("caption",{key:"caption",className:"perseus-table-title"},t(e.title,r));i=a.cloneElement(s,null,[o,...s.props.children])}else i="//invalid table//";return r.unwrapTitledTableContents?i:a.createElement("div",{className:"perseus-titled-table",key:r.key},i)}}),widget:U(U({},ze.widget),{},{react:(e,t,r)=>a.createElement("em",{key:r.key},s.doNotTranslate("[Widget: ",e.id,"]"))}),blockMath:U(U({},ze.blockMath),{},{react:(e,t,r)=>{var{TeX:i}=oe();return a.createElement(i,{key:r.key},e.content)}}),math:U(U({},ze.math),{},{react:(e,t,r)=>{var{TeX:i}=oe();return a.createElement(i,{key:r.key},e.content)}}),unescapedDollar:U(U({},ze.unescapedDollar),{},{react:(e,t,r)=>"$"}),link:U(U({},ze.link),{},{react:function(e,t,r){var i=c.defaultRules.link.react(e,t,r),n=i.props.href,s=null;!!n&&n.match(/https?:\/\/[^\/]*khanacademy.org|^\//)||(s="noopener noreferrer");var o=U(U({},i.props),{},{target:"_blank",href:n,rel:s});return r.baseElements&&r.baseElements.Link?r.baseElements.Link(o):a.cloneElement(i,o)}}),codeBlock:U(U({},ze.codeBlock),{},{react:(e,t,r)=>"alt"===e.lang?a.createElement("div",{key:r.key,className:"perseus-markdown-alt perseus-sr-only"},t(e.content,r)):c.defaultRules.codeBlock.react(e,t,r)}),lint:U(U({},ze.lint),{},{react:(e,t,r)=>a.createElement(ie,{message:e.message,ruleName:e.ruleName,inline:He(e.content),blockHighlight:e.blockHighlight,insideTable:e.insideTable,severity:e.severity},t(e.content,r))})});function He(e){return!!(e&&e.type&&We.hasOwnProperty(e.type))}var We={text:!0,math:!0,unescapedDollar:!0,link:!0,img:!0,strong:!0,u:!0,em:!0,del:!0,code:!0},Ue=c.parserFor(qe),Ge=(e,t)=>Ue(e+"\n\n",U(U({},t),{},{inline:!1})),Ve=(e,t)=>{l.isArray(e)?l.each(e,(e=>Ve(e,t))):l.isObject(e)&&(t(e),"table"===e.type?(Ve(e.header,t),Ve(e.cells,t)):"list"===e.type?Ve(e.items,t):"titledTable"===e.type?Ve(e.table,t):"columns"===e.type?(Ve(e.col1,t),Ve(e.col2,t)):l.isArray(e.content)&&Ve(e.content,t))},je=e=>{if(l.isArray(e))return l.flatten(l.map(e,je));if(e.content&&l.isString(e.content))return-1!==e.type.toLowerCase().indexOf("code")?["",e.content,""]:[e.content.replace(/\s+/g," ")];var t=l.chain(e).values().flatten().filter((e=>null!=e&&l.has(e,"type"))).value();if(!t.length)return[];var r=je(t);if("paragraph"===e.type&&r.length){r[0]=r[0].replace(/^\s+/,"");var i=r.length-1;r[i]=r[i].replace(/\s+$/,"")}return r},Ye={characterCount:e=>{var t=Ge(e);return je(t).join("").length},traverseContent:Ve,parse:Ge,parseInline:(e,t)=>Ue(e,U(U({},t),{},{inline:!0})),reactFor:c.reactFor,ruleOutput:c.ruleOutput(qe,"react"),basicOutput:c.reactFor(c.ruleOutput(qe,"react")),sanitizeUrl:c.sanitizeUrl};class Xe{static parse(e){return new $e(e).parse()}match(e){throw new he("Selector subclasses must implement match()",le.NotAllowed)}toString(){return"Unknown selector class"}}class $e{constructor(e){V(this,"tokens",void 0),V(this,"tokenIndex",void 0),e=e.trim().replace(/\s+/g," "),this.tokens=e.match($e.TOKENS)||[],this.tokenIndex=0}nextToken(){return this.tokens[this.tokenIndex]||""}consume(){this.tokenIndex++}isIdentifier(){var e=this.tokens[this.tokenIndex][0];return e>="a"&&e<="z"||e>="A"&&e<="Z"}skipSpace(){for(;" "===this.nextToken();)this.consume()}parse(){var e=this.parseTreeSelector(),t=this.nextToken();if(!t)return e;for(var r=[e];t;){if(","!==t)throw new Ke("Expected comma");this.consume(),r.push(this.parseTreeSelector()),t=this.nextToken()}return new Ze(r)}parseTreeSelector(){this.skipSpace();for(var e=this.parseNodeSelector();;){var t=this.nextToken();if(!t||","===t)break;if(" "===t)this.consume(),e=new tt(e,this.parseNodeSelector());else if(">"===t)this.consume(),e=new rt(e,this.parseNodeSelector());else if("+"===t)this.consume(),e=new it(e,this.parseNodeSelector());else{if("~"!==t)throw new Ke("Unexpected token: "+t);this.consume(),e=new nt(e,this.parseNodeSelector())}}return e}parseNodeSelector(){this.skipSpace();var e=this.nextToken();if("*"===e)return this.consume(),new Je;if(this.isIdentifier())return this.consume(),new Qe(e);throw new Ke("Expected node type")}}V($e,"TOKENS",void 0),$e.TOKENS=/([a-zA-Z][\w-]*)|(\d+)|[^\s]|(\s(?=[a-zA-Z\*]))/g;class Ke extends Error{constructor(e){super(e)}}class Ze extends Xe{constructor(e){super(),V(this,"selectors",void 0),this.selectors=e}match(e){for(var t=0;t<this.selectors.length;t++){var r=this.selectors[t].match(e);if(r)return r}return null}toString(){for(var e="",t=0;t<this.selectors.length;t++)e+=t>0?", ":"",e+=this.selectors[t].toString();return e}}class Je extends Xe{match(e){return[e.currentNode()]}toString(){return"*"}}class Qe extends Xe{constructor(e){super(),V(this,"type",void 0),this.type=e}match(e){var t=e.currentNode();return t.type===this.type?[t]:null}toString(){return this.type}}class et extends Xe{constructor(e,t){super(),V(this,"left",void 0),V(this,"right",void 0),this.left=e,this.right=t}}class tt extends et{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t)for(e=e.clone();e.hasParent();){e.goToParent();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" "+this.right.toString()}}class rt extends et{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t&&e.hasParent()){(e=e.clone()).goToParent();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" > "+this.right.toString()}}class it extends et{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t&&e.hasPreviousSibling()){(e=e.clone()).goToPreviousSibling();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" + "+this.right.toString()}}class nt extends et{constructor(e,t){super(e,t)}match(e){var t=this.right.match(e);if(t)for(e=e.clone();e.hasPreviousSibling();){e.goToPreviousSibling();var r=this.left.match(e);if(r)return r.concat(t)}return null}toString(){return this.left.toString()+" ~ "+this.right.toString()}}class st{constructor(e,t,r,i,n,s){var o=this;if(V(this,"name",void 0),V(this,"severity",void 0),V(this,"selector",void 0),V(this,"pattern",void 0),V(this,"lint",void 0),V(this,"applies",void 0),V(this,"message",void 0),!r&&!i)throw new he("Lint rules must have a selector or pattern",le.InvalidInput,{metadata:{name:e}});this.name=e||"unnamed rule",this.severity=t||st.Severity.BULK_WARNING,this.selector=r||st.DEFAULT_SELECTOR,this.pattern=i||null,"function"==typeof n?(this.lint=n,this.message=null):(this.lint=function(){return o._defaultLintFunction(...arguments)},this.message=n),this.applies=s||function(){return!0}}static makeRule(e){return new st(e.name,e.severity,e.selector?Xe.parse(e.selector):null,st.makePattern(e.pattern),e.lint||e.message,e.applies)}check(e,t,r,i){var n,s=this.selector.match(t);if(!s)return null;if(!(n=this.pattern?r.match(this.pattern):st.FakePatternMatch(r,r,0)))return null;try{var o=this.lint(t,r,s,n,i);return o?"string"==typeof o?{rule:this.name,severity:this.severity,message:o,start:0,end:r.length}:{rule:this.name,severity:this.severity,message:o.message,start:o.start,end:o.end}:null}catch(e){return{rule:"lint-rule-failure",message:"Exception in rule ".concat(this.name,": ").concat(e.message,"\nStack trace:\n").concat(e.stack),start:0,end:r.length}}}_defaultLintFunction(e,t,r,i,n){return{message:this.message||"",start:i.index,end:i.index+i[0].length}}static makePattern(e){if(!e)return null;if(e instanceof RegExp)return e;if("/"===e[0]){var t=e.lastIndexOf("/"),r=e.substring(1,t),i=e.substring(t+1);return new RegExp(r,i)}return new RegExp(e)}static FakePatternMatch(e,t,r){var i=[t];return i.index=r,i.input=e,i}}V(st,"DEFAULT_SELECTOR",void 0),V(st,"Severity",{ERROR:1,WARNING:2,GUIDELINE:3,BULK_WARNING:4}),st.DEFAULT_SELECTOR=Xe.parse("text");var ot=/\/\/([^\/]+)/;var at=st.makeRule({name:"absolute-url",severity:st.Severity.GUIDELINE,selector:"link, image",lint:function(e,t,r,i){var n=function(e){if(!e)return"";var t=e.match(ot);return t?t[1]:""}(r[0].target);if("khanacademy.org"===n||n.endsWith(".khanacademy.org"))return"Don't use absolute URLs:\nWhen linking to KA content or images, omit the\nhttps://www.khanacademy.org URL prefix.\nUse a relative URL beginning with / instead."}}),lt=st.makeRule({name:"blockquoted-math",severity:st.Severity.WARNING,selector:"blockQuote math, blockQuote blockMath",message:"Blockquoted math:\nmath should not be indented."}),pt=st.makeRule({name:"blockquoted-widget",severity:st.Severity.WARNING,selector:"blockQuote widget",message:"Blockquoted widget:\nwidgets should not be indented."}),ht=st.makeRule({name:"double-spacing-after-terminal",severity:st.Severity.BULK_WARNING,selector:"paragraph",pattern:/[.!\?] {2}/i,message:"Use a single space after a sentence-ending period, or\nany other kind of terminal punctuation."}),ct=st.makeRule({name:"extra-content-spacing",selector:"paragraph",pattern:/\s+$/,applies:function(e){return"article"===e.contentType},message:"No extra whitespace at the end of content blocks."}),dt=st.makeRule({name:"heading-level-1",severity:st.Severity.WARNING,selector:"heading",lint:function(e,t,r,i){if(1===r[0].level)return"Don't use level-1 headings:\nBegin headings with two or more # characters."}}),ut=st.makeRule({name:"heading-level-skip",severity:st.Severity.WARNING,selector:"heading ~ heading",lint:function(e,t,r,i){var n=r[1],s=r[0];if(n.level>s.level+1)return"Skipped heading level:\nthis heading is level ".concat(n.level," but\nthe previous heading was level ").concat(s.level)}}),mt=st.makeRule({name:"heading-sentence-case",severity:st.Severity.GUIDELINE,selector:"heading",pattern:/^\W*[a-z]/,message:"First letter is lowercase:\nthe first letter of a heading should be capitalized."}),gt={and:!0,nor:!0,but:!0,the:!0,for:!0};var ft=st.makeRule({name:"heading-title-case",severity:st.Severity.GUIDELINE,selector:"heading",pattern:/[^\s:]\s+[A-Z]+[a-z]/,locale:"en",lint:function(e,t,r,i){var n=t.trim().split(/\s+/);if(n.shift(),(n=n.filter((e=>e.length>2&&!gt.hasOwnProperty(e)))).length>=3&&n.every((e=>{return(t=e[0])===t.toUpperCase();var t})))return"Title-case heading:\nThis heading appears to be in title-case, but should be sentence-case.\nOnly capitalize the first letter and proper nouns."}}),vt=st.makeRule({name:"image-alt-text",severity:st.Severity.WARNING,selector:"image",lint:function(e,t,r,i){var n=r[0];return n.alt&&n.alt.trim()?n.alt.length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(n.alt.length," characters long."):void 0:"Images should have alt text:\nfor accessibility, all images should have alt text.\nSpecify alt text inside square brackets after the !."}}),bt=st.makeRule({name:"image-in-table",severity:st.Severity.BULK_WARNING,selector:"table image",message:"Image in table:\ndo not put images inside of tables."}),yt=st.makeRule({name:"image-spaces-around-urls",severity:st.Severity.ERROR,selector:"image",lint:function(e,t,r,i,n){var s=r[0].target;if(n&&n.content){var o=n.content.indexOf(s);if(-1===o)return;if("("!==n.content[o-1]||")"!==n.content[o+s.length])return"Whitespace before or after image url:\nFor images, don't include any space or newlines after '(' or before ')'.\nWhitespace in image URLs causes translation difficulties."}}}),xt=st.makeRule({name:"image-widget",severity:st.Severity.WARNING,selector:"widget",lint:function(e,t,r,i,n){if("image"===e.currentNode().widgetType){var s=n&&n.widgets&&n.widgets[e.currentNode().id];if(s){var o=s.options.alt;return o?o.trim().length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(o.trim().length," characters long."):s.options.caption&&s.options.caption.match(/[^\\]\$/)?"No math in image captions:\nDon't include math expressions in image captions.":void 0:'Images should have alt text:\nfor accessibility, all images should have a text description.\nAdd a description in the "Alt Text" box of the image widget.'}}}}),Ct=st.makeRule({name:"link-click-here",severity:st.Severity.WARNING,selector:"link",pattern:/click here/i,message:'Inappropriate link text:\nDo not use the words "click here" in links.'}),wt=st.makeRule({name:"long-paragraph",severity:st.Severity.GUIDELINE,selector:"paragraph",pattern:/^.{501,}/,lint:function(e,t,r,i){return"Paragraph too long:\nThis paragraph is ".concat(t.length," characters long.\nShorten it to 500 characters or fewer.")}}),kt=st.makeRule({name:"math-adjacent",severity:st.Severity.WARNING,selector:"blockMath+blockMath",message:"Adjacent math blocks:\ncombine the blocks between \\begin{align} and \\end{align}"}),Et=st.makeRule({name:"math-align-extra-break",severity:st.Severity.WARNING,selector:"blockMath",pattern:/(\\{2,})\s*\\end{align}/,message:"Extra space at end of block:\nDon't end an align block with backslashes"}),St=st.makeRule({name:"math-align-linebreaks",severity:st.Severity.WARNING,selector:"blockMath",pattern:/\\begin{align}[\s\S]*\\\\[\s\S]+\\end{align}/,lint:function(e,t,r,i){for(var n=i[0];n.length;){var s=n.indexOf("\\\\");if(-1===s)return null;var o=(n=n.substring(s+2)).match(/^\s*\\\\\s*(?!\\\\)/);if(!o)return"Use four backslashes between lines of an align block";n=n.substring(o[0].length)}}}),_t=st.makeRule({name:"math-empty",severity:st.Severity.WARNING,selector:"math, blockMath",pattern:/^$/,message:"Empty math: don't use $$ in your markdown."}),Mt=st.makeRule({name:"math-font-size",severity:st.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\(tiny|Tiny|small|large|Large|LARGE|huge|Huge|scriptsize|normalsize)\s*{/,message:"Math font size:\nDon't change the default font size with \\Large{} or similar commands"}),Tt=st.makeRule({name:"math-frac",severity:st.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\frac[ {]/,message:"Use \\dfrac instead of \\frac in your math expressions."}),It=st.makeRule({name:"math-nested",severity:st.Severity.ERROR,selector:"math, blockMath",pattern:/\\text{[^$}]*\$[^$}]*\$[^}]*}/,message:"Nested math:\nDon't nest math expressions inside \\text{} blocks"}),Pt=st.makeRule({name:"math-starts-with-space",severity:st.Severity.GUIDELINE,selector:"math, blockMath",pattern:/^\s*(~|\\qquad|\\quad|\\,|\\;|\\:|\\ |\\!|\\enspace|\\phantom)/,message:"Math starts with space:\nmath should not be indented. Do not begin math expressions with\nLaTeX space commands like ~, \\;, \\quad, or \\phantom"}),At=st.makeRule({name:"math-text-empty",severity:st.Severity.WARNING,selector:"math, blockMath",pattern:/\\text{\s*}/,message:"Empty \\text{} block in math expression"}),Nt=st.makeRule({name:"math-without-dollars",severity:st.Severity.GUIDELINE,pattern:/\\\w+{[^}]*}|{|}/,message:"This looks like LaTeX:\ndid you mean to put it inside dollar signs?"}),Rt=st.makeRule({name:"nested-lists",severity:st.Severity.WARNING,selector:"list list",message:"Nested lists:\nnested lists are hard to read on mobile devices;\ndo not use additional indentation."}),Ft=st.makeRule({name:"profanity",pattern:/\b(shit|piss|fuck|cunt|cocksucker|motherfucker|tits)\b/i,message:"Avoid profanity"}),Dt=st.makeRule({name:"table-missing-cells",severity:st.Severity.WARNING,selector:"table",lint:function(e,t,r,i){for(var n=r[0],s=n.header.length,o=n.cells.map((e=>e.length)),a=0;a<o.length;a++)if(o[a]!==s)return"Table rows don't match header:\nThe table header has ".concat(s," cells, but\nRow ").concat(a+1," has ").concat(o[a]," cells.")}}),Ot=st.makeRule({name:"unbalanced-code-delimiters",severity:st.Severity.ERROR,pattern:/[`~]+/,message:"Unbalanced code delimiters:\ncode blocks should begin and end with the same type and number of delimiters"}),Lt=[at,lt,pt,ht,ct,dt,ut,mt,ft,vt,bt,Ct,wt,kt,Et,St,_t,Mt,Tt,It,Pt,At,Rt,Dt,st.makeRule({name:"unescaped-dollar",severity:st.Severity.ERROR,selector:"unescapedDollar",message:"Unescaped dollar sign:\nDollar signs must appear in pairs or be escaped as \\$"}),st.makeRule({name:"widget-in-table",severity:st.Severity.BULK_WARNING,selector:"table widget",message:"Widget in table:\ndo not put widgets inside of tables."}),Ft,Nt,Ot,yt,xt];class Bt{constructor(e){V(this,"root",void 0),this.root=e}static isNode(e){return e&&"object"==typeof e&&"string"==typeof e.type}static isTextNode(e){return Bt.isNode(e)&&"text"===e.type&&"string"==typeof e.content}traverse(e){this._traverse(this.root,new zt(this.root),e)}_traverse(e,t,r){var i="";if(Bt.isNode(e)){var n=e;t._containers.push(n),t._ancestors.push(n),"string"==typeof n.content&&(i=n.content),Object.keys(n).forEach((e=>{if("type"!==e){var s=n[e];s&&"object"==typeof s&&(t._indexes.push(e),i+=this._traverse(s,t,r),t._indexes.pop())}})),t._currentNode=t._ancestors.pop(),t._containers.pop(),r(n,t,i)}else if(Array.isArray(e)){var s=e;t._containers.push(s);for(var o=0;o<s.length;)t._indexes.push(o),i+=this._traverse(s[o],t,r),o=t._indexes.pop()+1;t._containers.pop()}return i}}class zt{constructor(e){V(this,"root",void 0),V(this,"_currentNode",void 0),V(this,"_containers",void 0),V(this,"_indexes",void 0),V(this,"_ancestors",void 0),this.root=e,this._currentNode=null,this._containers=new qt,this._indexes=new qt,this._ancestors=new qt}currentNode(){return this._currentNode||this.root}parent(){return this._ancestors.top()}ancestors(){return this._ancestors.values()}nextSibling(){var e=this._containers.top();if(!e||!Array.isArray(e))return null;var t=this._indexes.top();return e.length>t+1?e[t+1]:null}previousSibling(){var e=this._containers.top();if(!e||!Array.isArray(e))return null;var t=this._indexes.top();return t>0?e[t-1]:null}removeNextSibling(){var e=this._containers.top();if(e&&Array.isArray(e)){var t=this._indexes.top();if(e.length>t+1)return e.splice(t+1,1)[0]}return null}replace(){var e=this._containers.top();if(!e)throw new he("Can't replace the root of the tree",le.Internal);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(Array.isArray(e)){var n=this._indexes.top();e.splice(n,1,...r),this._indexes.pop(),this._indexes.push(n+r.length-1)}else{var s=this._indexes.top();0===r.length?delete e[s]:1===r.length?e[s]=r[0]:e[s]=r}}hasPreviousSibling(){return Array.isArray(this._containers.top())&&this._indexes.top()>0}goToPreviousSibling(){if(!this.hasPreviousSibling())throw new he("goToPreviousSibling(): node has no previous sibling",le.Internal);this._currentNode=this.previousSibling();var e=this._indexes.pop();this._indexes.push(e-1)}hasParent(){return 0!==this._ancestors.size()}goToParent(){if(!this.hasParent())throw new he("goToParent(): node has no ancestor",le.NotAllowed);for(this._currentNode=this._ancestors.pop();this._containers.size()&&this._containers.top()[this._indexes.top()]!==this._currentNode;)this._containers.pop(),this._indexes.pop()}clone(){var e=new zt(this.root);return e._currentNode=this._currentNode,e._containers=this._containers.clone(),e._indexes=this._indexes.clone(),e._ancestors=this._ancestors.clone(),e}equals(e){return this.root===e.root&&this._currentNode===e._currentNode&&this._containers.equals(e._containers)&&this._indexes.equals(e._indexes)&&this._ancestors.equals(e._ancestors)}}class qt{constructor(e){V(this,"stack",void 0),this.stack=e?e.slice(0):[]}push(e){this.stack.push(e)}pop(){return this.stack.pop()}top(){return this.stack[this.stack.length-1]}values(){return this.stack.slice(0)}size(){return this.stack.length}toString(){return this.stack.toString()}clone(){return new qt(this.stack)}equals(e){if(!e||!e.stack||e.stack.length!==this.stack.length)return!1;for(var t=0;t<this.stack.length;t++)if(this.stack[t]!==e.stack[t])return!1;return!0}}var Ht=Lt.filter((e=>e.severity<st.Severity.BULK_WARNING));var Wt={runLinter:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ht,n=[],s=new Bt(e);s.traverse(((e,t,r)=>{if(Bt.isTextNode(e))for(var i=t.nextSibling();Bt.isTextNode(i);)e.content+=i.content,t.removeNextSibling(),i=t.nextSibling()}));var o=[],a=!1;return s.traverse(((e,s,l)=>{var p=[],h=i.filter((e=>e.applies(t))),c=[...t.stack];c.push(e.type);var d=U(U({},t),{},{stack:c.join(".")});if(h.forEach((t=>{var i=t.check(e,s,l,d);i&&((i.start||i.end)&&(i.target=l.substring(i.start,i.end)),n.push(i),r&&p.push(i))})),r&&("table"===e.type?(o.length&&p.push(...o),a=!1,o=[]):a||(a=s.ancestors().some((e=>"table"===e.type))),a&&p.length&&o.push(...p),p.length))if(p.sort(((e,t)=>e.severity-t.severity)),"text"!==e.type||p.length>1)s.replace({type:"lint",content:e,message:p.map((e=>e.message)).join("\n\n"),ruleName:p[0].rule,blockHighlight:d.blockHighlight,insideTable:a,severity:p[0].severity});else{var u=e.content,m=p[0],g=m.start||0,f=m.end||u.length,v=u.substring(0,g),b=u.substring(g,f),y=u.substring(f),x=[];v&&x.push({type:"text",content:v}),x.push({type:"lint",content:{type:"text",content:b},message:m.message,ruleName:m.rule,insideTable:a,severity:m.severity}),y&&x.push({type:"text",content:y}),s.replace(...x)}})),n},parse:Ye.parse,pushContextStack:function(e,t){var r=e.stack||[];return U(U({},e),{},{stack:r.concat(t)})},rules:Ht},Ut=h.shape({contentType:h.string,highlightLint:h.bool,paths:h.arrayOf(h.string),stack:h.arrayOf(h.string)}),Gt={contentType:"",highlightLint:!1,paths:[],stack:[]},Vt={};function jt(e){if(!Vt[e]){var t=f("<span>").text(e).appendTo("body");Vt[e]=t.width()+5,t.remove()}return Vt[e]}class Yt extends a.Component{constructor(){super(...arguments),V(this,"state",{items:this.props.options.concat("")}),V(this,"onChange",((e,t)=>{var r=l.clone(this.state.items);r[e]=t.target.value,e===r.length-1&&(r=r.concat("")),this.setState({items:r}),this.props.onChange(l.compact(r))})),V(this,"onKeyDown",((e,t)=>{var r=t.nativeEvent.keyCode;if(8===r&&""===this.state.items[e]){t.preventDefault();var i=l.clone(this.state.items),n=0===e?0:e-1;e!==i.length-1||0!==e&&""===i[n]?(i.splice(e,1),this.setState({items:i},(function(){g.findDOMNode(this.refs["input_"+n]).focus()}))):g.findDOMNode(this.refs["input_"+n]).focus()}else if(8===r&&1===this.state.items[e].length&&e===this.state.items.length-2){t.preventDefault();var s=l.clone(this.state.items);s.splice(e,1),this.setState({items:s}),this.props.onChange(l.compact(s))}else if(13===r){t.preventDefault();var o=l.clone(this.state.items),a=e+1;e===o.length-2?g.findDOMNode(this.refs["input_"+a]).focus():(o.splice(a,0,""),this.setState({items:o},(function(){g.findDOMNode(this.refs["input_"+a]).focus()})))}}))}UNSAFE_componentWillReceiveProps(e){this.setState({items:e.options.concat("")})}render(){var e=["perseus-text-list-editor","perseus-clearfix","layout-"+this.props.layout].join(" "),t=l.map(this.state.items,(function(e,t){return a.createElement("li",{key:t},a.createElement("input",{ref:"input_"+t,type:"text",value:e,onChange:this.onChange.bind(this,t),onKeyDown:this.onKeyDown.bind(this,t),style:{width:jt(e)}}))}),this);return a.createElement("ul",{className:e},t)}}V(Yt,"propTypes",{options:h.array,layout:h.string,onChange:h.func.isRequired}),V(Yt,"defaultProps",{options:[],layout:"horizontal"});var Xt=[];class $t extends a.Component{render(){return a.createElement("div",null,this.props.showTitle&&a.createElement("div",{style:{fontSize:14}},"Tags:"),a.createElement(Yt,{options:this.props.value||Xt,layout:"vertical",onChange:this.props.onChange}))}}V($t,"propTypes",{value:h.arrayOf(h.string),onChange:h.func.isRequired,showTitle:h.bool.isRequired}),V($t,"defaultProps",{value:Xt,showTitle:!0});var Kt={propTypes:h.shape({isArticle:h.bool.isRequired,satStyling:h.bool.isRequired,onInputError:h.func.isRequired,onFocusChange:h.func.isRequired,staticRender:h.bool.isRequired,GroupMetadataEditor:h.func.isRequired,showAlignmentOptions:h.bool.isRequired,readOnly:h.bool.isRequired,answerableCallback:h.func,getAnotherHint:h.func,interactionCallback:h.func,groupAnnotator:h.func.isRequired,imagePlaceholder:h.node,widgetPlaceholder:h.node,baseElements:h.shape({Link:h.func}),imagePreloader:h.func,trackInteraction:h.func,customKeypad:h.bool,nativeKeypadProxy:h.func,isMobile:h.bool,setDrawingAreaAvailable:h.func,useDraftEditor:h.bool,styling:h.shape({radioStyleVersion:h.oneOf(["intermediate","final"])}),hintProgressColor:h.string,canScrollPage:h.bool,inModal:h.bool,crossOutEnabled:h.bool,editorChangeDelay:h.number}).isRequired,defaults:{isArticle:!1,isMobile:!1,satStyling:!1,onInputError:function(){},onFocusChange:function(){},staticRender:!1,GroupMetadataEditor:$t,showAlignmentOptions:!1,readOnly:!1,groupAnnotator:function(){return null},baseElements:{Link:e=>a.createElement("a",e)},setDrawingAreaAvailable:function(){},useDraftEditor:!1,styling:{radioStyleVersion:"final"},canScrollPage:!1,inModal:!1,crossOutEnabled:!1,editorChangeDelay:0}},Zt={RENDERER:"perseus-renderer",TWO_COLUMN_RENDERER:"perseus-renderer-two-columns",RESPONSIVE_RENDERER:"perseus-renderer-responsive",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",MOBILE:"perseus-mobile"},Jt={assetStatuses:{},setAssetStatus:(e,t)=>{}},Qt=a.createContext(Jt);function er(e,t){var r=window.scrollX,i=window.scrollY,n=document.querySelector("meta[name=viewport]");n?n.setAttribute("content",e):f("head").append('<meta name="viewport" content="'.concat(e,'">')),document.body.style.opacity=.9999,setTimeout((()=>{document.body.style.opacity=1,window.scrollTo(r,i),t&&setTimeout(t,0)}),0)}function tr(){}function rr(e,t){this._fullHeight=this._fullWidth=this._overlay=null,this._targetImage=e,this._enableMobilePinch=t,this._$body=f(document.body)}f.fn.emulateTransitionEnd=function(e){var t=!1,r=this;f(this).one("bsTransitionEnd",(function(){t=!0}));return setTimeout((function(){t||f(r).trigger(f.support.transition.end)}),e),this},f((function(){f.support.transition=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var r in t)if(void 0!==e.style[r])return{end:t[r]};return!1}(),f.support.transition&&(f.event.special.bsTransitionEnd={bindType:f.support.transition.end,delegateType:f.support.transition.end,handle:function(e){if(f(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})),tr.prototype._initialize=function(e){this._$document||(this._activeZoom=this._initialScrollPosition=this._initialTouchPosition=this._touchMoveListener=null,this._$document=f(document),this._$window=f(window),this._$body=f(document.body),this._boundClick=f.proxy(this._clickHandler,this),this._enableMobilePinch=e)},tr.prototype.handleZoomClick=function(e,t){this._initialize(t);var r=e.target;if(r&&"IMG"===r.tagName&&!this._$body.hasClass("zoom-overlay-open"))return e.metaKey||e.ctrlKey?window.open(e.target.src,"_blank"):void(!t&&r.width>=window.innerWidth-rr.getOffset()||(this._activeZoomClose(!0),t?er("width=device-width, initial-scale=1, minimum-scale=1",(()=>this._zoom(r))):this._zoom(r),t||(this._$window.on("scroll.zoom",f.proxy(this._scrollHandler,this)),this._$document.on("keyup.zoom",f.proxy(this._keyHandler,this)),this._$document.on("touchstart.zoom",f.proxy(this._touchStart,this))),document.addEventListener("click",this._boundClick,!0),e.stopPropagation()))},tr.prototype._zoom=function(e){this._activeZoom=new rr(e,this._enableMobilePinch),this._activeZoom.zoomImage()},tr.prototype._activeZoomClose=function(e){this._activeZoom&&(e?(this._activeZoom.dispose(),this._disposeActiveZoom()):er("width=device-width, initial-scale=1, minimum-scale=1,\n maximum-scale=1",(()=>{this._activeZoom&&(this._activeZoom.close(),this._disposeActiveZoom())})))},tr.prototype._disposeActiveZoom=function(){this._$window.off(".zoom"),this._$document.off(".zoom"),document.removeEventListener("click",this._boundClick,!0),this._activeZoom=null},tr.prototype._scrollHandler=function(e){null===this._initialScrollPosition&&(this._initialScrollPosition=window.scrollY);var t=this._initialScrollPosition-window.scrollY;Math.abs(t)>=40&&this._activeZoomClose()},tr.prototype._keyHandler=function(e){27===e.keyCode&&this._activeZoomClose()},tr.prototype._clickHandler=function(e){e.stopPropagation(),e.preventDefault(),this._activeZoomClose()},tr.prototype._touchStart=function(e){this._initialTouchPosition=e.originalEvent.touches[0].pageY,f(e.target).on("touchmove.zoom",f.proxy(this._touchMove,this))},tr.prototype._touchMove=function(e){Math.abs(e.originalEvent.touches[0].pageY-this._initialTouchPosition)>10&&(this._activeZoomClose(),f(e.target).off("touchmove.zoom"))},rr._OFFSET=80,rr._MAX_WIDTH=2560,rr._MAX_HEIGHT=4096,rr.getOffset=function(e){return e?0:rr._OFFSET},rr.prototype.getOffset=function(){return rr.getOffset(this._enableMobilePinch)},rr.prototype.zoomImage=function(){var e=document.createElement("img"),t=f(e);e.onload=function(){this._fullHeight=Number(e.height),this._fullWidth=Number(e.width);var r=this._imageOffset=f(this._targetImage).offset(),i=this._left=r.left-f(window).scrollLeft(),n=this._top=r.top-f(window).scrollTop();t.css({left:i,top:n,width:this._targetImage.width,height:this._targetImage.height}),this._zoomOriginal()}.bind(this),e.src=this._targetImage.src,this.$zoomedImage=t},rr.prototype._zoomOriginal=function(){var e,t,r;this.$zoomedImage.addClass("zoom-img").attr("data-action","zoom-out"),f(this._targetImage).css("visibility","hidden"),this._backdrop=document.createElement("div"),this._backdrop.className="zoom-backdrop",null===(e=document.body)||void 0===e||e.appendChild(this._backdrop),this._overlay=document.createElement("div"),this._overlay.className="zoom-overlay",null===(t=document.body)||void 0===t||t.appendChild(this._overlay),null===(r=this._overlay)||void 0===r||r.appendChild(this.$zoomedImage[0]),this._calculateZoom(),this._triggerAnimation()},rr.prototype._calculateZoom=function(){var e=this._fullWidth,t=this._fullHeight,r=window.innerHeight-this.getOffset(),i=window.innerWidth-this.getOffset(),n=e/this._targetImage.width,s=e/t,o=i/r;this._imgScaleFactor=e<i&&t<r?n:s<o?r/t*n:i/(null!=e?e:0)*n},rr.prototype._triggerAnimation=function(){var e=f(window).scrollTop()+window.innerHeight/2,t=f(window).scrollLeft()+window.innerWidth/2,r=this._imgScaleFactor,i=this._imageOffset.top+this._targetImage.height/2,n=this._imageOffset.left+this._targetImage.width/2;this._translateY=(e-i)/r,this._translateX=(t-n)/r,this._zoomedInTransformString="\n scale(".concat(r,")\n translate3d(").concat(this._translateX,"px, ").concat(this._translateY,"px, 0)\n "),this.$zoomedImage.css({transform:this._zoomedInTransformString}).addClass("zoom-transition").one(f.support.transition.end,f.proxy(this._onZoomInFinish,this)).emulateTransitionEnd(300),this._$body.addClass("zoom-overlay-open")},rr.prototype._onZoomInFinish=function(){var e=this._targetImage.height*this._imgScaleFactor,t=this._targetImage.width*this._imgScaleFactor,r=0,i=0,n=0,s=0,o=0,a=0;t<window.innerWidth?(r="50%",n=-t/2):o=(t-window.innerWidth)/2,e<window.innerHeight?(i="50%",s=-e/2):a=(e-window.innerHeight)/2,this.$zoomedImage.css({height:e,left:r,marginLeft:n,marginTop:s,top:i,transform:"",width:t}).removeClass("zoom-transition"),f(this._overlay).scrollLeft(o).scrollTop(a)},rr.prototype.close=function(){this._$body.removeClass("zoom-overlay-open").addClass("zoom-overlay-transitioning"),this.$zoomedImage.css({height:this._targetImage.height,left:this._left,marginLeft:0,marginTop:0,top:this._top,transform:this._zoomedInTransformString,width:this._targetImage.width}).removeClass("zoom-transition"),f(this._overlay).scrollLeft(0).scrollTop(0),setTimeout((()=>{this.$zoomedImage.css({transform:"scale(1)"}).addClass("zoom-transition").one(f.support.transition.end,f.proxy(this.dispose,this)).emulateTransitionEnd(300)}),10)},rr.prototype.dispose=function(){this.$zoomedImage&&this.$zoomedImage[0].parentNode&&(this.$zoomedImage.remove(),this.$zoomedImage=null,this._overlay.parentNode.removeChild(this._overlay),this._backdrop.parentNode.removeChild(this._backdrop),this._$body.removeClass("zoom-overlay-transitioning")),f(this._targetImage).css("visibility","visible"),this._targetImage.focus()};var ir=new tr,nr=w({displayName:"FixedToResponsive",propTypes:{width:h.number.isRequired,height:h.number.isRequired,className:h.string,constrainHeight:h.bool,allowFullBleed:h.bool},getDefaultProps:function(){return{className:"",constrainHeight:!1,allowFullBleed:!1}},getInitialState:function(){return{viewportHeight:null,viewportWidth:null}},componentDidMount:function(){this._isMounted=!0,window.innerHeight<480?setTimeout(this._cacheViewportSize,800):this._cacheViewportSize()},componentWillUnmount:function(){this._isMounted=!1},_cacheViewportSize:function(){this._isMounted&&this.setState({viewportHeight:Math.max(480,window.innerHeight),viewportWidth:window.innerWidth})},render:function(){var e=this.props.width/this.props.height,t=a.createElement("div",{style:{paddingBottom:100*(1/e).toFixed(4)+"%"}}),{width:r,height:i}=this.props;if(this.props.constrainHeight&&this.state.viewportHeight){var n=2/3*this.state.viewportHeight;this.props.height>=n&&(i=n,r=n*e)}var s={maxWidth:r,maxHeight:i},l=o("fixed-to-responsive",this.props.className),p=a.createElement("div",{className:l,style:s},t,this.props.children);return this.props.allowFullBleed&&this.state.viewportWidth&&r>=this.state.viewportWidth?a.createElement("div",{style:{marginLeft:-16,marginRight:-16}},p):p}});function sr(e,t){return e+":"+t}var or={_fireEvent:function(e,t,r){l.invoke(e,"call",this,t,r)},_applyConstraints:function(e,t,r){var i=!1;return l.reduce(this.state.constraints,((e,n)=>{if(!1===e)return!1;if(i)return e;var s=n.call(this,e,t,U({onSkipRemaining:()=>{i=!0}},r));if(!1===s)return!1;if(b.is(s,2))return s;if(!0===s||null==s)return e;throw new he("Constraint returned invalid result: "+s,le.Internal)}),e,this)},draw:function(){var e=this.cloneState();or._fireEvent.call(this,this.state.draw,e,this.prevState),this.prevState=e},listen:function(e,t,r){this._listenerMap=this._listenerMap||{};var i=sr(e,t),n=this._listenerMap[i]=this._listenerMap[i]||this.state[e].length;this.state[e][n]=r},unlisten:function(e,t){this._listenerMap=this._listenerMap||{};var r=sr(e,t),i=this._listenerMap[r];if(void 0!==i){this.state[e].splice(i,1),delete this._listenerMap[r];var n=l.keys(this._listenerMap);l.each(n,(function(t){(function(e){return e.split(":")[0]})(t)===e&&this._listenerMap[t]>i&&this._listenerMap[t]--}),this)}}},ar=null;var lr=null;var pr={assert:function(e,t){if(!e)throw new he("Assertion Error"+(t?": "+t:""),le.Internal)},createGettersFor:function(e,t){l.each(l.keys(t),(function(t){void 0===e.prototype[t]&&(e.prototype[t]=function(){return this.state[t]})}))},addMovableHelperMethodsTo:function(e){l.each(or,(function(t,r){void 0===e.prototype[r]&&(e.prototype[r]=t)}))},arrayify:function(e){return null==e?[]:l.isArray(e)?l.filter(l.flatten(e),l.identity):[e]},normalizeOptions:function(e,t){var r=l.clone(t);return l.each(e,(function(e){var i=t[e];if(void 0!==i){var n=pr.arrayify(i);r[e]=n}})),r},getPrefixedTransform:function(){var e,t;return ar=ar||(e=document.createElement("div"),t=null,l.each(["transform","msTransform","MozTransform","WebkitTransform","OTransform"],(function(r){void 0!==e.style[r]&&(t=r)})),t)},getCanUse3dTransform:function(){var e,t;return null==lr&&(e=document.createElement("div"),t=pr.getPrefixedTransform(),e.style[t]="translateZ(0px)",lr=!!e.style[t]),lr}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function hr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var cr={exports:{}};
2
2
  /*!
3
3
  * Raphael 1.5.2 - JavaScript Vector Library
4
4
  *
5
5
  * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
6
6
  * Licensed under the MIT (http://raphaeljs.com/license.html) license.
7
- */!function(){var e;function t(){if(t.is(arguments[0],I)){for(var e=arguments[0],r=He[d](t,e.splice(0,3+t.is(e[0],M))),i=r.set(),o=0,s=e[b];o<s;o++){var l=e[o]||{};n[a](l.type)&&i[A](r[l.type]().attr(l))}return i}return He[d](t,arguments)}e="".trim?function(e,t,r){e.setAttribute(t,String(r).trim())}:function(e,t,r){e.setAttribute(t,String(r))},t.version="1.5.2";var r,i=/[, ]+/,n={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},o=/\{(\d+)\}/g,s="prototype",a="hasOwnProperty",l=document,p=window,h={was:Object[s][a].call(p,"Raphael"),is:p.Raphael},c=function(){this.customAttributes={}},d="apply",u="createTouch"in l,m="",g=" ",f=String,v="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend".split(g),y={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},b="length",x=f[s].toLowerCase,w=Math,C=w.max,k=w.min,E=w.abs,S=w.pow,_=w.PI,M="number",T="string",I="array",P="fill",N=Object[s].toString,A="push",R=/^url\(['"]?([^\)]+?)['"]?\)$/i,F=/^\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,O={NaN:1,Infinity:1,"-Infinity":1},D=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,L=w.round,B=parseFloat,z=parseInt,H=" progid:DXImageTransform.Microsoft",W=f[s].toUpperCase,q={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},U={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},G="replace",V=/^(from|to|\d+%?)$/,j=/\s*,\s*/,Y={hs:1,rg:1},$=/,?([achlmqrstvxz]),?/gi,X=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/gi,K=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/gi,Z=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,J=function(e,t){return e.key-t.key};if(t.type=p.SVGAngle||l.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML","VML"==t.type){var Q,ee=l.createElement("div");if(ee.innerHTML='<v:shape adj="1"/>',(Q=ee.firstChild).style.behavior="url(#default#VML)",!Q||"object"!=typeof Q.adj)return t.type=null;ee=null}function te(){for(var e=[],t=0;t<32;t++)e[t]=(~~(16*w.random())).toString(16);return e[12]=4,e[16]=(3&e[16]|8).toString(16),"r-"+e.join("")}t.svg=!(t.vml="VML"==t.type),c[s]=t[s],r=c[s],t._id=0,t._oid=0,t.fn={},t.is=function(e,t){return"finite"==(t=x.call(t))?!O[a](+e):"null"==t&&null===e||t==typeof e||"object"==t&&e===Object(e)||"array"==t&&Array.isArray&&Array.isArray(e)||N.call(e).slice(8,-1).toLowerCase()==t},t.angle=function(e,r,i,n,o,s){if(null==o){var a=e-i,l=r-n;return a||l?(180*(a<0)+180*w.atan(-l/-a)/_+360)%360:0}return t.angle(e,r,o,s)-t.angle(i,n,o,s)},t.rad=function(e){return e%360*_/180},t.deg=function(e){return 180*e/_%360},t.snapTo=function(e,r,i){if(i=t.is(i,"finite")?i:10,t.is(e,I)){for(var n=e.length;n--;)if(E(e[n]-r)<=i)return e[n]}else{var o=r%(e=+e);if(o<i)return r-o;if(o>e-i)return r-o+e}return r},t.setWindow=function(e){l=(p=e).document};var re=function(e){if(t.vml){var r,i=/^\s+|\s+$/g;try{var n=new ActiveXObject("htmlfile");n.write("<body>"),n.close(),r=n.body}catch(e){r=createPopup().document.body}var o=r.createTextRange();re=se((function(e){try{r.style.color=f(e)[G](i,m);var t=o.queryCommandValue("ForeColor");return"#"+("000000"+(t=(255&t)<<16|65280&t|(16711680&t)>>>16).toString(16)).slice(-6)}catch(e){return"none"}}))}else{var s=l.createElement("i");s.title="Raphaël Colour Picker",s.style.display="none",l.body.appendChild(s),re=se((function(e){return s.style.color=e,l.defaultView.getComputedStyle(s,m).getPropertyValue("color")}))}return re(e)},ie=function(){return"hsb("+[this.h,this.s,this.b]+")"},ne=function(){return"hsl("+[this.h,this.s,this.l]+")"},oe=function(){return this.hex};function se(e,t,r){return function i(){var n=Array[s].slice.call(arguments,0),o=n.join("►"),l=i.cache=i.cache||{},p=i.count=i.count||[];return l[a](o)||(p[b]>=1e3&&delete l[p.shift()],p[A](o),l[o]=e[d](t,n)),r?r(l[o]):l[o]}}t.hsb2rgb=function(e,r,i,n){return t.is(e,"object")&&"h"in e&&"s"in e&&"b"in e&&(i=e.b,r=e.s,n=(e=e.h).o),t.hsl2rgb(e,r,i/2,n)},t.hsl2rgb=function(e,r,i,n){t.is(e,"object")&&"h"in e&&"s"in e&&"l"in e&&(i=e.l,r=e.s,e=e.h),(e>1||r>1||i>1)&&(e/=360,r/=100,i/=100);var o,s,a,l={},p=["r","g","b"];if(r){s=2*i-(o=i<.5?i*(1+r):i+r-i*r);for(var h=0;h<3;h++)(a=e+1/3*-(h-1))<0&&a++,a>1&&a--,l[p[h]]=6*a<1?s+6*(o-s)*a:2*a<1?o:3*a<2?s+(o-s)*(2/3-a)*6:s}else l={r:i,g:i,b:i};return l.r*=255,l.g*=255,l.b*=255,l.hex="#"+(16777216|l.b|l.g<<8|l.r<<16).toString(16).slice(1),t.is(n,"finite")&&(l.opacity=n),l.toString=oe,l},t.rgb2hsb=function(e,r,i){if(null==r&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(i=e.b,r=e.g,e=e.r),null==r&&t.is(e,T)){var n=t.getRGB(e);e=n.r,r=n.g,i=n.b}(e>1||r>1||i>1)&&(e/=255,r/=255,i/=255);var o,s=C(e,r,i),a=k(e,r,i);if(a==s)return{h:0,s:0,b:s,toString:ie};var l=s-a;return o=e==s?(r-i)/l:r==s?2+(i-e)/l:4+(e-r)/l,(o/=6)<0&&o++,o>1&&o--,{h:o,s:l/s,b:s,toString:ie}},t.rgb2hsl=function(e,r,i){if(null==r&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(i=e.b,r=e.g,e=e.r),null==r&&t.is(e,T)){var n=t.getRGB(e);e=n.r,r=n.g,i=n.b}(e>1||r>1||i>1)&&(e/=255,r/=255,i/=255);var o,s,a=C(e,r,i),l=k(e,r,i),p=(a+l)/2;if(l==a)s={h:0,s:0,l:p};else{var h=a-l;o=e==a?(r-i)/h:r==a?2+(i-e)/h:4+(e-r)/h,(o/=6)<0&&o++,o>1&&o--,s={h:o,s:p<.5?h/(a+l):h/(2-a-l),l:p}}return s.toString=ne,s},t._path2string=function(){return this.join(",")[G]($,"$1")},t.getRGB=se((function(e){if(!e||(e=f(e)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if("none"==e)return{r:-1,g:-1,b:-1,hex:"none"};!Y[a](e.toLowerCase().substring(0,2))&&"#"!=e.charAt()&&(e=re(e));var r,i,n,o,s,l,p=e.match(F);return p?(p[2]&&(n=z(p[2].substring(5),16),i=z(p[2].substring(3,5),16),r=z(p[2].substring(1,3),16)),p[3]&&(n=z((s=p[3].charAt(3))+s,16),i=z((s=p[3].charAt(2))+s,16),r=z((s=p[3].charAt(1))+s,16)),p[4]&&(l=p[4].split(j),r=B(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=B(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=B(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),"rgba"==p[1].toLowerCase().slice(0,4)&&(o=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(o/=100)),p[5]?(l=p[5].split(j),r=B(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=B(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=B(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(r/=360),"hsba"==p[1].toLowerCase().slice(0,4)&&(o=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(o/=100),t.hsb2rgb(r,i,n,o)):p[6]?(l=p[6].split(j),r=B(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=B(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=B(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(r/=360),"hsla"==p[1].toLowerCase().slice(0,4)&&(o=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(o/=100),t.hsl2rgb(r,i,n,o)):((p={r:r,g:i,b:n}).hex="#"+(16777216|n|i<<8|r<<16).toString(16).slice(1),t.is(o,"finite")&&(p.opacity=o),p)):{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},r=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})),r.hex},t.getColor.reset=function(){delete this.start},t.parsePathString=se((function(e){if(!e)return null;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},i=[];return t.is(e,I)&&t.is(e[0],I)&&(i=le(e)),i[b]||f(e)[G](X,(function(e,t,n){var o=[],s=x.call(t);for(n[G](K,(function(e,t){t&&o[A](+t)})),"m"==s&&o[b]>2&&(i[A]([t].concat(o.splice(0,2))),s="l",t="m"==t?"l":"L");o[b]>=r[s]&&(i[A]([t].concat(o.splice(0,r[s]))),r[s]););})),i.toString=t._path2string,i})),t.findDotsAtSegment=function(e,t,r,i,n,o,s,a,l){var p=1-l,h=S(p,3)*e+3*S(p,2)*l*r+3*p*l*l*n+S(l,3)*s,c=S(p,3)*t+3*S(p,2)*l*i+3*p*l*l*o+S(l,3)*a,d=e+2*l*(r-e)+l*l*(n-2*r+e),u=t+2*l*(i-t)+l*l*(o-2*i+t),m=r+2*l*(n-r)+l*l*(s-2*n+r),g=i+2*l*(o-i)+l*l*(a-2*o+i),f=(1-l)*e+l*r,v=(1-l)*t+l*i,y=(1-l)*n+l*s,b=(1-l)*o+l*a,x=90-180*w.atan((d-m)/(u-g))/_;return(d>m||u<g)&&(x+=180),{x:h,y:c,m:{x:d,y:u},n:{x:m,y:g},start:{x:f,y:v},end:{x:y,y:b},alpha:x}};var ae=se((function(e){if(!e)return{x:0,y:0,width:0,height:0};for(var t,r=0,i=0,n=[],o=[],s=0,a=(e=fe(e))[b];s<a;s++)if("M"==(t=e[s])[0])r=t[1],i=t[2],n[A](r),o[A](i);else{var l=ge(r,i,t[1],t[2],t[3],t[4],t[5],t[6]);n=n.concat(l.min.x,l.max.x),o=o.concat(l.min.y,l.max.y),r=t[5],i=t[6]}var p=k[d](0,n),h=k[d](0,o);return{x:p,y:h,width:C[d](0,n)-p,height:C[d](0,o)-h}})),le=function(e){var r=[];t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));for(var i=0,n=e[b];i<n;i++){r[i]=[];for(var o=0,s=e[i][b];o<s;o++)r[i][o]=e[i][o]}return r.toString=t._path2string,r},pe=se((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var r=[],i=0,n=0,o=0,s=0,a=0;"M"==e[0][0]&&(o=i=e[0][1],s=n=e[0][2],a++,r[A](["M",i,n]));for(var l=a,p=e[b];l<p;l++){var h=r[l]=[],c=e[l];if(c[0]!=x.call(c[0]))switch(h[0]=x.call(c[0]),h[0]){case"a":h[1]=c[1],h[2]=c[2],h[3]=c[3],h[4]=c[4],h[5]=c[5],h[6]=+(c[6]-i).toFixed(3),h[7]=+(c[7]-n).toFixed(3);break;case"v":h[1]=+(c[1]-n).toFixed(3);break;case"m":o=c[1],s=c[2];default:for(var d=1,u=c[b];d<u;d++)h[d]=+(c[d]-(d%2?i:n)).toFixed(3)}else{h=r[l]=[],"m"==c[0]&&(o=c[1]+i,s=c[2]+n);for(var m=0,g=c[b];m<g;m++)r[l][m]=c[m]}var f=r[l][b];switch(r[l][0]){case"z":i=o,n=s;break;case"h":i+=+r[l][f-1];break;case"v":n+=+r[l][f-1];break;default:i+=+r[l][f-2],n+=+r[l][f-1]}}return r.toString=t._path2string,r}),0,le),he=se((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var r=[],i=0,n=0,o=0,s=0,a=0;"M"==e[0][0]&&(o=i=+e[0][1],s=n=+e[0][2],a++,r[0]=["M",i,n]);for(var l=a,p=e[b];l<p;l++){var h=r[l]=[],c=e[l];if(c[0]!=W.call(c[0]))switch(h[0]=W.call(c[0]),h[0]){case"A":h[1]=c[1],h[2]=c[2],h[3]=c[3],h[4]=c[4],h[5]=c[5],h[6]=+(c[6]+i),h[7]=+(c[7]+n);break;case"V":h[1]=+c[1]+n;break;case"H":h[1]=+c[1]+i;break;case"M":o=+c[1]+i,s=+c[2]+n;default:for(var d=1,u=c[b];d<u;d++)h[d]=+c[d]+(d%2?i:n)}else for(var m=0,g=c[b];m<g;m++)r[l][m]=c[m];switch(h[0]){case"Z":i=o,n=s;break;case"H":i=h[1];break;case"V":n=h[1];break;case"M":o=r[l][r[l][b]-2],s=r[l][r[l][b]-1];default:i=r[l][r[l][b]-2],n=r[l][r[l][b]-1]}}return r.toString=t._path2string,r}),null,le),ce=function(e,t,r,i){return[e,t,r,i,r,i]},de=function(e,t,r,i,n,o){var s=1/3,a=2/3;return[s*e+a*r,s*t+a*i,s*n+a*r,s*o+a*i,n,o]},ue=function e(t,r,i,n,o,s,a,l,p,h){var c,d=120*_/180,u=_/180*(+o||0),m=[],g=se((function(e,t,r){return{x:e*w.cos(r)-t*w.sin(r),y:e*w.sin(r)+t*w.cos(r)}}));if(h)T=h[0],I=h[1],S=h[2],M=h[3];else{t=(c=g(t,r,-u)).x,r=c.y;var f=(t-(l=(c=g(l,p,-u)).x))/2,v=(r-(p=c.y))/2,y=f*f/(i*i)+v*v/(n*n);y>1&&(i*=y=w.sqrt(y),n*=y);var x=i*i,C=n*n,k=(s==a?-1:1)*w.sqrt(E((x*C-x*v*v-C*f*f)/(x*v*v+C*f*f))),S=k*i*v/n+(t+l)/2,M=k*-n*f/i+(r+p)/2,T=w.asin(((r-M)/n).toFixed(9)),I=w.asin(((p-M)/n).toFixed(9));(T=t<S?_-T:T)<0&&(T=2*_+T),(I=l<S?_-I:I)<0&&(I=2*_+I),a&&T>I&&(T-=2*_),!a&&I>T&&(I-=2*_)}var P=I-T;if(E(P)>d){var N=I,A=l,R=p;I=T+d*(a&&I>T?1:-1),m=e(l=S+i*w.cos(I),p=M+n*w.sin(I),i,n,o,0,a,A,R,[I,N,S,M])}P=I-T;var F=w.cos(T),O=w.sin(T),D=w.cos(I),L=w.sin(I),B=w.tan(P/4),z=4/3*i*B,H=4/3*n*B,W=[t,r],q=[t+z*O,r-H*F],U=[l+z*L,p-H*D],G=[l,p];if(q[0]=2*W[0]-q[0],q[1]=2*W[1]-q[1],h)return[q,U,G].concat(m);for(var V=[],j=0,Y=(m=[q,U,G].concat(m).join().split(","))[b];j<Y;j++)V[j]=j%2?g(m[j-1],m[j],u).y:g(m[j],m[j+1],u).x;return V},me=function(e,t,r,i,n,o,s,a,l){var p=1-l;return{x:S(p,3)*e+3*S(p,2)*l*r+3*p*l*l*n+S(l,3)*s,y:S(p,3)*t+3*S(p,2)*l*i+3*p*l*l*o+S(l,3)*a}},ge=se((function(e,t,r,i,n,o,s,a){var l,p=n-2*r+e-(s-2*n+r),h=2*(r-e)-2*(n-r),c=e-r,u=(-h+w.sqrt(h*h-4*p*c))/2/p,m=(-h-w.sqrt(h*h-4*p*c))/2/p,g=[t,a],f=[e,s];return E(u)>"1e12"&&(u=.5),E(m)>"1e12"&&(m=.5),u>0&&u<1&&(l=me(e,t,r,i,n,o,s,a,u),f[A](l.x),g[A](l.y)),m>0&&m<1&&(l=me(e,t,r,i,n,o,s,a,m),f[A](l.x),g[A](l.y)),p=o-2*i+t-(a-2*o+i),c=t-i,u=(-(h=2*(i-t)-2*(o-i))+w.sqrt(h*h-4*p*c))/2/p,m=(-h-w.sqrt(h*h-4*p*c))/2/p,E(u)>"1e12"&&(u=.5),E(m)>"1e12"&&(m=.5),u>0&&u<1&&(l=me(e,t,r,i,n,o,s,a,u),f[A](l.x),g[A](l.y)),m>0&&m<1&&(l=me(e,t,r,i,n,o,s,a,m),f[A](l.x),g[A](l.y)),{min:{x:k[d](0,f),y:k[d](0,g)},max:{x:C[d](0,f),y:C[d](0,g)}}})),fe=se((function(e,t){for(var r=he(e),i=t&&he(t),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},o={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},s=function(e,t){if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C"].concat(ue[d](0,[t.x,t.y].concat(e.slice(1))));break;case"S":e=["C",t.x+(t.x-(t.bx||t.x)),t.y+(t.y-(t.by||t.y))].concat(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"].concat(de(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"].concat(de(t.x,t.y,e[1],e[2],e[3],e[4]));break;case"L":e=["C"].concat(ce(t.x,t.y,e[1],e[2]));break;case"H":e=["C"].concat(ce(t.x,t.y,e[1],t.y));break;case"V":e=["C"].concat(ce(t.x,t.y,t.x,e[1]));break;case"Z":e=["C"].concat(ce(t.x,t.y,t.X,t.Y))}return e},a=function(e,t){if(e[t][b]>7){e[t].shift();for(var n=e[t];n[b];)e.splice(t++,0,["C"].concat(n.splice(0,6)));e.splice(t,1),h=C(r[b],i&&i[b]||0)}},l=function(e,t,n,o,s){e&&t&&"M"==e[s][0]&&"M"!=t[s][0]&&(t.splice(s,0,["M",o.x,o.y]),n.bx=0,n.by=0,n.x=e[s][1],n.y=e[s][2],h=C(r[b],i&&i[b]||0))},p=0,h=C(r[b],i&&i[b]||0);p<h;p++){r[p]=s(r[p],n),a(r,p),i&&(i[p]=s(i[p],o)),i&&a(i,p),l(r,i,n,o,p),l(i,r,o,n,p);var c=r[p],u=i&&i[p],m=c[b],g=i&&u[b];n.x=c[m-2],n.y=c[m-1],n.bx=B(c[m-4])||n.x,n.by=B(c[m-3])||n.y,o.bx=i&&(B(u[g-4])||o.x),o.by=i&&(B(u[g-3])||o.y),o.x=i&&u[g-2],o.y=i&&u[g-1]}return i?[r,i]:r}),null,le),ve=se((function(e){for(var r=[],i=0,n=e[b];i<n;i++){var o={},s=e[i].match(/^([^:]*):?([\d\.]*)/);if(o.color=t.getRGB(s[1]),o.color.error)return null;o.color=o.color.hex,s[2]&&(o.offset=s[2]+"%"),r[A](o)}for(i=1,n=r[b]-1;i<n;i++)if(!r[i].offset){for(var a=B(r[i-1].offset||0),l=0,p=i+1;p<n;p++)if(r[p].offset){l=r[p].offset;break}l||(l=100,p=n);for(var h=((l=B(l))-a)/(p-i+1);i<p;i++)a+=h,r[i].offset=a+"%"}return r})),ye=function(e,r,i,n){var o;return t.is(e,T)||t.is(e,"object")?(o=t.is(e,T)?l.getElementById(e):e).tagName?null==r?{container:o,width:o.style.pixelWidth||o.offsetWidth,height:o.style.pixelHeight||o.offsetHeight}:{container:o,width:r,height:i}:void 0:{container:1,x:e,y:r,width:i,height:n}},be=function e(t,r){var i=this;for(var n in r)if(r[a](n)&&!(n in t))switch(typeof r[n]){case"function":!function(e){t[n]=t===i?e:function(){return e[d](i,arguments)}}(r[n]);break;case"object":t[n]=t[n]||{},e.call(this,t[n],r[n]);break;default:t[n]=r[n]}},xe=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)},we=function(e,t){t.top!==e&&(xe(e,t),e.next=null,e.prev=t.top,t.top.next=e,t.top=e)},Ce=function(e,t){t.bottom!==e&&(xe(e,t),e.next=t.bottom,e.prev=null,t.bottom.prev=e,t.bottom=e)},ke=function(e,t,r){xe(e,r),t==r.top&&(r.top=e),t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e},Ee=function(e,t,r){xe(e,r),t==r.bottom&&(r.bottom=e),t.prev&&(t.prev.next=e),e.prev=t.prev,t.prev=e,e.next=t},Se=function(e){return function(){throw new Error("Raphaël: you are calling to method “"+e+"” of removed object")}};if(t.pathToRelative=pe,t.svg){r.svgns="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",L=function(e){return+e+.5*(~~e===e)};var _e=function(t,i){if(!i)return(t=l.createElementNS(r.svgns,t)).style.webkitTapHighlightColor="rgba(0,0,0,0)",t;for(var n in i)i[a](n)&&e(t,n,f(i[n]))};t.toString=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var Me=function(e,t){var r=_e("path");t.canvas&&t.canvas.appendChild(r);var i=new Ae(r,t);return i.type="path",Pe(i,{fill:"none",stroke:"#000",path:e}),i},Te=function(e,t,r){var i="linear",n=.5,o=.5,s=e.style;if(t=(t=f(t)[G](Z,(function(e,t,r){if(i="radial",t&&r){n=B(t);var s=2*((o=B(r))>.5)-1;S(n-.5,2)+S(o-.5,2)>.25&&(o=w.sqrt(.25-S(n-.5,2))*s+.5)&&.5!=o&&(o=o.toFixed(5)-1e-5*s)}return m}))).split(/\s*\-\s*/),"linear"==i){var a=t.shift();if(a=-B(a),isNaN(a))return null;var p=[0,0,w.cos(a*_/180),w.sin(a*_/180)],h=1/(C(E(p[2]),E(p[3]))||1);p[2]*=h,p[3]*=h,p[2]<0&&(p[0]=-p[2],p[2]=0),p[3]<0&&(p[1]=-p[3],p[3]=0)}var c=ve(t);if(!c)return null;var d=e.getAttribute(P);(d=d.match(/^url\(#(.*)\)$/))&&r.defs.removeChild(l.getElementById(d[1]));var u=_e(i+"Gradient");u.id=te(),_e(u,"radial"==i?{fx:n,fy:o}:{x1:p[0],y1:p[1],x2:p[2],y2:p[3]}),r.defs.appendChild(u);for(var g=0,v=c[b];g<v;g++){var y=_e("stop");_e(y,{offset:c[g].offset?c[g].offset:g?"100%":"0%","stop-color":c[g].color||"#fff"}),u.appendChild(y)}return _e(e,{fill:"url(#"+u.id+")",opacity:1,"fill-opacity":1}),s.fill=m,s.opacity=1,s.fillOpacity=1,1},Ie=function(e){var r=e.getBBox();_e(e.pattern,{patternTransform:t.format("translate({0},{1})",r.x,r.y)})},Pe=function(r,n){var o={"":[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]},s=r.node,p=r.attrs,h=r.rotate(),c=function(e,t){if(t=o[x.call(t)]){for(var r=e.attrs["stroke-width"]||"1",i={round:r,square:r,butt:0}[e.attrs["stroke-linecap"]||n["stroke-linecap"]]||0,a=[],l=t[b];l--;)a[l]=t[l]*r+(l%2?1:-1)*i;_e(s,{"stroke-dasharray":a.join(",")})}};n[a]("rotation")&&(h=n.rotation);var d=f(h).split(i);for(var u in d.length-1?(d[1]=+d[1],d[2]=+d[2]):d=null,B(h)&&r.rotate(0,!0),n)if(n[a](u)){if(!q[a](u))continue;var v=n[u];switch(p[u]=v,u){case"blur":r.blur(v);break;case"rotation":r.rotate(v,!0);break;case"href":case"title":case"target":var y=s.parentNode;if("a"!=x.call(y.tagName)){var w=_e("a");y.insertBefore(w,s),w.appendChild(s),y=w}"target"==u&&"blank"==v?y.setAttributeNS(r.paper.xlink,"show","new"):y.setAttributeNS(r.paper.xlink,u,v);break;case"cursor":s.style.cursor=v;break;case"clip-rect":var C=f(v).split(i);if(4==C[b]){r.clip&&r.clip.parentNode.parentNode.removeChild(r.clip.parentNode);var k=_e("clipPath"),E=_e("rect");k.id=te(),_e(E,{x:C[0],y:C[1],width:C[2],height:C[3]}),k.appendChild(E),r.paper.defs.appendChild(k),_e(s,{"clip-path":"url(#"+k.id+")"}),r.clip=E}if(!v){var S=l.getElementById(s.getAttribute("clip-path")[G](/(^url\(#|\)$)/g,m));S&&S.parentNode.removeChild(S),_e(s,{"clip-path":m}),delete r.clip}break;case"path":"path"==r.type&&_e(s,{d:v?p.path=he(v):"M0,0"});break;case"width":if(e(s,u,v),!p.fx)break;u="x",v=p.x;case"x":p.fx&&(v=-p.x-(p.width||0));case"rx":if("rx"==u&&"rect"==r.type)break;case"cx":d&&("x"==u||"cx"==u)&&(d[1]+=v-p[u]),e(s,u,v),r.pattern&&Ie(r);break;case"height":if(e(s,u,v),!p.fy)break;u="y",v=p.y;case"y":p.fy&&(v=-p.y-(p.height||0));case"ry":if("ry"==u&&"rect"==r.type)break;case"cy":d&&("y"==u||"cy"==u)&&(d[2]+=v-p[u]),e(s,u,v),r.pattern&&Ie(r);break;case"r":"rect"==r.type?_e(s,{rx:v,ry:v}):e(s,u,v);break;case"src":"image"==r.type&&s.setAttributeNS(r.paper.xlink,"href",v);break;case"stroke-width":s.style.strokeWidth=v,e(s,u,v),p["stroke-dasharray"]&&c(r,p["stroke-dasharray"]);break;case"stroke-dasharray":c(r,v);break;case"translation":var _=f(v).split(i);_[0]=+_[0]||0,_[1]=+_[1]||0,d&&(d[1]+=_[0],d[2]+=_[1]),vt.call(r,_[0],_[1]);break;case"scale":_=f(v).split(i),r.scale(+_[0]||1,+_[1]||+_[0]||1,isNaN(B(_[2]))?null:+_[2],isNaN(B(_[3]))?null:+_[3]);break;case P:var M=f(v).match(R);if(M){k=_e("pattern");var T=_e("image");k.id=te(),_e(k,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1}),_e(T,{x:0,y:0}),T.setAttributeNS(r.paper.xlink,"href",M[1]),k.appendChild(T);var I=l.createElement("img");I.style.cssText="position:absolute;left:-9999em;top-9999em",I.onload=function(){_e(k,{width:this.offsetWidth,height:this.offsetHeight}),_e(T,{width:this.offsetWidth,height:this.offsetHeight}),l.body.removeChild(this),r.paper.safari()},l.body.appendChild(I),I.src=M[1],r.paper.defs.appendChild(k),s.style.fill="url(#"+k.id+")",_e(s,{fill:"url(#"+k.id+")"}),r.pattern=k,r.pattern&&Ie(r);break}var N=t.getRGB(v);if(N.error){if(({circle:1,ellipse:1}[a](r.type)||"r"!=f(v).charAt())&&Te(s,v,r.paper)){p.gradient=v,p.fill="none";break}}else delete n.gradient,delete p.gradient,!t.is(p.opacity,"undefined")&&t.is(n.opacity,"undefined")&&_e(s,{opacity:p.opacity}),!t.is(p["fill-opacity"],"undefined")&&t.is(n["fill-opacity"],"undefined")&&_e(s,{"fill-opacity":p["fill-opacity"]});N[a]("opacity")&&_e(s,{"fill-opacity":N.opacity>1?N.opacity/100:N.opacity});case"stroke":N=t.getRGB(v),e(s,u,N.hex),"stroke"==u&&N[a]("opacity")&&_e(s,{"stroke-opacity":N.opacity>1?N.opacity/100:N.opacity});break;case"gradient":({circle:1,ellipse:1}[a](r.type)||"r"!=f(v).charAt())&&Te(s,v,r.paper);break;case"opacity":p.gradient&&!p[a]("stroke-opacity")&&_e(s,{"stroke-opacity":v>1?v/100:v});case"fill-opacity":if(p.gradient){var A=l.getElementById(s.getAttribute(P)[G](/^url\(#|\)$/g,m));if(A){var F=A.getElementsByTagName("stop");e(F[F[b]-1],"stop-opacity",v)}break}default:"font-size"==u&&(v=z(v,10)+"px");var O=u[G](/(\-.)/g,(function(e){return W.call(e.substring(1))}));s.style[O]=v,e(s,u,v)}}Ne(r,n),d?r.rotate(d.join(g)):B(h)&&r.rotate(h,!0)},Ne=function(e,r){if("text"==e.type&&(r[a]("text")||r[a]("font")||r[a]("font-size")||r[a]("x")||r[a]("y"))){var i=e.attrs,n=e.node,o=n.firstChild?z(l.defaultView.getComputedStyle(n.firstChild,m).getPropertyValue("font-size"),10):10;if(r[a]("text")){for(i.text=r.text;n.firstChild;)n.removeChild(n.firstChild);for(var s=f(r.text).split("\n"),p=0,h=s[b];p<h;p++)if(s[p]){var c=_e("tspan");p&&_e(c,{dy:1.2*o,x:i.x}),c.appendChild(l.createTextNode(s[p])),n.appendChild(c)}}else for(p=0,h=(s=n.getElementsByTagName("tspan"))[b];p<h;p++)p&&_e(s[p],{dy:1.2*o,x:i.x});_e(n,{y:i.y});var d=e.getBBox(),u=i.y-(d.y+d.height/2);u&&t.is(u,"finite")&&_e(n,{y:i.y+u})}},Ae=function(e,r){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.paper=r,this.attrs=this.attrs||{},this.transformations=[],this._={tx:0,ty:0,rt:{deg:0,cx:0,cy: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},Re=Ae[s];Ae[s].rotate=function(e,r,n){if(this.removed)return this;if(null==e)return this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(g):this._.rt.deg;var o=this.getBBox();return(e=f(e).split(i))[b]-1&&(r=B(e[1]),n=B(e[2])),e=B(e[0]),null!=r&&!1!==r?this._.rt.deg=e:this._.rt.deg+=e,null==n&&(r=null),this._.rt.cx=r,this._.rt.cy=n,r=null==r?o.x+o.width/2:r,n=null==n?o.y+o.height/2:n,this._.rt.deg?(this.transformations[0]=t.format("rotate({0} {1} {2})",this._.rt.deg,r,n),this.clip&&_e(this.clip,{transform:t.format("rotate({0} {1} {2})",-this._.rt.deg,r,n)})):(this.transformations[0]=m,this.clip&&_e(this.clip,{transform:m})),_e(this.node,{transform:this.transformations.join(g)}),this},Ae[s].hide=function(){return!this.removed&&(this.node.style.display="none"),this},Ae[s].show=function(){return!this.removed&&(this.node.style.display=""),this},Ae[s].remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this)delete this[e];this.removed=!0}},Ae[s].getBBox=function(){if(this.removed)return this;if("path"==this.type)return ae(this.attrs.path);if("none"==this.node.style.display){this.show();var e=!0}var t={};try{t=this.node.getBBox()}catch(e){}finally{t=t||{}}if("text"==this.type){t={x:t.x,y:1/0,width:0,height:0};for(var r=0,i=this.node.getNumberOfChars();r<i;r++){var n=this.node.getExtentOfChar(r);n.y<t.y&&(t.y=n.y),n.y+n.height-t.y>t.height&&(t.height=n.y+n.height-t.y),n.x+n.width-t.x>t.width&&(t.width=n.x+n.width-t.x)}}return e&&this.hide(),t},Ae[s].attr=function(e,r){if(this.removed)return this;if(null==e){var i={};for(var n in this.attrs)this.attrs[a](n)&&(i[n]=this.attrs[n]);return this._.rt.deg&&(i.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(i.scale=this.scale()),i.gradient&&"none"==i.fill&&(i.fill=i.gradient)&&delete i.gradient,i}if(null==r&&t.is(e,T))return"translation"==e?vt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(null==r&&t.is(e,I)){for(var o={},s=0,l=e.length;s<l;s++)o[e[s]]=this.attr(e[s]);return o}if(null!=r){var p={};p[e]=r}else null!=e&&t.is(e,"object")&&(p=e);for(var h in this.paper.customAttributes)if(this.paper.customAttributes[a](h)&&p[a](h)&&t.is(this.paper.customAttributes[h],"function")){var c=this.paper.customAttributes[h].apply(this,[].concat(p[h]));for(var d in this.attrs[h]=p[h],c)c[a](d)&&(p[d]=c[d])}return Pe(this,p),this},Ae[s].toFront=function(){if(this.removed)return this;this.node.parentNode.appendChild(this.node);var e=this.paper;return e.top!=this&&we(this,e),this},Ae[s].toBack=function(){return this.removed||this.node.parentNode.firstChild!=this.node&&(this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild),Ce(this,this.paper),this.paper),this},Ae[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.appendChild(this.node),ke(this,e,this.paper),this},Ae[s].insertBefore=function(e){if(this.removed)return this;var t=e.node||e[0].node;return t.parentNode.insertBefore(this.node,t),Ee(this,e,this.paper),this},Ae[s].blur=function(e){var t=this;if(0!=+e){var r=_e("filter"),i=_e("feGaussianBlur");t.attrs.blur=e,r.id=te(),_e(i,{stdDeviation:+e||1.5}),r.appendChild(i),t.paper.defs.appendChild(r),t._blur=r,_e(t.node,{filter:"url(#"+r.id+")"})}else t._blur&&(t._blur.parentNode.removeChild(t._blur),delete t._blur,delete t.attrs.blur),t.node.removeAttribute("filter")};var Fe=function(e,t,r,i){var n=_e("circle");e.canvas&&e.canvas.appendChild(n);var o=new Ae(n,e);return o.attrs={cx:t,cy:r,r:i,fill:"none",stroke:"#000"},o.type="circle",_e(n,o.attrs),o},Oe=function(e,t,r,i,n,o){var s=_e("rect");e.canvas&&e.canvas.appendChild(s);var a=new Ae(s,e);return a.attrs={x:t,y:r,width:i,height:n,r:o||0,rx:o||0,ry:o||0,fill:"none",stroke:"#000"},a.type="rect",_e(s,a.attrs),a},De=function(e,t,r,i,n){var o=_e("ellipse");e.canvas&&e.canvas.appendChild(o);var s=new Ae(o,e);return s.attrs={cx:t,cy:r,rx:i,ry:n,fill:"none",stroke:"#000"},s.type="ellipse",_e(o,s.attrs),s},Le=function(e,t,r,i,n,o){var s=_e("image");_e(s,{x:r,y:i,width:n,height:o,preserveAspectRatio:"none"}),s.setAttributeNS(e.xlink,"href",t),e.canvas&&e.canvas.appendChild(s);var a=new Ae(s,e);return a.attrs={x:r,y:i,width:n,height:o,src:t},a.type="image",a},Be=function(e,t,r,i){var n=_e("text");_e(n,{x:t,y:r,"text-anchor":"middle"}),e.canvas&&e.canvas.appendChild(n);var o=new Ae(n,e);return o.attrs={x:t,y:r,"text-anchor":"middle",text:i,font:q.font,stroke:"none",fill:"#000"},o.type="text",Pe(o,o.attrs),o},ze=function(t,r){return this.width=t||this.width,this.height=r||this.height,e(this.canvas,"width",this.width),e(this.canvas,"height",this.height),this},He=function(){var e=ye[d](0,arguments),r=e&&e.container,i=e.x,n=e.y,o=e.width,s=e.height;if(!r)throw new Error("SVG container not found.");var a=_e("svg");return i=i||0,n=n||0,_e(a,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:o=o||512,height:s=s||342}),1==r?(a.style.cssText="position:absolute;left:"+i+"px;top:"+n+"px",l.body.appendChild(a)):r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),(r=new c).width=o,r.height=s,r.canvas=a,be.call(r,r,t.fn),r.clear(),r};r.clear=function(){for(var e=this.canvas;e.firstChild;)e.removeChild(e.firstChild);this.bottom=this.top=null,(this.desc=_e("desc")).appendChild(l.createTextNode("Created with Raphaël")),e.appendChild(this.desc),e.appendChild(this.defs=_e("defs"))},r.remove=function(){for(var e in this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Se(e)}}if(t.vml){var We,qe={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},Ue=/([clmz]),?([^clmz]*)/gi,Ge=/ progid:\S+Blur\([^\)]+\)/g,Ve=/-?[^,\s-]+/g,je="1000 1000",Ye=10,$e={path:1,rect:1};function Xe(e,r,i,n,o){return o?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+o,r,i-2*o,o,-o,n-2*o,2*o-i,2*o-n):t.format("M{0},{1}l{2},0,0,{3},{4},0z",e,r,i,n,-i)}t.toString=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version},Me=function(e,t){var r=We("group");r.style.cssText="position:absolute;left:0;top:0;width:"+t.width+"px;height:"+t.height+"px",r.coordsize=t.coordsize,r.coordorigin=t.coordorigin;var i=We("shape"),n=i.style;n.width=t.width+"px",n.height=t.height+"px",i.coordsize=je,i.coordorigin=t.coordorigin,r.appendChild(i);var o=new Ae(i,r,t),s={fill:"none",stroke:"#000"};return e&&(s.path=e),o.type="path",o.path=[],o.Path=m,Pe(o,s),t.canvas.appendChild(r),o},Pe=function(e,r){e.attrs=e.attrs||{};var n,o=e.node,s=e.attrs,p=o.style,h=(r.x!=s.x||r.y!=s.y||r.width!=s.width||r.height!=s.height||r.r!=s.r)&&"rect"==e.type,c=e;for(var d in r)r[a](d)&&(s[d]=r[d]);if(h&&(s.path=Xe(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&&(o.href=r.href),r.title&&(o.title=r.title),r.target&&(o.target=r.target),r.cursor&&(p.cursor=r.cursor),"blur"in r&&e.blur(r.blur),(r.path&&"path"==e.type||h)&&(o.path=function(e){var t=/[ahqstv]/gi,r=he;if(f(e).match(t)&&(r=fe),t=/[clmz]/g,r==he&&!f(e).match(t)){var i=f(e)[G](Ue,(function(e,t,r){var i=[],n="m"==x.call(t),o=qe[t];return r[G](Ve,(function(e){n&&2==i[b]&&(o+=i+qe["m"==t?"l":"L"],i=[]),i[A](L(e*Ye))})),o+i}));return i}var n,o,s=r(e);i=[];for(var a=0,l=s[b];a<l;a++){n=s[a],"z"==(o=x.call(s[a][0]))&&(o="x");for(var p=1,h=n[b];p<h;p++)o+=L(n[p]*Ye)+(p!=h-1?",":m);i[A](o)}return i.join(g)}(s.path)),null!=r.rotation&&e.rotate(r.rotation,!0),r.translation&&(n=f(r.translation).split(i),vt.call(e,n[0],n[1]),null!=e._.rt.cx&&(e._.rt.cx+=+n[0],e._.rt.cy+=+n[1],e.setBox(e.attrs,n[0],n[1]))),r.scale&&(n=f(r.scale).split(i),e.scale(+n[0]||1,+n[1]||+n[0]||1,+n[2]||null,+n[3]||null)),"clip-rect"in r){var u=f(r["clip-rect"]).split(i);if(4==u[b]){u[2]=+u[2]+ +u[0],u[3]=+u[3]+ +u[1];var v=o.clipRect||l.createElement("div"),y=v.style,w=o.parentNode;y.clip=t.format("rect({1}px {2}px {3}px {0}px)",u),o.clipRect||(y.position="absolute",y.top=0,y.left=0,y.width=e.paper.width+"px",y.height=e.paper.height+"px",w.parentNode.insertBefore(v,w),v.appendChild(w),o.clipRect=v)}r["clip-rect"]||o.clipRect&&(o.clipRect.style.clip=m)}if("image"==e.type&&r.src&&(o.src=r.src),"image"==e.type&&r.opacity&&(o.filterOpacity=H+".Alpha(opacity="+100*r.opacity+")",p.filter=(o.filterMatrix||m)+(o.filterOpacity||m)),r.font&&(p.font=r.font),r["font-family"]&&(p.fontFamily='"'+r["font-family"].split(",")[0][G](/^['"]+|['"]+$/g,m)+'"'),r["font-size"]&&(p.fontSize=r["font-size"]),r["font-weight"]&&(p.fontWeight=r["font-weight"]),r["font-style"]&&(p.fontStyle=r["font-style"]),null!=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"]){var E=(o=e.shape||o).getElementsByTagName(P)&&o.getElementsByTagName(P)[0],S=!1;if(!E&&(S=E=We(P)),"fill-opacity"in r||"opacity"in r){var _=((+s["fill-opacity"]+1||2)-1)*((+s.opacity+1||2)-1)*((+t.getRGB(r.fill).o+1||2)-1);_=k(C(_,0),1),E.opacity=_}if(r.fill&&(E.on=!0),null!=E.on&&"none"!=r.fill||(E.on=!1),E.on&&r.fill){var M=r.fill.match(R);M?(E.src=M[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}||"r"!=f(r.fill).charAt())&&Te(c,r.fill)&&(s.fill="none",s.gradient=r.fill))}S&&o.appendChild(E);var T=o.getElementsByTagName("stroke")&&o.getElementsByTagName("stroke")[0],I=!1;!T&&(I=T=We("stroke")),(r.stroke&&"none"!=r.stroke||r["stroke-width"]||null!=r["stroke-opacity"]||r["stroke-dasharray"]||r["stroke-miterlimit"]||r["stroke-linejoin"]||r["stroke-linecap"])&&(T.on=!0),("none"==r.stroke||null==T.on||0==r.stroke||0==r["stroke-width"])&&(T.on=!1);var N=t.getRGB(r.stroke);T.on&&r.stroke&&(T.color=N.hex),_=((+s["stroke-opacity"]+1||2)-1)*((+s.opacity+1||2)-1)*((+N.o+1||2)-1);var F=.75*(B(r["stroke-width"])||1);if(_=k(C(_,0),1),null==r["stroke-width"]&&(F=s["stroke-width"]),r["stroke-width"]&&(T.weight=F),F&&F<1&&(_*=F)&&(T.weight=1),T.opacity=_,r["stroke-linejoin"]&&(T.joinstyle=r["stroke-linejoin"]||"miter"),T.miterlimit=r["stroke-miterlimit"]||8,r["stroke-linecap"]&&(T.endcap="butt"==r["stroke-linecap"]?"flat":"square"==r["stroke-linecap"]?"square":"round"),r["stroke-dasharray"]){var O={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};T.dashstyle=O[a](r["stroke-dasharray"])?O[r["stroke-dasharray"]]:m}I&&o.appendChild(T)}if("text"==c.type)switch(p=c.paper.span.style,s.font&&(p.font=s.font),s["font-family"]&&(p.fontFamily=s["font-family"]),s["font-size"]&&(p.fontSize=s["font-size"]),s["font-weight"]&&(p.fontWeight=s["font-weight"]),s["font-style"]&&(p.fontStyle=s["font-style"]),c.node.string&&(c.paper.span.innerHTML=f(c.node.string)[G](/</g,"&#60;")[G](/&/g,"&#38;")[G](/\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+L(c.H/2),s["text-anchor"]){case"start":c.node.style["v-text-align"]="left",c.bbx=L(c.W/2);break;case"end":c.node.style["v-text-align"]="right",c.bbx=-L(c.W/2);break;default:c.node.style["v-text-align"]="center"}},Te=function(e,t){e.attrs=e.attrs||{},e.attrs;var r,i="linear",n=".5 .5";if(e.attrs.gradient=t,t=(t=f(t)[G](Z,(function(e,t,r){return i="radial",t&&r&&(t=B(t),r=B(r),S(t-.5,2)+S(r-.5,2)>.25&&(r=w.sqrt(.25-S(t-.5,2))*(2*(r>.5)-1)+.5),n=t+g+r),m}))).split(/\s*\-\s*/),"linear"==i){var o=t.shift();if(o=-B(o),isNaN(o))return null}var s=ve(t);if(!s)return null;if(!(r=(e=e.shape||e.node).getElementsByTagName(P)[0]||We(P)).parentNode&&e.appendChild(r),s[b]){r.on=!0,r.method="none",r.color=s[0].color,r.color2=s[s[b]-1].color;for(var a=[],l=0,p=s[b];l<p;l++)s[l].offset&&a[A](s[l].offset+g+s[l].color);r.colors&&(r.colors.value=a[b]?a.join():"0% "+r.color),"radial"==i?(r.type="gradientradial",r.focus="100%",r.focussize=n,r.focusposition=n):(r.type="gradient",r.angle=(270-o)%360)}return 1},(Re=(Ae=function(e,r,i){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.X=0,this.Y=0,this.attrs={},this.Group=r,this.paper=i,this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1},!i.bottom&&(i.bottom=this),this.prev=i.top,i.top&&(i.top.next=this),i.top=this,this.next=null})[s]).rotate=function(e,t,r){return this.removed?this:null==e?this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(g):this._.rt.deg:((e=f(e).split(i))[b]-1&&(t=B(e[1]),r=B(e[2])),e=B(e[0]),null!=t?this._.rt.deg=e:this._.rt.deg+=e,null==r&&(t=null),this._.rt.cx=t,this._.rt.cy=r,this.setBox(this.attrs,t,r),this.Group.style.rotation=this._.rt.deg,this)},Re.setBox=function(e,t,r){if(this.removed)return this;var i=this.Group.style,n=this.shape&&this.shape.style||this.node.style;for(var o in e=e||{})e[a](o)&&(this.attrs[o]=e[o]);t=t||this._.rt.cx,r=r||this._.rt.cy;var s,l,p,h,c=this.attrs;switch(this.type){case"circle":s=c.cx-c.r,l=c.cy-c.r,p=h=2*c.r;break;case"ellipse":s=c.cx-c.rx,l=c.cy-c.ry,p=2*c.rx,h=2*c.ry;break;case"image":s=+c.x,l=+c.y,p=c.width||0,h=c.height||0;break;case"text":this.textpath.v=["m",L(c.x),", ",L(c.y-2),"l",L(c.x)+1,", ",L(c.y-2)].join(m),s=c.x-L(this.W/2),l=c.y-this.H/2,p=this.W,h=this.H;break;case"rect":case"path":if(this.attrs.path){var d=ae(this.attrs.path);s=d.x,l=d.y,p=d.width,h=d.height}else s=0,l=0,p=this.paper.width,h=this.paper.height;break;default:s=0,l=0,p=this.paper.width,h=this.paper.height}r=null==r?l+h/2:r;var u,g=(t=null==t?s+p/2:t)-this.paper.width/2,f=r-this.paper.height/2;i.left!=(u=g+"px")&&(i.left=u),i.top!=(u=f+"px")&&(i.top=u),this.X=$e[a](this.type)?-g:s,this.Y=$e[a](this.type)?-f:l,this.W=p,this.H=h,$e[a](this.type)?(n.left!=(u=-g*Ye+"px")&&(n.left=u),n.top!=(u=-f*Ye+"px")&&(n.top=u)):"text"==this.type?(n.left!=(u=-g+"px")&&(n.left=u),n.top!=(u=-f+"px")&&(n.top=u)):(i.width!=(u=this.paper.width+"px")&&(i.width=u),i.height!=(u=this.paper.height+"px")&&(i.height=u),n.left!=(u=s-g+"px")&&(n.left=u),n.top!=(u=l-f+"px")&&(n.top=u),n.width!=(u=p+"px")&&(n.width=u),n.height!=(u=h+"px")&&(n.height=u))},Re.hide=function(){return!this.removed&&(this.Group.style.display="none"),this},Re.show=function(){return!this.removed&&(this.Group.style.display="block"),this},Re.getBBox=function(){return this.removed?this:$e[a](this.type)?ae(this.attrs.path):{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}},Re.remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this.Group.parentNode.removeChild(this.Group),this.shape&&this.shape.parentNode.removeChild(this.shape),this)delete this[e];this.removed=!0}},Re.attr=function(e,r){if(this.removed)return this;if(null==e){var i={};for(var n in this.attrs)this.attrs[a](n)&&(i[n]=this.attrs[n]);return this._.rt.deg&&(i.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(i.scale=this.scale()),i.gradient&&"none"==i.fill&&(i.fill=i.gradient)&&delete i.gradient,i}if(null==r&&t.is(e,"string"))return"translation"==e?vt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(this.attrs&&null==r&&t.is(e,I)){var o,s={};for(n=0,o=e[b];n<o;n++)s[e[n]]=this.attr(e[n]);return s}var l;if(null!=r&&((l={})[e]=r),null==r&&t.is(e,"object")&&(l=e),l){for(var p in this.paper.customAttributes)if(this.paper.customAttributes[a](p)&&l[a](p)&&t.is(this.paper.customAttributes[p],"function")){var h=this.paper.customAttributes[p].apply(this,[].concat(l[p]));for(var c in this.attrs[p]=l[p],h)h[a](c)&&(l[c]=h[c])}l.text&&"text"==this.type&&(this.node.string=l.text),Pe(this,l),l.gradient&&({circle:1,ellipse:1}[a](this.type)||"r"!=f(l.gradient).charAt())&&Te(this,l.gradient),(!$e[a](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this},Re.toFront=function(){return!this.removed&&this.Group.parentNode.appendChild(this.Group),this.paper.top!=this&&we(this,this.paper),this},Re.toBack=function(){return this.removed||this.Group.parentNode.firstChild!=this.Group&&(this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild),Ce(this,this.paper)),this},Re.insertAfter=function(e){return this.removed||(e.constructor==xt&&(e=e[e.length-1]),e.Group.nextSibling?e.Group.parentNode.insertBefore(this.Group,e.Group.nextSibling):e.Group.parentNode.appendChild(this.Group),ke(this,e,this.paper)),this},Re.insertBefore=function(e){return this.removed||(e.constructor==xt&&(e=e[0]),e.Group.parentNode.insertBefore(this.Group,e.Group),Ee(this,e,this.paper)),this},Re.blur=function(e){var r=this.node.runtimeStyle,i=r.filter;i=i.replace(Ge,m),0!=+e?(this.attrs.blur=e,r.filter=i+g+H+".Blur(pixelradius="+(+e||1.5)+")",r.margin=t.format("-{0}px 0 0 -{0}px",L(+e||1.5))):(r.filter=i,r.margin=0,delete this.attrs.blur)},Fe=function(e,t,r,i){var n=We("group"),o=We("oval");o.style,n.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",n.coordsize=je,n.coordorigin=e.coordorigin,n.appendChild(o);var s=new Ae(o,n,e);return s.type="circle",Pe(s,{stroke:"#000",fill:"none"}),s.attrs.cx=t,s.attrs.cy=r,s.attrs.r=i,s.setBox({x:t-i,y:r-i,width:2*i,height:2*i}),e.canvas.appendChild(n),s},Oe=function(e,t,r,i,n,o){var s=Xe(t,r,i,n,o),a=e.path(s),l=a.attrs;return a.X=l.x=t,a.Y=l.y=r,a.W=l.width=i,a.H=l.height=n,l.r=o,l.path=s,a.type="rect",a},De=function(e,t,r,i,n){var o=We("group"),s=We("oval");s.style,o.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",o.coordsize=je,o.coordorigin=e.coordorigin,o.appendChild(s);var a=new Ae(s,o,e);return a.type="ellipse",Pe(a,{stroke:"#000"}),a.attrs.cx=t,a.attrs.cy=r,a.attrs.rx=i,a.attrs.ry=n,a.setBox({x:t-i,y:r-n,width:2*i,height:2*n}),e.canvas.appendChild(o),a},Le=function(e,t,r,i,n,o){var s=We("group"),a=We("image");s.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",s.coordsize=je,s.coordorigin=e.coordorigin,a.src=t,s.appendChild(a);var l=new Ae(a,s,e);return l.type="image",l.attrs.src=t,l.attrs.x=r,l.attrs.y=i,l.attrs.w=n,l.attrs.h=o,l.setBox({x:r,y:i,width:n,height:o}),e.canvas.appendChild(s),l},Be=function(e,r,i,n){var o=We("group"),s=We("shape"),a=s.style,l=We("path");l.style;var p=We("textpath");o.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",o.coordsize=je,o.coordorigin=e.coordorigin,l.v=t.format("m{0},{1}l{2},{1}",L(10*r),L(10*i),L(10*r)+1),l.textpathok=!0,a.width=e.width,a.height=e.height,p.string=f(n),p.on=!0,s.appendChild(p),s.appendChild(l),o.appendChild(s);var h=new Ae(p,o,e);return h.shape=s,h.textpath=l,h.type="text",h.attrs.text=n,h.attrs.x=r,h.attrs.y=i,h.attrs.w=1,h.attrs.h=1,Pe(h,{font:q.font,stroke:"none",fill:"#000"}),h.setBox(),e.canvas.appendChild(o),h},ze=function(e,t){var r=this.canvas.style;return e==+e&&(e+="px"),t==+t&&(t+="px"),r.width=e,r.height=t,r.clip="rect(0 "+e+" "+t+" 0)",this},l.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!l.namespaces.rvml&&l.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),We=function(e){return l.createElement("<rvml:"+e+' class="rvml">')}}catch(Ct){We=function(e){return l.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}He=function(){var e=ye[d](0,arguments),r=e.container,i=e.height,n=e.width,o=e.x,s=e.y;if(!r)throw new Error("VML container not found.");var a=new c,p=a.canvas=l.createElement("div"),h=p.style;return o=o||0,s=s||0,(n=n||512)==+n&&(n+="px"),(i=i||342)==+i&&(i+="px"),a.width=1e3,a.height=1e3,a.coordsize="10000 10000",a.coordorigin="0 0",a.span=l.createElement("span"),a.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",p.appendChild(a.span),h.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",n,i),1==r?(l.body.appendChild(p),h.left=o+"px",h.top=s+"px",h.position="absolute"):r.firstChild?r.insertBefore(p,r.firstChild):r.appendChild(p),be.call(a,a,t.fn),a},r.clear=function(){this.canvas.innerHTML=m,this.span=l.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},r.remove=function(){for(var e in this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Se(e);return!0}}var Ke=navigator.userAgent.match(/Version\/(.*?)\s/);"Apple Computer, Inc."==navigator.vendor&&(Ke&&Ke[1]<4||"iP"==navigator.platform.slice(0,2))?r.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});p.setTimeout((function(){e.remove()}))}:r.safari=function(){};for(var Ze=function(){this.returnValue=!1},Je=function(){return this.originalEvent.preventDefault()},Qe=function(){this.cancelBubble=!0},et=function(){return this.originalEvent.stopPropagation()},tt=l.addEventListener?function(e,t,r,i){var n=u&&y[t]?y[t]:t,o=function(n){if(u&&y[a](t))for(var o=0,s=n.targetTouches&&n.targetTouches.length;o<s;o++)if(n.targetTouches[o].target==e){var l=n;(n=n.targetTouches[o]).originalEvent=l,n.preventDefault=Je,n.stopPropagation=et;break}return r.call(i,n)};return e.addEventListener(n,o,!1),function(){return e.removeEventListener(n,o,!1),!0}}:l.attachEvent?function(e,t,r,i){var n=function(e){return(e=e||p.event).preventDefault=e.preventDefault||Ze,e.stopPropagation=e.stopPropagation||Qe,r.call(i,e)};return e.attachEvent("on"+t,n),function(){return e.detachEvent("on"+t,n),!0}}:void 0,rt=[],it=function(e){for(var t,r=e.clientX,i=e.clientY,n=l.documentElement.scrollTop||l.body.scrollTop,o=l.documentElement.scrollLeft||l.body.scrollLeft,s=rt.length;s--;){if(t=rt[s],u){for(var a,p=e.touches.length;p--;)if((a=e.touches[p]).identifier==t.el._drag.id){r=a.clientX,i=a.clientY,(e.originalEvent?e.originalEvent:e).preventDefault();break}}else e.preventDefault();r+=o,i+=n,t.move&&t.move.call(t.move_scope||t.el,r-t.el._drag.x,i-t.el._drag.y,r,i,e)}},nt=function e(r){t.unmousemove(it).unmouseup(e);for(var i,n=rt.length;n--;)(i=rt[n]).el._drag={},i.end&&i.end.call(i.end_scope||i.start_scope||i.move_scope||i.el,r);rt=[]},ot=v[b];ot--;)!function(e){t[e]=Ae[s][e]=function(r,i){return t.is(r,"function")&&(this.events=this.events||[],this.events.push({name:e,f:r,unbind:tt(this.shape||this.node||l,e,r,i||this)})),this},t["un"+e]=Ae[s]["un"+e]=function(t){for(var r=this.events,i=r[b];i--;)if(r[i].name==e&&r[i].f==t)return r[i].unbind(),r.splice(i,1),!r.length&&delete this.events,this;return this}}(v[ot]);function st(){return this.x+g+this.y}Re.hover=function(e,t,r,i){return this.mouseover(e,r).mouseout(t,i||r)},Re.unhover=function(e,t){return this.unmouseover(e).unmouseout(t)},Re.drag=function(e,r,i,n,o,s){return this._drag={},this.mousedown((function(a){(a.originalEvent||a).preventDefault();var p=l.documentElement.scrollTop||l.body.scrollTop,h=l.documentElement.scrollLeft||l.body.scrollLeft;this._drag.x=a.clientX+h,this._drag.y=a.clientY+p,this._drag.id=a.identifier,r&&r.call(o||n||this,a.clientX+h,a.clientY+p,a),!rt.length&&t.mousemove(it).mouseup(nt),rt.push({el:this,move:e,end:i,move_scope:n,start_scope:o,end_scope:s})})),this},Re.undrag=function(e,r,i){for(var n=rt.length;n--;)rt[n].el==this&&rt[n].move==e&&rt[n].end==i&&rt.splice(n++,1);!rt.length&&t.unmousemove(it).unmouseup(nt)},r.circle=function(e,t,r){return Fe(this,e||0,t||0,r||0)},r.rect=function(e,t,r,i,n){return Oe(this,e||0,t||0,r||0,i||0,n||0)},r.ellipse=function(e,t,r,i){return De(this,e||0,t||0,r||0,i||0)},r.path=function(e){return e&&!t.is(e,T)&&!t.is(e[0],I)&&(e+=m),Me(t.format[d](t,arguments),this)},r.image=function(e,t,r,i,n){return Le(this,e||"about:blank",t||0,r||0,i||0,n||0)},r.text=function(e,t,r){return Be(this,e||0,t||0,f(r))},r.set=function(e){return arguments[b]>1&&(e=Array[s].splice.call(arguments,0,arguments[b])),new xt(e)},r.setSize=ze,r.top=r.bottom=null,r.raphael=t,Re.resetScale=function(){if(this.removed)return this;this._.sx=1,this._.sy=1,this.attrs.scale="1 1"},Re.scale=function(t,r,i,n){if(this.removed)return this;if(null==t&&null==r)return{x:this._.sx,y:this._.sy,toString:st};!+(r=r||t)&&(r=t);var o,s,a=this.attrs;if(0!=t){var l=this.getBBox(),p=l.x+l.width/2,h=l.y+l.height/2,c=E(t/this._.sx),d=E(r/this._.sy);i=+i||0==i?i:p,n=+n||0==n?n:h;var u=this._.sx>0,f=this._.sy>0,v=~~(t/E(t)),y=~~(r/E(r)),x=c*v,w=d*y,C=this.node.style,k=i+E(p-i)*x*(p>i==u?1:-1),S=n+E(h-n)*w*(h>n==f?1:-1),_=t*v>r*y?d:c;switch(this.type){case"rect":case"image":var M=a.width*c,T=a.height*d;this.attr({height:T,r:a.r*_,width:M,x:k-M/2,y:S-T/2});break;case"circle":case"ellipse":this.attr({rx:a.rx*c,ry:a.ry*d,r:a.r*_,cx:k,cy:S});break;case"text":this.attr({x:k,y:S});break;case"path":for(var I=pe(a.path),P=!0,N=u?x:c,A=f?w:d,R=0,F=I[b];R<F;R++){var O=I[R],D=W.call(O[0]);if("M"!=D||!P)if(P=!1,"A"==D)O[I[R][b]-2]*=N,O[I[R][b]-1]*=A,O[1]*=c,O[2]*=d,O[5]=+(v+y?!!+O[5]:!+O[5]);else if("H"==D)for(var L=1,B=O[b];L<B;L++)O[L]*=N;else if("V"==D)for(L=1,B=O[b];L<B;L++)O[L]*=A;else for(L=1,B=O[b];L<B;L++)O[L]*=L%2?N:A}var z=ae(I);o=k-z.x-z.width/2,s=S-z.y-z.height/2,I[0][1]+=o,I[0][2]+=s,this.attr({path:I})}!(this.type in{text:1,image:1})||1==v&&1==y?this.transformations?(this.transformations[2]=m,e(this.node,"transform",this.transformations.join(g)),a.fx=0,a.fy=0):(this.node.filterMatrix=m,C.filter=(this.node.filterMatrix||m)+(this.node.filterOpacity||m)):this.transformations?(this.transformations[2]="scale(".concat(v,",",y,")"),e(this.node,"transform",this.transformations.join(g)),o=-1==v?-a.x-(M||0):a.x,s=-1==y?-a.y-(T||0):a.y,this.attr({x:o,y:s}),a.fx=v-1,a.fy=y-1):(this.node.filterMatrix=H+".Matrix(M11=".concat(v,", M12=0, M21=0, M22=",y,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')"),C.filter=(this.node.filterMatrix||m)+(this.node.filterOpacity||m)),a.scale=[t,r,i,n].join(g),this._.sx=t,this._.sy=r}return this},Re.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 at={},lt=function e(r,i,n,o,s,a,l,p,h){if(r===n&&i===o&&s===l&&a==p){var c=l-r,d=p-i,u=Math.sqrt(c*c+d*d);if(null==h)return u;var m=h/u;return{start:{x:r,y:i},m:{x:r,y:i},n:{x:l,y:p},end:{x:l,y:p},x:r+m*c,y:i+m*d,alpha:90-180*w.atan(c/d)/_}}var g,f,v=0,y=100,b=[r,i,n,o,s,a,l,p].join(),x=at[b];(!x&&(at[b]=x={data:[]}),x.timer&&clearTimeout(x.timer),x.timer=setTimeout((function(){delete at[b]}),2e3),null!=h)&&(y=10*~~e(r,i,n,o,s,a,l,p));for(var C=0;C<y+1;C++){if(x.data[h]>C?f=x.data[C*y]:(f=t.findDotsAtSegment(r,i,n,o,s,a,l,p,C/y),x.data[C]=f),C&&(v+=S(S(g.x-f.x,2)+S(g.y-f.y,2),.5)),null!=h&&v>=h)return f;g=f}if(null==h)return v},pt=function(e,r){return function(i,n,o){for(var s,a,l,p,h,c="",d={},u=0,m=0,g=(i=fe(i)).length;m<g;m++){if("M"==(l=i[m])[0])s=+l[1],a=+l[2];else{if(u+(p=lt(s,a,l[1],l[2],l[3],l[4],l[5],l[6]))>n){if(r&&!d.start){if(c+=["C",(h=lt(s,a,l[1],l[2],l[3],l[4],l[5],l[6],n-u)).start.x,h.start.y,h.m.x,h.m.y,h.x,h.y],o)return c;d.start=c,c=["M",h.x,h.y+"C",h.n.x,h.n.y,h.end.x,h.end.y,l[5],l[6]].join(),u+=p,s=+l[5],a=+l[6];continue}if(!e&&!r)return{x:(h=lt(s,a,l[1],l[2],l[3],l[4],l[5],l[6],n-u)).x,y:h.y,alpha:h.alpha}}u+=p,s=+l[5],a=+l[6]}c+=l}return d.end=c,(h=e?u:r?d:t.findDotsAtSegment(s,a,l[1],l[2],l[3],l[4],l[5],l[6],1)).alpha&&(h={x:h.x,y:h.y,alpha:h.alpha}),h}},ht=pt(1),ct=pt(),dt=pt(0,1);Re.getTotalLength=function(){if("path"==this.type)return this.node.getTotalLength?this.node.getTotalLength():ht(this.attrs.path)},Re.getPointAtLength=function(e){if("path"==this.type)return ct(this.attrs.path,e)},Re.getSubpath=function(e,t){if("path"==this.type){if(E(this.getTotalLength()-t)<"1e-6")return dt(this.attrs.path,e).end;var r=dt(this.attrs.path,t,1);return e?dt(r,e).end:r}},t.easing_formulas={linear:function(e){return e},"<":function(e){return S(e,3)},">":function(e){return S(e-1,3)+1},"<>":function(e){return(e*=2)<1?S(e,3)/2:(S(e-=2,3)+2)/2},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return(e-=1)*e*((t+1)*e+t)+1},elastic:function(e){if(0==e||1==e)return e;return S(2,-10*e)*w.sin(2*_*(e-.075)/.3)+1},bounce:function(e){var t=7.5625,r=2.75;return e<1/r?t*e*e:e<2/r?t*(e-=1.5/r)*e+.75:e<2.5/r?t*(e-=2.25/r)*e+.9375:t*(e-=2.625/r)*e+.984375}};var ut=[],mt=function e(){for(var r=+new Date,i=0;i<ut[b];i++){var n=ut[i];if(!n.stop&&!n.el.removed){var o,s=r-n.start,l=n.ms,p=n.easing,h=n.from,c=n.diff,d=n.to,u=n.t,f=n.el,v={};if(s<l){var y=p(s/l);for(var x in h)if(h[a](x)){switch(U[x]){case"along":o=y*l*c[x],d.back&&(o=d.len-o);var w=ct(d[x],o);f.translate(c.sx-c.x||0,c.sy-c.y||0),c.x=w.x,c.y=w.y,f.translate(w.x-c.sx,w.y-c.sy),d.rot&&f.rotate(c.r+w.alpha,w.x,w.y);break;case M:o=+h[x]+y*l*c[x];break;case"colour":o="rgb("+[ft(L(h[x].r+y*l*c[x].r)),ft(L(h[x].g+y*l*c[x].g)),ft(L(h[x].b+y*l*c[x].b))].join(",")+")";break;case"path":o=[];for(var C=0,k=h[x][b];C<k;C++){o[C]=[h[x][C][0]];for(var E=1,S=h[x][C][b];E<S;E++)o[C][E]=+h[x][C][E]+y*l*c[x][C][E];o[C]=o[C].join(g)}o=o.join(g);break;case"csv":switch(x){case"translation":var _=y*l*c[x][0]-u.x,T=y*l*c[x][1]-u.y;u.x+=_,u.y+=T,o=_+g+T;break;case"rotation":o=+h[x][0]+y*l*c[x][0],h[x][1]&&(o+=","+h[x][1]+","+h[x][2]);break;case"scale":o=[+h[x][0]+y*l*c[x][0],+h[x][1]+y*l*c[x][1],2 in d[x]?d[x][2]:m,3 in d[x]?d[x][3]:m].join(g);break;case"clip-rect":for(o=[],C=4;C--;)o[C]=+h[x][C]+y*l*c[x][C]}break;default:var I=[].concat(h[x]);for(o=[],C=f.paper.customAttributes[x].length;C--;)o[C]=+I[C]+y*l*c[x][C]}v[x]=o}f.attr(v),f._run&&f._run.call(f)}else d.along&&(w=ct(d.along,d.len*!d.back),f.translate(c.sx-(c.x||0)+w.x-c.sx,c.sy-(c.y||0)+w.y-c.sy),d.rot&&f.rotate(c.r+w.alpha,w.x,w.y)),(u.x||u.y)&&f.translate(-u.x,-u.y),d.scale&&(d.scale+=m),f.attr(d),ut.splice(i--,1)}}t.svg&&f&&f.paper&&f.paper.safari(),ut[b]&&setTimeout(e)},gt=function(e,r,i,n,o){var s=i-n;r.timeouts.push(setTimeout((function(){t.is(o,"function")&&o.call(r),r.animate(e,s,e.easing)}),n))},ft=function(e){return C(k(e,255),0)},vt=function(e,t){if(null==e)return{x:this._.tx,y:this._.ty,toString:st};switch(this._.tx+=+e,this._.ty+=+t,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 r=pe(this.attrs.path);r[0][1]+=+e,r[0][2]+=+t,this.attr({path:r})}return this};function yt(e){return function(r,i,n,o){var s={back:e};return t.is(n,"function")?o=n:s.rot=n,r&&r.constructor==Ae&&(r=r.attrs.path),r&&(s.along=r),this.animate(s,i,o)}}function bt(e,t,r,i,n,o){var s=3*t,a=3*(i-t)-s,l=1-s-a,p=3*r,h=3*(n-r)-p,c=1-p-h;function d(e){return((l*e+a)*e+s)*e}return function(e,t){var r=function(e,t){var r,i,n,o,p,h;for(n=e,h=0;h<8;h++){if(o=d(n)-e,E(o)<t)return n;if(E(p=(3*l*n+2*a)*n+s)<1e-6)break;n-=o/p}if(i=1,(n=e)<(r=0))return r;if(n>i)return i;for(;r<i;){if(o=d(n),E(o-e)<t)return n;e>o?r=n:i=n,n=(i-r)/2+r}return n}(e,t);return((c*r+h)*r+p)*r}(e,1/(200*o))}Re.animateWith=function(e,t,r,i,n){for(var o=0,s=ut.length;o<s;o++)ut[o].el.id==e.id&&(t.start=ut[o].start);return this.animate(t,r,i,n)},Re.animateAlong=yt(),Re.animateAlongBack=yt(1),Re.onAnimation=function(e){return this._run=e||0,this},Re.animate=function(e,r,n,o){var s=this;if(s.timeouts=s.timeouts||[],!t.is(n,"function")&&n||(o=n||null),s.removed)return o&&o.call(s),s;var l={},p={},h=!1,c={};for(var d in e)if(e[a](d)&&(U[a](d)||s.paper.customAttributes[a](d)))switch(h=!0,l[d]=s.attr(d),null==l[d]&&(l[d]=q[d]),p[d]=e[d],U[d]){case"along":var u=ht(e[d]),m=ct(e[d],u*!!e.back),g=s.getBBox();c[d]=u/r,c.tx=g.x,c.ty=g.y,c.sx=m.x,c.sy=m.y,p.rot=e.rot,p.back=e.back,p.len=u,e.rot&&(c.r=B(s.rotate())||0);break;case M:c[d]=(p[d]-l[d])/r;break;case"colour":l[d]=t.getRGB(l[d]);var v=t.getRGB(p[d]);c[d]={r:(v.r-l[d].r)/r,g:(v.g-l[d].g)/r,b:(v.b-l[d].b)/r};break;case"path":var y=fe(l[d],p[d]);l[d]=y[0];var x=y[1];c[d]=[];for(var w=0,C=l[d][b];w<C;w++){c[d][w]=[0];for(var k=1,E=l[d][w][b];k<E;k++)c[d][w][k]=(x[w][k]-l[d][w][k])/r}break;case"csv":var S=f(e[d]).split(i),_=f(l[d]).split(i);switch(d){case"translation":l[d]=[0,0],c[d]=[S[0]/r,S[1]/r];break;case"rotation":l[d]=_[1]==S[1]&&_[2]==S[2]?_:[0,S[1],S[2]],c[d]=[(S[0]-l[d][0])/r,0,0];break;case"scale":e[d]=S,l[d]=f(l[d]).split(i),c[d]=[(S[0]-l[d][0])/r,(S[1]-l[d][1])/r,0,0];break;case"clip-rect":for(l[d]=f(l[d]).split(i),c[d]=[],w=4;w--;)c[d][w]=(S[w]-l[d][w])/r}p[d]=S;break;default:for(S=[].concat(e[d]),_=[].concat(l[d]),c[d]=[],w=s.paper.customAttributes[d][b];w--;)c[d][w]=((S[w]||0)-(_[w]||0))/r}if(h){var T=t.easing_formulas[n];if(!T)if((T=f(n).match(D))&&5==T[b]){var I=T;T=function(e){return bt(e,+I[1],+I[2],+I[3],+I[4],r)}}else T=function(e){return e};ut.push({start:e.start||+new Date,ms:r,easing:T,from:l,diff:c,to:p,el:s,t:{x:0,y:0}}),t.is(o,"function")&&(s._ac=setTimeout((function(){o.call(s)}),r)),1==ut[b]&&setTimeout(mt)}else{var P,N=[];for(var A in e)e[a](A)&&V.test(A)&&(d={value:e[A]},"from"==A&&(A=0),"to"==A&&(A=100),d.key=z(A,10),N.push(d));for(N.sort(J),N[0].key&&N.unshift({key:0,value:s.attrs}),w=0,C=N[b];w<C;w++)gt(N[w].value,s,r/100*N[w].key,r/100*(N[w-1]&&N[w-1].key||0),N[w-1]&&N[w-1].value.callback);(P=N[N[b]-1].value.callback)&&s.timeouts.push(setTimeout((function(){P.call(s)}),r))}return this},Re.stop=function(){for(var e=0;e<ut.length;e++)ut[e].el.id==this.id&&ut.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},Re.translate=function(e,t){return this.attr({translation:e+" "+t})},Re.toString=function(){return"Raphaël’s object"},t.ae=ut;var xt=function e(t){if(this.items=[],this[b]=0,this.type="set",t)for(var r=0,i=t[b];r<i;r++)!t[r]||t[r].constructor!=Ae&&t[r].constructor!=e||(this[this.items[b]]=this.items[this.items[b]]=t[r],this[b]++)};for(var wt in xt[s][A]=function(){for(var e,t,r=0,i=arguments[b];r<i;r++)!(e=arguments[r])||e.constructor!=Ae&&e.constructor!=xt||(this[t=this.items[b]]=this.items[t]=e,this[b]++);return this},xt[s].pop=function(){return delete this[this[b]--],this.items.pop()},Re)Re[a](wt)&&(xt[s][wt]=function(e){return function(){for(var t=0,r=this.items[b];t<r;t++)this.items[t][e][d](this.items[t],arguments);return this}}(wt));xt[s].attr=function(e,r){if(e&&t.is(e,I)&&t.is(e[0],"object"))for(var i=0,n=e[b];i<n;i++)this.items[i].attr(e[i]);else for(var o=0,s=this.items[b];o<s;o++)this.items[o].attr(e,r);return this},xt[s].animate=function(e,r,i,n){(t.is(i,"function")||!i)&&(n=i||null);var o,s,a=this.items[b],l=a,p=this;for(n&&(s=function(){!--a&&n.call(p)}),i=t.is(i,T)?i:s,o=this.items[--l].animate(e,r,i,s);l--;)this.items[l]&&!this.items[l].removed&&this.items[l].animateWith(o,e,r,i,s);return this},xt[s].insertAfter=function(e){for(var t=this.items[b];t--;)this.items[t].insertAfter(e);return this},xt[s].getBBox=function(){for(var e=[],t=[],r=[],i=[],n=this.items[b];n--;){var o=this.items[n].getBBox();e[A](o.x),t[A](o.y),r[A](o.x+o.width),i[A](o.y+o.height)}return{x:e=k[d](0,e),y:t=k[d](0,t),width:C[d](0,r)-e,height:C[d](0,i)-t}},xt[s].clone=function(e){e=new xt;for(var t=0,r=this.items[b];t<r;t++)e[A](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:{}},r=e.face["font-family"];for(var i in e.face)e.face[a](i)&&(t.face[i]=e.face[i]);if(this.fonts[r]?this.fonts[r][A](t):this.fonts[r]=[t],!e.svg)for(var n in t.face["units-per-em"]=z(e.face["units-per-em"],10),e.glyphs)if(e.glyphs[a](n)){var o=e.glyphs[n];if(t.glyphs[n]={w:o.w,k:{},d:o.d&&"M"+o.d[G](/[mlcxtrv]/g,(function(e){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[e]||"M"}))+"z"},o.k)for(var s in o.k)o[a](s)&&(t.glyphs[n].k[s]=o.k[s])}return e},r.getFont=function(e,r,i,n){if(n=n||"normal",i=i||"normal",r=+r||{normal:400,bold:700,lighter:300,bolder:800}[r]||400,t.fonts){var o,s=t.fonts[e];if(!s){var l=new RegExp("(^|\\s)"+e[G](/[^\w\d\s+!~.:_-]/g,m)+"(\\s|$)","i");for(var p in t.fonts)if(t.fonts[a](p)&&l.test(p)){s=t.fonts[p];break}}if(s)for(var h=0,c=s[b];h<c&&((o=s[h]).face["font-weight"]!=r||o.face["font-style"]!=i&&o.face["font-style"]||o.face["font-stretch"]!=n);h++);return o}},r.print=function(e,r,n,o,s,a,l){a=a||"middle",l=C(k(l||0,1),-1);var p,h=this.set(),c=f(n).split(m),d=0;if(t.is(o,n)&&(o=this.getFont(o)),o){p=(s||16)/o.face["units-per-em"];for(var u=o.face.bbox.split(i),g=+u[0],v=+u[1]+("baseline"==a?u[3]-u[1]+ +o.face.descent:(u[3]-u[1])/2),y=0,x=c[b];y<x;y++){var w=y&&o.glyphs[c[y-1]]||{},E=o.glyphs[c[y]];d+=y?(w.w||o.w)+(w.k&&w.k[c[y]]||0)+o.w*l:0,E&&E.d&&h[A](this.path(E.d).attr({fill:"#000",stroke:"none",translation:[d,0]}))}h.scale(p,p,g,v).translate(e-g,r-v)}return h},t.format=function(e,r){var i=t.is(r,I)?[0].concat(r):arguments;return e&&t.is(e,T)&&i[b]-1&&(e=e[G](o,(function(e,t){return null==i[++t]?m:i[t]}))),e||m},t.ninja=function(){return h.was?p.Raphael=h.is:Raphael=void 0,t},t.el=Re,t.st=xt[s],ur.exports=t}();var mr={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",BLUE_A:"#CCFAFF",BLUE_B:"#80F6FF",BLUE_C:"#63D9EA",BLUE_D:"#11ACCD",BLUE_E:"#0C7F99",TEAL_A:"#94FFF5",TEAL_B:"#26EDD5",TEAL_C:"#01D1C1",TEAL_D:"#01A995",TEAL_E:"#208170",GREEN_A:"#B6FFB0",GREEN_B:"#8AF281",GREEN_C:"#74CF70",GREEN_D:"#1FAB54",GREEN_E:"#0D923F",GOLD_A:"#FFD0A9",GOLD_B:"#FFBB71",GOLD_C:"#FF9C39",GOLD_D:"#E07D10",GOLD_E:"#A75A05",RED_A:"#FCA9A9",RED_B:"#FF8482",RED_C:"#F9685D",RED_D:"#E84D39",RED_E:"#BC2612",MAROON_A:"#FFBDE0",MAROON_B:"#FF92C6",MAROON_C:"#ED5FA6",MAROON_D:"#CA337C",MAROON_E:"#9E034E",PURPLE_A:"#DDD7FF",PURPLE_B:"#C6B9FC",PURPLE_C:"#AA87FF",PURPLE_D:"#7854AB",PURPLE_E:"#543B78",MINT_A:"#F5F9E8",MINT_B:"#EDF2DF",MINT_C:"#E0E5CC",GRAY_A:"#F6F7F7",GRAY_B:"#F0F1F2",GRAY_C:"#E3E5E6",GRAY_D:"#D6D8DA",GRAY_E:"#BABEC2",GRAY_F:"#888D93",GRAY_G:"#626569",GRAY_H:"#3B3E40",GRAY_I:"#21242C",KA_BLUE:"#314453",KA_GREEN:"#71B307",_BACKGROUND:"#FDFDFD",INTERACTING:"#71B307",INTERACTIVE:"#71B307",DYNAMIC:"#6495ED"};function gr(e,t){var r=y(e).find("."+t);return 0===r.length?y("<span>").addClass(t).appendTo(y(e)):r}function fr(e,t){var r=0;!function i(){e.scrollHeight>18||r>=10?t():(r++,setTimeout(i,100))}()}var vr,yr,br={processMath:(vr=function*(e,t,r,i){var n=y(e);if(null==n.attr("data-math-formula")||r){var o=gr(n,"katex-holder"),s=gr(n,"mathjax-holder"),a=s.find("script[type='math/tex']")[0];null==t&&(n.attr("data-math-formula")?t=n.attr("data-math-formula"):a&&(t=a.text||a.textContent)),t=null!=t?t+"":"",t=de.cleanMath(t),n.attr("data-math-formula",t);var l=yield ae().getKaTeX();try{if(l.render(t,o[0],{colorIsTextColor:!0}),"mathjax"===n.attr("data-math-type")&&"undefined"!=typeof MathJax){var p=MathJax.Hub.getJaxFor(a);if(p){var h=p.SourceElement();h.previousSibling&&h.previousSibling.className&&p.Remove()}}return n.attr("data-math-type","katex"),void(i&&fr(e,i))}catch(e){if(ae().logKaTeXError(t,e),e instanceof l.ParseError)throw e}n.attr("data-math-type","mathjax"),a?"text"in a?a.text=t:a.textContent=t:s.append("<script type='math/tex'>"+t.replace(/<\//g,"< /")+"<\/script>"),"undefined"!=typeof MathJax&&(MathJax.Hub.Queue(["Reprocess",MathJax.Hub,s[0]]),i&&MathJax.Hub.Queue((function(){var t=MathJax.Callback((function(){}));return fr(e,(function(){i(),t()})),t})))}},yr=function(){var e=this,t=arguments;return new Promise((function(r,i){var n=vr.apply(e,t);function o(e){V(n,r,i,o,s,"next",e)}function s(e){V(n,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r,i){return yr.apply(this,arguments)}),cleanupMath:function(e){var t=y(e);if(t.attr("data-math-formula")){if("undefined"!=typeof MathJax){var r=MathJax.Hub.getJaxFor(t.find("script")[0]);if(r){var i=r.SourceElement();i.previousSibling&&i.previousSibling.className&&r.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 y(e).attr("data-math-formula")}},{processMath:xr}=br;function wr(e,t){return"number"==typeof e&&(e=[e,e]),t=t*Math.PI/180,[e[0]*Math.cos(t),e[1]*Math.sin(t)]}var Cr={unscaledSvgPath:function(e){return!0===e[0]?"":y.map(e,(function(e,t){return!0===e?"z":(0===t?"M":"L")+e[0]+" "+e[1]})).join("")},getDistance:function(e,t){return x.distanceToPoint(e,t)},coordDiff:function(e,t){return h.map(t,(function(r,i){return t[i]-e[i]}))},snapCoord:function(e,t){return h.map(e,(function(e,r){return de.roundToNearest(t[r],e)}))},findAngle:function(e,t,r){if(void 0===r){var i=e[0]-t[0],n=e[1]-t[1];return i||n?(180+180*Math.atan2(-n,-i)/Math.PI+360)%360:0}return Cr.findAngle(e,r)-Cr.findAngle(t,r)},graphs:{}},kr=Cr.Graphie=function(){};h.extend(kr.prototype,{cartToPolar:function(e,t){var r=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)),i=Math.atan2(e[1],e[0]);return i<0&&(i+=2*Math.PI),t||(i=180*i/Math.PI),[r,i]},polar:wr});var Er={center:[-.5,-.5],above:[-.5,-1],"above right":[0,-1],right:[0,-.5],"below right":[0,0],below:[-.5,0],"below left":[-1,0],left:[-1,-.5],"above left":[-1,-1]},Sr={"stroke-width":null};Cr.createGraphie=function(e){var t,r,i=40,n=40;y(e).css("position","relative");var o=ur.exports(e);y(e).children("div").css("position","absolute");var s={"stroke-width":2,fill:"none"},a=function e(t){if("number"==typeof t)return e([t,t]);var r=t[0],o=t[1];return[r*i,o*n]},l=function e(o){if("number"==typeof o)return e([o,o]);var s=o[0],a=o[1];return[(s-t[0])*i,(r[1]-a)*n]},p=function(e,t){var r=y(e),i=r.data("labelDirection"),[n,o]=t;if(0===n&&0===o&&([n,o]=[1,1],he.log("Label size was 0x0 in graphie.js; using 1x1 instead")),r.css("visibility",""),"number"==typeof i){var s=Math.cos(i),a=Math.sin(i),l=Math.min(n/2/Math.abs(s),o/2/Math.abs(a));r.css({marginLeft:-n/2+s*l,marginTop:-o/2-a*l})}else{var p=Er[i||"center"];r.css({marginLeft:Math.round(n*p[0]),marginTop:Math.round(o*p[1])})}},c=function(e,t){return y.map(e,(function(e,r){if(!0===e)return"z";var i=t?e:l(e);return(0===r?"M":"L")+de.bound(i[0])+" "+de.bound(i[1])})).join("")},d=function(e,r,i){var n=function(t){return(e*t+r)*t+i};if(0===e){var o=h.map(t,(function(e){return[e,n(e)]}));return c(o)}var s=-r/(2*e),a=s+Math.max(Math.abs(s-t[0]),Math.abs(s-t[1])),p=[s,n(s)],d=[a,n(a)],u=[p[0],p[1]-(d[1]-p[1])],m=Math.abs(p[0]-d[0]),g=[p[0]-m,d[1]],f=[p[0]+m,d[1]],v=h.map([g,u,f],l),y=h.map(h.flatten(v),de.bound);return"M"+y[0]+","+y[1]+" Q"+y[2]+","+y[3]+" "+y[4]+","+y[5]},u=function(e,r,i,n){for(var o=Math.abs(Math.PI/(2*r)),s=function(t){return e*Math.sin(r*t-i)+n},a=function(t){return e*r*Math.cos(i-r*t)},p=function(e,t){var r=e+o*t,i=r+o,n=[r,2*r/3+1*i/3,1*r/3+2*i/3,i],p=[s(r),s(r)+a(r)*(i-r)/3,s(i)-a(i)*(i-r)/3,s(i)];return h.map(h.zip(n,p),l)},c=t[1]-t[0],d=Math.ceil(c/o)+1,u=i/r,m=u-t[0],g=p(u-=o*Math.ceil(m/o),0),f="M"+g[0][0]+","+g[0][1]+" C"+g[1][0]+","+g[1][1]+" "+g[2][0]+","+g[2][1]+" "+g[3][0]+","+g[3][1],v=1;v<d;v++)f+=" C"+(g=p(u,v))[1][0]+","+g[1][1]+" "+g[2][0]+","+g[2][1]+" "+g[3][0]+","+g[3][1];return f};Cr.svgPath=c;var m=function(e){var s={scale:function(e){"number"==typeof e&&(e=[e,e]),i=e[0],n=e[1],o.setSize((t[1]-t[0])*i,(r[1]-r[0])*n)},clipRect:function(e){var t=e[0],r=e[1];return t[1]+=r[1],{"clip-rect":l(t).concat(a(r)).join(" ")}},strokeWidth:function(e){return{"stroke-width":parseFloat(e)}},rx:function(e){return{rx:a([e,0])[0]}},ry:function(e){return{ry:a([0,e])[1]}},r:function(e){var t=a([e,e]);return{rx:t[0],ry:t[1]}}},p={};return y.each(e||{},(function(e,t){var r=s[e];if("function"==typeof r)y.extend(p,r(t));else{var i=e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase();p[i]=t}})),p},g=function e(t){var r=t.constructor.prototype;if(r===ur.exports.el){if("path"===t.type&&void 0===t.arrowheadsDrawn){var i=.6+.4*t.attr("stroke-width"),n=t.getTotalLength(),s=o.set(),a=o.path(v.isMobile?"M-4,4 C-4,4 -0.25,0 -0.25,0 C-0.25,0 -4,-4 -4,-4":"M-3 4 C-2.75 2.5 0 0.25 0.75 0C0 -0.25 -2.75 -2.5 -3 -4"),l=t.getPointAtLength(n-.4),p=t.getPointAtLength(n-.75*i),h=180*Math.atan2(l.y-p.y,l.x-p.x)/Math.PI,c=t.attr();delete c.path;var d=t.getSubpath(0,n-.75*i);return(d=o.path(d).attr(c)).arrowheadsDrawn=!0,t.remove(),a.rotate(h,v.isMobile?1e-5:.75,0).scale(i,i,.75,0).translate(p.x,p.y).attr(c).attr({"stroke-linejoin":"round","stroke-linecap":"round"}),a.arrowheadsDrawn=!0,s.push(d),s.push(a),s}}else if(r===ur.exports.st)for(var u=0,m=t.items.length;u<m;u++)e(t.items[u]);return t},f={circle:function(e,t){return o.ellipse(...l(e).concat(a([t,t])))},rect:function(e,t,r,i){var n=l([e,t+i]),s=a([r,i]),p=o.rect(...n.concat(s));return v.isMobile&&(p.node.style.shapeRendering="crispEdges"),p},ellipse:function(e,t){return o.ellipse(...l(e).concat(a(t)))},fixedEllipse:function(e,t,r,i){var n=l(e),o=a(t),s=2*o[0]*r+i,p=2*o[1]*r+i,h=n[0]-s/2,c=n[1]-p/2,d=document.createElement("div");return y(d).css({position:"absolute",width:s+"px",height:p+"px",left:h+"px",top:c+"px"}),{wrapper:d,visibleShape:ur.exports(d,s,p).ellipse(s/2,p/2,o[0],o[1])}},arc:function(e,t,r,i,n){r=(r%360+360)%360,i=(i%360+360)%360;var s=l(e),p=a(t),h=wr(t,r),c=wr(t,i),d=l([e[0]+h[0],e[1]+h[1]]),u=l([e[0]+c[0],e[1]+c[1]]),m=((i-r)%360+360)%360>180;return o.path("M"+d.join(" ")+"A"+p.join(" ")+" 0 "+(m?1:0)+" 0 "+u.join(" ")+(n?"L"+s.join(" ")+"z":""))},path:function(e){var t=o.path(c(e));return t.graphiePath=e,t},fixedPath:function(e,t,r){e=h.map(e,l),t=t?l(t):null,r=r||c;var i=h.min(h.pluck(e,0)),n=h.max(h.pluck(e,0)),o=h.min(h.pluck(e,1)),s=h.max(h.pluck(e,1)),a=[4,4],p=[i,o];e=h.map(e,(function(e){return w.add(w.subtract(e,p),w.scale(a,.5))}));var d=n-i+a[0],u=s-o+a[1],m=p[0]-a[0]/2,g=p[1]-a[1]/2,f=document.createElement("div");return y(f).css({position:"absolute",width:d+"px",height:u+"px",left:m+"px",top:g+"px",transformOrigin:t?d/2+t[0]+"px "+(u/2+t[1])+"px":null}),{wrapper:f,visibleShape:ur.exports(f,d,u).path(r(e))}},scaledPath:function(e){var t=o.path(c(e,!0));return t.graphiePath=e,t},line:function(e,t){var r=this.path([e,t]);return v.isMobile&&(r.node.style.shapeRendering="crispEdges"),r},parabola:function(e,t,r){return o.path(d(e,t,r))},fixedLine:function(e,t,r){var i=[r,r];e=l(e),t=l(t);var n=[Math.min(e[0],t[0]),Math.min(e[1],t[1])];e=w.add(w.subtract(e,n),w.scale(i,.5)),t=w.add(w.subtract(t,n),w.scale(i,.5));var o=n[0]-i[0]/2,s=n[1]-i[1]/2,a=Math.abs(e[0]-t[0])+i[0],p=Math.abs(e[1]-t[1])+i[1],h=document.createElement("div");y(h).css({position:"absolute",width:a+"px",height:p+"px",left:o+"px",top:s+"px",transformOrigin:e[0]+"px "+e[1]+"px"});var c=ur.exports(h,a,p),d="M"+e[0]+" "+e[1]+" L"+t[0]+" "+t[1],u=c.path(d);return u.graphiePath=[e,t],{wrapper:h,visibleShape:u}},sinusoid:function(e,t,r,i){return o.path(u(e,t,r,i))},grid:function(e,t){for(var r=s.step||[1,1],i=o.set(),n=r[0]*Math.ceil(e[0]/r[0]);n<=e[1];n+=r[0])i.push(this.line([n,t[0]],[n,t[1]]));for(var a=r[1]*Math.ceil(t[0]/r[1]);a<=t[1];a+=r[1])i.push(this.line([e[0],a],[e[1],a]));return i},label:function(t,r,i,n){n=void 0===n||n;var o=y("<span>").addClass("graphie-label"),a=s["label-distance"];o.css(y.extend({},{position:"absolute",padding:(null!=a?a:7)+"px",color:"black"})).data("labelDirection",i).appendTo(e),o.setPosition=function(e){var t=l(e);o.css({left:t[0],top:t[1]})},o.setPosition(t);var h=o[0];return o.processMath=function(e,t){xr(h,e,t,(function(){var e=h.scrollWidth,t=h.scrollHeight;p(h,[e,t])}))},o.processText=function(e){o.html(e);var t=h.scrollWidth,r=h.scrollHeight;p(h,[t,r])},n?o.processMath(r,!1):o.processText(r),o},plotParametric:function(e,t,r,i){i=i||function(e){return[e,0]};var a=e=>Math.abs(e[1])>5e5?[e[0],Math.min(Math.max(e[1],-5e5),5e5)]:e,l=t=>a(e(t)),p=e=>a(i(e));s.strokeLinejoin||(s.strokeLinejoin="round"),s.strokeLinecap||(s.strokeLinecap="round");var h=t[0],c=t[1],d=(c-h)/(s["plot-points"]||800);0===d&&(d=1);for(var u=o.set(),m=[],g=Cr.coordDiff(l(h),p(h)),f=h,v=h;v<=c;v+=d){var y=l(v),b=p(v),x=Cr.coordDiff(y,b);if(x[1]<0!=g[1]<0&&Math.abs(x[1]-g[1])>2*n||isNaN(x[1])){if(r){m.push(y);for(var w=v-d;w>=f;w-=d)m.push(p(w));f=v}u.push(this.path(m)),m=[],r&&m.push(y)}else m.push(y);g=x}if(r)for(var C=c-d;C>=f;C-=d)m.push(p(C));return u.push(this.path(m)),u},plotPolar:function(e,t){var r=t[0],n=t[1];return s["plot-points"]||(s["plot-points"]=2*(n-r)*i),this.plotParametric((function(t){return wr(e(t),180*t/Math.PI)}),t)},plot:function(e,t,r,n,o){var a=t[0],l=t[1];if(s["plot-points"]||(s["plot-points"]=2*(l-a)*i),r){if(o)throw new ce("Can't shade area between functions with swapped axes.",pe.Internal);return this.plotParametric((function(t){return[e(t),t]}),t,n)}if(o){if(n)return this.plotParametric((function(t){return[t,e(t)]}),t,n,(function(e){return[e,o(e)]}));throw new ce("fn2 should only be set when 'shade' is True.",pe.Internal)}return this.plotParametric((function(t){return[t,e(t)]}),t,n)},plotPiecewise:function(e,t){var r=o.set(),i=this;return h.times(e.length,(function(n){var o=e[n],s=t[n],a=i.plotParametric((function(e){return[e,o(e)]}),s);h.each(a,(function(e){r.push(e)}))})),r},plotEndpointCircles:function(e){var t=o.set(),r=this;return h.each(e,(function(e,i){t.push(r.circle(e,.15))})),t},plotAsymptotes:function(e,t){for(var r=t[0],i=t[1],a=(i-r)/(s["plot-points"]||800),l=o.set(),p=e(r),h=r;h<=i;h+=a){var c=e(h);c<0!=p<0&&Math.abs(c-p)>2*n&&l.push(this.line([h,n],[h,-n])),p=c}return l}},v=new kr;return h.extend(v,{raphael:o,init:function(s){var a=s.scale||[40,40];if(i=(a="number"==typeof a?[a,a]:a)[0],n=a[1],null==s.range)throw new ce("range should be specified in graph init",pe.Internal);t=s.range[0],r=s.range[1];var l=(t[1]-t[0])*i,p=(r[1]-r[0])*n;return o.setSize(l,p),y(e).css({width:l,height:p}),this.range=s.range,this.scale=a,this.dimensions=[l,p],this.xpixels=l,this.ypixels=p,this.isMobile=s.isMobile,this},style:function(e,t){var r=m(e);if("function"==typeof t){var i=s;s=y.extend({},s,r);var n=t.call(v);return s=i,n}y.extend(s,r)},scalePoint:l,scaleVector:a,unscalePoint:function e(o){if("number"==typeof o)return e([o,o]);var s=o[0],a=o[1];return[s/i+t[0],r[1]-a/n]},unscaleVector:function e(t){return"number"==typeof t?e([t,t]):[t[0]/i,t[1]/n]},svgPath:c,svgParabolaPath:d,svgSinusoidPath:u}),y.each(f,(function(e){v[e]=function(){var t,r=arguments[arguments.length-1],i=s;if("object"!=typeof r||h.isArray(r))s=y.extend({},s),t=f[e](...arguments);else{s=G(G({},s),m(r));var n=[].slice.call(arguments,0,arguments.length-1);t=f[e](...n)}var o=t.constructor.prototype;return o===ur.exports.el||o===ur.exports.st?(t.attr(s),s.arrows&&(t=g(t))):t instanceof y&&t.css(G(G({},s),Sr)),s=i,t}})),v.graphInit=function(e){e=e||{},y.each(e,(function(t,r){t.match(/.*Opacity$/)||"range"===t||"number"!=typeof r||(e[t]=[r,r]),"range"!==t&&"gridRange"!==t||(r.constructor===Array?r[0].constructor!==Array&&(e[t]=[[-r[0],r[0]],[-r[1],r[1]]]):"number"==typeof r&&(e[t]=[[-r,r],[-r,r]]))}));var t=e.range||[[-10,10],[-10,10]],r=e.gridRange||e.range,i=e.scale||[20,20],n=null==e.grid||e.grid,o=e.gridOpacity||.1,s=e.gridStep||[1,1],a=null==e.axes||e.axes,l=e.axisArrows||"",p=e.axisOpacity||1,c=e.axisCenter||[Math.min(Math.max(t[0][0],0),t[0][1]),Math.min(Math.max(t[1][0],0),t[1][1])],d=null!=e.axisLabels&&e.axisLabels,u=null==e.ticks||e.ticks,m=e.tickStep||[2,2],g=e.tickLen||[5,5],f=e.tickOpacity||1,v=e.labels||e.labelStep||!1,b=e.labelStep||[1,1],x=e.labelOpacity||1,w=e.unityLabels||!1,C=e.labelFormat||function(e){return e},k=e.xLabelFormat||C,E=e.yLabelFormat||C,S=null==e.smartLabelPositioning||e.smartLabelPositioning,_=[[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)]];if(h.isArray(w)||(w=[w,w]),S){var M=function(e){return function(t){return(e(t)+"").replace(/-(\d)/g,"\\llap{-}$1")}};k=M(k),E=M(E)}if(this.init({range:_,scale:i,isMobile:e.isMobile}),n&&this.grid(r[0],r[1],{stroke:e.isMobile?mr.GRAY_C:"#000000",opacity:e.isMobile?1:o,step:s,strokeWidth:e.isMobile?1:2}),a&&("<->"===l||!0===l?this.style({stroke:e.isMobile?mr.GRAY_G:"#000000",opacity:e.isMobile?1:p,strokeWidth:e.isMobile?1:2,arrows:"->"},(function(){t[1][0]<0&&t[1][1]>0&&(this.path([c,[r[0][0],c[1]]]),this.path([c,[r[0][1],c[1]]])),t[0][0]<0&&t[0][1]>0&&(this.path([c,[c[0],r[1][0]]]),this.path([c,[c[0],r[1][1]]]))})):"->"!==l&&""!==l||this.style({stroke:"#000000",opacity:p,strokeWidth:2,arrows:l},(function(){this.path([[r[0][0],c[1]],[r[0][1],c[1]]]),this.path([[c[0],r[1][0]],[c[0],r[1][1]]])})),d&&2===d.length&&(this.label([r[0][1],c[1]],d[0],"right"),this.label([c[0],r[1][1]],d[1],"above"))),u){var T=e.isMobile;this.style({stroke:e.isMobile?mr.GRAY_G:"#000000",opacity:e.isMobile?1:f,strokeWidth:1},(function(){var e=s[0]*m[0],n=g[0]/i[1],o=r[0][0],a=r[0][1];if(t[1][0]<0&&t[1][1]>0){for(var p=e+c[0];p<=a;p+=e)(p<a||!l)&&this.line([p,-n+c[1]],[p,T?0:n+c[1]]);for(var h=-e+c[0];h>=o;h-=e)(h>o||!l)&&this.line([h,-n+c[1]],[h,T?0:n+c[1]])}if(e=s[1]*m[1],n=g[1]/i[0],o=r[1][0],a=r[1][1],t[0][0]<0&&t[0][1]>0){for(var d=e+c[1];d<=a;d+=e)(d<a||!l)&&this.line([-n+c[0],d],[T?0:n+c[0],d]);for(var u=-e+c[1];u>=o;u-=e)(u>o||!l)&&this.line([-n+c[0],u],[T?0:n+c[0],u])}}))}v&&this.style({stroke:e.isMobile?mr.GRAY_G:"#000000",opacity:e.isMobile?1:x},(function(){for(var e=s[0]*m[0]*b[0],t=r[0][0],i=r[0][1],n=c[0]<0?"above":"below",o=c[0]<0?"right":"left",a=0===c[0]&&0!==c[1],p=0!==c[0]&&0===c[1],h=0!==c[0]||0!==c[1],d=w[0]||h,u=w[1]||h,g=(a?0:e)+c[0];g<=i;g+=e)(g<i||!l)&&this.label([g,c[1]],k(g),n);for(var f=-e*(d?1:2)+c[0];f>=t;f-=e)(f>t||!l)&&this.label([f,c[1]],k(f),n);e=s[1]*m[1]*b[1],t=r[1][0],i=r[1][1];for(var v=(p?0:e)+c[1];v<=i;v+=e)(v<i||!l)&&this.label([c[0],v],E(v),o);for(var y=-e*(u?1:2)+c[1];y>=t;y-=e)(y>t||!l)&&this.label([c[0],y],E(y),o)}))},v},function(e,t,r,i){if(void 0!==e){var n="virtualMouseBindings",o="virtualTouchID",s="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),a="clientX clientY pageX pageY screenX screenY".split(" "),l=e.event.mouseHooks?e.event.mouseHooks.props:[],p=e.event.props.concat(l),h={},c=0,d=0,u=0,m=!1,g=[],f=!1,v=!1,y="addEventListener"in r,b=e(r),x=1,w=0;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var C=0;C<s.length;C++)e.event.special[s[C]]=L(s[C]);y&&r.addEventListener("click",(function(t){var r,i,n,s,a,l=g.length,p=t.target;if(l)for(r=t.clientX,i=t.clientY,threshold=e.vmouse.clickDistanceThreshold,n=p;n;){for(s=0;s<l;s++)if(a=g[s],n===p&&Math.abs(a.x-r)<threshold&&Math.abs(a.y-i)<threshold||e.data(n,o)===a.touchID)return t.preventDefault(),void t.stopPropagation();n=n.parentNode}}),!0)}function k(e){for(;e&&void 0!==e.originalEvent;)e=e.originalEvent;return e}function E(t){for(var r,i,o={};t;){for(i in r=e.data(t,n))r[i]&&(o[i]=o.hasVirtualBinding=!0);t=t.parentNode}return o}function S(){v=!0}function _(){v=!1}function M(){T(),c=setTimeout((function(){c=0,w=0,g.length=0,f=!1,S()}),e.vmouse.resetTimerDuration)}function T(){c&&(clearTimeout(c),c=0)}function I(t,r,i){var o;return(i&&i[t]||!i&&function(t,r){for(var i;t;){if((i=e.data(t,n))&&(!r||i[r]))return t;t=t.parentNode}return null}(r.target,t))&&(o=function(t,r){var i,n,o,s,l,h,c,d,u,m=t.type;if((t=e.Event(t)).type=r,i=t.originalEvent,n=e.event.props,m.search(/mouse/)>-1&&(n=p),i)for(c=n.length;c;)t[s=n[--c]]=i[s];if(m.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1),-1!==m.search(/^touch/)&&(m=(o=k(i)).touches,l=o.changedTouches,h=m&&m.length?m[0]:l&&l.length?l[0]:void 0))for(d=0,u=a.length;d<u;d++)t[s=a[d]]=h[s];return t}(r,t),e(r.target).trigger(o)),o}function P(t){var r=e.data(t.target,o);if(!(f||w&&w===r)){var i=I("v"+t.type,t);i&&(i.isDefaultPrevented()&&t.preventDefault(),i.isPropagationStopped()&&t.stopPropagation(),i.isImmediatePropagationStopped()&&t.stopImmediatePropagation())}}function N(t){var r,i,n=k(t).touches;if(n&&1===n.length&&(i=E(r=t.target)).hasVirtualBinding){w=x++,e.data(r,o,w),T(),_(),m=!1;var s=k(t).touches[0];d=s.pageX,u=s.pageY,I("vmouseover",t,i),I("vmousedown",t,i)}}function A(e){v||(m||I("vmousecancel",e,E(e.target)),m=!0,M())}function R(t){if(!v){var r=k(t).touches[0],i=o,n=e.vmouse.moveDistanceThreshold,o=o||Math.abs(r.pageX-d)>n||Math.abs(r.pageY-u)>n,s=E(t.target);o&&!i&&I("vmousecancel",t,s),I("vmousemove",t,s),M()}}function F(e){if(!v){S();var t,r=E(e.target);if(I("vmouseup",e,r),!m){var i=I("vclick",e,r);i&&i.isDefaultPrevented()&&(t=k(e).changedTouches[0],g.push({touchID:w,x:t.clientX,y:t.clientY}),f=!0)}I("vmouseout",e,r),m=!1,M()}}function O(t){var r,i=e.data(t,n);if(i)for(r in i)if(i[r])return!0;return!1}function D(){}function L(t){var r=t.substr(1);return{setup:function(i,o){O(this)||e.data(this,n,{}),e.data(this,n)[t]=!0,h[t]=(h[t]||0)+1,1===h[t]&&b.bind(r,P),e(this).bind(r,D),y&&(h.touchstart=(h.touchstart||0)+1,1===h.touchstart&&b.bind("touchstart",N).bind("touchend",F).bind("touchmove",R).bind("scroll",A))},teardown:function(i,o){--h[t],h[t]||b.unbind(r,P),y&&(--h.touchstart,h.touchstart||b.unbind("touchstart",N).unbind("touchmove",R).unbind("touchend",F).unbind("scroll",A));var s=e(this),a=e.data(this,n);a&&(a[t]=!1),s.unbind(r,D),O(this)||s.removeData(n)}}}}(window.jQuery,window,document);var _r={pluck:function(e,t){return h.object(h.map(e,(function(e,r){return[r,e[t]]})))},mapObject:function(e,t){var r={};return h.each(h.keys(e),(function(i){r[i]=t(e[i],i)})),r},mapObjectFromArray:function(e,t){var r={};return h.each(e,(function(e){r[e]=t(e)})),r}},Mr=h.extend({transform:function(e){var t=hr.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(),y(this.wrapper).remove()},getMouseTarget:function(){return this.visibleShape[0]},moveTo:function(e){var t=w.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),r=hr.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()}},_r.mapObjectFromArray(["attr","animate"],(function(e){return function(){this.visibleShape[e](...arguments)}}))),Tr={maxScale:1,mouselayer:!1,shadow:!1,disableMouseEventsOnWrapper:!1},Ir=function(e,t,r,i){i=h.extend({},Tr,i);var n=e.fixedEllipse(t,r,i.maxScale,i.padding);if(h.extend(this,n,{graphie:e,initialPoint:t}),i.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",i.interactiveKindForTesting),i.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),i.shadow){var o="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))",s=this.wrapper;s.style.webkitFilter=o,s.style.filter=o,this.moveTo=function(e){var t=w.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),r=hr.getCanUse3dTransform(),i="translateX("+Math.round(t[0])+"px) translateY("+Math.round(t[1])+"px)"+(r?" translateZ(0)":"");this.transform(i)}}i.disableMouseEventsOnWrapper&&(this.wrapper.style.pointerEvents="none",this.visibleShape.node.style.pointerEvents="auto")};h.extend(Ir.prototype,Mr);var Pr={thickness:2,mouselayer:!1},Nr=function(e,t,r,i){i=h.extend({},Pr,i);var n=[e.range[0][0],0],o=[e.range[0][1],0];h.extend(this,e.fixedLine(n,o,i.thickness)),i.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",i.interactiveKindForTesting),this.visibleShape.attr(i.normalStyle),h.extend(this,{graphie:e,initialPoint:e.scalePoint(n),initialLength:x.distanceToPoint(e.scalePoint(n),e.scalePoint(o))}),i.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),this.moveTo(t,r)};h.extend(Nr.prototype,Mr,{getMouseTarget:function(){return this.wrapper},moveTo:function(e,t){var r=this.graphie.scalePoint(e),i=this.graphie.scalePoint(t),n=w.polarDegFromCart(w.subtract(i,r)),o=n[0],s=de.bound(n[1]),a=w.subtract(r,this.initialPoint),l=de.bound(o/this.initialLength),p=hr.getCanUse3dTransform(),h="translateX("+a[0]+"px) translateY("+a[1]+"px) "+(p?" translateZ(0)":"")+"rotate("+s+"deg) scaleX("+l+") scaleY(1)";this.transform(h)}});var Ar={center:null,createPath:null,mouselayer:!1},Rr=function(e,t,r){r=h.extend({},Ar,r),h.extend(this,e.fixedPath(t,r.center,r.createPath)),h.extend(this,{graphie:e,initialPoint:e.scalePoint(h.head(t))}),r.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper)};h.extend(Rr.prototype,Mr);var{getCanUse3dTransform:Fr}=hr;function Or(e){return h.reduce(e,(function(e,t){return e+t}),0)}function Dr(){var e=h.zip(...arguments);return h.map(e,Or)}function Lr(e){return h.map(e,(function(e){return-1*e}))}function Br(e){var t=11.374597405497571;return 58.919514629750836*Math.exp(-.037587715462826674*e)+t}function zr(e,t){return[e*Math.cos(t),e*Math.sin(t)*-1]}function Hr(e,t){return zr(e,t*Math.PI/180)}var Wr=!1,qr={animate:function(){},attr:function(){},remove:function(){}};function Ur(e,t){this.set=e.raphael.set(),this.cx=t[0],this.cy=t[1];var r=this,i=e.unscaleVector(180.5)[0],n=e.scalePoint([this.cx-i,this.cy+i-e.unscaleVector(10.5)[1]]),o=e.mouselayer.image("https://ka-perseus-graphie.s3.amazonaws.com/e9d032f2ab8b95979f674fbfa67056442ba1ff6a.png",n[0],n[1],360,180);this.set.push(o),o.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});var s=function(r,n){var o=e.scaleVector(i);o[0]-=16,o[1]-=16;var s=e.scalePoint(t);return Math.sin((r+90)*Math.PI/180)*(o[0]+n)+s[0]+","+(Math.cos((r+90)*Math.PI/180)*(o[1]+n)+s[1])},a=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(i)[0]+10)+","+(e.scaleVector(i)[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(i)[0]+10)+","+(e.scaleVector(i)[1]+10)+",0,0,0,"+s(180,6)+" Z").attr({stroke:null,fill:mr.INTERACTIVE});this.set.push(a),this.centerPoint=e.addMovablePoint({coord:t,visible:!1}),this.rotateHandle=e.addMovablePoint({bounded:!1,coord:[Math.sin(275*Math.PI/180)*i+this.cx,Math.cos(275*Math.PI/180)*i+this.cy],onMove:function(e,t){var i=180*Math.atan2(r.centerPoint.coord[1]-t,r.centerPoint.coord[0]-e)/Math.PI;r.rotate(-i-5,!0)}}),this.rotateHandle.constraints.fixedDistance.dist=i,this.rotateHandle.constraints.fixedDistance.point=this.centerPoint,this.rotateHandle.visibleShape.remove(),this.rotateHandle.mouseTarget.attr({scale:2});var l=!1,p=!1,h=function(){return p||l},c=y(this.rotateHandle.mouseTarget.getMouseTarget());c.bind("vmousedown",(function(e){l=!0,c.css("cursor","-webkit-grabbing"),c.css("cursor","grabbing"),a.animate({scale:1.5,fill:mr.INTERACTING},50),y(document).bind("vmouseup.rotateHandle",(function(e){l=!1,c.css("cursor","-webkit-grab"),c.css("cursor","grab"),h()||a.animate({scale:1,fill:mr.INTERACTIVE},50),y(document).unbind("vmouseup.rotateHandle")}))})),c.bind("vmouseover",(function(e){p=!0,a.animate({scale:1.5,fill:mr.INTERACTING},50)})),c.bind("vmouseout",(function(e){p=!1,h()||a.animate({scale:1,fill:mr.INTERACTIVE},50)}));var d=y.map(this.set,(function(e){return e.node}));return this.makeTranslatable=function(){y(d).css("cursor","move"),c.css("cursor","-webkit-grab"),c.css("cursor","grab"),y(d).bind("vmousedown",(function(t){t.preventDefault();var i=t.pageX-y(e.raphael.canvas.parentNode).offset().left,n=t.pageY-y(e.raphael.canvas.parentNode).offset().top;y(document).bind("vmousemove.protractor",(function(t){var o=t.pageX-y(e.raphael.canvas.parentNode).offset().left,s=t.pageY-y(e.raphael.canvas.parentNode).offset().top;o=Math.max(10,Math.min(e.xpixels-10,o)),s=Math.max(10,Math.min(e.ypixels-10,s));var a=o-i,l=s-n;y.each(r.set.items,(function(){this.translate(a,l)})),r.centerPoint.setCoord([r.centerPoint.coord[0]+a/e.scale[0],r.centerPoint.coord[1]-l/e.scale[1]]),r.rotateHandle.setCoord([r.rotateHandle.coord[0]+a/e.scale[0],r.rotateHandle.coord[1]-l/e.scale[1]]),i=o,n=s})),y(document).one("vmouseup",(function(e){y(document).unbind("vmousemove.protractor")}))}))},this.rotation=0,this.rotate=function(t,r){var i=e.scalePoint(this.centerPoint.coord);return r&&(this.rotation=0),this.set.rotate(this.rotation+t,i[0],i[1]),this.rotation=this.rotation+t,this},this.moveTo=function(t,i){var n=e.scalePoint(r.centerPoint.coord),o=e.scalePoint([t,i]),s=2*Cr.getDistance(n,o);y({x:n[0],y:n[1]}).animate({x:o[0],y:o[1]},{duration:s,step:function(t,i){var n=0,o=0;"x"===i.prop?n=t-e.scalePoint(r.centerPoint.coord)[0]:"y"===i.prop&&(o=t-e.scalePoint(r.centerPoint.coord)[1]),y.each(r.set.items,(function(){this.translate(n,o)})),r.centerPoint.setCoord([r.centerPoint.coord[0]+n/e.scale[0],r.centerPoint.coord[1]-o/e.scale[1]]),r.rotateHandle.setCoord([r.rotateHandle.coord[0]+n/e.scale[0],r.rotateHandle.coord[1]-o/e.scale[1]])}})},this.rotateTo=function(e){Math.abs(this.rotation-e)>180&&(this.rotation+=360);var t=5*Math.abs(this.rotation-e);y({0:this.rotation}).animate({0:e},{duration:t,step:function(e,t){r.rotate(e,!0),r.rotateHandle.setCoord([Math.sin((e+275)*Math.PI/180)*i+r.centerPoint.coord[0],Math.cos((e+275)*Math.PI/180)*i+r.centerPoint.coord[1]])}})},this.remove=function(){this.set.remove()},this.makeTranslatable(),this}function Gr(e,t){h.defaults(t,{center:[0,0],pixelsPerUnit:40,ticksPerUnit:10,units:10,label:"",style:{fill:null,stroke:mr.GRAY}});var r,i=h.extend({},t.style,{strokeWidth:1}),n=h.extend({},t.style,{strokeWidth:2}),o=t.units*t.pixelsPerUnit,s=e.unscalePoint(w.subtract(e.scalePoint(t.center),w.scale([o,-50],.5))),a=t.pixelsPerUnit/e.scale[0],l=50/e.scale[0],p=w.add(s,[t.units*a,l]);if(10===t.ticksPerUnit)r={10:1,5:.55,1:.35};else{var c=[1,.6,.45,.3];r={};for(var d=t.ticksPerUnit;d>=1;d/=2)r[d]=1*(c.shift()||.2)}var u=h.keys(r).sort((function(e,t){return t-e}));var m=s[0],g=s[1],f=p[0],v=p[1],b=t.units*t.ticksPerUnit+1,x=e.raphael.set(),C=1/e.scale[0];x.push(e.line([m-C,g],[f+C,g],n)),x.push(e.line([m-C,v],[f+C,v],n)),h.times(b,(function(o){var s=o/t.ticksPerUnit,p=m+s*a,h=function(e){for(var t=0;t<u.length;t++){var i=u[t];if(e%i==0)return r[i]}return 0}(o)*l,c=0===o||o===b-1?n:i;if(x.push(e.line([p,g],[p,g+h],c)),s%1==0){var d,f,y=e.scalePoint([p,v]);0===s?f={mm:13,cm:11,m:8,km:11,in:8,ft:8,yd:10,mi:10}[d=t.label]||3*d.toString().length:(d=s,f=-3*(s.toString().length+1));var w=e.raphael.text(y[0]+f,y[1]+10,d);w.attr({"font-family":"KaTeX_Main","font-size":"12px",color:"#444"}),x.push(w)}}));var k=e.mouselayer.path(Cr.svgPath([s,[m,v],p,[f,g],!0]));k.attr({fill:"#000",opacity:0,stroke:"#000","stroke-width":2}),x.push(k),k.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});var E=y.map(x,(function(e){return e.node}));y(E).css("cursor","move"),y(E).bind("vmousedown",(function(t){t.preventDefault();var r=t.pageX-y(e.raphael.canvas.parentNode).offset().left,i=t.pageY-y(e.raphael.canvas.parentNode).offset().top;y(document).bind("vmousemove.ruler",(function(t){var n=t.pageX-y(e.raphael.canvas.parentNode).offset().left,o=t.pageY-y(e.raphael.canvas.parentNode).offset().top;n=Math.max(10,Math.min(e.xpixels-10,n)),o=Math.max(10,Math.min(e.ypixels-10,o));var s=n-r,a=o-i;x.translate(s,a),S.setCoord([S.coord[0]+s/e.scale[0],S.coord[1]-a/e.scale[1]]),_.setCoord([_.coord[0]+s/e.scale[0],_.coord[1]-a/e.scale[1]]),r=n,i=o})),y(document).one("vmouseup",(function(e){y(document).unbind("vmousemove.ruler")}))}));var S=e.addMovablePoint({coord:s,normalStyle:{fill:mr.INTERACTIVE,"fill-opacity":0,stroke:mr.INTERACTIVE},highlightStyle:{fill:mr.INTERACTING,"fill-opacity":.1,stroke:mr.INTERACTING},pointSize:6,onMove:function(t,r){var i=_.coord[1]-r,n=_.coord[0]-t,o=180*Math.atan2(i,n)/Math.PI,s=w.scale(w.add([t,r],_.coord),.5),a=e.scalePoint(s),l=w.scale(w.add(S.coord,_.coord),.5),p=e.scalePoint(l),h=w.subtract(a,p);x.rotate(-o,p[0],p[1]),x.translate(h[0],h[1])}}),_=e.addMovablePoint({coord:[f,g],normalStyle:{fill:mr.INTERACTIVE,"fill-opacity":0,stroke:mr.INTERACTIVE},highlightStyle:{fill:mr.INTERACTING,"fill-opacity":.1,stroke:mr.INTERACTING},pointSize:6,onMove:function(t,r){var i=r-S.coord[1],n=t-S.coord[0],o=180*Math.atan2(i,n)/Math.PI,s=w.scale(w.add([t,r],S.coord),.5),a=e.scalePoint(s),l=w.scale(w.add(S.coord,_.coord),.5),p=e.scalePoint(l),h=w.subtract(a,p);x.rotate(-o,p[0],p[1]),x.translate(h[0],h[1])}});return S.constraints.fixedDistance.dist=o/e.scale[0],S.constraints.fixedDistance.point=_,_.constraints.fixedDistance.dist=o/e.scale[0],_.constraints.fixedDistance.point=S,this.remove=function(){x.remove(),S.remove(),_.remove()},this}function Vr(e,t){if(this.graphie=e,h.extend(this,t),h.defaults(this,{normalStyle:{stroke:mr.INTERACTIVE,"stroke-width":2,fill:mr.INTERACTIVE},highlightStyle:{stroke:mr.INTERACTING,"stroke-width":2,fill:mr.INTERACTING},labelStyle:{stroke:mr.DYNAMIC,"stroke-width":1,color:mr.DYNAMIC},angleStyle:{stroke:mr.DYNAMIC,"stroke-width":1,color:mr.DYNAMIC},allowReflex:!0}),!this.points||3!==this.points.length)throw new ce("MovableAngle requires 3 points",pe.InvalidInput);this.points=h.map(t.points,(function(t){return h.isArray(t)?e.addMovablePoint({coord:t,visible:!1,constraints:{fixed:!0},normalStyle:this.normalStyle}):t}),this),this.coords=h.pluck(this.points,"coord"),null==this.reflex&&(this.allowReflex?this.reflex=this._getClockwiseAngle(this.coords)>180:this.reflex=!1),this.rays=h.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()}h.extend(Cr.Graphie.prototype,{addMouseLayer:function(e){var t=this;e=h.extend({allowScratchpad:!1,setDrawingAreaAvailable:function(){}},e);if(t.mouselayer=ur.exports(t.raphael.canvas.parentNode,t.xpixels,t.ypixels),y(t.mouselayer.canvas).css("z-index",2),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;y(t.mouselayer.canvas).on("vmousedown",(function(n){n.target===r[0]&&(e.onMouseDown&&e.onMouseDown(t.getMouseCoord(n)),i=!0,e.onMouseMove&&y(document).bind("vmousemove.mouseLayer",(function(r){i&&(r.preventDefault(),e.onMouseMove(t.getMouseCoord(r)))})),y(document).bind("vmouseup.mouseLayer",(function(r){y(document).unbind(".mouseLayer"),i&&e.onClick&&e.onClick(t.getMouseCoord(r)),i=!1})))})),e.onMouseOver&&y(t.mouselayer.canvas).on("vmouseover",(function(r){e.onMouseOver(t.getMouseCoord(r))})),e.onMouseOut&&y(t.mouselayer.canvas).on("vmouseout",(function(r){e.onMouseOut(t.getMouseCoord(r))}))}e.allowScratchpad||e.setDrawingAreaAvailable(!1),t._mouselayerWrapper=document.createElement("div"),y(t._mouselayerWrapper).css({position:"absolute",left:0,top:0,zIndex:2}),t._visiblelayerWrapper=document.createElement("div"),y(t._visiblelayerWrapper).css({position:"absolute",left:0,top:0});var n=t.raphael.canvas.parentNode;n.appendChild(t._visiblelayerWrapper),n.appendChild(t._mouselayerWrapper),t.addToMouseLayerWrapper=function(e){this._mouselayerWrapper.appendChild(e)},t.addToVisibleLayerWrapper=function(e){this._visiblelayerWrapper.appendChild(e)}},getMousePx:function(e){return[e.pageX-y(this.raphael.canvas.parentNode).offset().left,e.pageY-y(this.raphael.canvas.parentNode).offset().top]},getMouseCoord:function(e){return this.unscalePoint(this.getMousePx(e))},labelAngle:function(e){var t=this;h.defaults(e,{point1:[0,0],vertex:[0,0],point3:[0,0],label:null,numArcs:1,showRightAngleMarker:!0,pushOut:0,clockwise:!1,style:{}});var r,i,n=void 0===e.text?"":e.text,o=e.vertex,s=t.scalePoint(o);e.clockwise?(r=e.point1,i=e.point3):(r=e.point3,i=e.point1);var a=Cr.findAngle(r,o),l=Cr.findAngle(i,o),p=(l+360-a)%360,c=(a+p/2)%360,d=5*e.pushOut+Br(p),u=[];if(Math.abs(p-90)<1e-9&&e.showRightAngleMarker){var m=Dr(s,Hr(d,a)),g=Dr(s,Hr(d,l)),f=Dr(s,Hr(d*=Math.SQRT2,c));h.each([m,g],(function(r){u.push(t.scaledPath([r,f],e.style))}))}else h.times(e.numArcs,(function(r){u.push(t.arc(o,t.unscaleVector(d),a,l,e.style)),d+=3}));if(n){var v=n.match(/\$deg(\d)?/);if(v){var y=v[1]||1;n=n.replace(v[0],de.toFixedApprox(p,y)+"^{\\circ}")}var b=Dr(s,Hr(d+15,c)),x=t.unscalePoint(b);e.label?(e.label.setPosition(x),e.label.processMath(n,!0)):t.label(x,n,"center",e.style)}return u},labelSide:function(e){var t,r,i=this;h.defaults(e,{point1:[0,0],point2:[0,0],label:null,text:"",numTicks:0,numArrows:0,clockwise:!1,style:{}}),e.clockwise?(t=e.point1,r=e.point2):(t=e.point2,r=e.point1);var n=[(t[0]+r[0])/2,(t[1]+r[1])/2],o=i.scalePoint(n),s=Math.atan2(r[1]-t[1],r[0]-t[0]),a=s+Math.PI/2,l=[],p=0;if(e.numTicks){var c=e.numTicks,d=h.extend({},e.style,{strokeWidth:2});h.times(c,(function(e){var t=zr(5*(e-(c-1)/2),s),r=zr(5,a),n=[Dr(o,t,r),Dr(o,t,Lr(r))];l.push(i.scaledPath(n,d))})),p+=5*(c-1)+15}if(e.numArrows){var u=e.numArrows,m=[t,r].sort((function(e,t){return e[1]===t[1]?e[0]-t[0]:e[1]-t[1]}))[0],g=i.scalePoint(m),f=h.extend({},e.style,{arrows:"->",strokeWidth:2});h.times(u,(function(e){var r=zr(p+5*e,s);m!==t&&(r=Lr(r));var n=Dr(o,r);l.push(i.scaledPath([g,n],f))}))}var v=e.text;if(v){var y=v.match(/\$len(\d)?/);if(y){var b=Cr.getDistance(t,r),x=y[1]||1;v=v.replace(y[0],de.toFixedApprox(b,x))}var w=zr(20,a),C=Dr(o,w),k=i.unscalePoint(C);e.label?(e.label.setPosition(k),e.label.processMath(v,!0)):i.label(k,v,"center",e.style)}return l},labelVertex:function(e){var t=this;if(h.defaults(e,{point1:null,vertex:[0,0],point3:null,label:null,text:"",clockwise:!1,style:{}}),e.text){var r,i,n=e.vertex,o=t.scalePoint(n);e.clockwise?(r=e.point1,i=e.point3):(r=e.point3,i=e.point1);var s,a=135;if(r&&i){var l=Cr.findAngle(r,n);s=(l+(a=(Cr.findAngle(i,n)+360-l)%360)/2+180)%360}else if(r){s=Cr.findAngle(n,r)+90}else if(i){s=Cr.findAngle(i,n)+90}else s=135;var p=Dr(o,Hr(10+Br(360-a),s)),c=t.unscalePoint(p);e.label?(e.label.setPosition(c),e.label.processMath(e.text,!0)):t.label(c,e.text,"center",e.style)}},addMovablePoint:function(e){var t=y.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:mr.INTERACTING,stroke:mr.INTERACTING},labelStyle:{color:mr.INTERACTIVE},vertexLabel:"",mouseTarget:null},e),r=t.constraints.fixed?mr.DYNAMIC:mr.INTERACTIVE;t.normalStyle=h.extend({},{fill:r,stroke:r},e.normalStyle),void 0!==e.coordX&&(t.coord[0]=e.coordX),void 0!==e.coordY&&(t.coord[1]=e.coordY);var i=t.graph,n=function(e){t.visible&&t.bounded&&!t.constraints.fixed&&(e=i.constrainToBounds(e,10));var r=e[0],n=e[1];if(0!==t.snapX&&(r=Math.round(r/t.snapX)*t.snapX),0!==t.snapY&&(n=Math.round(n/t.snapY)*t.snapY),t.constraints.fixedDistance.snapPoints){var o=i.scalePoint(e),s=o[0],a=o[1],l=2*Math.PI/t.constraints.fixedDistance.snapPoints,p=t.constraints.fixedDistance.dist,h=t.constraints.fixedDistance.point,c=(h[0]-i.range[0][0])*i.scale[0],d=(-h[1]+i.range[1][1])*i.scale[1],u=s-c,m=-a+d,g=Math.atan(m/u);u<0&&(g+=Math.PI),g=Math.round(g/l)*l,s=(u=p*Math.cos(g))+c,a=-(m=p*Math.sin(g))+d,r=de.roundTo(5,s/i.scale[0]+i.range[0][0]),n=de.roundTo(5,i.range[1][1]-a/i.scale[1])}return t.applyConstraint([r,n])};t.applyConstraint=function(e,r,i){var n=e.slice(),o={};if(i?y.extend(o,{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},r):y.extend(o,this.constraints,r),o.constrainX)n=[this.coord[0],e[1]];else if(o.constrainY)n=[e[0],this.coord[1]];else if("number"==typeof o.fixedAngle.angle&&"number"==typeof o.fixedDistance.dist){var s=o.fixedAngle.vertex.coord||o.fixedAngle.vertex,a=o.fixedAngle.ref.coord||o.fixedAngle.ref,l=o.fixedDistance.point.coord||o.fixedDistance.point,p=(o.fixedAngle.angle+Cr.findAngle(a,s))*Math.PI/180,h=o.fixedDistance.dist;n[0]=h*Math.cos(p)+l[0],n[1]=h*Math.sin(p)+l[1]}else if("number"==typeof o.fixedAngle.angle){var c=o.fixedAngle.vertex.coord||o.fixedAngle.vertex,d=o.fixedAngle.ref.coord||o.fixedAngle.ref,u=(o.fixedAngle.angle+Cr.findAngle(d,c))*Math.PI/180,m=Cr.findAngle(e,c)*Math.PI/180,g=Cr.getDistance(e,c)*Math.cos(u-m);g=g<1?1:g,n[0]=g*Math.cos(u)+c[0],n[1]=g*Math.sin(u)+c[1]}else if("number"==typeof o.fixedDistance.dist){var f=o.fixedDistance.point.coord||o.fixedDistance.point,v=Cr.findAngle(e,f),b=o.fixedDistance.dist;v=v*Math.PI/180,n[0]=b*Math.cos(v)+f[0],n[1]=b*Math.sin(v)+f[1]}else o.fixed&&(n=t.coord);return n},t.coord=n(t.coord);if(t.visible&&i.style(t.normalStyle,(function(){var e=[t.pointSize/i.scale[0],t.pointSize/i.scale[1]],r={maxScale:2,padding:2};t.visibleShape=new Ir(i,t.coord,e,r),t.visibleShape.attr(h.omit(t.normalStyle,"scale")),t.visibleShape.toFront()})),t.normalStyle.scale=1,t.highlightStyle.scale=2,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(e){e=e||[0,0],y(document).bind("vmousemove.point vmouseup.point",(function(r){r.preventDefault(),t.dragging=!0,Wr=!0;var o,s,a=w.add(i.getMouseCoord(r),e),l=(a=n(a))[0],p=a[1];if("vmousemove"===r.type){var c=!0;if(h.isFunction(t.onMove)){var d=t.onMove(l,p);!1===d&&(c=!1),h.isArray(d)&&(l=d[0],p=d[1])}if(o=(l-i.range[0][0])*i.scale[0],s=(-p+i.range[1][1])*i.scale[1],c){var u=i.unscalePoint([o,s]);t.visibleShape.moveTo(u),t.mouseTarget.moveTo(u),t.coord=[l,p],t.updateLineEnds(),y(t).trigger("move")}t.drawLabel()}else if("vmouseup"===r.type){if(y(document).unbind(".point"),t.dragging=!1,Wr=!1,h.isFunction(t.onMoveEnd)){var m=t.onMoveEnd(l,p);if(h.isArray(m)){l=m[0],p=m[1],o=(l-i.range[0][0])*i.scale[0],s=(-p+i.range[1][1])*i.scale[1];var g=i.unscalePoint([o,s]);t.visibleShape.moveTo(g),t.mouseTarget.moveTo(g),t.coord=[l,p]}}t.highlight||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight())}}))},t.visible&&!t.constraints.fixed){if(!t.mouseTarget){var o=i.unscaleVector(16);t.mouseTarget=new Ir(i,t.coord,o,{mouselayer:!0,padding:0,disableMouseEventsOnWrapper:!0,interactiveKindForTesting:"movable-point"}),t.mouseTarget.attr({fill:"#000",opacity:0})}var s=y(t.mouseTarget.getMouseTarget());s.css("cursor","move"),s.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)t.highlight=!0,Wr||(t.visibleShape.animate(t.highlightStyle,50),t.onHighlight&&t.onHighlight());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||Wr||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();var r=t.coord,n=i.getMouseCoord(e),o=!("ontouchstart"in window)?[0,0]:w.subtract(r,n);t.grab(o)}}))}return t.moveTo=function(e,r,i){var n=5*Cr.getDistance(this.graph.scalePoint([e,r]),this.graph.scalePoint(this.coord)),o=i&&function(e){t.coord=e,t.updateLineEnds()};this.visibleShape.animateTo([e,r],n,o),this.mouseTarget.animateTo([e,r],n,o),this.coord=[e,r],h.isFunction(this.onMove)&&this.onMove(e,r)},t.updateLineEnds=function(){y(this.lineStarts).each((function(){this.coordA=t.coord,this.transform()})),y(this.lineEnds).each((function(){this.coordZ=t.coord,this.transform()})),y(this.polygonVertices).each((function(){this.transform()}))},t.setCoord=function(e){this.visible&&(this.visibleShape.moveTo(e),null!=this.mouseTarget&&this.mouseTarget.moveTo(e)),this.coord=e.slice()},t.setCoordConstrained=function(e){this.setCoord(n(e))},t.toBack=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toBack(),this.visibleShape.toBack())},t.toFront=function(){this.visible&&(null!=this.mouseTarget&&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},addMovableLineSegment:function(e){var t=y.extend({graph:this,coordA:[0,0],coordZ:[1,1],snapX:0,snapY:0,fixed:!1,ticks:0,normalStyle:{},highlightStyle:{stroke:mr.INTERACTING,"stroke-width":6},labelStyle:{stroke:mr.INTERACTIVE,color:mr.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=t.fixed?mr.DYNAMIC:mr.INTERACTIVE;t.normalStyle=h.extend({},{"stroke-width":2,stroke:r},e.normalStyle),t.arrowStyle=h.extend({},t.normalStyle,{color:t.normalStyle.stroke}),void 0!==e.pointA?(t.coordA=e.pointA.coord,t.pointA.lineStarts.push(t)):void 0!==e.coordA&&(t.coordA=e.coordA.slice()),void 0!==e.pointZ?(t.coordZ=e.pointZ.coord,t.pointZ.lineEnds.push(t)):void 0!==e.coordA&&(t.coordA=t.coordA.slice());var i=t.graph;i.style(t.normalStyle);for(var n=0;n<t.ticks;++n)t.tick[n]=qr;Cr.unscaledSvgPath([[0,0],[1,0]]);for(var o=0;o<t.ticks;++o){var s=.5-(t.ticks-1+2*o)/i.scale[0];Cr.unscaledSvgPath([[s,-7],[s,7]])}if(e={thickness:Math.max(t.normalStyle["stroke-width"],t.highlightStyle["stroke-width"])},t.visibleLine=new Nr(i,[0,0],[1,0],e),t.visibleLine.attr(t.normalStyle),!t.fixed){t.mouseTarget=new Nr(i,[0,0],[1,0],{thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"}),t.mouseTarget.attr({fill:"#000",opacity:0})}if(t.transform=function(e){e&&("object"==typeof this.pointA&&(this.coordA=this.pointA.coord),"object"==typeof this.pointZ&&(this.coordZ=this.pointZ.coord));var r=function(e,r,i){var n=(e=t.graph).range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),o=e.unscaleVector(w.cartFromPolarDeg(1,i)),s=w.scale(w.normalize(o),n),a=w.add(r,s),l=w.polarDegFromCart(o)[1];return e.constrainToBoundsOnAngle(a,4,l*Math.PI/180)},n=function(e){var t=e.graph.scalePoint(e.coordA),r=e.graph.scalePoint(e.coordZ);return w.polarDegFromCart(w.subtract(r,t))[1]}(this),o=this.coordA,s=this.coordZ;this.extendLine?(o=r(i,o,360-n),s=r(i,s,(540-n)%360)):this.extendRay&&(s=r(i,o,360-n));var a=[this.visibleLine];this.fixed||a.push(this.mouseTarget),h.each(a,(function(e){e.moveTo(o,s)}));var l=function(e,t){var i=[.75,0],n=[[-3,4],[-2.75,2.5],[0,.25],i,[0,-.25],[-2.75,-2.5],[-3,-4]];n=h.map(n,(function(e){var t=w.subtract(e,i),r=w.scale(t,1.4);return w.add(i,r)}));var o=h.map(n,e.unscalePoint),s={center:e.unscalePoint(i),createPath:function(e){for(var t="M"+e[0][0]+" "+e[0][1],r=1;r<e.length;r+=3)t+="C"+e[r][0]+" "+e[r][1]+" "+e[r+1][0]+" "+e[r+1][1]+" "+e[r+2][0]+" "+e[r+2][1];return t}},a=new Rr(e,o,s);return a.attr(h.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),a.toCoordAtAngle=function(t,n){var o=e.scalePoint(r(e,t,n)),s=Fr();a.transform("translateX("+(o[0]+1.4*i[0])+"px) translateY("+(o[1]+1.4*i[1])+"px) "+(s?"translateZ(0) ":"")+"rotate("+(360-de.bound(n))+"deg)")},a};null==this._arrows&&(this._arrows=[],this.extendLine?(this._arrows.push(l(i,this.normalStyle)),this._arrows.push(l(i,this.normalStyle))):this.extendRay&&this._arrows.push(l(i,this.normalStyle)));var p=[this.coordA,this.coordZ],c=[360-n,(540-n)%360];h.each(this._arrows,(function(e,t){e.toCoordAtAngle(p[t],c[t])})),h.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=h.flatten(this.temp)},t.toBack=function(){t.fixed||t.mouseTarget.toBack(),t.visibleLine.toBack()},t.toFront=function(){t.fixed||t.mouseTarget.toFront(),t.visibleLine.toFront()},t.remove=function(){t.fixed||t.mouseTarget.remove(),t.visibleLine.remove(),t.labeledSide&&t.labeledSide.remove(),t.labeledVertices&&h.invoke(t.labeledVertices,"remove"),t._arrows&&h.invoke(t._arrows,"remove"),t.temp.length&&h.invoke(t.temp,"remove")},t.hide=function(){t.visibleLine.hide(),t.temp.length&&h.invoke(t.temp,"hide"),t._arrows&&h.invoke(t._arrows,"hide")},t.show=function(){t.visibleLine.show(),t.temp.length&&h.invoke(t.temp,"show"),t._arrows&&h.invoke(t._arrows,"show")},t.sideLabel&&(t.labeledSide=this.label([0,0],"","center",t.labelStyle)),t.vertexLabels.length&&(t.labeledVertices=h.map(t.vertexLabels,(function(e){return this.label([0,0],"","center",t.labelStyle)}),this)),!t.fixed&&!t.constraints.fixed){var a=y(t.mouseTarget.getMouseTarget());a.css("cursor","move"),a.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Wr||(t.highlight=!0,t.visibleLine.animate(t.highlightStyle,50),t.arrowStyle=h.extend({},t.arrowStyle,{color:t.highlightStyle.stroke,stroke:t.highlightStyle.stroke}),t.transform());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=h.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();var r=(e.pageX-y(i.raphael.canvas.parentNode).offset().left)/i.scale[0]+i.range[0][0],n=i.range[1][1]-(e.pageY-y(i.raphael.canvas.parentNode).offset().top)/i.scale[1];t.snapX>0&&(r=Math.round(r/t.snapX)*t.snapX),t.snapY>0&&(n=Math.round(n/t.snapY)*t.snapY);var o=[t.coordA[0]-r,t.coordA[1]-n],s=[t.coordZ[0]-r,t.coordZ[1]-n],a=-Math.min(i.scaleVector(o)[0],i.scaleVector(s)[0]),l=Math.max(i.scaleVector(o)[0],i.scaleVector(s)[0]),p=Math.max(i.scaleVector(o)[1],i.scaleVector(s)[1]),c=-Math.min(i.scaleVector(o)[1],i.scaleVector(s)[1]);y(document).bind("vmousemove.lineSegment vmouseup.lineSegment",(function(e){e.preventDefault(),t.dragging=!0,Wr=!0;var r=e.pageX-y(i.raphael.canvas.parentNode).offset().left,n=e.pageY-y(i.raphael.canvas.parentNode).offset().top;r=Math.max(a+10,Math.min(i.xpixels-10-l,r)),n=Math.max(p+10,Math.min(i.ypixels-10-c,n));var d=r/i.scale[0]+i.range[0][0],u=i.range[1][1]-n/i.scale[1];if(t.snapX>0&&(d=Math.round(d/t.snapX)*t.snapX),t.snapY>0&&(u=Math.round(u/t.snapY)*t.snapY),"vmousemove"===e.type){t.constraints.constrainX&&(d=t.coordA[0]-o[0]),t.constraints.constrainY&&(u=t.coordA[1]-o[1]);var m=d+o[0]-t.coordA[0],g=u+o[1]-t.coordA[1];t.coordA=[d+o[0],u+o[1]],t.coordZ=[d+s[0],u+s[1]],t.transform(),t.movePointsWithLine&&("object"==typeof t.pointA&&t.pointA.setCoord([t.pointA.coord[0]+m,t.pointA.coord[1]+g]),"object"==typeof t.pointZ&&t.pointZ.setCoord([t.pointZ.coord[0]+m,t.pointZ.coord[1]+g])),h.isFunction(t.onMove)&&t.onMove(m,g)}else"vmouseup"===e.type&&(y(document).unbind(".lineSegment"),t.dragging=!1,Wr=!1,t.highlight||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=h.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform()),h.isFunction(t.onMoveEnd)&&t.onMoveEnd());y(t).trigger("move")}))}}))}return void 0!==t.pointA&&t.pointA.toFront(),void 0!==t.pointZ&&t.pointZ.toFront(),t.transform(),t},addMovablePolygon:function(e){var t=this,r=y.extend({snapX:0,snapY:0,fixed:!1,constrainToGraph:!0,normalStyle:{},highlightStyle:{stroke:mr.INTERACTING,"stroke-width":2,fill:mr.INTERACTING,"fill-opacity":.05},pointHighlightStyle:{fill:mr.INTERACTING,stroke:mr.INTERACTING},labelStyle:{stroke:mr.DYNAMIC,"stroke-width":1,color:mr.DYNAMIC},angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],updateOnPointMove:!0,closed:!0},h.omit(e,"points")),i=r.fixed?mr.DYNAMIC:mr.INTERACTIVE;r.normalStyle=h.extend({"stroke-width":2,"fill-opacity":0,fill:i,stroke:i},e.normalStyle),r.points=e.points;var n=function(e){return!h.isArray(e)};if(r.update=function(){var e=r.points.length;r.coords=h.map(r.points,(function(e,t){return n(e)?e.coord:e})),r.left=h.min(h.pluck(r.coords,0)),r.right=h.max(h.pluck(r.coords,0)),r.top=h.max(h.pluck(r.coords,1)),r.bottom=h.min(h.pluck(r.coords,1));var i=h.map(r.coords,(function(e){return t.scalePoint(e)}));r.closed?i.push(!0):i=i.concat(h.clone(i).reverse()),r.path=Cr.unscaledSvgPath(i),h.invoke(r.temp,"remove"),r.temp=[];var o,s,a=(o=r.coords,s=h.zip(o,o.slice(1).concat(o.slice(0,1))),Or(h.map(s,(function(e){var t=e[0],r=e[1];return(r[0]-t[0])*(r[1]+t[1])})))>0);(r.angleLabels.length||r.showRightAngleMarkers.length)&&h.each(r.labeledAngles,(function(i,n){r.temp.push(t.labelAngle({point1:r.coords[(n-1+e)%e],vertex:r.coords[n],point3:r.coords[(n+1)%e],label:i,text:r.angleLabels[n],showRightAngleMarker:r.showRightAngleMarkers[n],numArcs:r.numArcs[n],clockwise:a,style:r.labelStyle}))})),r.sideLabels.length&&h.each(r.labeledSides,(function(i,n){r.temp.push(t.labelSide({point1:r.coords[n],point2:r.coords[(n+1)%e],label:i,text:r.sideLabels[n],numArrows:r.numArrows[n],numTicks:r.numTicks[n],clockwise:a,style:r.labelStyle}))})),r.vertexLabels.length&&h.each(r.labeledVertices,(function(i,n){t.labelVertex({point1:r.coords[(n-1+e)%e],vertex:r.coords[n],point3:r.coords[(n+1)%e],label:i,text:r.vertexLabels[n],clockwise:a,style:r.labelStyle})})),r.temp=h.flatten(r.temp)},r.transform=function(){r.update(),r.visibleShape.attr({path:r.path}),r.fixed||r.mouseTarget.attr({path:r.path})},r.remove=function(){r.visibleShape.remove(),r.fixed||r.mouseTarget.remove(),r.labeledAngles&&h.invoke(r.labeledAngles,"remove"),r.labeledSides&&h.invoke(r.labeledSides,"remove"),r.labeledVertices&&h.invoke(r.labeledVertices,"remove"),r.temp.length&&h.invoke(r.temp,"remove")},r.toBack=function(){r.fixed||r.mouseTarget.toBack(),r.visibleShape.toBack()},r.toFront=function(){r.fixed||r.mouseTarget.toFront(),r.visibleShape.toFront()},r.updateOnPointMove&&h.each(h.filter(r.points,n),(function(e){e.polygonVertices.push(r)})),r.coords=new Array(r.points.length),r.angleLabels.length){var o=Math.max(r.angleLabels.length,r.showRightAngleMarkers.length);r.labeledAngles=h.times(o,(function(){return this.label([0,0],"","center",r.labelStyle)}),this)}return r.sideLabels.length&&(r.labeledSides=h.map(r.sideLabels,(function(e){return this.label([0,0],"","center",r.labelStyle)}),this)),r.vertexLabels.length&&(r.labeledVertices=h.map(r.vertexLabels,(function(e){return this.label([0,0],"","center",r.labelStyle)}),this)),r.update(),r.visibleShape=t.raphael.path(r.path),r.visibleShape.attr(r.normalStyle),r.fixed||(r.mouseTarget=t.mouselayer.path(r.path),r.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"}),y(r.mouseTarget[0]).bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Wr&&!r.dragging||(r.highlight=!0,r.visibleShape.animate(r.highlightStyle,50),h.each(h.filter(r.points,n),(function(e){e.visibleShape.animate(r.pointHighlightStyle,50)})));else if("vmouseout"===e.type){if(r.highlight=!1,!r.dragging){r.visibleShape.animate(r.normalStyle,50);var i=h.filter(r.points,n);h.any(h.pluck(i,"dragging"))||h.each(i,(function(e){e.visibleShape.animate(e.normalStyle,50)}))}}else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),h.each(h.filter(r.points,n),(function(e){e.dragging=!0}));var o=(e.pageX-y(t.raphael.canvas.parentNode).offset().left)/t.scale[0]+t.range[0][0],s=t.range[1][1]-(e.pageY-y(t.raphael.canvas.parentNode).offset().top)/t.scale[1];r.snapX>0&&(o=Math.round(o/r.snapX)*r.snapX),r.snapY>0&&(s=Math.round(s/r.snapY)*r.snapY);var a=o,l=s,p=r.coords.slice(),c=(o-r.left)*t.scale[0],d=(r.right-o)*t.scale[0],u=(r.top-s)*t.scale[1],m=(s-r.bottom)*t.scale[1];y(document).bind("vmousemove.polygon vmouseup.polygon",(function(e){e.preventDefault(),r.dragging=!0,Wr=!0;var i=e.pageX-y(t.raphael.canvas.parentNode).offset().left,g=e.pageY-y(t.raphael.canvas.parentNode).offset().top;r.constrainToGraph&&(i=Math.max(c+10,Math.min(t.xpixels-10-d,i)),g=Math.max(u+10,Math.min(t.ypixels-10-m,g)));var f=i/t.scale[0]+t.range[0][0],v=t.range[1][1]-g/t.scale[1];if(r.snapX>0&&(f=Math.round(f/r.snapX)*r.snapX),r.snapY>0&&(v=Math.round(v/r.snapY)*r.snapY),"vmousemove"===e.type){var b=f-o,x=v-s,w=!0;if(h.isFunction(r.onMove)){var C=r.onMove(b,x);!1===C?w=!1:h.isArray(C)&&(b=C[0],x=C[1],f=o+b,v=s+x)}var k=function(e){return[p[e][0]+b,p[e][1]+x]};w&&(h.each(r.points,(function(e,t){n(e)?e.setCoord(k(t)):r.points[t]=k(t)})),r.transform(),y(r).trigger("move"),a=f,l=v)}else if("vmouseup"===e.type){y(document).unbind(".polygon");var E=h.filter(r.points,n);h.each(E,(function(e){e.dragging=!1})),r.dragging=!1,Wr=!1,r.highlight||(r.visibleShape.animate(r.normalStyle,50),h.each(E,(function(e){e.visibleShape.animate(e.normalStyle,50)}))),h.isFunction(r.onMoveEnd)&&r.onMoveEnd(a-o,l-s)}}))}}))),h.invoke(h.filter(r.points,n),"toFront"),r},constrainToBounds:function(e,t){var r=this.unscalePoint([t,this.ypixels-t]),i=this.unscalePoint([this.xpixels-t,t]);return[Math.max(r[0],Math.min(i[0],e[0])),Math.max(r[1],Math.min(i[1],e[1]))]},constrainToBoundsOnAngle:function(e,t,r){var i=this.unscalePoint([t,this.ypixels-t]),n=this.unscalePoint([this.xpixels-t,t]),o=e.slice();return o[0]<i[0]?o=[i[0],o[1]+(i[0]-o[0])*Math.tan(r)]:o[0]>n[0]&&(o=[n[0],o[1]-(o[0]-n[0])*Math.tan(r)]),o[1]<i[1]?o=[o[0]+(i[1]-o[1])/Math.tan(r),i[1]]:o[1]>n[1]&&(o=[o[0]-(o[1]-n[1])/Math.tan(r),n[1]]),o},addMovableAngle:function(e){return new Vr(this,e)},addCircleGraph:function(e){var t=this,r=y.extend({center:[0,0],radius:2,snapX:.5,snapY:.5,snapRadius:.5,minRadius:1,centerConstraints:{},centerNormalStyle:{},centerHighlightStyle:{stroke:mr.INTERACTING,fill:mr.INTERACTING},circleNormalStyle:{stroke:mr.INTERACTIVE,"fill-opacity":0},circleHighlightStyle:{stroke:mr.INTERACTING,fill:mr.INTERACTING,"fill-opacity":.05}},e),i=r.centerConstraints.fixed?mr.DYNAMIC:mr.INTERACTIVE,n=e?e.centerNormalStyle:null;r.centerNormalStyle=h.extend({},{fill:i,stroke:i},n),r.centerPoint=t.addMovablePoint({graph:t,coord:r.center,normalStyle:r.centerNormalStyle,snapX:r.snapX,snapY:r.snapY,constraints:r.centerConstraints}),r.circ=t.circle(r.center,r.radius,r.circleNormalStyle),r.perim=t.mouselayer.circle(t.scalePoint(r.center)[0],t.scalePoint(r.center)[1],t.scaleVector(r.radius)[0]).attr({"stroke-width":20,opacity:.002}),r.centerConstraints.fixed||y(r.centerPoint.mouseTarget.getMouseTarget()).on("vmouseover vmouseout",(function(e){r.centerPoint.highlight||r.centerPoint.dragging?r.circ.animate(r.circleHighlightStyle,50):r.circ.animate(r.circleNormalStyle,50)})),r.toFront=function(){r.circ.toFront(),r.perim.toFront(),r.centerPoint.visibleShape.toFront(),r.centerConstraints.fixed||r.centerPoint.mouseTarget.toFront()},r.centerPoint.onMove=function(e,i){r.toFront(),r.circ.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(i)[1]}),r.perim.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(i)[1]}),r.onMove&&r.onMove(e,i)},y(r.centerPoint).on("move",(function(){r.center=this.coord,y(r).trigger("move")})),r.setCenter=function(e,t){r.centerPoint.setCoord([e,t]),r.centerPoint.onMove(e,t),r.center=[e,t]},r.setRadius=function(e){r.radius=e,r.perim.attr({r:t.scaleVector(e)[0]}),r.circ.attr({rx:t.scaleVector(e)[0],ry:t.scaleVector(e)[1]})},r.remove=function(){r.centerPoint.remove(),r.circ.remove(),r.perim.remove()};var o=[[-1*Math.PI,-.875*Math.PI,"ew-resize"],[-.875*Math.PI,-.625*Math.PI,"nesw-resize"],[-.625*Math.PI,-.375*Math.PI,"ns-resize"],[-.375*Math.PI,-.125*Math.PI,"nwse-resize"],[-.125*Math.PI,.125*Math.PI,"ew-resize"],[.125*Math.PI,.375*Math.PI,"nesw-resize"],[.375*Math.PI,.625*Math.PI,"ns-resize"],[.625*Math.PI,.875*Math.PI,"nwse-resize"],[.875*Math.PI,1*Math.PI,"ew-resize"]];return y(r.perim.node).on("vmousemove",(e=>{var[t,i]=this.getMouseCoord(e);t-=r.center[0],i-=r.center[1];var n=Math.atan2(i,t);o.forEach((function(e){var[t,i,o]=e;n>=t&&n<i&&y(r.perim.node).css("cursor",o)}))})),y(r.perim.node).css("cursor","nesw-resize"),r.perim.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),y(r.perim.node).on("vmouseover vmouseout vmousedown",(function(e){if("vmouseover"===e.type)r.highlight=!0,Wr||(r.circ.animate(r.circleHighlightStyle,50),r.centerPoint.visibleShape.animate(r.centerHighlightStyle,50));else if("vmouseout"===e.type)r.highlight=!1,r.dragging||r.centerPoint.dragging||(r.circ.animate(r.circleNormalStyle,50),r.centerPoint.visibleShape.animate(r.centerNormalStyle,50));else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),r.toFront();var i=r.radius;y(document).on("vmousemove vmouseup",(function(e){if(e.preventDefault(),r.dragging=!0,Wr=!0,"vmousemove"===e.type){var n=t.constrainToBounds(t.getMouseCoord(e),10),o=Cr.getDistance(r.centerPoint.coord,n);o=Math.max(r.minRadius,Math.round(o/r.snapRadius)*r.snapRadius);var s=r.radius,a=!0;if(r.onResize){var l=r.onResize(o,s);h.isNumber(l)?o=l:!1===l&&(a=!1)}a&&(r.setRadius(o),y(r).trigger("move"))}else"vmouseup"===e.type&&(y(document).off("vmousemove vmouseup"),r.dragging=!1,Wr=!1,r.onResizeEnd&&r.onResizeEnd(r.radius,i))}))}})),r},addRotateHandle:function(e){var t=this,r=e.center,i=e.radius,n=e.lengthAngle||30,o=e.hideArrow||!1,s=e.mouseTarget,a=h.uniqueId("rotateHandle");h.isArray(r)&&(r={coord:r});var l=t.addMovablePoint({coord:x.addVector(r.coord,w.cartFromPolarDeg(i,e.angleDeg||0)),constraints:{fixedDistance:{dist:i,point:r}},mouseTarget:s});r.toFront();var p,c=r.coord,d=l.coord,u=d,m=!1,g=!1,f=function(i){if(!o){var s=w.subtract(i,r.coord),a=w.polarDegFromCart(s)[1];p&&p.remove(),p=function(e,t,r,i,n,o,s){var a=function(i,n){var s=r+n,a=w.cartFromPolarDeg(s,o+i),l=w.add(t,a),p=e.scalePoint(l);return p[0]+","+p[1]},l=e.scaleVector(r-i),p=e.scaleVector(r+i);return e.raphael.path(" M"+a(n,-i)+" L"+a(n,-3*i)+" L"+a(2*n,0)+" L"+a(n,3*i)+" L"+a(n,i)+" A"+p[0]+","+p[1]+",0,0,1,"+a(-n,i)+" L"+a(-n,3*i)+" L"+a(-2*n,0)+" L"+a(-n,-3*i)+" L"+a(-n,-i)+" A"+l[0]+","+l[1]+",0,0,0,"+a(n,-i)+" Z").attr({stroke:null,fill:s?mr.INTERACTING:mr.INTERACTIVE})}(t,r.coord,e.radius,m||g?e.hoverWidth/2:e.width/2,n,a,m||g)}};y(r).on("move."+a,(function(){var e=w.subtract(r.coord,c);l.setCoord(w.add(l.coord,e)),f(l.coord),c=r.coord,l.constraints.fixedDistance.point=r,d=l.coord})),l.onMove=function(t,i){m||(u=d,m=!0);var n=[t,i];if(e.onMove){var o=w.polarDegFromCart(w.subtract(d,r.coord)),s=w.polarDegFromCart(w.subtract(n,r.coord)),a=o[1],l=s[1],p=e.onMove(l,a);null!=p&&!0!==p&&(!1===p&&(p=a),n=w.add(r.coord,w.cartFromPolarDeg(o[0],p)))}return f(n),d=n,n},l.onMoveEnd=function(){if(m=!1,f(l.coord),e.onMoveEnd){var t=w.polarDegFromCart(w.subtract(u,r.coord)),i=w.polarDegFromCart(w.subtract(l.coord,r.coord));e.onMoveEnd(i[1],t[1])}},l.visibleShape.remove(),s||l.mouseTarget.attr({scale:2});var v=y(l.mouseTarget.getMouseTarget());v.bind("vmouseover",(function(e){g=!0,f(l.coord)})),v.bind("vmouseout",(function(e){g=!1,f(l.coord)})),f(l.coord);var b=l.remove;return l.remove=function(){b.call(l),p&&p.remove(),y(r).off("move."+a)},l.update=function(){f(l.coord)},l},addReflectButton:function(e){var t,r=this,i=e.line,n=r.addMovablePoint({constraints:e.constraints,coord:C.midpoint([i.pointA.coord,i.pointZ.coord]),snapX:r.snap[0],snapY:r.snap[1],onMove:function(e,t){return!1},onMoveEnd:function(t,r){e.onMoveEnd&&e.onMoveEnd.call(this,t,r)}}),o=!1,s=!1,a=function(){return o},l=h.map([0,1],(function(t){var r=t?e.highlightStyle:e.normalStyle;return h.map([0,1],(function(e){return h.defaults({"fill-opacity":e},r)}))})),p=function(e){return s&&(e=!e),l[+a()][+e]},c=function(i,n){t&&t.remove(),t=function(e,t,r,i,n,o,s){x.equal(r[0],r[1])&&(r=[r[0],x.addVector(r[0],[1,1])]);var a=w.normalize(w.subtract(r[1],r[0])),l=w.scale(a,i/2),p=w.scale(a,n),h=w.rotateDeg(p,90),c=w.rotateDeg(p,-90),d=w.negate(l),u=w.rotateDeg(l,90),m=w.rotateDeg(l,-90),g=x.addVectors(t,h),f=x.addVectors(t,c),v=x.addVectors(t,h,l,u),y=x.addVectors(t,h,d,u),b=x.addVectors(t,c,l,m),C=x.addVectors(t,c,d,m),k=e.path([g,v,y,!0],o),E=e.path([f,b,C,!0],s);return{remove:function(){k.remove(),E.remove()}}}(r,i,n,a()?1.5*e.size:e.size,a()?.125*e.size:.25,p(0),p(1))},d=function(e,t){e=e||i.pointA.coord,t=t||i.pointZ.coord;var r=C.midpoint([e,t]);n.setCoord(r),c(r,[e,t])};y(i).on("move",h.bind(d,n,null,null));var u=y(n.mouseTarget.getMouseTarget());u.on("vclick",(function(){!1!==e.onClick()&&(s=!s,c(n.coord,[i.pointA.coord,i.pointZ.coord]))})),i.pointA.toFront(),i.pointZ.toFront(),n.visibleShape.remove();var m=r.scaleVector(e.size)[0]/20;n.mouseTarget.attr({scale:1.5*m}),u.css("cursor","pointer"),u.bind("vmouseover",(function(e){o=!0,c(n.coord,[i.pointA.coord,i.pointZ.coord])})),u.bind("vmouseout",(function(e){o=!1,c(n.coord,[i.pointA.coord,i.pointZ.coord])}));var g=n.remove;return n.remove=function(){t.remove(),g.call(n)},n.update=d,n.isFlipped=function(){return s},d(),n},protractor:function(e){return new Ur(this,e)},ruler:function(e){return new Gr(this,e||{})},addPoints:Dr}),h.extend(Vr.prototype,{points:[],snapDegrees:0,snapOffsetDeg:0,angleLabel:"",numArcs:1,pushOut:0,fixed:!1,addMoveHandlers:function(){var e=this.graphie;function t(t,r){return Cr.getDistance(e.scalePoint(t),e.scalePoint(r))<30}var r=this.points;r[1].onMove=function(i,n){var o=r[1].coord,s=[i,n],a=Dr(s,Lr(o)),l=!0,p={};return h.each([0,2],(function(i){var n=Dr(r[i].coord,a),o=Cr.findAngle(s,n);o*=Math.PI/180,n=e.constrainToBoundsOnAngle(n,10,o),p[i]=n,t(s,n)&&(l=!1)})),l&&h.each(p,(function(e,t){r[t].setCoord(e)})),l};var i=this.snapDegrees,n=this.snapOffsetDeg;h.each([0,2],(function(o){r[o].onMove=function(o,s){var a=[o,s],l=r[1].coord;if(t(l,a))return!1;if(i){var p=Cr.findAngle(a,l);p=Math.round((p-n)/i)*i+n;var h=Cr.getDistance(a,l);return Dr(l,e.polar(h,p))}return!0}})),y(r).on("move",function(){this.update(),y(this).trigger("move")}.bind(this))},addHighlightHandlers:function(){var e=this.points[1];e.onHighlight=function(){h.each(this.points,(function(e){e.visibleShape.animate(this.highlightStyle,50)}),this),h.each(this.rays,(function(e){e.visibleLine.animate(this.highlightStyle,50),e.arrowStyle=h.extend({},e.arrowStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke})}),this),this.angleStyle=h.extend({},this.angleStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke}),this.update()}.bind(this),e.onUnhighlight=function(){h.each(this.points,(function(e){e.visibleShape.animate(this.normalStyle,50)}),this),h.each(this.rays,(function(e){e.visibleLine.animate(e.normalStyle,50),e.arrowStyle=h.extend({},e.arrowStyle,{color:e.normalStyle.stroke,stroke:e.normalStyle.stroke})}),this),this.angleStyle=h.extend({},this.angleStyle,{color:mr.DYNAMIC,stroke:mr.DYNAMIC}),this.update()}.bind(this)},_getClockwiseAngle:function(e){return Cr.findAngle(e[2],e[0],e[1])+0},isReflex:function(){return this.reflex},isClockwise:function(){return this._getClockwiseAngle(this.coords)>180===this.reflex},getClockwiseCoords:function(){return this.isClockwise()?h.clone(this.coords):h.clone(this.coords).reverse()},update:function(e){var t=this.coords;this.coords=h.pluck(this.points,"coord"),h.invoke(this.points,"updateLineEnds");var r=this._getClockwiseAngle(t),i=this._getClockwiseAngle(this.coords),n=r>180,o=i>180;this.allowReflex&&(null==e&&(e=n!==o&&Math.abs(i-r)<180),e&&(this.reflex=!this.reflex)),h.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===o,style:this.angleStyle})},remove:function(){h.invoke(this.rays,"remove"),h.invoke(this.temp,"remove"),this.labeledAngle.remove()}});var jr=De.nestedMap,Yr=De.deepEq;function $r(e){h.extend(this,e)}var Xr=function(){throw new ce("Abstract method! Must be implemented by Graphie Movable"+this.constructor.displayName,pe.NotAllowed)};h.extend($r.prototype,{movableProps:[],add:Xr,modify:Xr,remove:Xr,toFront:function(){},componentDidMount:function(){}});var Kr=function(e){var t=function e(t){if(!(this instanceof e))throw new ce("Use createElement or JSX with graphie movables",pe.NotAllowed);return this.props=function(e,t){return h.extend({},e,{children:h.filter(h.flatten(t),h.identity)})}(t,t.children||[]),this};return e.displayName=e.displayName||h.uniqueId("GraphieClass"),t.displayName=e.displayName,(t.prototype=new $r(e)).constructor=t,t},Zr={GraphieMovable:$r,createClass:Kr,createSimpleClass:function(e){return Kr({displayName:e.name||h.uniqueId("GraphieSimpleClass"),movableProps:["children"],add:function(t){this._elements=e(t,this.props),this._prevProps=this.props},modify:function(e){if(!Yr(this.props,this._prevProps))return this.remove(),this.add(e),this._prevProps=this.props,"reordered"},remove:function(){jr(this._elements,(e=>{e&&e.remove()})),this._elements=null,this._prevProps=null},toFront:function(){jr(this._elements,(e=>{h.isFunction(e.toFront)&&e.toFront()}))}})}},Jr=function(e){var t=e.graphie.scalePoint(e.coord(0)),r=e.graphie.scalePoint(e.coord(1));return w.polarDegFromCart(w.subtract(r,t))[1]},Qr=function(e,t,r){var i=e.range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),n=e.unscaleVector(w.cartFromPolarDeg(1,r)),o=w.scale(w.normalize(n),i),s=w.add(t,o),a=w.polarDegFromCart(n)[1];return e.constrainToBoundsOnAngle(s,4,a*Math.PI/180)},ei=function(e,t){var r=[.75,0],i=[[-3,4],[-2.75,2.5],[0,.25],r,[0,-.25],[-2.75,-2.5],[-3,-4]];i=h.map(i,(function(e){var t=w.subtract(e,r),i=w.scale(t,1.4);return w.add(r,i)}));var n=h.map(i,e.unscalePoint),o={center:e.unscalePoint(r),createPath:function(e){for(var t="M"+e[0][0]+" "+e[0][1],r=1;r<e.length;r+=3)t+="C"+e[r][0]+" "+e[r][1]+" "+e[r+1][0]+" "+e[r+1][1]+" "+e[r+2][0]+" "+e[r+2][1];return t}},s=new Rr(e,n,o);return s.attr(h.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),s.toCoordAtAngle=function(t,i){var n=e.scalePoint(Qr(e,t,i));s.transform("translateX("+(n[0]+1.4*r[0])+"px) translateY("+(n[1]+1.4*r[1])+"px) translateZ(0) rotate("+(360-de.bound(i))+"deg)")},s},ti={draw:function(){this.draw()},pointsToFront:function(e){h.invoke(e.points,"toFront")}};ti.standard=[ti.draw,ti.pointsToFront];var ri={draw:function(){this.draw()}};ri.standard=[ri.draw];var ni={basic:function(e){var t=this.graphie,r=this.coord(0),i=this.coord(1);if(!this.state.visibleShape){this.state.visibleShape=new Nr(t,r,i,{thickness:10}),this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}var n=Jr(this);e.extendLine?(r=Qr(t,r,360-n),i=Qr(t,i,(540-n)%360)):e.extendRay&&(i=Qr(t,i,360-n));var o=[this.state.visibleShape];this.mouseTarget()&&o.push(this.mouseTarget()),h.each(o,(function(e){e.moveTo(r,i)}))},arrows:function(e){null==this._arrows&&(this._arrows=[],e.extendLine?(this._arrows.push(ei(this.graphie,this.normalStyle())),this._arrows.push(ei(this.graphie,this.normalStyle()))):e.extendRay&&this._arrows.push(ei(this.graphie,this.normalStyle())));var t=Jr(this),r=[360-t,(540-t)%360];h.each(this._arrows,(function(e,t){e.toCoordAtAngle(this.coord(t),r[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)}};ni.standard=[ni.basic,ni.arrows,ni.highlight];var oi={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},arrows:function(){null!=this._arrows&&h.invoke(this._arrows,"remove"),this._arrows=null}};oi.standard=[oi.basic,oi.arrows];var si={fixed:function(){return function(){return!1}},snap:function(e){return function(t,r){if(null===e)return!0;var i=w.subtract(t,r);return e=e||this.graphie.snap,i=x.roundTo(i,e),w.add(r,i)}},bound:function(e,t,r){return void 0===r&&(r=void 0===e?10:0),function(i,n){var o=this.graphie,s=w.subtract(i,n);e=e||o.range,void 0===t&&(t=o.snap);var a=o.unscalePoint([r,o.ypixels-r]),l=o.unscalePoint([o.xpixels-r,r]);t&&(a=x.ceilTo(a,t),l=x.floorTo(l,t));var p=h.map(this.coords(),(function(e,t){var r=w.subtract(l,e);return[w.subtract(a,e),r]})),c=h.reduce(p,(function(e,t){var r=t[0],i=t[1];return[Math.max(r[0],Math.min(i[0],e[0])),Math.max(r[1],Math.min(i[1],e[1]))]}),s);return w.add(n,c)}},standard:null},ai={updatePoints:function(e,t){var r=w.subtract(e,t);h.each(this.state.points,(function(e){e.setCoord(w.add(e.coord(),r))}))},standard:null},li={add:ti,modify:ri,draw:ni,remove:oi,onMoveStart:{standard:null},constraints:si,onMove:ai,onMoveEnd:{standard:null}},pi=hr.assert,hi=hr.normalizeOptions,ci=["add","draw","remove","onMoveStart","constraints","onMove","onMoveEnd"],di={points:null,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,extendLine:!1,extendRay:!1},ui={visibleShape:null,mouseTarget:null},mi=function(e,t,r){pi(null!=e),pi(null!=r),h.extend(this,{graphie:e,movable:t,state:{id:h.uniqueId("movableLine")}}),this.modify(h.extend({},ui,r))};h.extend(mi,li),hr.createGettersFor(mi,h.extend({},di,ui)),hr.addMovableHelperMethodsTo(mi),h.extend(mi.prototype,{cloneState:function(){return h.extend(this.movable.cloneState(),{coords:this.coords()},this.state)},_createDefaultState:function(){return h.extend({id:this.state.id},hi(ci,_r.pluck(li,"standard")),di)},modify:function(e){this.update(h.extend(this._createDefaultState(),e))},update:function(e){var t=this,r=this.graphie,i=t.state=h.extend(t.state,hi(ci,e)),n=i.static?mr.DYNAMIC:mr.INTERACTIVE;if(i.normalStyle=h.extend({stroke:n,"stroke-width":2},i.normalStyle),i.highlightStyle=h.extend({stroke:mr.INTERACTING,"stroke-width":3},i.highlightStyle),!i.static&&!i.mouseTarget){i.mouseTarget=new Nr(r,this.coord(0),this.coord(1),{thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"}),i.mouseTarget.attr({fill:"#000",opacity:0})}i.static&&i.mouseTarget&&(i.mouseTarget.remove(),i.mouseTarget=null),t.movable.modify(h.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,r){var i=w.subtract(e,r);t._totalDelta=w.add(t._totalDelta,i);var n=w.add(t._initialRefCoord,t._totalDelta);!1!==(n=t._applyConstraints(n,t._prevRefCoord))&&(t._fireEvent(t.state.onMove,n,t._prevRefCoord),t._prevRefCoord=n)},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,h.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 h.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&&h.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()}});var gi={path:"M8.70710678,12.2928932 C8.31658249,11.9023689 7.68341751,11.9023689 7.29289322,12.2928932 C6.90236893,12.6834175 6.90236893,13.3165825 7.29289322,13.7071068 L9.82842712,16.2426407 C10.2207367,16.6349502 10.8574274,16.6328935 11.2471942,16.2380576 L16.7116603,10.7025237 C17.0996535,10.3094846 17.0955629,9.67633279 16.7025237,9.28833966 C16.3094846,8.90034653 15.6763328,8.90443714 15.2883397,9.29747629 L10.5309507,14.1167372 L8.70710678,12.2928932 Z",width:24,height:24},fi={path:"M6.072 10.4l6.175-7.058a1 1 0 1 1 1.506 1.317L6.769 12.64a1 1 0 0 1-1.55-.054L2.203 8.604a1 1 0 1 1 1.594-1.208L6.072 10.4z",width:16,height:16},vi={path:"M99.669 13.048q0 3.36-2.352 5.712l-41.664 41.664q-2.408 2.408-5.88 2.408t-5.712-2.408l-41.664-41.664q-2.408-2.24-2.408-5.712t2.408-5.88l4.76-4.816q2.52-2.352 5.88-2.352t5.656 2.352l31.136 31.136 31.08-31.136q2.352-2.352 5.712-2.352t5.88 2.352l4.816 4.816q2.352 2.52 2.352 5.88z",width:100,height:63.034},yi={path:"M62.808 49.728q0 3.36-2.352 5.88l-41.72 41.664q-2.352 2.408-5.768 2.408t-5.768-2.408l-4.872-4.76q-2.352-2.52-2.352-5.88t2.352-5.712l31.08-31.136-31.08-31.024q-2.352-2.52-2.352-5.88t2.352-5.712l4.872-4.76q2.296-2.408 5.768-2.408t5.768 2.408l41.72 41.664q2.352 2.296 2.352 5.656z",width:63.034,height:100},bi={path:"M100.035 50.046q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},xi={path:"M50.046 83.676q1.767 0 2.907-1.14l29.526-29.526q1.197-1.197 1.197-2.907t-1.197-2.964l-5.928-5.928q-1.197-1.14-2.964-1.14t-2.907 1.14l-12.312 12.312l0-32.661q0-1.71-1.254-2.964t-2.907-1.254l-8.322 0q-1.71 0-2.964 1.254t-1.254 2.964l0 32.661l-12.312-12.312q-1.197-1.254-2.907-1.254t-2.907 1.254l-5.928 5.928q-1.197 1.197-1.197 2.964t1.197 2.907l29.469 29.526q1.197 1.14 2.964 1.14zm49.989-33.63q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},wi={path:"M54.207 83.391q1.653 0 2.907-1.254t1.254-2.907l0-32.718l12.312 12.312q1.254 1.254 2.964 1.254t2.907-1.254l5.928-5.928q1.197-1.197 1.14-2.964 0-1.767-1.14-2.907l-29.526-29.526q-1.197-1.14-2.907-1.14t-2.964 1.14l-29.469 29.526q-1.197 1.254-1.197 2.964t1.197 2.907l5.928 5.928q1.197 1.197 2.907 1.197t2.907-1.197l12.312-12.312l0 32.718q0 1.653 1.254 2.907t2.964 1.254l8.322 0zm45.828-33.345q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},Ci={path:"M50.046 8.322q-8.493 0-16.188 3.306-15.561 6.669-22.173 22.23-3.363 7.695-3.363 16.188t3.306 16.188 8.949 13.281q5.586 5.586 13.281 8.892t16.188 3.306 16.188-3.306 13.281-8.892 8.892-13.281 3.306-16.188-3.306-16.188-8.892-13.281-13.281-8.949q-7.695-3.306-16.188-3.306zm0 91.713q-13.623 0-25.137-6.726t-18.183-18.183q-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.126q-11.514 6.726-25.08 6.726z",width:100,height:99.944},ki={path:"M58.368 81.225l0-12.369q0-.912-.57-1.539t-1.425-.627l-12.54 0q-.855-.057-1.482.627t-.684 1.539l0 12.369q-.057.855.627 1.482t1.539.684l12.54 0q.855 0 1.425-.627t.57-1.539zm1.026-62.871q0-1.596-2.223-1.71l-14.307 0q-2.109 0-2.223 1.71l1.14 40.47q0 .627.627 1.14t1.539.456l12.084 0q.912-.057 1.539-.513t.684-1.083zm-9.348-18.354q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669z",width:100,height:99.944},Ei={path:"M37.964 76.048q-2.576 0-4.368-1.792l-31.864-31.864q-1.792-1.792-1.792-4.368t1.792-4.368l8.736-8.68q1.792-1.792 4.368-1.792t4.312 1.792l18.816 18.872 42-42.056q1.792-1.792 4.368-1.792t4.312 1.792l8.736 8.736q1.792 1.792 1.792 4.368t-1.792 4.312l-55.048 55.048q-1.792 1.792-4.368 1.792z",width:100,height:76.637},Si={path:"M99.758 43.09l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-29.45 0l0 29.45q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-29.45l-29.45 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l29.45 0l0-29.45q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836l0 29.45l29.45 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:100},_i={path:"M100.464 80.808q0 3.404-2.368 5.772l-11.47 11.544q-2.368 2.368-5.772 2.368t-5.698-2.368l-24.864-24.864-24.864 24.864q-2.368 2.368-5.772 2.368t-5.772-2.368l-11.47-11.544q-2.368-2.368-2.368-5.772t2.368-5.698l24.864-24.864-24.864-24.864q-2.368-2.368-2.368-5.772t2.368-5.772l11.47-11.47q2.368-2.368 5.772-2.368t5.772 2.368l24.864 24.864 24.864-24.864q2.294-2.368 5.698-2.368t5.772 2.368l11.47 11.47q2.368 2.368 2.368 5.772t-2.368 5.772l-24.864 24.864 24.864 24.864q2.368 2.294 2.368 5.698z",width:100,height:100},Mi={path:"M15.1052249,9.55978547 L22.0028147,9.55978545 C23.6568673,9.55978545 23.9349557,10.3753626 22.6181351,11.3858845 L16.9943688,15.7015366 L19.2518801,22.8294455 C19.7526645,24.4106317 19.0984455,24.8825885 17.769353,23.8673293 L12.0490577,19.4977438 L6.5116497,23.8422153 C5.20921411,24.8640642 4.53299569,24.4067544 5.00266927,22.8160582 L7.10332364,15.7015366 L1.42794544,11.3634306 C0.110226041,10.3562014 0.383967283,9.54239221 2.0409646,9.54574013 L8.9924676,9.55978547 L11.1485117,2.72669438 C11.6458693,1.15043244 12.4548928,1.15900049 12.9494787,2.72669438 L15.1052249,9.55978547 Z",width:24,height:24},Ti={path:"M3.74890556,17.9799506 C2.19251241,16.1970909 1.10103636,13.4971457 1.13090903,11.1491783 C1.17160478,7.95052637 4.01704076,0.865059407 11.7028044,0.865059407 C19.388568,0.865059407 22.3026521,7.35203035 22.3026521,11.5879453 C22.3026521,15.8238603 19.386629,20.5574509 13.6832464,21.7131548 L13.6757539,17.3722171 C17.0812986,16.2190517 18.331158,14.1944123 18.3311578,11.5879451 C18.3311574,8.16554692 15.6664205,5.03476549 11.7028048,5.20494205 C7.73918903,5.37511861 5.59244567,8.66930079 5.59244567,11.1491783 C5.59244567,12.9090077 6.11128139,14.1753512 6.93640437,15.3053215 L8.14052356,14.2949456 C8.98559348,13.5858477 9.6994861,13.9070448 9.73489556,15.0076413 L9.91284941,20.5388014 C9.94832683,21.6415103 9.09967118,22.3514475 8.02194403,22.1254594 L2.60571602,20.9897332 C1.5259204,20.7633114 1.34338662,19.9984207 2.18070755,19.295825 L3.74890556,17.9799506 Z",width:23,height:23},Ii={path:"M31.293 37.506q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.218 0q-.912-.057-1.482-.627t-.57-1.482l0-37.506q0-2.109 2.052-2.109l4.218 0zm18.753 2.109l0 37.506q0 .912-.57 1.482t-1.539.627l-4.161 0q-1.995 0-2.109-2.109l0-37.506q.057-.912.627-1.482t1.482-.627l4.161 0q.969.057 1.539.627t.57 1.482zm14.592-2.109q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.161 0q-.969-.057-1.539-.627t-.57-1.482l0-37.506q0-2.109 2.109-2.109l4.161 0zm10.431 49.248l0-61.731l-58.368 0l0 61.731q.057 2.679.969 3.819t1.083 1.14l54.207 0q.171 0 1.14-1.083t.969-3.876zm-43.776-70.11l29.184 0l-3.135-7.581q-.456-.57-1.14-.741l-20.634 0q-.627.114-1.083.741zm-31.293 2.109q0-1.995 2.109-2.109l20.121 0l4.56-10.83q.969-2.394 3.477-4.104 2.565-1.71 5.187-1.71l20.805 0q2.622 0 5.187 1.71t3.477 4.104l4.56 10.83l20.178 0q.912.057 1.482.627t.57 1.482l0 4.161q0 1.995-2.052 2.109l-6.27 0l0 61.731q0 5.415-3.078 9.348t-7.353 3.933l-54.207 0q-4.275 0-7.353-3.819t-3.078-9.177l0-62.016l-6.213 0q-.969 0-1.539-.57t-.57-1.539l0-4.161z",width:91.681,height:100},Pi={path:"M10,6.6C10,7.2,9.8,8,9.3,9.1c0,0,0,0.1-0.1,0.1S9.2,9.3,9.2,9.4c0,0,0,0.1-0.1,0.1C9,9.6,9,9.6,8.9,9.6 c-0.1,0-0.1,0-0.1-0.1c0,0,0-0.1,0-0.1c0,0,0-0.1,0-0.1s0-0.1,0-0.1c0-0.3,0-0.5,0-0.7c0-0.4,0-0.7-0.1-1C8.6,7.1,8.5,6.9,8.4,6.7S8.2,6.3,8,6.1C7.8,5.9,7.6,5.8,7.4,5.7S6.9,5.5,6.7,5.5S6.1,5.4,5.8,5.4c-0.3,0-0.6,0-1,0H3.6v1.4c0,0.1,0,0.2-0.1,0.3C3.4,7.1,3.3,7.1,3.2,7.1C3.1,7.1,3,7.1,3,7L0.1,4.1C0,4.1,0,4,0,3.9s0-0.2,0.1-0.3L3,0.8C3,0.7,3.1,0.7,3.2,0.7c0.1,0,0.2,0,0.3,0.1C3.5,0.9,3.6,0.9,3.6,1v1.4h1.2c2.6,0,4.3,0.7,4.9,2.2C9.9,5.2,10,5.8,10,6.6z",width:10,height:10},Ni={path:"M8,13 L16,13 C16.5522847,13 17,12.5522847 17,12 C17,11.4477153 16.5522847,11 16,11 L8,11 C7.44771525,11 7,11.4477153 7,12 C7,12.5522847 7.44771525,13 8,13 Z",width:24,height:24},Ai=Object.freeze({__proto__:null,iconCheck:gi,iconCheckMedium:fi,iconChevronDown:vi,iconChevronRight:yi,iconCircle:bi,iconCircleArrowDown:xi,iconCircleArrowUp:wi,iconCircleThin:Ci,iconDesktop:{path:"M94.208 52.119l0-43.746q0-.69-.506-1.15t-1.196-.506l-84.088 0q-.69 0-1.196.506t-.506 1.15l0 43.746q0 .69.506 1.196t1.196.506l84.088 0q.69 0 1.196-.506t.506-1.196zm6.716-43.746l0 57.224q0 3.45-2.484 5.934t-5.934 2.484l-28.566 0q0 3.128 2.53 7.774.828 1.61.828 2.622t-1.012 2.07q-1.012 1.012-2.346.966l-26.91 0q-1.38 0-2.392-1.012t-1.012-2.024q0-1.058 1.656-4.14t1.748-6.256l-28.612 0q-3.45 0-5.934-2.484t-2.484-5.934l0-57.224q0-3.45 2.484-5.934t5.934-2.438l84.088 0q3.45 0 5.98 2.438 2.438 2.484 2.438 5.934z",width:100,height:86.648},iconDropdownArrow:{path:"M9 9.8c0 .5.7 1.7 1.5 2.8 1.5 1.9 1.5 1.9 3 0C15.7 9.7 15.4 9 12 9c-1.6 0-3 .4-3 .8z",width:24,height:24},iconExclamationSign:ki,iconGear:{path:"M1152 896q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm512-109v222q0 12-8 23t-20 13l-185 28q-19 54-39 91 35 50 107 138 10 12 10 25t-9 23q-27 37-99 108t-94 71q-12 0-26-9l-138-108q-44 23-91 38-16 136-29 186-7 28-36 28h-222q-14 0-24.5-8.5t-11.5-21.5l-28-184q-49-16-90-37l-141 107q-10 9-25 9-14 0-25-11-126-114-165-168-7-10-7-23 0-12 8-23 15-21 51-66.5t54-70.5q-27-50-41-99l-183-27q-13-2-21-12.5t-8-23.5v-222q0-12 8-23t19-13l186-28q14-46 39-92-40-57-107-138-10-12-10-24 0-10 9-23 26-36 98.5-107.5t94.5-71.5q13 0 26 10l138 107q44-23 91-38 16-136 29-186 7-28 36-28h222q14 0 24.5 8.5t11.5 21.5l28 184q49 16 90 37l142-107q9-9 24-9 13 0 25 10 129 119 165 170 7 8 7 22 0 12-8 23-15 21-51 66.5t-54 70.5q26 50 41 98l183 28q13 2 21 12.5t8 23.5z",width:1792,height:1792},iconMobilePhone:{path:"M36.04 89.557q0-2.584-1.836-4.42t-4.42-1.836-4.352 1.836q-1.836 1.836-1.836 4.42t1.836 4.352 4.42 1.836q2.652-.068 4.42-1.836t1.768-4.352zm16.184-12.444l0-54.74q0-1.088-.748-1.768t-1.768-.68l-39.78 0q-1.088 0-1.768.748t-.68 1.7l0 54.74q0 1.02.748 1.768t1.7.68l39.78 0q1.02-.068 1.768-.748t.748-1.7zm-14.892-65.892q0-1.224-1.292-1.292l-12.444 0q-1.224.068-1.224 1.292t1.224 1.224l12.444 0q1.292 0 1.292-1.224zm22.372-1.292l0 79.628q0 3.944-2.992 6.936t-7.004 2.992l-39.78 0q-4.012 0-7.004-2.924-2.924-2.924-2.924-7.004l0-79.628q0-4.012 2.924-6.936t7.004-2.992l39.78 0q4.012-.068 7.004 2.924t2.992 7.004z",width:60.013,height:100},iconOk:Ei,iconPlus:Si,iconRemove:_i,iconStar:Mi,iconTryAgain:Ti,iconTablet:{path:"M45.322 90.706q0-1.86-1.302-3.224-1.364-1.364-3.224-1.364t-3.224 1.364-1.302 3.224q0 1.86 1.364 3.224 1.302 1.364 3.162 1.302 1.86.062 3.224-1.302t1.302-3.224zm27.218-11.346l0-68.014q0-.93-.682-1.612t-1.55-.682l-58.962 0q-.93 0-1.612.682t-.682 1.612l0 68.014q0 .93.682 1.612t1.612.62l58.962 0q.992-.062 1.612-.682t.62-1.55zm9.114-68.014l0 77.066q0 4.65-3.348 7.998t-7.998 3.348l-58.962 0q-4.65 0-7.998-3.348t-3.348-7.998l0-77.066q0-4.65 3.348-7.998t7.998-3.348l58.962 0q4.65 0 7.998 3.348t3.348 7.998z",width:81.852,height:100},iconTrash:Ii,iconUndo:Pi,iconMinus:Ni}),Ri={constrain:function(){this.constrain()}};Ri.standard=[Ri.constrain];var Fi={draw:function(){this.draw()}};Fi.standard=[Fi.draw];var Oi={basic:function(e,t){var r=this.graphie;if(!this.state.visibleShape){var i=[this.pointSize()/r.scale[0],this.pointSize()/r.scale[1]],n={maxScale:Math.max(this.highlightStyle().scale,this.normalStyle().scale),padding:10,shadow:e.shadow};this.state.visibleShape=new Ir(r,this.coord(),i,n),this.state.visibleShape.attr(h.omit(this.normalStyle(),"scale")),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}e.normalStyle===t.normalStyle||h.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)}};Oi.standard=[Oi.basic,Oi.highlight];var Di={basic:function(){this.state.visibleShape&&(this.state.visibleShape.remove(),this.state.visibleShape=null)}};Di.standard=Di.basic;var Li={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,x.roundTo(t,e))}},bound:function(e,t,r){return void 0===r&&(r=void 0===e?10:0),function(i,n,o){var s=this.graphie;e=e||s.range,void 0===t&&(t=s.snap);var a=s.unscalePoint([r,s.ypixels-r]),l=s.unscalePoint([s.xpixels-r,r]);return t&&(a=x.ceilTo(a,t),l=x.floorTo(l,t)),o&&o.onOutOfBounds?((i[0]>l[0]||i[0]<a[0]||i[1]>l[1]||i[1]<a[1])&&(o.onSkipRemaining(),o.onOutOfBounds()),i):[Math.max(a[0],Math.min(l[0],i[0])),Math.max(a[1],Math.min(l[1],i[1]))]}},standard:null},Bi={add:Ri,modify:Fi,draw:Oi,remove:Di,onMoveStart:{standard:null},constraints:Li,onMove:{standard:null},onMoveEnd:{standard:null},onClick:{standard:null}},zi=hr.assert,Hi=hr.normalizeOptions,{processMath:Wi}=br,qi=h.keys(Bi),Ui={coord:[0,0],pointSize:4,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,shadow:!1,tooltip:!1},Gi={added:!1,hasMoved:!1,visibleShape:null,outOfBounds:!1,mouseTarget:null,touchOffset:null},Vi=[],ji=function(e,t,r){h.extend(this,{graphie:e,movable:t,state:{id:h.uniqueId("movablePoint")}}),this.modify(h.extend({},Gi,r))};function Yi(e){var t,r=h.zip(e,e.slice(1).concat(e.slice(0,1))),i=h.map(r,(function(e){var t=e[0],r=e[1];return(r[0]-t[0])*(r[1]+t[1])}));return t=i,h.reduce(t,(function(e,t){return e+t}),0)>0}h.extend(ji,Bi),hr.createGettersFor(ji,h.extend({},Ui,Gi)),hr.addMovableHelperMethodsTo(ji),h.extend(ji.prototype,{cloneState:function(){return h.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return h.extend({id:this.state.id},Hi(qi,_r.pluck(Bi,"standard")),Ui)},modify:function(e){this.update(h.extend(this._createDefaultState(),e))},_showTooltip:function(e){this._tooltip||(this._tooltip=document.createElement("div"),this._tooltip.className="tooltip-content",this.state.visibleShape.wrapper.className="tooltip",this.state.visibleShape.wrapper.appendChild(this._tooltip),Vi.push((()=>{this.state.added&&this._hideTooltip()}))),this._tooltip.firstChild&&this._tooltip.removeChild(this._tooltip.firstChild),this.state.visibleShape.wrapper.className="tooltip visible",this._tooltip.appendChild(document.createElement("span")),"string"==typeof e?Wi(this._tooltip.firstChild,e,!1):"function"==typeof e?e(this._tooltip.firstChild):this._tooltip.firstChild.appendChild(e)},_hideTooltip:function(){this._tooltip&&(this.state.visibleShape.wrapper.className="tooltip")},update:function(e){var t=this,r=t.graphie,i=h.extend(t.state,Hi(qi,e));zi(x.is(i.coord));var n=i.static?mr.DYNAMIC:mr.INTERACTIVE;if(i.normalStyle=h.extend({fill:n,stroke:n,scale:1},i.normalStyle),i.highlightStyle=h.extend({fill:mr.INTERACTING,stroke:mr.INTERACTING,scale:2},i.highlightStyle),!i.static&&!i.mouseTarget){var o=t.state.coord,s=r.unscaleVector(24);i.mouseTarget=new Ir(r,o,s,{mouselayer:!0,padding:0,interactiveKindForTesting:"movable-point"}),i.mouseTarget.attr({fill:"#000",opacity:0})}var l=()=>{this._showTooltip((e=>{f.render(a.createElement("span",{style:{fontSize:"2em"}},a.createElement(X,Y({},Ii,{style:{position:"static",color:mr.INTERACTIVE,marginLeft:9,marginRight:9}}))),e)}))},p=i.coord;t.movable.modify(h.extend({},i,{add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:e=>{if(i.hasMoved=!1,p=i.coord,null==i.touchOffset){var r=!("ontouchstart"in window);i.touchOffset=r?[0,0]:w.subtract(p,e)}var n=i.visibleShape.wrapper;if(i.shadow){var o="none";n.style.webkitFilter=o,n.style.filter=o}if(i.showHairlines&&i.showHairlines(i.coord),Vi.forEach((e=>e())),i.tooltip&&(i.xOnlyTooltip?this._showTooltip("".concat(i.coord[0])):this._showTooltip("(".concat(i.coord[0],", ").concat(i.coord[1],")")),i.shadow)){var s=n.getElementsByClassName("tooltip-content")[0],a="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";s.style.webkitFilter=a,s.style.filter=a}t._fireEvent(i.onMoveStart,p,p),t.draw()},onMove:(e,r)=>{var n=w.add(e,i.touchOffset);t.moveTo(n),i.showHairlines&&(this.state.outOfBounds?i.hideHairlines():i.showHairlines(i.coord)),i.tooltip&&(this.state.outOfBounds||(i.xOnlyTooltip?this._showTooltip("".concat(i.coord[0])):this._showTooltip("(".concat(i.coord[0],", ").concat(i.coord[1],")")))),i.onRemove&&this.state.outOfBounds&&l()},onMoveEnd:()=>{t.isHovering()&&!i.hasMoved&&t._fireEvent(i.onClick,i.coord,p);var e=i.visibleShape.wrapper;if(i.shadow){var r="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=r,e.style.filter=r}if(i.hideHairlines&&i.hideHairlines(),i.hasMoved)this._hideTooltip();else if(i.onRemove){l();var n=e.getElementsByClassName("tooltip-content")[0];n.style.webkitFilter="none",n.style.filter="none",this._tooltip.firstChild.addEventListener("touchstart",(e=>{e.stopPropagation()}),!0),this._tooltip.firstChild.addEventListener("touchend",(e=>{i.onRemove(),e.stopPropagation()}),!0)}else i.tooltip&&this._hideTooltip();i.outOfBounds&&i.onRemove(),t._fireEvent(i.onMoveEnd,i.coord,p),i.hasMoved=!1,i.touchOffset=null,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 x.is(e)&&this.setCoord(e),!1!==e},setCoord:function(e){zi(x.is(e,2)),this.state.coord=h.clone(e),this.draw()},setCoordConstrained:function(e){zi(x.is(e,2));var t=this._applyConstraints(e,this.coord());!1!==t&&(this.state.coord=h.clone(t),this.draw())},moveTo:function(e){var t=this.state;this.state.outOfBounds=!1;var r=this._applyConstraints(e,t.coord,t.onRemove?{onOutOfBounds:()=>{this.state.outOfBounds=!0}}:{});if(!1!==r&&(x.is(r)&&(e=r),!x.equal(e,t.coord))){var i=t.coord;t.coord=e,t.hasMoved=!0,this._fireEvent(t.onMove,t.coord,i),this.draw()}},normalStyle:function(){return h.clone(this.state.normalStyle)},highlightStyle:function(){return h.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.state.touchOffset=[0,0],this.movable.grab(e),this.moveTo(e)}});var $i={constrain:function(){this.constrain()},pointsToFront:function(e){h.invoke(e.points,"toFront")}};$i.standard=[$i.constrain,$i.pointsToFront];var Xi={draw:function(){this.draw()}};Xi.standard=[Xi.draw];var Ki={basic:function(e,t){var r=this.graphie,i=this.path(e);this.state.visibleShape||(this.state.visibleShape=r.raphael.path(i),this.state.visibleShape.attr(this.normalStyle())),e.normalStyle===t.normalStyle||h.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.attr({path:i}),this.mouseTarget()&&this.mouseTarget().attr({path:i})},labels:function(e,t){var r=this.graphie,i=this,n=h.invoke(e.points,"coord"),o=Yi(n),s=n.length;null!=i.state._labelCache&&h.invoke(i.state._labelCache,"remove"),i.state._labelCache=[],(e.angleLabels.length||e.showRightAngleMarkers.length)&&(null==i.state._labeledAngles&&(i.state._labeledAngles=h.times(Math.max(e.angleLabels.length,e.showRightAngleMarkers.length),(function(){return r.label([0,0],"","center",e.labelStyle)}))),h.each(i.state._labeledAngles,(function(t,a){i.state._labelCache.push(r.labelAngle({point1:n[(a-1+s)%s],vertex:n[a],point3:n[(a+1)%s],label:t,text:e.angleLabels[a],showRightAngleMarker:e.showRightAngleMarkers[a],numArcs:e.numArcs[a],clockwise:o,style:e.labelStyle}))}))),e.sideLabels.length&&(null==i.state._labeledSides&&(i.state._labeledSides=h.map(e.sideLabels,(function(t){return r.label([0,0],"","center",e.labelStyle)}))),h.each(i.state._labeledSides,(function(t,a){i.state._labelCache.push(r.labelSide({point1:n[a],point2:n[(a+1)%s],label:t,text:e.sideLabels[a],numArrows:e.numArrows[a],numTicks:e.numTicks[a],clockwise:o,style:e.labelStyle}))}))),e.vertexLabels.length&&(null==i.state._labeledVertices&&(i.state._labeledVertices=h.map(e.vertexLabels,(function(t){return r.label([0,0],"","center",e.labelStyle)}))),h.each(i.state._labeledVertices,(function(t,a){i.state._labelCache.push(r.labelVertex({point1:n[(a-1+s)%s],vertex:n[a],point3:n[(a+1)%s],label:t,text:e.vertexLabels[a],clockwise:o,style:e.labelStyle}))}))),i.state._labelCache=h.flatten(i.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)}};Ki.standard=[Ki.basic,Ki.labels,Ki.highlight];var Zi={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];h.each(e,(function(e){null!=e&&e.length&&h.invoke(e,"remove")}))}};Zi.standard=[Zi.basic,Zi.labels];var Ji={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,x.roundTo(t,e))}},bound:function(e,t,r){return void 0===r&&(r=void 0===e?10:0),function(i,n){var o=this.graphie,s=w.subtract(i,n);e=e||o.range,void 0===t&&(t=o.snap);var a=o.unscalePoint([r,o.ypixels-r]),l=o.unscalePoint([o.xpixels-r,r]);t&&(a=x.ceilTo(a,t),l=x.floorTo(l,t));var p=h.map(this.coords(),(function(e,t){var r=w.subtract(l,e);return[w.subtract(a,e),r]})),c=h.reduce(p,(function(e,t){var r=t[0],i=t[1];return[Math.max(r[0],Math.min(i[0],e[0])),Math.max(r[1],Math.min(i[1],e[1]))]}),s);return w.add(n,c)}},standard:null},Qi={updatePoints:function(e,t){var r=w.subtract(e,t);h.each(this.state.points,(function(e){e.setCoord(w.add(e.coord(),r))}))},standard:null},en={add:$i,modify:Xi,draw:Ki,remove:Zi,onMoveStart:{standard:null},constraints:Ji,onMove:Qi,onMoveEnd:{standard:null},onClick:{standard:null}},tn=hr.assert,rn=hr.normalizeOptions,nn=h.keys(en),on={points:null,angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],closed:!0,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,labelStyle:null},sn={added:!1,hasMoved:!1,visibleShape:null,mouseTarget:null},an=function(e,t,r){tn(null!=e),tn(null!=r),h.extend(this,{graphie:e,movable:t,state:{id:h.uniqueId("movablePolygon")}}),this.modify(h.extend({},sn,r))};h.extend(an,en),hr.createGettersFor(an,h.extend({},on,sn)),hr.addMovableHelperMethodsTo(an),h.extend(an.prototype,{cloneState:function(){return h.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return h.extend({id:this.state.id},rn(nn,_r.pluck(en,"standard")),on)},modify:function(e){this.update(h.extend(this._createDefaultState(),e))},update:function(e){var t=this,r=t.graphie,i=h.extend(t.state,rn(nn,e)),n=i.static?mr.DYNAMIC:mr.INTERACTIVE;i.normalStyle=h.extend({},i.normalStyle,{"stroke-width":2,"fill-opacity":0,fill:n,stroke:n},e.normalStyle),i.highlightStyle=h.extend({},{stroke:mr.INTERACTING,"stroke-width":2,fill:mr.INTERACTING,"fill-opacity":.05},i.highlightStyle),i.labelStyle=h.extend({},{stroke:mr.DYNAMIC,"stroke-width":1,color:mr.DYNAMIC},i.labelStyle),i.static||i.mouseTarget||(i.mouseTarget=r.mouselayer.path(this.path()),i.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"})),t.movable.modify(h.extend({},i,{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,r){var i=w.subtract(e,r);t._totalDelta=w.add(t._totalDelta,i);var n=w.add(t._initialRefCoord,t._totalDelta);!1!==(n=t._applyConstraints(n,t._prevRefCoord))&&(t._fireEvent(t.state.onMove,n,t._prevRefCoord),t._prevRefCoord=n)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),h.invoke(i.points,"listen","onMove",i.id,t.draw.bind(t)),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)},path:function(e){var t=this.graphie;e=e||this.state;var r=h.map(e.points,(function(e){return t.scalePoint(e.coord())}));return e.closed?r.push(!0):r=r.concat(h.clone(r).reverse()),Cr.unscaledSvgPath(r)},coords:function(){return h.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&&h.invoke(this.state.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){if(null!=this.points&&0!==this.points.length){var e=this.coord(0),t=this._applyConstraints(e,e);!1!==t&&this._fireEvent(this.state.onMove,t,e)}},normalStyle:function(){return h.clone(this.state.normalStyle)},highlightStyle:function(){return h.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()}});var ln=hr.normalizeOptions,pn=hr.assert,hn=["add","modify","draw","remove","onMoveStart","onMove","onMoveEnd","onClick"],cn={cursor:null},dn={added:!1,isHovering:!1,isMouseOver:!1,isDragging:!1,mouseTarget:null},un=function(e,t){h.extend(this,{graphie:e,state:{id:h.uniqueId("movable")}}),this.modify(h.extend({},dn,t))};hr.createGettersFor(un,h.extend({},cn,dn)),hr.addMovableHelperMethodsTo(un),h.extend(un.prototype,{cloneState:function(){return h.clone(this.state)},_createDefaultState:function(){return h.extend({id:this.state.id,add:[],modify:[],draw:[],remove:[],onMoveStart:[],onMove:[],onMoveEnd:[],onClick:[]},cn)},modify:function(e){this.update(h.extend({},this._createDefaultState(),e))},grab:function(e){pn(x.is(e));var t=this,r=t.graphie,i=t.state;i.isHovering=!0,i.isDragging=!0,r.isDragging=!0;var n=e,o=n;t._fireEvent(i.onMoveStart,n,n);var s=function(e){e.preventDefault();var n=r.getMouseCoord(e);t._fireEvent(i.onMove,n,o),t.draw(),o=n};y(document).bind("vmousemove",s),y(document).bind("vmouseup",(function e(a){y(document).unbind("vmousemove",s),y(document).unbind("vmouseup",e),i.isHovering&&t._fireEvent(i.onClick,o,n),i.isHovering=t.state.isMouseOver,i.isDragging=!1,r.isDragging=!1,t._fireEvent(i.onMoveEnd,o,n),t.draw()}))},update:function(e){var t,r=this,i=r.graphie,n=r.cloneState(),o=h.extend(r.state,ln(hn,e));o.mouseTarget&&!n.mouseTarget&&(t=o.mouseTarget.getMouseTarget?y(o.mouseTarget.getMouseTarget()):y(o.mouseTarget[0]),!("ontouchstart"in window)&&(t.on("vmouseover",(function(){o.isMouseOver=!0,i.isDragging||(o.isHovering=!0),r.state.added&&r.draw()})),t.on("vmouseout",(function(){o.isMouseOver=!1,o.isDragging||(o.isHovering=!1),r.state.added&&r.draw()}))),t[0].addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),t.on("vmousedown",(function(e){if(0===e.which||1===e.which){e.preventDefault();var t=i.getMouseCoord(e);r.grab(t)}})));o.mouseTarget&&void 0!==o.cursor&&(o.mouseTarget.getMouseTarget?y(o.mouseTarget.getMouseTarget()):y(o.mouseTarget[0])).css("cursor",o.cursor||"");o.added||(r._fireEvent(o.modify,r.cloneState(),{}),o.added=!0,r.prevState=r.cloneState()),r._fireEvent(o.modify,r.cloneState(),r.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.mouseTarget&&(y(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()}});var mn={MovablePoint:ji,addMovablePoint:function(e,t){var r=new un(e,{});return new ji(e,r,t)},MovableLine:mi,addMovableLine:function(e,t){var r=new un(e,{});return new mi(e,r,t)},MovablePolygon:an,addMovablePolygon:function(e,t){var r=new un(e,{});return new an(e,r,t)},addMaybeMobileMovablePoint:function(e,t){var r=e.props.apiOptions.isMobile,i=r?{stroke:"#ffffff","stroke-width":3,fill:mr.INTERACTIVE}:{stroke:mr.INTERACTIVE,fill:mr.INTERACTIVE},n=Object.assign(i,t.normalStyle),o=Object.assign(r?G(G({},i),{},{"stroke-width":0,scale:.75}):{},t.highlightStyle),s=Object.assign({normalStyle:n,highlightStyle:o,shadow:r,tooltip:r&&e.props.showTooltips,showHairlines:e.showHairlines,hideHairlines:e.hideHairlines},r?{pointSize:7}:{});return mn.addMovablePoint(e.graphie,Object.assign(t,s))}},gn=Zr.createClass({displayName:"MovablePoint",movableProps:["children"],_getProps:function(){if(this.props.isMobile){var e=this.props.isMobile,t=e?{stroke:"#ffffff","stroke-width":3,fill:mr.INTERACTIVE}:{stroke:mr.INTERACTIVE,fill:mr.INTERACTIVE},r=e?Object.assign(t,this.props.mobileStyleOverride||{}):Object.assign(t,this.props.normalStyle),i=e?G(G({},t),{},{"stroke-width":0,scale:.75}):this.props.highlightStyle,n=Object.assign({normalStyle:r,highlightStyle:i,shadow:e,tooltip:e&&this.props.showTooltips},e?{pointSize:7}:{});return Object.assign(this.props,n)}return this.props},add:function(e){this.point=mn.addMovablePoint(e,this._getProps())},modify:function(){this.point.modify(this._getProps())},remove:function(){this.point.remove()},toFront:function(){this.point.toFront()},grab:function(e){this.point.grab(e)}});h.extend(gn,mn.MovablePoint);var fn=Zr.createClass({displayName:"MovableLine",movableProps:["children"],add:function(e){var t=h.pluck(this.props.children,"point"),r=h.extend({},this.props,{points:t});this.line=mn.addMovableLine(e,r)},modify:function(){var e=h.pluck(this.props.children,"point"),t=h.extend({},this.props,{points:e});this.line.modify(t)},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}});h.extend(fn,mn.MovableLine);var vn=Zr.createSimpleClass(((e,t)=>{var r=t.coord;t.unscaled&&(r=e.unscalePoint(r));var i=null;return ae().JIPT.useJIPT?(i=e.label(r,t.text,t.direction,!1,t.style),ae().graphieMovablesJiptLabels.addLabel(i,t.tex)):i=e.label(r,t.text,t.direction,t.tex,t.style),i})),yn=Zr.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(h.extend({},e.style,{path:t}))},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}}),bn=Zr.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(h.extend({},e.style,{path:t}))},remove:function(){this.parabola.remove()},toFront:function(){this.parabola.toFront()}}),xn=Zr.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(h.extend({},e.style,{path:t}))},remove:function(){this.sinusoid.remove()},toFront:function(){this.sinusoid.toFront()}}),wn=Zr.createSimpleClass(((e,t)=>e.plot(t.fn,t.range,t.style))),Cn=Zr.createSimpleClass(((e,t)=>e.plotParametric(t.fn,t.range,t.style))),kn=Zr.createSimpleClass(((e,t)=>e.ellipse(t.coord,e.unscaleVector([4,4]),{fill:t.color||mr.BLACK,stroke:t.color||mr.BLACK}))),En=Zr.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()}}),Sn={Arc:Zr.createSimpleClass(((e,t)=>{var r=t.center,i=t.radius;return t.unscaled&&(r=e.unscalePoint(r),i=e.unscaleVector(i)),e.arc(r,i,t.startAngle,t.endAngle,t.sector,t.style)})),Circle:Zr.createSimpleClass(((e,t)=>e.circle(t.center,t.radius,t.style))),Label:vn,Line:yn,MovableLine:fn,MovablePoint:gn,Parabola:bn,Path:En,Plot:wn,PlotParametric:Cn,Point:kn,Sinusoid:xn,Rect:Zr.createSimpleClass(((e,t)=>e.rect(t.x,t.y,t.width,t.height,t.style)))},_n=Zr.GraphieMovable,Mn=Cr.createGraphie,{deepEq:Tn,nestedMap:In}=De,{assert:Pn}=hr;class Nn extends a.Component{constructor(){super(...arguments),j(this,"getGraphie",(()=>this._graphie)),j(this,"_range",(()=>h.map(this.props.range,(e=>e[0]>=e[1]?[-10,10]:e)))),j(this,"_box",(()=>h.map(this.props.box,(e=>e>0?e:340)))),j(this,"_scale",(()=>{var e=this._box(),t=this._range();return h.map(e,((e,r)=>e/(t[r][1]-t[r][0])))})),j(this,"_setupGraphie",(()=>{this._removeMovables();var e=v.findDOMNode(this.refs.graphieDiv);y(e).empty();var t=this._graphie=Mn(e);t.init({range:this._range(),scale:this._scale(),isMobile:this.props.isMobile}),this.props.addMouseLayer&&t.addMouseLayer({onClick:this.props.onClick,onMouseDown:this.props.onMouseDown,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),t.snap=this.props.options.snapStep||[1,1],this.props.responsive&&(y(e).css({width:"100%",height:"100%"}),t.raphael.setSize("100%","100%")),this.props.setup(t,h.extend({range:this._range(),scale:this._scale()},this.props.options))})),j(this,"_removeMovables",(()=>{h.invoke(this._movables,"remove"),this._movables={}})),j(this,"_renderMovables",((e,t)=>{var r=t.graphie,i=t.oldMovables,n=t.newMovables,o=e=>{h.each(e.movableProps,(r=>{e.props[r]=this._renderMovables(e.props[r],t)}))},s=!1;return In(e,(e=>{if(!e)return t.nextKey++,e;var a=new e.type(e.props);Pn(a instanceof _n,"All children of a Graphie component must be Graphie movables");var l=e.key,p=null==l?"_no_id_"+t.nextKey:l;t.nextKey++;var h=e.ref;o(a);var c=i[p];if(c)if(a.constructor===c.constructor){c.props=a.props,"reordered"===c.modify(r)&&(s=!0),n[p]=c}else null==l&&he.error("Replacing a <Graphie> child with a child of a different type. Please add keys to your <Graphie> children",pe.Internal),c.remove(),a.add(r),s=!0,n[p]=a;else a.add(r),s=!0,n[p]=a;return s&&n[p].toFront(),h&&(this.movables[h]=n[p]),n[p]}))})),j(this,"_updateMovables",(()=>{var e=this._graphie,t=this._movables,r={};this._movables=r,this.movables={},this._renderMovables(this.props.children,{nextKey:1,graphie:e,oldMovables:t,newMovables:r}),h.each(t,((e,t)=>{r[t]||e.remove()}))}))}componentDidMount(){this._setupGraphie(),this._updateMovables()}shouldComponentUpdate(e){return!h.isEqual(this.props,e)}componentDidUpdate(e){this.props.setup!==e.setup&&he.error("<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.",pe.Internal),Tn(this.props.options,e.options)&&Tn(this.props.box,e.box)&&Tn(this.props.range,e.range)||this._setupGraphie(),this._updateMovables()}render(){return a.createElement("div",{className:"graphie-container"},a.createElement("div",{className:"graphie",ref:"graphieDiv"}))}}j(Nn,"propTypes",{addMouseLayer:d.bool,box:d.arrayOf(d.number).isRequired,children:d.node,isMobile:d.bool,onClick:d.func,onMouseDown:d.func,onMouseMove:d.func,onMouseUp:d.func,options:d.shape({snapStep:d.arrayOf(d.number)}),range:d.arrayOf(d.arrayOf(d.number)),responsive:d.bool,setDrawingAreaAvailable:d.func,setup:d.func.isRequired}),j(Nn,"defaultProps",{range:[[-10,10],[-10,10]],options:{},responsive:!1,addMouseLayer:!0}),h.extend(Nn,Zr),h.extend(Nn,Sn);var An="pending",Rn="loading",Fn="loaded",On="failed";class Dn extends a.Component{constructor(e){super(e),j(this,"img",void 0),j(this,"createLoader",(()=>{this.destroyLoader(),this.img=new Image,this.img.onload=this.handleLoad,this.img.onerror=this.handleError,this.img.src=this.props.src})),j(this,"destroyLoader",(()=>{this.img&&(this.img.onload=null,this.img.onerror=null,this.img=null)})),j(this,"handleLoad",(e=>{this.destroyLoader(),this.setState({status:Fn}),this.props.onLoad&&this.props.onLoad(e)})),j(this,"handleError",(e=>{this.destroyLoader(),this.setState({status:On}),this.props.onError&&this.props.onError(e)})),j(this,"renderImg",(()=>{var{src:e,imgProps:t}=this.props,r=null,i=null;null!=t.onClick&&(r=e=>{13!==e.keyCode&&32!==e.keyCode||t.onClick&&t.onClick(e)},i=e=>{32===e.keyCode&&e.preventDefault()});var n=ae().staticUrl;return a.createElement("img",Y({src:n(e),onKeyUp:r,onKeyDown:i},t))})),this.state={status:e.src?Rn:An}}componentDidMount(){this.state.status===Rn&&this.createLoader()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({status:e.src?Rn:An})}componentDidUpdate(e,t){this.state.status!==Rn||this.img||this.createLoader(),t.status!==this.state.status&&this.props.onUpdate(this.state.status)}componentWillUnmount(){this.destroyLoader()}render(){switch(this.state.status){case Fn:return this.renderImg();case On:if(this.props.children)return this.props.children;break;default:if(this.props.preloader)return this.props.preloader()}return null}}var Ln={},Bn=/^file\+graphie\:/,zn=/\/([^/]+)$/;function Hn(e){return/\.(jpg|jpeg)$/i.test(e)}function Wn(){var{JIPT:e,kaLocale:t}=ae();return e.useJIPT?"en-pt":t}function qn(){return"en"!==Wn()}var Un=/\/(?=[^/]+$)/;function Gn(e){return a.createElement("span",{style:{background:"url(/images/spinner.gif) no-repeat",backgroundPosition:"center",width:"100%",height:"100%",position:"absolute",minWidth:"20px"}})}class Vn extends a.Component{constructor(e){super(e),j(this,"_isMounted",void 0),j(this,"onDataLoaded",((e,t)=>{if(this._isMounted&&e.labels&&e.range){var r=e.labels.reduce(((e,t)=>G(G({},e),{},{[t.content]:!1})),{});this.setState({dataLoaded:!0,labelDataIsLocalized:t,labelsRendered:r,labels:e.labels,range:e.range})}})),j(this,"onImageLoad",(()=>{this.sizeProvided()?this.setState({imageLoaded:!0}):De.getImageSize(this.props.src,((e,t)=>{this._isMounted&&this.setState({imageLoaded:!0,imageDimensions:[e,t]})}))})),j(this,"setupGraphie",((e,t)=>{h.map(t.labels,(t=>{var{JIPT:r}=ae();if(r.useJIPT&&this.state.labelDataIsLocalized){var i=e.label(t.coordinates,t.content,t.alignment,!1);ae().svgImageJiptLabels.addLabel(i,t.typesetAsMath)}else if(t.coordinates){var n=e.label(t.coordinates,t.content,t.alignment,t.typesetAsMath,{"font-size":100*this.props.scale+"%"}),o=n[0].style,s=this._tryGetPixels(o.top),a=this._tryGetPixels(o.left);if(null===s||null===a){var l=n.position();s=l.top,a=l.left}var p=(this.props.height||0)*this.props.scale,c=(this.props.width||0)*this.props.scale;n.css({top:s/p*100+"%",left:a/c*100+"%"}),h.each(t.style,((e,t)=>{n.css(t,e)}))}this.setState({labelsRendered:G(G({},this.state.labelsRendered),{},{[t.content]:!0})})}))})),j(this,"_handleZoomClick",(e=>{(y(e.target).width()<this.props.width||this.props.zoomToFullSizeOnMobile)&&nr.handleZoomClick(e,this.props.zoomToFullSizeOnMobile),this.props.trackInteraction&&this.props.trackInteraction()})),j(this,"handleUpdate",(e=>{this.props.onUpdate(),De.isLabeledSVG(this.props.src)||"loaded"!==e||this.setState({imageLoaded:!0})})),e.setAssetStatus(e.src,!1),this._isMounted=!1,this.state={imageLoaded:!1,imageDimensions:null,dataLoaded:!1,labelDataIsLocalized:!1,labels:[],labelsRendered:{},range:[[0,0],[0,0]]}}componentDidMount(){this._isMounted=!0,De.isLabeledSVG(this.props.src)&&this.loadResources()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({imageLoaded:!1,dataLoaded:!1})}shouldComponentUpdate(e,t){return!h.isEqual(this.props,e)||this.isLoadedInState(this.state)!==this.isLoadedInState(t)}componentDidUpdate(e,t){var r=this.isLoadedInState(t),i=this.isLoadedInState(this.state);De.isLabeledSVG(this.props.src)&&!i&&this.loadResources(),!r&&i&&this.props.setAssetStatus(this.props.src,!0)}componentWillUnmount(){this._isMounted=!1}isLoadedInState(e){return De.isLabeledSVG(this.props.src)?e.imageLoaded&&e.dataLoaded:e.imageLoaded}loadResources(){var e=function(e){var t=e.match(zn);if(null==t)throw new ce("not a valid URL",pe.InvalidInput);return t&&t[1]}(this.props.src);if(Ln[e])if(Ln[e].loaded){var{data:t,localized:r}=Ln[e];this.onDataLoaded(t,r)}else Ln[e].dataCallbacks.push(this.onDataLoaded);else{var i={loaded:!1,dataCallbacks:[this.onDataLoaded],data:null,localized:qn()};Ln[e]=i;var n=(t,r)=>{!function(e,t){t=G({callbackName:"callback",success:y.noop,error:y.noop},t);var r=document.createElement("script");function i(){document.head&&document.head.removeChild(r),delete window[t.callbackName]}r.setAttribute("async",""),r.setAttribute("src",e),window[t.callbackName]=function(){i(),t.success.apply(null,arguments)},r.addEventListener("error",(function(){i(),t.error.apply(null,arguments)})),document.head&&document.head.appendChild(r)}(t,{callbackName:"svgData"+e,success:e=>{i.data=e,i.loaded=!0,h.each(i.dataCallbacks,(e=>{e(i.data,i.localized)}))},error:r})};qn()?n(function(e){if(Bn.test(e))return De.getDataUrl(e);var[t,r]=De.getBaseUrl(e).split(Un);return"".concat(t,"/").concat(Wn(),"/").concat(r,"-data.json")}(this.props.src),((e,t,r)=>{i.localized=!1,n(De.getDataUrl(this.props.src),((e,t,r)=>{he.error("Data load failed for svg-image",pe.Service,{cause:r,loggedMetadata:{dataUrl:De.getDataUrl(this.props.src),status:t}})}))})):n(De.getDataUrl(this.props.src),((e,t,r)=>{he.error("Data load failed for svg-image",pe.Service,{cause:r,loggedMetadata:{dataUrl:De.getDataUrl(this.props.src),status:t}})}))}}sizeProvided(){return null!=this.props.width&&null!=this.props.height}_tryGetPixels(e){return(e=e||"").endsWith("px")&&parseFloat(e)||null}render(){var e=this.props.src,t={alt:this.props.alt,title:this.props.title,tabIndex:"0"};this.props.alt&&this.props.overrideAriaHidden&&(t["aria-hidden"]=!0);var r,i=this.props.width&&this.props.width*this.props.scale,n=this.props.height&&this.props.height*this.props.scale,o={width:i,height:n},l=this.props.responsive&&!(!i||!n);this.props.extraGraphie&&this.props.extraGraphie.labels.length&&(r=a.createElement(Nn,{box:this.props.extraGraphie.box,range:this.props.extraGraphie.range,options:{labels:this.props.extraGraphie.labels},responsive:!0,addMouseLayer:!1,setup:this.setupGraphie}));var p=void 0===this.props.preloader?Gn:this.props.preloader,c=p?()=>p(o):null;if(!De.isLabeledSVG(e)){if(l){var d=s({zoomable:(i||0)>700,"svg-image":!0});return t.onClick=this._handleZoomClick,a.createElement(or,{className:d,width:i,height:n,constrainHeight:this.props.constrainHeight,allowFullBleed:this.props.allowFullBleed&&Hn(e)},a.createElement(Dn,{src:e,imgProps:t,preloader:c,onUpdate:this.handleUpdate}),r)}return t.style=o,a.createElement(Dn,{src:e,preloader:c,imgProps:t,onUpdate:this.handleUpdate})}var u,m=De.getSvgUrl(e);if(this.isLoadedInState(this.state)){var g;if(this.sizeProvided())g=[i,n];else{if(!this.state.imageDimensions)throw new ce("svg-image has no dimensions",pe.InvalidInput,{metadata:{src:this.props.src}});g=[this.state.imageDimensions[0]*this.props.scale,this.state.imageDimensions[1]*this.props.scale]}var f=[40*this.props.scale,40*this.props.scale];u=a.createElement(Nn,{ref:"graphie",box:g,scale:f,range:this.state.range,options:h.pick(this.state,"labels"),responsive:l,addMouseLayer:!1,setup:this.setupGraphie})}return l?a.createElement(or,{className:"svg-image",width:i,height:n,constrainHeight:this.props.constrainHeight},a.createElement(Dn,{src:m,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:c,imgProps:t}),u,r):(t.style=o,a.createElement("div",{className:"unresponsive-svg-image",style:o},a.createElement(Dn,{src:m,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:c,imgProps:t}),u))}}j(Vn,"defaultProps",{constrainHeight:!1,onUpdate:()=>{},responsive:!0,src:"",scale:1,zoomToFullSizeOnMobile:!1,setAssetStatus:(e,t)=>{}});class jn extends a.Component{constructor(e){super(e),j(this,"_hasRendered",void 0),j(this,"handleRender",(()=>{this.props.onRender(),this.setState({rendered:!0}),this.props.onRender(),this._hasRendered||(this._hasRendered=!0,this.props.setAssetStatus(this.props.children,!0))})),this.props.setAssetStatus(this.props.children,!1),this.state={rendered:!1},this._hasRendered=!1}render(){var{TeX:e}=ae();return a.createElement(e,{onRender:this.handleRender},this.props.children)}}j(jn,"defaultProps",{onRender:()=>{},setAssetStatus:(e,t)=>{}});class Yn extends a.Component{constructor(){super(...arguments),j(this,"_isMounted",void 0),j(this,"_observer",void 0),j(this,"_measuringInitialized",void 0),j(this,"_originalWidth",void 0),j(this,"_node",void 0),j(this,"state",{visible:!1,marginBottomPx:0,zoomed:!0}),j(this,"reset",(()=>{this._isMounted&&this.state.visible&&(this._originalWidth=null,this.setState({visible:!1,compactHeight:null,expandedHeight:null,zoomed:!0},(()=>{this.measureAndScaleChildToFit(!1)})))})),j(this,"stopPropagationIfZoomed",(e=>{this.state.zoomed||e.stopPropagation()})),j(this,"handleClickIfZoomed",(e=>{this.state.zoomed||(e.stopPropagation(),this.handleClick())})),j(this,"handleClick",(()=>{this.setState({zoomed:!this.state.zoomed})}))}componentDidMount(){this._isMounted=!0,this.maybeInitializeMeasuring()}componentDidUpdate(){this.maybeInitializeMeasuring()}componentWillUnmount(){window.removeEventListener("resize",this.reset),this._observer&&this._observer.disconnect(),this._isMounted=!1}maybeInitializeMeasuring(){var e=this.props.readyToMeasure&&!this._measuringInitialized;this._isMounted&&e&&(this._measuringInitialized=!0,this._node=v.findDOMNode(this),setTimeout((()=>this.measureAndScaleChildToFit(!1)),0),window.MutationObserver&&(this._observer=new MutationObserver((e=>{if(this._isMounted)for(var t of e)if(t.target!==this._node){this.measureAndScaleChildToFit(this.state.zoomed);break}})),this._observer.observe(this._node,{childList:!0,subtree:!0,attributes:!0})),window.addEventListener("resize",this.reset))}measureAndScaleChildToFit(e){if(this._isMounted){var t={width:this._node.offsetWidth,height:this._node.offsetHeight},r=this.props.computeChildBounds(this._node,t),i=r.width+1,n=r.height+1;if(i>t.width){var o=t.width/i;this.setState({scale:o,zoomed:e,compactHeight:Math.ceil(o*n),expandedHeight:n}),setTimeout((()=>{this._isMounted&&this.setState({visible:!0})}))}else this.setState({visible:!0})}}render(){var{visible:e,scale:t,compactHeight:r,expandedHeight:i,zoomed:n}=this.state,{animateHeight:o}=this.props,s=o?"opacity transform height":"opacity transform",l=e?{transitionProperty:s,WebkitTransitionProperty:s,msTransitionProperty:s,transitionDuration:"0.3s",WebkitTransitionDuration:"0.3s",msTransitionDuration:"0.3s",transitionTimingFunction:"ease-out",WebkitTransitionTimingfunction:"ease-out",msTransitionTmingFunction:"ease-out"}:{},p=e?"":" translate(0, 8px)",h=(null!=t?t:1).toString(),c=n?"scale(1, 1) ".concat(p):"scale(".concat(h,", ").concat(h,") ").concat(p),d=G({display:"block",width:"100%",height:n?i:r,transform:c,WebkitTransform:c,msTransform:c,transformOrigin:"0 0",WebkitTransformOrigin:"0 0",msTransformOrigin:"0 0",opacity:e?1:0,WebkitTapHighlightColor:"transparent"},l);return a.createElement("span",{onClick:this.handleClick,onClickCapture:this.handleClickIfZoomed,onTouchCancelCapture:this.stopPropagationIfZoomed,onTouchEndCapture:this.stopPropagationIfZoomed,onTouchStartCapture:this.stopPropagationIfZoomed,style:d},this.props.children)}}j(Yn,"defaultProps",{animateHeight:!1,readyToMeasure:!0,computeChildBounds:e=>{var t=e.firstElementChild;return{width:t.offsetWidth,height:t.offsetHeight}}});var $n=(e,t)=>{var r=e.querySelector(".katex-html")||e.querySelector(".MathJax"),i={width:r.offsetWidth,height:r.offsetHeight};return{width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)}};class Xn extends a.Component{constructor(){super(),j(this,"handleRender",(()=>{this.setState({isRendered:!0})})),this.state={isRendered:!1}}render(){return a.createElement(Yn,{readyToMeasure:this.state.isRendered,computeChildBounds:$n},a.createElement(er.Consumer,null,(e=>{var{setAssetStatus:t}=e;return a.createElement(jn,{onRender:this.handleRender,setAssetStatus:t},this.props.children)})))}}class Kn extends a.Component{constructor(e){super(e),this.state={error:""}}componentDidCatch(e,t){this.setState({error:e.toString()}),he.error("Perseus error boundary caught error",pe.Internal,{cause:e,loggedMetadata:{info:t.toString()}})}render(){return this.state.error?a.createElement("svg",{height:"16",width:"16",viewBox:"0 0 16 16"},a.createElement("path",{d:"m8 16c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-3c0.55 0 1-0.45 1-1s-0.45-1-1-1-1 0.45-1 1 0.45 1 1 1zm0-9c-0.55 0-1 0.45-1 1v4c0 0.55.45 1 1 1s1-0.45 1-1v-4c0-0.55-0.45-1-1-1z",fill:"#d92916",fillRule:"evenodd"})):this.props.children}}function Zn(){}class Jn{constructor(e,t,r,i){j(this,"_tracked",void 0),j(this,"setting",void 0),j(this,"track",void 0),j(this,"trackApi",void 0),j(this,"widgetID",void 0),j(this,"widgetType",void 0),j(this,"_track",(e=>{this._tracked&&!this.setting||(this._tracked=!0,this.trackApi(G({type:this.widgetType,id:this.widgetID},e)))})),e?(this._tracked=!1,this.trackApi=e,this.widgetType=t,this.widgetID=r,this.setting=i,this.track=this._track):this.track=Zn}}var Qn={fence:{match:u.defaultRules.fence.match,order:1,parse:(e,t,r)=>e[3]},paragraph:{match:u.defaultRules.paragraph.match,order:2,parse:(e,t,r)=>e[1]}},eo=u.parserFor(Qn),to={parseToArray:e=>{var t=e.replace(/^\n\s*\n/,"")+"\n\n";return eo(t,{inline:!1})},joinFromArray:e=>e.join("\n\n")};class ro{constructor(){j(this,"previousContent",null),j(this,"runLinter",c(((e,t)=>{"undefined"!=typeof KA&&e!==this.previousContent&&(this.previousContent=e,""!==e?fetch("/api/internal/translations/lint_poentry?preview=1&lang=en",{headers:{"Content-Type":"application/json"},body:JSON.stringify({msgid:e,msgstr:e,format:"perseus_text",filename:""}),method:"POST"}).then((e=>e.status>=400?{status:"error",message:"Could not run i18n linter."}:e.json()),(e=>({status:"error",message:"Could not run i18n linter."}))).then((e=>{"error"===e.status?t(["Some part of this text makes it untranslatable. The specific message from the i18n linter was: "+e.message.replace(/\n/g," ")]):t([])})):t([]))}),1e3))}applyLintErrors(e,t){if(t.length){var r=t.join("\n\n");e.unshift({content:{type:"text",content:""},insideTable:!1,message:r,ruleName:"legacy-error",severity:st.Severity.ERROR,type:"lint"})}}}class io extends a.Component{render(){var e=this.props.className?"paragraph "+this.props.className:"paragraph";return a.createElement("div",{className:e,"data-perseus-component-index":this.props.translationIndex,"data-perseus-paragraph-index":this.props.paragraphIndex},this.props.children)}}var no=e=>e.replace(/\{align[*]?\}/g,"{aligned}").replace(/[\u00a0]/g," "),{interactiveSizes:oo}=re,so={SMALL:"small",MEDIUM:"medium",LARGE:"large",XLARGE:"xlarge"},ao=e=>e?e<=512?so.SMALL:e<=688?so.MEDIUM:so.LARGE:so.MEDIUM,lo=e=>e===so.SMALL?[oo.defaultBoxSizeSmall,oo.defaultBoxSizeSmall]:[oo.defaultBoxSize,oo.defaultBoxSize],po=Object.freeze({__proto__:null,containerSizeClass:so,getClassFromWidth:ao,getInteractiveBoxFromSizeClass:lo}),ho=["default"],co={},uo={},mo=(e,t)=>{co[e]=t},go=e=>{e.forEach((e=>{mo(e.name,e)})),_o()},fo=e=>h.has(co,e)?co[e].getWidget?co[e].getWidget():co[e].widget:null,vo=e=>co[e]?co[e].version||{major:0,minor:0}:null,yo=()=>{var e={};return h.each(h.keys(co),(function(t){e[t]=vo(t)})),e},bo=e=>{var t=co[e.type].accessible;return"function"==typeof t?t(e.options):!!t},xo=e=>{var t=e.type;if(!h.isString(t))throw new ce("widget type must be a string, but was: "+t,pe.Internal);var r=co[t];if(null==r)return e;var i=e.version||{major:0,minor:0},n=r.version||{major:0,minor:0};if(i.major>n.major||i.major===n.major&&i.minor>n.minor)return e;var o=h.clone(e.options)||{},s=r.propUpgrades||{};if(0!==h.keys(o).length)for(var a=i.major+1;a<=n.major;a++)s[String(a)]?o=s[String(a)](o):he.error("No upgrade found for widget. Cannot render.",pe.Internal,{loggedMetadata:{type:t,fromMajorVersion:a-1,toMajorVersion:a}});o=G(G({},t in uo?uo[t].defaultProps:{}),o);var l=e.alignment;null!=l&&"default"!==l||(l=ko(t)[0]);var p=e.static;return null==p&&(p=false),h.extend({},e,{version:n,graded:null==e.graded||e.graded,alignment:l,static:p,options:o})},wo=(e,t)=>{var r=e.type,i=co[r];return null==i?e.options:(e.static?Mo(r)||h.identity:i.transform||h.identity)(e.options,t)},Co=(e,t)=>{if(!t)throw new ce("traverseRenderer must be provided, but was not",pe.Internal);if(!e||!e.type||!co[e.type])return e;var r=co[e.type],i=e.options;if(r.traverseChildWidgets&&i){var n=r.traverseChildWidgets(i,t);return h.extend({},e,{options:n})}return e},ko=e=>{var t=co[e];return t&&t.supportedAlignments||ho},Eo=e=>{var t=co[e];return t&&(t.getDefaultAlignment?t.getDefaultAlignment():t.defaultAlignment)||"block"},So=["block","inline-block","inline","float-left","float-right","full-width"],_o=()=>{h.each(co,(function(e){if(e.defaultAlignment&&!h.contains(So,e.defaultAlignment))throw new ce("Widget '"+e.displayName+"' has an invalid defaultAlignment value: "+e.defaultAlignment,pe.InvalidInput);if(e.supportedAlignments){var t=h.difference(e.supportedAlignments,So);if(t.length)throw new ce("Widget '"+e.displayName+"' has an invalid value for supportedAlignments: "+t.join(" "),pe.InvalidInput)}}))},Mo=e=>{var t=co[e];return t&&t.staticTransform},To=e=>{var t=co[e];return t&&t.tracking||""},Io=e=>{var t=co[e];return t&&t.isLintable||false},Po=Object.freeze({__proto__:null,registerWidget:mo,registerWidgets:go,registerEditors:e=>{e.forEach((e=>{if(!e.widgetName)throw new ce("Editor ".concat(e.displayName," doesn't have a widgetName property"),pe.Internal);uo[e.widgetName]=e}))},getWidget:fo,getEditor:e=>h.has(uo,e)?uo[e]:null,getTransform:e=>h.has(co,e)?co[e].transform||h.identity:null,getVersion:vo,getVersionVector:yo,getPublicWidgets:()=>h.pick(co,h.reject(h.keys(co),(function(e){return co[e].hidden}))),isAccessible:bo,getAllWidgetTypes:()=>h.keys(co),upgradeWidgetInfoToLatestVersion:xo,getRendererPropsForWidgetInfo:wo,traverseChildWidgets:Co,getSupportedAlignments:ko,getDefaultAlignment:Eo,validateAlignments:_o,supportsStaticMode:e=>{var t=co[e];return t&&null!=t.staticTransform},getStaticTransform:Mo,getTracking:To,isLintable:Io});class No extends a.Component{constructor(){super(...arguments),j(this,"state",{sizeClass:so.MEDIUM,widgetProps:this.props.initialProps}),j(this,"getWidget",(()=>this.refs.widget)),j(this,"replaceWidgetProps",(e=>{this.setState({widgetProps:e})}))}componentDidMount(){if(this.state.widgetProps.apiOptions.isMobile){var e=v.findDOMNode(this).offsetWidth;this.setState({sizeClass:ao(e)})}}render(){var e=s({"perseus-widget-container":!0,"widget-highlight":this.props.shouldHighlight,"widget-nohighlight":!this.props.shouldHighlight}),t=this.props.type,r=fo(t);if(null==r)return console.warn("Widget type '".concat(t,"' not found!")),a.createElement("div",{className:e});var i=this.state.widgetProps.alignment;"default"===i&&(i=Eo(t)),e+=" widget-"+i;var n=this.state.widgetProps.apiOptions,o=this.state.widgetProps.static||n.readOnly,l={width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:3},p=Io(t)?this.props.linterContext:G(G({},this.props.linterContext),{},{highlightLint:!1});return a.createElement("div",{className:e,style:o?{position:"relative",overflow:"visible"}:{}},a.createElement(r,Y({},this.state.widgetProps,{linterContext:p,containerSizeClass:this.state.sizeClass,ref:"widget"})),o&&a.createElement("div",{style:l}))}UNSAFE_componentWillReceiveProps(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(e,t){return this.props.shouldHighlight!==e.shouldHighlight||this.props.type!==e.type||this.state.widgetProps!==t.widgetProps||this.state.sizeClass!==t.sizeClass}}j(No,"defaultProps",{linterContext:Vt});var{mapObject:Ao,mapObjectFromArray:Ro}=_r,Fo=/\S/,Oo=/(web\+graphie|https):\/\/[^\s]*/,Do=()=>{},Lo=["content","problemNum","widgets"];class Bo extends a.Component{constructor(e,t){var r;super(e,t),r=this,j(this,"_currentFocus",void 0),j(this,"_foundTextNodes",void 0),j(this,"_interactionTrackers",void 0),j(this,"_isMounted",void 0),j(this,"_isTwoColumn",void 0),j(this,"_notGorgon",void 0),j(this,"lastRenderedMarkdown",void 0),j(this,"reuseMarkdown",void 0),j(this,"translationIndex",void 0),j(this,"widgetIds",void 0),j(this,"getApiOptions",(()=>G(G({},Zt.defaults),this.props.apiOptions))),j(this,"_getInitialWidgetState",(e=>{var t=this._getAllWidgetsInfo(e);return{widgetInfo:t,widgetProps:this._getAllWidgetsStartProps(t,e)}})),j(this,"_getAllWidgetsInfo",(e=>Ao(e.widgets,((e,t)=>{if(!e.type||!e.alignment){var r={};e.type||(r.type=t.split(" ")[0]),e.alignment||(r.alignment="default"),e=h.extend({},e,r)}return xo(e)})))),j(this,"_getAllWidgetsStartProps",((e,t)=>Ao(e,(e=>wo(e,t.problemNum))))),j(this,"_getDefaultWidgetInfo",(e=>{var t=De.rTypeFromWidgetId.exec(e);return null==t?{}:{type:t[1],graded:!0,options:{}}})),j(this,"_getWidgetInfo",(e=>this.state.widgetInfo[e]||this._getDefaultWidgetInfo(e))),j(this,"renderWidget",((e,t,r)=>{var i=this.state.widgetInfo[t];if(i&&"full-width"===i.alignment&&(r.foundFullWidth=!0),i){var n=i&&i.type||e,o=h.contains(this.props.highlightedWidgets,t);return a.createElement(Kn,{key:"container:"+t},a.createElement(No,{ref:"container:"+t,type:n,initialProps:this.getWidgetProps(t),shouldHighlight:o,linterContext:Ut.pushContextStack(this.props.linterContext,"widget")}))}return null})),j(this,"getWidgetProps",(e=>{var t=this.getApiOptions(),i=this.state.widgetProps[e]||{},n=null,o=this.state.widgetInfo[e];this.props.reviewMode&&o&&(n=o.options),this._interactionTrackers||(this._interactionTrackers={});var s=this._interactionTrackers[e];return s||(s=this._interactionTrackers[e]=new Jn(t.trackInteraction,o&&o.type,e,To(o&&o.type))),G(G({},i),{},{ref:e,widgetId:e,alignment:o&&o.alignment,static:o&&o.static&&!this.props.problemNum,problemNum:this.props.problemNum,apiOptions:this.getApiOptions(),keypadElement:this.props.keypadElement,questionCompleted:this.props.questionCompleted,onFocus:h.partial(this._onWidgetFocus,e),onBlur:h.partial(this._onWidgetBlur,e),findWidgets:this.findWidgets,reviewModeRubric:n,onChange:function(t,i){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r._setWidgetProps(e,t,i,n)},trackInteraction:s.track,isLastUsedWidget:e===this.state.lastUsedWidgetId})})),j(this,"getSerializedState",(e=>Ao(e||this.state.widgetProps,((e,t)=>{var r=this.getWidgetInstance(t);return r&&r.getSerializedState?r.getSerializedState():e})))),j(this,"restoreSerializedState",((e,t)=>{var r=h.keys(e),i=h.keys(this.state.widgetProps);if(r.length===i.length&&h.intersection(r,i).length===r.length){var n=1,o=()=>{--n,t&&0===n&&t()};this.setState({widgetProps:Ao(e,((e,t)=>{var r=this.getWidgetInstance(t);if(r&&r.restoreSerializedState){++n;var i=r.restoreSerializedState(e,o);return h.extend({},this.state.widgetProps[t],i)}return e}))},(()=>{setTimeout(o,0)}))}else he.error("Refusing to restore bad serialized state:",pe.Internal,{loggedMetadata:{serializedState:JSON.stringify(e),currentProps:JSON.stringify(this.state.widgetProps)}})})),j(this,"showRationalesForCurrentlySelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{var t=this.getWidgetInstance(e);t&&t.showRationalesForCurrentlySelectedChoices&&t.showRationalesForCurrentlySelectedChoices(this._getWidgetInfo(e).options)}))})),j(this,"deselectIncorrectSelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{var t=this.getWidgetInstance(e);t&&t.deselectIncorrectSelectedChoices&&t.deselectIncorrectSelectedChoices()}))})),j(this,"findInternalWidgets",(e=>{var t;if("string"==typeof e)if(-1!==e.indexOf(" ")){var r=e;t=(e,t,i)=>e===r}else{var i=e;t=(e,t,r)=>t.type===i}else t=e;return this.widgetIds.filter((e=>{var r=this._getWidgetInfo(e),i=this.getWidgetInstance(e);return t(e,r,i)})).map(this.getWidgetInstance)})),j(this,"findWidgets",(e=>[...this.findInternalWidgets(e),...this.props.findExternalWidgets(e)])),j(this,"getWidgetInstance",(e=>{var t=this.refs["container:"+e];return t?t.getWidget():null})),j(this,"_onWidgetFocus",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!h.isArray(t))throw new ce("widget props.onFocus focusPath must be an Array, but was"+JSON.stringify(t),pe.Internal);r._setCurrentFocus([e].concat(t))})),j(this,"_onWidgetBlur",((e,t)=>{var r=this._currentFocus,i=[e].concat(t);h.isEqual(i,r)&&h.defer((()=>{h.isEqual(this._currentFocus,r)&&this._setCurrentFocus(null)}))})),j(this,"getContent",((e,t)=>t.jiptContent||e.content)),j(this,"shouldRenderJiptPlaceholder",((e,t)=>ae().JIPT.useJIPT&&null==t.jiptContent&&-1!==e.content.indexOf("crwdns"))),j(this,"replaceJiptContent",((e,t)=>{if(null==t)this.setState({jiptContent:e});else{/^\s*(`{3,}|~{3,})\s*(\S+)?\s*\n([\s\S]+?)\s*\1\s*$/.test(e)||(/\S\n\s*\n\S/.test(e)?e="$\\large{\\red{\\text{Please translate each paragraph to a single paragraph.}}}$":/^\s*$/.test(e)&&(e="$\\large{\\red{\\text{Translated paragraph is currently empty}}}$"));var r=this.getContent(this.props,this.state),i=to.parseToArray(r);i[t]=e,this.setState({jiptContent:to.joinFromArray(i)})}})),j(this,"outputMarkdown",((e,t)=>{if(h.isArray(e)){for(var r=t.key,i=[],n=!1,o=0;o<e.length;o++){t.key=o,t.paragraphIndex=o;var l=this.outputMarkdown(e[o],t),p="string"==typeof l;"string"==typeof l&&n?i[i.length-1]+=l:i.push(l),n=p}return t.key=r,i}this._foundTextNodes=!1,t.foundFullWidth=!1;var c,d=this.outputNested(e,t);return c=null!=this.translationIndex?null:s({"perseus-paragraph-centered":!this._foundTextNodes,"perseus-paragraph-full-width":t.foundFullWidth&&1===e.content.length}),a.createElement(io,{key:t.key,className:c,translationIndex:this.translationIndex,paragraphIndex:t.paragraphIndex},a.createElement(Kn,null,d))})),j(this,"outputNested",((e,t)=>{if(h.isArray(e)){for(var r=t.key,i=[],n=!1,o=0;o<e.length;o++){t.key=o;var s=this.outputNested(e[o],t),a="string"==typeof s;"string"==typeof s&&n?i[i.length-1]+=s:i.push(s),n=a}return t.key=r,i}return this.outputNode(e,this.outputNested,t)})),j(this,"outputNode",((e,t,r)=>{var i=this.getApiOptions(),n=i.imagePlaceholder;if("widget"===e.type){var o=i.widgetPlaceholder;return o||(this._foundTextNodes=!0,h.contains(this.widgetIds,e.id)?a.createElement("span",{key:r.key,className:"renderer-widget-error"},["Widget [[","☃"," ",e.id,"]] already exists."].join("")):(this.widgetIds.push(e.id),this.renderWidget(e.widgetType,e.id,r)))}if("blockMath"===e.type){var s=no(e.content),l={overflowX:"auto",overflowY:"hidden",paddingTop:10,paddingBottom:10,marginTop:-10,marginBottom:-10};if(i.isMobile){var p={marginLeft:-16,marginRight:-16},c={paddingLeft:16,paddingRight:16},d=G(G({},l),zo.mobileZoomableParentFix);return a.createElement("div",{key:r.key,className:"perseus-block-math",style:p},a.createElement(Kn,null,a.createElement("div",{className:"perseus-block-math-inner",style:G(G({},d),c)},a.createElement(Xn,null,s))))}return a.createElement("div",{key:r.key,className:"perseus-block-math"},a.createElement(Kn,null,a.createElement("div",{className:"perseus-block-math-inner",style:l},a.createElement(er.Consumer,null,(e=>{var{setAssetStatus:t}=e;return a.createElement(jn,{setAssetStatus:t},s)})))))}if("math"===e.type){var u=e.content.replace(/\{align[*]?\}/g,"{aligned}");return a.createElement("span",{key:r.key,style:{whiteSpace:"nowrap"}},a.createElement(Kn,null,a.createElement("span",null),a.createElement(er.Consumer,null,(e=>{var{setAssetStatus:t}=e;return a.createElement(jn,{onRender:this.props.onRender,setAssetStatus:t},u)})),a.createElement("span",null)))}if("image"===e.type){if(n)return n;var m=h.has(this.props.images,e.target)?this.props.images[e.target]:null,g=!r.inTable;return a.createElement(Kn,{key:r.key},a.createElement(er.Consumer,null,(t=>{var{setAssetStatus:r}=t;return a.createElement(Vn,Y({setAssetStatus:r,src:$e.sanitizeUrl(e.target),alt:e.alt,title:e.title,responsive:g,onUpdate:this.props.onRender,zoomToFullSizeOnMobile:i.isMobile&&i.isArticle},m))})))}if("columns"===e.type)return this._isTwoColumn=!0,a.createElement(Kn,{key:r.key},$e.ruleOutput(e,t,r));if("text"===e.type)return Fo.test(e.content)&&(this._foundTextNodes=!0),n&&Oo.test(e.content)?n:e.content;if("table"===e.type||"titledTable"===e.type){var f=$e.ruleOutput(e,t,G(G({},r),{},{isMobile:i.isMobile,inTable:!0}));if(!i.isMobile)return f;var v={marginLeft:-16,marginRight:-16},y=G(G({},{paddingLeft:0,paddingRight:0}),zo.mobileZoomableParentFix),b=a.createElement("div",{style:G(G({},y),{},{overflowX:"auto"})},a.createElement(Kn,null,a.createElement(Yn,{animateHeight:!0},f)));return a.createElement("div",{style:v},b)}return a.createElement(Kn,{key:r.key},$e.ruleOutput(e,t,r))})),j(this,"handleRender",(e=>{var t=this.props.onRender,r=e.onRender;if(t!==Do||r!==Do){var i=y(v.findDOMNode(this)).find("img");r!==Do&&i.off("load",r),t!==Do&&i.on("load",t)}t()})),j(this,"_setCurrentFocus",(e=>{var t,r,i=this.getApiOptions();if(t=e,r=this._currentFocus,!(null===t||null===r?t===r:h.every(t,((e,t)=>{if(null!=r)return h.isEqual(e,r[t])})))){var n=this._currentFocus;n&&this.blurPath(n),this._currentFocus=e,i.onFocusChange(this._currentFocus,n)}})),j(this,"focus",(()=>{for(var e,t,r,i=0;i<this.widgetIds.length;i++){var n=this.widgetIds[i],o=this.getWidgetInstance(n),s=o&&o.focus&&o.focus();if(s){e=n,t=s;break}}if(e)return"object"==typeof t?(r=[e].concat(t.path||[]),he.error("Renderer received a focus result of type 'object' instead of the expected type 'boolean'",pe.Internal,{loggedMetadata:{focusResult:JSON.stringify(t),currentProps:JSON.stringify(this.state.widgetProps)}})):r=[e],this._setCurrentFocus(r),!0})),j(this,"getDOMNodeForPath",(e=>{var t=h.first(e),r=h.rest(e),i=this.getWidgetInstance(t),n=i&&i.getDOMNodeForPath;return n?n(r):0===r.length?v.findDOMNode(i):void 0})),j(this,"getGrammarTypeForPath",(e=>{var t=h.first(e),r=h.rest(e),i=this.getWidgetInstance(t);if(i&&i.getGrammarTypeForPath)return i.getGrammarTypeForPath(r)})),j(this,"getInputPaths",(()=>{var e=[];return h.each(this.widgetIds,(t=>{var r=this.getWidgetInstance(t);if(r&&r.getInputPaths){var i=r.getInputPaths();h.each(i,(r=>{var i=[t].concat(r);e.push(i)}))}})),e})),j(this,"focusPath",(e=>{if(!h.isEqual(this._currentFocus,e)){this._currentFocus&&this.blurPath(this._currentFocus);var t=h.first(e),r=h.rest(e),i=this.getWidgetInstance(t);i&&i.focusInputPath&&i.focusInputPath(r)}})),j(this,"blurPath",(e=>{if(h.isEqual(this._currentFocus,e)){var t=h.first(e),r=h.rest(e);if(this.getWidgetInstance(t)){var i=this.getWidgetInstance(t);i&&i.blurInputPath&&i.blurInputPath(r)}}})),j(this,"blur",(()=>{this._currentFocus&&this.blurPath(this._currentFocus)})),j(this,"serialize",(()=>{var e={};return h.each(this.state.widgetInfo,(function(t,r){var i=this.getWidgetInstance(r).serialize();h.isEmpty(i)||(e[r]=i)}),this),e})),j(this,"emptyWidgets",(()=>h.filter(this.widgetIds,(e=>{var t=this._getWidgetInfo(e);if(t.static)return!1;var r=this.getWidgetInstance(e);if(r&&r.simpleValidate){var i=r.simpleValidate(t.options,null);return De.scoreIsEmpty(i)}})))),j(this,"_setWidgetProps",((e,t,r,i)=>{this.setState((r=>{var n=G(G({},r.widgetProps),{},{[e]:G(G({},r.widgetProps[e]),t)}),o=i?r.lastUsedWidgetId:e;return i||this.props.onSerializedStateUpdated(this.getSerializedState(n)),{lastUsedWidgetId:o,widgetProps:n}}),(()=>{setTimeout((()=>{var t=r&&r();i||this.props.onInteractWithWidget(e),!1!==t&&this._setCurrentFocus([e])}),0)}))})),j(this,"setInputValue",((e,t,r)=>{var i,n=h.first(e),o=h.rest(e),s=this.getWidgetInstance(n);null==s||null===(i=s.setInputValue)||void 0===i||i.call(s,o,t,r)})),j(this,"getUserInput",(()=>this.widgetIds.map((e=>{var t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),j(this,"getWidgetIds",(()=>this.widgetIds)),j(this,"getUserInputForWidgets",(()=>Ro(this.widgetIds,(e=>{var t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),j(this,"scoreWidgets",(()=>{var e=this.state.widgetInfo,t=this.getApiOptions().onInputError,r=h.filter(this.widgetIds,(t=>{var r=e[t],i=null==(null==r?void 0:r.graded)||r.graded,n=!(null==r||!r.static);return i&&!n})),i={};return h.each(r,(r=>{var n=e[r],o=this.getWidgetInstance(r);o&&o.simpleValidate&&(i[r]=o.simpleValidate(null==n?void 0:n.options,t))})),i})),j(this,"score",(()=>h.reduce(this.scoreWidgets(),De.combineScores,De.noScore))),j(this,"guessAndScore",(()=>[this.getUserInput(),this.score()])),j(this,"examples",(()=>{var e=this.widgetIds,t=h.compact(h.map(e,(e=>{var t=this.getWidgetInstance(e);return null!=t&&t.examples?t.examples():null})));return t.length&&h.all(t,(function(e){return h.isEqual(t[0],e)}))?t[0]:null})),j(this,"handleNotGorgonLintErrors",(e=>{this._isMounted&&this.setState({notGorgonLintErrors:e})})),this._notGorgon=new ro,this.state=G({jiptContent:null,notGorgonLintErrors:[],lastUsedWidgetId:null},this._getInitialWidgetState(e))}componentDidMount(){this._isMounted=!0,this.handleRender({}),this._currentFocus=null,this.props.serializedState&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}UNSAFE_componentWillReceiveProps(e){h.isEqual(h.pick(this.props,Lo),h.pick(e,Lo))||this.setState(this._getInitialWidgetState(e))}shouldComponentUpdate(e,t){if(this.props.alwaysUpdate)return!0;var r=!h.isEqual(this.state,t);return!h.isEqual(this.props,e)||r}UNSAFE_componentWillUpdate(e,t){var r=this.shouldRenderJiptPlaceholder(this.props,this.state),i=this.shouldRenderJiptPlaceholder(e,t),n=this.getContent(this.props,this.state),o=this.getContent(e,t),s=this.props.highlightedWidgets,a=e.highlightedWidgets;this.reuseMarkdown=!r&&!i&&n===o&&h.isEqual(this.state.notGorgonLintErrors,t.notGorgonLintErrors)&&(!this.props.linterContext.highlightLint||h.isEqual(this.props.widgets,e.widgets))&&this.props.linterContext.highlightLint===e.linterContext.highlightLint&&s===a}componentDidUpdate(e,t){this.handleRender(e),h.each(this.widgetIds,(e=>{var t=this.refs["container:"+e];t&&t.replaceWidgetProps(this.getWidgetProps(e))})),this.props.serializedState&&!h.isEqual(this.props.serializedState,this.getSerializedState())&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}componentWillUnmount(){this.widgetIds=[],null!=this.translationIndex&&ae().rendererTranslationComponents.removeComponentAtIndex(this.translationIndex),this._isMounted=!1}render(){var e=this.getApiOptions(),{KatexProvider:t}=ae();if(this.reuseMarkdown)return this.lastRenderedMarkdown;var r=this.getContent(this.props,this.state);if(this.widgetIds=[],this.shouldRenderJiptPlaceholder(this.props,this.state)&&(this.translationIndex||(this.translationIndex=ae().rendererTranslationComponents.addComponent(this)),!e.isArticle))return a.createElement(t,null,a.createElement("div",{"data-perseus-component-index":this.translationIndex},r));this._isTwoColumn=!1;var i=$e.parse(r,{isJipt:null!=this.translationIndex});if(this.props.linterContext.highlightLint){var n=G({content:this.props.content,widgets:this.props.widgets},this.props.linterContext);Ut.runLinter(i,n,!0),this._notGorgon.applyLintErrors(i,[...this.state.notGorgonLintErrors,...this.props.legacyPerseusLint||[]])}var o=this.outputMarkdown(i,{baseElements:e.baseElements}),l=s({[Jt.RENDERER]:!0,[Jt.RESPONSIVE_RENDERER]:!0,[Jt.TWO_COLUMN_RENDERER]:this._isTwoColumn});return this.lastRenderedMarkdown=a.createElement(t,null,a.createElement("div",{className:l},o)),this.lastRenderedMarkdown}}j(Bo,"defaultProps",{content:"",widgets:{},images:{},highlightedWidgets:[],questionCompleted:!1,onRender:Do,onInteractWithWidget:function(){},findExternalWidgets:()=>[],alwaysUpdate:!1,reviewMode:!1,serializedState:null,onSerializedStateUpdated:()=>{},linterContext:Vt});var zo={mobileZoomableParentFix:{transform:"translate3d(0,0,0)"}},Ho={fontSize:"150%"},Wo={fontSize:"120%"},qo={fontSize:"130%"},Uo=[()=>[a.createElement("span",{key:"plus",style:Wo},"+"),"+"],()=>[a.createElement("span",{key:"minus",style:Ho},"-"),"-"],e=>{var{TeX:t}=ae();return e.convertDotToTimes?[a.createElement(t,{key:"times",style:Ho},o.doNotTranslate("\\times")),"\\times"]:[a.createElement(t,{key:"times",style:Ho},o.doNotTranslate("\\cdot")),"\\cdot"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"frac",style:Ho},o.doNotTranslate("\\frac{x}{y}")),e=>{var t=e.latex();e.typedText("/"),e.latex()===t&&e.cmd("\\frac")}]}],Go={basic:Uo,"basic+div":Uo.concat([()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"div"},o.doNotTranslate("\\div")),"\\div"]}]),trig:[()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"sin"},o.doNotTranslate("\\sin")),"\\sin"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"cos"},o.doNotTranslate("\\cos")),"\\cos"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"tan"},o.doNotTranslate("\\tan")),"\\tan"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"theta",style:qo},o.doNotTranslate("\\theta")),"\\theta"]},()=>{var{TeX:e}=ae();return[a.createElement("span",{key:"phi"},a.createElement("span",{className:"perseus-sr-only"},o.doNotTranslate("phi")),a.createElement(e,{key:"pi",style:qo},o.doNotTranslate("\\phi"))),"\\phi"]}],prealgebra:[()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"sqrt"},o.doNotTranslate("\\sqrt{x}")),"\\sqrt"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"nthroot"},o.doNotTranslate("\\sqrt[3]{x}")),e=>{e.typedText("nthroot3"),e.keystroke("Right")}]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"pow",style:Wo},o.doNotTranslate("a^b")),e=>{var t=e.latex();e.typedText("^"),e.latex()===t&&e.typedText("a^b")}]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"pi",style:Wo},o.doNotTranslate("\\pi")),"\\pi"]}],logarithms:[()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"log"},o.doNotTranslate("\\log")),"\\log"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"ln"},o.doNotTranslate("\\ln")),"\\ln"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"log_b"},o.doNotTranslate("\\log_b")),e=>{e.typedText("log_"),e.keystroke("Right"),e.typedText("("),e.keystroke("Left"),e.keystroke("Left")}]}],"basic relations":[()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"eq"},"="),"="]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"lt"},o.doNotTranslate("\\lt")),"\\lt"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"gt"},o.doNotTranslate("\\gt")),"\\gt"]}],"advanced relations":[()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"neq"},o.doNotTranslate("\\neq")),"\\neq"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"leq"},o.doNotTranslate("\\leq")),"\\leq"]},()=>{var{TeX:e}=ae();return[a.createElement(e,{key:"geq"},o.doNotTranslate("\\geq")),"\\geq"]}]},Vo=d.arrayOf(d.oneOf(h(Go).keys()));class jo extends a.Component{render(){var e=h.sortBy(this.props.sets,(e=>h.keys(Go).indexOf(e))),t=h(e).map((e=>Go[e])),r=h(t).map((e=>e.map((e=>{var t=e(this.props);return a.createElement("button",{onClick:()=>this.props.onInsert(t[1]),className:"tex-button",key:t[0].key,type:"button"},t[0])})))),i=h(r).map(((e,t)=>a.createElement("div",{className:"clearfix tex-button-row",key:this.props.sets[t]},e)));return a.createElement("div",{className:"".concat(this.props.className||""," preview-measure")},i)}}j(jo,"propTypes",{sets:Vo.isRequired,onInsert:d.func.isRequired,className:d.string}),j(jo,"buttonSets",Go),j(jo,"buttonSetsType",Vo);var Yo=d;class $o extends a.Component{constructor(){super(...arguments),j(this,"mouseDown",void 0),j(this,"state",{focused:!1}),j(this,"handleFocus",(()=>{this.setState({focused:!0})})),j(this,"handleMouseDown",(e=>{var t=v.findDOMNode(this).contains(e.target);this.mouseDown=t,t||this.setState({focused:!1})})),j(this,"handleMouseUp",(()=>{this.mouseDown&&this.focus(),this.mouseDown=!1})),j(this,"handleBlur",(e=>{this.mouseDown||v.findDOMNode(this).contains(e.relatedTarget)||this.setState({focused:!1})})),j(this,"_shouldShowButtons",(()=>"always"===this.props.buttonsVisible||"never"!==this.props.buttonsVisible&&this.state.focused)),j(this,"insert",(e=>{var t=this.mathField();h(e).isFunction()?e(t):"\\"===e[0]?t.cmd(e).focus():t.write(e).focus(),t.focus()})),j(this,"mathField",(e=>S.getInterface(2).MathField(v.findDOMNode(this.refs.mathinput),e))),j(this,"focus",(()=>{this.mathField().focus(),this.setState({focused:!0})})),j(this,"blur",(()=>{this.mathField().blur(),this.setState({focused:!1})}))}render(){var e=s({"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=a.createElement(jo,{sets:this.props.buttonSets,className:"math-input-buttons absolute",convertDotToTimes:this.props.convertDotToTimes,onInsert:this.insert})),a.createElement("div",{style:{display:"inline-block"}},a.createElement("div",{style:{display:"inline-block"}},a.createElement("span",{className:e,ref:"mathinput","aria-label":this.props.labelText,onFocus:this.handleFocus,onBlur:this.handleBlur})),a.createElement("div",{style:{position:"relative"},onBlur:this.handleBlur},t))}componentWillUnmount(){window.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}componentDidMount(){window.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp);var e=!1;this.mathField({autoCommands:"pi theta phi sqrt nthroot",charsThatBreakOutOfSupSub:"+-*/=<>≠≤≥",supSubsRequireOperand:!0,spaceBehavesLikeTab:!0,handlers:{edited:t=>{var r=t.latex();if(r=r.replace(/<>/g,"\\ne"),this.props.convertDotToTimes){r=r.replace(/\\cdot/g,"\\times");var i=t.__controller.cursor[S.L];i&&"\\cdot "===i.ctrlSeq&&(t.__controller.backspace(),t.cmd("\\times"))}else r=r.replace(/\\times/g,"\\cdot");e&&this.props.value!==r&&this.props.onChange(r)},enter:()=>{y(v.findDOMNode(this.refs.mathinput)).submit()},upOutOf:e=>{e.typedText("^")}}}),this.mathField().latex(this.props.value),e=!0}}function Xo(e,t,r){var i=e.indexOf("{",t)+1,n=function(e,t){for(var r=0,i=t,n=e.length;i<n;i++){var o=e[i];if("{"===o?r++:"}"===o&&r--,r<0)return i}return e.length}(e,i);return{endpoint:n,expression:Zo(e.substring(i,n),r)}}function Ko(e,t){var r=e.indexOf("\\frac",t),i=e.indexOf("\\dfrac",t);return r>-1&&i>-1?Math.min(r,i):r>-1?r:i>-1?i:-1}function Zo(e,t){if(!e)return"";for(var r="",i=0,n=Ko(e,i);n>-1;){r+=e.substring(i,n);var o=Xo(e,i=n,t),s=Xo(e,i=o.endpoint+1,t);i=s.endpoint+1,r.length&&(r+=" "),r+=t(o.expression,s.expression),n=Ko(e,i)}return r+=e.slice(i)}j($o,"propTypes",{value:Yo.string,onChange:Yo.func.isRequired,convertDotToTimes:Yo.bool,buttonsVisible:Yo.oneOf(["always","never","focused"]),buttonSets:jo.buttonSetsType.isRequired,labelText:d.string,onFocus:Yo.func,onBlur:Yo.func}),j($o,"defaultProps",{value:"",convertDotToTimes:!1,buttonsVisible:"focused"});var Jo=function(e){return Zo(e,(function(e,t){return e+"/"+t})).replace("\\%","%")},Qo=function(e){function t(e){return e.indexOf("\\frac")>-1||e.indexOf("\\dfrac")>-1}return Zo(e,(function(e,r){return(t(e)||t(r)?"\\dfrac":"\\frac")+" {"+e+"}{"+r+"}"}))};class es extends a.Component{constructor(){super(...arguments),j(this,"state",{focused:!1,selectorNamespace:h.uniqueId("math-output")}),j(this,"_getInputClassName",(()=>{var e="math-output "+Jt.INPUT+" "+Jt.INTERACTIVE;return this.state.focused&&(e+=" "+Jt.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),j(this,"_getDisplayValue",(e=>Qo(null!=e?""+e:""))),j(this,"getValue",(()=>this.props.value)),j(this,"focus",(()=>{this.state.focused||(this.props.onFocus(),this._bindBlurHandler(),this.setState({focused:!0}))})),j(this,"blur",(()=>{this.state.focused&&(this.props.onBlur(),this._unbindBlurHandler(),this.setState({focused:!1}))})),j(this,"_bindBlurHandler",(()=>{y(document).bind("vclick."+this.state.selectorNamespace,(e=>{y(e.target).closest(v.findDOMNode(this)).length||this.blur()}))})),j(this,"_unbindBlurHandler",(()=>{y(document).unbind("."+this.state.selectorNamespace)}))}render(){var{TeX:e}=ae();return a.createElement("span",{ref:"input",className:this._getInputClassName(),"aria-label":this.props.labelText,onMouseDown:this.focus,onTouchStart:this.focus},a.createElement("div",{style:{textAlign:"center"}},a.createElement(e,null,this._getDisplayValue(this.props.value))))}componentWillUnmount(){this._unbindBlurHandler()}}j(es,"propTypes",{value:d.oneOfType([d.string,d.number]),className:d.string,labelText:d.string,onFocus:d.func,onBlur:d.func}),j(es,"defaultProps",{value:"",onFocus:function(){},onBlur:function(){}});var ts=["labelText"];class rs extends a.Component{constructor(){super(...arguments),j(this,"focus",(()=>{v.findDOMNode(this).focus()})),j(this,"blur",(()=>{v.findDOMNode(this).blur()})),j(this,"getValue",(()=>{var e;return null===(e=v.findDOMNode(this))||void 0===e?void 0:e.value})),j(this,"getStringValue",(()=>{var e;return null===(e=v.findDOMNode(this))||void 0===e?void 0:e.value.toString()})),j(this,"setSelectionRange",((e,t)=>{v.findDOMNode(this).setSelectionRange(e,t)})),j(this,"getSelectionStart",(()=>v.findDOMNode(this).selectionStart)),j(this,"getSelectionEnd",(()=>v.findDOMNode(this).selectionEnd))}render(){var e=this.props,{labelText:t}=e,r=$(e,ts);return a.createElement("input",Y({},r,{type:"text","aria-label":t,onChange:e=>this.props.onChange(e.target.value)}))}}j(rs,"propTypes",{value:d.string,onChange:d.func.isRequired,className:d.string,labelText:d.string,onFocus:d.func,onBlur:d.func,disabled:d.bool}),j(rs,"defaultProps",{value:"",disabled:!1});var is=E({displayName:"Triangle",propTypes:{color:d.string.isRequired,left:d.number.isRequired,top:d.number.isRequired,width:d.number.isRequired,height:d.number.isRequired,horizontalDirection:d.oneOf(["left","right"]).isRequired,verticalDirection:d.oneOf(["top","bottom"]).isRequired},render:function(){var e,t,r,i,n="".concat(this.props.width,"px solid transparent");"right"===this.props.horizontalDirection?e=n:t=n;var o="".concat(this.props.height,"px solid ").concat(this.props.color);return"top"===this.props.verticalDirection?r=o:i=o,a.createElement("div",{style:{display:"block",height:0,width:0,position:"absolute",left:this.props.left,top:this.props.top,borderLeft:e,borderRight:t,borderTop:r,borderBottom:i}})}}),ns=E({displayName:"TooltipArrow",propTypes:{position:d.string,visibility:d.string,left:d.number,top:d.number,color:d.string.isRequired,border:d.string.isRequired,width:d.number.isRequired,height:d.number.isRequired,horizontalDirection:d.oneOf(["left","right"]).isRequired,verticalDirection:d.oneOf(["top","bottom"]).isRequired},getDefaultProps:function(){return{position:"relative",visibility:"visible",left:0,top:0}},render:function(){var e="top"===this.props.verticalDirection,t=e?0:1,r=e?0:-1;return a.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:10}},a.createElement(is,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.border,left:0,top:r,width:this.props.width+2,height:this.props.height+2}),a.createElement(is,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.color,left:1,top:t,width:this.props.width,height:this.props.height}))}}),os={top:{top:"-100%"},bottom:{top:0}},ss={left:{targetLeft:0},right:{targetLeft:"100%"}},as={left:{tooltipLeft:0,arrowLeft:e=>0},right:{tooltipLeft:"-100%",arrowLeft:e=>-e-2}},ls=E({displayName:"Tooltip",propTypes:{show:d.bool.isRequired,className:d.string,arrowSize:d.number,borderColor:d.string,verticalPosition:d.oneOf(Object.keys(os)),horizontalPosition:d.oneOf(Object.keys(ss)),horizontalAlign:d.oneOf(Object.keys(as)),children:d.arrayOf(d.element).isRequired,targetContainerStyle:d.any},getDefaultProps:function(){return{className:"",arrowSize:10,borderColor:"#ccc",verticalPosition:"bottom",horizontalPosition:"left",horizontalAlign:"left",targetContainerStyle:{}}},getInitialState:function(){return{height:null}},componentDidMount:function(){this._updateHeight()},UNSAFE_componentWillReceiveProps:function(){this.setState({height:null})},componentDidUpdate:function(){this._updateHeight()},_renderToolTipDiv:function(e){var t,r,i=Object.assign({},ss[this.props.horizontalPosition],as[this.props.horizontalAlign],os[this.props.verticalPosition]);return e?(t=a.createElement(ns,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,position:"absolute",color:"white",border:this.props.borderColor,left:i.arrowLeft(this.props.arrowSize),top:2-this.props.arrowSize,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),r=a.createElement(ns,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,visibility:"hidden",color:"white",border:this.props.borderColor,left:i.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10})):(t=a.createElement(ns,{verticalDirection:"bottom",horizontalDirection:this.props.horizontalAlign,color:"white",border:this.props.borderColor,left:i.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),r=null),a.createElement("div",{style:{position:"relative",height:0,display:this.props.show?"block":"none"}},a.createElement("div",{ref:"tooltipContainer",className:"tooltipContainer",style:{position:"absolute",height:this.state.height||void 0,left:i.targetLeft}},t,a.createElement("div",{className:this.props.className,ref:"tooltipContent",style:{position:"relative",top:i.top,left:i.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:9}},this.props.children.slice(1)),r))},_updateHeight:function(){var e=v.findDOMNode(this.refs.tooltipContainer).offsetHeight;e!==this.state.height&&this.setState({height:e})},render:function(){var e="top"===this.props.verticalPosition;return a.createElement("span",null,e&&this._renderToolTipDiv(e),a.createElement("div",{style:this.props.targetContainerStyle},this.props.children[0]),!e&&this._renderToolTipDiv())}}),{captureScratchpadTouchStart:ps}=De;class hs extends a.Component{constructor(){super(...arguments),j(this,"state",{focused:!1,showExamples:!1}),j(this,"_getUniqueId",(()=>"input-with-examples-".concat(btoa(this.props.id).replace(/=/g,"")))),j(this,"_getInputClassName",(()=>{if("tex"===this.props.type)return this.props.className;var e=Jt.INPUT+" "+Jt.INTERACTIVE;return this.state.focused&&(e+=" "+Jt.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),j(this,"_getPropsForInputType",(()=>{var e={"aria-describedby":this._getUniqueId(),ref:"input",className:this._getInputClassName(),labelText:this.props.labelText,value:this.props.value,onFocus:this._handleFocus,onBlur:this._handleBlur,disabled:this.props.disabled};return"tex"===this.props.type?e:(h.extend(e,{onChange:this.props.onChange,onTouchStart:ps}),"math"===this.props.type?h.extend({buttonSet:this.props.buttonSet,buttonsVisible:this.props.buttonsVisible,convertDotToTimes:this.props.convertDotToTimes},e):"text"===this.props.type?h.extend({autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:"false"},e):void 0)})),j(this,"_getComponentForInputType",(()=>{switch(this.props.type){case"tex":return es;case"math":return $o;case"text":return rs;default:return null}})),j(this,"_renderInput",(()=>{var e=this._getPropsForInputType(),t=this._getComponentForInputType();return a.createElement(t,e)})),j(this,"_handleFocus",(()=>{this.props.onFocus(),this.setState({focused:!0,showExamples:!0})})),j(this,"show",(()=>{this.setState({showExamples:!0})})),j(this,"hide",(()=>{this.setState({showExamples:!1})})),j(this,"_handleBlur",(()=>{this.props.onBlur(),this.setState({focused:!1,showExamples:!1})})),j(this,"focus",(()=>{this.refs.input.focus()})),j(this,"blur",(()=>{this.refs.input.blur()})),j(this,"handleChange",(e=>{this.props.onChange(e.target.value)}))}render(){var e=this._renderInput();if("tex"===this.props.type)return e;var t=h.map(this.props.examples,(e=>"- "+e)).join("\n"),r=this.props.shouldShowExamples&&this.state.showExamples;return a.createElement(ls,{ref:"tooltip",className:"perseus-formats-tooltip preview-measure",horizontalPosition:"left",horizontalAlign:"left",verticalPosition:"bottom",arrowSize:10,borderColor:"#ccc",show:r},e,a.createElement("div",{id:this._getUniqueId()},a.createElement(Bo,{content:t,linterContext:Ut.pushContextStack(this.props.linterContext,"input-with-examples")})))}}j(hs,"propTypes",{type:d.oneOf(["math","text","tex"]),value:d.string,onChange:d.func.isRequired,className:d.string,examples:d.arrayOf(d.string).isRequired,shouldShowExamples:d.bool,convertDotToTimes:d.bool,buttonSet:d.string,buttonsVisible:d.oneOf(["always","never","focused"]),labelText:d.string,onFocus:d.func,onBlur:d.func,disabled:d.bool,id:d.string.isRequired,linterContext:Gt}),j(hs,"defaultProps",{type:"text",shouldShowExamples:!0,onFocus:function(){},onBlur:function(){},disabled:!1,linterContext:Vt});var cs=["key","ref","containerSizeClass","widgetId","onChange","problemNum","apiOptions","questionCompleted","findWidgets","onRemove","id","onBlur","onFocus","trackInteraction","keypadElement"],ds='Usage:\n this.change({propName: 5}, callback);\n this.change("propName", 5, callback);\n this.change("propName")',us=function(e,t,r){var i=h.omit(e.props,cs),n=h.extend(i,t);e.props.onChange(n,r)},ms=function e(t,r,i,n){if(void 0===i)return h.partial(e,t,r);var o={};o[r]=i,us(t,o,n)},gs=function(e,t,r){if(h.isObject(e)&&void 0===r)return us(this,e,r=t);if("string"==typeof e)return ms(this,e,t,r);throw new ce("Invalid types sent to this.change(): "+h.toArray(arguments).join()+"\n"+ds,pe.Internal)},fs={onChange:d.func.isRequired},vs=Object.freeze({__proto__:null,change:gs,propTypes:fs}),ys=o._("Sorry, I don't understand that!"),bs=e=>e.replace(/([_^])([^{])/g,"$1{$2}");class xs extends a.Component{constructor(){var t;super(...arguments),t=this,j(this,"displayName","Expression"),j(this,"state",{showErrorTooltip:!1,showErrorText:!1}),j(this,"componentDidMount",(()=>{this._isMounted=!0})),j(this,"componentDidUpdate",(e=>{h.isEqual(this.props.value,e.value)&&h.isEqual(this.props.functions,e.functions)||(clearTimeout(this.errorTimeout),this.parse(this.props.value,this.props).parsed?this.setState({showErrorTooltip:!1}):this.errorTimeout=setTimeout((()=>{!1!==this.props.apiOptions.onInputError(null,this.props.value,ys)&&this.setState({showErrorTooltip:!0})}),2e3))})),j(this,"componentWillUnmount",(()=>{clearTimeout(this.errorTimeout),this._isMounted=!1})),j(this,"_isMounted",!1),j(this,"errorTimeout",null),j(this,"simpleValidate",((e,t)=>(t=t||function(){},xs.validate(this.getUserInput(),e,t)))),j(this,"getUserInput",(()=>xs.getUserInputFromProps(this.props))),j(this,"change",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return gs.apply(t,r)})),j(this,"parse",((t,r)=>{var i=h.pick(r||this.props,"functions");return h.extend(i,{decimal_separator:o.getDecimalSeparator()}),e.parse(bs(t),i)})),j(this,"changeAndTrack",((e,t)=>{this.change("value",e,t),this.props.trackInteraction()})),j(this,"_handleFocus",(()=>{this.props.onFocus([])})),j(this,"_handleBlur",(()=>{this.props.onBlur([])})),j(this,"focus",(()=>(this.props.apiOptions.customKeypad&&this.refs.input.focus(),!0))),j(this,"focusInputPath",(e=>{this.refs.input.focus()})),j(this,"blurInputPath",(e=>{this.refs.input.blur()})),j(this,"insert",(e=>{this.props.apiOptions.staticRender||this.refs.input.insert(e)})),j(this,"getInputPaths",(()=>[[]])),j(this,"getGrammarTypeForPath",(e=>"expression")),j(this,"setInputValue",((e,t,r)=>{this.props.onChange({value:t},r)}))}static validate(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},n=h.clone(r);h.extend(n,{decimal_separator:o.getDecimalSeparator()});var s,a,l,p,c,d=!0;for(var u of r.answerForms||[]){var m=(p=u,c=void 0,(c=e.parse(p.value,r)).parsed?ge.expression.createValidatorFunctional(c.expr,h({}).extend(n,{simplify:p.simplify,form:p.form})):(he.error("Unable to parse solution answer for expression",pe.InvalidInput,{loggedMetadata:{rubric:JSON.stringify(r)}}),null));if(m){var g=m(t);if(g.correct){s=u,a=g.message||"";break}d=d&&g.empty,"correct"===u.considered&&g.ungraded&&!l&&(l=g)}}return s?"ungraded"===s.considered?{type:"invalid",message:!1===i(null,t,a)?null:a}:{type:"points",earned:"correct"===s.considered?1:0,total:1,message:a}:l?{type:"invalid",message:l.message,suppressAlmostThere:l.suppressAlmostThere}:d?{type:"invalid",message:null}:{type:"points",earned:0,total:1}}static getUserInputFromProps(e){return bs(e.value)}static getOneCorrectAnswerFromRubric(e){var t=(e.answerForms||[]).filter((e=>"correct"===e.considered));if(0!==t.length)return t[0].value}render(){if(this.props.apiOptions.customKeypad)return a.createElement(t,{ref:"input",value:this.props.value,keypadElement:this.props.keypadElement,onChange:this.changeAndTrack,onFocus:()=>{var e;null===(e=this.props.keypadElement)||void 0===e||e.configure(this.props.keypadConfiguration,(()=>{this._isMounted&&this._handleFocus()}))},onBlur:this._handleBlur});if(this.props.apiOptions.staticRender)return a.createElement(hs,{ref:"input",value:this.props.value,type:"tex",examples:[],shouldShowExamples:!1,onChange:this.changeAndTrack,onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,linterContext:this.props.linterContext});var e=a.createElement("span",{className:"error-tooltip",role:"tooltip"},a.createElement(ls,{className:"error-text-container",horizontalPosition:"right",horizontalAlign:"left",verticalPosition:"top",arrowSize:10,borderColor:"#fcc335",show:this.state.showErrorText},a.createElement("span",{className:"error-icon","data-test-id":"test-error-icon",onMouseEnter:()=>{this.setState({showErrorText:!0})},onMouseLeave:()=>{this.setState({showErrorText:!1})},onClick:()=>{this.setState({showErrorText:!this.state.showErrorText})}},a.createElement(X,ki)),a.createElement("div",{className:"error-text"},ys))),r=s({"perseus-widget-expression":!0,"show-error-tooltip":this.state.showErrorTooltip});return a.createElement("div",{className:r},a.createElement($o,{ref:"input",className:Jt.INTERACTIVE,value:this.props.value,onChange:this.changeAndTrack,convertDotToTimes:this.props.times,buttonsVisible:this.props.buttonsVisible||"focused",buttonSets:this.props.buttonSets,onFocus:this._handleFocus,onBlur:this._handleBlur}),this.state.showErrorTooltip&&e)}}j(xs,"defaultProps",{value:"",times:!1,functions:[],buttonSets:["basic","trig","prealgebra","logarithms"],onFocus:()=>{},onBlur:()=>{},apiOptions:Zt.defaults,linterContext:Vt});var ws=t=>{var i=r.EXPRESSION,n={},o={};for(var s of t.answerForms){var a=e.parse(s.value,t);a.parsed&&function(){var e=a.expr,t=e=>(e=>"pi"===e||"theta"===e)(e)?e.toUpperCase():e;for(var r of e.getVars())n[t(r)]=!0;for(var i of e.getConsts())o[t(i)]=!0}()}var l=Object.keys(n);l.sort();var p=Object.keys(o);p.sort();var h=[...l,...p];return h.length||h.push("PI"),{keypadType:i,extraKeys:h}},Cs={name:"expression",displayName:"Expression / Equation",defaultAlignment:"inline-block",widget:xs,transform:e=>{var{times:t,functions:r,buttonSets:i,buttonsVisible:n}=e;return{keypadConfiguration:ws(e),times:t,functions:r,buttonSets:i,buttonsVisible:n}},version:{major:1,minor:0},propUpgrades:{1:e=>({times:e.times,buttonSets:e.buttonSets,functions:e.functions,buttonsVisible:e.buttonsVisible,answerForms:[{considered:"correct",form:e.form,simplify:e.simplify,value:e.value}]})},isLintable:!0};class ks extends a.Component{render(){var e=h.uniq(this.props.answers),t=h.map(e,(e=>a.createElement("dd",{key:e},e)));return a.createElement("dl",{className:"perseus-possible-answers"},a.createElement("dt",null,o.doNotTranslate("Correct Answer")),t)}}j(ks,"propTypes",{answers:d.arrayOf(d.string)});var Es=["keypadElement","onFocus","value"],Ss=E({displayName:"SimpleKeypadInput",propTypes:{keypadElement:i,onFocus:d.func,value:d.oneOfType([d.string,d.number])},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},focus(){this.refs.input.focus()},blur(){this.refs.input.blur()},getValue:function(){return this.props.value},render(){var e=this,i=e.props,{keypadElement:n,onFocus:o,value:s}=i,l=$(i,Es);return a.createElement(t,Y({ref:"input",keypadElement:n,onFocus:()=>{n?n.configure({keypadType:r.FRACTION},(()=>{e._isMounted&&o&&o()})):o&&o()},value:null==s?"":""+s},l))}}),_s=Jo,Ms={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"}},Ts={integer:function(e){return o._("an integer, like $6$")},proper:function(e){return"optional"===e.simplify?o._("a *proper* fraction, like $1/2$ or $6/10$"):o._("a *simplified proper* fraction, like $3/5$")},improper:function(e){return"optional"===e.simplify?o._("an *improper* fraction, like $10/7$ or $14/8$"):o._("a *simplified improper* fraction, like $7/4$")},mixed:function(e){return o._("a mixed number, like $1\\ 3/4$")},decimal:function(e){return o._("an *exact* decimal, like $0.75$")},percent:function(e){return o._("a percent, like $12.34\\%$")},pi:function(e){return o._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")}};class Is extends a.Component{constructor(){super(...arguments),j(this,"shouldShowExamples",(()=>"number"!==this.props.answerType&&!this.props.apiOptions.staticRender)),j(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t)})),j(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),j(this,"_handleFocus",(()=>{this.props.onFocus([]);var{interactionCallback:e}=this.props.apiOptions;e&&e()})),j(this,"_handleBlur",(()=>{this.props.onBlur([])})),j(this,"focus",(()=>(this.refs.input.focus(),!0))),j(this,"focusInputPath",(e=>{this.refs.input.focus()})),j(this,"blurInputPath",(e=>{this.refs.input.blur()})),j(this,"getInputPaths",(()=>[[]])),j(this,"getGrammarTypeForPath",(e=>"number")),j(this,"setInputValue",((e,t,r)=>{this.props.onChange({currentValue:t},r)})),j(this,"getUserInput",(()=>Is.getUserInputFromProps(this.props))),j(this,"simpleValidate",((e,t)=>(t=t||function(){},Is.validate(this.getUserInput(),e,t)))),j(this,"examples",(()=>{var e=this.props.answerType,t=Ms[e].forms.split(/\s*,\s*/),r=h.map(t,(function(e){return Ts[e](this.props)}),this);return[o._("**Your answer should be** ")].concat(r)}))}render(){if(this.props.apiOptions.customKeypad){var e=a.createElement(Ss,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur});return this.props.rightAlign?a.createElement("div",{className:"perseus-input-right-align"},e):e}var t=this.props.reviewModeRubric,r=null,i=null;if(this.props.apiOptions.satStyling&&t){var n=this.simpleValidate(t);if(!(r="points"===n.type&&n.earned===n.total)){var o=String(t.value);t.inexact&&t.maxError&&(o+=" ± "+t.maxError);var l=[o];i=a.createElement(ks,{answers:l})}}var p={};p["perseus-input-size-"+this.props.size]=!0,p["perseus-input-right-align"]=this.props.rightAlign,p[Jt.CORRECT]=t&&r&&this.props.currentValue,p[Jt.INCORRECT]=t&&!r&&this.props.currentValue,p[Jt.UNANSWERED]=t&&!this.props.currentValue;var h=a.createElement(hs,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:s(p),type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,linterContext:this.props.linterContext});return i?a.createElement("span",{className:"perseus-input-with-answer-blurb"},h,i):h}static validate(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>{};null==t.answerType&&(t.answerType="number");var i=ge.number.createValidatorFunctional(t.value,{simplify:t.simplify,inexact:t.inexact||void 0,maxError:t.maxError,forms:Ms[t.answerType].forms})(_s(e.currentValue));return i.empty?{type:"invalid",message:!1===(null==r?void 0:r(null,e.currentValue,i.message))?null:i.message}:{type:"points",earned:i.correct?1:0,total:1,message:i.message}}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){if(null!=e.value){var t=String(e.value);return e.inexact&&e.maxError&&(t+=" ± "+e.maxError),t}}}j(Is,"defaultProps",{currentValue:"",size:"normal",answerType:"number",rightAlign:!1,apiOptions:Zt.defaults,linterContext:Vt});var Ps={name:"input-number",displayName:"Number text box (old)",defaultAlignment:"inline-block",hidden:!0,widget:Is,transform:e=>{var{simplify:t,size:r,answerType:i,rightAlign:n}=e;return{simplify:t,size:r,answerType:i,rightAlign:n}},isLintable:!0},Ns=Jo,As=[{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:"π"}],Rs={integer:()=>o._("an integer, like $6$"),proper:e=>"optional"===e.simplify?o._("a *proper* fraction, like $1/2$ or $6/10$"):o._("a *simplified proper* fraction, like $3/5$"),improper:e=>"optional"===e.simplify?o._("an *improper* fraction, like $10/7$ or $14/8$"):o._("a *simplified improper* fraction, like $7/4$"),mixed:()=>o._("a mixed number, like $1\\ 3/4$"),decimal:()=>o._("an *exact* decimal, like $0.75$"),pi:()=>o._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")};class Fs extends a.Component{constructor(){super(...arguments),j(this,"state",{previousValues:[""]}),j(this,"getAnswerBlurb",(e=>{var t,r;if(this.props.apiOptions.satStyling&&e){var i=this.simpleValidate(e);if(!(t="points"===i.type&&i.earned===i.total)){var n=h.filter(e.answers,(e=>"correct"===e.status)),o=h.map(n,(e=>{var t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);var r=de.toNumericString(e.value,t);return e.maxError&&(r+=" ± "+de.toNumericString(e.maxError,t)),r}));r=a.createElement(ks,{answers:o})}}return[r,!!t]})),j(this,"getClasses",((e,t)=>{var r={};return r["perseus-input-size-"+this.props.size]=!0,r["perseus-input-right-align"]=this.props.rightAlign,r[Jt.CORRECT]=t&&e&&this.props.currentValue,r[Jt.INCORRECT]=t&&!e&&this.props.currentValue,r[Jt.UNANSWERED]=t&&!this.props.currentValue,r})),j(this,"examples",(()=>{var e,t=0!==(null===(e=this.props.answerForms)||void 0===e?void 0:e.length)?this.props.answerForms:h.map(h.keys(Rs),(e=>({name:e,simplify:"required"}))),r=h.map(t,(e=>Rs[e.name](e)));return r=h.uniq(r),[o._("**Your answer should be** ")].concat(r)})),j(this,"shouldShowExamples",(()=>{var e,t,r=0===(null===(e=this.props.answerForms)||void 0===e?void 0:e.length),i=h.uniq(null===(t=this.props.answerForms)||void 0===t?void 0:t.map((e=>e.name))).length>=h.size(Rs);return!r&&!i})),j(this,"simpleValidate",(e=>Fs.validate(this.getUserInput(),e))),j(this,"focus",(()=>(this.refs.input.focus(),!0))),j(this,"focusInputPath",(e=>{this.refs.input.focus()})),j(this,"blurInputPath",(e=>{this.refs.input.blur()})),j(this,"getInputPaths",(()=>[[]])),j(this,"getGrammarTypeForPath",(e=>"number")),j(this,"setInputValue",((e,t,r)=>{this.props.onChange({currentValue:t},r)})),j(this,"getUserInput",(()=>Fs.getUserInputFromProps(this.props))),j(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t),this.props.trackInteraction()})),j(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),j(this,"_handleFocus",(()=>{this.props.onFocus([]);var{interactionCallback:e}=this.props.apiOptions;e&&e()})),j(this,"_handleBlur",(()=>{this.props.onBlur([])}))}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){var t=h.filter(e.answers,(e=>"correct"===e.status)),r=h.map(t,(e=>{var t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);var r=de.toNumericString(e.value,t);return e.maxError&&(r+=" ± "+de.toNumericString(e.maxError,t)),r}));if(0!==r.length)return r[0]}static validate(e,t){var r=h.pluck(As,"value"),i=e=>ge.number.createValidatorFunctional(e.value,{message:e.message,simplify:"correct"===e.status?e.simplify:"optional",inexact:!0,maxError:e.maxError,forms:e.strict&&e.answerForms&&0!==e.answerForms.length?e.answerForms:r}),n=Ns(e.currentValue),o=h.where(t.answers,{status:"correct"}),s=o.every((e=>Math.abs(e.value)<=1)),a=h.find(h.map(o,(e=>{var r=n;return t.coefficient&&(r?"-"===r&&(r=-1):r=1),i(e)(Os(r,s))})),(e=>e.correct||e.empty));if(!a){var l=[].concat(h.where(t.answers,{status:"ungraded"}),h.where(t.answers,{status:"wrong"})),p=h.find(l,(e=>i(e)(Os(n,s)).correct));a={empty:!!p&&"ungraded"===p.status,correct:!!p&&"correct"===p.status,message:p?p.message:null,guess:n}}return a.empty?{type:"invalid",message:a.message}:{type:"points",earned:a.correct?1:0,total:1,message:a.message}}render(){var e=this.props.reviewModeRubric,t=this.getAnswerBlurb(e),r=t[0],i=t[1],n=this.getClasses(i,e),l=this.props.labelText;null!=l&&""!==l||(l=o._("Your answer:"));if(this.props.apiOptions.customKeypad)return(e=>this.props.rightAlign?a.createElement("div",{className:"perseus-input-right-align"},e):e)(a.createElement(Ss,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur}));var p=a.createElement(hs,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:s(n),labelText:l,type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,highlightLint:this.props.highlightLint});return r?a.createElement("span",{className:"perseus-input-with-answer-blurb"},p,r):this.props.apiOptions.satStyling?a.createElement("label",{className:"perseus-input-with-label"},a.createElement("span",{className:"perseus-input-label","aria-hidden":"true"},o.doNotTranslate("Answer:")),p):a.createElement("div",null,p)}}j(Fs,"defaultProps",{currentValue:"",size:"normal",rightAlign:!1,apiOptions:Zt.defaults,coefficient:!1,answerForms:[],labelText:"",linterContext:Vt,multipleNumberInput:!1});var Os=(e,t)=>{if("string"!=typeof e||!e.endsWith("%"))return e;var r=parseFloat(e.slice(0,-1));return isNaN(r)?e:t?r/100:r},Ds={name:"numeric-input",displayName:"Number text box",defaultAlignment:"inline-block",accessible:!0,widget:Fs,transform:function(e){var t,r,i,n,o;return h.extend(h.omit(e,"answers"),{answerForms:(t=h.map(e.answers,(e=>h.map(e.answerForms,(t=>({simplify:e.simplify,name:t}))))),n=h.flatten(t),r=n,i=h.isEqual,o=h.reduce(r,((e,t)=>h.find(e,i.bind(null,t))?e:e.concat([t])),[]),h.sortBy(o,(e=>h.keys(Rs).indexOf(e.name))))})},isLintable:!0},Ls={getUserInput:function(){return h.omit(this.props,cs)},getUserInputFromProps:function(e){return h.omit(e,cs)}};class Bs extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"displayName","PassageRef"),j(this,"_isMounted",void 0),j(this,"_throttledUpdateRange",void 0),j(this,"state",{lineRange:null,content:null}),j(this,"getUserInput",(()=>Ls.getUserInput.call(this))),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"_deferredUpdateRange",(()=>{h.defer(this._updateRange)})),j(this,"_updateRange",(()=>{var e=this.props.findWidgets("passage "+this.props.passageNumber)[0],t=null;e&&(t=e.getReference(this.props.referenceNumber)),this._isMounted&&(t?this.setState({lineRange:[t.startLine,t.endLine],content:t.content}):this.setState({lineRange:null,content:null}))})),j(this,"simpleValidate",(e=>Bs.validate(this.getUserInput(),e)))}shouldComponentUpdate(e,t){return!h.isEqual(this.props,e)||!h.isEqual(this.state,t)}render(){var e,t,r=this.state.lineRange;if(e=r?r[0]===r[1]?o.$_("line %(lineNumber)s",{lineNumber:r[0]}):o.$_("lines %(lineRange)s",{lineRange:r[0]+"–"+r[1]}):o.$_("lines %(lineRange)s",{lineRange:"?".concat("–","?")}),this.props.summaryText){var i=$e.parseInline(this.props.summaryText);t=a.createElement("span",{"aria-hidden":!0}," ","(“",$e.basicOutput(i),"”)")}else t=null;return a.createElement("span",null,e,t,r&&a.createElement("div",{className:"perseus-sr-only"},this.state.content))}componentDidMount(){this._isMounted=!0,this._deferredUpdateRange(),this._throttledUpdateRange=h.throttle(this._deferredUpdateRange,500),window.addEventListener("resize",this._throttledUpdateRange)}componentDidUpdate(){this._deferredUpdateRange()}componentWillUnmount(){window.removeEventListener("resize",this._throttledUpdateRange),this._isMounted=!1}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}j(Bs,"defaultProps",{passageNumber:1,referenceNumber:1,summaryText:""});var zs={name:"passage-ref",displayName:"PassageRef (SAT only)",defaultAlignment:"inline",widget:Bs,transform:e=>({passageNumber:e.passageNumber,referenceNumber:e.referenceNumber,summaryText:e.summaryText}),version:{major:0,minor:1}},{pureXsMax:Hs,pureSmMin:Ws,pureSmMax:qs,pureMdMin:Us,pureMdMax:Gs,pureLgMin:Vs,pureLgMax:js,pureXlMin:Ys}=re,$s={xs:"@media screen and (max-width: ".concat(Hs,")"),sm:"@media screen and (min-width: ".concat(Ws,") and ")+"(max-width: ".concat(qs,")"),md:"@media screen and (min-width: ".concat(Us,") and ")+"(max-width: ".concat(Gs,")"),lg:"@media screen and (min-width: ".concat(Vs,") and ")+"(max-width: ".concat(js,")"),xl:"@media screen and (min-width: ".concat(Ys,")"),xsOrSmaller:"@media screen and (max-width: ".concat(Hs,")"),smOrSmaller:"@media screen and (max-width: ".concat(qs,")"),mdOrSmaller:"@media screen and (max-width: ".concat(Gs,")"),lgOrSmaller:"@media screen and (max-width: ".concat(js,")"),smOrLarger:"@media screen and (min-width: ".concat(Ws,")"),mdOrLarger:"@media screen and (min-width: ".concat(Us,")"),lgOrLarger:"@media screen and (min-width: ".concat(Vs,")"),xlOrLarger:"@media screen and (min-width: ".concat(Ys,")")},{zIndexAboveScratchpad:Xs,zIndexInteractiveComponent:Ks,radioBorderColor:Zs,checkedColor:Js,circleSize:Qs,radioMarginWidth:ea}=re,ta=m.create({perseusInteractive:{zIndex:Ks,position:"relative"},aboveScratchpad:{position:"relative",zIndex:Xs},blankBackground:{backgroundColor:"#FDFDFD"},perseusSrOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1},responsiveLabel:{[$s.smOrSmaller]:{fontSize:14,lineHeight:1.3},[$s.md]:{fontSize:17,lineHeight:1.4},[$s.lgOrLarger]:{fontSize:20,lineHeight:1.4}},responsiveInput:{display:"inline-block",WebkitAppearance:"none",appearance:"none","::-ms-check":{display:"none"},backgroundColor:"#fff",border:"2px solid #fff",boxShadow:"0 0px 0px 1px ".concat(Zs),outline:"none",boxSizing:"border-box",flexShrink:0,marginBottom:1,marginLeft:1,marginRight:1,marginTop:1,height:Qs-2,width:Qs-2},responsiveRadioInput:{borderRadius:"50%",":checked":{backgroundColor:Js,border:"none",borderRadius:"50%",boxShadow:"inset 0px 0px 0px 2px white, "+"0 0px 0px 2px ".concat(Js),marginTop:ea,marginBottom:ea,marginLeft:ea,marginRight:ea,height:Qs-2*ea,width:Qs-2*ea}},responsiveRadioInputActive:{backgroundColor:"#fff",border:"2px solid #fff",borderRadius:"50%",boxShadow:"0 0px 0px 2px ".concat(Js),marginTop:ea,marginBottom:ea,marginLeft:ea,marginRight:ea,height:Qs-2*ea,width:Qs-2*ea,":checked":{backgroundColor:"#fff"}},disableTextSelection:{userSelect:"none"}});"undefined"==typeof HTMLElement||HTMLElement.prototype.scrollTo||(HTMLElement.prototype.scrollTo=function(e,t){this.scrollLeft=e,this.scrollTop=t});var ra=(e,t)=>{"function"==typeof e.scrollTo?e.scrollTo(0,t):"scrollTop"in e&&(e.scrollTop=t)},ia=e=>e===document.body||null==e?window:e.scrollHeight>e.clientHeight?e:ia(e.parentElement),na=(e,t)=>{setTimeout((()=>{var r=ia(e),i=e.getBoundingClientRect(),n=r===window?{top:0,bottom:window.innerHeight}:r.getBoundingClientRect(),o=0,s=r===window?window.scrollY:r.scrollTop;if(i.bottom>n.bottom){var a=i.bottom-n.bottom;i.top+a<n.top&&(a=i.top-n.top),o=s+a}else if(i.top<n.top){o=s+(i.top-n.top)}!function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0,n=e===window?window.pageYOffset:e.scrollTop,o=t,s=o-n,a=17,l=r/a,p=0,h=setInterval((function(){if(p<l){var t=p/l,r=(1-Math.cos(Math.PI*t))/2;ra(e,n+s*r),p+=1}else ra(e,o),clearInterval(h),i&&i()}),a)}(r,o,750,t)}),0)};class oa extends a.Component{render(){var e={borderColor:this.props.visible?this.props.color:"transparent"};return a.createElement("span",{className:g(sa.ring),style:e},this.props.children)}}j(oa,"defaultProps",{visible:!0,color:"#71B307"});var sa=m.create({ring:{margin:"auto",display:"inline-block",borderRadius:"50%",borderWidth:2,padding:2,borderStyle:"solid"}});function aa(e){var t=o._("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z").split(" ");return e<t.length?t[e]:" "}class la extends a.Component{constructStyles(e,t,r){var i,n="#0084CE",o="#0084CE";return e?t?(n="#009900",o=r?Z:"#009900",i=r?"#009900":Z):r&&(n="#990000",o=Z,i="#990000"):r&&(o=Z,i="#0084CE"),{color:o,backgroundColor:i,borderColor:n}}render(){var{letter:e,a11yText:t,reviewMode:r,checked:i,correct:n,crossedOut:o}=this.props,{color:s,backgroundColor:l,borderColor:p}=this.constructStyles(r,n,i);return a.createElement("div",{className:g(da.iconWrapper)},a.createElement("div",{className:g(da.satCircle),style:{backgroundColor:l,borderColor:p}}),a.createElement("div",{style:{color:s},className:g(da.letter)},a.createElement("span",{className:"perseus-sr-only"},t),a.createElement("span",{"aria-hidden":"true"},e)),o&&a.createElement(ha,{color:p,sat:!0}))}}class pa extends a.Component{getChoiceInner(){var{letter:e,showCorrectness:t,correct:r}=this.props;return t?r?a.createElement(X,Y({},gi,{style:{position:"relative",top:-1}})):a.createElement(X,Ni):e}getDynamicStyles(){var{checked:e,showCorrectness:t,pressed:r,primaryProductColor:i,correct:n,transparentBackground:o}=this.props;if(!t&&r)return{borderColor:i,color:i,backgroundColor:o?"transparent":Z};if(e){var s=t&&n?"#71B307":i;return{color:Z,backgroundColor:s,borderColor:s}}return{borderColor:Q,color:Q}}render(){var{a11yText:e,checked:t,crossedOut:r,showCorrectness:i,correct:n,focused:o,primaryProductColor:s,previouslyAnswered:l}=this.props,p=this.getDynamicStyles();return a.createElement("div",{className:g(da.iconWrapper)},a.createElement(oa,{color:s,visible:o},a.createElement("div",{style:p,className:g(da.libraryCircle,i&&n&&da.libraryCircleCorrect,i&&!n&&da.libraryCircleIncorrect,i&&!n&&(t||l)&&da.libraryCircleIncorrectAnswered),"data-is-radio-icon":!0},a.createElement("div",{className:"perseus-sr-only"},e),a.createElement("div",{"aria-hidden":!0},this.getChoiceInner()))),r&&a.createElement(ha,{color:p.borderColor}))}}function ha(e){var t=e.sat?29:28;return a.createElement("svg",{width:t,height:t,viewBox:"0 0 ".concat(t," ").concat(t),className:g(da.crossOutLine)},a.createElement("line",{x1:2,x2:t-2,y1:t-2,y2:2,stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}))}class ca extends a.Component{a11yText(e){var{checked:t,correct:r,crossedOut:i,showCorrectness:n}=this.props;return n&&r?t?o._("(Choice %(letter)s, Checked, Correct)",{letter:e}):i?o._("(Choice %(letter)s, Crossed out, Correct)",{letter:e}):o._("(Choice %(letter)s, Correct)",{letter:e}):n&&!r?t?o._("(Choice %(letter)s, Checked, Incorrect)",{letter:e}):i?o._("(Choice %(letter)s, Crossed out, Incorrect)",{letter:e}):o._("(Choice %(letter)s, Incorrect)",{letter:e}):t?o._("(Choice %(letter)s, Checked)",{letter:e}):i?o._("(Choice %(letter)s, Crossed out)",{letter:e}):o._("(Choice %(letter)s)",{letter:e})}render(){var{pos:e,reviewMode:t,checked:r,crossedOut:i,correct:n,product:o,showCorrectness:s,pressed:l,focused:p,primaryProductColor:h,previouslyAnswered:c,transparentBackground:d}=this.props,u=aa(e);return"sat"===o?a.createElement(la,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:r,correct:n,crossedOut:i}):a.createElement(pa,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:r,crossedOut:i,pressed:l,focused:p,correct:n,showCorrectness:s,primaryProductColor:h,previouslyAnswered:c,transparentBackground:d})}}j(ca,"defaultProps",{primaryProductColor:"#71B307"});var da=m.create({satCircle:{display:"block",borderRadius:25,borderStyle:"solid",borderWidth:2,content:"''",height:25,width:25,top:1,left:1},iconWrapper:{display:"inline-block",position:"relative"},crossOutLine:{position:"absolute",top:"calc(50% - ".concat(14,"px)"),left:"calc(50% - ".concat(14,"px)")},libraryCircle:{width:24,height:24,boxSizing:"border-box",borderRadius:24,borderStyle:"solid",borderWidth:2,fontFamily:"'Proxima Nova',sans-serif",fontWeight:"bold",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1px"},libraryCircleCorrect:{fontSize:24},libraryCircleIncorrect:{fontSize:24,borderColor:Q,color:Q},libraryCircleIncorrectAnswered:{backgroundColor:"#F86700",borderColor:"#F86700",color:Z},letter:{border:"2px solid transparent",width:25,height:25,position:"absolute",top:1,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:K,fontSize:13}});class ua extends a.Component{render(){var{color:e,pathClassName:t,className:r,title:i,style:n,alt:o}=this.props,{icon:s,size:l}=this.props,p="";"string"==typeof s&&(s={path:s,width:10,height:10}),"number"!=typeof l&&(l=1,p="em");var h=l,c=h/s.height*s.width,d=!!this.props.focusable;return a.createElement("svg",{role:"img",alt:o,"aria-label":i,"aria-hidden":!i||null,className:r,style:n,focusable:d.toString(),width:c+p,height:h+p,viewBox:"".concat(0," ").concat(0," ").concat(s.width," ").concat(s.height)},!!i&&a.createElement("title",null,i),a.createElement("path",{className:t,fill:e,d:s.path}))}}function ma(){return ma=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ma.apply(this,arguments)}function ga(e,t){if(null==e)return{};var r,i,n={},o=Object.keys(e);for(i=0;i<o.length;i++)r=o[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}j(ua,"defaultProps",{color:"currentColor"});const fa="@media (max-width: 1023px)",va="@media (min-width: 1024px)",ya={display:"block"},ba='Lato, "Noto Sans", sans-serif',xa=m.create({Title:ma({},ya,{fontFamily:ba,fontWeight:900,[va]:{fontSize:36,lineHeight:"40px"},[fa]:{fontSize:28,lineHeight:"32px"}}),Tagline:ma({},ya,{fontFamily:ba,fontWeight:400,fontSize:20,lineHeight:"24px"}),HeadingLarge:ma({},ya,{fontFamily:ba,fontWeight:700,[va]:{fontSize:28,lineHeight:"32px"},[fa]:{fontSize:24,lineHeight:"28px"}}),HeadingMedium:ma({},ya,{fontFamily:ba,fontWeight:700,[va]:{fontSize:24,lineHeight:"28px"},[fa]:{fontSize:22,lineHeight:"26px"}}),HeadingSmall:ma({},ya,{fontFamily:ba,fontWeight:700,fontSize:20,lineHeight:"24px"}),HeadingXSmall:ma({},ya,{fontFamily:ba,fontWeight:700,fontSize:12,lineHeight:"16px",letterSpacing:.6,textTransform:"uppercase"}),BodySerifBlock:ma({},ya,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:22,lineHeight:"28px"}),BodySerif:ma({},ya,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:18,lineHeight:"22px"}),BodyMonospace:ma({},ya,{fontFamily:"Inconsolata, monospace",fontWeight:400,fontSize:17,lineHeight:"22px"}),Body:ma({},ya,{fontFamily:ba,fontWeight:400,fontSize:16,lineHeight:"22px"}),LabelLarge:ma({},ya,{fontFamily:ba,fontWeight:700,fontSize:16,lineHeight:"20px"}),LabelMedium:ma({},ya,{fontFamily:ba,fontWeight:400,fontSize:16,lineHeight:"20px"}),LabelSmall:ma({},ya,{fontFamily:ba,fontWeight:400,fontSize:14,lineHeight:"18px"}),LabelXSmall:ma({},ya,{fontFamily:ba,fontWeight:400,fontSize:12,lineHeight:"16px"}),Caption:ma({},ya,{fontFamily:ba,fontWeight:400,fontSize:14,lineHeight:"20px"}),Footnote:ma({},ya,{fontFamily:ba,fontWeight:400,fontSize:12,lineHeight:"18px"})}),wa=["style","children"];class Ca extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,wa);return a.createElement(P,ma({},i,{style:[xa.Title,t]}),r)}}Ca.defaultProps={tag:"h1"};const ka=["style","children"];class Ea extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,ka);return a.createElement(P,ma({},i,{style:[xa.HeadingLarge,t]}),r)}}Ea.defaultProps={tag:"h2"};const Sa=["style","children"];class _a extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Sa);return a.createElement(P,ma({},i,{style:[xa.HeadingMedium,t]}),r)}}_a.defaultProps={tag:"h3"};const Ma=["style","children"];class Ta extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Ma);return a.createElement(P,ma({},i,{style:[xa.HeadingSmall,t]}),r)}}Ta.defaultProps={tag:"h4"};const Ia=["style","children"];class Pa extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Ia);return a.createElement(P,ma({},i,{style:[xa.HeadingXSmall,t]}),r)}}Pa.defaultProps={tag:"h4"};const Na=["style","children"];class Aa extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Na);return a.createElement(P,ma({},i,{style:[xa.BodySerifBlock,t]}),r)}}Aa.defaultProps={tag:"span"};const Ra=["style","children"];class Fa extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Ra);return a.createElement(P,ma({},i,{style:[xa.BodySerif,t]}),r)}}Fa.defaultProps={tag:"span"};const Oa=["style","children"];class Da extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Oa);return a.createElement(P,ma({},i,{style:[xa.BodyMonospace,t]}),r)}}Da.defaultProps={tag:"span"};const La=["style","children"];class Ba extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,La);return a.createElement(P,ma({},i,{style:[xa.Body,t]}),r)}}Ba.defaultProps={tag:"span"};const za=["style","children"];class Ha extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,za);return a.createElement(P,ma({},i,{style:[xa.LabelLarge,t]}),r)}}Ha.defaultProps={tag:"span"};const Wa=["style","children"];class qa extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Wa);return a.createElement(P,ma({},i,{style:[xa.LabelMedium,t]}),r)}}qa.defaultProps={tag:"span"};const Ua=["style","children"];class Ga extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Ua);return a.createElement(P,ma({},i,{style:[xa.LabelSmall,t]}),r)}}Ga.defaultProps={tag:"span"};const Va=["style","children"];class ja extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Va);return a.createElement(P,ma({},i,{style:[xa.LabelXSmall,t]}),r)}}ja.defaultProps={tag:"span"};const Ya=["style","children"];class $a extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Ya);return a.createElement(P,ma({},i,{style:[xa.Tagline,t]}),r)}}$a.defaultProps={tag:"span"};const Xa=["style","children"];class Ka extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Xa);return a.createElement(P,ma({},i,{style:[xa.Caption,t]}),r)}}Ka.defaultProps={tag:"span"};const Za=["style","children"];class Ja extends a.Component{render(){const e=this.props,{style:t,children:r}=e,i=ga(e,Za);return a.createElement(P,ma({},i,{style:[xa.Footnote,t]}),r)}}Ja.defaultProps={tag:"span"};var Qa=Object.freeze({__proto__:null,black:"#000000",grayDarker:"#333333",grayDark:"#555555",gray:"#999999",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",white:"#FFFFFF",blue:"#005A88",blueDark:"#2C3747",green:"#76A005",red:"#CF5044",yellow:"#FFC40D",orange:"#BF4F04",pink:"#C3325F",purple:"#7A43B6",bodyBackground:"#FFFFFF",textColor:"#444444",linkColor:"#005987",linkColorHover:"#678D00",sansFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",serifFontFamily:"Georgia,'Times New Roman',Times,serif",monoFontFamily:"Monaco,Menlo,Consolas,'Courier New',monospace",baseFontSize:"14px",baseFontFamily:"inherit",baseLineHeight:"20px",altFontFamily:"Georgia,'Times New Roman',Times,serif",headingsFontFamily:"inherit",headingsFontWeight:"bold",headingsColor:"inherit",fontSizeLarge:"18px",fontSizeSmall:"12px",fontSizeMini:"10.5px",paddingLarge:"11px 19px",paddingSmall:"2px 10px",paddingMini:"0 6px",baseBorderRadius:"4px",borderRadiusLarge:"6px",borderRadiusSmall:"3px",tableBackground:"#000000",tableBackgroundAccent:"#F9F9F9",tableBackgroundHover:"#F5F5F5",tableBorder:"#DDDDDD",btnBackground:"#FFFFFF",btnBackgroundHighlight:"rgb(230, 230, 230)",btnBorder:"#CCCCCC",btnPrimaryBackground:"#0088CC",btnPrimaryBackgroundHighlight:"rgb(0, 68, 204)",btnInfoBackground:"#5BC0DE",btnInfoBackgroundHighlight:"#2F96B4",btnSuccessBackground:"#62C462",btnSuccessBackgroundHighlight:"#51A351",btnWarningBackground:"rgb(251, 180, 81)",btnWarningBackgroundHighlight:"#F89406",btnDangerBackground:"#EE5F5B",btnDangerBackgroundHighlight:"#BD362F",btnInverseBackground:"#444444",btnInverseBackgroundHighlight:"#222222",inputBackground:"#FFFFFF",inputBorder:"#CCCCCC",inputBorderRadius:"4px",inputDisabledBackground:"#EEEEEE",formActionsBackground:"#F5F5F5",inputHeight:"30px",dropdownBackground:"#FFFFFF",dropdownBorder:"rgba(0, 0, 0, 0.2)",dropdownDividerTop:"#E5E5E5",dropdownDividerBottom:"#FFFFFF",dropdownLinkColor:"#333333",dropdownLinkColorHover:"#FFFFFF",dropdownLinkColorActive:"#FFFFFF",dropdownLinkBackgroundActive:"#0088CC",dropdownLinkBackgroundHover:"#0088CC",zindexDropdown:1e3,zindexPopover:1010,zindexTooltip:1030,zindexFixedNavbar:1030,zindexHeader:1060,zindexModalBackdrop:1070,zindexModal:1080,zindexAboveModal:1090,iconSpritePath:"../img/glyphicons-halflings.png",iconWhiteSpritePath:"../img/glyphicons-halflings-white.png",placeholderText:"#999999",hrBorder:"#EEEEEE",horizontalComponentOffset:"180px",wellBackground:"#F5F5F5",navbarCollapseWidth:"979px",navbarCollapseDesktopWidth:"980px",navbarHeight:"40px",navbarBackgroundHighlight:"#FFFFFF",navbarBackground:"rgb(242, 242, 242)",navbarBorder:"rgb(212, 212, 212)",navbarText:"#777777",navbarLinkColor:"#777777",navbarLinkColorHover:"#333333",navbarLinkColorActive:"#555555",navbarLinkBackgroundHover:"#000000",navbarLinkBackgroundActive:"rgb(230, 230, 230)",navbarBrandColor:"#777777",navbarInverseBackground:"#111111",navbarInverseBackgroundHighlight:"#222222",navbarInverseBorder:"#252525",navbarInverseText:"#999999",navbarInverseLinkColor:"#999999",navbarInverseLinkColorHover:"#FFFFFF",navbarInverseLinkColorActive:"#FFFFFF",navbarInverseLinkBackgroundHover:"#000000",navbarInverseLinkBackgroundActive:"#111111",navbarInverseSearchBackground:"rgb(82, 82, 82)",navbarInverseSearchBackgroundFocus:"#FFFFFF",navbarInverseSearchBorder:"#111111",navbarInverseSearchPlaceholderColor:"#CCCCCC",navbarInverseBrandColor:"#999999",paginationBackground:"#FFFFFF",paginationBorder:"#DDDDDD",paginationActiveBackground:"#F5F5F5",heroUnitBackground:"#EEEEEE",heroUnitHeadingColor:"inherit",heroUnitLeadColor:"inherit",warningText:"#C09853",warningBackground:"#FCF8E3",warningBorder:"rgb(251, 239, 213)",errorText:"#B94A48",errorBackground:"#F2DEDE",errorBorder:"rgb(238, 211, 215)",successText:"#468847",successBackground:"#DFF0D8",successBorder:"rgb(212, 232, 197)",infoText:"#4A7C17",infoBackground:"#EDF2DF",infoBorder:"rgb(228, 232, 197)",tooltipColor:"#FFFFFF",tooltipBackground:"#000000",tooltipArrowWidth:"5px",tooltipArrowColor:"#000000",popoverBackground:"#FFFFFF",popoverArrowWidth:"10px",popoverArrowColor:"#FFFFFF",popoverTitleBackground:"rgb(247, 247, 247)",popoverArrowOuterWidth:"11px",popoverArrowOuterColor:"rgba(0, 0, 0, 0.25)",gridColumns:"12",gridColumnWidth:"60px",gridGutterWidth:"20px",gridRowWidth:"940px",gridColumnWidth1200:"70px",gridGutterWidth1200:"30px",gridRowWidth1200:"1170px",gridColumnWidth768:"42px",gridGutterWidth768:"20px",gridRowWidth768:"724px",fluidGridColumnWidth:"6.382978723404255%",fluidGridGutterWidth:"2.127659574468085%",fluidGridColumnWidth1200:"5.982905982905983%",fluidGridGutterWidth1200:"2.564102564102564%",fluidGridColumnWidth768:"5.801104972375691%",fluidGridGutterWidth768:"2.7624309392265194%",kaGreen:"#71B307",kaGreenLight:"#BED47A",kaBlue:"#314453",kaBlueLight:"#4D6779",grayExtraDark:"#111111",grayExtraLight:"#EEEEEE",graySuperLight:"#F7F7F7",whiteDark:"#FDFDFD",dark:"#21242C",blueDarkUnsaturated:"#3B414E",blueDarkSaturated:"#1F3043",blueLight:"#A9C0D1",greenLight:"#C6D1AD",greenDark:"#356700",yellowGreen:"#9DB63B",okGreen:"#A7CF5B",alertRed:"#C42420",coral:"#EE6666",grayBlue:"#9AB3B9",lightPageBackground:"#FDFDFD",yclaBlue:"#49BAD5",yclaTeal:"#56D0B3",yclaTealDark:"#50C1A7",yclaGreenDark:"#3D9A82",yclaGreen:"#81C262",learnstormBlue:"#4898FC",homepageBlue:"#46A8BF",backgroundBlue:"#00294A",teacherSignupBlue:"#335d7d",homepageGreen:"#2B8E7B",streakColor:"#F79734",facebookColor:"#1A60A2",blueGoogleColor:"#2CAFE2",redGoogleColor:"#BF4434",homepageColor:"#2D585E",lightTextColor:"#898989",fontSizeTiny:"11px",fontSizeNormal:"14px",fontSizeMedium:"16px",fontSizeExtraLarge:"24px",fontSizeHuge:"36px",fontSizeBakana:"48px",fontSizeBananas:"60px",fixedWidthFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",contentPadding:"20px",primaryButtonBackground:"#89B908",primaryButtonBorder:"#76A005",buttonTextColor:"rgb(122, 122, 122)",buttonBorderRadius:"3px",basicBorderColor:"#CCCCCC",minContainerWidth:"1000px",maxContainerWidth:"1200px",formHintColor:"#999999",guidelineExampleText:"#606060",hoverCardWidth:"450px",menuHighlightColor:"#96AB4F",menuHighlightBorderColor:"#76A005",menuActiveTextColor:"#FFFFFF",menuInactiveTextColor:"#444444",menuSubheaderTextColor:"rgb(120, 120, 120)",menuBorderColor:"#94A170",unreadBackgroundColor:"#ECEEF4",menuLineHeight:"18px",menuSubheaderLineHeight:"17px",menuSubheaderFontSize:"9px",notificationBarColor:"#4858A4",modalBodyTopPadding:"20px",modalDialogPadding:"15px",modalSectionPadding:"9px",mathDomain1:"#11ACCD",mathDomain2:"#63D9EA",mathDomain3:"#027d97",mathDomain4:"#085566",partnerContentDomain1:"#01A995",partnerContentDomain2:"#01D1C1",partnerContentDomain3:"#208170",partnerContentDomain4:"#144F44",csDomain1:"#1FAB54",csDomain2:"#74CF70",csDomain3:"#0D923F",csDomain4:"#085E29",economicsDomain1:"#E07D10",economicsDomain2:"#FFBE26",economicsDomain3:"#A75A05",economicsDomain4:"#953C02",collegeCareersMoreDomain1:"#01A995",collegeCareersMoreDomain2:"#01D1C1",collegeCareersMoreDomain3:"#208170",collegeCareersMoreDomain4:"#144F44",humanitiesDomain1:"#E84D39",humanitiesDomain2:"#FF8482",humanitiesDomain3:"#BE2612",humanitiesDomain4:"#8C1C0D",gtpDomain1:"#1865F2",gtpDomain2:"#1865F2",gtpDomain3:"#1865F2",gtpDomain4:"#1865F2",scienceDomain1:"#CA337C",scienceDomain2:"#FF92C6",scienceDomain3:"#9E034E",scienceDomain4:"#6B0235",testPrepDomain1:"#1865F2",testPrepDomain2:"#1865F2",testPrepDomain3:"#1865F2",testPrepDomain4:"#1865F2",defaultDomain1:"#1865F2",defaultDomain2:"#66afe9",defaultDomain3:"#1152b0",defaultDomain4:"#0d3d82",defaultDomainColor:"#314453",defaultSubjectColor:"#4D6779",defaultTopicColor:"#6A8DA6",defaultHoverColor:"#314453",defaultLinkColor:"#314453",defaultLinkHoverColor:"#6A8DA6",scienceDomainColor:"#94424F",scienceSubjectColor:"#9D4A5A",scienceTopicColor:"#C55F73",scienceHoverColor:"#94424F",scienceLinkColor:"#94424F",scienceLinkHoverColor:"#C55F73",humanitiesDomainColor:"#AD3434",humanitiesSubjectColor:"#C13B31",humanitiesTopicColor:"#D24A45",humanitiesHoverColor:"#AD3434",humanitiesLinkColor:"#AD3434",humanitiesLinkHoverColor:"#D24A45",economicsDomainColor:"#B77033",economicsSubjectColor:"#BF7B34",economicsTopicColor:"#D1933B",economicsHoverColor:"#B77033",economicsLinkColor:"#B77033",economicsLinkHoverColor:"#D1933B",csDomainColor:"#437A39",csSubjectColor:"#53893E",csTopicColor:"#689B51",csHoverColor:"#437A39",csLinkColor:"#437A39",csLinkHoverColor:"#689B51",partnerContentDomainColor:"#218270",partnerContentSubjectColor:"#2C8D7B",partnerContentTopicColor:"#329A86",partnerContentHoverColor:"#218270",partnerContentLinkColor:"#218270",partnerContentLinkHoverColor:"#329A86",essayDomainColor:"#0071B3",mathDomainColor:"#1C758A",mathSubjectColor:"#46A8BF",mathTopicColor:"#4FBAD4",mathHoverColor:"#1C758A",mathLinkColor:"#1C758A",mathLinkHoverColor:"#4FBAD4",testPrepDomainColor:"#644172",testPrepSubjectColor:"#7E5F8E",testPrepTopicColor:"#9A72AC",testPrepHoverColor:"#644172",testPrepLinkColor:"#644172",testPrepLinkHoverColor:"#9A72AC",collegeCareersMoreDomainColor:"#218270",collegeCareersMoreSubjectColor:"#2C8D7B",collegeCareersMoreTopicColor:"#329A86",collegeCareersMoreHoverColor:"#218270",collegeCareersMoreLinkColor:"#218270",collegeCareersMoreLinkHoverColor:"#329A86",satDomainColor:"#0084CE",satSubjectColor:"#0084CE",satTopicColor:"#0084CE",satHoverColor:"#0084CE",satLinkColor:"#0084CE",satLinkHoverColor:"#0084CE",colorProficient:"#1C758A",colorPracticed:"rgb(158, 221, 235)",colorMastery1:"rgb(90, 197, 221)",colorMastery2:"rgb(42, 174, 203)",colorMastery3:"#1C758A",colorSuggested:"#73982C",colorReview:"#E35D04",colorNotStarted:"#CCCCCC",colorStarted:"#C7E5F7",colorStruggling:"#C30202",colorPersonal:"#00809C",colorPractice:"#96D9FF",colorEnergyPoints:"#005987",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1200px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1199px"}),el={white:"#FFFFFF",gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:"#BABEC2",gray72:"#999A9D",gray68:"#888D93",gray55:"#707378",gray41:"#626569",gray25:"#3B3E40",gray17:"#21242C",gray10:"#1499af",black:"#000000",alertRed:"#C42420",homepageBlue:"#46A8BF",kaBlue:"#314453",kaBlueLight:"#4D6779",kaGreen:"#71B307",kaGreenLight:"#BED47A",learnstormBlue:"#4898FC",backgroundBlue:"#00294A",adminGreen:"#78C008",kaBlueExtraLight:"#39c2db",kaBlueHover:"#0c7f99",kaGreenHover:"#518005",skyDark:"#001f4d",recommendationGold:"#ffbe26",starAced:"#ff9c39",google:"#C1432f",modernGoogle:"#be2612",modernGoogleHover:"#8c1c0d",facebook:"#4267B2",modernFacebook:"#4267B2",modernFacebookHover:"#00294a",wonderBlocksGold:"#FFB100",wonderBlocksLightBlue:"#37C5FD",breadcrumbs:"rgba(255, 255, 255, 0.7)"},tl={color:el.breadcrumbs,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased"},rl={regular:"inherit"},il={subjectHeadingDesktop:{fontFamily:"inherit",fontSize:50,fontWeight:"bold",lineHeight:"61px"},subjectHeadingMobile:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingDesktop:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingMobile:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingDesktop:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingMobile:{fontFamily:"inherit",fontSize:20,fontWeight:"bold",lineHeight:"24px"},smallSubheadingDesktop:{fontFamily:"inherit",fontSize:20,lineHeight:1.25},smallSubheadingMobile:{fontFamily:"inherit",fontSize:15,lineHeight:1.25},smallHeading:{color:el.gray25,fontFamily:"inherit",fontSize:17,fontWeight:"bold",lineHeight:"23px"},smallHeadingMobile:{color:el.gray25,fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},accentHeading:{color:el.gray68,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase"},bodyLarge:{fontFamily:rl.regular,fontSize:20,lineHeight:"30px"},bodySmall:{fontFamily:rl.regular,fontSize:17,fontWeight:"normal",lineHeight:"23px"},bodySmallBold:{fontFamily:rl.regular,fontSize:17,fontWeight:"bold",lineHeight:"23px"},bodyXsmall:{fontFamily:rl.regular,fontSize:15,lineHeight:"22px"},bodyXsmallBold:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"22px"},breadcrumb:tl,breadcrumbSmall:G(G({},tl),{},{fontSize:12,lineHeight:"13px"}),labelLarge:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},labelMedium:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},labelSmall:{fontFamily:rl.regular,fontSize:12,lineHeight:"14px"},caption:{fontFamily:rl.regular,fontSize:14,fontStyle:"italic",lineHeight:"17px"},desktopScalingOnMobile:{MozTextSizeAdjust:"100%",MsTextSizeAdjust:"100%",WebkitTextSizeAdjust:"100%"},modalSubtitle:{fontSize:12,lineHeight:1.65,WebkitFontSmoothing:"antialiased",fontWeight:"bold"},wonderBlocksHeader:{paddingLeft:16,paddingRight:16,paddingBottom:24,paddingTop:34,[$s.mdOrLarger]:{paddingBottom:32}},wonderBlocksTitle:{color:el.white,fontWeight:900,fontSize:28,lineHeight:"32px",margin:0,[$s.mdOrLarger]:{fontSize:36,lineHeight:"40px"}},wonderBlocksLabelLarge:{fontSize:16,lineHeight:"20px",fontWeight:700}},nl=Object.freeze({__proto__:null,colors:el,borderRadius:4,fonts:rl,typography:il});class ol extends a.PureComponent{constructor(){super(...arguments),j(this,"_handleTooltipButtonRef",(e=>{e&&this.props.usingKeyboardFocus&&e.focus()}))}_getAriaLabel(){var{crossedOut:e,pos:t}=this.props,r=aa(t);return e?o._("Bring back Choice %(letter)s",{letter:r}):o._("Cross out Choice %(letter)s",{letter:r})}render(){var{crossedOut:e,pos:t,primaryProductColor:r,theme:i}=this.props,n="day"===i?r:_.white;return a.createElement("button",{type:"button","aria-label":this._getAriaLabel(),className:g([sl.tooltipButton]),onClick:()=>this.props.onClick(),onMouseDown:e=>e.preventDefault(),onFocus:()=>this.props.onFocus(),onBlur:()=>this.props.onBlur(),disabled:this.props.disabled,tabIndex:this.props.tabFocusable?0:-1,ref:this._handleTooltipButtonRef},a.createElement(ca,{pos:t,product:"library",crossedOut:!this.props.crossedOut,primaryProductColor:n,pressed:!0,checked:!1,focused:!1,correct:!1,showCorrectness:!1,reviewMode:!1,previouslyAnswered:!1,transparentBackground:!0}),a.createElement(Ha,{style:{color:n}},e?o._("Bring back"):o._("Cross out")))}}j(ol,"defaultProps",{primaryProductColor:el.kaGreen});var sl=m.create({tooltipButton:{background:"none",border:"none",font:"inherit",padding:0,cursor:"pointer",textDecoration:"none",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"}});class al{constructor(e,t,r){j(this,"_intersectionObserver",void 0),j(this,"_onVisibilityChange",void 0),j(this,"_handleIntersection",(e=>{for(var t of e)this._onVisibilityChange(t.isIntersecting,t.rootBounds)})),this._intersectionObserver=new IntersectionObserver(this._handleIntersection,{root:e,threshold:Number.EPSILON,rootMargin:r}),this._onVisibilityChange=t}setTargetElement(e){this._intersectionObserver.disconnect(),this._intersectionObserver.observe(e)}disconnect(){this._intersectionObserver.disconnect()}}class ll extends a.PureComponent{render(){var{direction:e,pxFromStart:t,pxFromEnd:r}=this.props,i=[pl.wrapper,"horizontal"===e&&pl.wrapperHorizontal,"vertical"===e&&pl.wrapperVertical],n=[pl.content,"horizontal"===e&&pl.contentHorizontal,"vertical"===e&&pl.contentVertical];return 0===t?a.createElement("div",{className:g(...i)},a.createElement("div",{className:g(...n)},this.props.children)):0===r?a.createElement("div",{className:g(...i,pl.wrapperAlignToEnd)},a.createElement("div",{className:g(...n)},this.props.children)):a.createElement("div",{className:g(...i)},a.createElement("div",{style:{flexShrink:r,flexBasis:t}}),a.createElement("div",{className:g(...n)},this.props.children),a.createElement("div",{style:{flexShrink:t,flexBasis:r}}))}}var pl=m.create({wrapper:{display:"flex",overflow:"hidden"},wrapperHorizontal:{flexDirection:"row",width:"100%"},wrapperVertical:{flexDirection:"column",height:"100%"},wrapperAlignToEnd:{justifyContent:"flex-end"},content:{flex:"0 0 auto"},contentHorizontal:{maxWidth:"100%"},contentVertical:{maxHeight:"100%"}}),hl=parseInt("6px");function cl(e){var{color:t,inverted:r}=e;return r?{backgroundColor:t,textColor:_.white}:{backgroundColor:_.white,textColor:t}}class dl extends a.PureComponent{render(){var e,t,r,{onClick:i,onMouseEnter:n,onMouseLeave:o,side:s}=this.props.tooltipProps,{backgroundColor:l}=cl(this.props.tooltipProps);if("top"===s)e=["0,0","".concat(9,",").concat(9),"".concat(18,",0")],t=18,r=9;else if("right"===s)e=["".concat(9,",0"),"0,".concat(9),"".concat(9,",").concat(18)],t=9,r=18;else if("bottom"===s)e=["0,".concat(9),"".concat(9,",0"),"".concat(18,",").concat(9)],t=18,r=9;else{if("left"!==s)throw new ce("unexpected side ".concat(s),pe.InvalidInput);e=["0,0","".concat(9,",").concat(9),"0,".concat(18)],t=9,r=18}return a.createElement("svg",{width:t,height:r,className:g(ul.tooltipArrow)},a.createElement("filter",{id:"tooltip-dropshadow-".concat(s),height:"150%"},a.createElement("feOffset",{dx:0,dy:1,result:"offsetblur"}),a.createElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:2}),a.createElement("feComponentTransfer",null,a.createElement("feFuncA",{type:"linear",slope:.1})),a.createElement("feMerge",null,a.createElement("feMergeNode",null),a.createElement("feMergeNode",{in:"SourceGraphic"}))),a.createElement("polyline",{fill:l,stroke:l,points:e.join(" "),className:g(i&&ul.tooltipArrowShapeWithOnClick),onClick:i,onMouseEnter:n,onMouseLeave:o}),a.createElement("polyline",{fill:l,points:e.join(" "),stroke:"rgba(0, 0, 0, 0.1)",filter:"url(#tooltip-dropshadow-".concat(s,")")}))}}var ul=m.create({tooltipArrow:{display:"block",userSelect:"none"},tooltipArrowShapeWithOnClick:{pointerEvents:"auto",cursor:"pointer"}}),ml=m.create({srOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1}});class gl extends a.PureComponent{constructor(){super(...arguments),j(this,"_handleClickClose",(()=>this.props.dismiss()))}_renderCloseButton(e){var{inverted:t,dismissOnClickClose:r}=this.props.tooltipProps;if(!r)return null;var i=e.get("button-description"),n=this.getA11yHeaderId(e);return a.createElement("button",{className:g(fl.closeIcon),onClick:this._handleClickClose,"aria-describedby":"".concat(i," ").concat(n)},a.createElement(ua,{title:o._("Close"),icon:"M6.26353762,4.99851587 L9.73097464,1.53107884 C10.0836373,1.17841618 10.0842213,0.612127047 9.73530496,0.263210718 C9.38395604,-0.0881381913 8.81874474,-0.0837668714 8.46743686,0.267541014 L4.99999981,3.73497806 L1.5325628,0.267541051 C1.1812549,-0.0837668481 0.616043606, -0.0881381955 0.264694717,0.263210694 C-0.0842215912,0.612127004 -0.0836375768,1.17841613 0.269025093,1.5310788 L3.73646206,4.9985158 L0.269025109,8.46595276 C-0.083637537,8.81861541 -0.0842215923, 9.38490462 0.264694642,9.73382106 C0.616043456,10.0851701 1.18125469, 10.0807988 1.53256259,9.72949093 L4.99999988,6.26205363 L8.46743739, 9.72949117 C8.8187453,10.0807991 9.38395655,10.0851704 9.73530537, 9.73382138 C10.0842216,9.38490498 10.0836375,8.81861579 9.73097488, 8.46595313 L6.26353762,4.99851587 Z",size:10,color:t?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.15)"}),a.createElement("div",{id:i,className:g(ml.srOnly)},o._("Closes the tooltip: ")))}getA11yHeaderId(e){var{tooltipProps:{a11y:t}}=this.props;return t&&t.title?"string"==typeof t.title?e.get("header"):t.title.id:this.getA11yContentId(e)}getA11yContentId(e){return e.get("content")}renderTooltip(e){var{content:t,dismissOnClickClose:r,noPadding:i,onClick:n,onMouseEnter:o,onMouseLeave:s,a11y:l,testId:p}=this.props.tooltipProps,h=l&&l.title,c=l&&l.assertiveness,{backgroundColor:d,textColor:u}=cl(this.props.tooltipProps),m=this.getA11yHeaderId(e),f=this.getA11yContentId(e);return a.createElement("div",{className:g(fl.tooltipBubble,!i&&fl.tooltipBubbleWithPadding,r&&fl.tooltipBubbleWithCloseIcon,n&&fl.tooltipBubbleWithOnClick),onClick:n,onMouseEnter:o,onMouseLeave:s,style:{backgroundColor:d,color:u},role:"region","aria-labelledby":m,"aria-describedby":f===m?null:f,"data-test-id":p},this._renderCloseButton(e),a.createElement("div",{"aria-live":c},"string"==typeof h?a.createElement("div",{className:g(ml.srOnly),id:m},h):null,a.createElement("div",{id:f,className:g(fl.tooltipContent)},t)))}render(){return a.createElement(N,{mockOnFirstRender:!1,scope:"tooltip-bubble"},(e=>this.renderTooltip(e)))}}var fl=m.create({tooltipBubble:G(G({boxSizing:"border-box",position:"relative"},il.labelMedium),{},{borderRadius:hl,border:"1px solid rgba(0, 0, 0, 0.1)",boxShadow:"".concat(0,"px ").concat(1,"px ")+"".concat(4,"px 0px ")+"rgba(0, 0, 0, ".concat(.1,")"),userSelect:"none"}),tooltipBubbleWithPadding:{padding:"10px 23px"},tooltipBubbleWithCloseIcon:{paddingRight:34},tooltipBubbleWithOnClick:{cursor:"pointer"},tooltipContent:{userSelect:"auto"},closeIcon:{display:"block",position:"absolute",right:10,top:10,padding:0,background:"inherit",border:"none"}});class vl extends a.PureComponent{constructor(){super(...arguments),j(this,"_mountRemeasureTimeout",void 0),j(this,"state",{targetElementClientRect:null,rootElementClientRect:null}),j(this,"_handleScroll",(e=>{var{rootElement:t,targetElement:r}=this.props,i=e.target;t.contains(i)&&i.contains(r)&&this.remeasure()})),j(this,"remeasure",(()=>{var{targetElement:e,rootElement:t}=this.props;this.setState({targetElementClientRect:e.getBoundingClientRect(),rootElementClientRect:t.getBoundingClientRect()})}))}componentDidMount(){this._mountRemeasureTimeout=setTimeout(this.remeasure,0),window.addEventListener("resize",this.remeasure),window.addEventListener("scroll",this._handleScroll,!0)}componentWillUnmount(){this._mountRemeasureTimeout&&clearTimeout(this._mountRemeasureTimeout),window.removeEventListener("resize",this.remeasure),window.removeEventListener("scroll",this._handleScroll,!0)}_computeTargetPointOffsets(e,t){var r,{offset:i,offsetFrom:n,side:o}=this.props.tooltipProps,s=e,a=t,l=i;if("arrow"===n&&(l+=9),"top"===o)r={left:s.left+s.width/2,top:s.top-l};else if("bottom"===o)r={left:s.left+s.width/2,top:s.bottom+l};else if("left"===o)r={left:s.left-l,top:s.top+s.height/2};else{if("right"!==o)throw new ce("unexpected side ".concat(o),pe.InvalidInput);r={left:s.right+l,top:s.top+s.height/2}}return{pxFromTop:r.top-a.top,pxFromBottom:a.bottom-r.top,pxFromLeft:r.left-a.left,pxFromRight:a.right-r.left}}_renderBubble(e){var t,{isAboveModal:r}=this.props,{side:i,tooltipMargin:n}=this.props.tooltipProps,o={},s={},l={};if("top"===i||"bottom"===i)t=yl.tooltipBubblePositionerTopBottom,s.direction="horizontal",s.pxFromStart=e.pxFromLeft,s.pxFromEnd=e.pxFromRight,l.marginLeft=n,l.marginRight=n;else{if("left"!==i&&"right"!==i)throw new ce("unexpected side ".concat(i),pe.InvalidInput);t=yl.tooltipBubblePositionerLeftRight,s.direction="vertical",s.pxFromStart=e.pxFromTop,s.pxFromEnd=e.pxFromBottom,l.marginTop=n,l.marginBottom=n}if("top"===i)o.bottom=e.pxFromBottom;else if("bottom"===i)o.top=e.pxFromTop;else if("left"===i)o.right=e.pxFromRight;else{if("right"!==i)throw new ce("unexpected side ".concat(i),pe.InvalidInput);o.left=e.pxFromLeft}return a.createElement("div",{className:g(yl.tooltipBubblePositioner,t,r&&yl.tooltipAboveModal),style:o},a.createElement(ll,s,a.createElement("div",{className:g(yl.tooltipBubbleWrapper),style:l},a.createElement(gl,{tooltipProps:this.props.tooltipProps,dismiss:this.props.dismiss}))))}_renderArrow(e,t){var{isAboveModal:r}=this.props,{side:i,tooltipMargin:n}=this.props.tooltipProps,o={};if("top"===i)o.bottom=e.pxFromBottom-9+1;else if("bottom"===i)o.top=e.pxFromTop-9+1;else if("left"===i)o.right=e.pxFromRight-9+1;else{if("right"!==i)throw new ce("unexpected side ".concat(i),pe.InvalidInput);o.left=e.pxFromLeft-9+1}var s=n+hl;if("top"===i||"bottom"===i){var l=s,p=t.width-18-s;o.left=e.pxFromLeft-9,o.left=Math.min(o.left,p),o.left=Math.max(o.left,l)}else{if("left"!==i&&"right"!==i)throw new ce("unexpected side ".concat(i),pe.InvalidInput);var h=s,c=t.height-18-s;o.top=e.pxFromTop-9,o.top=Math.min(o.top,c),o.top=Math.max(o.top,h)}return a.createElement("div",{className:g(yl.tooltipArrowPositioner,r&&yl.tooltipAboveModal),style:o},a.createElement(dl,{tooltipProps:this.props.tooltipProps}))}_buildMediaFilterStyle(){var{media:e}=this.props.tooltipProps;return e?m.create({mediaFilter:{display:"none",[e]:{display:"block"}}}).mediaFilter:null}render(){var{targetElementClientRect:e,rootElementClientRect:t}=this.state;if(!e||!t)return null;var r=this._computeTargetPointOffsets(e,t);return a.createElement("div",{className:g(this._buildMediaFilterStyle())},this._renderBubble(r),this._renderArrow(r,t))}}var yl=m.create({tooltipBubblePositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"},tooltipAboveModal:{zIndex:1090},tooltipBubblePositionerTopBottom:{left:0,width:"100%"},tooltipBubblePositionerLeftRight:{top:0,height:"100%"},tooltipBubbleWrapper:{pointerEvents:"auto"},tooltipArrowPositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"}});class bl extends a.Component{constructor(){super(...arguments),j(this,"_mountNode",void 0),j(this,"_tooltipPositioner",void 0)}componentDidMount(){var e=document.createElement("div");this._mountNode=e,this.props.rootElement.appendChild(e),this._renderInMountNode(e)}componentDidUpdate(){var e=this._mountNode;e&&this._renderInMountNode(e)}componentWillUnmount(){var e=this._mountNode;e&&(v.unmountComponentAtNode(e),this.props.rootElement.removeChild(e))}remeasure(){this._tooltipPositioner&&this._tooltipPositioner.remeasure()}_renderInMountNode(e){var{tooltipProps:t,dismiss:r,rootElement:i,targetElement:n,isAboveModal:o}=this.props;v.render(a.createElement(vl,{tooltipProps:t,dismiss:r,rootElement:i,targetElement:n,isAboveModal:o,ref:e=>this._tooltipPositioner=e}),e)}render(){return null}}var xl=["children"],wl=Object.freeze({side:"top",offset:0,offsetFrom:"bubble",tooltipMargin:0,noPadding:!1,color:el.gray17,inverted:!1,dismissOnClickClose:!1,toggleOnHover:!0,showOnMount:!1});class Cl extends a.PureComponent{constructor(e){super(e),j(this,"_rootElement",void 0),j(this,"_wrapper",void 0),j(this,"_targetElement",void 0),j(this,"_tooltipPortal",void 0),j(this,"_visibilityObserver",void 0),j(this,"_isMounted",void 0),j(this,"_targetElementMountTimeout",void 0),j(this,"_handleVisibilityChange",(e=>{this.setState({targetElementIsVisible:e})})),j(this,"_handleMouseEnter",(()=>{this.setState({hovered:!0})})),j(this,"_handleMouseLeave",(()=>{this.setState({hovered:!1})})),j(this,"_handleDismiss",(()=>{null==this.props.dismissed&&this.setState({dismissed:!0}),this.props.onDismiss&&this.props.onDismiss()})),this._isMounted=!1,this.state={dismissed:null!=e.dismissed&&e.dismissed,hovered:!1,targetElementIsVisible:!1}}componentDidMount(){this._isMounted=!0,this._registerVisibilityObserver()}UNSAFE_componentWillReceiveProps(e){null!=e.dismissed&&this.setState({dismissed:e.dismissed})}UNSAFE_componentWillUpdate(){this._registerVisibilityObserver()}componentWillUnmount(){this._isMounted=!1,this._targetElementMountTimeout&&clearTimeout(this._targetElementMountTimeout),this._visibilityObserver.disconnect()}_findRootElement(){return this.context.modalContainerElement||document.getElementById("mission-task-container")||document.getElementById("outer-wrapper")||document.body}_registerVisibilityObserver(){var e=this._findRootElement();if(!e)throw new ce("Failed to mount NewTooltip: we need a #outer-wrapper or document.body element.",pe.Internal);if(e!==this._rootElement){this._rootElement=e,this._visibilityObserver&&this._visibilityObserver.disconnect(),this._visibilityObserver=function(e,t,r){return new al(e,t,r)}(e,this._handleVisibilityChange);var t=this._wrapper;if(!t)throw new ce("NewTooltip expected a wrapper element after mount",pe.Internal);for(var r=t;r.hasAttribute("data-tooltip-wrapper");)if(!(r=r.childNodes[0]))throw new ce("NewTooltip expected wrapper element to have a child",pe.Internal);this._targetElement=r,this._targetElementMountTimeout=setTimeout((()=>{var e=this._targetElement;if(!e)throw new ce("NewTooltip should have a target element after mounting.",pe.Internal);ae().isDevServer&&"inline"===getComputedStyle(e).display&&(he.error("Warning: The children of a NewTooltip element must be block-like, but this element seems to have `display: inline`. This could break position tracking.",pe.Internal),he.log("NewTooltip Target Element:",{targetElement:e.outerHTML})),this._visibilityObserver.setTargetElement(e),this.forceUpdate()}),0)}}_shouldShowTooltip(){var{toggleOnHover:e,showOnMount:t}=this.props,{dismissed:r,targetElementIsVisible:i}=this.state;return!1!==i&&(!r&&(!!t||!(!e||!this.state.hovered)))}remeasure(){this._tooltipPortal&&this._tooltipPortal.remeasure()}render(){var{children:e,toggleOnHover:t}=this.props,r=$(this.props,xl);return a.createElement("div",{className:g(kl.targetElement),onMouseEnter:t?this._handleMouseEnter:void 0,onMouseLeave:t?this._handleMouseLeave:void 0,ref:e=>this._wrapper=e,"data-tooltip-wrapper":!0,"data-test-id":"question-id"},e,this._targetElement&&this._shouldShowTooltip()&&a.createElement(bl,{tooltipProps:r,dismiss:this._handleDismiss,rootElement:this._rootElement,targetElement:this._targetElement,isAboveModal:!!this.context.modalContainerElement,ref:e=>this._tooltipPortal=e}))}}j(Cl,"defaultProps",wl),Cl.contextTypes={modalContainerElement:d.instanceOf(HTMLElement)};var kl=m.create({targetElement:{display:"inline"}});class El extends a.PureComponent{constructor(){super(...arguments),j(this,"_handleKeyDown",(e=>{"Tab"===e.key&&(this.props.onDismiss(),e.preventDefault())}))}_renderTooltipContent(){return a.createElement("div",{onKeyDown:this._handleKeyDown},a.createElement(ol,this.props.buttonProps))}render(){return a.createElement("div",null,a.createElement(Cl,{content:this._renderTooltipContent(),offsetFrom:"arrow",offset:10,dismissed:this.props.dismissed,showOnMount:!0,toggleOnHover:!1,onClick:()=>this.props.buttonProps.onClick(),media:$s.mdOrLarger},this.props.children),!this.props.dismissed&&a.createElement(Sl,{onDismiss:this.props.onDismiss}))}}class Sl extends a.PureComponent{constructor(){super(...arguments),j(this,"_handleGlobalClick",(()=>{this.props.onDismiss()})),j(this,"_handleGlobalKeyup",(e=>{"Escape"===e.key&&this.props.onDismiss()}))}componentDidMount(){setTimeout((()=>{window.addEventListener("click",this._handleGlobalClick),window.addEventListener("keyup",this._handleGlobalKeyup)}),0)}componentWillUnmount(){window.removeEventListener("click",this._handleGlobalClick),window.removeEventListener("keyup",this._handleGlobalKeyup)}render(){return null}}var _l={path:"M27.218 6.82l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:27.284};class Ml extends a.PureComponent{constructor(){super(...arguments),j(this,"_menu",void 0),j(this,"_menuButton",void 0),j(this,"_crossOutButtonIsFocused",void 0),j(this,"state",{hovered:!1,opened:!1,slidePanelCovered:!0,usingKeyboardFocus:!1,wasCrossedOutOnLastOpen:!1}),j(this,"_openMenu",(()=>{var e=null!=this._menu&&this._menu.contains(document.activeElement);this.setState({opened:!0,usingKeyboardFocus:e,wasCrossedOutOnLastOpen:this.props.crossedOut})})),j(this,"_closeMenu",(()=>{this._crossOutButtonIsFocused&&this._menuButton&&this._menuButton.focus(),this.setState({opened:!1,slidePanelCovered:!0})})),j(this,"_handleMenuClick",((e,t)=>{t?this._openMenu():this._closeMenu(),e.preventDefault()})),j(this,"_handleCrossedOutButtonClick",(e=>{this.props.onCrossedOutChange(e),this._closeMenu()})),j(this,"_handleSlideTransitionEnd",(()=>{this.state.opened&&this.setState({slidePanelCovered:!1})}))}UNSAFE_componentWillReceiveProps(e){e.enabled||this._closeMenu()}_getButtonProps(e){var t=this.state.wasCrossedOutOnLastOpen;return{onClick:()=>{this._handleCrossedOutButtonClick(!t)},onFocus:()=>{this._crossOutButtonIsFocused=!0},onBlur:()=>{this._crossOutButtonIsFocused=!1},crossedOut:t,pos:this.props.pos,primaryProductColor:this.props.primaryProductColor,usingKeyboardFocus:this.state.usingKeyboardFocus,theme:e}}_getMenuIconColor(){return this.state.opened?this.props.primaryProductColor:this.state.hovered?_.offBlack:_.offBlack50}_renderMenu(){var{pos:e,isSatProduct:t}=this.props,{opened:r}=this.state,i=g(Tl.menu,t&&Tl.spacing);return a.createElement("div",{ref:e=>this._menu=e,className:i,onClick:e=>this._handleMenuClick(e,!r),onMouseEnter:()=>this.setState({hovered:!0}),onMouseLeave:()=>this.setState({hovered:!1})},a.createElement(El,{dismissed:!this.state.opened,onDismiss:this._closeMenu,buttonProps:this._getButtonProps("day")},a.createElement("button",{type:"button","aria-label":o._("Open menu for Choice %(letter)s",{letter:aa(e)}),className:g([Tl.menuButton]),onClick:e=>this._handleMenuClick(e,!r),onMouseDown:e=>e.preventDefault(),ref:e=>this._menuButton=e},a.createElement(ua,{className:g(Tl.menuIcon),icon:_l,size:3,color:this._getMenuIconColor()}))))}_renderSlidePanel(){var e=this._getButtonProps("night"),{slidePanelCovered:t}=this.state;return a.createElement("div",{className:g(Tl.slidePanel,t&&Tl.slidePanelCovered),onClick:e.onClick,"aria-hidden":t},a.createElement(ol,Y({},e,{disabled:t,tabFocusable:!t})))}render(){var{enabled:e}=this.props,{opened:t}=this.state;return a.createElement("div",{className:g(Tl.wrapper)},a.createElement("div",{className:g(Tl.slidingContent,e&&Tl.slidingContentEnabled,t&&Tl.slidingContentOpen),onTransitionEnd:this._handleSlideTransitionEnd},a.createElement("div",{className:g(Tl.content)},this.props.children),e&&this._renderMenu()),e&&this._renderSlidePanel())}}var Tl=m.create({wrapper:{display:"block",position:"relative"},slidingContent:{display:"flex",flexDirection:"row",alignItems:"stretch"},slidingContentEnabled:{[$s.smOrSmaller]:{transition:"transform 0.2s ease-out",backgroundColor:_.white}},slidingContentOpen:{[$s.smOrSmaller]:{transform:"translateX(-".concat(96,"px)")}},content:{display:"block",flex:"1 1 0"},menu:{cursor:"pointer",boxSizing:"border-box",width:32,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",[$s.smOrSmaller]:{paddingRight:8}},menuButton:{background:"none",border:"none",font:"inherit",padding:0,textAlign:"inherit",cursor:"pointer",display:"flex",flexDirection:"column",justifyContent:"center",height:16},menuIcon:{display:"block"},slidePanel:{position:"absolute",top:0,right:0,boxSizing:"border-box",width:96,height:"100%",paddingLeft:8,paddingRight:8,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",background:_.offBlack50,cursor:"pointer",[$s.mdOrLarger]:{display:"none"}},spacing:{paddingRight:12},slidePanelCovered:{zIndex:-1}});class Il extends a.Component{_renderText(){var{checked:e,correct:t,crossedOut:r}=this.props;return t?e?o._("Correct (selected)"):r?o._("Correct (but you crossed it out)"):o._("Correct"):e?o._("Incorrect (selected)"):o._("Incorrect")}render(){var e,{checked:t,correct:r,previouslyAnswered:i}=this.props;return e=r?Pl.correct:t||i?Pl.incorrectAnswered:Pl.incorrect,a.createElement("div",{className:g(Pl.text,e)},this._renderText())}}var Pl=m.create({text:{alignItems:"center",display:"flex",fontSize:12,height:32,textTransform:"uppercase"},correct:{color:"#71B307"},incorrectAnswered:{color:"#F86700"},incorrect:{color:Q}}),Nl=["inputRef","onChecked","goToPrevChoice","goToNextChoice"];class Al extends a.Component{constructor(){super(...arguments),j(this,"_inputElement",void 0),j(this,"handleClick",(e=>{this.props.onChecked(!this.props.checked)})),j(this,"handleKeyUp",(e=>{" "===e.key&&(this.props.onChecked(!this.props.checked),e.preventDefault())})),j(this,"handleChange",(e=>{!this.props.checked&&e.target.checked&&this.props.onChecked(!0)})),j(this,"handleKeyDown",(e=>{" "===e.key?e.preventDefault():"ArrowUp"===e.key||"ArrowLeft"===e.key?(this.props.goToPrevChoice(),e.preventDefault()):"ArrowDown"!==e.key&&"ArrowRight"!==e.key||(this.props.goToNextChoice(),e.preventDefault())})),j(this,"handleRef",(e=>{this._inputElement=e,this.props.inputRef&&this.props.inputRef(e)}))}render(){var e=$(this.props,Nl);return a.createElement("input",Y({},e,{type:"radio",onChange:this.handleChange,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,ref:this.handleRef}))}}j(Al,"propTypes",{checked:d.bool.isRequired,inputRef:d.func,onChecked:d.func.isRequired,goToPrevChoice:d.func.isRequired,goToNextChoice:d.func.isRequired});var Rl={backgroundColor:"#E4F3F9",outline:"2px solid ".concat("#0084CE"),zIndex:1};class Fl extends a.Component{constructor(){super(...arguments),j(this,"justFinishedTouch",void 0),j(this,"justFinishedTimeoutID",void 0),j(this,"_input",void 0),j(this,"state",{isInputFocused:!1,isInputActive:!1}),j(this,"onInputFocus",(()=>{this.setState({isInputFocused:!0})})),j(this,"onInputBlur",(()=>{this.setState({isInputFocused:!1})})),j(this,"onInputMouseDown",(e=>{"mousedown"===e.type&&this.justFinishedTouch||(this.setState({isInputActive:!0}),this.props.apiOptions.satStyling&&this._input&&this._input.focus())})),j(this,"onInputMouseUp",(e=>{if("mouseup"!==e.type||!this.justFinishedTouch){if("touchend"===e.type)return this.justFinishedTouch=!0,null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID),void(this.justFinishedTimeoutID=setTimeout((()=>{this.setState({isInputActive:!1}),this.justFinishedTouch=!1}),10));this.setState({isInputActive:!1}),this.props.apiOptions.satStyling&&this._input&&this._input.focus()}})),j(this,"onInputMouseOut",(()=>{this.setState({isInputActive:!1})})),j(this,"inputRef",(e=>{this._input=e})),j(this,"renderOptionStatus",(()=>{var{correct:e,checked:t,crossedOut:r,reviewMode:i,previouslyAnswered:n}=this.props;return this.props.apiOptions.satStyling?null:i||n?a.createElement(Il,{checked:t,correct:e,crossedOut:r,previouslyAnswered:n}):null})),j(this,"renderChoiceIcon",(()=>{var{radioStyleVersion:e,primaryProductColor:t}=this.props.apiOptions.styling;return void 0!==e&&"final"===e||this.props.apiOptions.satStyling?a.createElement(ca,{pos:this.props.pos,correct:this.props.correct,crossedOut:this.props.crossedOut,pressed:this.state.isInputActive,focused:this.state.isInputFocused,checked:this.props.checked,showCorrectness:this.props.showCorrectness,reviewMode:this.props.reviewMode,product:this.props.apiOptions.satStyling?"sat":"library",primaryProductColor:t,previouslyAnswered:this.props.previouslyAnswered}):null})),j(this,"_setChecked",(e=>{e?this._sendChange({checked:!0,crossedOut:!1}):this._sendChange({checked:!1})})),j(this,"_setCrossedOut",(e=>{e?this._sendChange({checked:!1,crossedOut:!0}):this._sendChange({crossedOut:!1})})),j(this,"_sendChange",(e=>{var t=null!=e.checked?e.checked:this.props.checked,r=null!=e.crossedOut?e.crossedOut:this.props.crossedOut;this.props.onChange({checked:t,crossedOut:r})})),j(this,"focusInput",(()=>{var e;null===(e=this._input)||void 0===e||e.focus()}))}UNSAFE_componentWillUpdate(e){this.state.isInputFocused&&e.disabled&&this.setState({isInputFocused:!1})}componentWillUnmount(){null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID)}render(){var e=this.props.apiOptions.satStyling,t=this.props.apiOptions.isMobile,{radioStyleVersion:r}=this.props.apiOptions.styling,i=void 0!==r&&"final"===r,n=s(this.props.className,"checkbox-label",g(Ol.label,t&&ta.disableTextSelection,!e&&Ol.responsiveLabel,e&&Ol.satLabel)),o=s(g(this.state.isInputFocused&&Ol.satDescriptionInputFocused,this.state.isInputActive&&Ol.satDescriptionInputActive)),l=this.props.showCorrectness&&!this.props.correct,p=this.props.checked&&!l,h={type:this.props.type,name:this.props.groupName,id:"".concat(this.props.groupName,"-choice-").concat(this.props.pos),checked:p,disabled:this.props.disabled,onFocus:this.onInputFocus,onBlur:this.onInputBlur,className:g(!i&&ta.perseusInteractive,!i&&Ol.input,!i&&ta.responsiveInput,!i&&!e&&ta.responsiveRadioInput,!i&&!e&&this.state.isInputActive&&ta.responsiveRadioInputActive,i&&ta.perseusSrOnly,e&&ta.perseusSrOnly,e&&this.props.reviewMode&&Ol.satReviewInput)},c=null;c="radio"===this.props.type?a.createElement(Al,Y({onChecked:e=>this._setChecked(e),goToPrevChoice:this.props.goToPrevChoice,goToNextChoice:this.props.goToNextChoice,inputRef:this.inputRef},h)):a.createElement("input",Y({onChange:e=>this._setChecked(e.target.checked),ref:this.inputRef},h));var{reviewMode:d,correct:u,checked:m}=this.props,f=e&&d&&u,v=e&&d&&!u&&m,y=s("description",f&&"sat-correct",v&&"sat-incorrect",g(!e&&Ol.description,e&&Ol.satDescription,f&&Ol.satDescriptionCorrect,f&&m&&Ol.satDescriptionCorrectChecked,v&&Ol.satDescriptionIncorrectChecked)),b=s("checkbox",g(ta.perseusInteractive,!e&&Ol.choiceIconWrapper,e&&Ol.satCheckboxOptionContent)),x=s("checkbox-and-option",g(!e&&Ol.intermediateResponsiveCheckbox,!e&&d&&Ol.intermediateResponsiveCheckboxReview)),w=s("perseus-radio-rationale-content",g(Ol.rationale,!e&&Ol.nonSatRationale,e&&Ol.satReviewRationale)),C=this.props.editMode?"div":"label",k=this.props.apiOptions.crossOutEnabled&&!this.props.showCorrectness,E=!e&&!d&&this.props.apiOptions.readOnly||k&&this.props.crossedOut;return a.createElement("div",{className:e?o:void 0},a.createElement(Ml,{enabled:k,pos:this.props.pos,primaryProductColor:this.props.apiOptions.styling.primaryProductColor,crossedOut:this.props.crossedOut,onCrossedOutChange:this._setCrossedOut,isSatProduct:e},a.createElement(C,{htmlFor:this.props.editMode?void 0:h.id,className:n,style:{opacity:E?.5:1}},a.createElement("div",{className:y,onMouseDown:this.onInputMouseDown,onMouseUp:this.onInputMouseUp,onMouseOut:this.onInputMouseOut,onTouchStart:this.onInputMouseDown,onTouchEnd:this.onInputMouseUp},a.createElement("div",{className:x},a.createElement("span",{className:b},c,this.renderChoiceIcon()),a.createElement("span",{className:s(Jt.RADIO.OPTION_CONTENT,Jt.INTERACTIVE,g(e&&Ol.satRadioOptionContent,e&&d&&Ol.satReviewRadioOptionContent)),style:{cursor:"default"}},a.createElement("div",{className:g(Ol.optionStatusContainer)},this.renderOptionStatus()),a.createElement("div",null,this.props.content))),this.props.showRationale&&a.createElement("div",{className:w,"data-test-id":"perseus-radio-rationale-content-".concat(this.props.pos)},this.props.rationale)))))}}j(Fl,"propTypes",{apiOptions:d.shape({satStyling:d.bool,isMobile:d.bool,styling:d.shape({radioStyleVersion:d.oneOf(["intermediate","final"]),primaryProductColor:d.string}),readOnly:d.bool}),checked:d.bool,className:d.string,rationale:d.node,content:d.node,correct:d.bool,deselectEnabled:d.bool,disabled:d.bool,editMode:d.bool,groupName:d.string,isLastChoice:d.bool,pos:d.number,reviewMode:d.bool,showRationale:d.bool,showCorrectness:d.bool,type:d.string,crossedOut:d.bool,previouslyAnswered:d.bool,onChange:d.func,goToPrevChoice:d.func.isRequired,goToNextChoice:d.func.isRequired}),j(Fl,"defaultProps",{apiOptions:{styling:{}},checked:!1,classSet:{},correct:!1,disabled:!1,editMode:!1,onChange:function(){},showRationale:!1,type:"radio",pos:0,previouslyAnswered:!1});var Ol=m.create({description:{display:"inline-block",width:"100%"},satDescription:{display:"block",position:"relative",boxSizing:"border-box",cursor:"pointer",marginLeft:0,padding:"17px 14px"},satDescriptionInputFocused:G(G({},Rl),{},{display:"block"}),satDescriptionInputActive:G(G({},Rl),{},{backgroundColor:"#D0EDF4"}),satDescriptionCorrect:{color:"#009900"},satDescriptionCorrectChecked:{backgroundColor:"#E4F7E4"},satDescriptionIncorrectChecked:{color:"#990000",backgroundColor:"#F2EBEB"},input:{display:"inline-block",width:20,margin:3,marginLeft:-20,marginRight:0,float:"none"},satReviewInput:{pointerEvents:"none"},satRadioOptionContent:{userSelect:"text",display:"block",marginLeft:45,cursor:"inherit"},satReviewRadioOptionContent:{fontWeight:"bold"},satCheckboxOptionContent:{position:"absolute",display:"block",top:"50%",margin:"-16px 0 0 0",width:"auto"},choiceIconWrapper:{display:"flex",marginRight:12,flexShrink:0},optionStatusContainer:{display:"block"},rationale:{display:"block"},nonSatRationale:{padding:"16px 16px",paddingTop:0,marginLeft:44,[$s.smOrSmaller]:{padding:"12px 16px",paddingTop:0}},satReviewRationale:{marginTop:13,marginLeft:45},label:{display:"block",transition:"opacity 0.2s ease-out"},responsiveLabel:{WebkitTapHighlightColor:"transparent",display:"flex",alignItems:"stretch"},satLabel:{cursor:"pointer"},intermediateResponsiveCheckbox:{display:"flex",alignItems:"center",padding:"16px 16px",[$s.smOrSmaller]:{padding:"12px 16px"}},intermediateResponsiveCheckboxReview:{alignItems:"flex-start"}});class Dl extends a.Component{constructor(){super(...arguments),j(this,"_choice",void 0),j(this,"focusInput",(()=>{this._choice.focusInput()}))}render(){var e=G(G({},this.props),{},{className:s(this.props.className,"none-of-above"),content:this.props.showContent?this.props.content:a.createElement(Bo,{key:"noneOfTheAboveRenderer",content:o._("None of the above")}),ref:e=>this._choice=e});return a.createElement(Fl,e)}}j(Dl,"propTypes",{className:d.string,content:d.node,showContent:d.bool}),j(Dl,"defaultProps",{showContent:!0});var{captureScratchpadTouchStart:Ll}=De,Bl=d.arrayOf(d.shape({checked:d.bool,crossedOut:d.bool,content:d.node,rationale:d.node,hasRationale:d.bool,showRationale:d.bool,showCorrectness:d.bool,correct:d.bool,originalIndex:d.number,isNoneOfTheAbove:d.bool}));class zl extends a.Component{constructor(){super(...arguments),j(this,"state",{radioGroupName:h.uniqueId("perseus_radio_")}),j(this,"updateChoice",((e,t)=>{var r;r=t.checked&&!this.props.multipleSelect?this.props.choices.map((e=>!1)):this.props.choices.map((e=>e.checked));var i=this.props.choices.map((e=>e.crossedOut));r[e]=t.checked,i[e]=t.crossedOut,this.props.onChange({checked:r,crossedOut:i})})),j(this,"focus",(e=>(v.findDOMNode(this.refs["radio"+(e||0)]).focus(),!0))),j(this,"getInstructionsText",(()=>this.props.multipleSelect?this.props.countChoices?o._("Choose %(numCorrect)s answers:",{numCorrect:this.props.numCorrect}):o._("Choose all answers that apply:"):o._("Choose 1 answer:"))),j(this,"deselectEnabled",(()=>this.props.apiOptions.isMobile||this.props.deselectEnabled)),j(this,"goToChoice",(e=>{var t=this.props.choices.length;e<0&&(e+=t),e>=t&&(e-=t);var r=this.refs["radio".concat(e)];if(r){r.focusInput();var i=this.props.choices.map((e=>e.crossedOut)),n=this.props.choices.map((e=>!1));this.props.choices[e].crossedOut||(n[e]=!0),this.props.onChange({checked:n,crossedOut:i})}else he.error("found no choice at index ".concat(e,", even after ")+"wrapping it to be within bounds",pe.Internal,{loggedMetadata:{choices:JSON.stringify(this.props.choices)}})}))}componentDidUpdate(e){var{apiOptions:t,choices:r,isLastUsedWidget:i,reviewModeRubric:n}=this.props;if(t.canScrollPage&&i&&n&&!e.reviewModeRubric){var o=r.findIndex((e=>e.checked));if(o>=0){var s=v.findDOMNode(this.refs["radio"+o]);na(s)}}}render(){var e=this.props.multipleSelect?"checkbox":"radio",t=this.props.reviewModeRubric,r=!!t,i=zl.styles,n=this.props.apiOptions.satStyling,o=this.props.apiOptions.isMobile,l=this.props.choices,p=l[0].highlighted,c=l[l.length-1].highlighted,d=s("perseus-widget-radio",!this.props.editMode&&"perseus-rendered-radio",g(i.radio,!n&&i.responsiveRadioContainer,!n&&p&&o&&i.radioContainerFirstHighlighted,!n&&c&&o&&i.radioContainerLastHighlighted,n&&i.satRadio)),u=s("instructions",g(i.instructions,o&&i.instructionsMobile)),m=this.getInstructionsText(),f=!n,v=g(i.responsiveFieldset),y=a.createElement("fieldset",{className:"perseus-widget-radio-fieldset ".concat(v)},a.createElement("legend",{className:"perseus-sr-only"},m),f&&a.createElement("div",{className:u},m),a.createElement("ul",{className:d},this.props.choices.map((function(o,l){var p=Fl,c={ref:"radio".concat(l),apiOptions:this.props.apiOptions,checked:o.checked,crossedOut:o.crossedOut,previouslyAnswered:o.previouslyAnswered,reviewMode:r,correct:o.correct,rationale:o.rationale,content:o.content,disabled:this.props.apiOptions.readOnly||o.disabled,editMode:this.props.editMode,groupName:this.state.radioGroupName,isLastChoice:l===this.props.choices.length-1,showCorrectness:r||!!o.showCorrectness,showRationale:o.hasRationale&&(r||o.showRationale),type:e,pos:l,deselectEnabled:this.deselectEnabled(),onChange:e=>{this.updateChoice(l,e)},goToPrevChoice:()=>this.goToChoice(l-1),goToNextChoice:()=>this.goToChoice(l+1)};o.isNoneOfTheAbove&&(p=Dl,h.extend(c,{showContent:o.revealNoneOfTheAbove}));var d=this.props.choices[l+1],u=!!d&&d.highlighted,m=e=>{var s=n&&r&&e,a=n&&r&&d&&d.checked;return g(ta.aboveScratchpad,i.item,!n&&i.responsiveItem,!n&&e&&i.selectedItem,!n&&e&&o.highlighted&&i.aboveBackdrop,!n&&e&&o.highlighted&&this.props.apiOptions.isMobile&&i.aboveBackdropMobile,!n&&u&&this.props.apiOptions.isMobile&&i.nextHighlighted,n&&i.satRadioOption,s&&!o.correct&&i.satRadioOptionIncorrect,s&&o.correct&&i.satRadioOptionCorrect,a&&!d.correct&&i.satRadioOptionNextIncorrect,a&&d.correct&&i.satRadioOptionNextCorrect,n&&t&&i.satReviewRadioOption)};m(!0);var f=s(m(o.checked),Jt.RADIO.OPTION,o.checked&&Jt.RADIO.SELECTED,r&&t.choices[l].correct&&Jt.CORRECT,r&&!t.choices[l].correct&&Jt.INCORRECT),v=null,y=null;return this.props.editMode&&(y=e=>{for(var t=e.target;t&&t!==v;){if(t.getAttribute("data-is-radio-icon"))return void this.updateChoice(l,{checked:!o.checked});t=t.parentNode}}),a.createElement("li",{key:l,ref:e=>v=e,className:f,onClick:y,onTouchStart:this.props.labelWrap?Ll:null},a.createElement(p,c))}),this)));return a.createElement("div",{className:g(!n&&i.responsiveContainer)},y)}}j(zl,"propTypes",{apiOptions:d.shape({readOnly:d.bool,satStyling:d.bool,isMobile:d.bool,styling:d.shape({radioStyleVersion:d.oneOf(["intermediate","final"])}),canScrollPage:d.bool}),choices:Bl,deselectEnabled:d.bool,editMode:d.bool,labelWrap:d.bool,countChoices:d.bool,numCorrect:d.number,multipleSelect:d.bool,reviewModeRubric:d.shape({choices:Bl}),onChange:d.func,isLastUsedWidget:d.bool}),j(zl,"styles",m.create({instructions:{display:"block",color:ee,fontSize:14,lineHeight:1.25,fontStyle:"normal",fontWeight:"bold",marginBottom:16},instructionsMobile:{fontSize:18,[$s.smOrSmaller]:{fontSize:16},[$s.xl]:{fontSize:20}},radio:{width:"100%"},responsiveRadioContainer:{borderBottom:"1px solid ".concat("#BABEC2"),borderTop:"1px solid ".concat("#BABEC2"),width:"auto",[$s.smOrSmaller]:{marginLeft:-16,marginRight:-16}},radioContainerFirstHighlighted:{borderTop:"1px solid rgba(0, 0, 0, 0)"},radioContainerLastHighlighted:{borderBottom:"1px solid rgba(0, 0, 0, 0)"},satRadio:{background:"none",marginLeft:0,userSelect:"none"},satRadioOption:{margin:0,padding:0,borderBottom:"1px solid #ccc",":first-child":{borderTop:"1px solid #ccc"}},satRadioOptionCorrect:{borderBottomColor:"#00CC00",":first-child":{borderTopColor:"#00CC00"}},satRadioOptionIncorrect:{borderBottomColor:"#CC5252",":first-child":{borderTopColor:"#CC5252"}},satRadioOptionNextCorrect:{borderBottomColor:"#00CC00"},satRadioOptionNextIncorrect:{borderBottomColor:"#CC5252"},satReviewRadioOption:{pointerEvents:"none"},item:{marginLeft:20},inlineItem:{display:"inline-block",paddingLeft:20,verticalAlign:"middle"},responsiveItem:{marginLeft:0,padding:0,":not(:last-child)":{borderBottom:"1px solid ".concat("#BABEC2")}},selectedItem:{background:"white"},aboveBackdrop:{position:"relative",zIndex:1062},aboveBackdropMobile:{boxShadow:"0 0 4px 0 rgba(0, 0, 0, 0.2),0 0 2px 0 rgba(0, 0, 0, 0.1)",":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},nextHighlighted:{":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},responsiveContainer:{overflow:"auto",marginLeft:-16,marginRight:-16,paddingLeft:16},responsiveFieldset:{paddingRight:16}})),j(zl,"defaultProps",{editMode:!1});class Hl extends a.Component{constructor(){super(...arguments),j(this,"_renderRenderer",(e=>{var t=1,r={},i=(e=e||"").replace(/\{\{passage-ref (\d+) (\d+)(?: "([^"]*)")?\}\}/g,((e,i,n,o)=>{var s="passage-ref "+t;return t++,r[s]={type:"passage-ref",graded:!1,options:{passageNumber:parseInt(i),referenceNumber:parseInt(n),summaryText:o},version:zs.version},"[["+De.snowman+" "+s+"]]"}));return a.createElement(Bo,{key:"choiceContentRenderer",content:i,widgets:r,findExternalWidgets:this.props.findWidgets,alwaysUpdate:!0,linterContext:G(G({},this.props.linterContext),{},{blockHighlight:!0})})})),j(this,"focus",(e=>this.refs.baseRadio.focus(e))),j(this,"updateChoices",(e=>{var t,{choiceStates:r,choices:i}=this.props;(t=r?r.map((e=>G({},e))):i.map((()=>({selected:!1,crossedOut:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1,readOnly:!1})))).forEach(((t,r)=>{t.selected=e.checked[r],t.crossedOut=e.crossedOut[r]})),this.props.onChange({choiceStates:t}),this.props.trackInteraction()})),j(this,"getUserInput",(()=>Hl.getUserInputFromProps(this.props))),j(this,"simpleValidate",(e=>Hl.validate(this.getUserInput(),e))),j(this,"showRationalesForCurrentlySelectedChoices",(e=>{var{choiceStates:t}=this.props;if(t){var r=this.simpleValidate(e),i="points"===r.type&&r.total===r.earned,n=t.map((e=>G(G({},e),{},{highlighted:e.selected,rationaleShown:e.selected||e.rationaleShown||i,readOnly:e.selected||e.readOnly||i,correctnessShown:e.selected||e.correctnessShown,previouslyAnswered:e.previouslyAnswered||e.selected})));this.props.onChange({choiceStates:n},null,!0)}})),j(this,"deselectIncorrectSelectedChoices",(()=>{if(this.props.choiceStates){var e=this.props.choiceStates.map(((e,t)=>G(G({},e),{},{selected:e.selected&&!!this.props.choices[t].correct,highlighted:!1})));this.props.onChange({choiceStates:e},null,!1)}}))}render(){var e,t=this.props.choices;return e=this.props.static?h.map(t,(e=>({selected:e.correct,crossedOut:e.crossedOut,readOnly:!0,highlighted:!1,rationaleShown:!0,correctnessShown:!0,previouslyAnswered:!1}))):this.props.choiceStates?this.props.choiceStates:this.props.values?h.map(this.props.values,(e=>({selected:e,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))):h.map(t,(()=>({selected:!1,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))),t=h.map(t,((t,r)=>{var i=t.isNoneOfTheAbove&&!t.content?o._("None of the above"):t.content,{selected:n,crossedOut:s,rationaleShown:a,correctnessShown:l,readOnly:p,highlighted:h,previouslyAnswered:c}=e[r],d=this.props.reviewModeRubric&&this.props.reviewModeRubric.choices[r];return{content:this._renderRenderer(i),checked:n,correct:void 0===t.correct?!!d&&d.correct:t.correct,disabled:p,hasRationale:!!t.clue,rationale:this._renderRenderer(t.clue),showRationale:a,showCorrectness:l,isNoneOfTheAbove:t.isNoneOfTheAbove,revealNoneOfTheAbove:this.props.questionCompleted&&n,crossedOut:s,highlighted:h,previouslyAnswered:c}})),a.createElement(zl,{ref:"baseRadio",labelWrap:!0,multipleSelect:this.props.multipleSelect,countChoices:this.props.countChoices,numCorrect:this.props.numCorrect,choices:t,onChange:this.updateChoices,reviewModeRubric:this.props.reviewModeRubric,deselectEnabled:this.props.deselectEnabled,apiOptions:this.props.apiOptions,isLastUsedWidget:this.props.isLastUsedWidget})}static validate(e,t){var r=h.reduce(e.choicesSelected,((e,t)=>e+(t?1:0)),0);return 0===r?{type:"invalid",message:null}:e.numCorrect>1&&r!==e.numCorrect?{type:"invalid",message:o._("Please choose the correct number of answers.")}:e.noneOfTheAboveSelected&&r>1?{type:"invalid",message:o._("'None of the above' may not be selected when other answers are selected.")}:{type:"points",earned:h.all(e.choicesSelected,((r,i)=>(e.noneOfTheAboveIndex===i?h.all(t.choices,((e,t)=>i===t||!e.correct)):!!t.choices[i].correct)===r))?1:0,total:1,message:null}}static getUserInputFromProps(e){if(e.choiceStates){for(var t=null,r=!1,i=e.choiceStates,n=i.map((()=>!1)),o=e.countChoices,s=e.numCorrect,a=0;a<n.length;a++){var l=e.choices[a].originalIndex;n[l]=i[a].selected,e.choices[a].isNoneOfTheAbove&&(t=l,n[a]&&(r=!0))}return{countChoices:o,choicesSelected:n,numCorrect:s,noneOfTheAboveIndex:t,noneOfTheAboveSelected:r}}if(e.values){for(var p=null,c=!1,d=e.values.slice(),u=e.countChoices,m=e.numCorrect,g=0;g<e.values.length;g++){var f=e.choices[g].originalIndex;d[f]=e.values[g],e.choices[g].isNoneOfTheAbove&&(p=f,d[g]&&(c=!0))}return{choicesSelected:d,noneOfTheAboveIndex:p,noneOfTheAboveSelected:c,countChoices:u,numCorrect:m}}return{choicesSelected:h.map(e.choices,(()=>!1))}}}j(Hl,"defaultProps",{choices:[{}],displayCount:null,multipleSelect:!1,countChoices:!1,deselectEnabled:!1,linterContext:Vt});var{shuffle:Wl,random:ql}=De,Ul=[[o._("False"),o._("True")],[o._("No"),o._("Yes")]],Gl=(e,t)=>{var r=((e,t)=>{var r,i,n=e.choices.slice();return n=h.map(n,((e,t)=>h.extend({},e,{originalIndex:t,correct:Boolean(e.correct)}))),function(e){var t=null,r=h.reject(e,(function(e,r){if(e.isNoneOfTheAbove)return t=e,!0}));return t&&r.push(t),r}((e=>{var t=e.map((e=>e.content));return Ul.some((e=>h.isEqual(t,e)))?[e[1],e[0]]:e})((r=n,i=void 0===t?ql:t,e.randomize?Wl(r,null!=i?i:0):r)))})(e,t),i=h.reduce(e.choices,(function(e,t){return t.correct?e+1:e}),0),{hasNoneOfTheAbove:n,multipleSelect:o,countChoices:s,deselectEnabled:a}=e;return{numCorrect:i,hasNoneOfTheAbove:n,multipleSelect:o,countChoices:s,deselectEnabled:a,choices:r,selectedChoices:h.pluck(r,"correct")}},Vl={name:"radio",displayName:"Multiple choice",accessible:!0,widget:Hl,transform:Gl,staticTransform:Gl,version:{major:1,minor:0},propUpgrades:{1:e=>{var t,r;if(e.noneOfTheAbove)throw new Error("radio widget v0 no longer supports auto noneOfTheAbove");return t=e.choices,r=!1,h.extend(h.omit(e,"noneOfTheAbove"),{choices:t,hasNoneOfTheAbove:r})}},isLintable:!0},jl=[Vl,Ps,Ds,Cs];class Yl extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"state",{uniqueId:h.uniqueId("perseus_radio_")}),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"getUserInput",(()=>Yl.getUserInputFromProps(this.props))),j(this,"onChange",((e,t)=>{var r=[...this.props.values];r[e]=t,this.change("values",r),this.props.trackInteraction()})),j(this,"simpleValidate",(e=>Yl.validate(this.getUserInput(),e)))}render(){var e=this,t=this.props.apiOptions.isMobile,r=this.props.items.map(((e,t)=>[e,t]));this.props.randomizeItems&&(r=De.shuffle(r,this.props.problemNum));var i=a.createElement("table",{className:"categorizer-table "+g(Xl.mobileTable)},a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null," "),this.props.categories.map(((e,t)=>a.createElement("th",{className:g(Xl.header),key:t},a.createElement(Bo,{content:e,linterContext:this.props.linterContext})))))),a.createElement("tbody",null,r.map((r=>{var i=r[0],n=r[1],o=e.state.uniqueId+"_"+n;return a.createElement("tr",{key:n},a.createElement("td",null,a.createElement(Bo,{content:i,linterContext:this.props.linterContext})),e.props.categories.map(((r,i)=>{var s=e.props.values[n]===i;return a.createElement("td",{className:"category "+g(Xl.cell),key:i},a.createElement("div",{className:Jt.INTERACTIVE,role:"button","aria-label":r,onClick:this.onChange.bind(this,n,i)},t&&a.createElement("input",{type:"radio",name:o,className:g(ta.responsiveInput,ta.responsiveRadioInput),checked:s,onChange:this.onChange.bind(this,n,i),onClick:e=>e.stopPropagation()}),!t&&a.createElement("span",{className:g(Xl.radioSpan,s&&Xl.checkedRadioSpan,this.props.static&&s&&Xl.staticCheckedRadioSpan)},s?a.createElement(X,bi):a.createElement(X,Ci))))})))})))),n=s({"categorizer-container":!0,"static-mode":this.props.static}),o=this.props.apiOptions.isMobile?[Xl.fullBleedContainer]:[];return a.createElement("div",{className:n+" "+g(...o)},i)}static validate(e,t){var r=!0,i=!0;return h.each(t.values,(function(t,n){null==e.values[n]&&(r=!1),e.values[n]!==t&&(i=!1)})),r?{type:"points",earned:i?1:0,total:1,message:null}:{type:"invalid",message:o._("Make sure you select something for every row.")}}static getUserInputFromProps(e){return Ls.getUserInputFromProps(e)}}j(Yl,"defaultProps",{items:[],categories:[],values:[],linterContext:Vt});var $l,Xl=m.create({mobileTable:{[$s.smOrSmaller]:{minWidth:"auto"}},fullBleedContainer:{[$s.mdOrSmaller]:{marginLeft:-16,marginRight:-16,overflowX:"auto"}},header:{textAlign:"center",verticalAlign:"bottom"},cell:{textAlign:"center",padding:0,color:"#ccc",verticalAlign:"middle"},radioSpan:{fontSize:30,paddingRight:3,":hover":{color:"#999"}},checkedRadioSpan:{color:"#333"},staticCheckedRadioSpan:{color:"#888"}}),Kl={name:"categorizer",displayName:"Categorizer",widget:Yl,transform:e=>h.pick(e,"items","categories","randomizeItems"),staticTransform:e=>h.pick(e,"items","categories","values","randomizeItems"),isLintable:!0},Zl=e=>new URL(e,($l||($l=window.location),$l).origin),{updateQueryString:Jl}=De;function Ql(e){var t,{InitialRequestUrl:r}=ae(),i="/computer-programming/program/"+"".concat(e,"/embedded?embed=yes&author=no");return(t=r.protocol)&&"file:"===t.toLowerCase()?"https://khanacademy.org".concat(i):Zl(i).href}class ep extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"handleMessageEvent",(e=>{var t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(!h.isUndefined(t.testsPassed)){var r=t.testsPassed?"correct":"incorrect";this.change({status:r,message:t.message})}})),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"simpleValidate",(e=>ep.validate({status:this.props.status,message:this.props.message},e)))}static validate(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}componentDidMount(){y(window).on("message",this.handleMessageEvent)}componentWillUnmount(){y(window).off("message",this.handleMessageEvent)}render(){if(!this.props.programID)return a.createElement("div",null);var e,t=!1,r=Ql(this.props.programID),i={height:this.props.height,width:"100%"};if(this.props.showEditor?(r+="&editor=yes",e="perseus-scratchpad-editor"):(r+="&editor=no&width=".concat(688),e="perseus-scratchpad","webpage"!==this.props.programType&&(t=!0)),this.props.showButtons?(r+="&buttons=yes",i.height+=67):r+="&buttons=no",this.props.settings){var n={};h.each(this.props.settings,(function(e){e.name&&e.value&&(n[e.name]=e.value)})),r=Jl(r,"settings",JSON.stringify(n))}var o=["allow-popups","allow-same-origin","allow-scripts","allow-top-navigation"].join(" ");return a.createElement("div",{className:g(tp.widthOverride,t&&tp.container)},a.createElement("iframe",{sandbox:o,src:r,style:i,className:e,allowFullScreen:!0}))}}j(ep,"propTypes",G(G({},fs),{},{programID:d.string,programType:d.oneOf(["pjs","sql","webpage"]),width:d.number,height:d.number,settings:d.array,showEditor:d.bool,showButtons:d.bool,status:d.oneOf(["incomplete","incorrect","correct"]),message:d.string})),j(ep,"defaultProps",{showEditor:!1,showButtons:!1,status:"incomplete",message:null});var tp=m.create({widthOverride:{width:820},container:{margin:"auto"}}),rp={name:"cs-program",displayName:"CS Program",supportedAlignments:["block","full-width"],widget:ep,hidden:!0};class ip extends a.Component{componentDidMount(){this.props.trackInteraction()}render(){return a.createElement(A,{style:op.tooltipBody},a.createElement(Bo,{apiOptions:this.props.apiOptions,content:this.props.content,widgets:this.props.widgets}))}}j(ip,"propTypes",{apiOptions:Zt.propTypes,content:d.string,trackInteraction:d.func.isRequired,widgets:d.objectOf(d.any)});class np extends a.Component{constructor(){super(...arguments),j(this,"getUserInput",(()=>({}))),j(this,"simpleValidate",(e=>np.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e=a.createElement(ip,{apiOptions:this.props.apiOptions,content:this.props.definition,key:this.props.definition,trackInteraction:this.props.trackInteraction,widgets:this.props.widgets});return a.createElement(O,{content:e,placement:"top"},a.createElement("span",{className:"perseus-widget-definition"},a.createElement(A,{style:op.definitionLink},this.props.togglePrompt)))}}j(np,"defaultProps",{togglePrompt:"define me",definition:"definition goes here"});var op={tooltipBody:{color:_.offBlack,display:"block",fontSize:20,fontWeight:500,lineHeight:"30px",margin:F.xSmall_8},definitionLink:{borderBottom:"dashed 1px ".concat(_.blue),color:_.blue,cursor:"pointer",display:"inline-block",textDecoration:"none"}},sp={name:"definition",displayName:"Definition",accessible:!0,defaultAlignment:"inline",widget:np,transform:h.identity};class ap extends a.Component{constructor(){super(...arguments),j(this,"focus",(()=>(v.findDOMNode(this).focus(),!0))),j(this,"_handleChangeEvent",(e=>{this._handleChange(parseInt(e.target.value))})),j(this,"_handleChange",(e=>{this.props.trackInteraction(),this.props.onChange({selected:e})})),j(this,"getUserInput",(()=>({value:this.props.selected}))),j(this,"simpleValidate",(e=>ap.validate(this.getUserInput(),e)))}static validate(e,t){var r=e.value;return 0===r?{type:"invalid",message:null}:{type:"points",earned:t.choices[r-1].correct?1:0,total:1,message:null}}render(){var e=[a.createElement(D,{key:"placeholder",value:"0",disabled:!0,label:this.props.placeholder}),...this.props.choices.map(((e,t)=>a.createElement(D,{key:String(t+1),value:String(t+1),label:e})))];return a.createElement("div",{onClick:e=>{e.stopPropagation()},onTouchStart:e=>{e.stopPropagation()}},a.createElement(L,{onChange:e=>this._handleChange(parseInt(e)),selectedValue:String(this.props.selected),disabled:this.props.apiOptions.readOnly},e))}}j(ap,"defaultProps",{choices:[],selected:0,placeholder:"",apiOptions:Zt.defaults});var lp={name:"dropdown",displayName:"Drop down",defaultAlignment:"inline-block",accessible:!0,widget:ap,transform:e=>({placeholder:e.placeholder,choices:h.map(e.choices,(e=>e.content))})};class pp extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"state",{expanded:!1}),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"_onClick",(()=>{this.setState({expanded:!this.state.expanded}),this.props.trackInteraction()})),j(this,"getUserInput",(()=>({}))),j(this,"simpleValidate",(e=>pp.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e,{Link:t}=this.props.apiOptions.baseElements,{isArticle:r,isMobile:i}=this.props.apiOptions,n=this.state.expanded?this.props.hidePrompt:this.props.showPrompt,o="javascript:void(0)",s=this._onClick;e=i?a.createElement("div",{className:g(up.linkContainer)},a.createElement("a",{className:g(up.mobileExplanationLink),href:o,onClick:s,role:"button","aria-expanded":this.state.expanded},n),this.state.expanded&&a.createElement("svg",{className:g(up.disclosureArrow)},a.createElement("polygon",{style:{fill:dp},points:"0,".concat(cp," ")+"".concat(hp,",").concat(cp," ")+"".concat(hp/2,",0")}))):r?a.createElement("div",{className:g(up.linkContainer,up.articleLink)},a.createElement(t,{className:g(up.explanationLink),style:up.explanationLink,href:o,onClick:s,role:"button","aria-expanded":this.state.expanded},"[".concat(n,"]"))):a.createElement("div",{className:g(up.linkContainer,up.exerciseLink)},a.createElement(t,{className:g(up.explanationLink),href:o,onClick:s,role:"button","aria-expanded":this.state.expanded},"[".concat(n,"]")));var l=i?up.contentExpandedMobile:up.contentExpanded;return a.createElement("div",{className:g(up.container)},e,this.state.expanded&&a.createElement("div",{className:g(up.content,i&&up.contentMobile,this.state.expanded&&l),ref:"content"},a.createElement(Bo,{apiOptions:this.props.apiOptions,content:this.props.explanation,widgets:this.props.widgets,linterContext:this.props.linterContext})))}}j(pp,"defaultProps",{showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{},linterContext:Vt});var hp=30,cp=14,dp="#F0F1F2",up=m.create({container:{display:"inline",position:"relative"},linkContainer:{display:"inline-block"},explanationLink:{fontStyle:"italic",color:"#007d96"},articleLink:{fontSize:20,lineHeight:"30px"},exerciseLink:{fontSize:14,lineHeight:"19.6px"},mobileExplanationLink:{color:"#71B307",borderBottom:"dashed 1px ".concat("#71B307"),textDecoration:"none",[$s.xl]:{fontSize:22,lineHeight:1.4},[$s.lgOrSmaller]:{fontSize:20,lineHeight:1.5},[$s.smOrSmaller]:{fontSize:18,lineHeight:1.2}},content:{position:"relative",transition:"margin-top 0.1s"},contentExpanded:{borderLeft:"5px solid #ccc",marginLeft:-23,paddingLeft:23,paddingBottom:10,marginBottom:cp,marginTop:cp},contentExpandedMobile:{boxSizing:"content-box",paddingTop:32,paddingBottom:32,marginTop:cp},contentMobile:{background:dp,marginLeft:-16,marginRight:-16,paddingLeft:16,paddingRight:16},disclosureArrow:{bottom:-(cp+5),height:cp,left:"50%",marginLeft:-hp/2,position:"absolute",width:hp}}),mp={name:"explanation",displayName:"Explanation",accessible:!0,defaultAlignment:"inline",widget:pp,transform:h.identity,isLintable:!0};function gp(e,t){return gp=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},gp(e,t)}function fp(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,gp(e,t)}function vp(e){return"/"===e.charAt(0)}function yp(e,t){for(var r=t,i=r+1,n=e.length;i<n;r+=1,i+=1)e[r]=e[i];e.pop()}var bp="production"===process.env.NODE_ENV;function xp(e,t){if(!bp){if(e)return;var r="Warning: "+t;"undefined"!=typeof console&&console.warn(r);try{throw Error(r)}catch(e){}}}var wp="production"===process.env.NODE_ENV,Cp="Invariant failed";function kp(e,t){if(!e){if(wp)throw new Error(Cp);var r="function"==typeof t?t():t;throw new Error(r?Cp+": "+r:Cp)}}function Ep(e){return"/"===e.charAt(0)?e:"/"+e}function Sp(e){return"/"===e.charAt(0)?e.substr(1):e}function _p(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}function Mp(e,t){return _p(e,t)?e.substr(t.length):e}function Tp(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function Ip(e){var t=e.pathname,r=e.search,i=e.hash,n=t||"/";return r&&"?"!==r&&(n+="?"===r.charAt(0)?r:"?"+r),i&&"#"!==i&&(n+="#"===i.charAt(0)?i:"#"+i),n}function Pp(e,t,r,i){var n;"string"==typeof e?(n=function(e){var t=e||"/",r="",i="",n=t.indexOf("#");-1!==n&&(i=t.substr(n),t=t.substr(0,n));var o=t.indexOf("?");return-1!==o&&(r=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===r?"":r,hash:"#"===i?"":i}}(e),n.state=t):(void 0===(n=ma({},e)).pathname&&(n.pathname=""),n.search?"?"!==n.search.charAt(0)&&(n.search="?"+n.search):n.search="",n.hash?"#"!==n.hash.charAt(0)&&(n.hash="#"+n.hash):n.hash="",void 0!==t&&void 0===n.state&&(n.state=t));try{n.pathname=decodeURI(n.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+n.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return r&&(n.key=r),i?n.pathname?"/"!==n.pathname.charAt(0)&&(n.pathname=function(e,t){void 0===t&&(t="");var r,i=e&&e.split("/")||[],n=t&&t.split("/")||[],o=e&&vp(e),s=t&&vp(t),a=o||s;if(e&&vp(e)?n=i:i.length&&(n.pop(),n=n.concat(i)),!n.length)return"/";if(n.length){var l=n[n.length-1];r="."===l||".."===l||""===l}else r=!1;for(var p=0,h=n.length;h>=0;h--){var c=n[h];"."===c?yp(n,h):".."===c?(yp(n,h),p++):p&&(yp(n,h),p--)}if(!a)for(;p--;p)n.unshift("..");!a||""===n[0]||n[0]&&vp(n[0])||n.unshift("");var d=n.join("/");return r&&"/"!==d.substr(-1)&&(d+="/"),d}(n.pathname,i.pathname)):n.pathname=i.pathname:n.pathname||(n.pathname="/"),n}function Np(){var e=null;var t=[];return{setPrompt:function(t){return"production"!==process.env.NODE_ENV&&xp(null==e,"A history supports only one prompt at a time"),e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,r,i,n){if(null!=e){var o="function"==typeof e?e(t,r):e;"string"==typeof o?"function"==typeof i?i(o,n):("production"!==process.env.NODE_ENV&&xp(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),n(!0)):n(!1!==o)}else n(!0)},appendListener:function(e){var r=!0;function i(){r&&e.apply(void 0,arguments)}return t.push(i),function(){r=!1,t=t.filter((function(e){return e!==i}))}},notifyListeners:function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];t.forEach((function(e){return e.apply(void 0,r)}))}}}var Ap=!("undefined"==typeof window||!window.document||!window.document.createElement);function Rp(e,t){t(window.confirm(e))}function Fp(){try{return window.history.state||{}}catch(e){return{}}}function Op(e){void 0===e&&(e={}),Ap||("production"!==process.env.NODE_ENV?kp(!1,"Browser history needs a DOM"):kp(!1));var t,r=window.history,i=(-1===(t=window.navigator.userAgent).indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&window.history&&"pushState"in window.history,n=!(-1===window.navigator.userAgent.indexOf("Trident")),o=e,s=o.forceRefresh,a=void 0!==s&&s,l=o.getUserConfirmation,p=void 0===l?Rp:l,h=o.keyLength,c=void 0===h?6:h,d=e.basename?Tp(Ep(e.basename)):"";function u(e){var t=e||{},r=t.key,i=t.state,n=window.location,o=n.pathname+n.search+n.hash;return"production"!==process.env.NODE_ENV&&xp(!d||_p(o,d),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+o+'" to begin with "'+d+'".'),d&&(o=Mp(o,d)),Pp(o,i,r)}function m(){return Math.random().toString(36).substr(2,c)}var g=Np();function f(e){ma(T,e),T.length=r.length,g.notifyListeners(T.location,T.action)}function v(e){(function(e){return void 0===e.state&&-1===navigator.userAgent.indexOf("CriOS")})(e)||x(u(e.state))}function y(){x(u(Fp()))}var b=!1;function x(e){if(b)b=!1,f();else{g.confirmTransitionTo(e,"POP",p,(function(t){t?f({action:"POP",location:e}):function(e){var t=T.location,r=C.indexOf(t.key);-1===r&&(r=0);var i=C.indexOf(e.key);-1===i&&(i=0);var n=r-i;n&&(b=!0,E(n))}(e)}))}}var w=u(Fp()),C=[w.key];function k(e){return d+Ip(e)}function E(e){r.go(e)}var S=0;function _(e){1===(S+=e)&&1===e?(window.addEventListener("popstate",v),n&&window.addEventListener("hashchange",y)):0===S&&(window.removeEventListener("popstate",v),n&&window.removeEventListener("hashchange",y))}var M=!1;var T={length:r.length,action:"POP",location:w,createHref:k,push:function(e,t){"production"!==process.env.NODE_ENV&&xp(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var n="PUSH",o=Pp(e,t,m(),T.location);g.confirmTransitionTo(o,n,p,(function(e){if(e){var t=k(o),s=o.key,l=o.state;if(i)if(r.pushState({key:s,state:l},null,t),a)window.location.href=t;else{var p=C.indexOf(T.location.key),h=C.slice(0,p+1);h.push(o.key),C=h,f({action:n,location:o})}else"production"!==process.env.NODE_ENV&&xp(void 0===l,"Browser history cannot push state in browsers that do not support HTML5 history"),window.location.href=t}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&xp(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var n="REPLACE",o=Pp(e,t,m(),T.location);g.confirmTransitionTo(o,n,p,(function(e){if(e){var t=k(o),s=o.key,l=o.state;if(i)if(r.replaceState({key:s,state:l},null,t),a)window.location.replace(t);else{var p=C.indexOf(T.location.key);-1!==p&&(C[p]=o.key),f({action:n,location:o})}else"production"!==process.env.NODE_ENV&&xp(void 0===l,"Browser history cannot replace state in browsers that do not support HTML5 history"),window.location.replace(t)}}))},go:E,goBack:function(){E(-1)},goForward:function(){E(1)},block:function(e){void 0===e&&(e=!1);var t=g.setPrompt(e);return M||(_(1),M=!0),function(){return M&&(M=!1,_(-1)),t()}},listen:function(e){var t=g.appendListener(e);return _(1),function(){_(-1),t()}}};return T}var Dp={hashbang:{encodePath:function(e){return"!"===e.charAt(0)?e:"!/"+Sp(e)},decodePath:function(e){return"!"===e.charAt(0)?e.substr(1):e}},noslash:{encodePath:Sp,decodePath:Ep},slash:{encodePath:Ep,decodePath:Ep}};function Lp(e){var t=e.indexOf("#");return-1===t?e:e.slice(0,t)}function Bp(){var e=window.location.href,t=e.indexOf("#");return-1===t?"":e.substring(t+1)}function zp(e){window.location.replace(Lp(window.location.href)+"#"+e)}function Hp(e){void 0===e&&(e={}),Ap||("production"!==process.env.NODE_ENV?kp(!1,"Hash history needs a DOM"):kp(!1));var t=window.history,r=-1===window.navigator.userAgent.indexOf("Firefox"),i=e,n=i.getUserConfirmation,o=void 0===n?Rp:n,s=i.hashType,a=void 0===s?"slash":s,l=e.basename?Tp(Ep(e.basename)):"",p=Dp[a],h=p.encodePath,c=p.decodePath;function d(){var e=c(Bp());return"production"!==process.env.NODE_ENV&&xp(!l||_p(e,l),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+e+'" to begin with "'+l+'".'),l&&(e=Mp(e,l)),Pp(e)}var u=Np();function m(e){ma(_,e),_.length=t.length,u.notifyListeners(_.location,_.action)}var g=!1,f=null;function v(){var e,t,r=Bp(),i=h(r);if(r!==i)zp(i);else{var n=d(),s=_.location;if(!g&&(t=n,(e=s).pathname===t.pathname&&e.search===t.search&&e.hash===t.hash))return;if(f===Ip(n))return;f=null,function(e){if(g)g=!1,m();else{var t="POP";u.confirmTransitionTo(e,t,o,(function(r){r?m({action:t,location:e}):function(e){var t=_.location,r=w.lastIndexOf(Ip(t));-1===r&&(r=0);var i=w.lastIndexOf(Ip(e));-1===i&&(i=0);var n=r-i;n&&(g=!0,C(n))}(e)}))}}(n)}}var y=Bp(),b=h(y);y!==b&&zp(b);var x=d(),w=[Ip(x)];function C(e){"production"!==process.env.NODE_ENV&&xp(r,"Hash history go(n) causes a full page reload in this browser"),t.go(e)}var k=0;function E(e){1===(k+=e)&&1===e?window.addEventListener("hashchange",v):0===k&&window.removeEventListener("hashchange",v)}var S=!1;var _={length:t.length,action:"POP",location:x,createHref:function(e){var t=document.querySelector("base"),r="";return t&&t.getAttribute("href")&&(r=Lp(window.location.href)),r+"#"+h(l+Ip(e))},push:function(e,t){"production"!==process.env.NODE_ENV&&xp(void 0===t,"Hash history cannot push state; it is ignored");var r="PUSH",i=Pp(e,void 0,void 0,_.location);u.confirmTransitionTo(i,r,o,(function(e){if(e){var t=Ip(i),n=h(l+t);if(Bp()!==n){f=t,function(e){window.location.hash=e}(n);var o=w.lastIndexOf(Ip(_.location)),s=w.slice(0,o+1);s.push(t),w=s,m({action:r,location:i})}else"production"!==process.env.NODE_ENV&&xp(!1,"Hash history cannot PUSH the same path; a new entry will not be added to the history stack"),m()}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&xp(void 0===t,"Hash history cannot replace state; it is ignored");var r="REPLACE",i=Pp(e,void 0,void 0,_.location);u.confirmTransitionTo(i,r,o,(function(e){if(e){var t=Ip(i),n=h(l+t);Bp()!==n&&(f=t,zp(n));var o=w.indexOf(Ip(_.location));-1!==o&&(w[o]=t),m({action:r,location:i})}}))},go:C,goBack:function(){C(-1)},goForward:function(){C(1)},block:function(e){void 0===e&&(e=!1);var t=u.setPrompt(e);return S||(E(1),S=!0),function(){return S&&(S=!1,E(-1)),t()}},listen:function(e){var t=u.appendListener(e);return E(1),function(){E(-1),t()}}};return _}function Wp(e,t,r){return Math.min(Math.max(e,t),r)}function qp(e){void 0===e&&(e={});var t=e,r=t.getUserConfirmation,i=t.initialEntries,n=void 0===i?["/"]:i,o=t.initialIndex,s=void 0===o?0:o,a=t.keyLength,l=void 0===a?6:a,p=Np();function h(e){ma(f,e),f.length=f.entries.length,p.notifyListeners(f.location,f.action)}function c(){return Math.random().toString(36).substr(2,l)}var d=Wp(s,0,n.length-1),u=n.map((function(e){return Pp(e,void 0,"string"==typeof e?c():e.key||c())})),m=Ip;function g(e){var t=Wp(f.index+e,0,f.entries.length-1),i=f.entries[t];p.confirmTransitionTo(i,"POP",r,(function(e){e?h({action:"POP",location:i,index:t}):h()}))}var f={length:u.length,action:"POP",location:u[d],index:d,entries:u,createHref:m,push:function(e,t){"production"!==process.env.NODE_ENV&&xp(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var i="PUSH",n=Pp(e,t,c(),f.location);p.confirmTransitionTo(n,i,r,(function(e){if(e){var t=f.index+1,r=f.entries.slice(0);r.length>t?r.splice(t,r.length-t,n):r.push(n),h({action:i,location:n,index:t,entries:r})}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&xp(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var i="REPLACE",n=Pp(e,t,c(),f.location);p.confirmTransitionTo(n,i,r,(function(e){e&&(f.entries[f.index]=n,h({action:i,location:n}))}))},go:g,goBack:function(){g(-1)},goForward:function(){g(1)},canGo:function(e){var t=f.index+e;return t>=0&&t<f.entries.length},block:function(e){return void 0===e&&(e=!1),p.setPrompt(e)},listen:function(e){return p.appendListener(e)}};return f}var Up="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function Gp(e){var t=[];return{on:function(e){t.push(e)},off:function(e){t=t.filter((function(t){return t!==e}))},get:function(){return e},set:function(r,i){e=r,t.forEach((function(t){return t(e,i)}))}}}var Vp=l.createContext||function(e,t){var r,i,n="__create-react-context-"+function(){var e="__global_unique_id__";return Up[e]=(Up[e]||0)+1}()+"__",o=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).emitter=Gp(t.props.value),t}fp(r,e);var i=r.prototype;return i.getChildContext=function(){var e;return(e={})[n]=this.emitter,e},i.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var r,i=this.props.value,n=e.value;((o=i)===(s=n)?0!==o||1/o==1/s:o!=o&&s!=s)?r=0:(r="function"==typeof t?t(i,n):1073741823,"production"!==process.env.NODE_ENV&&xp((1073741823&r)===r,"calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: "+r),0!==(r|=0)&&this.emitter.set(e.value,r))}var o,s},i.render=function(){return this.props.children},r}(p);o.childContextTypes=((r={})[n]=d.object.isRequired,r);var s=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).state={value:e.getValue()},e.onUpdate=function(t,r){0!=((0|e.observedBits)&r)&&e.setState({value:e.getValue()})},e}fp(r,t);var i=r.prototype;return i.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?1073741823:t},i.componentDidMount=function(){this.context[n]&&this.context[n].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?1073741823:e},i.componentWillUnmount=function(){this.context[n]&&this.context[n].off(this.onUpdate)},i.getValue=function(){return this.context[n]?this.context[n].get():e},i.render=function(){return(e=this.props.children,Array.isArray(e)?e[0]:e)(this.state.value);var e},r}(p);return s.contextTypes=((i={})[n]=d.object,i),{Provider:o,Consumer:s}},jp={exports:{}},Yp=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)};jp.exports=ih,jp.exports.parse=Xp,jp.exports.compile=function(e,t){return Zp(Xp(e,t),t)},jp.exports.tokensToFunction=Zp,jp.exports.tokensToRegExp=rh;var $p=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function Xp(e,t){for(var r,i=[],n=0,o=0,s="",a=t&&t.delimiter||"/";null!=(r=$p.exec(e));){var l=r[0],p=r[1],h=r.index;if(s+=e.slice(o,h),o=h+l.length,p)s+=p[1];else{var c=e[o],d=r[2],u=r[3],m=r[4],g=r[5],f=r[6],v=r[7];s&&(i.push(s),s="");var y=null!=d&&null!=c&&c!==d,b="+"===f||"*"===f,x="?"===f||"*"===f,w=r[2]||a,C=m||g;i.push({name:u||n++,prefix:d||"",delimiter:w,optional:x,repeat:b,partial:y,asterisk:!!v,pattern:C?Qp(C):v?".*":"[^"+Jp(w)+"]+?"})}}return o<e.length&&(s+=e.substr(o)),s&&i.push(s),i}function Kp(e){return encodeURI(e).replace(/[\/?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}function Zp(e,t){for(var r=new Array(e.length),i=0;i<e.length;i++)"object"==typeof e[i]&&(r[i]=new RegExp("^(?:"+e[i].pattern+")$",th(t)));return function(t,i){for(var n="",o=t||{},s=(i||{}).pretty?Kp:encodeURIComponent,a=0;a<e.length;a++){var l=e[a];if("string"!=typeof l){var p,h=o[l.name];if(null==h){if(l.optional){l.partial&&(n+=l.prefix);continue}throw new TypeError('Expected "'+l.name+'" to be defined')}if(Yp(h)){if(!l.repeat)throw new TypeError('Expected "'+l.name+'" to not repeat, but received `'+JSON.stringify(h)+"`");if(0===h.length){if(l.optional)continue;throw new TypeError('Expected "'+l.name+'" to not be empty')}for(var c=0;c<h.length;c++){if(p=s(h[c]),!r[a].test(p))throw new TypeError('Expected all "'+l.name+'" to match "'+l.pattern+'", but received `'+JSON.stringify(p)+"`");n+=(0===c?l.prefix:l.delimiter)+p}}else{if(p=l.asterisk?encodeURI(h).replace(/[?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})):s(h),!r[a].test(p))throw new TypeError('Expected "'+l.name+'" to match "'+l.pattern+'", but received "'+p+'"');n+=l.prefix+p}}else n+=l}return n}}function Jp(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function Qp(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function eh(e,t){return e.keys=t,e}function th(e){return e&&e.sensitive?"":"i"}function rh(e,t,r){Yp(t)||(r=t||r,t=[]);for(var i=(r=r||{}).strict,n=!1!==r.end,o="",s=0;s<e.length;s++){var a=e[s];if("string"==typeof a)o+=Jp(a);else{var l=Jp(a.prefix),p="(?:"+a.pattern+")";t.push(a),a.repeat&&(p+="(?:"+l+p+")*"),o+=p=a.optional?a.partial?l+"("+p+")?":"(?:"+l+"("+p+"))?":l+"("+p+")"}}var h=Jp(r.delimiter||"/"),c=o.slice(-h.length)===h;return i||(o=(c?o.slice(0,-h.length):o)+"(?:"+h+"(?=$))?"),o+=n?"$":i&&c?"":"(?="+h+"|$)",eh(new RegExp("^"+o,th(r)),t)}function ih(e,t,r){return Yp(t)||(r=t||r,t=[]),r=r||{},e instanceof RegExp?function(e,t){var r=e.source.match(/\((?!\?)/g);if(r)for(var i=0;i<r.length;i++)t.push({name:i,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return eh(e,t)}(e,t):Yp(e)?function(e,t,r){for(var i=[],n=0;n<e.length;n++)i.push(ih(e[n],t,r).source);return eh(new RegExp("(?:"+i.join("|")+")",th(r)),t)}(e,t,r):function(e,t,r){return rh(Xp(e,r),t,r)}(e,t,r)}var nh,oh={exports:{}},sh={};var ah,lh,ph={};
8
- /** @license React v16.13.1
9
- * react-is.development.js
10
- *
11
- * Copyright (c) Facebook, Inc. and its affiliates.
12
- *
13
- * This source code is licensed under the MIT license found in the
14
- * LICENSE file in the root directory of this source tree.
15
- */lh=oh,"production"===process.env.NODE_ENV?lh.exports=function(){if(nh)return sh;nh=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,n=e?Symbol.for("react.strict_mode"):60108,o=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,p=e?Symbol.for("react.concurrent_mode"):60111,h=e?Symbol.for("react.forward_ref"):60112,c=e?Symbol.for("react.suspense"):60113,d=e?Symbol.for("react.suspense_list"):60120,u=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,g=e?Symbol.for("react.block"):60121,f=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var d=e.$$typeof;switch(d){case t:switch(e=e.type){case l:case p:case i:case o:case n:case c:return e;default:switch(e=e&&e.$$typeof){case a:case h:case m:case u:case s:return e;default:return d}}case r:return d}}}function x(e){return b(e)===p}return sh.AsyncMode=l,sh.ConcurrentMode=p,sh.ContextConsumer=a,sh.ContextProvider=s,sh.Element=t,sh.ForwardRef=h,sh.Fragment=i,sh.Lazy=m,sh.Memo=u,sh.Portal=r,sh.Profiler=o,sh.StrictMode=n,sh.Suspense=c,sh.isAsyncMode=function(e){return x(e)||b(e)===l},sh.isConcurrentMode=x,sh.isContextConsumer=function(e){return b(e)===a},sh.isContextProvider=function(e){return b(e)===s},sh.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},sh.isForwardRef=function(e){return b(e)===h},sh.isFragment=function(e){return b(e)===i},sh.isLazy=function(e){return b(e)===m},sh.isMemo=function(e){return b(e)===u},sh.isPortal=function(e){return b(e)===r},sh.isProfiler=function(e){return b(e)===o},sh.isStrictMode=function(e){return b(e)===n},sh.isSuspense=function(e){return b(e)===c},sh.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===p||e===o||e===n||e===c||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===u||e.$$typeof===s||e.$$typeof===a||e.$$typeof===h||e.$$typeof===f||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},sh.typeOf=b,sh}():lh.exports=(ah||(ah=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,n=e?Symbol.for("react.strict_mode"):60108,o=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,p=e?Symbol.for("react.concurrent_mode"):60111,h=e?Symbol.for("react.forward_ref"):60112,c=e?Symbol.for("react.suspense"):60113,d=e?Symbol.for("react.suspense_list"):60120,u=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,g=e?Symbol.for("react.block"):60121,f=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var d=e.$$typeof;switch(d){case t:var g=e.type;switch(g){case l:case p:case i:case o:case n:case c:return g;default:var f=g&&g.$$typeof;switch(f){case a:case h:case m:case u:case s:return f;default:return d}}case r:return d}}}var x=l,w=p,C=a,k=s,E=t,S=h,_=i,M=m,T=u,I=r,P=o,N=n,A=c,R=!1;function F(e){return b(e)===p}ph.AsyncMode=x,ph.ConcurrentMode=w,ph.ContextConsumer=C,ph.ContextProvider=k,ph.Element=E,ph.ForwardRef=S,ph.Fragment=_,ph.Lazy=M,ph.Memo=T,ph.Portal=I,ph.Profiler=P,ph.StrictMode=N,ph.Suspense=A,ph.isAsyncMode=function(e){return R||(R=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),F(e)||b(e)===l},ph.isConcurrentMode=F,ph.isContextConsumer=function(e){return b(e)===a},ph.isContextProvider=function(e){return b(e)===s},ph.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},ph.isForwardRef=function(e){return b(e)===h},ph.isFragment=function(e){return b(e)===i},ph.isLazy=function(e){return b(e)===m},ph.isMemo=function(e){return b(e)===u},ph.isPortal=function(e){return b(e)===r},ph.isProfiler=function(e){return b(e)===o},ph.isStrictMode=function(e){return b(e)===n},ph.isSuspense=function(e){return b(e)===c},ph.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===p||e===o||e===n||e===c||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===u||e.$$typeof===s||e.$$typeof===a||e.$$typeof===h||e.$$typeof===f||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},ph.typeOf=b}()),ph);var hh=oh.exports,ch={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},dh={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},uh={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},mh={};function gh(e){return hh.isMemo(e)?uh:mh[e.$$typeof]||ch}mh[hh.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},mh[hh.Memo]=uh;var fh=Object.defineProperty,vh=Object.getOwnPropertyNames,yh=Object.getOwnPropertySymbols,bh=Object.getOwnPropertyDescriptor,xh=Object.getPrototypeOf,wh=Object.prototype;var Ch=function e(t,r,i){if("string"!=typeof r){if(wh){var n=xh(r);n&&n!==wh&&e(t,n,i)}var o=vh(r);yh&&(o=o.concat(yh(r)));for(var s=gh(t),a=gh(r),l=0;l<o.length;++l){var p=o[l];if(!(dh[p]||i&&i[p]||a&&a[p]||s&&s[p])){var h=bh(r,p);try{fh(t,p,h)}catch(e){}}}}return t},kh=function(e){var t=Vp();return t.displayName=e,t},Eh=kh("Router-History"),Sh=kh("Router"),_h=function(e){function t(t){var r;return(r=e.call(this,t)||this).state={location:t.history.location},r._isMounted=!1,r._pendingLocation=null,t.staticContext||(r.unlisten=t.history.listen((function(e){r._isMounted?r.setState({location:e}):r._pendingLocation=e}))),r}fp(t,e),t.computeRootMatch=function(e){return{path:"/",url:"/",params:{},isExact:"/"===e}};var r=t.prototype;return r.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},r.componentWillUnmount=function(){this.unlisten&&(this.unlisten(),this._isMounted=!1,this._pendingLocation=null)},r.render=function(){return l.createElement(Sh.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},l.createElement(Eh.Provider,{children:this.props.children||null,value:this.props.history}))},t}(l.Component);"production"!==process.env.NODE_ENV&&(_h.propTypes={children:d.node,history:d.object.isRequired,staticContext:d.object},_h.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&xp(e.history===this.props.history,"You cannot change <Router history>")});var Mh=function(e){function t(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return(t=e.call.apply(e,[this].concat(i))||this).history=qp(t.props),t}return fp(t,e),t.prototype.render=function(){return l.createElement(_h,{history:this.history,children:this.props.children})},t}(l.Component);if("production"!==process.env.NODE_ENV&&(Mh.propTypes={initialEntries:d.array,initialIndex:d.number,getUserConfirmation:d.func,keyLength:d.number,children:d.node},Mh.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&xp(!this.props.history,"<MemoryRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { MemoryRouter as Router }`.")}),l.Component,"production"!==process.env.NODE_ENV){var Th=d.oneOfType([d.func,d.string]);d.bool,Th.isRequired}"production"!==process.env.NODE_ENV&&(d.bool,d.string,d.oneOfType([d.string,d.object]).isRequired);var Ih={},Ph=0;function Nh(e,t){void 0===t&&(t={}),("string"==typeof t||Array.isArray(t))&&(t={path:t});var r=t,i=r.path,n=r.exact,o=void 0!==n&&n,s=r.strict,a=void 0!==s&&s,l=r.sensitive,p=void 0!==l&&l;return[].concat(i).reduce((function(t,r){if(!r&&""!==r)return null;if(t)return t;var i=function(e,t){var r=""+t.end+t.strict+t.sensitive,i=Ih[r]||(Ih[r]={});if(i[e])return i[e];var n=[],o={regexp:jp.exports(e,n,t),keys:n};return Ph<1e4&&(i[e]=o,Ph++),o}(r,{end:o,strict:a,sensitive:p}),n=i.regexp,s=i.keys,l=n.exec(e);if(!l)return null;var h=l[0],c=l.slice(1),d=e===h;return o&&!d?null:{path:r,url:"/"===r&&""===h?"/":h,isExact:d,params:s.reduce((function(e,t,r){return e[t.name]=c[r],e}),{})}}),null)}function Ah(e){return 0===l.Children.count(e)}function Rh(e,t,r){var i=e(t);return"production"!==process.env.NODE_ENV&&xp(void 0!==i,"You returned `undefined` from the `children` function of <Route"+(r?' path="'+r+'"':"")+">, but you should have returned a React element or `null`"),i||null}var Fh=function(e){function t(){return e.apply(this,arguments)||this}return fp(t,e),t.prototype.render=function(){var e=this;return l.createElement(Sh.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?kp(!1,"You should not use <Route> outside a <Router>"):kp(!1));var r=e.props.location||t.location,i=ma({},t,{location:r,match:e.props.computedMatch?e.props.computedMatch:e.props.path?Nh(r.pathname,e.props):t.match}),n=e.props,o=n.children,s=n.component,a=n.render;return Array.isArray(o)&&Ah(o)&&(o=null),l.createElement(Sh.Provider,{value:i},i.match?o?"function"==typeof o?"production"!==process.env.NODE_ENV?Rh(o,i,e.props.path):o(i):o:s?l.createElement(s,i):a?a(i):null:"function"==typeof o?"production"!==process.env.NODE_ENV?Rh(o,i,e.props.path):o(i):null)}))},t}(l.Component);function Oh(e){return"/"===e.charAt(0)?e:"/"+e}function Dh(e,t){if(!e)return t;var r=Oh(e);return 0!==t.pathname.indexOf(r)?t:ma({},t,{pathname:t.pathname.substr(r.length)})}function Lh(e){return"string"==typeof e?e:Ip(e)}function Bh(e){return function(){"production"!==process.env.NODE_ENV?kp(!1,"You cannot %s with <StaticRouter>"):kp(!1)}}function zh(){}"production"!==process.env.NODE_ENV&&(Fh.propTypes={children:d.oneOfType([d.func,d.node]),component:function(e,t){if(e[t]&&!oh.exports.isValidElementType(e[t]))return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component")},exact:d.bool,location:d.object,path:d.oneOfType([d.string,d.arrayOf(d.string)]),render:d.func,sensitive:d.bool,strict:d.bool},Fh.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&xp(!(this.props.children&&!Ah(this.props.children)&&this.props.component),"You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored"),"production"!==process.env.NODE_ENV&&xp(!(this.props.children&&!Ah(this.props.children)&&this.props.render),"You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored"),"production"!==process.env.NODE_ENV&&xp(!(this.props.component&&this.props.render),"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored")},Fh.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&xp(!(this.props.location&&!e.location),'<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.'),"production"!==process.env.NODE_ENV&&xp(!(!this.props.location&&e.location),'<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.')});var Hh=function(e){function t(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return(t=e.call.apply(e,[this].concat(i))||this).handlePush=function(e){return t.navigateTo(e,"PUSH")},t.handleReplace=function(e){return t.navigateTo(e,"REPLACE")},t.handleListen=function(){return zh},t.handleBlock=function(){return zh},t}fp(t,e);var r=t.prototype;return r.navigateTo=function(e,t){var r=this.props,i=r.basename,n=void 0===i?"":i,o=r.context,s=void 0===o?{}:o;s.action=t,s.location=function(e,t){return e?ma({},t,{pathname:Oh(e)+t.pathname}):t}(n,Pp(e)),s.url=Lh(s.location)},r.render=function(){var e=this.props,t=e.basename,r=void 0===t?"":t,i=e.context,n=void 0===i?{}:i,o=e.location,s=void 0===o?"/":o,a=ga(e,["basename","context","location"]),p={createHref:function(e){return Oh(r+Lh(e))},action:"POP",location:Dh(r,Pp(s)),push:this.handlePush,replace:this.handleReplace,go:Bh(),goBack:Bh(),goForward:Bh(),listen:this.handleListen,block:this.handleBlock};return l.createElement(_h,ma({},a,{history:p,staticContext:n}))},t}(l.Component);"production"!==process.env.NODE_ENV&&(Hh.propTypes={basename:d.string,context:d.object,location:d.oneOfType([d.string,d.object])},Hh.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&xp(!this.props.history,"<StaticRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { StaticRouter as Router }`.")});var Wh=function(e){function t(){return e.apply(this,arguments)||this}return fp(t,e),t.prototype.render=function(){var e=this;return l.createElement(Sh.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?kp(!1,"You should not use <Switch> outside a <Router>"):kp(!1));var r,i,n=e.props.location||t.location;return l.Children.forEach(e.props.children,(function(e){if(null==i&&l.isValidElement(e)){r=e;var o=e.props.path||e.props.from;i=o?Nh(n.pathname,ma({},e.props,{path:o})):t.match}})),i?l.cloneElement(r,{location:n,computedMatch:i}):null}))},t}(l.Component);if("production"!==process.env.NODE_ENV&&(Wh.propTypes={children:d.node,location:d.object},Wh.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&xp(!(this.props.location&&!e.location),'<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.'),"production"!==process.env.NODE_ENV&&xp(!(!this.props.location&&e.location),'<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.')}),l.useContext,"production"!==process.env.NODE_ENV&&"undefined"!=typeof window){var qh=window,Uh="__react_router_build__",Gh={cjs:"CommonJS",esm:"ES modules",umd:"UMD"};if(qh[Uh]&&"esm"!==qh[Uh]){var Vh=Gh[qh[Uh]];throw new Error("You are loading the "+Gh.esm+" build of React Router on a page that is already running the "+Vh+" build, so things won't work right.")}qh[Uh]="esm"}var jh=function(e){function t(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return(t=e.call.apply(e,[this].concat(i))||this).history=Op(t.props),t}return fp(t,e),t.prototype.render=function(){return l.createElement(_h,{history:this.history,children:this.props.children})},t}(l.Component);"production"!==process.env.NODE_ENV&&(jh.propTypes={basename:d.string,children:d.node,forceRefresh:d.bool,getUserConfirmation:d.func,keyLength:d.number},jh.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&xp(!this.props.history,"<BrowserRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { BrowserRouter as Router }`.")});var Yh=function(e){function t(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return(t=e.call.apply(e,[this].concat(i))||this).history=Hp(t.props),t}return fp(t,e),t.prototype.render=function(){return l.createElement(_h,{history:this.history,children:this.props.children})},t}(l.Component);"production"!==process.env.NODE_ENV&&(Yh.propTypes={basename:d.string,children:d.node,getUserConfirmation:d.func,hashType:d.oneOf(["hashbang","noslash","slash"])},Yh.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&xp(!this.props.history,"<HashRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { HashRouter as Router }`.")});var $h=function(e,t){return"function"==typeof e?e(t):e},Xh=function(e,t){return"string"==typeof e?Pp(e,null,null,t):e},Kh=function(e){return e},Zh=l.forwardRef;void 0===Zh&&(Zh=Kh);var Jh=Zh((function(e,t){var r=e.innerRef,i=e.navigate,n=e.onClick,o=ga(e,["innerRef","navigate","onClick"]),s=o.target,a=ma({},o,{onClick:function(e){try{n&&n(e)}catch(t){throw e.preventDefault(),t}e.defaultPrevented||0!==e.button||s&&"_self"!==s||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||(e.preventDefault(),i())}});return a.ref=Kh!==Zh&&t||r,l.createElement("a",a)}));"production"!==process.env.NODE_ENV&&(Jh.displayName="LinkAnchor");var Qh=Zh((function(e,t){var r=e.component,i=void 0===r?Jh:r,n=e.replace,o=e.to,s=e.innerRef,a=ga(e,["component","replace","to","innerRef"]);return l.createElement(Sh.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?kp(!1,"You should not use <Link> outside a <Router>"):kp(!1));var r=e.history,p=Xh($h(o,e.location),e.location),h=p?r.createHref(p):"",c=ma({},a,{href:h,navigate:function(){var t=$h(o,e.location),i=Ip(e.location)===Ip(Xh(t));(n||i?r.replace:r.push)(t)}});return Kh!==Zh?c.ref=t||s:c.innerRef=s,l.createElement(i,c)}))}));if("production"!==process.env.NODE_ENV){var ec=d.oneOfType([d.string,d.object,d.func]),tc=d.oneOfType([d.string,d.func,d.shape({current:d.any})]);Qh.displayName="Link",Qh.propTypes={innerRef:tc,onClick:d.func,replace:d.bool,target:d.string,to:ec.isRequired}}var rc=function(e){return e},ic=l.forwardRef;void 0===ic&&(ic=rc);var nc=ic((function(e,t){var r=e["aria-current"],i=void 0===r?"page":r,n=e.activeClassName,o=void 0===n?"active":n,s=e.activeStyle,a=e.className,p=e.exact,h=e.isActive,c=e.location,d=e.sensitive,u=e.strict,m=e.style,g=e.to,f=e.innerRef,v=ga(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return l.createElement(Sh.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?kp(!1,"You should not use <NavLink> outside a <Router>"):kp(!1));var r=c||e.location,n=Xh($h(g,r),r),y=n.pathname,b=y&&y.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),x=b?Nh(r.pathname,{path:b,exact:p,sensitive:d,strict:u}):null,w=!!(h?h(x,r):x),C="function"==typeof a?a(w):a,k="function"==typeof m?m(w):m;w&&(C=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((function(e){return e})).join(" ")}(C,o),k=ma({},k,s));var E=ma({"aria-current":w&&i||null,className:C,style:k,to:n},v);return rc!==ic?E.ref=t||f:E.innerRef=f,l.createElement(Qh,E)}))}));if("production"!==process.env.NODE_ENV){nc.displayName="NavLink";var oc=d.oneOf(["page","step","location","date","time","true","false"]);nc.propTypes=ma({},Qh.propTypes,{"aria-current":oc,activeClassName:d.string,activeStyle:d.object,className:d.oneOfType([d.string,d.func]),exact:d.bool,isActive:d.func,location:d.object,sensitive:d.bool,strict:d.bool,style:d.oneOfType([d.object,d.func])})}const sc=e=>{switch(e){case"link":return{triggerOnEnter:!0,triggerOnSpace:!1};case"checkbox":case"radio":case"listbox":case"option":return{triggerOnEnter:!1,triggerOnSpace:!0};default:return{triggerOnEnter:!0,triggerOnSpace:!0}}},ac={onClick:()=>{},onMouseEnter:()=>{},onMouseLeave:()=>{},onMouseDown:()=>{},onMouseUp:()=>{},onDragStart:()=>{},onTouchStart:()=>{},onTouchEnd:()=>{},onTouchCancel:()=>{},onKeyDown:()=>{},onKeyUp:()=>{},tabIndex:0},lc=13,pc=32,hc={hovered:!1,focused:!1,pressed:!1,waiting:!1};class cc extends a.Component{static getDerivedStateFromProps(e,t){return e.disabled?ma({},hc,{focused:t.focused}):null}constructor(e){super(e),this.handleClick=e=>{const{onClick:t,beforeNav:r,safeWithNav:i}=this.props;this.enterClick||((t||r||i)&&(this.waitingForClick=!1),this.runCallbackAndMaybeNavigate(e))},this.handleMouseEnter=e=>{1===e.buttons?(this.dragging=!0,this.setState({pressed:!0})):this.waitingForClick||this.setState({hovered:!0})},this.handleMouseLeave=()=>{this.waitingForClick||(this.dragging=!1,this.setState({hovered:!1,pressed:!1,focused:!1}))},this.handleMouseDown=()=>{this.setState({pressed:!0})},this.handleMouseUp=e=>{this.dragging&&(this.dragging=!1,this.handleClick(e)),this.setState({pressed:!1,focused:!1})},this.handleDragStart=e=>{this.dragging=!0,e.preventDefault()},this.handleTouchStart=()=>{this.setState({pressed:!0})},this.handleTouchEnd=()=>{this.setState({pressed:!1}),this.waitingForClick=!0},this.handleTouchCancel=()=>{this.setState({pressed:!1}),this.waitingForClick=!0},this.handleKeyDown=e=>{const{onKeyDown:t,role:r}=this.props;t&&t(e);const i=e.which||e.keyCode,{triggerOnEnter:n,triggerOnSpace:o}=sc(r);n&&i===lc||o&&i===pc?(e.preventDefault(),this.setState({pressed:!0})):n||i!==lc||(this.enterClick=!0)},this.handleKeyUp=e=>{const{onKeyUp:t,role:r}=this.props;t&&t(e);const i=e.which||e.keyCode,{triggerOnEnter:n,triggerOnSpace:o}=sc(r);n&&i===lc||o&&i===pc?(this.setState({pressed:!1,focused:!0}),this.runCallbackAndMaybeNavigate(e)):n||i!==lc||(this.enterClick=!1)},this.handleFocus=e=>{this.setState({focused:!0})},this.handleBlur=e=>{this.setState({focused:!1,pressed:!1})},this.state=hc,this.waitingForClick=!1,this.enterClick=!1,this.dragging=!1}navigateOrReset(e){if(e){const{history:e,href:t,skipClientNav:r,target:i}=this.props;t&&("_blank"===i?(window.open(t,"_blank"),this.setState({waiting:!1})):e&&!r?(e.push(t),this.setState({waiting:!1})):window.location.assign(t))}else this.setState({waiting:!1})}handleSafeWithNav(e,t){const{skipClientNav:r,history:i}=this.props;return i&&!r||"_blank"===this.props.target?(e(),this.navigateOrReset(t),Promise.resolve()):(this.state.waiting||this.setState({waiting:!0}),e().then((()=>{this.state.waiting||this.setState({waiting:!0})})).catch((e=>{})).finally((()=>{this.navigateOrReset(t)})))}runCallbackAndMaybeNavigate(e){const{onClick:t,beforeNav:r,safeWithNav:i,href:n,type:o}=this.props;let s=!0,a=!0;if(t&&t(e),e.defaultPrevented&&(s=!1,a=!1),e.preventDefault(),!n&&"submit"===o&&a){let t=e.currentTarget;for(;t;){if(t instanceof window.HTMLFormElement){const e=new window.Event("submit",{cancelable:!0});t.dispatchEvent(e);break}t=t.parentElement}}if(r)this.setState({waiting:!0}),r().then((()=>i?this.handleSafeWithNav(i,s):this.navigateOrReset(s))).catch((()=>{}));else{if(i)return this.handleSafeWithNav(i,s);this.navigateOrReset(s)}}render(){const e=this.props.disabled?ma({},ac,{onFocus:this.handleFocus,onBlur:this.handleBlur}):{onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onMouseDown:this.handleMouseDown,onMouseUp:this.handleMouseUp,onDragStart:this.handleDragStart,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onTouchCancel:this.handleTouchCancel,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onFocus:this.handleFocus,onBlur:this.handleBlur,tabIndex:0};e.rel=this.props.rel||("_blank"===this.props.target?"noopener noreferrer":void 0);const{children:t}=this.props;return t&&t(this.state,e)}}cc.defaultProps={disabled:!1};const dc=e=>"string"==typeof e&&(!/^(https?:)?\/\//i.test(e)&&!/^([^#]*#[\w-]*|[\w\-.]+:)/.test(e)),uc=function(e){var t="withRouter("+(e.displayName||e.name)+")",r=function(r){var i=r.wrappedComponentRef,n=ga(r,["wrappedComponentRef"]);return l.createElement(Sh.Consumer,null,(function(r){return r||("production"!==process.env.NODE_ENV?kp(!1,"You should not use <"+t+" /> outside a <Router>"):kp(!1)),l.createElement(e,ma({},n,r,{ref:i}))}))};return r.displayName=t,r.WrappedComponent=e,"production"!==process.env.NODE_ENV&&(r.propTypes={wrappedComponentRef:d.oneOfType([d.string,d.func,d.object])}),Ch(r,e)}(cc);function mc(e,t,r){return r&&!0!==t&&e&&dc(e)?uc:cc}const gc=["href","onClick","skipClientNav","beforeNav","safeWithNav","style","target","testId","onKeyDown","onKeyUp","hideDefaultFocusRing","light","disabled"],fc=R("a"),vc=R("button"),yc=R(Qh);class bc extends a.Component{constructor(...e){super(...e),this.getCorrectTag=(e,t,r)=>{const i=this.props.href&&!this.props.disabled,n=t&&!this.props.skipClientNav&&dc(this.props.href||"");return i&&n&&this.props.href?a.createElement(yc,ma({},r,{to:this.props.href,role:this.props.role,target:this.props.target||void 0,"aria-disabled":this.props.disabled?"true":void 0}),this.props.children(e)):i&&!n?a.createElement(fc,ma({},r,{href:this.props.href,role:this.props.role,target:this.props.target||void 0,"aria-disabled":this.props.disabled?"true":void 0}),this.props.children(e)):a.createElement(vc,ma({},r,{type:"button","aria-disabled":this.props.disabled}),this.props.children(e))}}renderClickableBehavior(e){const t=this.props,{href:r,onClick:i,skipClientNav:n,beforeNav:o,safeWithNav:s,style:l,target:p,testId:h,onKeyDown:c,onKeyUp:d,hideDefaultFocusRing:u,light:m,disabled:g}=t,f=ga(t,gc),v=mc(r,n,e),y=e=>[xc.reset,xc.link,!u&&e.focused&&(m?xc.focusedLight:xc.focused),l];return o?a.createElement(v,{href:r,onClick:i,beforeNav:o,safeWithNav:s,onKeyDown:c,onKeyUp:d,disabled:g},((t,r)=>this.getCorrectTag(t,e,ma({},f,{"data-test-id":h,style:y(t)},r)))):a.createElement(v,{href:r,onClick:i,safeWithNav:s,onKeyDown:c,onKeyUp:d,target:p,disabled:g},((t,r)=>this.getCorrectTag(t,e,ma({},f,{"data-test-id":h,style:y(t)},r))))}render(){return a.createElement(Sh.Consumer,null,(e=>this.renderClickableBehavior(e)))}}bc.defaultProps={light:!1,disabled:!1,"aria-label":""};const xc=m.create({reset:{border:"none",margin:0,padding:0,width:"auto",overflow:"visible",background:"transparent",textDecoration:"none",color:"inherit",font:"inherit",boxSizing:"border-box",touchAction:"manipulation",userSelect:"none",outline:"none",lineHeight:"normal",WebkitFontSmoothing:"inherit",MozOsxFontSmoothing:"inherit"},link:{cursor:"pointer"},focused:{outline:`solid 2px ${_.blue}`},focusedLight:{outline:`solid 2px ${_.white}`}}),wc={xsmall:16,small:24,medium:48,large:96},Cc={xsmall:"M7.237.741C7.165.393 6.95.154 6.656.053A1.01 1.01 0 0 0 6.18.01c-.053.009-.053.009-.087.017C2.553.949 0 4.214 0 7.91 0 12.36 3.598 16 8 16c4.4 0 8-3.647 8-8.112a1.02 1.02 0 0 0-.118-.423.877.877 0 0 0-.808-.48.909.909 0 0 0-.81.46c-.09.151-.13.296-.146.455-.08 3.493-2.737 6.207-6.118 6.207-3.41 0-6.118-2.74-6.118-6.196 0-2.843 1.936-5.291 4.644-6.022.1-.028.224-.082.352-.177a.928.928 0 0 0 .36-.97z",small:"M10.598.943c-.093-.449-.362-.748-.732-.875a1.314 1.314 0 0 0-.723-.033C3.83 1.417 0 6.317 0 11.864 0 18.538 5.398 24 12 24c6.598 0 12-5.471 12-12.16a1.333 1.333 0 0 0-.154-.548c-.193-.368-.544-.606-1.023-.606-.472 0-.825.229-1.035.585-.117.2-.169.39-.189.582-.124 5.472-4.294 9.73-9.599 9.73-5.349 0-9.599-4.3-9.599-9.72 0-4.46 3.036-8.299 7.28-9.444.127-.036.291-.107.458-.232.373-.28.57-.711.46-1.244z",medium:"M44.19 23.455a1.91 1.91 0 1 1 3.801 0h.003c.004.18.006.363.006.545 0 13.255-10.745 24-24 24S0 37.255 0 24 10.745 0 24 0c.182 0 .364.002.545.006V.01a1.91 1.91 0 1 1 0 3.801v.015A20.564 20.564 0 0 0 24 3.818C12.854 3.818 3.818 12.854 3.818 24c0 11.146 9.036 20.182 20.182 20.182 11.146 0 20.182-9.036 20.182-20.182 0-.182-.003-.364-.007-.545h.015z",large:"M88.38 46.91a3.818 3.818 0 1 1 7.602 0h.006c.008.362.012.725.012 1.09 0 26.51-21.49 48-48 48S0 74.51 0 48 21.49 0 48 0c.365 0 .728.004 1.09.012v.005a3.818 3.818 0 1 1 0 7.602v.032c-.362-.01-.725-.015-1.09-.015C25.708 7.636 7.636 25.708 7.636 48c0 22.292 18.072 40.364 40.364 40.364 22.292 0 40.364-18.072 40.364-40.364 0-.365-.005-.728-.015-1.09h.032z"},kc={light:_.white,dark:_.offBlack16},Ec=R("path");class Sc extends a.Component{render(){const{size:e,light:t,style:r}=this.props,i=wc[e],n=Cc[e],o=t?kc.light:kc.dark,s=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:`0 0 ${i} ${i}`},a.createElement(Ec,{style:[_c.loadingSpinner,{fill:o}],fillRule:"nonzero",d:n}));return a.createElement(A,{style:[_c.spinnerContainer,r]},s)}}Sc.defaultProps={size:"large",light:!1};const _c=m.create({spinnerContainer:{justifyContent:"center"},loadingSpinner:{transformOrigin:"50% 50%",animationName:{"0%":{transform:"rotate(0deg)"},"50%":{transform:"rotate(180deg)"},"100%":{transform:"rotate(360deg)"}},animationDuration:"1.1s",animationIterationCount:"infinite",animationTimingFunction:"linear"}}),Mc=e=>({small:16,medium:24,large:48,xlarge:96}[e]),Tc=["color","icon","size","style"],Ic=R("svg");class Pc extends a.PureComponent{render(){const e=this.props,{color:t,icon:r,size:i,style:n}=e,o=ga(e,Tc),{assetSize:s,path:l}=((e,t)=>{if(e[t])return{assetSize:t,path:e[t]};{const r=Mc(t),i=Object.keys(e),n=e=>{const t=Mc(e)-r;return t>0?Number.POSITIVE_INFINITY:Math.abs(t)},o=i.sort(((e,t)=>n(e)-n(t)))[0];if(o&&e[o])return{assetSize:o,path:e[o]};throw new Error("Icon does not contain any valid asset sizes!")}})(r,i),p=Mc(i),h=Mc(s);return a.createElement(Ic,ma({},o,{style:[Nc.svg,n],width:p,height:p,viewBox:`0 0 ${h} ${h}`}),a.createElement("path",{fill:t,d:l}))}}Pc.defaultProps={color:"currentColor",size:"small"};const Nc=m.create({svg:{display:"inline-block",verticalAlign:"text-bottom",flexShrink:0,flexGrow:0}}),Ac=["children","skipClientNav","color","disabled","focused","hovered","href","kind","light","pressed","size","style","testId","type","spinner","icon","id","waiting"],Rc=R("a"),Fc=R("button"),Oc=R(Qh);class Dc extends a.Component{renderInner(e){const t=this.props,{children:r,skipClientNav:i,color:n,disabled:o,focused:s,hovered:l,href:p,kind:h,light:c,pressed:d,size:u,style:m,testId:g,type:f,spinner:v,icon:y,id:b}=t,x=ga(t,Ac),w="destructive"===n?M.controlDestructive:M.controlDefault,C=zc(w,h,c,y?8+("small"===u?16:24):0,u),k=v||o,E=ma({"data-test-id":g,id:b,role:"button",style:[[Lc.shared,k&&Lc.disabled,y&&Lc.withIcon,C.default,k&&C.disabled,"tertiary"!==h&&!k&&(d?C.active:(l||s)&&C.focus),"small"===u&&Lc.small,"xlarge"===u&&Lc.xlarge],m]},x),S="small"===u?Ga:Ha,_=a.createElement(S,{style:[Lc.text,"xlarge"===u&&Lc.xlargeText,y&&Lc.textWithIcon,v&&Lc.hiddenText,"tertiary"===h&&Lc.textWithFocus,"tertiary"===h&&!k&&(d?C.active:(l||s)&&C.focus)]},y&&a.createElement(Pc,{size:u,color:"currentColor",icon:y,style:Lc.icon}),r),T=a.createElement(a.Fragment,null,_,v&&a.createElement(Sc,{style:Lc.spinner,size:{medium:"small",small:"xsmall",xlarge:"medium"}[u],light:"primary"===h}));return p&&!k?e&&!i&&dc(p)?a.createElement(Oc,ma({},E,{to:p}),T):a.createElement(Rc,ma({},E,{href:p}),T):a.createElement(Fc,ma({type:f||"button"},E,{"aria-disabled":k}),T)}render(){return a.createElement(Sh.Consumer,null,(e=>this.renderInner(e)))}}const Lc=m.create({shared:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:40,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16,border:"none",borderRadius:4,cursor:"pointer",outline:"none",textDecoration:"none",boxSizing:"border-box",touchAction:"manipulation",userSelect:"none",":focus":{WebkitTapHighlightColor:"rgba(0,0,0,0)"}},withIcon:{paddingLeft:12},disabled:{cursor:"auto"},small:{height:32},xlarge:{height:60},text:{alignItems:"center",fontWeight:"bold",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",pointerEvents:"none"},xlargeText:{fontSize:18,lineHeight:"20px"},textWithIcon:{display:"flex"},textWithFocus:{position:"relative"},hiddenText:{visibility:"hidden"},spinner:{position:"absolute"},icon:{paddingRight:F.xSmall_8}}),Bc={},zc=(e,t,r,i,n)=>{const o=e+t+r.toString()+i.toString()+n;if(Bc[o])return Bc[o];const{white:s,white50:a,white64:l,offBlack32:p,offBlack50:h,darkBlue:c}=_,d=T(I(e,.32),s),u=T(p,e),g="xlarge"===n?F.xLarge_32:F.medium_16;let f={};if("primary"===t)f={default:{background:r?s:e,color:r?e:s,paddingLeft:g,paddingRight:g},focus:{boxShadow:`0 0 0 1px ${r?c:s}, 0 0 0 3px ${r?s:e}`},active:{boxShadow:`0 0 0 1px ${r?c:s}, 0 0 0 3px ${r?d:u}`,background:r?d:u,color:r?u:d},disabled:{background:r?d:p,color:r?e:l,cursor:"default",":focus":{boxShadow:`0 0 0 1px ${r?p:s}, 0 0 0 3px ${r?d:p}`}}};else if("secondary"===t)f={default:{background:"none",color:r?s:e,borderColor:r?a:h,borderStyle:"solid",borderWidth:1,paddingLeft:i?g-4:g,paddingRight:g},focus:{background:r?"transparent":s,borderColor:r?s:e,borderWidth:2,paddingLeft:i?g-5:g-1,paddingRight:g-1},active:{background:r?u:d,color:r?d:u,borderColor:r?d:u,borderWidth:2,paddingLeft:i?g-5:g-1,paddingRight:g-1},disabled:{color:r?a:p,borderColor:r?d:p,cursor:"default",":focus":{borderColor:r?a:p,borderWidth:2,paddingLeft:i?g-5:g-1,paddingRight:g-1}}};else{if("tertiary"!==t)throw new Error("Button kind not recognized");f={default:{background:"none",color:r?s:e,paddingLeft:0,paddingRight:0},focus:{":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${i}px)`,right:0,bottom:0,background:r?s:e,borderRadius:2}},active:{color:r?d:u,":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${i}px)`,right:0,bottom:"calc(50% - 11px)",background:r?d:u,borderRadius:2}},disabled:{color:r?d:p,cursor:"default"}}}return Bc[o]=m.create(f),Bc[o]},Hc=["href","type","children","skipClientNav","spinner","disabled","onClick","beforeNav","safeWithNav","tabIndex","target","rel"],Wc=["tabIndex"];class qc extends a.Component{renderClickableBehavior(e){const t=this.props,{href:r,type:i,children:n,skipClientNav:o,spinner:s,disabled:l,onClick:p,beforeNav:h,safeWithNav:c,tabIndex:d,target:u,rel:m}=t,g=ga(t,Hc),f=mc(r,o,e),v=(e,t)=>{let{tabIndex:p}=t,h=ga(t,Wc);return a.createElement(Dc,ma({},g,e,h,{disabled:l,spinner:s||e.waiting,skipClientNav:o,href:r,target:u,type:i,tabIndex:d||p}),n)};return h?a.createElement(f,{disabled:s||l,href:r,role:"button",type:i,onClick:p,beforeNav:h,safeWithNav:c,rel:m},v):a.createElement(f,{disabled:s||l,href:r,role:"button",type:i,onClick:p,safeWithNav:c,target:u,rel:m},v)}render(){return a.createElement(Sh.Consumer,null,(e=>this.renderClickableBehavior(e)))}}qc.defaultProps={color:"default",kind:"primary",light:!1,size:"medium",disabled:!1,spinner:!1};class Uc extends a.Component{render(){var{apiOptions:e,answerBarState:t,onCheckAnswer:r,onNextQuestion:i}=this.props,n=G(G({},Gc.answerBar),{},{backgroundColor:"CORRECT"===t?_.offWhite:"white",justifyContent:"CORRECT"!==t||i?"space-between":"center"}),s="INCORRECT"===t?a.createElement("span",{style:Gc.text},a.createElement("span",{style:Gc.tryAgainIcon},a.createElement(X,Ti)),a.createElement("span",{style:{marginLeft:8}},o._("Keep trying"))):a.createElement("span",null);if("CORRECT"!==t){var l="INCORRECT"===t?o._("Try again"):o._("Check");return a.createElement("div",{style:n},s,a.createElement(qc,{disabled:e.readOnly||"ACTIVE"!==t,onClick:r},l))}return a.createElement("div",{style:n},a.createElement("span",{style:Gc.text},a.createElement("span",{style:{fontSize:28,color:_.green}},a.createElement(X,Y({},Mi,{style:{marginBottom:5}}))),a.createElement("span",{role:"alert","aria-label":o._("Correct!"),style:{marginLeft:8}},o._("Correct!"))),i&&a.createElement(qc,{onClick:i},o._("Next question")))}}var Gc={answerBar:{display:"flex",alignItems:"center",height:68,marginLeft:-16,marginRight:-16,marginBottom:-16,marginTop:16,paddingLeft:16,paddingRight:10,borderTop:"1px solid ".concat(_.offBlack50)},tryAgainIcon:{fontSize:28,color:"#63D9EA",transform:"scale(-1,1) rotate(-268deg)"},text:{display:"flex",flexDirection:"row",alignItems:"center",fontWeight:"bold",fontSize:17}},Vc="ungraded",jc="correct",Yc="incorrect",$c="invalid",Xc=(e,t)=>{switch(e){case"HIDDEN":case"INACTIVE":return t?"ACTIVE":e;case"ACTIVE":return t?e:"INACTIVE";case"INCORRECT":return t?"ACTIVE":"INACTIVE";default:return e}},Kc=o._("We couldn't grade your answer."),Zc=o._("It looks like you left something blank or ")+o._("entered in an invalid answer.");class Jc extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"state",{status:Vc,showHint:!1,message:"",answerBarState:"HIDDEN"}),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"_onInteractWithWidget",(e=>{if(this.setState({status:Vc,message:""}),this.refs.renderer){this.change("widgets",this.props.widgets);var t=0===this.refs.renderer.emptyWidgets().length,r=this.state.answerBarState;this.setState({answerBarState:Xc(r,t)})}})),j(this,"_checkAnswer",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices();var e=this.refs.renderer.score(),t="points"===e.type?e.total===e.earned?jc:Yc:$c,r="points"===e.type?e.message||"":e.message?"".concat(Kc," ").concat(e.message):"".concat(Kc," ").concat(Zc);this.setState({status:t,message:r,answerBarState:"correct"===t?"CORRECT":"INCORRECT"}),this.props.trackInteraction({status:t})})),j(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),j(this,"setInputValue",((e,t,r)=>this.refs.renderer.setInputValue(e,t,r))),j(this,"focus",(()=>this.refs.renderer.focus())),j(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),j(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){var e=h.extend({},Zt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}}),t=null,r=null;this.state.status===jc?(r=a.createElement(X,Y({},Ei,{style:{color:"#526f03"}})),t=o._("Correct")):this.state.status===Yc&&(r=a.createElement(X,Y({},_i,{style:{color:"#ff5454"}})),t=o._("Incorrect"));var i=this.props.inGradedGroupSet?g(Qc.gradedGroupInSet):g(Qc.gradedGroup),n=s({[i]:e.isMobile,"perseus-graded-group":!0,"answer-correct":!e.isMobile&&this.state.status===jc,"answer-incorrect":!e.isMobile&&this.state.status===Yc}),{answerBarState:l}=this.state,p="CORRECT"===l,c=e.readOnly||e.isMobile&&p;return a.createElement("div",{className:n},!!this.props.title&&a.createElement("div",{className:g(Qc.title)},this.props.title),a.createElement(Bo,Y({},this.props,{ref:"renderer",apiOptions:G(G({},e),{},{readOnly:c}),onInteractWithWidget:this._onInteractWithWidget,linterContext:this.props.linterContext})),!e.isMobile&&r&&a.createElement("div",{className:"group-icon"},r),!e.isMobile&&t&&a.createElement("div",{className:g(ml.srOnly),role:"alert","aria-label":t},t),!e.isMobile&&a.createElement("p",null,this.state.message),!e.isMobile&&a.createElement(qc,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this._checkAnswer},o._("Check")),!e.isMobile&&p&&this.props.onNextQuestion&&a.createElement(qc,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this.props.onNextQuestion,style:{marginLeft:5}},o._("Next question")),this.props.hint&&this.props.hint.content&&(this.state.showHint?a.createElement("div",null,a.createElement("button",{tabIndex:"0",className:g(Qc.explanationTitle),onClick:()=>this.setState({showHint:!1}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!1})}},o._("Hide explanation")),a.createElement(Bo,Y({},this.props.hint,{ref:"hints-renderer",apiOptions:e,linterContext:this.props.linterContext}))):a.createElement("button",{tabIndex:"0",onClick:()=>this.setState({showHint:!0}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!0})},className:g(Qc.showHintLink)},o._("Explain"))),e.isMobile&&"HIDDEN"!==l&&a.createElement(Uc,{apiOptions:e,answerBarState:l,onCheckAnswer:this._checkAnswer,onNextQuestion:this.props.onNextQuestion}))}}j(Jc,"defaultProps",{title:"",content:"",widgets:{},images:{},hint:null,hasHint:!1,linterContext:Vt});var Qc=m.create({gradedGroupInSet:{marginLeft:0,paddingLeft:0},gradedGroup:{borderTop:"1px solid ".concat(J),borderBottom:"1px solid ".concat(J),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"},showHintLink:{backgroundColor:"unset",fontSize:14,padding:0,border:"none",marginTop:20,color:"#71B307",cursor:"pointer",display:"block",clear:"both"},explanationTitle:{backgroundColor:"unset",marginTop:20,color:"#71B307",marginBottom:10,cursor:"pointer",fontSize:14,padding:0,border:"none",display:"block",clear:"both"},title:{fontSize:12,color:J,textTransform:"uppercase",marginBottom:11,letterSpacing:.8}}),ed={name:"graded-group",displayName:"Graded group (articles only)",widget:Jc,traverseChildWidgets:function(e,t){return h.extend({},e,t(e))},hidden:!1,tracking:"all",isLintable:!0},td=ed.widget;class rd extends a.Component{render(){for(var e=this,t=[],r=function(r){t.push(a.createElement("div",{role:"button","aria-label":o._("Skip to %(title)s",{title:e.props.groupTitles[r]}),key:r,className:g(od.indicator,r===e.props.currentGroup&&od.selectedIndicator),onClick:()=>e.props.onChangeCurrentGroup(r)}))},i=0;i<this.props.numGroups;i++)r(i);return a.createElement("div",{className:g(od.indicatorContainer)},t)}}class id extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"_childGroup",void 0),j(this,"state",{currentGroup:0}),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"getInputPaths",(()=>this._childGroup.getInputPaths())),j(this,"setInputValue",((e,t,r)=>this._childGroup.setInputValue(e,t,r))),j(this,"focus",(()=>this._childGroup.focus())),j(this,"focusInputPath",(e=>{this._childGroup.focusInputPath(e)})),j(this,"blurInputPath",(e=>{this._childGroup.blurInputPath(e)})),j(this,"handleNextQuestion",(()=>{var{currentGroup:e}=this.state;e<this.props.gradedGroups.length-1&&this.setState({currentGroup:e+1})}))}shouldComponentUpdate(e,t){return e.gradedGroups,e!==this.props||t!==this.state}render(){var{JIPT:e}=ae();if(e.useJIPT&&this.props.gradedGroups.length>1)return a.createElement("div",{className:g(od.container)},this.props.gradedGroups.map(((e,t)=>a.createElement(td,Y({key:t},this.props,e,{inGradedGroupSet:!1,linterContext:this.props.linterContext})))));var t=this.props.gradedGroups[this.state.currentGroup];if(!t)return a.createElement("span",null,o.doNotTranslate("No current group..."));var r=this.props.gradedGroups.length,i=this.state.currentGroup<r-1?this.handleNextQuestion:null;return a.createElement("div",{className:g(od.container)},a.createElement("div",{className:g(od.top)},a.createElement("div",{className:g(od.title)},t.title),a.createElement("div",{className:g(od.spacer)}),a.createElement(rd,{numGroups:r,currentGroup:this.state.currentGroup,groupTitles:this.props.gradedGroups.map((e=>e.title)),onChangeCurrentGroup:e=>this.setState({currentGroup:e})})),a.createElement(td,Y({key:this.state.currentGroup,ref:e=>this._childGroup=e},this.props,t,{inGradedGroupSet:!0,title:null,onNextQuestion:i,linterContext:this.props.linterContext})))}}j(id,"defaultProps",{gradedGroups:[],linterContext:Vt});var nd={name:"graded-group-set",displayName:"Graded group set (articles only)",widget:id,traverseChildWidgets:function(e,t){return{groups:e.gradedGroups.map(t)}},hidden:!1,tracking:"all",isLintable:!0},od=m.create({top:{display:"flex",flexDirection:"row"},spacer:{flex:1},title:{fontSize:12,color:J,textTransform:"uppercase",marginBottom:11,letterSpacing:.8},indicatorContainer:{display:"flex",flexDirection:"row"},indicator:{width:10,height:10,borderRadius:5,backgroundColor:"#AAAAAA",marginLeft:5,cursor:"pointer"},selectedIndicator:{backgroundColor:"#71B307"},container:{borderTop:"1px solid ".concat(J),borderBottom:"1px solid ".concat(J),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"}});class sd extends a.Component{constructor(){super(...arguments),j(this,"container",void 0)}componentWillUnmount(){this.container=null}focus(){if(this.container)return this.container.focus(),!0}toggleSelect(e){var t=this.props.value;this.props.allowEmpty?this.props.onChange(t!==e?e:null):this.props.onChange(e)}render(){var e=this.props.value,t=this.props.buttons.map(((t,r)=>a.createElement("button",{title:t.title,type:"button",id:""+r,ref:"button"+r,key:""+r,className:g(ad.buttonStyle,t.value===e&&ad.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)));return a.createElement("div",{style:{display:"inline-block"},ref:e=>this.container=e},t)}}j(sd,"defaultProps",{value:null,allowEmpty:!0});var ad=m.create({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"}}),ld={url:null};function pd(e){var t=e[0],r=e[1],i=e[2],n=e[3];t<0&&(t*=-1,r*=-1,i*=-1);var o=2*Math.PI;for(r<0&&(r*=-1,i*=-1,i+=o/2);i>0;)i-=o;for(;i<0;)i+=o;return[t,r,i,n]}function hd(e){var t=e[0],r=e[1],i=e[2],n=e[3];t<0&&(t*=-1,r*=-1,i*=-1);var o=Math.PI;for(r<0&&(r*=-1,i*=-1,i+=o/2);i>0;)i-=o;for(;i<0;)i+=o;return[t,r,i,n]}var cd={areEqual:function(e,t){return De.deepEq(e,t)},Movable:Nn.Plot,getPropsForCoeffs:function(e){return{fn:h.partial(this.getFunctionForCoeffs,e)}}},dd=h.extend({},cd,{url:"https://ka-perseus-graphie.s3.amazonaws.com/67aaf581e6d9ef9038c10558a1f70ac21c11c9f8.png",defaultCoords:[[.25,.75],[.75,.75]],getCoefficients:function(e){var t=e[0],r=e[1],i=r[0]-t[0],n=r[1]-t[1];if(0!==i){var o=n/i;return[o,r[1]-o*r[0]]}},getFunctionForCoeffs:function(e,t){return e[0]*t+e[1]},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1];return"y = "+r.toFixed(3)+"x + "+i.toFixed(3)}}),ud=h.extend({},cd,{url:"https://ka-perseus-graphie.s3.amazonaws.com/e23d36e6fc29ee37174e92c9daba2a66677128ab.png",defaultCoords:[[.5,.5],[.75,.75]],Movable:Nn.Parabola,getCoefficients:function(e){var t=e[0],r=e[1],i=t[0],n=t[1],o=(r[1]-n)/((r[0]-i)*(r[0]-i));return[o,-2*i*o,o*i*i+n]},getFunctionForCoeffs:function(e,t){return(e[0]*t+e[1])*t+e[2]},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2]}},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1],n=t[2];return"y = "+r.toFixed(3)+"x^2 + "+i.toFixed(3)+"x + "+n.toFixed(3)}}),md=h.extend({},cd,{url:"https://ka-perseus-graphie.s3.amazonaws.com/3d68e7718498475f53b206c2ab285626baf8857e.png",defaultCoords:[[.5,.5],[.6,.6]],Movable:Nn.Sinusoid,getCoefficients:function(e){var t=e[0],r=e[1],i=r[1]-t[1],n=Math.PI/(2*(r[0]-t[0]));return[i,n,t[0]*n,t[1]]},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2],o=e[3];return r*Math.sin(i*t-n)+o},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2],d:e[3]}},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1],n=t[2],o=t[3];return"y = "+r.toFixed(3)+" sin("+i.toFixed(3)+"x - "+n.toFixed(3)+") + "+o.toFixed(3)},areEqual:function(e,t){return De.deepEq(pd(e),pd(t))}}),gd=h.extend({},cd,{url:"https://ka-perseus-graphie.s3.amazonaws.com/7db80d23c35214f98659fe1cf0765811c1bbfbba.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){var t=e[0],r=e[1],i=r[1]-t[1],n=Math.PI/(4*(r[0]-t[0]));return[i,n,t[0]*n,t[1]]},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2],o=e[3];return r*Math.tan(i*t-n)+o},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1],n=t[2],o=t[3];return"y = "+r.toFixed(3)+" sin("+i.toFixed(3)+"x - "+n.toFixed(3)+") + "+o.toFixed(3)},areEqual:function(e,t){return De.deepEq(hd(e),hd(t))}}),fd=h.extend({},cd,{url:"https://ka-perseus-graphie.s3.amazonaws.com/9cbfad55525e3ce755a31a631b074670a5dad611.png",defaultCoords:[[.5,.55],[.75,.75]],defaultAsymptote:[[0,.5],[1,.5]],extraCoordConstraint:function(e,t,r,i,n){var o=h.head(i)[1];return h.all(r,(e=>e[1]!==o))},extraAsymptoteConstraint:function(e,t,r,i,n){var o=e[1];if(h.all(r,(e=>e[1]>o))||h.all(r,(e=>e[1]<o)))return[t[0],o];var s=t[1];if(h.all(r,(e=>e[1]>s))){var a=h.min(h.map(r,(e=>e[1])));return[t[0],a-n.snapStep[1]]}var l=h.max(h.map(r,(e=>e[1])));return[t[0],l+n.snapStep[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){var r=e[0],i=e[1],n=h.head(t)[1],o=Math.log((r[1]-n)/(i[1]-n))/(r[0]-i[0]);return[(r[1]-n)/Math.exp(o*r[0]),o,n]},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2];return r*Math.exp(i*t)+n},getEquationString:function(e,t){if(!t)return null;var r=this.getCoefficients(e,t),i=r[0],n=r[1],o=r[2];return"y = "+i.toFixed(3)+"e^("+n.toFixed(3)+"x) + "+o.toFixed(3)}}),vd=h.extend({},cd,{url:"https://ka-perseus-graphie.s3.amazonaws.com/f6491e99d34af34d924bfe0231728ad912068dc3.png",defaultCoords:[[.55,.5],[.75,.75]],defaultAsymptote:[[.5,0],[.5,1]],extraCoordConstraint:function(e,t,r,i,n){var o=h.head(i)[0];return h.all(r,(e=>e[0]!==o))&&r[0][1]!==r[1][1]},extraAsymptoteConstraint:function(e,t,r,i,n){var o=e[0];if(h.all(r,(e=>e[0]>o))||h.all(r,(e=>e[0]<o)))return[o,t[1]];var s=t[0];return h.all(r,(e=>e[0]>s))?[h.min(h.map(r,(e=>e[0])))-n.snapStep[0],t[1]]:[h.max(h.map(r,(e=>e[0])))+n.snapStep[0],t[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){var r=e=>[e[1],e[0]],i=fd.getCoefficients(h.map(e,r),h.map(t,r)),n=-i[2]/i[0],o=1/i[0];return[1/i[1],o,n]},getFunctionForCoeffs:function(e,t,r){var i=e[0],n=e[1],o=e[2];return i*Math.log(n*t+o)},getEquationString:function(e,t){if(!t)return null;var r=this.getCoefficients(e,t),i=r[0],n=r[1],o=r[2];return"y = ln("+i.toFixed(3)+"x + "+n.toFixed(3)+") + "+o.toFixed(3)}}),yd=h.extend({},cd,{url:"https://ka-perseus-graphie.s3.amazonaws.com/8256a630175a0cb1d11de223d6de0266daf98721.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){var t=e[0],r=e[1],i=r[0]-t[0],n=r[1]-t[1];if(0!==i){var o=Math.abs(n/i);return r[1]<t[1]&&(o*=-1),[o,t[0],t[1]]}},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2];return r*Math.abs(t-i)+n},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1],n=t[2];return"y = "+r.toFixed(3)+"| x - "+i.toFixed(3)+"| + "+n.toFixed(3)}}),bd={linear:dd,quadratic:ud,sinusoid:md,tangent:gd,exponential:fd,logarithm:vd,absolute_value:yd},xd=h.keys(bd);function wd(e){return bd[e]}var Cd=(e,t)=>{if(e.type!==t.correct.type)return{type:"points",earned:0,total:1,message:null};if(null==e.coords)return{type:"invalid",message:null};var r=wd(e.type),i=r.getCoefficients(e.coords,e.asymptote),n=r.getCoefficients(t.correct.coords,t.correct.asymptote);return null==i||null==n?{type:"invalid",message:null}:r.areEqual(i,n)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}},kd=(e,t,r,i)=>e.map((e=>{var n=e.map(((e,i)=>{var n=t[i],o=r[i],s=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,o),a=Math.round(e*s);return n[0]+o*a}));return x.roundTo(n,i)})),Ed=(e,t,r,i)=>e?kd(e,t,r,i):e,Sd=(e,t)=>{var r=wd(e),i=De.snapStepFromGridStep([1,1]);return{type:e,asymptote:Ed(r.defaultAsymptote,t.range,t.step,i),coords:null}},_d=h.first,Md=(e,t)=>{var r=e.gridStep||De.getGridStep(e.range,e.step,t);return{gridStep:r,snapStep:e.snapStep||De.snapStepFromGridStep(r)}},Td={labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:ld,markings:"graph",rulerLabel:"",rulerTicks:10,valid:!0,showTooltips:!1},Id=Sd("linear",Td),Pd={graph:Td,plot:Id,availableTypes:[Id.type]},Nd=e=>{var t=e.charAt(0).toUpperCase()+e.substring(1),r=ae().staticUrl;return{value:e,title:t,content:a.createElement("img",{src:r(wd(e).url),alt:t})}},Ad=Object.freeze({__proto__:null,DEFAULT_BACKGROUND_IMAGE:ld,allTypes:xd,functionForType:wd,validate:Cd,getEquationString:e=>{var t=e.plot;return t.type&&t.coords&&wd(t.type).getEquationString(t.coords,t.asymptote)||""},pointsFromNormalized:kd,maybePointsFromNormalized:Ed,defaultPlotProps:Sd,chooseType:_d,getGridAndSnapSteps:Md,DEFAULT_GRAPHER_PROPS:Pd,typeToButton:Nd}),Rd=Nn.MovablePoint,Fd=Nn.MovableLine;var Od={padding:"5px 5px"};class Dd extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"_coords",(()=>{var e=this.props,t=e.graph,r=e.model&&Ed(e.model.defaultCoords,t.range,t.step,t.snapStep);return e.coords||r||null})),j(this,"_asymptote",(()=>this.props.asymptote)),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"renderPlot",(()=>{var e=this.props.model,t=this.props.graph.range[0],r=G({stroke:this.props.isMobile?mr.BLUE_C:mr.DYNAMIC},this.props.isMobile?{"stroke-width":3}:{}),i=e.getCoefficients(this._coords(),this._asymptote());if(i){var n=e.getPropsForCoeffs(i,t);return a.createElement(e.Movable,Y({},n,{key:this.props.model.url,range:t,style:r}))}})),j(this,"renderAsymptote",(()=>{var e=this.props.model,t=this.props.graph,r=this._asymptote(),i={strokeDasharray:"- "};return r&&a.createElement(Fd,{onMove:(e,t)=>{var r=w.subtract(e,t),i=h.map(this._asymptote(),(e=>w.add(e,r)));this.props.onChange({asymptote:i})},constraints:[mn.MovableLine.constraints.bound(),mn.MovableLine.constraints.snap(),(r,i)=>{var n=w.subtract(r,i),o=h.map(this._asymptote(),(e=>w.add(e,n)));return!e.extraAsymptoteConstraint||e.extraAsymptoteConstraint(r,i,this._coords(),o,t)}],normalStyle:i,highlightStyle:i},h.map(r,((e,t)=>a.createElement(Rd,{key:"asymptoteCoord-".concat(t),coord:e,static:!0,draw:null,extendLine:!0,showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))))}))}render(){var e=h.map(this._coords(),((e,t)=>a.createElement(Rd,{key:t,coord:e,static:this.props.static,constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),e=>{var r=h.all(this._coords(),((r,i)=>t===i||!r||!b.equal(e[0],r[0])));if(!r)return!1;if(this.props.model&&this.props.model.extraCoordConstraint){var i=this.props.model.extraCoordConstraint,n=h.clone(this._coords()),o=h.clone(n[t]);return n[t]=e,i(e,o,n,this._asymptote(),this.props.graph)}return r}],onMove:(e,r)=>{var i,n=this._asymptote();i=n&&this.props.model.allowReflectOverAsymptote&&function(e,t,r){var i=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1]);return i(r[0],r[1],t)>0!=i(r[0],r[1],e)>0}(e,r,n)?h.map(this._coords(),(e=>x.reflectOverLine(e,n))):h.clone(this._coords()),i[t]=e,this.props.onChange({coords:i})},showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))),t=this.props.graph.box,r=this.props.graph.backgroundImage,i=null;if(r.url){var n=t[0]/te.defaultBoxSize;i=a.createElement(Vn,{src:r.url,width:r.width,height:r.height,scale:n})}return a.createElement("div",{className:"perseus-widget perseus-widget-grapher",style:{width:t[0],height:t[1],boxSizing:"initial"}},a.createElement("div",{className:"graphie-container above-scratchpad",style:{width:t[0],height:t[1]}},i,a.createElement(Nn,Y({},this.props.graph,{setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this.props.model&&this.renderPlot(),this.props.model&&this.renderAsymptote(),this.props.model&&e)))}}j(Dd,"defaultProps",{graph:{range:[[-10,10],[-10,10]],step:[1,1]},coords:null,asymptote:null,isMobile:!1});class Ld extends a.Component{constructor(){super(...arguments),j(this,"horizHairline",void 0),j(this,"vertHairline",void 0),j(this,"handlePlotChanges",(e=>{var t=h.extend({},this.props.plot,e);this.props.onChange({plot:t}),this.props.trackInteraction()})),j(this,"handleActiveTypeChange",(e=>{var t=this.props.graph,r=h.extend({},this.props.plot,Sd(e,t));this.props.onChange({plot:r})})),j(this,"_setupGraphie",((e,t)=>{var r=this.props.apiOptions.isMobile;if("graph"===t.markings?(e.graphInit({range:t.range,scale:h.pluck(t.gridConfig,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,snapStep:t.snapStep,tickStep:r?this._calculateMobileTickStep(t.gridStep,t.step,t.range):h.pluck(t.gridConfig,"tickStep"),labelStep:1,unityLabels:h.pluck(t.gridConfig,"unityLabel"),isMobile:r}),e.label([0,t.range[1][1]],t.labels[1],r?"below right":"above"),e.label([t.range[0][1],0],t.labels[0],r?"above left":"right")):"grid"===t.markings?e.graphInit({range:t.range,scale:h.pluck(t.gridConfig,"scale"),gridStep:t.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:r}):"none"===t.markings&&e.init({range:t.range,scale:h.pluck(t.gridConfig,"scale")}),this.props.apiOptions.isMobile){var i={normalStyle:{strokeWidth:1}};this.horizHairline=new Nr(e,[0,0],[0,0],i),this.horizHairline.attr({stroke:mr.INTERACTIVE}),this.horizHairline.hide(),this.vertHairline=new Nr(e,[0,0],[0,0],i),this.vertHairline.attr({stroke:mr.INTERACTIVE}),this.vertHairline.hide()}})),j(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.props.graph.range[0][0],e[1]],[this.props.graph.range[0][1],e[1]]),this.horizHairline.show(),this.vertHairline.moveTo([e[0],this.props.graph.range[1][0]],[e[0],this.props.graph.range[1][1]]),this.vertHairline.show())})),j(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&(this.horizHairline.hide(),this.vertHairline.hide())}))}render(){var e=this.props.plot.type,t=this.props.plot.coords,r=this.props.plot.asymptote,i=a.createElement("div",{style:Od,className:"above-scratchpad"},a.createElement(sd,{value:e,allowEmpty:!0,buttons:h.map(this.props.availableTypes,Nd),onChange:this.handleActiveTypeChange})),n=lo(this.props.containerSizeClass),o=G(G(G({},this.props.graph),Md(this.props.graph,n[0])),{},{gridConfig:this._getGridConfig(G(G({},this.props.graph),{},{box:n},Md(this.props.graph,n[0])))}),s={graph:{box:n,range:o.range,step:o.step,snapStep:o.snapStep,backgroundImage:o.backgroundImage,options:o,setup:this._setupGraphie},onChange:this.handlePlotChanges,model:e&&wd(e),coords:t,asymptote:r,static:this.props.static,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile,showTooltips:this.props.graph.showTooltips,showHairlines:this.showHairlines,hideHairlines:this.hideHairlines};return a.createElement("div",null,a.createElement(Dd,s),this.props.availableTypes.length>1&&i)}_getGridConfig(e){return e.step.map(((t,r)=>De.gridDimensionConfig(t,e.range[r],e.box[r],e.gridStep[r])))}_calculateMobileTickStep(e,t,r){var i=De.constrainedTickStepsFromTickSteps(t,r);return i[0]=i[0]/e[0],i[1]=i[1]/e[1],i}simpleValidate(e){return Cd(this.getUserInput(),e)}getUserInput(){return Ld.getUserInputFromProps(this.props)}focus(){}static validate(e,t){return Cd(e,t)}static getUserInputFromProps(e){return e.plot}}j(Ld,"defaultProps",Pd);var Bd=e=>{var t={availableTypes:e.availableTypes,graph:e.graph};if(1===t.availableTypes.length){var r=t.graph,i=_d(t.availableTypes);t.plot=Sd(i,r)}return t},zd={name:"grapher",displayName:"Grapher",widget:Ld,transform:Bd,staticTransform:e=>G(G({},Bd(e)),{},{availableTypes:[e.correct.type],plot:e.correct})};class Hd extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"getUserInput",(()=>this.refs.renderer.getUserInput())),j(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),j(this,"restoreSerializedState",((e,t)=>(this.refs.renderer.restoreSerializedState(e,t),null))),j(this,"simpleValidate",(e=>this.refs.renderer.score())),j(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),j(this,"setInputValue",((e,t,r)=>this.refs.renderer.setInputValue(e,t,r))),j(this,"focus",(()=>this.refs.renderer.focus())),j(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),j(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)})),j(this,"showRationalesForCurrentlySelectedChoices",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices()}))}componentDidMount(){this.forceUpdate()}render(){var e=h.extend({},Zt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}}),t=h.indexOf(this.props.findWidgets("group"),this),r=this.props.apiOptions.groupAnnotator(t,this.props.widgetId),i=this.refs.renderer&&this.refs.renderer.score(),n=i&&"invalid"!==i.type,o=i&&"invalid"===i.type;return a.createElement("div",{className:s({"perseus-group":!0,"perseus-group-valid-answer":n,"perseus-group-invalid-answer":o})},r,a.createElement(Bo,Y({},this.props,{ref:"renderer",apiOptions:e,findExternalWidgets:this.props.findWidgets,reviewMode:!!this.props.reviewModeRubric,onInteractWithWidget:e=>{this.refs.renderer&&this.change("widgets",this.refs.renderer.props.widgets)},linterContext:this.props.linterContext})),this.props.icon&&a.createElement("div",{className:"group-icon"},this.props.icon))}}j(Hd,"defaultProps",{content:"",widgets:{},images:{},linterContext:Vt});var Wd={name:"group",displayName:"Group (SAT only)",widget:Hd,traverseChildWidgets:function(e,t){return h.extend({},e,t(e))},hidden:!1,isLintable:!0},{updateQueryString:qd}=De;class Ud extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"getUserInput",(()=>Ls.getUserInput.call(this))),j(this,"handleMessageEvent",(e=>{var t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(!h.isUndefined(t.testsPassed)){var r=t.testsPassed?"correct":"incorrect";this.change({status:r,message:t.message})}})),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"simpleValidate",(e=>Ud.validate(this.getUserInput(),e)))}componentDidMount(){y(window).on("message",this.handleMessageEvent)}componentWillUnmount(){y(window).off("message",this.handleMessageEvent)}render(){var e={width:String(this.props.width),height:String(this.props.height)},{InitialRequestUrl:t}=ae();Object.entries(e).forEach((t=>{var[r,i]=t;i.endsWith("%")||i.endsWith("px")||(e[r]=i+"px")}));var r=this.props.url;if(r&&r.length&&0!==r.indexOf("http")&&(r=qd(r="https://www.khanacademy.org/computer-programming/program/"+r+"/embedded?buttons=no&embed=yes&editor=no&author=no","width",this.props.width),r=qd(r,"height",this.props.height),r=qd(r,"origin",t.origin)),this.props.settings){var i={};h.each(this.props.settings,(function(e){e.name&&e.value&&(i[e.name]=e.value)})),r=qd(r,"settings",JSON.stringify(i))}return" allow-top-navigation",a.createElement("iframe",{sandbox:"allow-same-origin allow-scripts allow-top-navigation",style:e,src:r,allowFullScreen:this.props.allowFullScreen})}}j(Ud,"propTypes",G(G({},fs),{},{width:d.oneOfType([d.string,d.number]),height:d.oneOfType([d.string,d.number]),url:d.string,settings:d.array,status:d.oneOf(["incomplete","incorrect","correct"]),message:d.string,allowFullScreen:d.bool,allowTopNavigation:d.bool})),j(Ud,"defaultProps",{status:"incomplete",message:null,allowFullScreen:!1,allowTopNavigation:!1}),h.extend(Ud,{validate:function(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}});var Gd={name:"iframe",displayName:"Iframe",widget:Ud,hidden:!0},Vd=[0,10];class jd extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"getUserInput",(()=>null)),j(this,"simpleValidate",(e=>jd.validate(this.getUserInput(),e))),j(this,"focus",(()=>{}))}render(){var e,t,r,i,{apiOptions:n}=this.props,o=this.props.backgroundImage;if(o.url&&(e=a.createElement(Vn,{src:o.url,alt:this.props.alt,overrideAriaHidden:!0,width:o.width,height:o.height,preloader:n.imagePreloader,extraGraphie:{box:this.props.box,range:this.props.range,labels:this.props.labels},trackInteraction:this.props.trackInteraction,zoomToFullSizeOnMobile:n.isMobile,constrainHeight:n.isMobile,allowFullBleed:n.isMobile})),this.props.alt&&(t=a.createElement("span",{className:"perseus-sr-only"},a.createElement(Bo,{content:this.props.alt,apiOptions:n,linterContext:this.props.linterContext}))),n.isMobile){var l;if(this.props.title||this.props.caption){var p=this.props.title;p&&(this.props.caption&&!/[.?!"']\s*$/.test(p)&&(p+="."),p="**".concat(p,"** "));var h=s({"perseus-image-caption":!0,"has-title":!!p}),c=this.props.alignment,d="block"===c||"full-width"===c?null:"0 !important";l=a.createElement("div",{className:h},a.createElement("div",{className:g(Yd.caption),style:{minWidth:d}},a.createElement(Bo,{content:p+this.props.caption,apiOptions:n,linterContext:this.props.linterContext})))}return a.createElement("div",{className:"perseus-image-widget"},e,t,l)}return this.props.title&&(r=a.createElement("div",{className:"perseus-image-title"},a.createElement(Bo,{content:this.props.title,apiOptions:n,linterContext:this.props.linterContext}))),this.props.caption&&(i=a.createElement("div",{className:"perseus-image-caption"},a.createElement(Bo,{content:this.props.caption,apiOptions:n,linterContext:this.props.linterContext}))),a.createElement("div",{className:"perseus-image-widget"},r,e,t,i)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}j(jd,"defaultProps",{alignment:"block",title:"",range:[Vd,Vd],box:[400,400],backgroundImage:{url:null,width:0,height:0},labels:[],alt:"",caption:"",linterContext:Vt});var Yd=m.create({caption:{display:"inline-block",marginTop:16,maxWidth:640,[$s.lgOrSmaller]:{maxWidth:540},[$s.smOrSmaller]:{maxWidth:450}}}),$d={name:"image",accessible:e=>{var t=e.backgroundImage;return!(t&&t.url&&!e.alt)},defaultAlignment:"block",supportedAlignments:["block","full-width"],displayName:"Image",widget:jd,isLintable:!0},Xd=Nn.Label,Kd=Nn.Line,Zd=Nn.MovablePoint,Jd=Nn.MovableLine,Qd=Nn.Plot,eu=Nn.PlotParametric,tu=Nn.Point,ru=Nn.Rect,{unescapeMathMode:iu}=De,nu=(e,t)=>{for(var r=e+"||"+(t=t||{}).decimal_separator+"||",i=t.functions,n=i?i.length:0,o=0;o<n;o++)r+=i[o]+"|";return r},ou=Object.create(null),su=(t,r)=>{var i=nu(t,r),n=ou[i];return n||(n=e.parse(t,r),ou[i]=n,n)},au=Object.create(null),lu=(t,r)=>{var i=nu(t,r),n=au[i];if(n)return n;var o=e.parse(t,r).expr;return n=o?o.compile():function(){return 0},au[i]=n,n};class pu extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"state",{variables:hu(this.props.elements),functions:cu(this.props.elements)}),j(this,"_setupGraphie",((e,t)=>{e.graphInit(h.extend({},t,{grid:h.contains(["graph","grid"],this.props.graph.markings),axes:h.contains(["graph"],this.props.graph.markings),ticks:h.contains(["graph"],this.props.graph.markings),labels:h.contains(["graph"],this.props.graph.markings),labelFormat:function(e){return"\\small{"+e+"}"},axisArrows:"<->",unityLabels:!1}))})),j(this,"_updatePointLocation",((e,t)=>{var r=h.clone(this.state.variables);r["x_"+e]=t[0],r["y_"+e]=t[1],this.setState({variables:r}),this.props.trackInteraction()})),j(this,"_updateLineLocation",((e,t)=>{var r=this._eval("("+e.endX+")-("+e.startX+")"),i=this._eval("("+e.endY+")-("+e.startY+")"),n=w.add(t,[r,i]),o=h.clone(this.state.variables);o["x_"+e.startSubscript]=t[0],o["y_"+e.startSubscript]=t[1],o["x_"+e.endSubscript]=n[0],o["y_"+e.endSubscript]=n[1],this.setState({variables:o}),this.props.trackInteraction()})),j(this,"_eval",((e,t)=>{var r=lu(e,{functions:this.state.functions}),i=h.extend({},this.state.variables,t);return h.each(h.keys(i),(e=>{if(h.isString(i[e])){var t=lu(i[e],{functions:this.state.functions});i[e]=function(e){return t(h.extend({},i,{x:e}))}}})),r(i)||0})),j(this,"_extractVars",(e=>{if(null==e)return[];var t=[];return h.each(e.args(),(function(e){e&&"Expr"===e.constructor.name&&(t=t.concat(this._extractVars(e)))}),this),"Var"===e.name()&&t.push(e.prettyPrint()),t})),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"getUserInput",(()=>({}))),j(this,"simpleValidate",(e=>pu.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){h.isEqual(this.props.elements,e.elements)||this.setState({variables:hu(e.elements),functions:cu(e.elements)})}render(){var e=this.props.graph.range,t=this.props.graph.labels;return"graph"===this.props.graph.markings&&(t=this.props.graph.labels.map((e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e))),a.createElement(Nn,{box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable},"graph"===this.props.graph.markings&&a.createElement(Xd,{coord:[0,e[1][1]],text:t[1],direction:"above"}),"graph"===this.props.graph.markings&&a.createElement(Xd,{coord:[e[0][1],0],text:t[0],direction:"right"}),h.map(this.props.elements,(function(e,t){if("point"===e.type)return a.createElement(tu,{key:e.key,coord:[this._eval(e.options.coordX),this._eval(e.options.coordY)],color:e.options.color});if("line"===e.type){var r=[this._eval(e.options.startX),this._eval(e.options.startY)],i=[this._eval(e.options.endX),this._eval(e.options.endY)];return a.createElement(Kd,{key:e.key,start:r,end:i,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,arrows:e.options.arrows}})}if("movable-point"===e.type){var n=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];return"snap"===e.options.constraint?n.push(Zd.constraints.snap(e.options.snap)):"x"===e.options.constraint?n.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&n.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})])),a.createElement(Zd,{key:e.key,coord:[this.state.variables["x_"+e.options.varSubscript],this.state.variables["y_"+e.options.varSubscript]],constraints:n,foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap,onMove:h.partial(this._updatePointLocation,e.options.varSubscript)})}if("movable-line"===e.type){var o=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];"snap"===e.options.constraint?o.push(Zd.constraints.snap(e.options.snap)):"x"===e.options.constraint?o.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&o.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})]));var s=[this.state.variables["x_"+e.options.startSubscript],this.state.variables["y_"+e.options.startSubscript]],l=[this.state.variables["x_"+e.options.endSubscript],this.state.variables["y_"+e.options.endSubscript]];return a.createElement(Jd,{key:e.key,constraints:o,onMove:h.bind(this._updateLineLocation,this,e.options),foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap},a.createElement(Zd,{coord:s,static:!0,normalStyle:{stroke:"none",fill:"none"}}),a.createElement(Zd,{coord:l,static:!0,normalStyle:{stroke:"none",fill:"none"}}))}if("function"===e.type){var p=h.without(this._extractVars(su(e.options.value).expr),"x"),c=h.object(p,h.map(p,(e=>this.state.variables[e]))),d=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return a.createElement(Qd,{key:e.key,fn:t=>this._eval(e.options.value,{x:t}),foo_fn:e.options.value,foo_varvalues:c,range:d,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("parametric"===e.type){var u=h.without(this._extractVars(su(e.options.x).expr).concat(this._extractVars(su(e.options.y).expr)),"t"),m=h.object(u,h.map(u,(e=>this.state.variables[e]))),g=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return a.createElement(eu,{key:e.key,fn:t=>[this._eval(e.options.x,{t:t}),this._eval(e.options.y,{t:t})],foo_fnx:e.options.x,foo_fny:e.options.y,foo_varvalues:m,range:g,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("label"===e.type){var f=[this._eval(e.options.coordX),this._eval(e.options.coordY)];return a.createElement(Xd,{key:t+1,coord:f,text:iu(e.options.label),style:{color:e.options.color}})}return"rectangle"===e.type?a.createElement(ru,{key:t+1,x:this._eval(e.options.coordX),y:this._eval(e.options.coordY),width:h.max([this._eval(e.options.width),0]),height:h.max([this._eval(e.options.height),0]),style:{stroke:"none",fill:e.options.color}}):void 0}),this))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}j(pu,"defaultProps",{graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]});var hu=e=>{var t={};return h.each(h.where(e,{type:"movable-point"}),(e=>{var r=e.options.varSubscript,i=su(e.options.startX||"0").expr,n=su(e.options.startY||"0").expr,o=0,s=0;i&&(o=i.eval({})||0),n&&(s=n.eval({})||0),t["x_"+r]=o,t["y_"+r]=s})),h.each(h.where(e,{type:"movable-line"}),(e=>{var r=e.options.startSubscript,i=e.options.endSubscript,n=su(e.options.startX||"0").expr,o=su(e.options.startY||"0").expr,s=su(e.options.endX||"0").expr,a=su(e.options.endY||"0").expr,l=0,p=0,h=0,c=0;n&&(l=n.eval({})||0),o&&(p=o.eval({})||0),s&&(h=s.eval({})||0),a&&(c=a.eval({})||0),t["x_"+r]=l,t["y_"+r]=p,t["x_"+i]=h,t["y_"+i]=c})),h.each(h.where(e,{type:"function"}),(e=>{t[e.options.funcName]=e.options.value})),t},cu=e=>h.map(h.where(e,{type:"function"}),(e=>e.options.funcName)),du={name:"interaction",displayName:"Interaction",widget:pu,transform:h.identity,hidden:!0},uu=/^\s+|\s+$/g,mu=/^[-+]0x[0-9a-f]+$/i,gu=/^0b[01]+$/i,fu=/^0o[0-7]+$/i,vu=parseInt,yu="object"==typeof cr&&cr&&cr.Object===Object&&cr,bu="object"==typeof self&&self&&self.Object===Object&&self,xu=yu||bu||Function("return this")(),wu=Object.prototype.toString,Cu=Math.max,ku=Math.min,Eu=function(){return xu.Date.now()};function Su(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function _u(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==wu.call(e)}(e))return NaN;if(Su(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Su(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(uu,"");var r=gu.test(e);return r||fu.test(e)?vu(e.slice(2),r?2:8):mu.test(e)?NaN:+e}var Mu=function(e,t,r){var i,n,o,s,a,l,p=0,h=!1,c=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function u(t){var r=i,o=n;return i=n=void 0,p=t,s=e.apply(o,r)}function m(e){return p=e,a=setTimeout(f,t),h?u(e):s}function g(e){var r=e-l;return void 0===l||r>=t||r<0||c&&e-p>=o}function f(){var e=Eu();if(g(e))return v(e);a=setTimeout(f,function(e){var r=t-(e-l);return c?ku(r,o-(e-p)):r}(e))}function v(e){return a=void 0,d&&i?u(e):(i=n=void 0,s)}function y(){var e=Eu(),r=g(e);if(i=arguments,n=this,l=e,r){if(void 0===a)return m(l);if(c)return a=setTimeout(f,t),u(l)}return void 0===a&&(a=setTimeout(f,t)),s}return t=_u(t)||0,Su(r)&&(h=!!r.leading,o=(c="maxWait"in r)?Cu(_u(r.maxWait)||0,t):o,d="trailing"in r?!!r.trailing:d),y.cancel=function(){void 0!==a&&clearTimeout(a),p=0,i=l=n=a=void 0},y.flush=function(){return void 0===a?s:v(Eu())},y},Tu={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"},Iu={position:"relative",top:"25%"};class Pu extends a.Component{constructor(){super(...arguments),j(this,"protractor",void 0),j(this,"ruler",void 0),j(this,"_graphie",void 0),j(this,"_hasSetupGraphieThisUpdate",void 0),j(this,"_shouldSetupGraphie",void 0),j(this,"reset",(()=>{this._setupGraphie(!1)})),j(this,"graphie",(()=>this._graphie)),j(this,"pointsFromNormalized",((e,t)=>{var r=this;return h.map(e,(function(e){return h.map(e,(function(e,i){var n=r.props.range[i];if(t)return n[0]+(n[1]-n[0])*e;var o=r.props.step[i],s=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,o),a=Math.round(e*s);return n[0]+o*a}))}))})),j(this,"_setupGraphie",(e=>{if(!this._hasSetupGraphieThisUpdate){var t=v.findDOMNode(this.refs.graphieDiv);y(t).empty();var r=this.props.labels.map((e=>De.unescapeMathMode(e))),i=this.props.range,n=this._graphie=Cr.createGraphie(t),o=this._getGridConfig();n.snap=this.props.snapStep,"graph"===this.props.markings?(n.graphInit({range:i,scale:h.pluck(o,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:this.props.gridStep,tickStep:h.pluck(o,"tickStep"),labelStep:1,unityLabels:h.pluck(o,"unityLabel"),isMobile:this.props.isMobile}),n.label([0,i[1][1]],r[1],this.props.isMobile?"below right":"above"),n.label([i[0][1],0],r[0],this.props.isMobile?"above left":"right")):"grid"===this.props.markings?n.graphInit({range:i,scale:h.pluck(o,"scale"),gridStep:this.props.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:this.props.isMobile}):"none"===this.props.markings&&n.init({range:i,scale:h.pluck(o,"scale"),isMobile:this.props.isMobile});var s;if(this.props.instructions){s=y("<div/>"),h.each(Tu,(function(e,t){s.css(t,e)})),s.css("opacity",.5);var a=y("<span/>",{text:this.props.instructions});h.each(Iu,(function(e,t){a.css(t,e)})),s.append(a),y(t).append(s)}else s=void 0;var l=s||this.props.onMouseDown?h.bind((function(e){s&&(s.remove(),s=null),this.props.onMouseDown(e)}),this):null,p=s?function(){s&&s.css("opacity",0)}:null,c=s?function(){s&&s.css("opacity",.5)}:null;n.addMouseLayer({onClick:this.props.onClick,onMouseDown:l,onMouseOver:p,onMouseOut:c,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,allowScratchpad:!0,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this._updateProtractor(),this._updateRuler(),this._hasSetupGraphieThisUpdate=!0,!e&&this.props.onGraphieUpdated&&this.props.onGraphieUpdated(n)}})),j(this,"_getGridConfig",(()=>{var e=this;return h.map(e.props.step,(function(t,r){return De.gridDimensionConfig(t,e.props.range[r],e.props.box[r],e.props.gridStep[r])}))})),j(this,"_updateProtractor",(()=>{if(this.protractor&&this.protractor.remove(),this.props.showProtractor){var e=this.pointsFromNormalized([[.5,.05]])[0];this.protractor=this._graphie.protractor(e)}})),j(this,"_updateRuler",(()=>{if(this.ruler&&this.ruler.remove(),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)})}})),j(this,"toJSON",(()=>h.pick(this.props,"range","step","markings","labels","backgroundImage","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep")))}render(){var e,t=this.props.backgroundImage;if(t.url){var r=this.props.box[0]/te.defaultBoxSize;e=a.createElement(Vn,{src:t.url,width:t.width,height:t.height,scale:r,responsive:!1})}else e=null;return a.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,a.createElement("div",{className:"graphie",ref:"graphieDiv"}))}componentDidMount(){this._setupGraphie(!0)}componentDidUpdate(){this._hasSetupGraphieThisUpdate=!1,this._shouldSetupGraphie&&(this._setupGraphie(!1),this._shouldSetupGraphie=!1)}UNSAFE_componentWillReceiveProps(e){var t=this;h.each(["labels","range","step","markings","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep"],(function(r){h.isEqual(t.props[r],e[r])||(t._shouldSetupGraphie=!0)}))}}j(Pu,"propTypes",{box:d.array.isRequired,labels:d.arrayOf(d.string),range:d.arrayOf(d.arrayOf(d.number)),step:d.arrayOf(d.number),gridStep:d.arrayOf(d.number),snapStep:d.arrayOf(d.number),markings:d.string,backgroundImage:d.shape({url:d.string}),showProtractor:d.bool,showRuler:d.bool,rulerLabel:d.string,rulerTicks:d.number,onGraphieUpdated:d.func,instructions:d.string,onClick:d.func,setDrawingAreaAvailable:d.func,isMobile:d.bool}),j(Pu,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[.5,.5],markings:"graph",backgroundImage:{url:null},showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,instructions:null,onGraphieUpdated:null,onClick:null,onMouseDown:null,isMobile:!1});var{DeprecationMixin:Nu}=De,Au=De.eq,Ru=De.deepEq;function Fu(e,t,r){return(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1])}function Ou(e,t,r){return Au(Fu(e,t,r),0)}function Du(e){return Au(e,0)?0:e>0?1:-1}function Lu(e,t,r){return r[0]<=Math.max(e[0],t[0])&&r[0]>=Math.min(e[0],t[0])&&r[1]<=Math.max(e[1],t[1])&&r[1]>=Math.min(e[1],t[1])}function Bu(e,t){var r=[[e[0],e[1],t[0]],[e[0],e[1],t[1]],[t[0],t[1],e[0]],[t[0],t[1],e[1]]],i=h.map(r,(function(e){return Du(Fu(...e))}));if(i[0]!==i[1]&&i[2]!==i[3])return!0;for(var n=0;n<4;n++)if(0===i[n]&&Lu(...r[n]))return!0;return!1}function zu(e,t){return h.map(h.zip(e,t),(function(e){return e[0]-e[1]}))}function Hu(e){return Math.sqrt(h.reduce(e,(function(e,t){return e+Math.pow(t,2)}),0))}function Wu(e){return h.zip(e,ju(e)).map((function(e){return Hu(zu(...e))}))}function qu(e){var t=h.zip(ju(e,-1),e,ju(e,1)),r=h.map(t,(function(e){var t,r,i=zu(e[1],e[0]),n=zu(e[2],e[1]),o=Math.acos((t=i,r=n,h.reduce(h.zip(t,r),(function(e,t){return e+t[0]*t[1]}),0)/(Hu(i)*Hu(n))));return Du(Fu(...e))>0?o:-o})),i=h.reduce(r,(function(e,t){return e+t}),0);return h.map(r,(function(e){return i>0?Math.PI-e:Math.PI+e}))}function Uu(e,t,r){if(e.length!==t.length)return!1;for(var i=e.length,n=qu(e),o=qu(t),s=Wu(e),a=Wu(t),l=0;l<2*i;l++){var p=o.slice(),c=a.slice();if(l>=i&&(p.reverse(),c.reverse(),c=ju(c,1)),p=ju(p,l),c=ju(c,l),Ru(n,p)){var d=function(){var e=h.zip(s,c),t=h.map(e,(function(e){return e[0]/e[1]})),i=h.all(t,(function(e){return Au(t[0],e)})),n=h.all(e,(function(e){return b.equal(e[0],e[1],r)}));if(i&&n)return{v:!0}}();if("object"==typeof d)return d.v}}return!1}function Gu(e,t){return e<t||Au(e,t)}function Vu(e){var[t,r,i,n]=e;t<0&&(t*=-1,r*=-1,i*=-1);var o=2*Math.PI;for(r<0&&(r*=-1,i*=-1,i+=o/2);i>0;)i-=o;for(;i<0;)i+=o;return[t,r,i,n]}function ju(e,t){return t=void 0===t?1:t%e.length,e.slice(t).concat(e.slice(0,t))}function Yu(e){return e.replace(/(?:^|-)(.)/g,(function(e,t){return t.toUpperCase()}))}function $u(e,t){if(Au(e[0],t[0]))return"x = "+e[0].toFixed(3);var r=(t[1]-e[1])/(t[0]-e[0]),i=e[1]-r*e[0];return"y = "+r.toFixed(3)+"x + "+i.toFixed(3)}var Xu={showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},Ku=e=>Zu(e)&&(null==e.graph.coords||0===e.graph.coords.length),Zu=e=>"point"===e.graph.type&&"unlimited"===e.graph.numPoints||"polygon"===e.graph.type&&"unlimited"===e.graph.numSides,Ju=(e,t)=>new ce("".concat(e," called but current graph type is not a '").concat(t,"'"),pe.NotAllowed,{metadata:{graphType:t}});class Qu extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"angle",void 0),j(this,"circle",void 0),j(this,"graphie",void 0),j(this,"horizHairline",void 0),j(this,"line",void 0),j(this,"lines",void 0),j(this,"parabola",void 0),j(this,"pointA",void 0),j(this,"pointB",void 0),j(this,"pointC",void 0),j(this,"points",void 0),j(this,"polygon",void 0),j(this,"shouldResetGraphie",void 0),j(this,"sinusoid",void 0),j(this,"trashCan",void 0),j(this,"vertHairline",void 0),j(this,"state",{shouldShowInstructions:Ku(this.props)}),j(this,"_getShouldShowInstructions",(e=>(e=e||this.props,this.isClickToAddPoints(e)&&(null==e.graph.coords||0===e.graph.coords.length)))),j(this,"deprecatedProps",Xu),j(this,"setGraphie",(e=>{this.graphie=e,this.setupGraphie()})),j(this,"handleAddPointsMouseDown",(e=>{if(!this.isClickToAddPoints())throw new ce("handleAddPointsClick should not be registeredwhen isClickToAddPoints() is false",pe.NotAllowed);if(!this.isCoordInTrash(e)){var t;if("point"===this.props.graph.type){if(!(t=this.createPointForPointsType(e,this.points.length)).constrain())return void t.remove();this.points.push(t);var r=this.points.length-1;this.points[r].grab(e),this.updateCoordsFromPoints()}else if("polygon"===this.props.graph.type){var i;if(null!==(i=this.polygon)&&void 0!==i&&i.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})}})),j(this,"resetGraphie",(()=>{this.shouldResetGraphie=!1,this.parabola=null,this.sinusoid=null,this.refs.graph.reset()})),j(this,"setupGraphie",(()=>{var e,t;(this.setTrashCanVisibility(0),this.isClickToAddPoints()&&this.setTrashCanVisibility(.5),this.props.apiOptions.isMobile)&&(this.horizHairline=new Nr(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:mr.INTERACTIVE}),null===(e=this.horizHairline)||void 0===e||e.hide(),this.vertHairline=new Nr(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.vertHairline.attr({stroke:mr.INTERACTIVE}),null===(t=this.vertHairline)||void 0===t||t.hide());this["add"+Yu(this.props.graph.type)+"Controls"]()})),j(this,"showHairlines",(e=>{var t,r,i,n;this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(null===(t=this.horizHairline)||void 0===t||t.moveTo([this.props.range[0][0],e[1]],[this.props.range[0][1],e[1]]),null===(r=this.horizHairline)||void 0===r||r.show(),null===(i=this.vertHairline)||void 0===i||i.moveTo([e[0],this.props.range[1][0]],[e[0],this.props.range[1][1]]),null===(n=this.vertHairline)||void 0===n||n.show())})),j(this,"hideHairlines",(()=>{var e,t;this.props.apiOptions.isMobile&&(null===(e=this.horizHairline)||void 0===e||e.hide(),null===(t=this.vertHairline)||void 0===t||t.hide())})),j(this,"setTrashCanVisibility",(e=>{var t=this.graphie;if(b.equal(e,0))this.trashCan&&(this.trashCan.remove(),this.trashCan=null);else if(!this.props.apiOptions.isMobile){var r,i;if(!this.trashCan)this.trashCan=null==t||null===(i=t.raphael)||void 0===i?void 0:i.image("https://ka-perseus-graphie.s3.amazonaws.com/b1452c0d79fd0f7ff4c3af9488474a0a0decb361.png",t.xpixels-40,t.ypixels-40,40,40);null===(r=this.trashCan)||void 0===r||r.attr({opacity:e})}})),j(this,"isClickToAddPoints",(e=>(e=e||this.props,Zu(e)))),j(this,"_lineStroke",(()=>this.props.isMobile?{"stroke-width":3}:{})),j(this,"addLine",(e=>{var t=this,r=t.graphie,i=Qu.getLineCoords(t.props.graph,t.props),n=t.points=h.map(i,(e=>mn.addMaybeMobileMovablePoint(this,{coord:e,constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap()],onMove:()=>{var e=h.extend({},t.props.graph,{coords:h.invoke(n,"coord")});t.onChange({graph:e})}}))),o={points:n,static:!0,normalStyle:G({stroke:this.props.apiOptions.isMobile?mr.BLUE_C:mr.INTERACTIVE},this._lineStroke())};"line"===e?o.extendLine=!0:"ray"===e&&(o.extendRay=!0),t.line=mn.addMovableLine(r,o),n[0].listen("constraints","isLine",(e=>!x.equal(e,n[1].coord()))),n[1].listen("constraints","isLine",(e=>!x.equal(e,n[0].coord())))})),j(this,"removeLine",(()=>{var e;h.invoke(this.points,"remove"),null===(e=this.line)||void 0===e||e.remove()})),j(this,"addLinearControls",(()=>{this.addLine("line")})),j(this,"removeLinearControls",(()=>{this.removeLine()})),j(this,"addQuadraticControls",(()=>{if("quadratic"!==this.props.graph.type)throw Ju("addQuadraticControls","quadratic");var e=this.props.graph.coords;e||(e=Qu.defaultQuadraticCoords(this.props));var t=()=>{var e=h.extend({},this.props.graph,{coords:[r.coord(),i.coord(),n.coord()]});this.onChange({graph:e}),this.updateQuadratic()},r=null;r=this.pointA=mn.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),e=>!r||e[0]!==i.coord()[0]&&e[0]!==n.coord()[0]],onMove:t});var i=null;i=this.pointB=mn.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),e=>!i||e[0]!==r.coord()[0]&&e[0]!==n.coord()[0]],onMove:t});var n=null;n=this.pointC=mn.addMaybeMobileMovablePoint(this,{coord:e[2],constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),e=>!n||e[0]!==r.coord()[0]&&e[0]!==i.coord()[0]],onMove:t}),this.updateQuadratic()})),j(this,"updateQuadratic",(()=>{var e=Qu.getCurrentQuadraticCoefficients(this.props);if(e){var t=e[0],r=e[1],i=e[2];if(this.parabola){var n,o,s=null===(n=this.graphie)||void 0===n?void 0:n.svgParabolaPath(t,r,i);null===(o=this.parabola)||void 0===o||o.attr({path:s})}else{var a,l,p;this.parabola=null===(a=this.graphie)||void 0===a?void 0:a.parabola(t,r,i),null===(l=this.parabola)||void 0===l||l.attr(G({stroke:this.props.apiOptions.isMobile?mr.BLUE_C:mr.DYNAMIC},this._lineStroke())),null===(p=this.parabola)||void 0===p||p.toBack()}}})),j(this,"removeQuadraticControls",(()=>{var e,t,r;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),null===(r=this.pointC)||void 0===r||r.remove(),this.parabola&&(this.parabola.remove(),this.parabola=null)})),j(this,"addSinusoidControls",(()=>{if("sinusoid"!==this.props.graph.type)throw Ju("addSinusoidControls","sinusoid");var e=this.props.graph.coords;e||(e=Qu.defaultSinusoidCoords(this.props));var t=()=>{var e=h.extend({},this.props.graph,{coords:[r.coord(),i.coord()]});this.onChange({graph:e}),this.updateSinusoid()},r=null;r=this.pointA=mn.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),e=>!r||e[0]!==i.coord()[0]],onMove:t});var i=this.pointB=mn.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),e=>!r||e[0]!==r.coord()[0]],onMove:t});this.updateSinusoid()})),j(this,"updateSinusoid",(()=>{var e=Qu.getCurrentSinusoidCoefficients(this.props);if(e){var t=e[0],r=e[1],i=e[2],n=e[3];if(this.sinusoid){var o,s,a=null===(o=this.graphie)||void 0===o?void 0:o.svgSinusoidPath(t,r,i,n);null===(s=this.sinusoid)||void 0===s||s.attr({path:a})}else{var l,p,h;this.sinusoid=null===(l=this.graphie)||void 0===l?void 0:l.sinusoid(t,r,i,n),null===(p=this.sinusoid)||void 0===p||p.attr(G({stroke:this.props.apiOptions.isMobile?mr.BLUE_C:mr.DYNAMIC},this._lineStroke())),null===(h=this.sinusoid)||void 0===h||h.toBack()}}})),j(this,"removeSinusoidControls",(()=>{var e,t;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),this.sinusoid&&(this.sinusoid.remove(),this.sinusoid=null)})),j(this,"addCircleControls",(()=>{var e=this.graphie,t=h.min(e.snap),r=this.circle=null==e?void 0:e.addCircleGraph({center:this.props.graph.center||[0,0],radius:this.props.graph.radius||h.min(this.props.step),snapX:e.snap[0],snapY:e.snap[1],minRadius:t,snapRadius:t});y(r).on("move",(()=>{var e=h.extend({},this.props.graph,{center:r.center,radius:r.radius});this.onChange({graph:e})}))})),j(this,"removeCircleControls",(()=>{var e;null===(e=this.circle)||void 0===e||e.remove()})),j(this,"addLinearSystemControls",(()=>{var t=this.graphie,r=Qu.getLinearSystemCoords(this.props.graph,this.props),i=[mr.INTERACTIVE,mr.GREEN],n=this.points=h.map(r,((t,r)=>{for(var n=[],o=function(o){var s=t[o];n.push(mn.addMaybeMobileMovablePoint(e,{coord:s,constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),e=>{var t=n[1-o];if(t)return!x.equal(e,t.coord())}],onMove:()=>{var t=h.extend({},e.props.graph,{coords:h.map(e.points,(e=>h.invoke(e,"coord")))});e.onChange({graph:t})},normalStyle:{fill:i[r]},highlightStyle:{fill:i[r]}}))},s=0;s<t.length;s+=1)o(s);return n}));this.lines=h.map(n,((e,r)=>mn.addMovableLine(t,{points:e,static:!0,extendLine:!0,normalStyle:{stroke:i[r]}})))})),j(this,"removeLinearSystemControls",(()=>{h.invoke(this.lines,"remove"),h.map(this.points,(e=>h.invoke(e,"remove")))})),j(this,"isCoordInTrash",(e=>{if(this.props.apiOptions.isMobile)return!1;var t=this.graphie,r=null==t?void 0:t.scalePoint(e);return r[0]>=t.xpixels-40&&r[1]>=t.ypixels-40})),j(this,"createPointForPointsType",((e,t)=>{var r=this,i=()=>{r.points=h.filter(r.points,(function(e){return e!==n})),r.updateCoordsFromPoints(),setTimeout(n.remove.bind(n),0)},n=null;return n=mn.addMaybeMobileMovablePoint(this,G({coord:e,constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),function(e){return h.all(r.points,(function(t){return n===t||!x.equal(e,t.coord())}))}],onMoveStart:function(){r.isClickToAddPoints()&&r.setTrashCanVisibility(1)},onMove:r.updateCoordsFromPoints,onMoveEnd:function(e){r.isClickToAddPoints()&&(r.isCoordInTrash(e)&&i(),r.setTrashCanVisibility(.5))}},this.props.apiOptions.isMobile&&r.isClickToAddPoints()?{onRemove:i}:{})),n})),j(this,"removePoint",(e=>{var t=null;return this.points=h.filter(this.points,(function(r,i){return r!==e||(t=i,!1)})),t})),j(this,"createPointForPolygonType",((e,t)=>{if("polygon"!==this.props.graph.type)throw Ju("createPointForPolygonType","polygon");var r=!h.contains(["angles","sides"],this.props.graph.snapTo),i=e=>(t+e+this.points.length)%this.points.length,n=()=>{var e,t,r=this.removePoint(s);null!==(e=this.polygon)&&void 0!==e&&e.closed()&&(this.points=ju(this.points,r),null===(t=this.polygon)||void 0===t||t.update({closed:!1}));this.updatePolygon(),this.clearCoords(),setTimeout(s.remove.bind(s),0)},o=Mu(((e,t)=>{e.state.isInitialMove=t}),1e3),s=mn.addMaybeMobileMovablePoint(this,G({coord:e,constraints:[mn.MovablePoint.constraints.bound(),r?mn.MovablePoint.constraints.snap():null,e=>{if(null==this.points||0===this.points.length)return!0;var r,n,o,s=h.invoke(this.points,"coord");if(s[t]=e,!this.isClickToAddPoints()){if(Ou(s[i(-2)],s[i(-1)],s[t])||Ou(s[i(-1)],s[t],s[i(1)])||Ou(s[t],s[i(1)],s[i(2)]))return!1;var a=h.zip(s,ju(s));if(this.points.length>3)for(var l=-1;l<=0;l++)for(var p=a[i(l)],c=h.without(a,p,a[i(l-1)],a[i(l+1)]),d=0;d<c.length;d++){if(Bu(p,c[d]))return!1}}if("angles"===this.props.graph.snapTo&&this.points.length>2){var u,m,g=h.map(qu(s),(function(e){return 180*e/Math.PI}));h.each([-1,1],(function(e){g[i(e)]=Math.round(g[i(e)])}));var f=function(e,t,r){return(Cr.findAngle(s[i(e)],s[i(r)],s[i(t)])+360)%360},v=[g[i(-1)]-f(-2,-1,1),g[i(1)]-f(-1,1,2)];if(v[2]=180-(v[0]+v[1]),h.any(v,(function(e){return Gu(e,1)})))return!1;var y=Hu(zu(s[i(-1)],s[i(1)])),b=1===Du(Fu(s[i(-1)],s[i(1)],s[t])),x=Math.sin(v[1]*Math.PI/180)/Math.sin(v[2]*Math.PI/180)*y,w=Cr.findAngle(s[i(1)],s[i(-1)]),C=null===(u=this.graphie)||void 0===u?void 0:u.polar(x,w+(b?1:-1)*v[0]);return null===(m=this.graphie)||void 0===m?void 0:m.addPoints(s[i(-1)],C)}if("sides"===this.props.graph.snapTo&&this.points.length>1){var k,E,S=h.map([[s[i(-1)],s[t]],[s[t],s[i(1)]],[s[i(-1)],s[i(1)]]],(function(e){return Hu(zu(...e))}));if(h.each([0,1],(function(e){S[e]=Math.round(S[e])})),Gu(S[1]+S[2],S[0])||Gu(S[0]+S[2],S[1])||Gu(S[0]+S[1],S[2]))return!1;var _=(r=S[0],n=S[2],o=S[1],180*Math.acos((r*r+n*n-o*o)/(2*r*n))/Math.PI),M=Cr.findAngle(s[i(1)],s[i(-1)]),T=1===Du(Fu(s[i(-1)],s[i(1)],s[t])),I=null===(k=this.graphie)||void 0===k?void 0:k.polar(S[0],M+(T?1:-1)*_);return null===(E=this.graphie)||void 0===E?void 0:E.addPoints(s[i(-1)],I)}return!0}],onMoveStart:()=>{this.isClickToAddPoints()&&this.setTrashCanVisibility(1)},onMove:()=>{var e;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&this.updateCoordsFromPoints()},onMoveEnd:e=>{var t=this.points.length>1&&(s===this.points[0]&&x.equal(e,h.last(this.points).coord())||s===h.last(this.points)&&x.equal(e,this.points[0].coord()));if(this.isClickToAddPoints()){if(this.isCoordInTrash(e))n();else if(t){var r,i,a=this.points.pop();if(this.points.length>2)null===(r=this.polygon)||void 0===r||r.update({closed:!0}),this.updateCoordsFromPoints();else null===(i=this.polygon)||void 0===i||i.update({closed:!1}),this.clearCoords();this.updatePolygon(),setTimeout(a.remove.bind(a),0)}else{if(h.any(this.points,(function(t){return t!==s&&x.equal(t.coord(),e)}))){var l,p;if(this.removePoint(s),this.points.length<3)null===(p=this.polygon)||void 0===p||p.update({closed:!1}),this.clearCoords();else null!==(l=this.polygon)&&void 0!==l&&l.closed()&&this.updateCoordsFromPoints();this.updatePolygon(),setTimeout(s.remove.bind(s),0)}else{var c,d,u=s===h.head(this.points)||s===h.last(this.points),m=!s.hasMoved(),g=!s.state.isInitialMove,f=!(null!==(c=this.polygon)&&void 0!==c&&c.closed()),v=this.points.length>2;if(u&&m&&g&&f&&v)null===(d=this.polygon)||void 0===d||d.update({closed:!0}),this.updatePolygon(),this.updateCoordsFromPoints()}}this.setTrashCanVisibility(.5)}o(s,!1)}},this.props.apiOptions.isMobile&&this.isClickToAddPoints()?{onRemove:n}:{}));return s.state.isInitialMove=!0,s})),j(this,"updateCoordsFromPoints",(()=>{var e=h.extend({},this.props.graph,{coords:h.map(this.points,(function(e){return h.result(e,"coord")}))});this.onChange({graph:e})})),j(this,"clearCoords",(()=>{var e=h.extend({},this.props.graph,{coords:null});this.onChange({graph:e})})),j(this,"onChange",(e=>{this.props.onChange(e),this.props.trackInteraction()})),j(this,"addPointControls",(()=>{if("point"!==this.props.graph.type)throw Ju("addPointControls","point");var e=Qu.getPointCoords(this.props.graph,this.props);this.points=[],this.points=h.map(e,this.createPointForPointsType,this)})),j(this,"removePointControls",(()=>{h.invoke(this.points,"remove")})),j(this,"addSegmentControls",(()=>{if("segment"!==this.props.graph.type)throw Ju("addSegmentControls","segment");var e=this,t=this.graphie,r=Qu.getSegmentCoords(this.props.graph,this.props),i=e=>mn.addMaybeMobileMovablePoint(this,e);this.points=[],this.lines=h.map(r,(function(r,n){for(var o=function(){var t=h.extend({},e.props.graph,{coords:h.invoke(e.lines,"coords")});e.onChange({graph:t})},s=[],a=function(e){var t=r[e];s.push(i({coord:t,constraints:[mn.MovablePoint.constraints.bound(),mn.MovablePoint.constraints.snap(),t=>{var r=s[1-e];return!!r&&!x.equal(t,r.coord())}],onMove:o}))},l=0;l<r.length;l+=1)a(l);e.points=e.points.concat(s);var p=mn.addMovableLine(t,{points:s,static:!1,constraints:[mn.MovableLine.constraints.bound(),mn.MovableLine.constraints.snap()],onMove:[mn.MovableLine.onMove.updatePoints,o],normalStyle:G({stroke:this.props.apiOptions.isMobile?mr.BLUE_C:mr.INTERACTIVE},this._lineStroke()),highlightStyle:G({stroke:this.props.apiOptions.isMobile?mr.BLUE_C:mr.INTERACTING},this._lineStroke())});return h.invoke(s,"toFront"),p}),this)})),j(this,"removeSegmentControls",(()=>{h.invoke(this.points,"remove"),h.invoke(this.lines,"remove")})),j(this,"addRayControls",(()=>{this.addLine("ray")})),j(this,"removeRayControls",(()=>{this.removeLine()})),j(this,"addPolygonControls",(()=>{this.polygon=null;var e=Qu.getPolygonCoords(this.props.graph,this.props);this.points=[],this.points=h.map(e,this.createPointForPolygonType,this),this.updatePolygon()})),j(this,"updatePolygon",(()=>{if("polygon"!==this.props.graph.type)throw Ju("updatePolygon","polygon");var e;e=this.polygon?this.polygon.closed():this.points.length>=3;var t=this.graphie,r=this.points.length,i=!h.contains(["angles","sides"],this.props.graph.snapTo),n=h.times(r,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==r-1)?"angles"===this.props.graph.snapTo?"$deg0":"$deg1":""}),this),o=h.times(r,(function(t){return e||0!==t&&t!==r-1}),this),s=h.times(r,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==r-1)?1:0}),this),a=h.times(r,(function(t){return!this.props.graph.showSides||!e&&t===r-1?"":"sides"===this.props.graph.snapTo?"$len0":"$len1"}),this);if(null==this.polygon){var l=this;l.polygon=mn.addMovablePolygon(t,{constraints:[mn.MovablePolygon.constraints.bound(),i?mn.MovablePolygon.constraints.snap():null],closed:e,points:l.points,angleLabels:n,showRightAngleMarkers:o,numArcs:s,sideLabels:a,onMove:[mn.MovablePolygon.onMove.updatePoints,function(){this.closed()&&l.updateCoordsFromPoints()}],normalStyle:G({stroke:this.props.apiOptions.isMobile?mr.BLUE_C:mr.INTERACTIVE},this._lineStroke())})}else this.polygon.update({closed:e,points:this.points,angleLabels:n,showRightAngleMarkers:o,numArcs:s,sideLabels:a})})),j(this,"removePolygonControls",(()=>{var e;h.invoke(this.points,"remove"),null===(e=this.polygon)||void 0===e||e.remove()})),j(this,"addAngleControls",(()=>{if("angle"!==this.props.graph.type)throw Ju("addAngleControls","angle");var e,t,r=this.props.graph,i=this.graphie,n=Qu.getAngleCoords(this.props.graph,this.props);this.points=n.map((function(e,t){return null==i?void 0:i.addMovablePoint(h.extend({coord:e,normalStyle:{stroke:mr.INTERACTIVE,fill:mr.INTERACTIVE}},1===t?{snapX:i.snap[0],snapY:i.snap[1]}:{}))})),this.angle=null==i?void 0:i.addMovableAngle({points:this.points,snapDegrees:r.snapDegrees||1,snapOffsetDeg:r.angleOffsetDeg||0,angleLabel:r.showAngles?"$deg0":"",pushOut:2,allowReflex:(e=r.allowReflexAngles,t=!0,null==e?t:e)}),y(this.angle).on("move",(()=>{var e;this.onChange({graph:G(G({},r),{},{coords:null===(e=this.angle)||void 0===e?void 0:e.getClockwiseCoords()})})}))})),j(this,"removeAngleControls",(()=>{var e;h.invoke(this.points,"remove"),null===(e=this.angle)||void 0===e||e.remove()})),j(this,"toggleShowAngles",(()=>{if("polygon"!==this.props.graph.type)throw Ju("toggleShowAngles","polygon");var e=h.extend({},this.props.graph,{showAngles:!this.props.graph.showAngles});this.onChange({graph:e})})),j(this,"toggleShowSides",(()=>{if("polygon"!==this.props.graph.type)throw Ju("toggleShowSides","polygon");var e=h.extend({},this.props.graph,{showSides:!this.props.graph.showSides});this.onChange({graph:e})})),j(this,"getUserInput",(()=>Qu.getUserInputFromProps(this.props))),j(this,"simpleValidate",(e=>Qu.validate(this.getUserInput(),e,this))),j(this,"focus",y.noop)}UNSAFE_componentWillMount(){Nu.UNSAFE_componentWillMount.call(this)}componentDidMount(){this.setGraphie(this.refs.graph.graphie())}UNSAFE_componentWillReceiveProps(e){var t,r;this.isClickToAddPoints()!==this.isClickToAddPoints(e)&&(this.shouldResetGraphie=!0,this.setState({shouldShowInstructions:Ku(e)})),(null===(t=this.props.backgroundImage)||void 0===t?void 0:t.url)===(null===(r=e.backgroundImage)||void 0===r?void 0:r.url)&&this.props.backgroundImage===e.backgroundImage&&this.props.containerSizeClass===e.containerSizeClass||(this.shouldResetGraphie=!0)}componentDidUpdate(e,t){var r=e.graph.type,i=this.props.graph.type;(r!==i||"angle"===e.graph.type&&"angle"===this.props.graph.type&&this.areAngleGraphsEqual(e.graph,this.props.graph)||"point"===e.graph.type&&"point"===this.props.graph.type&&this.arePointGraphsEqual(e.graph,this.props.graph)||"polygon"===e.graph.type&&"polygon"===this.props.graph.type&&this.arePolygonGraphsEqual(e.graph,this.props.graph)||"segment"===e.graph.type&&"segment"===this.props.graph.type&&this.areSegmentGraphsEqual(e.graph,this.props.graph))&&(this["remove"+Yu(r)+"Controls"](),this["add"+Yu(i)+"Controls"]()),this.shouldResetGraphie&&this.resetGraphie()}areAngleGraphsEqual(e,t){return e.allowReflexAngles!==t.allowReflexAngles||e.angleOffsetDeg!==t.angleOffsetDeg||e.snapDegrees!==t.snapDegrees}arePointGraphsEqual(e,t){return e.numPoints!==t.numPoints}arePolygonGraphsEqual(e,t){return e.numSides!==t.numSides||e.showAngles!==t.showAngles||e.showSides!==t.showSides||e.snapTo!==t.snapTo}areSegmentGraphsEqual(e,t){return e.numSegments!==t.numSegments}render(){var e,t=lo(this.props.containerSizeClass);this.isClickToAddPoints()&&this.state.shouldShowInstructions?"point"===this.props.graph.type?e=o._("Click to add points"):"polygon"===this.props.graph.type&&(e=o._("Click to add vertices")):e=void 0;var r=this.isClickToAddPoints()?this.handleAddPointsMouseDown:null,i=this.props.gridStep||De.getGridStep(this.props.range,this.props.step,t[0]),n=this.props.snapStep||De.snapStepFromGridStep(i),s=this.props.apiOptions.isMobile;return a.createElement("div",{className:"perseus-widget perseus-widget-interactive-graph",style:{width:t[0],height:t[1]}},a.createElement(Pu,{instructions:e,ref:"graph",box:t,labels:this.props.labels,range:this.props.range,step:s?De.constrainedTickStepsFromTickSteps(this.props.step,this.props.range):this.props.step,gridStep:i,snapStep:n,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:r,onGraphieUpdated:this.setGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:s}))}static getQuadraticCoefficients(e){var t=e[0],r=e[1],i=e[2],n=(t[0]-r[0])*(t[0]-i[0])*(r[0]-i[0]);if(0!==n)return[(i[0]*(r[1]-t[1])+r[0]*(t[1]-i[1])+t[0]*(i[1]-r[1]))/n,(i[0]*i[0]*(t[1]-r[1])+r[0]*r[0]*(i[1]-t[1])+t[0]*t[0]*(r[1]-i[1]))/n,(r[0]*i[0]*(r[0]-i[0])*t[1]+i[0]*t[0]*(i[0]-t[0])*r[1]+t[0]*r[0]*(t[0]-r[0])*i[1])/n]}static getSinusoidCoefficients(e){var t=e[0],r=e[1],i=r[1]-t[1],n=Math.PI/(2*(r[0]-t[0]));return[i,n,t[0]*n,t[1]]}static getLineCoords(e,t){return e.coords||Qu.pointsFromNormalized(t,[[.25,.75],[.75,.75]])}static getPointCoords(e,t){var r=e.numPoints||1,i=e.coords;if(i)return i;switch(r){case 1:i=[e.coord||[0,0]];break;case 2:i=[[-5,0],[5,0]];break;case 3:i=[[-5,0],[0,0],[5,0]];break;case 4:i=[[-6,0],[-2,0],[2,0],[6,0]];break;case 5:i=[[-6,0],[-3,0],[0,0],[3,0],[6,0]];break;case 6:i=[[-5,0],[-3,0],[-1,0],[1,0],[3,0],[5,0]];break;case"unlimited":i=[]}var n=Qu.normalizeCoords(i,[[-10,10],[-10,10]]);return Qu.pointsFromNormalized(t,n)}static getLinearSystemCoords(e,t){return e.coords||h.map([[[.25,.75],[.75,.75]],[[.25,.25],[.75,.25]]],(e=>Qu.pointsFromNormalized(t,e)))}static getPolygonCoords(e,t){if("polygon"!==e.type)throw Ju("toggleShowSides","polygon");var r=e.coords;if(r)return r;var i=e.numSides||3;if("unlimited"===i)r=[];else{var n=2*Math.PI/i,o=(1/i-.5)*Math.PI,s="sides"===e.snapTo?Math.sqrt(3)/3*7:4;r=h.times(i,(function(e){return[s*Math.cos(e*n+o),s*Math.sin(e*n+o)]}))}r=Qu.normalizeCoords(r,[[-10,10],[-10,10]]);var a=!h.contains(["angles","sides"],e.snapTo);return r=Qu.pointsFromNormalized(t,r,!a)}static getSegmentCoords(e,t){var r=e.coords;if(r)return r;var i=e.numSegments||1,n=[[-10,10],[-10,10]];return{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]}[i].map((function(e){var r=[[-5,e],[5,e]];return r=Qu.normalizeCoords(r,n),r=Qu.pointsFromNormalized(t,r)}))}static getAngleCoords(e,t){var r=e.coords;if(r)return r;for(var i=e.snapDegrees||1,n=i;n<20;)n+=i;n=n*Math.PI/180;var o=(e.angleOffsetDeg||0)*Math.PI/180;r=Qu.pointsFromNormalized(t,[[.85,.5],[.5,.5]]);var s=Hu(zu(...r));return r[0]=[r[1][0]+s*Math.cos(o),r[1][1]+s*Math.sin(o)],r[2]=[r[1][0]+s*Math.cos(n+o),r[1][1]+s*Math.sin(n+o)],r}static normalizeCoords(e,t){return h.map(e,(function(e){return h.map(e,(function(e,r){var i=t[r][1]-t[r][0];return(e+t[r][1])/i}))}))}static getEquationString(e){var t="get"+Yu(e.graph.type)+"EquationString";return Qu[t](e)}static pointsFromNormalized(e,t,r){return h.map(t,(function(t){return h.map(t,(function(t,i){var n=e.range[i];if(r)return n[0]+(n[1]-n[0])*t;var o=e.step[i],s=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,o),a=Math.round(t*s);return n[0]+o*a}))}))}static getLinearEquationString(e){var t=Qu.getLineCoords(e.graph,e);if(Au(t[0][0],t[1][0]))return"x = "+t[0][0].toFixed(3);var r=(t[1][1]-t[0][1])/(t[1][0]-t[0][0]),i=t[0][1]-r*t[0][0];return Au(r,0)?"y = "+i.toFixed(3):"y = "+r.toFixed(3)+"x + "+i.toFixed(3)}static getCurrentQuadraticCoefficients(e){var t=e.graph.coords||Qu.defaultQuadraticCoords(e);return Qu.getQuadraticCoefficients(t)}static defaultQuadraticCoords(e){return Qu.pointsFromNormalized(e,[[.25,.75],[.5,.25],[.75,.75]])}static getQuadraticEquationString(e){var t=Qu.getCurrentQuadraticCoefficients(e);return"y = "+t[0].toFixed(3)+"x^2 + "+t[1].toFixed(3)+"x + "+t[2].toFixed(3)}static getCurrentSinusoidCoefficients(e){var t=e.graph.coords||Qu.defaultSinusoidCoords(e);return Qu.getSinusoidCoefficients(t)}static defaultSinusoidCoords(e){return Qu.pointsFromNormalized(e,[[.5,.5],[.65,.6]])}static getSinusoidEquationString(e){var t=Qu.getCurrentSinusoidCoefficients(e);return"y = "+t[0].toFixed(3)+"sin("+t[1].toFixed(3)+"x - "+t[2].toFixed(3)+") + "+t[3].toFixed(3)}static getCircleEquationString(e){var t=e.graph,r=t.center||[0,0],i=t.radius||2;return"center ("+r[0]+", "+r[1]+"), radius "+i}static getLinearSystemEquationString(e){var t=Qu.getLinearSystemCoords(e.graph,e);return"\n"+$u(t[0][0],t[0][1])+"\n"+$u(t[1][0],t[1][1])+"\n"+function(e,t){var r=e[0][0],i=e[0][1],n=e[1][0],o=e[1][1],s=t[0][0],a=t[0][1],l=t[1][0],p=t[1][1],h=(r-n)*(a-p)-(i-o)*(s-l);if(Math.abs(h)<1e-9)return"Lines are parallel";var c=((r*o-i*n)*(a-p)-(i-o)*(s*p-a*l))/h;return"Intersection: ("+(((r*o-i*n)*(s-l)-(r-n)*(s*p-a*l))/h).toFixed(3)+", "+c.toFixed(3)+")"}(t[0],t[1])}static getPointEquationString(e){if("point"!==e.graph.type)throw Ju("getPointEquationString","point");return Qu.getPointCoords(e.graph,e).map((function(e){return"("+e[0]+", "+e[1]+")"})).join(", ")}static getSegmentEquationString(e){if("segment"!==e.graph.type)throw Ju("getSegmentEquationString","segment");var t=Qu.getSegmentCoords(e.graph,e);return h.map(t,(function(e){return"["+h.map(e,(function(e){return"("+e.join(", ")+")"})).join(" ")+"]"})).join(" ")}static getRayEquationString(e){if("ray"!==e.graph.type)throw Ju("createPointForPolygonType","ray");var t=Qu.getLineCoords(e.graph,e),r=t[0],i=t[1],n=Qu.getLinearEquationString(e);return r[0]>i[0]?n+=" (for x <= "+r[0].toFixed(3)+")":r[0]<i[0]?n+=" (for x >= "+r[0].toFixed(3)+")":r[1]>i[1]?n+=" (for y <= "+r[1].toFixed(3)+")":n+=" (for y >= "+r[1].toFixed(3)+")",n}static getPolygonEquationString(e){if("polygon"!==e.graph.type)throw Ju("getPolygonEquationString","polygon");var t=Qu.getPolygonCoords(e.graph,e);return h.map(t,(function(e){return"("+e.join(", ")+")"})).join(" ")}static getAngleEquationString(e){if("angle"!==e.graph.type)throw Ju("getAngleEquationString","angle");var t=Qu.getAngleCoords(e.graph,e);return Cr.findAngle(t[2],t[0],t[1]).toFixed(0)+"° angle at ("+t[1].join(", ")+")"}static validate(e,t,r){var i=!!(e.coords||e.center&&e.radius);if(e.type===t.correct.type&&i)if("linear"===e.type&&"linear"===t.correct.type&&null!=e.coords){var n=e.coords,o=t.correct.coords;if(Ou(o[0],o[1],n[0])&&Ou(o[0],o[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("linear-system"===e.type&&"linear-system"===t.correct.type&&null!=e.coords){var s=e.coords,a=t.correct.coords;if(Ou(a[0][0],a[0][1],s[0][0])&&Ou(a[0][0],a[0][1],s[0][1])&&Ou(a[1][0],a[1][1],s[1][0])&&Ou(a[1][0],a[1][1],s[1][1])||Ou(a[0][0],a[0][1],s[1][0])&&Ou(a[0][0],a[0][1],s[1][1])&&Ou(a[1][0],a[1][1],s[0][0])&&Ou(a[1][0],a[1][1],s[0][1]))return{type:"points",earned:1,total:1,message:null}}else if("quadratic"===e.type&&"quadratic"===t.correct.type&&null!=e.coords){var l=this.getQuadraticCoefficients(e.coords),p=this.getQuadraticCoefficients(t.correct.coords);if(Ru(l,p))return{type:"points",earned:1,total:1,message:null}}else if("sinusoid"===e.type&&"sinusoid"===t.correct.type&&null!=e.coords){var c=this.getSinusoidCoefficients(e.coords),d=this.getSinusoidCoefficients(t.correct.coords),u=Vu(c),m=Vu(d);if(Ru(u,m))return{type:"points",earned:1,total:1,message:null}}else if("circle"===e.type&&"circle"===t.correct.type){if(Ru(e.center,t.correct.center)&&Au(e.radius,t.correct.radius))return{type:"points",earned:1,total:1,message:null}}else if("point"===e.type&&"point"===t.correct.type&&null!=e.coords){var g,f=Qu.getPointCoords(t.correct,r),v=null===(g=e.coords)||void 0===g?void 0:g.slice();if(f=f.slice(),null==v||v.sort(),f.sort(),Ru(v,f))return{type:"points",earned:1,total:1,message:null}}else if("polygon"===e.type&&"polygon"===t.correct.type&&null!=e.coords){var y,x,w,C=null===(y=e.coords)||void 0===y?void 0:y.slice(),k=null===(x=t.correct.coords)||void 0===x?void 0:x.slice();if("similar"===t.correct.match?w=Uu(C,k,Number.POSITIVE_INFINITY):"congruent"===t.correct.match?w=Uu(C,k,b.DEFAULT_TOLERANCE):"approx"===t.correct.match?w=Uu(C,k,.1):(C.sort(),k.sort(),w=Ru(C,k)),w)return{type:"points",earned:1,total:1,message:null}}else if("segment"===e.type&&"segment"===t.correct.type&&null!=e.coords){var E,S=e.coords.slice(),_=null===(E=t.correct.coords)||void 0===E?void 0:E.slice();if(S=h.invoke(S,"sort").sort(),_=h.invoke(_,"sort").sort(),Ru(S,_))return{type:"points",earned:1,total:1,message:null}}else if("ray"===e.type&&"ray"===t.correct.type&&null!=e.coords){var M=e.coords,T=t.correct.coords;if(Ru(M[0],T[0])&&Ou(T[0],T[1],M[1]))return{type:"points",earned:1,total:1,message:null}}else if("angle"===e.type&&"angle"===t.correct.type){var I,P=e.coords,N=t.correct.coords;if("congruent"===t.correct.match){var A=h.map([P,N],(function(e){return(Cr.findAngle(e[2],e[0],e[1])+360)%360}));I=Au(...A)}else I=Ru(P[1],N[1])&&Ou(N[1],N[0],P[0])&&Ou(N[1],N[2],P[2]);if(I)return{type:"points",earned:1,total:1,message:null}}return!i||h.isEqual(e,t.graph)?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}static getUserInputFromProps(e){return e.graph}}j(Qu,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showTooltips:!1,showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,graph:{type:"linear"}});var em={name:"interactive-graph",displayName:"Interactive graph",widget:Qu};class tm extends a.Component{constructor(){super(...arguments),j(this,"_input",void 0),j(this,"state",{isInputFocused:!1})}focusInput(){this._input&&this._input.focus()}handleClick(e){var{checked:t,onChange:r}=this.props;e.preventDefault(),this.focusInput(),r(!t)}handleKeyDown(e){var{onFocusPrevAnswer:t,onFocusNextAnswer:r}=this.props;switch(e.key){case"ArrowUp":e.preventDefault(),t();break;case"ArrowDown":e.preventDefault(),r()}}handleInputChange(e){e.preventDefault()}handleInputFocus(){this.setState({isInputFocused:!0})}handleInputBlur(){this.setState({isInputFocused:!1})}renderCheckmark(){var{checked:e}=this.props;return a.createElement("span",{className:g(im.checkmarkContainer)},e&&a.createElement(ua,{icon:fi,size:16,color:_.offBlack}))}render(){var{content:e,checked:t,groupName:r,index:i,inputType:n}=this.props,{isInputFocused:o}=this.state,s="".concat(r,"-").concat(i);return a.createElement("div",{className:g(im.answerChoice,o&&im.answerFocused),onClick:e=>this.handleClick(e),onKeyDown:e=>this.handleKeyDown(e)},a.createElement("span",{className:g(im.answerInputWrapper)},a.createElement("input",{className:g(ta.perseusSrOnly),checked:t,name:r,id:s,type:n,onChange:e=>this.handleInputChange(e),onFocus:()=>this.handleInputFocus(),onBlur:()=>this.handleInputBlur(),ref:e=>this._input=e}),this.renderCheckmark()),a.createElement("label",{htmlFor:s},a.createElement(Bo,{content:e})))}}class rm extends a.Component{constructor(e){super(e),j(this,"_choices",void 0),this._choices=[],this.state={groupName:h.uniqueId("answer_choices_")}}focusAnswer(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.props.choices.length;e<0?e+=t:e>=t&&(e-=t);var r=this._choices[e];r&&r.focusInput()}onAnswerChange(e,t){for(var{choices:r,multipleSelect:i,onChange:n}=this.props,o=[],s=0;s<r.length;s++)o.push(i?s===e?t:r[s].checked:s===e&&t);n(o)}onFocusAnswer(e){this.focusAnswer(e)}render(){var{choices:e,multipleSelect:t}=this.props,{groupName:r}=this.state;return a.createElement("fieldset",null,e.map(((e,i)=>a.createElement(tm,Y({},e,{key:e.content,groupName:r,index:i,inputType:t?"checkbox":"radio",onChange:e=>this.onAnswerChange(i,e),onFocusPrevAnswer:()=>this.onFocusAnswer(i-1),onFocusNextAnswer:()=>this.onFocusAnswer(i+1),ref:e=>this._choices[i]=e})))))}}var im=m.create({answerChoice:{display:"flex",alignItems:"center",userSelect:"none",padding:"10px 16px 10px 0px",fontWeight:"bold",border:"solid 2px transparent",borderRadius:2,":active":{backgroundColor:"rgba(33, 36, 44, 0.08)"}},answerFocused:{borderColor:"#1865f2",":active":{borderColor:"transparent"}},answerInputWrapper:{marginRight:8},checkmarkContainer:{display:"flex",position:"relative",width:16,height:16,marginLeft:8}});class nm extends a.Component{constructor(){super(...arguments),j(this,"_icon",void 0),j(this,"state",{isFocused:!1})}handleFocus(){this.setState({isFocused:!0})}handleBlur(){this.setState({isFocused:!1})}renderIcon(){var e,t,{selected:r,showCorrectness:i,showSelected:n,showPulsate:o}=this.props,{isFocused:s}=this.state,l=n||s;return i?(e=a.createElement(ua,{icon:"correct"===i?gi:Ni,size:24,color:_.white}),t="correct"===i?[om.markerCorrect,l&&om.markerCorrectSelected]:[om.markerIncorrect,l&&om.markerIncorrectSelected]):t=r&&r.length>0?[om.markerFilled,l&&om.markerFilledSelected]:[l?om.markerUnfilledSelected:o&&om.markerUnfilledPulsate],a.createElement("div",{className:g(om.markerIcon,...t),ref:e=>this._icon=e},e)}render(){var{label:e,x:t,y:r,showCorrectness:i}=this.props,n="correct"===i;return a.createElement("button",{"aria-label":e,className:g(om.unstyledButton,om.marker,n&&om.disabled),style:{left:"".concat(t,"%"),top:"".concat(r,"%")},tabIndex:n?-1:0,onFocus:()=>this.handleFocus(),onBlur:()=>this.handleBlur(),onClick:e=>this.props.onClick(e),onKeyDown:e=>this.props.onKeyDown(e)},this.renderIcon())}}j(nm,"defaultProps",{selected:[]});var om=m.create({unstyledButton:{padding:0,overflow:"visible",color:"inherit",font:"inherit",lineHeight:"normal",background:"none",border:"none"},marker:{position:"absolute",width:30,height:30,marginLeft:-15,marginTop:-15},disabled:{pointerEvents:"none"},markerIcon:{display:"flex",position:"relative",boxSizing:"content-box",width:16,height:16,marginLeft:5,cursor:"pointer",backgroundColor:"#1865f2",border:"solid 2px #ffffff",borderRadius:16,boxShadow:"0 2px 6px 0 ".concat("rgba(33, 36, 44, 0.32)")},markerUnfilledPulsate:{animationName:{"0%":{transform:"scale(1)"},"100%":{transform:"scale(1.5)"}},animationDirection:"alternate",animationDuration:"0.8s",animationIterationCount:"infinite",animationTimingFunction:"ease-in",transformOrigin:"50% 50%"},markerUnfilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:20,height:20,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:20},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerFilled:{width:8,height:8,marginLeft:9,borderRadius:8,boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerFilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:12,height:12,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:12},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerCorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#00a60e",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerCorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#167b1f",boxShadow:"none","::before":{display:"none"}}},markerIncorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#909195",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerIncorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#6c6e73",boxShadow:"none","::before":{display:"none"}}}});class sm extends a.Component{static gradeMarker(e){var t={hasAnswers:!1,isCorrect:!1};return e.selected&&e.selected.length>0&&(t.hasAnswers=!0),e.answers.length>0?e.selected&&e.selected.length===e.answers.length&&(t.isCorrect=e.selected.every((t=>e.answers.includes(t)))):e.selected&&0!==e.selected.length||(t.isCorrect=!0),t}static validate(e,t){var r=0,i=0;for(var n of e.markers){var o=sm.gradeMarker(n);o.hasAnswers&&r++,o.isCorrect&&i++}return r!==e.markers.length?{type:"invalid",message:null}:{type:"points",earned:i===e.markers.length?1:0,total:1,message:null}}static pointInTriangle(e,t,r,i){var n=(e,t,r)=>(e.x-r.x)*(t.y-r.y)-(t.x-r.x)*(e.y-r.y),o=n(e,t,r)<0,s=n(e,r,i)<0,a=n(e,i,t)<0;return o===s&&s===a}static imageSideForMarkerPosition(e,t){if(e<20)return"left";if(e>80)return"right";var r={x:20,y:0},i={x:80,y:0},n={x:80,y:100},o={x:20,y:100},s={x:50,y:50},a={top:[r,i,s],right:[s,i,n],bottom:[o,s,n],left:[r,s,o]},l={x:e,y:t};for(var p of Object.keys(a)){var h=a[p];if(sm.pointInTriangle(l,...h))return p}return"center"}static navigateToMarkerIndex(e,t,r){var i=t[r],n=t.map(((e,t)=>{var r=e.x-i.x,n=e.y-i.y,o=Math.sqrt(r**2+n**2);return{index:t,dist:o,dir:{x:0!==o?r/o:0,y:0!==o?n/o:0}}})).filter((e=>e.index!==r&&"correct"!==t[e.index].showCorrectness)).sort(((t,r)=>{var i,n,o=Math.round(t.dist*(e.x*t.dir.x+e.y*t.dir.y)),s=Math.round(r.dist*(e.x*r.dir.x+e.y*r.dir.y));return e.x>0?(i=t.dir.x>0&&0!==o,n=r.dir.x>0&&0!==s):e.x<0?(i=t.dir.x<0&&0!==o,n=r.dir.x<0&&0!==s):e.y>0?(i=t.dir.y>0&&0!==o,n=r.dir.y>0&&0!==s):e.y<0&&(i=t.dir.y<0&&0!==o,n=r.dir.y<0&&0!==s),i!==n?i?-1:1:o-s}));return n.length>0?n[0].index:r}constructor(e){super(e),j(this,"_markers",void 0),j(this,"_selectedMarkerPopup",void 0),j(this,"_answerChoices",void 0),j(this,"handleDocumentClick",(e=>{if(this._selectedMarkerPopup&&this._answerChoices){var t=v.findDOMNode(this._answerChoices),r=e.target;(function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return t&&(t.contains(r)||i>0&&e(t.parentElement,i-1))})(t)||this.dismissMarkerPopup()}})),j(this,"handleDocumentKeyDown",(e=>{this._selectedMarkerPopup&&27===e.keyCode&&(e.stopPropagation(),this.dismissMarkerPopup())})),this._markers=[],this.state={selectedMarkerIndex:-1,markersInteracted:!1}}componentDidMount(){document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeyDown,!0)}componentWillUnmount(){document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeyDown,!0)}simpleValidate(e){return sm.validate(this.getUserInput(),e)}getUserInput(){var{markers:e}=this.props;return{markers:e}}showRationalesForCurrentlySelectedChoices(e){var{markers:t}=this.props,{onChange:r}=this.props;r({markers:t.map((e=>{var t=sm.gradeMarker(e);return G(G({},e),{},{showCorrectness:t.hasAnswers?t.isCorrect?"correct":"incorrect":void 0})}))},null,!0)}dismissMarkerPopup(){var{selectedMarkerIndex:e}=this.state;-1!==e&&this.setState({selectedMarkerIndex:-1},(()=>{var t=this._markers[e];t&&v.findDOMNode(t).focus()}))}handleMarkerChange(e,t){var{markers:r,onChange:i}=this.props;i({markers:[...r.slice(0,e),G(G({},t),{},{showCorrectness:void 0}),...r.slice(e+1)]})}handleMarkerClick(e,t){var{selectedMarkerIndex:r}=this.state;t.preventDefault(),r!==e?this.setState({selectedMarkerIndex:e,markersInteracted:!0},(()=>{setTimeout((()=>{this._answerChoices&&this._answerChoices.focusAnswer()}),100)})):this.dismissMarkerPopup()}handleMarkerKeyDown(e,t){var{markers:r}=this.props;if(!(r.length<2)){var i={ArrowUp:{x:0,y:-1},ArrowRight:{x:1,y:0},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0}}[t.key];if(i){t.preventDefault();var n=this._markers[sm.navigateToMarkerIndex(i,r,e)];n&&v.findDOMNode(n).focus()}}}handleAnswerChoicesChangeForMarker(e,t){var{choices:r,markers:i,multipleAnswers:n}=this.props,o=r.filter(((e,r)=>t[r]));this.handleMarkerChange(e,G(G({},i[e]),{},{selected:o})),n||this.dismissMarkerPopup()}renderAnswerChoicesForMarker(e,t){var{choices:r,multipleAnswers:i}=this.props,n=t.selected;return a.createElement("div",{className:s("perseus-label-image-widget-answer-choices",g(am.scrollableChoices))},a.createElement(rm,{choices:r.map((e=>({content:e,checked:!!n&&n.includes(e)}))),multipleSelect:i,onChange:t=>this.handleAnswerChoicesChangeForMarker(e,t),ref:e=>this._answerChoices=e}))}renderMarkers(){var{markers:e,questionCompleted:t}=this.props,{selectedMarkerIndex:r,markersInteracted:i}=this.state;return e.map(((e,n)=>{var o,s=sm.gradeMarker(e),l=a.createElement(nm,Y({},e,{showCorrectness:t&&s.hasAnswers&&s.isCorrect?"correct":e.showCorrectness,showSelected:n===r,showPulsate:!i,key:"".concat(e.x,".").concat(e.y),onClick:e=>this.handleMarkerClick(n,e),onKeyDown:e=>this.handleMarkerKeyDown(n,e),ref:e=>this._markers[n]=e}));return n!==r?l:(o=window.matchMedia($s.xsOrSmaller.replace("@media ","")).matches?e.y>50?"top":"bottom":{left:"right",top:"bottom",right:"left",bottom:"top",center:"top"}[sm.imageSideForMarkerPosition(e.x,e.y)],a.createElement(B,{content:()=>a.createElement(z,{style:am.choicesPopover},this.renderAnswerChoicesForMarker(n,e)),placement:o,opened:!0,key:"".concat(e.x,".").concat(e.y),ref:e=>this._selectedMarkerPopup=e},l))}))}renderInstructions(){var{apiOptions:{isMobile:e},choices:t,multipleAnswers:r,hideChoicesFromInstructions:i}=this.props,n=e?r?o._("Tap each dot on the image to select all answers that apply."):o._("Tap each dot on the image to select an answer."):r?o._("Click each dot on the image to select all answers that apply."):o._("Click each dot on the image to select an answer."),l=o._("Choices:");return a.createElement("div",{className:s("perseus-label-image-widget-instructions",g(am.instructions))},a.createElement("div",{className:g(am.instructionsCaption)},n," ",!i&&l),!i&&a.createElement("div",{className:g(am.instructionsChoices)},t.map(((e,t)=>a.createElement("div",{className:g(am.instructionsChoice),key:t},a.createElement(Bo,{content:e}))))))}render(){var{imageAlt:e,imageUrl:t,imageWidth:r,imageHeight:i}=this.props,{selectedMarkerIndex:n}=this.state;return a.createElement("div",null,this.renderInstructions(),a.createElement("div",{className:g(am.markersCanvas),style:{maxWidth:r,maxHeight:i}},a.createElement("div",{className:g(am.imageContainer,-1!==n&&am.imageInteractionDisabled)},a.createElement(er.Consumer,null,(n=>{var{setAssetStatus:o}=n;return a.createElement(Vn,{alt:e,src:t,width:r,height:i,setAssetStatus:o})}))),this.renderMarkers()))}}var am=m.create({instructions:{paddingBottom:16},instructionsCaption:G(G({},il.bodyXsmallBold),{},{paddingBottom:16}),instructionsChoices:{display:"flex",flexWrap:"wrap",margin:"-8px 0"},instructionsChoice:{display:"flex",alignItems:"center",margin:"8px 0",":not(:last-child)":{"::after":{content:"''",display:"inline-block",position:"relative",width:2,height:2,marginLeft:5,marginRight:5,background:"rgba(33, 36, 44, 0.32)",borderRadius:2}}},markersCanvas:{position:"relative"},imageContainer:{display:"flex"},imageInteractionDisabled:{pointerEvents:"none"},scrollableChoices:{paddingTop:8,paddingBottom:8,[$s.xsOrSmaller]:{maxHeight:250,overflowY:"auto"}},choicesPopover:{padding:0}}),lm={name:"label-image",displayName:"Label Image",widget:sm,accessible:!0,isLintable:!0},pm={display:"table",tableLayout:"fixed"},hm={display:"table-row"},cm={display:"table-cell",padding:5},dm={borderRadius:10,cursor:"pointer"},um={padding:5,display:"inline-block"},mm={float:"right",paddingRight:5},gm={plus:()=>[[!1,!0,!1],[!0,!0,!0],[!1,!0,!1]],x:()=>[[!0,!1,!0],[!1,!0,!1],[!0,!1,!0]],"plus/x":e=>e%2?gm.x():gm.plus()};class fm extends a.Component{constructor(){super(...arguments),j(this,"_flip",(()=>{this.props.onChange(!this.props.value)}))}render(){var e=this.props.value?"#55dd55":"#115511",t=h.extend({},dm,{width:this.props.size,height:this.props.size,backgroundColor:e});return a.createElement("div",{style:t,onClick:this._flip})}}j(fm,"propTypes",{value:d.bool.isRequired,size:d.number.isRequired});class vm extends a.Component{render(){return a.createElement("div",{style:pm,className:"no-select"},h.map(this.props.cells,((e,t)=>a.createElement("div",{key:t,style:hm},h.map(e,((e,r)=>a.createElement("div",{key:r,style:cm},a.createElement(fm,{value:e,size:this.props.size,onChange:h.partial(this.props.onChange,t,r)}))))))))}}j(vm,"propTypes",{cells:d.arrayOf(d.arrayOf(d.bool)).isRequired,size:d.number.isRequired});var ym=(e,t,r,i)=>((e,t)=>h.map(e,((e,r)=>h.map(e,((e,i)=>t(r,i)?!e:e)))))(e,((e,n)=>{var o=e-t,s=n-r;return Math.abs(o)<=1&&Math.abs(s)<=1&&i[o+1][s+1]}));class bm extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"_currPattern",void 0),j(this,"_nextPattern",void 0),j(this,"_patternIndex",void 0),j(this,"getUserInput",(()=>Ls.getUserInput.call(this))),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"_width",(()=>0!==this.props.cells.length?this.props.cells[0].length:0)),j(this,"_initNextPatterns",(()=>{this._currPattern=gm[this.props.flipPattern](0),this._nextPattern=gm[this.props.flipPattern](1),this._patternIndex=2})),j(this,"_shiftPatterns",(()=>{this._currPattern=this._nextPattern,this._nextPattern=gm[this.props.flipPattern](this._patternIndex),this._patternIndex++})),j(this,"_flipTile",((e,t)=>{var r=ym(this.props.cells,e,t,this._currPattern);this._shiftPatterns(),this.change({cells:r,moveCount:this.props.moveCount+1})})),j(this,"_reset",(()=>{this.change({cells:this.props.startCells,moveCount:0})})),j(this,"simpleValidate",(e=>xm(e,this.getUserInput())))}render(){var e=60*this._width();return a.createElement("div",null,a.createElement(vm,{cells:this.props.cells,size:50,onChange:this._flipTile}),a.createElement("div",{style:{width:e}},a.createElement("div",{style:um},o.ngettext("Moves: %(num)s","Moves: %(num)s",this.props.moveCount)),a.createElement("div",{style:mm},a.createElement("input",{type:"button",value:"Reset",onClick:this._reset,className:"simple-button"}))),a.createElement("div",{className:"clearfix"}))}componentDidMount(){this._initNextPatterns()}componentDidUpdate(e){e.flipPattern!==this.props.flipPattern&&this._initNextPatterns()}}j(bm,"propTypes",G(G({},fs),{},{cells:d.arrayOf(d.arrayOf(d.bool)),startCells:d.arrayOf(d.arrayOf(d.bool)),flipPattern:d.string.isRequired,moveCount:d.number.isRequired})),j(bm,"defaultProps",{cells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",moveCount:0});var xm=function(e,t){return h.all(t.cells,((t,r)=>h.all(t,((t,i)=>t===e.startCells[r][i]))))?{type:"invalid",message:o._("Click on the tiles to change the lights.")}:h.all(t.cells,(e=>h.all(e,(e=>e))))?{type:"points",earned:1,total:1,message:null}:e.gradeIncompleteAsWrong?{type:"points",earned:0,total:1,message:null}:{type:"invalid",message:o._("You must turn on all of the lights to continue.")}},wm={name:"lights-puzzle",displayName:"Lights Puzzle",hidden:!0,widget:bm,transform:function(e){return{cells:e.startCells,startCells:e.startCells,flipPattern:e.flipPattern}}},Cm=(e,t)=>{var r=e.offsetParent();return{top:t.top+r.scrollTop(),left:t.left+r.scrollLeft()}};class km extends a.Component{render(){var{layout:e}=this.props,t=g(_m.card,_m.placeholder,"horizontal"===e&&_m.horizontalCard),r={width:this.props.width,height:this.props.height};return null!=this.props.margin&&(r.margin=this.props.margin),a.createElement("li",{className:t,style:r})}}j(km,"propTypes",{layout:d.oneOf(["horizontal","vertical"]),width:d.number.isRequired,height:d.number.isRequired});class Em extends a.Component{constructor(){super(...arguments),j(this,"animationFrameRequest",null),j(this,"isMouseMoveUpBound",void 0),j(this,"_mounted",void 0),j(this,"state",{startPosition:{left:0,top:0},startMouse:{left:0,top:0},mouse:{left:0,top:0}}),j(this,"getCurrentPosition",(()=>({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}))),j(this,"bindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!0,y(document).on("mousemove",this.onMouseMove),y(document).on("mouseup",this.onMouseUp)})),j(this,"unbindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!1,y(document).off("mousemove",this.onMouseMove),y(document).off("mouseup",this.onMouseUp)})),j(this,"onMouseDown",(e=>{if("static"===this.props.type&&(0===e.button||null!=e.touches&&1===e.touches.length)){e.preventDefault();var t=De.extractPointerLocation(e);this.animationFrameRequest=requestAnimationFrame((()=>{var e=y(v.findDOMNode(this)),r=e.position(),i=Cm(e,r);t&&this._mounted&&this.setState({startPosition:i,startMouse:t,mouse:t,dragging:!0},(function(){this.bindMouseMoveUp(),this.props.onMouseDown()}))}))}})),j(this,"onMouseMove",(e=>{if(!("dragging"!==this.props.type||!this.state.dragging)){e.preventDefault();var t=De.extractPointerLocation(e);t&&(this.animationFrameRequest=requestAnimationFrame((()=>{this.setState({mouse:t},this.props.onMouseMove)})))}})),j(this,"onMouseUp",(e=>{"dragging"!==this.props.type||!this.state.dragging||(e.preventDefault(),De.extractPointerLocation(e)&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp()))}))}componentDidMount(){this._mounted=!0,this.isMouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!De.supportsPassiveEvents()&&{passive:!1})}componentWillUnmount(){this._mounted=!1,this.isMouseMoveUpBound&&this.unbindMouseMoveUp(),this.animationFrameRequest&&cancelAnimationFrame(this.animationFrameRequest),document.removeEventListener("touchmove",this.onMouseMove)}render(){var{includePadding:e,layout:t,type:r}=this.props,i=g(_m.card,_m.draggable,"horizontal"===t&&_m.horizontalCard,"vertical"===t&&_m.verticalCard,"dragging"===r&&_m.dragging,"disabled"===r&&_m.disabled,!e&&_m.unpaddedCard)+" "+Jt.INTERACTIVE+" perseus-sortable-draggable";e||(i+=" perseus-sortable-draggable-unpadded");var n={position:"static"};return"dragging"!==this.props.type&&"animating"!==this.props.type||h.extend(n,{position:"absolute"},this.getCurrentPosition()),this.props.width&&(n.width=this.props.width+1),this.props.height&&(n.height=this.props.height),null!=this.props.margin&&(n.margin=this.props.margin),a.createElement("li",{className:i,style:n,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,onTouchMove:this.onMouseMove,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},a.createElement(Bo,{content:this.props.content,linterContext:Ut.pushContextStack(this.props.linterContext,"draggable"),onRender:this.props.onRender}))}componentDidUpdate(e){if(this.props.type!==e.type)if("animating"===this.props.type){var t=this.getCurrentPosition(),r=15*Math.sqrt(Math.sqrt(Math.pow(this.props.endPosition.left-t.left,2)+Math.pow(this.props.endPosition.top-t.top,2)));y(v.findDOMNode(this)).animate(this.props.endPosition,{duration:Math.max(r,1),complete:this.props.onAnimationEnd})}else"static"===this.props.type&&y(v.findDOMNode(this)).finish()}}j(Em,"propTypes",{content:d.string.isRequired,endPosition:d.object.isRequired,includePadding:d.bool,layout:d.oneOf(["horizontal","vertical"]),onAnimationEnd:d.func.isRequired,onMouseDown:d.func.isRequired,onMouseMove:d.func.isRequired,onMouseUp:d.func.isRequired,onRender:d.func.isRequired,type:d.oneOf(["static","dragging","animating","disabled"]),linterContext:Gt}),j(Em,"defaultProps",{includePadding:!0,type:"static",linterContext:Vt});class Sm extends a.Component{constructor(e){super(e),j(this,"remeasureItems",h.debounce((()=>{this.setState({items:Sm.clearItemMeasurements(this.state.items)})}),20)),this.state={items:Sm.itemsFromProps(this.props),katex:null}}UNSAFE_componentWillReceiveProps(e){var t=this.props;h.isEqual(e.options,t.options)?e.layout===t.layout&&e.padding===t.padding&&e.disabled===t.disabled&&h.isEqual(e.constraints,t.constraints)||this.setState({items:Sm.clearItemMeasurements(this.state.items)}):this.setState({items:Sm.itemsFromProps(e)})}componentDidUpdate(){!this.state.items.length||this.state.items[0].width||this.state.items[0].height||setTimeout((()=>{this.measureItems()}),0)}componentDidMount(){ae().getKaTeX().then((e=>{this.setState({katex:e})}))}static itemsFromProps(e){var t=e.disabled?"disabled":"static";return e.options.map(((e,r)=>({option:e,key:r,type:t,endPosition:{},width:0,height:0})))}static clearItemMeasurements(e){return e.map((e=>G(G({},e),{},{width:0,height:0})))}measureItems(){var e=h.clone(this.state.items),t=h.map(e,(function(e){return y(v.findDOMNode(this.refs[e.key]))}),this),r=h.invoke(t,"outerWidth"),i=h.invoke(t,"outerHeight"),{constraints:n,layout:o}=this.props,s=null;null!=n&&n.width?s=h.max(r.concat(n.width)):"vertical"===o&&(s=h.max(r));var a=null;null!=n&&n.height?a=h.max(i.concat(n.height)):"horizontal"===o&&(a=h.max(i)),e=h.map(e,(function(e,t){return e.width=s||r[t],e.height=a||i[t],e})),this.setState({items:e},(()=>{this.props.onMeasure&&this.props.onMeasure({widths:r,heights:i})}))}render(){var e,t;if(this.props.waitForKatexLoad&&!this.state.katex)return a.createElement(Sc,null);var r=[],{layout:i}=this.props,n=g(_m.sortable)+" perseus-sortable",o=(null===(e=this.props.constraints)||void 0===e?void 0:e.width)||"vertical"===i,s=(null===(t=this.props.constraints)||void 0===t?void 0:t.height)||"horizontal"===i;return h.each(this.state.items,(function(e,t,n){var l,p=t===n.length-1,h="static"===e.type||"disabled"===e.type;"horizontal"===this.props.layout?l="0 "+this.props.margin+"px 0 0":"vertical"===this.props.layout&&(l="0 0 "+this.props.margin+"px 0"),r.push(a.createElement(Em,{content:e.option,key:e.key,type:e.type,ref:e.key,width:o?e.width:void 0,height:s?e.height:void 0,layout:i,includePadding:this.props.padding,margin:p&&h?0:l,endPosition:e.endPosition,linterContext:Ut.pushContextStack(this.props.linterContext,"sortable"),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)})),"dragging"!==e.type&&"animating"!==e.type||r.push(a.createElement(km,{key:"placeholder_"+e.key,ref:"placeholder_"+e.key,width:e.width,height:e.height,layout:i,margin:p?0:l}))}),this),a.createElement("ul",{className:n},r)}onMouseDown(e){var t=h.map(this.state.items,(function(t){return t.key===e&&(t.type="dragging"),t}));this.setState({items:t})}moveOptionToIndex(e,t){var{items:r}=this.state;if(t<0||t>r.length)throw new Error("index ".concat(t," out of bounds"));var i=h.clone(r),n=r.filter((t=>t.option===e))[0];if(null==n)throw new Error("option ".concat(e," not found"));var o=r.findIndex((e=>e.key===n.key));i.splice(o,1),i.splice(t,0,n),this.setState({items:i}),this.props.onChange&&this.props.onChange({})}onMouseMove(e){var t=y(v.findDOMNode(this.refs[e])),r=y(v.findDOMNode(this)),i=h.clone(this.state.items),n=h.findWhere(this.state.items,{key:e}),o=this.props.margin||0,s=h.indexOf(i,n),a=0;if(i.splice(s,1),"horizontal"===this.props.layout){var l,p=t.offset().left-r.offset().left,c=0;h.each(i,(function(e){l=e.width,p>c+l/2&&(a+=1),c+=l+o}))}else{var d,u=t.offset().top-r.offset().top,m=0;h.each(i,(function(e){d=e.height,u>m+d/2&&(a+=1),m+=d+o}))}a!==s&&(i.splice(a,0,n),this.setState({items:i}))}onMouseUp(e){var t=requestAnimationFrame((()=>{var t=h.map(this.state.items,(function(t){if(t.key===e){t.type="animating";var r=y(v.findDOMNode(this.refs["placeholder_"+e])),i=r.position(),n=Cm(r,i);t.endPosition=n}return t}),this);this.setState({items:t}),this.props.onChange&&this.props.onChange({})}));this.animationFrameRequest=t}onAnimationEnd(e){var t=h.map(this.state.items,(function(t){return t.key===e&&(t.type="static"),t}));this.setState({items:t})}getOptions(){return h.pluck(this.state.items,"option")}}j(Sm,"defaultProps",{layout:"horizontal",padding:!0,disabled:!1,constraints:{},onMeasure:function(){},margin:5,onChange:function(){},linterContext:Vt,waitForKatexLoad:!0});var _m=m.create({sortable:{boxSizing:"border-box",float:"left",padding:0,margin:0},card:{boxSizing:"border-box",background:"#fff",border:"1px solid #ddd",borderRadius:4,cursor:"pointer",minWidth:25,minHeight:44,padding:10,listStyleType:"none",userSelect:"none",touchAction:"none"},placeholder:{background:"#ddd",border:"1px solid #ccc"},draggable:{textAlign:"center"},horizontalCard:{float:"left",cursor:"ew-resize"},verticalCard:{maxWidth:"100%",cursor:"ns-resize"},unpaddedCard:{padding:0},dragging:{background:"#ffedcd",opacity:.8},disabled:{backgroundColor:"inherit",border:"1px solid transparent",cursor:"default"}}),{shuffle:Mm,seededRNG:Tm}=De;class Im extends a.Component{constructor(){super(...arguments),j(this,"state",{leftHeight:0,rightHeight:0,katex:null}),j(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),j(this,"onMeasureLeft",(e=>{var t=h.max(e.heights);this.setState({leftHeight:t})})),j(this,"onMeasureRight",(e=>{var t=h.max(e.heights);this.setState({rightHeight:t})})),j(this,"getUserInput",(()=>this.state.katex?{left:this.refs.left.getOptions(),right:this.refs.right.getOptions()}:{left:[],right:[]})),j(this,"moveLeftOptionToIndex",((e,t)=>{this.refs.left.moveOptionToIndex(e,t)})),j(this,"moveRightOptionToIndex",((e,t)=>{this.refs.right.moveOptionToIndex(e,t)})),j(this,"simpleValidate",(e=>Im.validate(this.getUserInput(),e)))}componentDidMount(){ae().getKaTeX().then((e=>this.setState({katex:e})))}render(){if(!this.state.katex)return a.createElement(Sc,null);var e,t=Tm(this.props.problemNum);e=this.props.orderMatters?Mm(this.props.left,t,!0):this.props.left;var r=Mm(this.props.right,t,!0),i=h.any(this.props.labels),n={height:h.max([this.state.leftHeight,this.state.rightHeight])},o=this.props.apiOptions.isMobile?8:5;return a.createElement("table",{className:g(Pm.widget)+" perseus-widget-matcher"},a.createElement("tbody",null,i&&a.createElement("tr",{className:g(Pm.row)},a.createElement("th",{className:g(Pm.column,Pm.columnLabel)},a.createElement(Bo,{content:this.props.labels[0]||"...",linterContext:this.props.linterContext})),a.createElement("th",{className:g(Pm.column,Pm.columnRight,Pm.columnLabel)},a.createElement(Bo,{content:this.props.labels[1]||"...",linterContext:this.props.linterContext}))),a.createElement("tr",{className:g(Pm.row)},a.createElement("td",{className:g(Pm.column)},a.createElement(Sm,{options:e,layout:"vertical",padding:this.props.padding,disabled:!this.props.orderMatters,constraints:n,onMeasure:this.onMeasureLeft,onChange:this.changeAndTrack,margin:o,linterContext:this.props.linterContext,ref:"left"})),a.createElement("td",{className:g(Pm.column,Pm.columnRight)},a.createElement(Sm,{options:r,layout:"vertical",padding:this.props.padding,constraints:n,onMeasure:this.onMeasureRight,onChange:this.changeAndTrack,margin:o,linterContext:this.props.linterContext,ref:"right"})))))}}j(Im,"propTypes",{apiOptions:Zt.propTypes,labels:d.array,left:d.array,onChange:d.func,orderMatters:d.bool,padding:d.bool,problemNum:d.number,right:d.array,trackInteraction:d.func.isRequired,linterContext:Gt}),j(Im,"defaultProps",{left:[],right:[],labels:["",""],orderMatters:!1,padding:!0,problemNum:0,onChange:function(){},linterContext:Vt}),h.extend(Im,{validate:function(e,t){return{type:"points",earned:h.isEqual(e.left,t.left)&&h.isEqual(e.right,t.right)?1:0,total:1,message:null}}});var Pm=m.create({widget:{paddingTop:5,maxWidth:"100%",minWidth:"auto"},row:{border:0},column:{padding:0,border:0},columnRight:{borderLeft:"1px solid #444"},columnLabel:{fontWeight:"inherit",borderBottom:"1px solid #444",padding:"0 ".concat(5,"px ").concat(5,"px ").concat(5,"px"),textAlign:"center"}}),Nm={name:"matcher",displayName:"Two column matcher",widget:Im,isLintable:!0},Am=["onFormatChange","checkValidity","useArrowKeys"],{firstNumericalParse:Rm,captureScratchpadTouchStart:Fm}=De,Om=de.toNumericString,Dm=de.getNumericFormat;class Lm extends a.Component{constructor(){super(...arguments),j(this,"state",{format:this.props.format}),j(this,"getValue",(()=>this.parseInputValue(v.findDOMNode(this.refs.input).value))),j(this,"getStringValue",(()=>v.findDOMNode(this.refs.input).value.toString())),j(this,"parseInputValue",(e=>{if(""===e){var t=this.props.placeholder;return h.isFinite(t)?+t:null}var r=Rm(e);return h.isFinite(r)?r:this.props.value})),j(this,"focus",(()=>{v.findDOMNode(this.refs.input).focus(),this._handleFocus()})),j(this,"blur",(()=>{v.findDOMNode(this.refs.input).blur(),this._handleBlur()})),j(this,"setSelectionRange",((e,t)=>{v.findDOMNode(this).setSelectionRange(e,t)})),j(this,"getSelectionStart",(()=>v.findDOMNode(this).selectionStart)),j(this,"getSelectionEnd",(()=>v.findDOMNode(this).selectionEnd)),j(this,"_checkValidity",(e=>{if(null==e)return!0;var t=Rm(e),r=this.props.checkValidity;return h.isFinite(t)&&r(t)})),j(this,"_handleChange",(e=>{var t=e.target.value,r=this.parseInputValue(t),i=Dm(t);this.props.onChange(r),i&&(this.props.onFormatChange(r,i),this.setState({format:i}))})),j(this,"_handleFocus",(()=>{this.props.onFocus&&this.props.onFocus()})),j(this,"_handleBlur",(e=>{e&&"keypress"===e.type&&13!==e.keyCode||(this._setValue(this.props.value,this.state.format),this.props.onBlur&&this.props.onBlur())})),j(this,"_onKeyDown",(e=>{if(this.props.onKeyDown&&this.props.onKeyDown(e),this.props.useArrowKeys&&h.contains(["ArrowUp","ArrowDown"],e.key)){var t=this.getValue();t===Math.floor(t)&&("ArrowUp"===e.key?t+=1:"ArrowDown"===e.key&&(t-=1),this._checkValidity(t)&&this.props.onChange(t))}})),j(this,"_setValue",((e,t)=>{y(v.findDOMNode(this.refs.input)).val(Om(e,t))}))}render(){var e=s({"number-input":!0,"invalid-input":!this._checkValidity(this.props.value),mini:"mini"===this.props.size,small:"small"===this.props.size,normal:"normal"===this.props.size});null!=this.props.className&&(e=e+" "+this.props.className);var t=$(this.props,Am);return a.createElement("input",Y({},t,{className:e,type:"text",ref:"input",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,onKeyPress:this._handleBlur,onKeyDown:this._onKeyDown,onTouchStart:Fm,defaultValue:Om(this.props.value,this.state.format),value:void 0}))}componentDidUpdate(e){b.equal(this.getValue(),this.props.value)||this._setValue(this.props.value,this.state.format)}}j(Lm,"propTypes",{value:d.number,format:d.string,placeholder:d.oneOfType([d.string,d.number]),onChange:d.func.isRequired,onFormatChange:d.func,checkValidity:d.func,size:d.string,label:d.oneOf(["put your labels outside your inputs!"])}),j(Lm,"defaultProps",{value:null,placeholder:null,format:null,onFormatChange:()=>null,checkValidity:()=>!0,useArrowKeys:!1});var{assert:Bm}=hr,{stringArrayOfSize:zm}=De,Hm={INPUT_MARGIN:4,INPUT_HEIGHT:38,INPUT_WIDTH:82},Wm={INPUT_MARGIN:3,INPUT_HEIGHT:30,INPUT_WIDTH:40},qm={INPUT_MARGIN:4,INPUT_HEIGHT:36,INPUT_WIDTH:64};function Um(e,t){return[""+e,""+t]}var Gm=function(){return Um(0,0)},Vm=function(e){return Bm(h.isArray(e)&&2===e.length),+e[0]},jm=function(e){return Bm(h.isArray(e)&&2===e.length),+e[1]},Ym=function(e){return"answer"+Vm(e)+","+jm(e)},$m=function(e){var t=[1,1];return h(e).each(((e,r)=>{var i=0;h(e).each(((e,t)=>{null!=e&&e.toString().length&&(i=t+1)})),t[1]=Math.max(t[1],i),i>0&&(t[0]=Math.max(t[0],r+1))})),t};class Xm extends a.Component{constructor(){super(...arguments),j(this,"cursorPosition",void 0),j(this,"state",{enterTheMatrix:0}),j(this,"getInputPaths",(()=>{var e=[],t=this.props.matrixBoardSize[0],r=this.props.matrixBoardSize[1];return h(t).times((t=>{h(r).times((r=>{var i=Um(t,r);e.push(i)}))})),e})),j(this,"getGrammarTypeForPath",(e=>"number")),j(this,"_handleFocus",((e,t)=>{this.props.onFocus(Um(e,t))})),j(this,"_handleBlur",((e,t)=>{this.props.onBlur(Um(e,t))})),j(this,"focus",(()=>(this.focusInputPath(Gm()),!0))),j(this,"focusInputPath",(e=>{var t=Ym(e);this.refs[t].focus()})),j(this,"blurInputPath",(e=>{0===e.length&&(e=Gm());var t=Ym(e);this.refs[t].blur()})),j(this,"getDOMNodeForPath",(e=>{var t=Ym(e);return v.findDOMNode(this.refs[t])})),j(this,"setInputValue",((e,t,r)=>{var i=Vm(e),n=jm(e);this.onValueChange(i,n,t,r)})),j(this,"handleKeyDown",((e,t,r)=>{var i=this.props.matrixBoardSize[0],n=this.props.matrixBoardSize[1],o=null,s=this.refs[Ym(Um(e,t))],a=s.getStringValue(),l=s.getSelectionStart(),p=s.getSelectionEnd(),h=null;if("ArrowUp"===r.key&&e>0?h=Um(e-1,t):"ArrowDown"===r.key&&e+1<i?h=Um(e+1,t):"ArrowLeft"===r.key&&t>0?0===l&&0===p&&(h=Um(e,t-1)):"ArrowRight"===r.key&&t+1<n?l===a.length&&(h=Um(e,t+1)):"Enter"===r.key?o=this.state.enterTheMatrix+1:"Escape"===r.key&&(o=0),h){r.preventDefault();var c=this.refs[Ym(h)],d=2*c.getStringValue().length;c.focus(),"ArrowRight"===r.key?c.setSelectionRange(0,0):c.setSelectionRange(d,d)}null!=o&&this.setState({enterTheMatrix:o})})),j(this,"onValueChange",((e,t,r,i)=>{var n=h.map(this.props.answers,h.clone);n[e]||(n[e]=[]),n[e][t]=r,this.props.onChange({answers:n},i),this.props.trackInteraction()})),j(this,"getUserInput",(()=>({answers:this.props.answers}))),j(this,"simpleValidate",(e=>Xm.validate(this.getUserInput(),e)))}componentDidMount(){this.cursorPosition=[0,0]}render(){var e;e=this.props.apiOptions.customKeypad?qm:this.props.apiOptions.staticRender?Hm:Wm;var{INPUT_MARGIN:t,INPUT_HEIGHT:r,INPUT_WIDTH:i}=e,n=$m(this.props.answers),o=this.props.matrixBoardSize[0],l=this.props.matrixBoardSize[1],p=this.props.cursorPosition[0],c=this.props.cursorPosition[1],d=Math.max(p,n[0]-1),u=Math.max(c,n[1]-1),m=(d+1)*(r+2*t),g=(u+1)*(i+2*t),f=s({"perseus-matrix":!0,"static-mode":this.props.static,"the-matrix":this.state.enterTheMatrix>=5});return a.createElement("div",{className:f},this.props.prefix&&a.createElement("div",{className:"matrix-prefix"},a.createElement(Bo,{content:this.props.prefix,linterContext:this.props.linterContext})),a.createElement("div",{className:"matrix-input"},a.createElement("div",{className:"matrix-bracket bracket-left",style:{height:m}}),a.createElement("div",{className:"matrix-bracket bracket-right",style:{height:m,left:g}}),h(o).times((e=>{var n=this.props.answers[e];return a.createElement("div",{className:"matrix-row",key:e},h(l).times((o=>{var s,l=e>d||o>u,p={className:l?"outside":"inside",ref:Ym(Um(e,o)),value:n?n[o]:null,style:{height:r,width:i,margin:t},disabled:this.props.apiOptions.readOnly,onFocus:()=>{this.cursorPosition=[e,o],this.props.onChange({cursorPosition:[e,o]},(()=>!1)),this._handleFocus(e,o)},onBlur:()=>{e===this.cursorPosition[0]&&o===this.cursorPosition[1]&&this.props.onChange({cursorPosition:[0,0]},(()=>!1)),this._handleBlur(e,o)},onKeyDown:t=>{this.handleKeyDown(e,o,t)},onChange:(t,r)=>{this.onValueChange(e,o,t,r)}};if(this.props.apiOptions.customKeypad){var h={margin:t,minWidth:i,minHeight:r,boxSizing:"border-box",backgroundColor:l?"#f3f3f3":"#fff"};s=a.createElement(Ss,Y({},p,{style:h,scrollable:!0,keypadElement:this.props.keypadElement}))}else s=this.props.apiOptions.staticRender?a.createElement(es,p):this.props.numericInput?a.createElement(Lm,p):a.createElement(rs,p);return a.createElement("span",{key:o,className:"matrix-input-field"},s)})))}))),this.props.suffix&&a.createElement("div",{className:"matrix-suffix"},a.createElement(Bo,{content:this.props.suffix,linterContext:this.props.linterContext})))}}j(Xm,"defaultProps",{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0],apiOptions:Zt.defaults,linterContext:Vt}),h.extend(Xm,{validate:function(e,t){var r=t.answers,i=e.answers,n=$m(r),s=$m(i),a=n[0]!==s[0]||n[1]!==s[1],l=ge.number.createValidatorFunctional,p=null,c=!1,d=!1;return h(s[0]).times((e=>{h(s[1]).times((t=>{if(null!=i[e][t]&&0!==i[e][t].toString().length||(c=!0),!a){var n=l(r[e][t],{simplify:!0})(i[e][t]);n.message&&(p=n.message),n.correct||(d=!0)}}))})),c?{type:"invalid",message:o._("Make sure you fill in all cells in the matrix.")}:a?{type:"points",earned:0,total:1,message:null}:{type:"points",earned:d?0:1,total:1,message:p}}});var Km={name:"matrix",displayName:"Matrix",widget:Xm,transform:e=>{var t=h(e.matrixBoardSize[0]).times((function(){return zm(e.matrixBoardSize[1])}));return e=h.pick(e,"matrixBoardSize","prefix","suffix"),h.extend(e,{answers:t})},staticTransform:e=>{var t=h.pick(e,"matrixBoardSize","prefix","suffix");return t.answers=h.map(e.answers,(e=>h.map(e,(e=>null!=e?String(e):"")))),t},isLintable:!0},Zm={url:null,top:0,left:0},Jm=E({displayName:"Measurer",propTypes:{apiOptions:Zt.propTypes,box:d.arrayOf(d.number),image:d.shape({url:d.string,top:d.number,left:d.number}),showProtractor:d.bool,protractorX:d.number,protractorY:d.number,showRuler:d.bool,rulerLabel:d.string,rulerTicks:d.number,rulerPixels:d.number,rulerLength:d.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=h.extend({},Zm,this.props.image);return a.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&&a.createElement("div",{style:{position:"relative",top:e.top,left:e.left}},a.createElement(Vn,{src:e.url})),a.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this.setupGraphie()},componentDidUpdate:function(e){h.any(["box","showProtractor","showRuler","rulerLabel","rulerTicks","rulerPixels","rulerLength"],(function(t){return e[t]!==this.props[t]}),this)&&this.setupGraphie()},setupGraphie:function(){var e=v.findDOMNode(this.refs.graphieDiv);y(e).empty();var t=this.graphie=Cr.createGraphie(e),r=[40,40],i=[[0,this.props.box[0]/r[0]],[0,this.props.box[1]/r[1]]];t.init({range:i,scale:r}),t.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),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:[(i[0][0]+i[0][1])/2,(i[1][0]+i[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 Jm.validate(this.getUserInput(),e)},focus:y.noop});h.extend(Jm,{validate:function(e,t){return{type:"points",earned:1,total:1,message:null}}});var Qm={name:"measurer",displayName:"Measurer",widget:Jm,version:{major:1,minor:0},propUpgrades:{1:e=>h(e).chain().omit("imageUrl","imageTop","imageLeft").extend({image:{url:e.imageUrl,top:e.imageTop,left:e.imageLeft}}).value()}};function eg(e,t){var r=new Path2D;e.lineWidth=og.lineWidth,e.strokeStyle=og.fgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r)}var tg={text:function(e,t){null!==t.value&&(e.fillStyle=og.fgColor,e.font=og.font,e.fillText(t.value,t.pos[0]-og.fontSizePx/2+1,t.pos[1]+og.fontSizePx/2))},"line:single":eg,"line:double":function(e,t){var r=new Path2D;e.lineWidth=5*og.lineWidth,e.strokeStyle=og.fgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r),r=new Path2D,e.lineWidth=3*og.lineWidth,e.strokeStyle=og.bgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r)},"line:triple":function(e,t){var r=new Path2D;e.lineWidth=7*og.lineWidth,e.strokeStyle=og.fgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r),r=new Path2D,e.lineWidth=5*og.lineWidth,e.strokeStyle=og.bgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r),eg(e,t)}};var rg={"line:single":0,"line:double":0,"line:triple":0,text:1};function ig(e,t){return rg[e.type]-rg[t.type]}function ng(e,t){t.sort(ig).forEach(function(e){return function(t){tg[t.type](e,t)}}(e))}var og={bgColor:"rgb(255, 255, 255)",fgColor:"rgb(0, 0, 0)",fontSizePx:12,lineWidth:1,font:"12px sans"};function sg(e,t,r,i){var n=e.symbol;if("C"===n&&1!==Object.keys(t).length&&(n=null),"1,0"===e.idx){var o=[0,0];return e.pos=o,e.baseAngle=-30+i,{type:"text",value:n,pos:o,idx:e.idx}}var s=t[e.connections.find((function(e){return t[e].pos}))],a=s.connections.indexOf(e.idx),l=60,p=120;4===s.connections.length?(p=90,l=90):(r.find((t=>"triple"===t.bondType&&t.to===e.idx))||r.find((e=>"triple"===e.bondType&&e.to===s.idx)))&&(p=0,l=0);var h=0,c=s.idx.split(":"),d=c[c.length-1].split(",")[0];h=parseInt(d)%2!=0?s.baseAngle-(l-p*a):s.baseAngle+(l-p*a);var u=function(e,t,r){var i=e[0],n=e[1];return[i+Math.cos(2*t*Math.PI/360)*r,n+-1*Math.sin(2*t*Math.PI/360)*r]}(s.pos,h,30);return e.pos=u,e.baseAngle=h,{type:"text",value:n,pos:u,idx:e.idx}}function ag(e,t){var r=function(e,t){var r=[e.pos[0],e.pos[1]],i=[t.pos[0],t.pos[1]];return"C"!==e.symbol&&(r=[t.pos[0]-.75*(t.pos[0]-e.pos[0]),t.pos[1]-.75*(t.pos[1]-e.pos[1])]),"C"!==t.symbol&&(i=[e.pos[0]-.75*(e.pos[0]-t.pos[0]),e.pos[1]-.75*(e.pos[1]-t.pos[1])]),[r,i]}(t[e.from],t[e.to]);return{type:"line:"+e.bondType,startPos:r[0],endPos:r[1]}}function lg(e){return e.join(":")}function pg(e,t,r){if(null===r)return[e,t];if("atom"===r.type){var i=lg(r.idx);e[i]={idx:i,symbol:r.symbol,connections:[]},r.bonds&&r.bonds.forEach((function(r){var n=lg(r.to.idx);e[i].connections.push(n),t.push({from:i,to:n,bondType:r.bondType}),pg(e,t,r.to),e[n].connections.push(i)}))}return[e,t]}function hg(e,t,r,i,n){if(0===t.length)return e;var o=t.shift(),s=r[o];return s.connections.forEach((function(e){r[e].pos||t.push(e)})),hg(e.concat(sg(s,r,i,n)),t,r,i,n)}function cg(e,t,r){return 0===r.length?e:cg(e.concat(ag(r[0],t)),t,r.slice(1))}var dg={layout:function(e,t){var r=pg({},[],e),i=r[0],n=r[1];return cg(hg([],["1,0"],i,n,t),i,n)},_atomLayout:sg,_bondLayout:ag,_bondLength:30,_convertTree:pg},ug=new RegExp("^[A-Za-z\\[\\]()=#+-]*$"),mg=new RegExp("^(Cl|Br|[CONPSFBI]|\\[)");function gg(e){this.message=e}function fg(e,t,r){var i,n=t[0],o=t.slice(1);i=Array.isArray(e)?[...e]:G({},e||{});var s=r;return o.length>0&&(s=fg(i[n],o,r)),i[n]=s,i}function vg(e,t){if(0===t.length)return e;if(""===e)throw new gg("Mismatched parentheses");var r=e[0],i=e.slice(1);return vg(i,"("===r?t.concat(r):")"===r?t.slice(1):t)}function yg(e,t){var r,i,n,o=e[0],s=e.slice(1);if("("===o){var a=G(G({},t),{},{parens:t.parens+"("});r=t,i=["idx",t.idx.length-1,1],n=i.reduce((function(e,t){return e[t]}),r),a=fg(r,i,n+1);var l=-1;t.idx[t.idx.length-1][0]%2==0&&(l=0);var p=xg(s,G(G({},a),{},{idx:a.idx.concat([[l,0]]),parens:a.parens.concat("(")})),h=xg(vg(s,["("]),a);return[p].concat(h)}if(")"===o){if("("!==t.parens[t.parens.length-1])throw new gg("Mismatched parentheses");return null}throw new gg("Invalid bare character: "+o)}function bg(e,t){var r=function(e,t){var r=null,i=null;if("["===e[0]){var n=e.indexOf("]");if(-1===n)return["",e];r=e.slice(1,n),i=e.slice(n+1)}else r=mg.exec(e)[1],i=e.slice(r.length);return[r,i]}(e),i=r[0];if(""===i)return["error","Unable to parse bracketed atom."];var n=r[1],o=fg(t,["idx",t.idx.length-1],[1+t.idx[t.idx.length-1][0],0]),s=xg(n,fg(o,["bond","bondType"],"single"));!Array.isArray(s)&&s&&(s=[s]);var a={type:"atom",symbol:i,bonds:s,idx:o.idx};return t.bond?{type:"bond",bondType:t.bond.bondType,to:a}:a}function xg(e,t){if(!function(e){return ug.test(e)}(e))throw new gg("Invalid input.");return e&&0!==e.length?(r=e,mg.test(r)?bg(e,t||{idx:[[0,0]],parens:[],stack:[],bondModifiers:[]}):function(e){return"="===e||"#"===e}(e[0])?function(e,t){var r=e[0],i=e.slice(1);if("="===r)return xg(i,fg(t,["bond","bondType"],"double"));if("#"===r)return xg(i,fg(t,["bond","bondType"],"triple"));throw new gg("Invalid character: "+r)}(e,t):yg(e,t)):null;var r}var wg=xg,Cg=gg,{layout:kg}=dg,Eg=wg,Sg=Cg;class _g extends a.Component{constructor(){super(...arguments),j(this,"state",{parsedSmiles:null,error:null}),j(this,"stateFromSmiles",(e=>{try{this.setState({parsedSmiles:Eg(e),error:null})}catch(e){if(!(e instanceof Sg))throw e;this.setState({error:e.message})}})),j(this,"setCanvasBounds",((e,t)=>{var r=Math.max(...t.map((e=>e.pos?e.pos[0]:-1/0))),i=Math.max(...t.map((e=>e.pos?e.pos[1]:-1/0))),n=Math.min(...t.map((e=>e.pos?e.pos[0]:1/0))),o=Math.min(...t.map((e=>e.pos?e.pos[1]:1/0))),s=r-n+60,a=i-o+60;return e.width=s,e.height=a,[30-n,30-o]})),j(this,"canvasRender",(()=>{if(!this.state.error&&this.state.parsedSmiles){var e=kg(this.state.parsedSmiles,this.props.rotationAngle),t=this.refs.canvas,r=this.setCanvasBounds(t,e),i=t.getContext("2d");i.clearRect(0,0,t.width,t.height),i.save(),i.translate(r[0],r[1]),ng(i,e),i.restore()}}))}UNSAFE_componentWillMount(){this.stateFromSmiles(this.props.smiles)}componentDidMount(){this.canvasRender()}UNSAFE_componentWillReceiveProps(e){this.stateFromSmiles(e.smiles)}componentDidUpdate(){this.canvasRender()}render(){var e=a.createElement("canvas",{className:"molecule-canvas",id:this.props.id+"-molecule",ref:"canvas"},o.$_("A molecular structure drawing. SMILES notation: %(content)s",{content:this.props.smiles}));return this.state.error&&(e=a.createElement("div",{className:"error"},this.state.error)),a.createElement("div",{className:"molecule-canvas"},e)}}j(_g,"propTypes",{id:d.string.isRequired,rotationAngle:d.number,smiles:d.string});class Mg extends a.Component{constructor(){super(...arguments),j(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),j(this,"getUserInput",(()=>[])),j(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null})))}render(){return a.createElement(_g,{id:this.props.widgetId,smiles:this.props.smiles,rotationAngle:this.props.rotationAngle})}}j(Mg,"propTypes",{rotationAngle:d.number,smiles:d.string,widgetId:d.string}),j(Mg,"defaultProps",{rotationAngle:0});var Tg={name:"molecule-renderer",displayName:"Molecule renderer",hidden:!0,widget:Mg},Ig=Nn.MovablePoint,Pg=Nn.Line,{assert:Ng}=hr,Ag={ge:"le",gt:"lt",le:"ge",lt:"gt"},Rg={ge:"gt",gt:"ge",le:"lt",lt:"le"};function Fg(e,t){return 1===t?""+e:"\\dfrac{".concat(e,"}{").concat(t,"}")}function Og(e,t){if(e<0)return"-"+Og(-e,t);var r=Math.floor(e/t);return 0===r?Fg(e,t):e-r*t==0?""+r:r+Fg(e-r*t,t)}var Dg=(e,t,r,i,n)=>{if(i=i||r,"decimal"===t||"decimal ticks"===t)return e.label([r,-.53],Math.round(100*i)/100,"center");if("improper"===t){var o=de.toFraction(i);return e.label([r,-.17],Fg(o[0],o[1]),"below")}if("mixed"===t){var s=de.toFraction(i);return e.label([r,-.17],Og(s[0],s[1]),"below")}if("non-reduced"===t){var a=de.toFraction(i);return e.label([r,-.17],function(e,t,r){return Fg(e*Math.floor(r/t),r)}(a[0],a[1],n),"below")}},Lg=Nn.createSimpleClass(((e,t)=>{if(!h.isFinite(t.tickStep)||t.tickStep<=0)return[];var r,i=[],n=t.range,o=t.labelRange,s=null==o[0]?n[0]:o[0],a=null==o[1]?n[1]:o[1];if("non-reduced"===t.labelStyle){for(var l=[s,a],p=0;p<=t.numDivisions;p++){var c=n[0]+p*t.tickStep;l.push(c)}var d=h.map(l,(e=>b.toFraction(e)[1]));r=h.reduce(d,((e,t)=>de.getLCM(e,t)))}else r=void 0;for(var u=0;u<=t.numDivisions;u++){var m=n[0]+u*t.tickStep;i.push(e.line([m,-.2],[m,.2])),(t.labelTicks||"decimal ticks"===t.labelStyle)&&i.push(Dg(e,t.labelStyle,m,m,r))}return i.push(e.style(t.isMobile?{color:mr.BLUE_D}:{},(()=>Dg(e,t.labelStyle,s,s,r)))),i.push(e.style(t.isMobile?{color:mr.BLUE_D}:{},(()=>Dg(e,t.labelStyle,a,a,r)))),e.style({stroke:t.isMobile?mr.BLUE_D:mr.DYNAMIC,strokeWidth:3.5},(()=>{i.push(e.line([s,-.2],[s,.2])),i.push(e.line([a,-.2],[a,.2]))})),i}));class Bg extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"state",{numDivisionsEmpty:!1}),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"isValid",(()=>{var e=this.props.range,t=this.props.numLinePosition,r=this.props.divisionRange;return t=null==t?e[0]:t,e[0]<e[1]&&b.sign(t-e[0])>=0&&b.sign(t-e[1])<=0&&r[0]<r[1]&&0<this.props.numDivisions&&0<this.props.snapDivisions})),j(this,"onNumDivisionsChange",((e,t)=>{var r=this.props.divisionRange.slice(),i=this.props.range[1]-this.props.range[0];if(e=(e=Math.round(e))<0?-1*e:e){var n=h.extend({},this.props,{tickStep:i/e}),o=this.snapNumLinePosition(n,this.props.numLinePosition);this.setState({numDivisionsEmpty:!1},(()=>{this.props.onChange({divisionRange:r,numDivisions:e,numLinePosition:o},t)}))}else this.setState({numDivisionsEmpty:!0},t)})),j(this,"_handleTickCtrlFocus",(()=>{this.props.onFocus(["tick-ctrl"])})),j(this,"_handleTickCtrlBlur",(()=>{this.props.onBlur(["tick-ctrl"])})),j(this,"focus",(()=>{if(this.props.isTickCtrl)return this.refs["tick-ctrl"].focus(),!0})),j(this,"focusInputPath",(e=>{1===e.length&&this.refs[e[0]].focus()})),j(this,"blurInputPath",(e=>{1===e.length&&this.refs[e[0]].blur()})),j(this,"getInputPaths",(()=>this.props.isTickCtrl?[["tick-ctrl"]]:[])),j(this,"getDOMNodeForPath",(e=>{if(1===e.length)return v.findDOMNode(this.refs[e[0]])})),j(this,"getGrammarTypeForPath",(e=>{if(1===e.length&&"tick-ctrl"===e[0])return"number"})),j(this,"setInputValue",((e,t,r)=>{1===e.length&&"tick-ctrl"===e[0]&&this.onNumDivisionsChange(t,r)})),j(this,"_renderGraphie",(()=>{var e=this.props.range,t=e[1]-e[0],r=h.pick(this.props,["range","isTickCtrl"]),i=h.extend({},this.props,{tickStep:t/this.props.numDivisions});return a.createElement(Nn,{ref:"graphie",key:this.props.labelStyle,box:[this.props.apiOptions.isMobile?288:460,80],options:r,onMouseDown:e=>{this.refs.graphie.movables.numberLinePoint.grab(e)},setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile},a.createElement(Lg,Y({},h.pick(i,["range","numDivisions","labelTicks","labelStyle","labelRange","tickStep"]),{isMobile:this.props.apiOptions.isMobile})),this._renderInequality(i),this._renderNumberLinePoint(i))})),j(this,"snapNumLinePosition",((e,t)=>{var r=e.range[0],i=e.range[1],n=e.tickStep/e.snapDivisions,o=((e,t,r)=>Math.min(Math.max(e,t),r))(t,r,i);return o=r+b.roundTo(o-r,n),Ng(h.isFinite(o)),o})),j(this,"movePosition",(e=>{this.change({numLinePosition:e}),this.props.trackInteraction()})),j(this,"_renderNumberLinePoint",(e=>{var t=h(["lt","gt"]).contains(e.rel),r={fill:t?mr._BACKGROUND:e.static?mr.DYNAMIC:mr.INTERACTIVE,stroke:e.static?mr.DYNAMIC:mr.INTERACTIVE,"stroke-width":t?3:1},i={fill:t?mr._BACKGROUND:mr.INTERACTING,"stroke-width":t?3:1},n=e.isInequality?{stroke:mr.INTERACTIVE,"fill-opacity":t?0:1}:{};return a.createElement(Ig,{ref:"numberLinePoint",pointSize:6,coord:[e.numLinePosition,0],constraints:[(e,t)=>[e[0],t[1]],(t,r)=>[this.snapNumLinePosition(e,t[0]),t[1]]],normalStyle:r,highlightStyle:i,onMove:e=>{this.movePosition(e[0])},isMobile:this.props.apiOptions.isMobile,mobileStyleOverride:n,showTooltips:this.props.showTooltips,xOnlyTooltip:!0})})),j(this,"handleReverse",(()=>{var e=Ag[this.props.rel];this.props.onChange({rel:e})})),j(this,"handleToggleStrict",(()=>{var e=Rg[this.props.rel];this.props.onChange({rel:e})})),j(this,"_getInequalityEndpoint",(e=>{var t=h(["ge","gt"]).contains(e.rel),r=e.range,i=30*((r[1]-r[0])/400),n=r[0]-i,o=r[1]+i;return t?[o,0]:[n,0]})),j(this,"_renderInequality",(e=>{if(e.isInequality){var t=this._getInequalityEndpoint(e),r={arrows:"->",stroke:this.props.apiOptions.isMobile?mr.INTERACTIVE:mr.DYNAMIC,strokeWidth:3.5},i=["ge","gt"].includes(e.rel);return a.createElement(Pg,{start:[(i?.4:-.4)+e.numLinePosition,0],end:t,style:r})}return null})),j(this,"_setupGraphie",((e,t)=>{if(this.isValid()){var r=this.props.apiOptions.isMobile?228:400,i=t.range,n=(i[1]-i[0])/r,o=30*n,s=i[0]-o,a=i[1]+o,l="improper"===this.props.labelStyle||"mixed"===this.props.labelStyle||"non-reduced"===this.props.labelStyle?-1.5:-1;e.init({range:[[s,a],[l,1]],scale:[1/n,40],isMobile:this.props.apiOptions.isMobile});var p=(i[0]+i[1])/2;e.line([p,0],[a,0],{arrows:"->"}),e.line([p,0],[s,0],{arrows:"->"})}})),j(this,"getUserInput",(()=>({numLinePosition:this.props.numLinePosition,rel:this.props.isInequality?this.props.rel:"eq",numDivisions:this.props.numDivisions,divisionRange:this.props.divisionRange}))),j(this,"simpleValidate",(e=>Bg.validate(this.getUserInput(),e)))}render(){var e,t,r=this.props.divisionRange,i=r[0]+"–"+r[1],n=this.props.numDivisions<r[0]||this.props.numDivisions>r[1],s=a.createElement("div",null,a.createElement("input",{type:"button",className:"simple-button",value:o._("Switch direction"),onClick:this.handleReverse}),a.createElement("input",{type:"button",className:"simple-button",value:h(["le","ge"]).contains(this.props.rel)?o._("Make circle open"):o._("Make circle filled"),onClick:this.handleToggleStrict}));this.props.isTickCtrl&&(t=this.props.apiOptions.customKeypad?Ss:this.props.apiOptions.staticRender?es:Lm,e=a.createElement("label",null,o._("Number of divisions:")," ",a.createElement(t,{ref:"tick-ctrl",value:this.state.numDivisionsEmpty?null:this.props.numDivisions||r[0],checkValidity:e=>e>=r[0]&&e<=r[1],onChange:this.onNumDivisionsChange,onFocus:this._handleTickCtrlFocus,onBlur:this._handleTickCtrlBlur,useArrowKeys:!0,keypadElement:this.props.keypadElement})));return a.createElement("div",{className:"perseus-widget perseus-widget-interactive-number-line"},e,this.isValid()?this.props.isTickCtrl&&n?a.createElement("div",{className:"perseus-error"},o.$_("Please make sure the number of divisions is in the range %(divRangeString)s.",{divRangeString:i})):this._renderGraphie():a.createElement("div",{className:"perseus-error"},o.doNotTranslate("Invalid number line configuration.")),!this.props.static&&this.props.isInequality&&s)}}j(Bg,"defaultProps",{range:[0,10],labelStyle:"decimal",labelRange:[null,null],divisionRange:[1,12],labelTicks:!0,isTickCtrl:!1,isInequality:!1,numLinePosition:0,snapDivisions:2,showTooltips:!1,rel:"ge",apiOptions:Zt.defaults}),h.extend(Bg,{validate:function(e,t){var r=t.range,i=e.divisionRange,n=null!=t.initialX?t.initialX:r[0],o=t.isInequality?"ge":"eq",s=t.correctRel||"eq",a=b.equal(e.numLinePosition,t.correctX||0),l=e.numDivisions>i[1]||e.numDivisions<i[0];return e.isTickCrtl&&l?{type:"invalid",message:"Number of divisions is outside the allowed range."}:a&&s===e.rel?{type:"points",earned:1,total:1,message:null}:e.numLinePosition===n&&e.rel===o?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}});var zg={name:"number-line",displayName:"Number line",widget:Bg,transform:e=>{var t,r=h.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isTickCtrl","isInequality","showTooltips"]),i=null!=e.initialX?e.initialX:e.range[0],n=e.range[1]-e.range[0];return t=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?n/e.tickStep:void 0,h.extend(r,{numLinePosition:i,numDivisions:t,snapDivisions:r.snapDivisions||void 0}),r},staticTransform:e=>{var t,r=h.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isInequality"]),i=null!=e.correctX?e.correctX:e.range[0],n=e.range[1]-e.range[0];return t=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?n/e.tickStep:void 0,h.extend(r,{numLinePosition:i,numDivisions:t,rel:e.isInequality?e.correctRel:null,snapDivisions:r.snapDivisions||void 0}),r}};class Hg extends a.Component{render(){return a.createElement("div",{className:"card-wrap "+Jt.INTERACTIVE,style:{width:this.props.width}},a.createElement("div",{className:"card placeholder",style:{height:this.props.height}}))}}j(Hg,"propTypes",{width:d.number.isRequired,height:d.number.isRequired});class Wg extends a.Component{render(){return a.createElement("div",{className:"card-wrap "+Jt.INTERACTIVE},a.createElement("div",{className:"card drag-hint"}))}}var qg=d.shape({left:d.number,top:d.number});class Ug extends a.Component{constructor(){super(...arguments),j(this,"mouseMoveUpBound",void 0),j(this,"state",{dragging:!1}),j(this,"bindMouseMoveUp",(()=>{this.mouseMoveUpBound=!0,y(document).on("mousemove",this.onMouseMove),y(document).on("mouseup",this.onMouseUp)})),j(this,"unbindMouseMoveUp",(()=>{this.mouseMoveUpBound=!1,y(document).off("mousemove",this.onMouseMove),y(document).off("mouseup",this.onMouseUp)})),j(this,"onMouseDown",(e=>{e.preventDefault();var t=De.extractPointerLocation(e);t&&(this.setState({dragging:!0}),this.bindMouseMoveUp(),this.props.onMouseDown&&this.props.onMouseDown(t,this))})),j(this,"onMouseMove",(e=>{if(this.state.dragging){e.preventDefault();var t=De.extractPointerLocation(e);t&&this.props.onMouseMove&&this.props.onMouseMove(t)}})),j(this,"onMouseUp",(e=>{e.preventDefault();var t=De.extractPointerLocation(e);t&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp&&this.props.onMouseUp(t))}))}render(){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 r=h.pick(this.props,"content"),i=this.props.animating?y.noop:this.onMouseDown;return a.createElement("div",{className:"card-wrap "+Jt.INTERACTIVE,style:e,onMouseDown:i,onTouchStart:i,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},a.createElement("div",{className:t.join(" ")},a.createElement(Bo,Y({},r,{linterContext:this.props.linterContext}))))}shouldComponentUpdate(e,t){return this.props.floating||e.floating||this.props.content!==e.content||this.props.fakeRef!==e.fakeRef}componentDidMount(){this.mouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!De.supportsPassiveEvents()&&{passive:!1})}componentDidUpdate(e,t){if(this.props.animating&&!e.animating){var r=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)));y(v.findDOMNode(this)).animate(this.props.animateTo,Math.max(r,1),this.props.onAnimationEnd)}}componentWillUnmount(){this.mouseMoveUpBound&&(he.error("Removing an element with bound event handlers.",pe.Internal),this.unbindMouseMoveUp(),De.resetTouchHandlers()),document.removeEventListener("touchmove",this.onMouseMove)}}j(Ug,"propTypes",{floating:d.bool.isRequired,animating:d.bool,width:d.number,stack:d.bool,onMouseDown:d.func,onMouseMove:d.func,onMouseUp:d.func,startMouse:qg,startOffset:qg,animateTo:qg,onAnimationEnd:d.func,linterContext:Gt}),j(Ug,"defaultProps",{stack:!1,animating:!1,linterContext:Vt});class Gg extends a.Component{constructor(){super(...arguments),j(this,"state",{current:[],dragging:!1,placeholderIndex:null,dragKey:null,animating:!1,dragContent:null,dragWidth:null,dragHeight:null,offsetPos:null,animateTo:null,grabPos:null}),j(this,"onClick",((e,t,r,i)=>{var n,o=y(v.findDOMNode(i)),s=this.state.current.slice(),a=null;"current"===e?(s.splice(t,1),n=this.state.current[t],a=t):"bank"===e&&(n=this.props.options[t]),this.setState({current:s,dragging:!0,placeholderIndex:a,dragKey:n.key,dragContent:n.content,dragWidth:o.width(),dragHeight:o.height(),grabPos:r,mousePos:r,offsetPos:o.position()})})),j(this,"onRelease",(e=>{var t=this.refs.dragging;if(null!=t){var r=this.isCardInBank(t),i=this.state.placeholderIndex||0,n=()=>{var e=this.state.current.slice();if(!r){var t={content:this.state.dragContent,key:h.uniqueId("perseus_draggable_card_"),width:this.state.dragWidth};e.splice(i,0,t)}this.props.onChange({current:e}),this.setState({current:e,dragging:!1,placeholderIndex:null,animating:!1}),this.props.trackInteraction()},o=y(v.findDOMNode(t)).position(),s=null;r?h.each(this.props.options,(function(e,t){if(e.content===this.state.dragContent){var r=v.findDOMNode(this.refs["bank"+t]);s=y(r).position()}}),this):null!=this.refs.placeholder&&(s=y(v.findDOMNode(this.refs.placeholder)).position()),null==s?n():this.setState({offsetPos:o,animateTo:s,onAnimationEnd:n,animating:!0,dragging:!1})}})),j(this,"onMouseMove",(e=>{var t,r=this.refs.dragging;null!=r&&(t=this.isCardInBank(r)?null:this.findCorrectIndex(r,this.state.current),this.setState({mousePos:e,placeholderIndex:t}))})),j(this,"findCorrectIndex",((e,t)=>{var r="horizontal"===this.props.layout,i=y(v.findDOMNode(this.refs.dragList)),n=i.offset().left,o=i.offset().top,s=y(v.findDOMNode(e)).offset().left-n,a=y(v.findDOMNode(e)).offset().top-o,l=0,p=0,c=0;return r?h.each(t,(function(e,t){var r=v.findDOMNode(this.refs["sortable"+t]),i=y(r).outerWidth(!0);s>p+i/2&&(l+=1),p+=i}),this):h.each(t,(function(e,t){var r=v.findDOMNode(this.refs["sortable"+t]),i=y(r).outerHeight(!0);a>c+i/2&&(l+=1),c+=i}),this),l})),j(this,"isCardInBank",(e=>{if(null==e)return!1;var t="horizontal"===this.props.layout,r=y(v.findDOMNode(e)),i=y(v.findDOMNode(this.refs.bank)),n=r.offset(),o=i.offset(),s=r.outerHeight(!0),a=i.outerHeight(!0),l=i.outerWidth(!0),p=v.findDOMNode(this.refs.dragList);y(p).width();var h=r.outerWidth(!0);return t?n.top+s/2<o.top+a:n.left+h/2<o.left+l})),j(this,"setListValues",(e=>{var t=e.map((e=>({content:e})));this.props.onChange({current:t}),this.setState({current:t})})),j(this,"getUserInput",(()=>({current:h.map(this.props.current,(function(e){return e.content}))}))),j(this,"simpleValidate",(e=>Gg.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){h.isEqual(this.props.current,e.current)||this.setState({current:e.current})}render(){var e=this.state.dragging&&a.createElement(Ug,{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",linterContext:this.props.linterContext}),t=this.state.animating&&a.createElement(Ug,{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",linterContext:this.props.linterContext}),r=h.map(this.state.current,(function(e,t){return a.createElement(Ug,{key:"sortableCard".concat(t),ref:"sortable"+t,fakeRef:"sortable"+t,floating:!1,content:e.content,width:e.width,linterContext:this.props.linterContext,onMouseDown:this.state.animating?y.noop:this.onClick.bind(null,"current",t)})}),this);if(null!=this.state.placeholderIndex){var i=a.createElement(Hg,{ref:"placeholder",width:this.state.dragWidth,height:this.state.dragHeight,key:"placeholder"});r.splice(this.state.placeholderIndex,0,i)}var n=r.length>0;r.push(e,t);var o=a.createElement("div",{className:"perseus-clearfix draggable-box"},!n&&a.createElement(Wg,null),a.createElement("div",{ref:"dragList"},r)),s=a.createElement("div",{ref:"bank",className:"bank perseus-clearfix"},h.map(this.props.options,((e,t)=>a.createElement(Ug,{ref:"bank"+t,floating:!1,content:e.content,stack:!0,key:t,linterContext:this.props.linterContext,onMouseDown:this.state.animating?y.noop:this.onClick.bind(null,"bank",t),onMouseMove:this.onMouseMove,onMouseUp:this.onRelease})),this));return a.createElement("div",{className:"draggy-boxy-thing orderer height-"+this.props.height+" layout-"+this.props.layout+" above-scratchpad blank-background perseus-clearfix "+Jt.INTERACTIVE,ref:"orderer"},s,o)}}j(Gg,"defaultProps",{current:[],options:[],correctOptions:[],height:"normal",layout:"horizontal",linterContext:Vt}),h.extend(Gg,{validate:function(e,t){return 0===e.current.length?{type:"invalid",message:null}:{type:"points",earned:h.isEqual(e.current,h.pluck(t.correctOptions,"content"))?1:0,total:1,message:null}}});var Vg={name:"orderer",displayName:"Orderer",widget:Gg,isLintable:!0};class jg extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"getUserInput",(()=>Ls.getUserInput.call(this))),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"simpleValidate",(e=>jg.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){return a.createElement(Bo,{content:this.props.content,inline:!0,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext})}}j(jg,"propTypes",G(G({},fs),{},{content:d.string,linterContext:Gt})),j(jg,"defaultProps",{content:"",linterContext:Vt});var Yg={name:"passage-ref-target",displayName:"PassageRefTarget",defaultAlignment:"inline",widget:jg,hidden:!0,transform:e=>h.pick(e,"content"),version:{major:0,minor:0},isLintable:!0};function $g(e,t,r,i){var n;return n="start"===t&&"start"===i?Range.START_TO_START:"start"===t&&"end"===i?Range.END_TO_START:"end"===t&&"start"===i?Range.START_TO_END:Range.END_TO_END,e.compareBoundaryPoints(n,r)}function Xg(e,t){var r=e.cloneRange();return r.setEnd(t.endContainer,t.endOffset),r}function Kg(e,t){return!($g(e,"end",t,"start")<0||$g(t,"end",e,"start")<0)}function Zg(e,t,r,i,n){for(var o=-1,s=i,a=n,l=0;s<=a;){if(++l>2*t.length)throw new Error("Assertion error: Binary search isn't terminating? "+"lower=".concat(s,", upper=").concat(a));var p=Math.floor((s+a)/2);if("first"===r)$g(t[p],"end",e,"start")<=0?s=p+1:(o=p,a=p-1);else $g(t[p],"start",e,"end")>=0?a=p-1:(o=p,s=p+1)}return o}function Jg(e,t){var r,i,n={},o=t.domRange,s=t.firstWordIndex,a=t.lastWordIndex;for(var l of Object.keys(e)){var p=e[l],h=Kg(r=p.domRange,i=o)?Xg($g(r,"start",i,"start")<0?r:i,$g(r,"end",i,"end")>0?r:i):null;h?(o=h,s=Math.min(p.firstWordIndex,s),a=Math.max(p.lastWordIndex,a)):n[l]=p}var c={firstWordIndex:s,lastWordIndex:a,domRange:o},d=function(e){var t="".concat((new Date).getTime());if(!e.includes(t))return t;var r,i=0;do{r="".concat(t,"-").concat(i),i++}while(e.includes(r));return r}(Object.keys(n));return n[d]=c,n}function Qg(e,t,r){for(var i of Object.keys(e)){var n=e[i].domRange;if($g(o=n,"start",s=r,"start")<=0&&$g(o,"end",s,"end")>=0)return null}var o,s,a=function(e,t){var r=Zg(e,t,"first",0,t.length-1);if(r<0)return null;var i=Zg(e,t,"last",r,t.length-1);return i<0?null:[r,i]}(r,t);if(!a)return null;var[l,p]=a;return{firstWordIndex:l,lastWordIndex:p,domRange:Xg(t[l],t[p])}}function ef(e,t){var{firstWordIndex:r,lastWordIndex:i}=e.range,n=t[r];if(!n)throw new ce("first word index ".concat(n," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),pe.InvalidInput,{metadata:{firstWord:n,wordRanges:JSON.stringify(t)}});var o=t[i];if(!o)throw new ce("last word index ".concat(o," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),pe.InvalidInput,{metadata:{lastWord:o,wordRanges:JSON.stringify(t)}});return{firstWordIndex:r,lastWordIndex:i,domRange:Xg(n,o)}}function tf(e){var{firstWordIndex:t,lastWordIndex:r}=e;return{range:{type:"word-indexes",firstWordIndex:t,lastWordIndex:r}}}function rf(e,t){return{left:e.left-t.left,top:e.top-t.top}}function nf(e,t){var{left:r,top:i,width:n,height:o}=e;return G(G({},rf({left:r,top:i},t)),{},{width:n,height:o})}function of(e){var t=[];return sf(e.commonAncestorContainer,e,t),t}function sf(e,t,r){var i,n,o=new Range;if(o.selectNodeContents(e),e.nodeType===Node.TEXT_NODE){var s=Kg(i=t,n=o)?Xg($g(i,"start",n,"start")>0?i:n,$g(i,"end",n,"end")<0?i:n):null;s&&function(e,t,r){var i=e.parentElement,n=window.getComputedStyle(i),o=null;if("string"==typeof n.lineHeight&&n.lineHeight.endsWith("px")){var s=parseFloat(n.lineHeight);isNaN(s)||(o=s)}var a=Array.from(t.getClientRects());for(var l of a){var p={left:l.left,top:l.top,height:l.height,width:l.width};if(null!==o){var h=o-p.height;p.top-=h,p.height=o}r.push(p)}}(e,s,r)}else if(e.nodeType===Node.ELEMENT_NODE){if(!Kg(t,o))return;for(var a of Array.from(e.childNodes))sf(a,t,r)}}class af extends a.PureComponent{constructor(){super(...arguments),j(this,"state",{cachedHighlightRects:this._computeRects(this.props),tooltipIsHovered:!1})}UNSAFE_componentWillReceiveProps(e){this.props.highlight===e.highlight&&this.props.offsetParent===e.offsetParent||this.setState({cachedHighlightRects:this._computeRects(e)})}_computeRects(e){var{highlight:t,offsetParent:r}=e,i=of(t.domRange),{left:n,top:o}=r.getBoundingClientRect();return i.map((e=>nf(e,{left:n,top:o})))}_rectIsHovered(e,t){var r=rf(t,{left:e.left,top:e.top});return 0<=r.left&&r.left<e.width&&0<=r.top&&r.top<e.height}isHovered(e){if(!e)return!1;var{offsetParent:t}=this.props,{cachedHighlightRects:r}=this.state,{left:i,top:n}=t.getBoundingClientRect(),o=rf(e,{left:i,top:n});return r.some((e=>this._rectIsHovered(e,o)))}render(){var e=this.state.cachedHighlightRects;return a.createElement("div",null,e.map(((e,t)=>a.createElement("div",{key:t,className:g(lf.highlightRect),style:{position:"absolute",width:e.width,height:e.height,top:e.top,left:e.left,zIndex:this.props.zIndexes.belowContent}}))))}}var lf=m.create({highlightRect:{background:"#fffabe"}});class pf extends a.PureComponent{constructor(){super(...arguments),j(this,"_tooltip",void 0)}componentDidUpdate(e){var t;this.props.focusNode===e.focusNode&&this.props.focusOffset===e.focusOffset&&this.props.offsetParent===e.offsetParent||(null===(t=this._tooltip)||void 0===t||t.remeasure())}_getFocusRect(){var{focusNode:e,focusOffset:t,offsetParent:r}=this.props,i=document.createRange();i.setStart(e,t),i.setEnd(e,t);var n=i.getClientRects()[0];if(!n)return he.log('[Highlighting] Known bug: Could not determine the focus position, so did not show an "Add Highlight" tooltip. https://app.asana.com/0/329800276300868/413878480039713 (see also /r/asana-links)'),null;var{left:o,top:s}=r.getBoundingClientRect();return nf({left:n.left,top:n.top,width:n.width,height:n.height},{left:o,top:s})}render(){var e=this._getFocusRect();if(!e)return null;var t=a.createElement("div",{className:g(hf.tooltipLabel)},this.props.label);return a.createElement(Cl,{content:t,color:el.kaBlue,inverted:!0,onClick:this.props.onClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,toggleOnHover:!1,showOnMount:!0,ref:e=>this._tooltip=e},a.createElement("div",{style:{position:"absolute",left:e.left,top:e.top,height:e.height}}))}}var hf=m.create({tooltipLabel:{userSelect:"none"}});class cf extends a.PureComponent{constructor(){super(...arguments),j(this,"state",{hoveredHighlightKey:null,hoveringTooltipFor:null}),j(this,"_highlightRenderers",{}),j(this,"_handleMouseMove",(e=>{var t={left:e.clientX,top:e.clientY},r=this._getHoveredHighlightKey(t);this.setState({hoveredHighlightKey:r})}))}componentDidMount(){this._updateEditListeners(!1,this.props.editable)}UNSAFE_componentWillReceiveProps(e){this._updateEditListeners(this.props.editable,e.editable),null==this.state.hoveredHighlightKey||this.state.hoveredHighlightKey in e.highlights||this.setState({hoveredHighlightKey:null}),null==this.state.hoveringTooltipFor||this.state.hoveringTooltipFor in e.highlights||this.setState({hoveringTooltipFor:null})}componentWillUnmount(){this._updateEditListeners(this.props.editable,!1)}_updateEditListeners(e,t){!e&&t?window.addEventListener("mousemove",this._handleMouseMove):e&&!t&&(window.removeEventListener("mousemove",this._handleMouseMove),this.setState({hoveredHighlightKey:null,hoveringTooltipFor:null}))}_getHoveredHighlightKey(e){var{hoveringTooltipFor:t}=this.state;return"string"==typeof t?t:Object.keys(this.props.highlights).find((t=>{var r=this._highlightRenderers[t];return r&&r.isHovered(e)}))}_renderTooltip(){var{hoveredHighlightKey:e}=this.state;if(null==e)return null;var t=this.props.highlights[e];return a.createElement(pf,{label:o._("Remove highlight"),focusNode:t.domRange.endContainer,focusOffset:t.domRange.endOffset,offsetParent:this.props.offsetParent,onClick:()=>this.props.onRemoveHighlight(e),onMouseEnter:()=>this.setState({hoveringTooltipFor:e}),onMouseLeave:()=>this.setState({hoveringTooltipFor:null})})}render(){return a.createElement("div",null,Object.keys(this.props.highlights).map((e=>a.createElement(af,{ref:t=>{t?this._highlightRenderers[e]=t:delete this._highlightRenderers[e]},key:e,highlight:this.props.highlights[e],highlightKey:e,offsetParent:this.props.offsetParent,zIndexes:this.props.zIndexes}))),this.props.editable&&this._renderTooltip())}}class df extends a.PureComponent{constructor(){super(...arguments),j(this,"state",{mouseState:"up",trackedSelection:null}),j(this,"_handleSelectionChange",(()=>{this._updateTrackedSelection(this.props.buildHighlight),"down"===this.state.mouseState&&this.setState({mouseState:"down-and-selecting"})})),j(this,"_handleMouseDown",(()=>{this.setState({mouseState:"down"})})),j(this,"_handleMouseUp",(()=>{this.setState({mouseState:"up"})}))}componentDidMount(){this._updateListeners(!1,this.props.enabled)}UNSAFE_componentWillReceiveProps(e){this.props.buildHighlight!==e.buildHighlight&&this._updateTrackedSelection(e.buildHighlight),this._updateListeners(this.props.enabled,e.enabled)}componentWillUnmount(){this._updateListeners(this.props.enabled,!1)}_updateListeners(e,t){!e&&t?(window.addEventListener("mousedown",this._handleMouseDown),window.addEventListener("mouseup",this._handleMouseUp),document.addEventListener("selectionchange",this._handleSelectionChange)):e&&!t&&(window.removeEventListener("mousedown",this._handleMouseDown),window.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("selectionchange",this._handleSelectionChange),this.setState({mouseState:"up",trackedSelection:null}))}_computeFocusAndRange(){var e=document.getSelection();if(!e||0===e.rangeCount)return null;var t=e.getRangeAt(0);return t.collapsed?null:{focusNode:e.focusNode,focusOffset:e.focusOffset,range:t}}_computeTrackedSelection(e){var t=this._computeFocusAndRange();if(!t)return null;var{focusNode:r,focusOffset:i,range:n}=t,o=e(n);return o?{focusNode:r,focusOffset:i,proposedHighlight:o}:null}_updateTrackedSelection(e){var t=this._computeTrackedSelection(e);this.setState({trackedSelection:t})}render(){var{mouseState:e,trackedSelection:t}=this.state,r="down-and-selecting"===e;return this.props.children?a.createElement("div",null,this.props.children(t,r)):null}}class uf extends a.PureComponent{_handleAddHighlight(e){this.props.onAddHighlight(e);var t=document.getSelection();t&&t.collapseToEnd()}_selectionIsValid(e){if(!e)return!1;var{contentNode:t}=this.props,r=new Range;r.selectNodeContents(t);var i=new Range;return i.setStart(e.focusNode,e.focusOffset),i.collapse(!0),Kg(r,i)}render(){return a.createElement(df,{buildHighlight:this.props.buildHighlight,enabled:this.props.editable},((e,t)=>a.createElement("div",null,a.createElement(cf,{editable:this.props.editable&&!this._selectionIsValid(e),highlights:this.props.highlights,offsetParent:this.props.offsetParent,onRemoveHighlight:this.props.onRemoveHighlight,zIndexes:this.props.zIndexes}),this._selectionIsValid(e)&&!t&&a.createElement(pf,{label:o._("Add highlight"),onClick:()=>this._handleAddHighlight(e.proposedHighlight),focusNode:e.focusNode,focusOffset:e.focusOffset,offsetParent:this.props.offsetParent}))))}}class mf extends a.PureComponent{constructor(){super(...arguments),j(this,"_container",void 0)}componentDidMount(){this._sendWordsUpdate()}componentDidUpdate(){this._sendWordsUpdate()}_sendWordsUpdate(){this.props.onWordsUpdate(this._getWordRanges())}_getWordRanges(){var e=this._container;if(!e)throw new ce("invariant violation: `this._container` is not defined, but this method is only called after mount/update",pe.NotAllowed);for(var t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,(()=>NodeFilter.FILTER_ACCEPT),!1),r=[],i=null;t.nextNode();){var n=t.currentNode;if(n.nodeType===Node.ELEMENT_NODE)"inline"!==getComputedStyle(n).display&&(i=null);else if(n.nodeType===Node.TEXT_NODE){for(var o=n.nodeValue,s=/\S+/g,a=void 0,l=null;null!==(a=s.exec(o));){var p=a.index,h=a.index+a[0].length,c=void 0;0===p&&i?(c=i).setEnd(n,h):((c=n.ownerDocument.createRange()).setStart(n,p),c.setEnd(n,h),r.push(c)),h===o.length&&(l=c)}i=l}}return r}render(){return a.createElement("div",{ref:e=>this._container=e},this.props.children)}}class gf extends a.PureComponent{constructor(){super(...arguments),j(this,"_container",void 0),j(this,"_content",void 0),j(this,"state",{wordRanges:[]}),j(this,"_handleAddHighlight",(e=>{var t=Jg(this._getDOMHighlights(),e),r={};for(var i of Object.keys(t))r[i]=tf(t[i]);this.props.onSerializedHighlightsUpdate(r)})),j(this,"_handleRemoveHighlight",(e=>{var{serializedHighlights:t}=this.props,r=G({},t);delete r[e],this.props.onSerializedHighlightsUpdate(r)})),j(this,"_handleWordsUpdate",(e=>{this.setState({wordRanges:e})}))}_buildHighlight(e){return Qg(this._getDOMHighlights(),this.state.wordRanges,e)}_getDOMHighlights(){var{serializedHighlights:e}=this.props,{wordRanges:t}=this.state,r={};for(var i of Object.keys(e))r[i]=ef(e[i],t);return r}render(){var e=this._getDOMHighlights();return a.createElement("div",{className:g(ff.container),ref:e=>this._container=e},a.createElement("div",null,this.props.enabled&&this._container&&this._content&&a.createElement(uf,{buildHighlight:e=>this._buildHighlight(e),contentNode:this._content,editable:this.props.editable,highlights:e,offsetParent:this._container,zIndexes:{belowContent:0},onAddHighlight:this._handleAddHighlight,onRemoveHighlight:this._handleRemoveHighlight})),a.createElement("div",{className:g(ff.content),ref:e=>this._content=e},a.createElement(mf,{onWordsUpdate:this._handleWordsUpdate},this.props.children)))}}var ff=m.create({container:{position:"relative",zIndex:0},content:{position:"relative",zIndex:1}}),vf={display:"inline-block",width:0,visibility:"hidden"},yf={display:"inline",whiteSpace:"nowrap"},bf={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",paddingLeft:10,paddingRight:10,userSelect:"none",WebkitUserSelect:"none"},xf={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"};class wf extends a.Component{constructor(){super(...arguments),j(this,"getRefContent",(()=>this.props.refContent))}render(){return a.createElement("span",{style:vf},o.doNotTranslate("_"))}}j(wf,"propTypes",{refContent:d.node.isRequired});class Cf extends a.Component{render(){return a.createElement("span",{style:vf},o.doNotTranslate("_"))}}var kf={newline:u.defaultRules.newline,paragraph:u.defaultRules.paragraph,escape:u.defaultRules.escape,passageFootnote:{order:u.defaultRules.escape.order+.1,match:u.inlineRegex(/^\^/),parse:(e,t,r)=>{var i=r.lastFootnote.id+1,n={id:i,text:1===i?"*":""+i};return"*"===r.lastFootnote.text&&(r.lastFootnote.text=""+r.lastFootnote.id),r.lastFootnote=n,n},react:(e,t,r)=>a.createElement("sup",{key:r.key},e.text)},refStart:{order:u.defaultRules.escape.order+.2,match:function(e,t){var r=/^\{\{/.exec(e);if(r){for(var i=2,n=0;i<e.length;){var o=e.slice(i,i+2);if("{{"===o)n++,i++;else if("}}"===o){if(!(n>0))break;n--,i++}i++}var s=e.slice(2,i);return[r[0],s]}return null},parse:(e,t,r)=>{if(!r.useRefs)return{ref:null,refContent:null};var i=r.lastRef+1;return r.lastRef=i,r.currentRef.push(i),{ref:i,refContent:t("(“"+e[1]+"”)\n\n",h.defaults({useRefs:!1},Ef))}},react:(e,t,r)=>{if(null==e.ref)return null;var i=t(e.refContent,{});return a.createElement(wf,{ref:"start-ref-"+e.ref,key:"start-ref-"+e.ref,refContent:i})}},refEnd:{order:u.defaultRules.escape.order+.3,match:u.inlineRegex(/^\}\}/),parse:(e,t,r)=>r.useRefs?{ref:r.currentRef.pop()||null}:{ref:null},react:(e,t,r)=>null!=e.ref?a.createElement(Cf,{ref:"end-ref-"+e.ref,key:"end-ref-"+e.ref}):null},squareLabel:{order:u.defaultRules.escape.order+.4,match:u.inlineRegex(/^\[\[(\w+)\]\]( *)/),parse:(e,t,r)=>(r.firstQuestionRef||(r.firstQuestionRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,r)=>[a.createElement("span",{key:"visual-square",className:"perseus-passage-square-label",style:yf,"aria-hidden":"true"},a.createElement("span",{style:bf},e.content)),a.createElement("span",{key:"alt-text",className:"perseus-sr-only"},o.$_("[Marker for question %(number)s]",{number:e.content})),e.space?" ":null]},circleLabel:{order:u.defaultRules.escape.order+.5,match:u.inlineRegex(/^\(\((\w+)\)\)( *)/),parse:(e,t,r)=>({content:e[1],space:e[2].length>0}),react:(e,t,r)=>[a.createElement("span",{key:"visual-circle",className:"perseus-passage-circle-label",style:yf,"aria-hidden":!0},a.createElement("span",{style:xf},e.content)),a.createElement("span",{key:"alt-text",className:"perseus-sr-only"},o.$_("[Circle marker %(number)s]",{number:e.content})),e.space?" ":null]},squareBracketRef:{order:u.defaultRules.escape.order+.6,match:u.inlineRegex(/^\[(\d+)\]( *)/),parse:(e,t,r)=>(r.firstSentenceRef||(r.firstSentenceRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,r)=>[a.createElement("span",{key:"visual-brackets",className:"perseus-passage-bracket-label","aria-hidden":"true"},"[",e.content,"]"),a.createElement("span",{key:"alt-text",className:"perseus-sr-only"},o.$_("[Sentence %(number)s]",{number:e.content})),e.space?" ":null]},highlight:{order:u.defaultRules.escape.order+.7,match:u.inlineRegex(/^{highlighting.start}(.+?){highlighting.end}/),parse:(e,t,r)=>({content:e[1]}),react:(e,t,r)=>[a.createElement("span",{key:0,className:"perseus-highlight"},e.content)]},reviewHighlight:{order:u.defaultRules.escape.order+.7,match:u.inlineRegex(/^{review-highlighting.start}(.+?){review-highlighting.end}/),parse:(e,t,r)=>({content:e[1]}),react:(e,t,r)=>[a.createElement("span",{key:0,className:"perseus-review-highlight"},e.content)]},strong:u.defaultRules.strong,u:u.defaultRules.u,em:u.defaultRules.em,del:u.defaultRules.del,text:G(G({},u.defaultRules.text),{},{react:(e,t,r)=>a.createElement("span",{key:r.key},e.content)})},Ef={currentRef:[],useRefs:!0,lastRef:0,lastFootnote:{id:0,text:""}},Sf=u.parserFor(kf),_f={parse:(e,t)=>(t=t||{},Sf(e+"\n\n",h.extend(t,Ef))),output:u.reactFor(u.ruleOutput(kf,"react")),START_REF_PREFIX:"start-ref-",END_REF_PREFIX:"end-ref-",_rulesForTesting:kf};class Mf extends a.Component{constructor(){super(...arguments),j(this,"_cachedLineHeight",void 0),j(this,"$body",void 0),j(this,"$end",void 0)}measureLineHeight(){return"number"!=typeof this._cachedLineHeight&&this.forceMeasureLineHeight(),this._cachedLineHeight}forceMeasureLineHeight(){var e;this.$body.text(" €"),this._cachedLineHeight=(e=this.$body,this.$end.offset().top-e.offset().top),this.$body.text("")}render(){return a.createElement("div",{className:g(Tf.measurer)},a.createElement("div",null,a.createElement("div",{ref:e=>this.$body=y(e),className:"paragraph"}),a.createElement("div",{ref:e=>this.$end=y(e)})))}}var Tf=m.create({measurer:{position:"absolute",width:"100%",top:0,left:0}});class If extends a.Component{constructor(){super(...arguments),j(this,"_onResize",void 0),j(this,"_lineHeightMeasurer",void 0),j(this,"_stylesAppiedTimer",void 0),j(this,"state",{nLines:null,startLineNumbersAfter:0,stylesAreApplied:!1}),j(this,"_handleSerializedHighlightsUpdate",(e=>{this.props.onChange({highlights:e})}))}componentDidMount(){this._updateState(),this._onResize=h.throttle((()=>{this.shouldRenderJipt()||(this._lineHeightMeasurer.forceMeasureLineHeight(),this._updateState())}),500),window.addEventListener("resize",this._onResize),this._stylesAppiedTimer=window.setTimeout((()=>{this.setState({stylesAreApplied:!0})}),0)}shouldComponentUpdate(e,t){return!h.isEqual(this.props,e)||!h.isEqual(this.state,t)}componentDidUpdate(){this._updateState()}componentWillUnmount(){window.removeEventListener("resize",this._onResize),clearTimeout(this._stylesAppiedTimer)}_updateState(){this.shouldRenderJipt()||this.setState({nLines:this._measureLines(),startLineNumbersAfter:this._getInitialLineNumber()})}_measureLines(){var e=y(v.findDOMNode(this.refs.content)).height(),t=this._getLineHeight();return Math.round(e/t)}_getInitialLineNumber(){var e=!0;return this.props.findWidgets(((t,r)=>"passage"===r.type&&(t===this.props.widgetId&&(e=!1),e))).map((e=>e.getLineCount())).reduce(((e,t)=>e+t),0)}_getLineHeight(){return this._lineHeightMeasurer.measureLineHeight()}getLineCount(){return null!=this.state.nLines?this.state.nLines:this._measureLines()}_getStartRefLineNumber(e){var t=_f.START_REF_PREFIX+e,r=this.refs[t];if(!r)return null;var i=y(v.findDOMNode(r)),n=i.next();0===n.length&&(n=i);var o=n.offset().top;return this.state.startLineNumbersAfter+1+this._convertPosToLineNumber(o)}_getEndRefLineNumber(e){var t=_f.END_REF_PREFIX+e,r=this.refs[t];if(!r)return null;var i=y(v.findDOMNode(r)),n=i.prev();0===n.length&&(n=i);var o=n.height(),s=n.offset().top,a=this._convertPosToLineNumber(s+o);return 0===o&&(a+=1),this.state.startLineNumbersAfter+a}_convertPosToLineNumber(e){var t=e-y(v.findDOMNode(this.refs.content)).offset().top,r=this._getLineHeight();return Math.round(t/r)}_getRefContent(e){var t=_f.START_REF_PREFIX+e,r=this.refs[t];return r?r.getRefContent():null}getReference(e){var t=this._getStartRefLineNumber(e),r=this._getEndRefLineNumber(e);return null==t||null==r?null:{startLine:t,endLine:r,content:this._getRefContent(e)}}getUserInput(){return null}simpleValidate(e){return If.validate(this.getUserInput(),e)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}_renderInstructions(e){var t=e.firstQuestionRef,r=e.firstSentenceRef,i="";t&&(i+=o._("The symbol %(questionSymbol)s indicates that question %(questionNumber)s references this portion of the passage.",{questionSymbol:"[["+t+"]]",questionNumber:t})),r&&(i+=o._(" The symbol %(sentenceSymbol)s indicates that the following sentence is referenced in a question.",{sentenceSymbol:"["+r+"]"}));var n=_f.parse(i);return a.createElement("div",{className:"perseus-widget-passage-instructions"},_f.output(n))}shouldRenderJipt(){var{JIPT:e}=ae();return e.useJIPT&&-1!==this.props.passageText.indexOf("crwdns")}_renderContent(e){var t=this.state.stylesAreApplied,r=!this.props.reviewModeRubric;return a.createElement(gf,{editable:r,enabled:t,onSerializedHighlightsUpdate:this._handleSerializedHighlightsUpdate,serializedHighlights:this.props.highlights},a.createElement("div",{ref:"content"},a.createElement(Mf,{ref:e=>this._lineHeightMeasurer=e}),_f.output(e)))}_hasFootnotes(){var e=this.props.footnotes;return!/^\s*$/.test(e)}_renderFootnotes(){var e=this.props.footnotes,t=_f.parse(e);return _f.output(t)}render(){var e,t=this.state.nLines;this.props.showLineNumbers&&t&&(e=h.range(1,t+1).map((e=>{var t=e+this.state.startLineNumbersAfter;if(4===t){var r=o._("Line ");return a.createElement("span",{key:"line-marker",className:"line-marker"},r)}return a.createElement("span",{key:e},t)})));var r={firstSentenceRef:null,firstQuestionRef:null},i=this.props.passageText.replace(/("{1})([^"]*)("{1})/g,"“$2”"),n=_f.parse(i,r),s=/\S/.test(this.props.passageTitle);return a.createElement("div",null,a.createElement("div",{className:"perseus-widget-passage-container"},this._renderInstructions(r),a.createElement("div",{className:"perseus-widget-passage"},s&&a.createElement("h3",{className:"passage-title"},a.createElement(Bo,{content:this.props.passageTitle,linterContext:this.props.linterContext})),e&&a.createElement("div",{className:"line-numbers","aria-hidden":!0},e),!s&&a.createElement("h3",{className:"perseus-sr-only"},o._("Beginning of reading passage.")),a.createElement("div",{className:"passage-text"},this.shouldRenderJipt()?a.createElement(Bo,{content:this.props.passageText}):this._renderContent(n)),this._hasFootnotes()&&[a.createElement("h4",{key:"footnote-start",className:"perseus-sr-only"},o._("Beginning of reading passage footnotes.")),a.createElement("div",{key:"footnotes",className:"footnotes"},this._renderFootnotes())],a.createElement("div",{className:"perseus-sr-only"},o._("End of reading passage.")))))}}j(If,"defaultProps",{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0,highlights:{},linterContext:Vt});var Pf={name:"passage",displayName:"Passage (SAT only)",widget:If,transform:e=>h.pick(e,"passageTitle","passageText","footnotes","showLineNumbers"),isLintable:!0},{deepEq:Nf}=De;d.oneOf(["bar","line","pic","histogram","dotplot"]),d.arrayOf(d.string),d.arrayOf(d.oneOfType([d.number,d.string])),d.number,d.number,d.number,d.number,d.number,d.string,d.arrayOf(d.number),d.number,d.arrayOf(d.number),d.bool;class Af extends a.Component{constructor(){super(...arguments),j(this,"shouldSetupGraphie",void 0),j(this,"_isMounted",!1),j(this,"horizHairline",void 0),j(this,"hairlineRange",void 0),j(this,"graphie",void 0),j(this,"state",{values:this.props.starting||[1],categoryHeights:{}}),j(this,"DOT_PLOT_POINT_SIZE",(()=>this.props.apiOptions.isMobile?6:4)),j(this,"DOT_PLOT_POINT_PADDING",(()=>8)),j(this,"DOT_TICK_POINT_SIZE",(()=>2)),j(this,"setupGraphie",(e=>{var t=this;t.shouldSetupGraphie=!1;var r=v.findDOMNode(t.refs.graphieDiv);y(r).empty();var i=Cr.createGraphie(r);t.graphie=i,t.graphie.pics=[],t.graphie.dotTicks=[];var n="bar"===t.props.type,s="line"===t.props.type,a="pic"===t.props.type,l="histogram"===t.props.type,p="dotplot"===t.props.type,c=a||p,d={},u=d,m=this.props.apiOptions.isMobile;u.graph={lines:[],bars:[],points:[],dividers:[]},u.scaleY=t.props.scaleY,u.dimX=t.props.categories.length;var g=m?[288,336]:t.props.plotDimensions;if(s)u.dimX+=m?-.2:1;else if(l)u.barPad=0,u.barWidth=1;else if(n)u.barPad=m?.08:.15,u.barWidth=1-2*u.barPad,u.dimX+=(m?-2:2)*u.barPad;else if(c){u.picBoxHeight=t.props.picBoxHeight,u.picBoxWidthPx=g[0]/t.props.categories.length;var f=g[0]-u.dimX*u.picBoxWidthPx;u.picPad=f/(2*u.dimX+2);var b=u.picBoxWidthPx+2*u.picPad;u.picPad=u.picPad/b,u.picBoxWidth=u.picBoxWidthPx/b,u.dimX+=2*u.picPad}p&&(u.picBoxHeight=2*this.DOT_PLOT_POINT_SIZE()+this.DOT_PLOT_POINT_PADDING()),u.dimY=Math.ceil(t.props.maxY/u.scaleY)*u.scaleY;var x=25;(n||s)&&m&&(x=0!==t.props.labels[1].length?17:11),p&&(x/=2),m&&c&&0===t.props.labels[1].length&&(x=0);var w=25,C=75;if(m&&(n||c)){var k=Math.max(0,...Object.values(t.state.categoryHeights));if(k){var E=25;c&&(E+=10),C=E+k}}if(u.scale=m?[(g[0]-4*x)/u.dimX,(g[1]-(w+C))/u.dimY]:h.map([u.dimX,u.dimY],(function(e,t){return g[t]/e})),c&&(u.scale[1]=u.picBoxHeight/u.scaleY),x/=u.scale[0],w/=u.scale[1],C/=u.scale[1],i.init({range:[[-3*x,u.dimX+x],[-C,u.dimY+w]],scale:u.scale,isMobile:this.props.apiOptions.isMobile}),i.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!c)for(var S=function(e){i.label([0,e],de.roundToApprox(e,2),"left",!0),i.style({stroke:m?"#e9ebec":"#000",strokeWidth:1,opacity:m?1:.3},(function(){i.line([0,e],[u.dimX,e])}))},_=m?u.scaleY:0;_<=u.dimY;_+=u.scaleY)S(_);(n||s)&&m&&(t.graphie.dragPrompt=i.label([u.dimX/2,u.dimY/2],o._("Drag handles to make graph"),"center",!1).css("font-weight","bold").css("color",mr.KA_GREEN).css("display","none")),t.setupCategories(d),c&&m&&(t.graphie.dotPrompt=i.label([u.dimX/2,u.dimY/2],o._("Tap to add points"),"center",!1).css("font-weight","bold").css("color",mr.KA_GREEN).css("display","none")),c&&t.drawPicHeights(t.state.values,e.values),i.style({stroke:"#000",strokeWidth:2,opacity:1},(function(){c?p?i.style({stroke:m?mr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([m?0:.5,0],[u.dimX-(m?0:.5),0]))):(i.line([0,0],[u.dimX,0]),0===t.props.labels[1].length&&m||i.style({stroke:m?mr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([0,0],[0,u.dimY])))):(i.style({stroke:m?mr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([m?3*-x:0,0],[u.dimX+(m?x:0),0]))),(n||s)&&m||i.style({stroke:m?mr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([0,0],[0,u.dimY]))))})),i.label([u.dimX/2,m?-C:-35/u.scale[1]],t.props.labels[0],m?"above":"below",!1).css("font-weight","bold").css("color",m&&mr.GRAY_F),i.label([(m?-35:-60)/u.scale[0],u.dimY/2],t.props.labels[1],"center",!1).css("font-weight","bold").css("color",m&&mr.GRAY_F).addClass("rotate"),this.props.apiOptions.isMobile&&(this.horizHairline=new Nr(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:mr.INTERACTIVE}),this.horizHairline.hide(),this.hairlineRange=[[0,u.dimX],[0,u.dimY]])})),j(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.hairlineRange[0][0],e[1]],[this.hairlineRange[0][1],e[1]]),this.horizHairline.show())})),j(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&this.horizHairline.hide()})),j(this,"labelCategory",((e,t)=>{var r=this.props.apiOptions.isMobile,i=this.graphie,n=!1,o=(t+="").match(/^\$(.*)\$$/);o&&(t=o[1],n=!0);var s=Math.PI/180*45,a="translateX(-50%) translateX(".concat(5,"px) ")+"translateY(-50%) rotate(-".concat(45,"deg)"),l=r&&!o;return new Promise((o=>{i.style({color:r?mr.GRAY_G:"inherit",transform:l?a:"none",transformOrigin:"100%"},(()=>{var a=i.label([e,r?-.5:0],t,"below",n),p=14+(l?Math.round(a.height()*Math.cos(s)+(a.width()+5)*Math.sin(s)):a.height());o({category:t,height:p})}))}))})),j(this,"setupCategories",(e=>{var t=this,r=e,i=t.graphie,n=this.props.apiOptions.isMobile,o=[];"histogram"===t.props.type?(h.times(t.props.categories.length-1,(function(r){t.setupBar({index:r,startHeight:t.state.values[r],config:e,isHistogram:!0})})),h.each(t.props.categories,(function(e,s){var a=.5+s*r.barWidth;o.push(t.labelCategory(a,e));var l=6/r.scale[1];i.style({stroke:"#000",strokeWidth:n?1:2,opacity:1},(function(){i.line([a,-l],[a,0])}))}))):h.each(t.props.categories,(function(s,a){var l,p=t.state.values[a];"bar"===t.props.type?l=t.setupBar({index:a,startHeight:p,config:e,isHistogram:!1}):"line"===t.props.type?l=t.setupLine(a,p,e):"pic"===t.props.type?l=t.setupPic(a,e):"dotplot"===t.props.type&&(l=t.setupDotplot(a,e));var h=0,c=-6/r.scale[1];"dotplot"!==t.props.type||n||(h=-c),"dotplot"===t.props.type?a%t.props.labelInterval!=0&&a!==t.props.categories.length-1||(o.push(t.labelCategory(l,s)),h*=1.5,c*=1.5):o.push(t.labelCategory(l,s)),i.style({stroke:n?mr.GRAY_G:"#000",strokeWidth:n?1:2,opacity:1},(function(){i.line([l,h],[l,c])}))})),Promise.all(o).then((e=>{if(t._isMounted){var r={};e.forEach((e=>{var{category:t,height:i}=e;return r[t]=i})),t.setState({categoryHeights:r})}}))})),j(this,"_clampValue",((e,t,r)=>Math.max(Math.min(e,r),t))),j(this,"_maybeShowDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="inline")})),j(this,"_maybeHideDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="none")})),j(this,"setupBar",(e=>{var t,r=this.props.apiOptions.isMobile,i=e.index,n=e.startHeight,o=e.config,s=e.isHistogram,a=this,l=a.graphie,p=o.barWidth/2;t=s?.5+i*o.barWidth+p:(r?p:.5+o.barPad)+i;var c=function(e,t){var i=l.scalePoint(0);if(o.graph.bars[e].scale(1,Math.max(r?.2:.01,t/o.scaleY),i[0],i[1]),s){var n=o.graph.dividers[e-1],p=o.graph.dividers[e];if(n){var h=Math.min(a.state.values[e-1],t);n.scale(1,Math.max(.01,h/o.scaleY),i[0],i[1])}if(p){var c=Math.min(a.state.values[e+1],t);p.scale(1,Math.max(.01,c/o.scaleY),i[0],i[1])}}};if(l.style({stroke:"none",fill:r?mr.BLUE_C:mr.LIGHT_BLUE,opacity:1},(function(){o.graph.bars[i]=l.path([[t-p,0],[t-p,o.scaleY],[t+p,o.scaleY],[t+p,0],[t-p,0]])})),s&&i>0&&l.style({stroke:"#000",strokeWidth:1,opacity:.3},(function(){o.graph.dividers.push(l.path([[t-p,0],[t-p,o.scaleY]]))})),r){var d=o.scaleY/a.props.snapsPerLine;o.graph.lines[i]=mn.addMaybeMobileMovablePoint(this,{coord:[t,n],constraints:[(e,r,i)=>[t,this._clampValue(Math.round(e[1]/d)*d,0,o.dimY)]],onMoveStart:function(){o.graph.bars[i].attr({fill:mr.INTERACTIVE})},onMove:function(){var e=o.graph.lines[i].coord()[1],t=h.clone(a.state.values);t[i]=e,a.setState({values:t}),a.changeAndTrack({values:t}),a._maybeHideDragPrompt(),c(i,e)},onMoveEnd:function(){o.graph.bars[i].attr({fill:mr.BLUE_C})}}),o.graph.lines[i].state.visibleShape.wrapper.style.zIndex="1",a._maybeShowDragPrompt()}else o.graph.lines[i]=l.addMovableLineSegment({coordA:[t-p,n],coordZ:[t+p,n],snapY:o.scaleY/a.props.snapsPerLine,constraints:{constrainX:!0},normalStyle:{stroke:mr.INTERACTIVE,"stroke-width":this.props.static?0:4}}),o.graph.lines[i].onMove=function(e,t){var r=this.coordA[1];(r<0||r>o.dimY)&&(r=Math.min(Math.max(r,0),o.dimY),this.coordA[1]=this.coordZ[1]=r,this.transform());var n=h.clone(a.state.values);n[i]=r,a.setState({values:n}),a.changeAndTrack({values:n}),c(i,r)};return c(i,n),t})),j(this,"setupLine",((e,t,r)=>{var i=this.props.apiOptions.isMobile,n=this,o=r,s=n.graphie,a=e+(i?.4:1);if(i){var l=r.scaleY/n.props.snapsPerLine;o.graph.points[e]=mn.addMaybeMobileMovablePoint(this,{coord:[a,t],constraints:[(e,t,i)=>[a,this._clampValue(Math.round(e[1]/l)*l,0,r.dimY)]],onMove:function(){var t=o.graph.points[e].coord()[1],r=h.clone(n.state.values);r[e]=t,n.setState({values:r}),n.changeAndTrack({values:r}),n._maybeHideDragPrompt()}}),n._maybeShowDragPrompt(),e>0&&(o.graph.lines[e]=mn.addMovableLine(s,{points:[o.graph.points[e-1],o.graph.points[e]],constraints:mn.MovablePoint.constraints.fixed(),normalStyle:{stroke:mr.BLUE_C,"stroke-width":2},highlightStyle:{stroke:mr.BLUE_C,"stroke-width":2}}))}else o.graph.points[e]=s.addMovablePoint({coord:[a,t],constraints:{constrainX:!0},normalStyle:{fill:mr.INTERACTIVE,stroke:mr.INTERACTIVE},snapY:o.scaleY/n.props.snapsPerLine}),o.graph.points[e].onMove=function(t,r){r=Math.min(Math.max(r,0),o.dimY);var i=h.clone(n.state.values);return i[e]=r,n.setState({values:i}),n.changeAndTrack({values:i}),[t,r]},e>0&&(o.graph.lines[e]=s.addMovableLineSegment({pointA:o.graph.points[e-1],pointZ:o.graph.points[e],constraints:{fixed:!0},normalStyle:{stroke:"#9ab8ed","stroke-width":2}}));return a})),j(this,"setupDotplot",((e,t)=>{var r=this.graphie,i=this.props.apiOptions.isMobile;return this.setupTiledPlot(e,i?.5:1,t,((e,t)=>r.ellipse([e,t],[this.DOT_PLOT_POINT_SIZE()/r.scale[0],this.DOT_PLOT_POINT_SIZE()/r.scale[1]],{fill:mr.INTERACTIVE,stroke:mr.INTERACTIVE})))})),j(this,"setupPic",((e,t)=>{var r=this.graphie;return this.setupTiledPlot(e,0,t,((e,t)=>{var i=r.scalePoint([e,t]),n=this.props.picSize;return r.raphael.image(this.props.picUrl,i[0]-n/2,i[1]-n/2,n,n)}))})),j(this,"setupTiledPlot",((e,t,r,i)=>{var n=this,o=r,s=n.graphie,a=s.pics,l=s.dotTicks,p=e+.5+o.picPad;s.mouselayer.canvas.style.touchAction="none",a[e]=[],l[e]=[];var c=Math.round(o.dimY/o.scaleY)+1;return h(c).times((function(r){var h=((r-=1)+.5)*o.scaleY,c=p-o.picBoxWidth/2,d=h+.5*o.scaleY,u=s.scalePoint([c,d+t]),m=s.mouselayer.rect(u[0],u[1],o.picBoxWidthPx,o.picBoxHeight);y(m[0]).css({fill:"#000",opacity:0,cursor:"pointer"}).on("vmousedown",(function(r){r.preventDefault(),n.whichPicClicked=e,n.setPicHeight(e,d),y(document).on("vmouseup.plotTile",(function(e){y(document).unbind(".plotTile")})),y(document).on("vmousemove.plotTile",(function(e){e.preventDefault();var r=s.getMouseCoord(e)[1],i=Math.floor(r-t),a=(Math.max(-1,Math.floor(i/o.scaleY))+.5)*o.scaleY,l=Math.min(a+.5*o.scaleY,o.dimY);n.setPicHeight(n.whichPicClicked,l)}))})),r<0||(a[e][r]=i(p,h+t),l[e][r]=s.ellipse([p,h+t],[n.DOT_TICK_POINT_SIZE()/s.scale[0],n.DOT_TICK_POINT_SIZE()/s.scale[1]],{fill:"#dee1e3",stroke:"#dee1e3"}))})),p})),j(this,"setPicHeight",((e,t)=>{var r=h.clone(this.state.values);r[e]=t,this.drawPicHeights(r,this.state.values),this.setState({values:r}),this.changeAndTrack({values:r})})),j(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),j(this,"drawPicHeights",((e,t)=>{var r=this,i=r.graphie,n=i.pics,o=this.props.apiOptions.isMobile;if(o){var s=e.every((e=>0===e));i.dotPrompt[0].style.display=s?"inline":"none"}h.each(n,(function(n,s){h.each(n,(function(n,a){var l=(a+1)*r.props.scaleY,p=l<=e[s];if("dotplot"===r.props.type){var h=l<=t[s];p&&!h&&n.animate({"stroke-width":8},75,(()=>n.animate({"stroke-width":2},75)))}y(n[0]).css({display:p?"inline":"none"}),i.dotTicks[s][a][0].style.display=p||!o?"none":"inline"}))}))})),j(this,"getUserInput",(()=>this.state.values)),j(this,"simpleValidate",(e=>Af.validate(this.getUserInput(),e)))}render(){var e={marginBottom:this.props.labels[0]?75:0};return a.createElement("div",{className:"perseus-widget-plotter graphie "+Jt.INTERACTIVE,ref:"graphieDiv",style:e})}componentDidUpdate(e,t){this.shouldSetupGraphie=this.shouldSetupGraphie||!h.isEqual(this.state.categoryHeights,t.categoryHeights),this.shouldSetupGraphie&&this.setupGraphie(t)}componentDidMount(){this._isMounted=!0,this.setupGraphie(this.state)}UNSAFE_componentWillReceiveProps(e){this.shouldSetupGraphie=h.any(["type","labels","categories","scaleY","maxY","snapsPerLine","picUrl","labelInterval","static"],(function(t){return!h.isEqual(this.props[t],e[t])}),this),h.isEqual(this.props.starting,e.starting)||h.isEqual(this.state.values,e.starting)||(this.shouldSetupGraphie=!0,this.setState({values:e.starting}))}componentWillUnmount(){this._isMounted=!1}}j(Af,"propTypes",{onChange:d.func.isRequired,trackInteraction:d.func.isRequired}),j(Af,"defaultProps",{type:"bar",labels:["",""],categories:[""],scaleY:1,maxY:10,snapsPerLine:2,picSize:40,picBoxHeight:48,picUrl:"",plotDimensions:[380,300],labelInterval:1}),h.extend(Af,{validate:function(e,t){return Nf(e,t.starting)?{type:"invalid",message:null}:{type:"points",earned:Nf(e,t.correct)?1:0,total:1,message:null}}});var Rf=h.identity,Ff={name:"plotter",displayName:"Plotter",widget:Af,staticTransform:Rf};class Of extends a.Component{constructor(){super(...arguments),j(this,"arrowLength",100),j(this,"drawArrow",(()=>{var e=this.refs["arrowCanvas"+this.props.index],t=e.getContext("2d");t.clearRect(0,0,e.width,e.height);var r=new Path2D;t.strokeStyle="rgb(0,0,0)",t.lineWidth=1.2,t.lineCap="round";r.moveTo(5,e.height/2),r.lineTo(e.width-5,e.height/2),r.moveTo(e.width-10,e.height/2-5),r.lineTo(e.width-5,e.height/2),r.moveTo(e.width-10,e.height/2+5),r.lineTo(e.width-5,e.height/2),t.stroke(r)}))}componentDidMount(){this.drawArrow()}componentDidUpdate(){this.drawArrow()}render(){return a.createElement("div",{className:"arrow-container"},a.createElement("div",{className:"above-text"},this.props.data.topText),a.createElement("canvas",{height:"30",id:"arrowCanvas"+this.props.index,ref:"arrowCanvas"+this.props.index,width:this.arrowLength},o._("Reaction arrow pointing to the right.")),a.createElement("div",{className:"below-text"},this.props.data.bottomText))}}j(Of,"propTypes",{data:d.any,index:d.number});class Df extends a.Component{constructor(){super(...arguments),j(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),j(this,"getUserInput",(()=>[])),j(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null}))),j(this,"focus",(()=>!0))}render(){return a.createElement("div",{className:"reaction",ref:"reaction"},this.props.smiles.map(((e,t)=>{var r=this.props.widgetId+"-"+t;return a.createElement("div",{key:r,className:"molecule-container"},a.createElement(_g,{id:r,rotationAngle:this.props.rotationAngle[t],smiles:e}),t===this.props.smiles.length-1?null:a.createElement(Of,{data:this.props.separators[t],index:t}))})))}}j(Df,"propTypes",{rotationAngle:d.arrayOf(d.number),separators:d.arrayOf(d.object),smiles:d.arrayOf(d.string),widgetId:d.string}),j(Df,"defaultProps",{smiles:[],rotationAngle:[],separators:[]});var Lf={name:"reaction-diagram",displayName:"Chemical reaction",hidden:!0,widget:Df};class Bf extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"state",{visible:1}),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"_handleInteraction",(e=>{var t=parseInt(e.split(" ")[1]);if(t===this.state.visible-1){var r=this.refs.renderer.getWidgetInstance("group "+t);r.showRationalesForCurrentlySelectedChoices();var i=r.simpleValidate();"points"===i.type&&i.total===i.earned&&(this.setState({visible:this.state.visible+1}),this.props.trackInteraction({visible:this.state.visible+1}))}}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){var e=a.createElement(X,Y({},Ei,{style:{color:"green"}})),t=h.chain(this.props.json).first(this.state.visible).map(((e,t)=>"[[".concat(De.snowman," group ").concat(t,"]]"))).join("\n\n").value(),r={};return h.each(this.props.json,((t,i)=>{var n="group ".concat(i);r[n]={type:"group",graded:!0,version:{major:0,minor:0},options:h.extend({},t,{icon:i<this.state.visible-1?e:null})}})),a.createElement("div",{className:"perseus-sequence"},a.createElement(Bo,{ref:"renderer",content:t,widgets:r,onInteractWithWidget:this._handleInteraction,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext}))}}j(Bf,"propTypes",G(G({},fs),{},{apiOptions:Zt.propTypes,json:d.arrayOf(d.shape({content:d.string,images:d.objectOf(d.any),widgets:d.objectOf(d.any)})),trackInteraction:d.func.isRequired,linterContext:Gt})),j(Bf,"defaultProps",{json:[{content:"",widgets:{},images:{}}],linterContext:Vt});var zf={name:"sequence",displayName:"Graded Sequence",widget:Bf,traverseChildWidgets:function(e,t){var r=e.json;h.isArray(r)||(r=[r]);var i=h.map(r,(e=>t(e)));return h.extend({},e,{json:i})},tracking:"all",hidden:!0,isLintable:!0},Hf="#aaa",Wf="#ccc",qf="#fff",Uf={borderBottom:"9px solid transparent",borderTop:"9px solid transparent",content:'" "',height:"0",position:"absolute",top:"0",width:"0"},Gf=m.create({infoTip:{display:"inline-block",marginLeft:"5px",position:"relative"},infoTipContainer:{position:"absolute",top:"-12px",left:"22px",zIndex:1e3},infoTipTriangle:{height:"10px",left:"0",position:"absolute",top:"8px",width:"0",zIndex:1,":before":G(G({},Uf),{},{borderRight:"9px solid #bbb",right:"0"}),":after":G(G({},Uf),{},{borderRight:"9px solid ".concat(qf),right:"-1px"})},verticalShadow:{border:"1px solid ".concat(Wf),boxShadow:"0 1px 3px ".concat(Wf),borderBottom:"1px solid ".concat(Hf)},infoTipContentContainer:{background:qf,padding:"5px 10px",width:"240px"}});class Vf extends a.Component{constructor(){super(...arguments),j(this,"state",{hover:!1}),j(this,"handleMouseEnter",(()=>{this.setState({hover:!0})})),j(this,"handleMouseLeave",(()=>{this.setState({hover:!1})}))}render(){return a.createElement("div",{className:g(Gf.infoTip)},a.createElement("img",{alt:"",width:10,height:10,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo2N2M3NTAxYS04YmVlLTQ0M2MtYmRiNS04OGM2N2IxN2NhYzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUJCRTk4Qjc4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUJCRTk4QjY4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NGE5ZDI0OTMtODk1NC00OGFkLTlhMTgtZDAwM2MwYWNjNDJlIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjY3Yzc1MDFhLThiZWUtNDQzYy1iZGI1LTg4YzY3YjE3Y2FjMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pqm89uYAAADMSURBVHjaXJA9DoJAEIUH1M4TUHIFsCMGen9OwCGw1YRGW2ntKel0exsojHIBC0ouQAyUviFDstmXfNmZeS+zm7XSNCXRFiRgJf0bXIHixpbhGdxBBJYC1w/xaA424MhNEATkui71fU9KqfEU78UbD9PdbJRlOdae55GmhIP+1NV1TcMwkOM41DSNHvRtMhTHMRVFQW3b6mOLgx99kue5GRp/gIOZuZGvNpTNwjD8oliANU+qqqKu6/TQBdymN57AHjzBT+B6Jx79BRgAvc49kQA4yxgAAAAASUVORK5CYII=",onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave}),a.createElement("div",{className:g(Gf.infoTipContainer),style:{display:this.state.hover?"block":"none"}},a.createElement("div",{className:g(Gf.infoTipTriangle)}),a.createElement("div",{className:g(Gf.verticalShadow,Gf.infoTipContentContainer)},this.props.children)))}}class jf extends a.Component{constructor(){super(...arguments),j(this,"state",{didMount:!1})}componentDidMount(){this.setState({didMount:!0})}render(){return this.state.didMount?a.createElement(Vf,this.props):a.createElement("div",null)}}var{assert:Yf}=hr,{Path:$f,Arc:Xf,Circle:Kf,Label:Zf,Line:Jf,MovablePoint:Qf,MovableLine:ev}=Nn;class tv extends a.Component{constructor(){super(...arguments),j(this,"_renderThresholdLine",(()=>{var e=[0,this._range()[1][1]],t=h.map(e,(e=>[this.state.threshold,e]));return a.createElement(ev,{onMove:this.handleMouseInteraction},h.map(t,((e,t)=>a.createElement(Qf,{key:t,static:!0,coord:e,normalStyle:{stroke:"none",fill:"none"}}))))})),j(this,"_renderCircle",(()=>{var e,t=this.props.data,r=h.reduce(t,((e,t)=>e+t),0),i=h.reduce(t,((e,t,r)=>null!=this.state.threshold&&r<=this.state.threshold?e+t:e),0),n=i/r,o=1e-5,s=[this.props.box[0]-30,30],l=this._range()[0],p=Math.min(Math.max(this.state.threshold,l[0]),l[1]).toFixed(2);return[n>0&&(e={key:"below",center:s,radius:20,startAngle:0,endAngle:n<1?360*n:359.99999,sector:1!==n,unscaled:!0,style:{fill:mr.LIGHT_RED,stroke:mr.RED}},a.createElement(Xf,e)),n<1&&(()=>{var e={key:"above",center:s,radius:20,startAngle:n>0?360*n:o,endAngle:360,sector:0!==n,unscaled:!0,style:{fill:mr.LIGHT_BLUE,stroke:mr.BLUE}};return a.createElement(Xf,e)})(),(()=>{var e={key:"label",coord:[s[0],s[1]+30],text:i+" of "+r+" results below "+p+"%",direction:"center",tex:!1,unscaled:!0,style:{fontSize:"12px"}};return a.createElement(Zf,e)})()]})),j(this,"_renderData",(()=>{var e=this.props.data;this._range();return h.map(e,((e,t)=>{if(e){var r=null!=this.state.threshold&&t<=this.state.threshold,i={fill:r?mr.LIGHT_RED:mr.LIGHT_BLUE,stroke:r?mr.RED:mr.BLUE},n=[[t,0],[t,e],[t+1,e],[t+1,0]];return a.createElement($f,{key:t,coords:n,style:i})}}))})),j(this,"_setupGraphie",((e,t)=>{var r=t.data,i=t.range,n=t.scale,o=i[0][1]-i[0][0],s=i[1][1]-0,a=Math.ceil(s/20);if(h.each(h.range(0,i[1][1],a),(t=>{r&&e.label([i[0][0],t],de.roundToApprox(t,2),"left",!0),e.line([i[0][0],t],[i[0][1],t],{stroke:"#000",strokeWidth:1,opacity:.3})})),r){var l=Math.ceil(o/15);h.each(h.range(i[0][0],i[0][1],l),(t=>{e.label([t,0],b.round(t,2),"below",!0);e.line([t,0],[t,-8/n[1]],{stroke:"#000",strokeWidth:1})}))}var p=[i[0][0],0],c=[i[0][0],i[1][1]];e.line(p,c,{stroke:"#000",strokeWidth:2,opacity:1});var d=i[0][0]+o/2,u=r?25:0;e.label([d,-u/n[1]],t.xAxisLabel,"below",!1).css("font-weight","bold");var m=0+s/2,g=r?55:28;e.label([i[0][0]-g/n[0],m],t.yAxisLabel,"center",!1).css("font-weight","bold").css("-webkit-transform","rotate(-90deg)")})),j(this,"handleMouseInteraction",(e=>{this.setState({threshold:e[0]})})),j(this,"_range",(e=>(e=e||this.props).data?this._getRangeForData(e.data):[[0,100],[-1,10]])),j(this,"_getRangeForData",(e=>{var t=h.indexOf(e,h.find(e,(e=>e>0))),r=Math.max(0,t-10),i=h.lastIndexOf(e,h.last(h.filter(e,(e=>e>0))));return[[r,Math.min(101,i+1+10)],[-1,h.max(e)]]})),j(this,"_getInitialThreshold",(e=>{var t=e[0];return t[0]+(t[1]-t[0])/3})),j(this,"state",{threshold:this._getInitialThreshold(this._range())})}UNSAFE_componentWillReceiveProps(e){var t=this._range(),r=this._range(e);De.deepEq(t,r)||this.setState({threshold:this._getInitialThreshold(r)})}render(){var e=this.props.data,t=this._range(),r={xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,box:this.props.box,range:t,data:e,scale:[De.scaleFromExtent(t[0],this.props.box[0]),De.scaleFromExtent(t[1],this.props.box[1])]},i=[t[0][0],0],n=[t[0][1],0];return a.createElement(Nn,{box:r.box,range:r.range,options:r,setup:this._setupGraphie,onMouseMove:this.handleMouseInteraction,onMouseDown:this.handleMouseInteraction,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable},a.createElement(Jf,{start:i,end:n,style:{stroke:"#000",strokeWidth:1,opacity:1}}),e&&this._renderData(),e&&this._renderCircle(),e&&this._renderThresholdLine())}}j(tv,"propTypes",{data:d.arrayOf(d.number),xAxisLabel:d.string,yAxisLabel:d.string,box:d.arrayOf(d.number)}),j(tv,"defaultProps",{data:null,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",box:[400,400]});class rv extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"generateNumber",void 0),j(this,"state",{invalidInput:!1}),j(this,"calculateDisplayProportion",(()=>{var e=this.props.userProportion;return"percentage"===this.props.proportionOrPercentage?Math.round(100*e):e})),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)})),j(this,"checkProportionValidity",(e=>e>=0&&"proportion"===this.props.proportionOrPercentage&&e<=1||"percentage"===this.props.proportionOrPercentage&&e<=100)),j(this,"handleUserProportionChange",((e,t)=>{var r;null!=(r="percentage"===this.props.proportionOrPercentage?e/100:e)&&(r=Math.min(1,Math.max(0,r))),this.props.onChange({userProportion:r},t)})),j(this,"handleSampleSizeChange",((e,t)=>{null!=e&&(e=Math.min(1e3,Math.max(0,Math.floor(e)))),this.props.onChange({sampleSize:e},t)})),j(this,"handleRunSimulation",(()=>{null!=this.props.numTrials&&null!=this.props.userProportion&&null!=this.props.sampleSize?(this.setState({invalidInput:!1}),this.props.onChange({data:this.generateData()}),this.props.trackInteraction()):this.setState({invalidInput:!0})})),j(this,"generateData",(e=>((e,t,r)=>{var i=()=>this.generateNumber()<r,n=h.times(101,(()=>0));return h.times(t,(()=>{var t=h.times(e,i),r=h.filter(t,h.identity).length,o=Math.floor(100*r/e);n[o]++})),n})((e=e||this.props).sampleSize,e.numTrials,e.userProportion))),j(this,"getInputPaths",(()=>[["userProportion"],["sampleSize"]])),j(this,"focus",(()=>{var e=h.head(this.getInputPaths());return this.focusInputPath(e),!0})),j(this,"focusInputPath",(e=>{Yf(e.length>0);var t=h.head(e);this.refs[t].focus()})),j(this,"blurInputPath",(e=>{Yf(e.length>0);var t=h.head(e);this.refs[t].blur()})),j(this,"getDOMNodeForPath",(e=>{Yf(e.length>0);var t=h.head(e);return v.findDOMNode(this.refs[t])})),j(this,"getGrammarTypeForPath",(e=>(Yf(e.length>0),"number"))),j(this,"setInputValue",((e,t,r)=>{Yf(e.length>0);var i=h.head(e);this["handle"+(i.charAt(0).toUpperCase()+i.slice(1))+"Change"](t,r)})),j(this,"getUserInput",(()=>null)),j(this,"simpleValidate",(e=>rv.validate(this.getUserInput(),e)))}UNSAFE_componentWillMount(){null!=this.props.randomSeed&&(this.generateNumber=De.seededRNG(this.props.randomSeed))}UNSAFE_componentWillReceiveProps(e){e.randomSeed!==this.props.randomSeed&&(this.generateNumber=De.seededRNG(e.randomSeed))}render(){var e={marginLeft:"5px"},t="0px 0px 0px 2px rgba(255, 165, 0, 1)",r=h.extend({},e,{WebkitBoxShadow:t,MozBoxShadow:t,boxShadow:t,transition:"all 0.15s"}),i=h.extend({},e,{transition:"all 0.15s"}),n=this.state.invalidInput?r:i,s=this.props.apiOptions.staticRender?es:Lm,l=a.createElement("div",null,a.createElement(s,{ref:"userProportion",style:n,value:this.calculateDisplayProportion(),checkValidity:this.checkProportionValidity,disabled:this.props.apiOptions.readOnly,onChange:this.handleUserProportionChange,onFocus:()=>this.props.onFocus(["userProportion"]),onBlur:()=>this.props.onBlur(["userProportion"])}),a.createElement(jf,null,a.createElement("p",null,o._("This controls the proportion or percentage that will be used in your simulation.")))),p=a.createElement("div",null,a.createElement(s,{ref:"sampleSize",style:n,value:this.props.sampleSize,checkValidity:e=>e>=0,disabled:this.props.apiOptions.readOnly,onChange:this.handleSampleSizeChange,onFocus:()=>this.props.onFocus(["sampleSize"]),onBlur:()=>this.props.onBlur(["sampleSize"])}),a.createElement(jf,null,a.createElement("p",null,o._("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.")))),c=a.createElement("div",{style:{textAlign:"right"}},a.createElement("b",null,this.props.numTrials),a.createElement(jf,null,a.createElement("p",null,o._("This is the number of trials used in the simulation. For example, if set to 50, then the survey will be conducted 50 times.")))),d=[{title:this.props.proportionLabel+":",value:l},{title:o._("Sample size:"),value:p},{title:o._("Number of trials:"),value:c}],u=a.createElement("button",{className:"simple-button",style:{margin:"20px 0"},disabled:this.props.apiOptions.readOnly,onClick:this.handleRunSimulation},o._("Run simulation")),m={paddingBottom:this.props.data?40:0},g=a.createElement("div",{style:m},a.createElement(tv,{data:this.props.data,xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}));return a.createElement("div",null,(e=>{var t=a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,o._("Parameter")),a.createElement("th",null,o._("Value")))),r=a.createElement("tbody",null,h.map(e,((e,t)=>a.createElement("tr",{key:t},a.createElement("td",null,e.title),a.createElement("td",null,e.value)))));return a.createElement("table",null,t,r)})(d),u,g)}}j(rv,"propTypes",G(G({},fs),{},{apiOptions:Zt.propTypes,data:d.arrayOf(d.number),numTrials:d.number,proportionLabel:d.string,proportionOrPercentage:d.string,randomSeed:d.number,sampleSize:d.number,trackInteraction:d.func.isRequired,userProportion:d.number,xAxisLabel:d.string,yAxisLabel:d.string})),j(rv,"defaultProps",{data:null,userProportion:null,sampleSize:null,numTrials:null,randomSeed:0,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion",apiOptions:Zt.defaults}),h.extend(rv,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var iv={name:"simulator",displayName:"Simulator",widget:rv,transform:e=>{var t=h.clone(e);return t.randomSeed=e.problemNum,t},hidden:!0},{shuffle:nv}=De;class ov extends a.Component{constructor(){super(...arguments),j(this,"_isMounted",void 0),j(this,"state",{changed:!1}),j(this,"handleChange",(e=>{this._isMounted&&this.setState({changed:!0},(()=>{setTimeout((()=>{this.props.onChange(e),this.props.trackInteraction()}),0)}))})),j(this,"getUserInput",(()=>({options:this.refs.sortable.getOptions()}))),j(this,"moveOptionToIndex",((e,t)=>{this.refs.sortable.moveOptionToIndex(e,t)})),j(this,"simpleValidate",(e=>this.state.changed?ov.validate(this.getUserInput(),e):{type:"invalid",message:null}))}static validate(e,t){return{type:"points",earned:h.isEqual(e.options,t.correct)?1:0,total:1,message:null}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1}render(){var e=nv(this.props.correct,this.props.problemNum,!0),{apiOptions:t}=this.props,r=t.isMobile?8:5;return a.createElement("div",{className:"perseus-widget-sorter perseus-clearfix"},a.createElement(Sm,{options:e,layout:this.props.layout,margin:r,padding:this.props.padding,onChange:this.handleChange,linterContext:this.props.linterContext,ref:"sortable"}))}}j(ov,"propTypes",{apiOptions:Zt.propTypes,correct:d.array,layout:d.oneOf(["horizontal","vertical"]),onChange:d.func,padding:d.bool,problemNum:d.number,trackInteraction:d.func.isRequired,linterContext:Gt}),j(ov,"defaultProps",{correct:[],layout:"horizontal",padding:!0,problemNum:0,onChange:function(){},linterContext:Vt});var sv,av={name:"sorter",displayName:"Sorter",widget:ov,isLintable:!0},{assert:lv}=hr,pv=function(e,t){return[""+e,""+t]},hv=function(e){return lv(h.isArray(e)&&2===e.length),+e[0]},cv=function(e){return lv(h.isArray(e)&&2===e.length),+e[1]},dv=function(e){return"answer"+hv(e)+","+cv(e)};class uv extends a.Component{constructor(){super(...arguments),j(this,"_getRows",(()=>this.props.answers.length)),j(this,"_getColumns",(()=>this.props.answers[0].length)),j(this,"getUserInput",(()=>h.map(this.props.answers,h.clone))),j(this,"onValueChange",((e,t,r)=>{var i=h.map(this.props.answers,h.clone);i[e][t]=r.target?r.target.value:r,this.props.onChange({answers:i}),this.props.trackInteraction()})),j(this,"onHeaderChange",((e,t)=>{var r=this.props.headers.slice();r[e]=t.content,this.props.onChange({headers:r})})),j(this,"simpleValidate",(e=>uv.validate(this.getUserInput(),e))),j(this,"_handleFocus",(e=>{this.props.onFocus(e)})),j(this,"_handleBlur",(e=>{this.props.onBlur(e)})),j(this,"focus",(()=>(this.focusInputPath(pv(0,0)),!0))),j(this,"focusInputPath",(e=>{var t=dv(e),r=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?r.focus():v.findDOMNode(r).focus()})),j(this,"blurInputPath",(e=>{var t=dv(e),r=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?r.blur():v.findDOMNode(r).blur()})),j(this,"getDOMNodeForPath",(e=>{var t=dv(e);return v.findDOMNode(this.refs[t])})),j(this,"getInputPaths",(()=>{var e=this._getRows(),t=this._getColumns(),r=[];return h(e).times((e=>{h(t).times((t=>{var i=pv(e,t);r.push(i)}))})),r})),j(this,"getGrammarTypeForPath",(e=>"number")),j(this,"setInputValue",((e,t,r)=>{var i=hv(e),n=cv(e),o=h.map(this.props.answers,h.clone);o[i][n]=t,this.props.onChange({answers:o},r)}))}render(){var e,t,r=this._getRows(),i=this._getColumns(),n=this.props.headers,o={};return this.props.apiOptions.customKeypad?(e=Ss,t={width:80},o.keypadElement=this.props.keypadElement):this.props.apiOptions.staticRender?(e=es,t={}):(e="input",t={}),a.createElement("table",{className:"perseus-widget-table-of-values non-markdown"},a.createElement("thead",null,a.createElement("tr",null,h.map(n,((e,t)=>this.props.editableHeaders?a.createElement("th",{key:t},a.createElement(this.props.Editor,{ref:"columnHeader"+t,apiOptions:this.props.apiOptions,content:e,widgetEnabled:!1,onChange:h.partial(this.onHeaderChange,t)})):a.createElement("th",{key:t},a.createElement(Bo,{content:e,linterContext:this.props.linterContext})))))),a.createElement("tbody",null,h(r).times((r=>a.createElement("tr",{key:r},h(i).times((i=>a.createElement("td",{key:i},a.createElement(e,Y({ref:dv(pv(r,i)),type:"text",value:this.props.answers[r][i],disabled:this.props.apiOptions.readOnly,onFocus:h.partial(this._handleFocus,pv(r,i)),onBlur:h.partial(this._handleBlur,pv(r,i)),onChange:h.partial(this.onValueChange,r,i),style:t},o))))))))))}}j(uv,"propTypes",{answers:d.arrayOf(d.arrayOf(d.string)),editableHeaders:d.bool,Editor:d.func,headers:d.arrayOf(d.string),keypadElement:i,trackInteraction:d.func.isRequired,linterContext:Gt}),j(uv,"defaultProps",(sv=h(4).times((function(){return De.stringArrayOfSize(1)})),{apiOptions:Zt.defaults,headers:[""],editableHeaders:!1,rows:4,columns:1,answers:sv,linterContext:Vt})),h.extend(uv,{validate:function(e,t){var r=function(e){return h.filter(e,(function(e){return h.some(e,h.identity)}))},i=r(t.answers),n=r(e);if(h.some(n,(function(e){return h.some(e,(function(e){return""===e}))}))||!n.length)return{type:"invalid",message:null};if(n.length!==i.length)return{type:"points",earned:0,total:1,message:null};var o=ge.number.createValidatorFunctional,s=null;return{type:"points",earned:h.every(i,(function(e){var t;for(t=0;t<n.length;t++){var r=n[t],i=h.every(r,(function(t,r){var i=e[r],n=o(i,{simplify:!0})(t);return n.message&&(s=n.message),n.correct}));if(i)return n.splice(t,1),!0}return!1}))?1:0,total:1,message:s}}});var mv={name:"table",displayName:"Table of values",accessible:!0,widget:uv,transform:e=>{var t=e.answers.length,r=e.answers[0].length,i=h(t).times((function(){return De.stringArrayOfSize(r)}));return h.extend({},e,{answers:i})},hidden:!0,isLintable:!0},{deepEq:gv,getGridStep:fv,captureScratchpadTouchStart:vv}=De,{assert:yv}=hr,bv={url:null};var xv={apiOptions:Zt.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:[]}};function wv(e){return e.constraints.fixed?mr.DYNAMIC:mr.INTERACTIVE}function Cv(e){return String(de.roundTo(9,e))}function kv(e){var{TeX:t}=ae();return[a.createElement(t,{key:"("},"("),Cv(e[0]),a.createElement(t,{key:","},", {}"),Cv(e[1]),a.createElement(t,{key:")"},")")]}function Ev(e){var{TeX:t}=ae();return[a.createElement(t,{key:"<"},o.doNotTranslate("\\langle")),Cv(e[0]),a.createElement(t,{key:","},", {}"),Cv(e[1]),a.createElement(t,{key:">"},o.doNotTranslate("\\rangle"))]}function Sv(e,t){return e=h.clone(e).sort(x.compare),t=h.clone(t).sort(x.compare),h.all(h.map(e,(function(e,r){var i=t[r];return x.equal(e,i)})))}var _v=e=>e.customKeypad?Ss:e.staticRender?es:Lm,Mv={apply:function(e){return Tv[e.type].isValid(e)?Tv[e.type].apply(e):h.identity},append:function(e,t){var r=Mv._appendAndCollapseLastTwo(e,t);return Mv._collapseFinalNoOps(r)},_collapseFinalNoOps:function(e){return e.length&&Mv.isNoOp(h.last(e))?h.initial(e):e},_appendAndCollapseLastTwo:function(e,t){if(!e.length)return[t];var r=Mv.collapse(h.last(e),t);return h.initial(e).concat(r)},isNoOp:function(e){return Tv[e.type].isNoOp(e)},collapse:function(e,t){return e.type!==t.type?[e,t]:Mv.isEmpty(e)&&Mv.isEmpty(t)?[]:Mv.isValid(e)&&Mv.isValid(t)?Mv._collapseValidMonotypedTransforms(e,t):[e,t]},isValid:function(e){return Tv[e.type].isValid(e)},isEmpty:function(e){return Tv[e.type].isEmpty(e)},_collapseValidMonotypedTransforms:function(e,t){var r=Tv[e.type].collapse(e,t);return r?(h.isArray(r)||(r=[r]),h.each(r,(function(t){t.type=e.type})),r):[e,t]},toTeX:function(e){return Tv[e.type].toTeX(e)},ListItem:E({displayName:"ListItem",render:function(){if("dynamic"===this.props.mode)return a.createElement("div",null,Mv.toTeX(this.props.transform));if("interactive"===this.props.mode){var e=Tv[this.props.transform.type].Input;return a.createElement(e,Y({ref:"transform",onChange:this.handleChange,onFocus:this.props.onFocus,onBlur:this.props.onBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions},this.props.transform))}throw new ce("Invalid mode: "+this.props.mode,pe.InvalidInput)},value:function(){return"interactive"===this.props.mode?h.extend({type:this.props.transform.type},this.refs.transform.value()):this.props.transform},handleChange:h.debounce((function(e){this.props.onChange(this.value(),e)}),300),_getComponentAtPath:function(e){var t=this.refs.transform,r=h.head(e);return t.refs[r]},focus:function(){var e=this.refs.transform,t=h.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 v.findDOMNode(this._getComponentAtPath(e))},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,r){t.length&&(t=parseFloat(t),isNaN(t))||this.refs.transform.setInputValue(e,t,r)},getInputPaths:function(){return"dynamic"===this.props.mode?[]:this.refs.transform.getInputPaths()}})},Tv={translation:{verbName:o._("Translate"),nounName:o._("Translation"),lowerNounName:o._("translation"),apply:function(e){return function(t){return w.add(t,e.vector)}},isValid:function(e){return h.isFinite(e.vector[0])&&h.isFinite(e.vector[1])},isEmpty:function(e){return null===e.vector[0]&&null===e.vector[1]},isNoOp:function(e){return w.equal(e.vector,[0,0])},collapse:function(e,t){return{vector:w.add(e.vector,t.vector)}},toTeX:function(e){return o.$_("Translation by %(vector)s",{vector:Ev(e.vector)})},Input:class extends a.Component{constructor(){super(...arguments),j(this,"state",{vector:this.props.vector||[null,null]}),j(this,"value",(()=>({vector:[this.refs.x.getValue(),this.refs.y.getValue()]}))),j(this,"setInputValue",((e,t,r)=>{var i=h.first(e),n=h.clone(this.state.vector);"x"===i?n[0]=t:"y"===i&&(n[1]=t),this.setState({vector:n},(()=>{this.props.onChange(r)}))})),j(this,"getInputPaths",(()=>[["x"],["y"]]))}componentDidUpdate(e){gv(this.props,e)||this.setState({vector:this.props.vector})}render(){var e=_v(this.props.apiOptions),{TeX:t}=ae(),r=[a.createElement(t,{key:"<"},o.doNotTranslate("\\langle")),a.createElement(e,{key:"vec_x",ref:"x",placeholder:0,value:this.state.vector[0],useArrowKeys:!0,onChange:e=>{var t=this.state.vector[1];this.setState({vector:[e,t]},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"x"),onBlur:h.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"vec_y",ref:"y",placeholder:0,value:this.state.vector[1],useArrowKeys:!0,onChange:e=>{var t=this.state.vector[0];this.setState({vector:[t,e]},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"y"),onBlur:h.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:">"},o.doNotTranslate("\\rangle"))];return a.createElement("div",null,o.$_("Translation by %(vector)s",{vector:r}))}}},rotation:{verbName:o._("Rotate"),nounName:o._("Rotation"),lowerNounName:o._("rotation"),apply:function(e){return function(t){return x.rotateDeg(t,e.angleDeg,e.center)}},isValid:function(e){return h.isFinite(e.angleDeg)&&h.isFinite(e.center[0])&&h.isFinite(e.center[1])},isEmpty:function(e){return null===e.angleDeg&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return b.equal(e.angleDeg,0)},collapse:function(e,t){return!!x.equal(e.center,t.center)&&{center:e.center,angleDeg:e.angleDeg+t.angleDeg}},toTeX:function(e){return o.$_("Rotation by %(degrees)s about %(point)s",{degrees:(t=e.angleDeg,Cv(t)+"°"),point:kv(e.center)});var t},Input:class extends a.Component{constructor(){super(...arguments),j(this,"state",{center:this.props.center||[null,null],angleDeg:this.props.angleDeg||null}),j(this,"value",(()=>({angleDeg:this.refs.angleDeg.getValue(),center:[this.refs.centerX.getValue(),this.refs.centerY.getValue()]}))),j(this,"setInputValue",((e,t,r)=>{var i=h.first(e),n=h.clone(this.state.angleDeg),o=h.clone(this.state.center);"angleDeg"===i?n=t:"centerX"===i?o[0]=t:"centerY"===i&&(o[1]=t),this.setState({angleDeg:n,center:o},(()=>{this.props.onChange(r)}))})),j(this,"getInputPaths",(()=>[["centerX"],["centerY"],["angleDeg"]]))}componentDidUpdate(e){gv(this.props,e)||this.setState({center:this.props.center,angleDeg:this.props.angleDeg})}render(){var e=_v(this.props.apiOptions),{TeX:t}=ae(),r=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"X",ref:"centerX",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{var t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"centerX"),onBlur:h.partial(this.props.onBlur,"centerX"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"Y",ref:"centerY",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{var t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"centerY"),onBlur:h.partial(this.props.onBlur,"centerY"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")],i=[a.createElement(e,{key:"deg",ref:"angleDeg",placeholder:0,value:this.state.angleDeg,useArrowKeys:!0,onChange:e=>{this.setState({angleDeg:e},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"angleDeg"),onBlur:h.partial(this.props.onBlur,"angleDeg"),keypadElement:this.props.keypadElement}),"°"],n=o.$_("Rotation about %(point)s by %(degrees)s",{point:r,degrees:i});return a.createElement("div",null,n)}}},reflection:{verbName:o._("Reflect"),nounName:o._("Reflection"),lowerNounName:o._("reflection"),apply:function(e){return function(t){return x.reflectOverLine(t,e.line)}},isValid:function(e){return h.all(h.flatten(e.line),h.isFinite)&&!x.equal(e.line[0],e.line[1])},isEmpty:function(e){return h.all(h.flatten(e.line),h.isNull)},isNoOp:function(e){return!1},collapse:function(e,t){return!!C.equal(e.line,t.line)&&[]},toTeX:function(e){var t=e.line[0],r=e.line[1];return o.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:kv(t),point2:kv(r)})},Input:class extends a.Component{constructor(){super(...arguments),j(this,"state",{line:this.props.line||[[null,null],[null,null]]}),j(this,"changePoint",((e,t,r,i)=>{var n=h.map(this.state.line,h.clone);n[e][t]=r,this.setState({line:n},(()=>{this.props.onChange(i)}))})),j(this,"value",(()=>({line:[[this.refs.x1.getValue(),this.refs.y1.getValue()],[this.refs.x2.getValue(),this.refs.y2.getValue()]]}))),j(this,"setInputValue",((e,t,r)=>{var i,n,o=h.first(e);"x"===o[0]?i=0:"y"===o[0]&&(i=1),"1"===o[1]?n=0:"2"===o[1]&&(n=1),this.changePoint(n,i,t,r)})),j(this,"getInputPaths",(()=>[["x1"],["y1"],["x2"],["y2"]]))}componentDidUpdate(e){gv(this.props,e)||this.setState({line:this.props.line})}render(){var e=_v(this.props.apiOptions),{TeX:t}=ae(),r=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"x1",ref:"x1",value:this.state.line[0][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,0),onFocus:h.partial(this.props.onFocus,"x1"),onBlur:h.partial(this.props.onBlur,"x1"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"y1",ref:"y1",value:this.state.line[0][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,1),onFocus:h.partial(this.props.onFocus,"y1"),onBlur:h.partial(this.props.onBlur,"y1"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")],i=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"x2",ref:"x2",value:this.state.line[1][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,0),onFocus:h.partial(this.props.onFocus,"x2"),onBlur:h.partial(this.props.onBlur,"x2"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"y2",ref:"y2",value:this.state.line[1][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,1),onFocus:h.partial(this.props.onFocus,"y2"),onBlur:h.partial(this.props.onBlur,"y2"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")];return a.createElement("div",null,o.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:r,point2:i}))}}},dilation:{verbName:o._("Dilate"),nounName:o._("Dilation"),lowerNounName:o._("dilation"),apply:function(e){return function(t){return function(e,t,r){var i=w.subtract(e,t),n=w.scale(i,r);return w.add(t,n)}(t,e.center,e.scale)}},isValid:function(e){return h.isFinite(e.scale)&&h.isFinite(e.center[0])&&h.isFinite(e.center[1])},isEmpty:function(e){return null===e.scale&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return b.equal(e.scale,1)},collapse:function(e,t){return!!x.equal(e.center,t.center)&&{center:e.center,scale:e.scale*t.scale}},toTeX:function(e){var t,r,i=(t=e.scale,1===(r=de.toFraction(t,b.DEFAULT_TOLERANCE))[1]?Cv(t):Cv(r[0])+"/"+Cv(r[1]));return o.$_("Dilation of scale %(scale)s about %(point)s",{scale:i,point:kv(e.center)})},Input:class extends a.Component{constructor(){super(...arguments),j(this,"state",{center:this.props.center||[null,null],scale:this.props.scale||null}),j(this,"value",(()=>({scale:this.refs.scale.getValue(),center:[this.refs.x.getValue(),this.refs.y.getValue()]}))),j(this,"setInputValue",((e,t,r)=>{var i=h.first(e),n=this.state.scale,o=h.clone(this.state.center);"x"===i?o[0]=t:"y"===i?o[1]=t:"scale"===i&&(n=t),this.setState({scale:n,center:o},(()=>{this.props.onChange(r)}))})),j(this,"getInputPaths",(()=>[["x"],["y"],["scale"]]))}componentDidUpdate(e){gv(this.props,e)||this.setState({center:this.props.center,scale:this.props.scale})}render(){var e=_v(this.props.apiOptions),{TeX:t}=ae(),r=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"point_x",ref:"x",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{var t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"x"),onBlur:h.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"point_y",ref:"y",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{var t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"y"),onBlur:h.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")],i=a.createElement(e,{ref:"scale",placeholder:1,value:this.state.scale,useArrowKeys:!0,onChange:e=>{this.setState({scale:e},(()=>{this.props.onChange()}))},onFocus:h.partial(this.props.onFocus,"scale"),onBlur:h.partial(this.props.onBlur,"scale"),keypadElement:this.props.keypadElement});return a.createElement("div",null,o.$_("Dilation about %(point)s by %(scale)s",{point:r,scale:i}))}}}},Iv={getPointCountForType:function(e){var t=e.split("-");return"polygon"===t[0]?t[1]||3:"line"===t[0]||"lineSegment"===t[0]?2:"angle"===t[0]?3:"circle"===t[0]?2:"point"===t[0]?1:void 0},addMovableShape:function(e,t){if(t.editable&&t.translatable)throw new ce("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously. options: "+JSON.stringify(t),pe.InvalidInput);var r=h.map(t.shape.coords,(function(n){var o=!1,s=n,a=e.addMovablePoint({coord:n,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:function(e,n){o||(s=a.coord,o=!0);var l=w.subtract([e,n],a.coord);t.onMove&&(l=t.onMove(l[0],l[1])),t.translatable&&h.each(r,(function(e){e!==a&&e.setCoord(w.add(e.coord,l))}));var p=a.coord,c=w.add(a.coord,l);return a.coord=c,i.update(),a.coord=p,c},onMoveEnd:function(){if(t.onMoveEnd&&o){o=!1;var e=w.subtract(a.coord,s);t.onMoveEnd(e[0],e[1])}i.update()}});return a.bounded=!0,a})),i=Iv.addShape(e,t,r),n=i.remove;return i.remove=function(){n.apply(i),h.invoke(r,"remove")},i},addShape:function(e,t,r){r=r||t.shape.coords;var i=Iv._typesOf(t.shape),n=t.shape.options||Iv.defaultOptions(i),o=Iv._mapTypes(i,r,(function(r,i,o){var s=h.extend({},t,n[o]);return Iv._addType(e,r,i,s)})),s=h.filter(h.pluck(o,"update"),h.identity),a=h.filter(h.pluck(o,"remove"),h.identity),l=function(){return h.map(o,(function(e){return e.getOptions?e.getOptions():{}}))};return{type:i,points:r,update:function(){h.invoke(s,"call")},remove:function(){h.invoke(a,"call")},toJSON:function(){var e=h.map(r,(function(e){return h.isArray(e)?e:e.coord}));return{type:i,coords:e,options:l()}},getOptions:l}},equal:function(e,t){var r=Iv._typesOf(e),i=Iv._typesOf(t);if(r.length!==i.length)return!1;var n=Iv._mapTypes(r,e.coords,Iv._combine),o=Iv._mapTypes(i,t.coords,Iv._combine);return h.all(h.map(n,(function(e,t){var r=o[t];return e.type===r.type&&Iv._forType(e.type).equal(e.coords,r.coords)})))},_typesOf:function(e){var t=e.type;return h.isArray(t)||(t=[t]),h.map(t,(function(e){return"polygon"===e?"polygon-3":e}))},defaultOptions:function(e){return h.map(e,(function(e){var t=Iv._forType(e).defaultOptions;return h.extend({},t)}))},_forType:function(e){var t=e.split("-")[0];return Iv[t]},_mapTypes:function(e,t,r,i){return h.map(e,(function(e,n){var o=Iv.getPointCountForType(e),s=h.first(t,o);return t=h.rest(t,o),r.call(i,e,s,n)}))},_addType:function(e,t,r,i){var n=h.isArray(r[0])?{coordA:r[0],coordZ:r[1]}:{pointA:r[0],pointZ:r[1]};if("polygon"===(t=t.split("-")[0])){var o=e.addMovablePolygon(h.extend({},i,{fixed:!i.editable,snapX:i.snap&&i.snap[0]||0,snapY:i.snap&&i.snap[1]||0,points:r,constrainToGraph:!1}));return{update:o.transform.bind(o),remove:o.remove.bind(o)}}if("line"===t||"lineSegment"===t){var s=e.addMovableLineSegment(h.extend({},i,n,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:"line"===t}));return{update:s.transform.bind(s,!0),remove:s.remove.bind(s)}}if("angle"===t){var a=!!i.editable&&null,l=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:r,normalStyle:i.normalStyle,reflex:i.reflex});return h.isArray(r[0])||i.editable||(r[0].remove(),r[2].remove()),{update:l.update.bind(l,a),remove:l.remove.bind(l),getOptions:function(){return{reflex:l.isReflex()}}}}if("circle"===t){var p={remove:h.identity},c=function(){var t=r[0].coord||r[0],n=r[1].coord||r[1],o=x.distanceToPoint(t,n);p.remove(),p=e.circle(t,o,h.extend({stroke:mr.DYNAMIC,"stroke-width":2},i.normalStyle))};return c(),r[1].remove&&!i.editable&&r[1].remove(),{update:c,remove:function(){p.remove()}}}if("point"===t)return{update:null,remove:null};throw new ce("Invalid shape type "+t,pe.InvalidInput)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:Sv},line:{equal:C.equal},lineSegment:{equal:Sv},angle:{equal:function(e,t){if(!x.equal(e[1],t[1]))return!1;var r=[e[1],e[0]],i=[e[1],e[2]],n=[t[1],t[0]],o=[t[1],t[2]],s=k.equal(r,n)&&k.equal(i,o),a=k.equal(r,o)&&k.equal(i,n);return s||a},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){var r=x.distanceToPoint(e[0],e[1]),i=x.distanceToPoint(t[0],t[1]);return x.equal(e[0],t[0])&&b.equal(r,i)}},point:{equal:x.equal}},Pv=Mv.ListItem;class Nv extends a.Component{constructor(){super(...arguments),j(this,"_transformationRefs",(()=>h.times(this.props.transformations.length,(e=>this.refs["transformation"+e])))),j(this,"value",(()=>h.invoke(this._transformationRefs(),"value"))),j(this,"handleChange",((e,t)=>{this.props.onChange(this.value(),t)})),j(this,"focusLast",(()=>{var e=this._transformationRefs();0!==e.length&&h.last(e).focus()}))}render(){if("static"===this.props.mode)return a.createElement("span",null);var e=h.map(this.props.transformations,(function(e,t){return a.createElement(Pv,{ref:"transformation"+t,key:"transformation"+t,transform:e,mode:this.props.mode,onChange:this.handleChange,onFocus:h.partial(this.props.onFocus,""+t),onBlur:h.partial(this.props.onBlur,""+t),keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions})}),this);return a.createElement("div",{className:"perseus-transformation-list"},e)}}class Av extends a.Component{render(){var e=this.props.toggled?"simple-button exercise-orange toggled highlighted-tool-button":"simple-button";return a.createElement("button",{type:"button",className:e,disabled:this.props.disabled,onClick:this.props.onClick,onTouchStart:vv},this.props.children)}}class Rv extends a.Component{constructor(){super(...arguments),j(this,"state",{selected:null}),j(this,"changeSelected",(e=>{this.props.removeTool(this.state.selected),e&&e!==this.state.selected?(this.props.addTool(e),this.setState({selected:e})):this.setState({selected:null})}))}render(){var e=h.map(Tv,(function(e,t){if(this.props.enabled[t])return a.createElement(Av,{key:t,disabled:this.props.apiOptions.readOnly,toggled:this.state.selected===t,onClick:this.changeSelected.bind(this,t)},e.verbName)}),this);return a.createElement("div",{className:"transformer-tools-bar"},a.createElement("span",{className:"simple-button-group"},e),a.createElement("button",{className:"transformer-undo-button simple-button",type:"button",disabled:this.props.apiOptions.readOnly,onClick:this.props.onUndoClick,onTouchStart:vv},a.createElement(X,Pi)," "+o._("Undo")),a.createElement("div",{className:"clear"}))}}class Fv extends a.Component{constructor(){super(...arguments),j(this,"changeSelected",(e=>{e&&this.props.addTool(e)}))}render(){var e=h.map(Tv,(function(e,t){if(this.props.enabled[t])return a.createElement(Av,{key:t,toggled:!1,disabled:this.props.apiOptions.readOnly,onClick:this.changeSelected.bind(this,t)},a.createElement(X,Si)," ",e.nounName)}),this);return a.createElement("div",{className:"transformer-tools-bar"},e,a.createElement("button",{className:"transformer-undo-button simple-button",type:"button",onClick:this.props.onUndoClick,disabled:this.props.apiOptions.readOnly,onTouchStart:vv},a.createElement(X,Pi)," "+o._("Undo")),a.createElement("div",{className:"clear"}))}}class Ov extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"tools",void 0),j(this,"currentTool",void 0),j(this,"transformations",void 0),j(this,"shape",void 0),j(this,"dilationCircle",void 0),j(this,"rotatePoint",void 0),j(this,"rotateHandle",void 0),j(this,"shouldSetupGraphie",((e,t)=>!gv(t.starting,e.starting)||(t.graphMode!==e.graphMode||(t.listMode!==e.listMode||(t.drawSolutionShape!==e.drawSolutionShape||(!(!e.drawSolutionShape||gv(t.correct.shape,e.correct.shape))||!gv(this.tools,e.tools))))))),j(this,"graphie",(()=>this.refs.graph.graphie())),j(this,"setupGraphie",(e=>{this.props.drawSolutionShape&&this.props.correct.shape&&this.props.correct.shape.coords&&Iv.addShape(e,{fixed:!0,shape:this.props.correct.shape,normalStyle:{stroke:mr.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:h.clone(this.props.tools.translation),rotation:h.clone(this.props.tools.rotation),reflection:h.clone(this.props.tools.reflection),dilation:h.clone(this.props.tools.dilation)}})),j(this,"setTransformations",(e=>{this.resetCoords(),this.transformations=h.clone(e),h.each(this.transformations,this.applyTransform)})),j(this,"addTransformerShape",((e,t)=>{var r=this,i=this.graphie();this.shape=Iv.addMovableShape(i,{shape:e,editable:!1,showPoints:"static"!==this.props.graphMode,translatable:t,onMove:function(e,t){return e=de.roundToNearest(i.snap[0],e),t=de.roundToNearest(i.snap[1],t),r.addTransform({type:"translation",vector:[e,t]}),[e,t]},normalPointStyle:{fill:t?mr.INTERACTIVE:mr.DYNAMIC,stroke:t?mr.INTERACTIVE:mr.DYNAMIC},highlightPointStyle:{fill:mr.INTERACTING,stroke:mr.INTERACTING}})})),j(this,"addTool",(e=>{var t=this;if("interactive"===this.props.graphMode)if("translation"===e)this.currentTool=this.addTranslationTool();else if("rotation"===e)this.currentTool=this.addRotationTool();else if("reflection"===e)this.currentTool=this.addReflectionTool();else{if("dilation"!==e)throw new ce("Invalid tool id: "+e,pe.InvalidInput);this.currentTool=this.addDilationTool()}else{var r;if("translation"===e)r={type:"translation",vector:[null,null]};else if("rotation"===e)r={type:"rotation",center:[null,null],angleDeg:null};else if("reflection"===e)r={type:"reflection",line:[[null,null],[null,null]]};else{if("dilation"!==e)throw new ce("Invalid tool id: "+e,pe.InvalidInput);r={type:"dilation",center:[null,null],scale:null}}this.doTransform(r,(function(){t.refs.transformationList.focusLast()}))}})),j(this,"removeTool",(e=>{this.currentTool&&this.currentTool.remove(),this.currentTool=null})),j(this,"addTranslationTool",(()=>{var e,t,r=this;return null===(e=this.shape)||void 0===e||e.remove(),this.addTransformerShape(null===(t=this.shape)||void 0===t?void 0:t.toJSON(),!0),{remove:function(){var e,t;null===(e=r.shape)||void 0===e||e.remove(),r.addTransformerShape(null===(t=r.shape)||void 0===t?void 0:t.toJSON(),!1)}}})),j(this,"snapCoord",(e=>{var t=this.graphie();return h.map(e,(function(e,r){return de.roundToNearest(t.snap[r],e)}))})),j(this,"normalizeReflectionCoords",(e=>{var t=this.snapCoord(C.midpoint(e)),r=w.polarDegFromCart(w.subtract(e[0],e[1])),i=w.cartFromPolarDeg(1,de.roundToNearest(45,r[1]));return h.map([-1,1],(function(e){var r=w.add(t,w.scale(i,e*this.scaleToCurrentRange(2)));return this.snapCoord(r)}),this)})),j(this,"addReflectionTool",(()=>{var e=this.props.tools.reflection;if(e.enabled){var t,r=this,i=this.refs.graph.graphie(),n=function(){r.changeTool("reflection",{coords:h.pluck(s,"coord")})},o=this.normalizeReflectionCoords(e.coords),s=h.map(o,(function(e){return i.addMovablePoint({coord:e,visible:!1})}),this),a=wv(e);i.style({},(function(){t=i.addMovableLineSegment({fixed:e.constraints.fixed,constraints:e.constraints,pointA:s[0],pointZ:s[1],snapX:i.snap[0],snapY:i.snap[1],extendLine:!0,normalStyle:{stroke:a,"stroke-width":2,"stroke-dasharray":"- "},highlightStyle:{stroke:mr.INTERACTING,"stroke-width":2,"stroke-dasharray":"- "},movePointsWithLine:!0,onMoveEnd:n})}));var l=i.addReflectButton({fixed:e.constraints.fixed,line:t,size:this.scaleToCurrentRange(1),onClick:function(){r.doTransform({type:"reflection",line:h.pluck(s,"coord")}),p&&(p.setCoord(w.add(l.coord,w.subtract(l.coord,p.coord))),p.update())},normalStyle:{stroke:a,"stroke-width":2,fill:a},highlightStyle:{stroke:mr.INTERACTING,"stroke-width":3,fill:mr.INTERACTING},onMoveEnd:n}),p=null;if(!e.constraints.fixed){var c=w.polarDegFromCart(w.subtract(s[1].coord,s[0].coord))[1]+90;p=i.addRotateHandle({center:l,radius:this.scaleToCurrentRange(2),angleDeg:c,width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),lengthAngle:17,onMove:function(e){return de.roundToNearest(45,e)},onMoveEnd:n})}return y(t).on("move",(function(){l.update(),y(l).trigger("move")})),p&&y(p).on("move",(function(){var e=r.snapCoord(p.coord),i=w.subtract(e,l.coord),n=l.isFlipped()?1:0;s[n].setCoord(w.add(l.coord,w.rotateDeg(i,90))),s[1-n].setCoord(w.add(l.coord,w.rotateDeg(i,-90))),t.transform(!0),l.update()})),{remove:function(){l.remove(),p&&p.remove(),t.remove(),s[0].remove(),s[1].remove()}}}})),j(this,"scaleToCurrentRange",(e=>function(e,t){var r=t[0][1]-t[0][0],i=t[1][1]-t[1][0];return e*Math.max(r,i)/20}(e,this.refs.graph.props.range))),j(this,"addRotationTool",(()=>{var e=this.props.tools.rotation;if(e.enabled){var t=this,r=this.refs.graph.graphie(),i=wv(e);return this.rotatePoint=r.addMovablePoint({constraints:e.constraints,coord:e.coord,snapX:r.snap[0],snapY:r.snap[1],normalStyle:{"stroke-dasharray":"",stroke:i,fill:i},highlightStyle:{"stroke-dasharray":"",stroke:mr.INTERACTING,fill:mr.INTERACTING}}),this.rotateHandle=r.addRotateHandle({center:this.rotatePoint,radius:this.scaleToCurrentRange(1.5),width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),onMove:function(e,r){var i=t.getRotationTransformFromAngle(t.rotatePoint.coord,e-r);return t.doTransform(i),r+i.angleDeg}}),this.rotatePoint.onMoveEnd=(e,r)=>{t.changeTool("rotation",{coord:[e,r]})},{remove:function(){var e,r;null===(e=t.rotateHandle)||void 0===e||e.remove(),null===(r=t.rotatePoint)||void 0===r||r.remove()}}}})),j(this,"addDilationTool",(()=>{var e=this.props.tools.dilation;if(e.enabled){var t=this,r=this.refs.graph.graphie(),i=wv(e);t.dilationCircle=r.addCircleGraph({centerConstraints:e.constraints,center:e.coord,radius:t.scaleToCurrentRange(2),snapX:r.snap[0],snapY:r.snap[1],minRadius:t.scaleToCurrentRange(1),snapRadius:t.scaleToCurrentRange(.5),onResize:function(e,r){t.doTransform({type:"dilation",center:t.dilationCircle.centerPoint.coord,scale:e/r})},circleNormalStyle:{stroke:i,"stroke-width":2,"stroke-dasharray":"- ","fill-opacity":0},circleHighlightStyle:{stroke:mr.INTERACTING,"stroke-width":2,"stroke-dasharray":"",fill:mr.INTERACTING,"fill-opacity":.05},centerNormalStyle:{stroke:i,fill:i,"stroke-width":2,"stroke-dasharray":""},centerHighlightStyle:{stroke:i,fill:i,"stroke-width":2,"stroke-dasharray":""}});var n=this.dilationCircle.centerPoint.onMoveEnd;return this.dilationCircle.centerPoint.onMoveEnd=function(){if(n){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];n(r)}t.changeTool("dilation",{coord:t.dilationCircle.centerPoint.coord})},{remove:function(){var e;null===(e=t.dilationCircle)||void 0===e||e.remove()}}}})),j(this,"getRotationTransformFromAngle",((e,t)=>((t=(t+360)%360)>180&&(t-=360),{type:"rotation",center:e,angleDeg:15*Math.round(t/15)}))),j(this,"doTransform",((e,t)=>{this.applyTransform(e),this.addTransform(e,t)})),j(this,"applyTransform",(e=>{if("static"!==this.props.graphMode){var t=Mv.apply(e);this.applyCoordTransformation(t)}})),j(this,"applyCoordTransformation",(e=>{var t;h.each(this.shape.points,(function(t){var r=e(t.coord);t.setCoord(r)})),null===(t=this.shape)||void 0===t||t.update()})),j(this,"resetCoords",(()=>{var e,t=this.props.starting.shape.coords;h.each(this.shape.points,(function(e,r){e.setCoord(t[r])})),null===(e=this.shape)||void 0===e||e.update()})),j(this,"handleUndoClick",(()=>{this.refs.toolsBar.changeSelected(null),this.props.transformations.length&&this.props.onChange({transformations:h.initial(this.props.transformations)})})),j(this,"setTransformationProps",((e,t)=>{this.props.onChange({transformations:e},t)})),j(this,"addTransform",((e,t)=>{this.transformations=Mv.append(this.transformations,e),this.props.onChange({transformations:h.clone(this.transformations)},t)})),j(this,"changeTool",((e,t)=>{var r=h.clone(this.props.tools);r[e]=h.extend({},this.props.tools[e],t),this.tools[e]=h.clone(r[e]),this.props.onChange({tools:r}),this.props.trackInteraction()})),j(this,"simpleValidate",(e=>Ov.validate(this.getUserInput(),e))),j(this,"getCoords",(()=>{var e=this.props.starting.shape.coords,t=this.props.transformations;return h.reduce(t,(function(e,t){return h.map(e,Mv.apply(t))}),e)})),j(this,"getEditorJSON",(()=>{var e=h.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})),j(this,"getUserInput",(()=>{var e;return{transformations:this.props.transformations,shape:{type:this.shape.type,coords:this.getCoords(),options:null===(e=this.shape)||void 0===e?void 0:e.getOptions()}}})),j(this,"_handleFocus",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];e.props.onFocus(r)})),j(this,"_handleBlur",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];e.props.onBlur(r)})),j(this,"_getTransformationForID",(e=>{var t=["transformationList","transformation"+e],r=this;return h.each(t,(e=>{r=r.refs[e]})),r})),j(this,"getInputPaths",(()=>{if("static"===this.props.listMode)return[];var e=[];return h.each(this.props.transformations,((t,r)=>{var i=this._getTransformationForID(r).getInputPaths(),n=h.map(i,(e=>[""+r].concat(e)));e=e.concat(n)})),e})),j(this,"_passToInner",(function(e,t){if(t&&t.length){for(var r=h.rest(t),i=h.head(t),n=this._getTransformationForID(i),o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];return n[e](r,...s)}})),j(this,"focus",(()=>{var e=this.getInputPaths();return e.length>0&&(this.focusInputPath(e[0]),!0)})),j(this,"focusInputPath",(e=>0!==e.length&&(yv(e.length>=2),this._passToInner("focusInputPath",e)))),j(this,"blurInputPath",(e=>0!==e.length&&(yv(e.length>=2),this._passToInner("blurInputPath",e)))),j(this,"setInputValue",((e,t,r)=>(yv(e.length>=2),this._passToInner("setInputValue",e,t,r)))),j(this,"getDOMNodeForPath",(e=>(yv(e.length>=2),this._passToInner("getDOMNodeForPath",e)))),j(this,"getGrammarTypeForPath",(e=>(yv(e.length>=2),this._passToInner("getGrammarTypeForPath",e))))}render(){var e,t,r,i,n,s,l,p=h.extend((e=this.props.graph,t=400,r=(e=e||{}).labels||["x","y"],i=e.range||[[-10,10],[-10,10]],n=e.step||[1,1],{box:[t,t],labels:r,range:i,step:n,gridStep:e.gridStep||fv(i,n,t),valid:!0,backgroundImage:bv,markings:"grid",showProtractor:!1}),this.props.graph),c="interactive"===this.props.graphMode,d=c?Rv:Fv,u=a.createElement("div",{style:{width:p.box[0]}},a.createElement(d,{ref:"toolsBar",enabled:(s=this.props.tools,l="enabled",h.object(h.map(s,(function(e,t){return[t,e[l]]})))),apiOptions:this.props.apiOptions,addTool:this.addTool,removeTool:this.removeTool,onUndoClick:this.handleUndoClick}));return a.createElement("div",{className:"perseus-widget perseus-widget-transformer"},a.createElement(Pu,{ref:"graph",box:p.box,range:p.range,labels:p.labels,step:p.step,gridStep:p.gridStep,markings:p.markings,backgroundImage:p.backgroundImage,showProtractor:p.showProtractor,onGraphieUpdated:this.setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!c&&o._("Add transformations below:"),"static"===this.props.graphMode&&[a.createElement("br",{key:"static-br"}),a.createElement("em",{key:"static-nomove"}," ",o._("Note: For this question, the shape will not move.")," ")],c&&u,a.createElement(Nv,{ref:"transformationList",mode:this.props.listMode,transformations:this.props.transformations,onChange:this.setTransformationProps,onFocus:this._handleFocus,onBlur:this._handleBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions}),!c&&u)}componentDidMount(){this.setupGraphie(this.graphie())}componentDidUpdate(e){this.shouldSetupGraphie(this.props,e)?this.refs.graph.reset():gv(this.props.transformations,this.transformations)||this.setTransformations(this.props.transformations)}static validate(e,t){var r=function(r){if(t.tools[r].required){var i=h.any(h.map(e.transformations,(function(e){return e.type===r&&!Mv.isEmpty(e)&&!Mv.isNoOp(e)})));if(!i)return{v:{type:"invalid",message:o._("Your transformation must use a %(type)s.",{type:Tv[r].lowerNounName})}}}};for(var i in Tv){var n=r(i);if("object"==typeof n)return n.v}return Iv.equal(e.shape,t.correct.shape)?{type:"points",earned:1,total:1,message:null}:!t.gradeEmpty&&gv(e.shape.coords,t.starting.shape.coords)?{type:"invalid",message:o._("Use the interactive graph to define a correct transformation.")}:{type:"points",earned:0,total:1,message:null}}}j(Ov,"defaultProps",h.defaults({transformations:[]},xv));var Dv,Lv={name:"transformer",displayName:"Transformer",widget:Ov},Bv={exports:{}};Dv=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){var r=function(e){return e===Object(e)},i=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];if(r)for(var i in r)e[i]=r[i]}return e};e.exports={isObject:r,merge:i,clone:function(e){return r(e)?Array.isArray(e)?e.slice():i(e):e}}},function(e,t,r){var i=r(0),n=i.clone,o=i.isObject,s=i.merge,a=r(2),l=r(3),p=r(4),h=function(e){return Array.isArray(e)?a:o(e)?l:"string"==typeof e?p:void 0},c=function e(t){if(t instanceof e)return t;if(!(this instanceof e))return new e(t);var r=h(t);this._wrapped=r.thaw?r.thaw(t):t};c.prototype.freeze=function(){var e=this._wrapped,t=h(e);return t.freeze?t.freeze(e):e},c.prototype.zoom=function(e){return void 0===this._zoomStack&&(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){for(var t=this._wrapped,r=0;r<e.length;r++)t=h(t).get(t,e[r]);return t},c.prototype.mod=function(e,t){var r=this._wrapped,i=n(r),o=h(r);if(0===e.length)this._wrapped=t(this._wrapped);else if(1===e.length)this._wrapped=o.mod(i,e[0],t);else{var s=e[0],a=e.slice(1);i[s]=c(r[s]).mod(a,t).freeze(),this._wrapped=i}return this},c.prototype.merge=function(e,t){return this._wrapped=c(this._wrapped).mod(e,(function(e){return s(e,t)})).freeze(),this},c.prototype.del=function(e){var t=this._wrapped,r=h(t);if(1===e.length)this._wrapped=r.del(t,e[0]);else{var i=e[0],o=e.slice(1),s=n(t);s[i]=c(t[i]).del(o).freeze(),this._wrapped=s}return this},c.prototype.set=function(e,t){return this.mod(e,(function(){return t}))},e.exports=c},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,r){var i=e.splice();return i[t]=r,i},mod:function(e,t,r){var i=e.slice();return i[t]=r(e[t]),i},del:function(e,t){var r=e.slice();return r.splice(t,1),r}}},function(e,t,r){var i=r(0).clone;e.exports={get:function(e,t){return e[t]},set:function(e,t,r){var n=i(e);return n[t]=r,n},mod:function(e,t,r){var n=i(e);return n[t]=r(e[t]),n},del:function(e,t){var r=i(e);return delete r[t],r}}},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,r){var i=e.splice();return i[t]=r,i},mod:function(e,t,r){var i=e.splice();return i[t]=r(e[t]),i},del:function(e,t){var r=e.slice();return r.splice(t),r}}}])};var zv=dr(Bv.exports=Dv());class Hv{constructor(e){j(this,"order",void 0),j(this,"mantissa",void 0),j(this,"positive",void 0),j(this,"sigFigs",void 0),j(this,"sigDecs",void 0),this.order=Vv(e),this.mantissa=Gv(e),this.positive=Uv(e),this.sigFigs=this.mantissa.length,this.sigDecs=this.order-this.mantissa.length}}function Wv(e,t,r,i){var n,o,s,a=""+e,l=Vv(a),p=Gv(a),h=Uv(a),c=!1;if(0==e||""==p||"0"==p){p="";for(var d=0;d<t;d++)p+="0";l=t+r,r<0&&-r>=t&&(c=!0)}else{if(o=l-p.length-r,s=t-p.length,(n=Math.min(s,o))<0){var u=jv(p,-n);u.length>p.length+n&&(l++,o>s&&(u=jv(u,1))),p=u}else if(n>0)for(var m=0;m<n;m++)p+="0";""!=p&&"0"!=p||(p="0",h=!0,0!=(l=1+r)&&(c=!0))}var g="";if(h||(g+="-"),i||p.length>20||l>4||l<-2||l-p.length>0&&qv(p)>0||c)g+=p.charAt(0),p.length>1&&(g+="."+p.substring(1,p.length)),l-1!=0&&(g+=" x 10^"+(l-1));else{var f="",v="",y=!0;if(l>0)if(p.length>l)f=p.substring(0,l),v=p.substring(l,p.length);else{f=p,y=0!=qv(p);for(var b=0;b<l-p.length;b++)f+="0"}else{for(var x=0;x<-l;x++)v+="0";v+=p}g+=(""==f?"0":f)+(y?".":"")+v}return g}function qv(e){for(var t=0,r=e.length-1;r>=0;r--){if("0"!=e.charAt(r))return t;t++}return t}function Uv(e){for(var t=!0,r=!1,i=!1,n="",o="",s=!0,a=0;a<e.length;a++){var l=e.charAt(a);l>="1"&&l<="9"?(o+=n+l,n="",i=!0,t=!1):"0"==l?(r?i&&(o+=n+l,n=""):i&&(n+=l),t=!1):r||"."!=l?"e"==l||"E"==l&&a+1<e.length?(parseInt(e.substring(a+1,e.length)),a=e.length):!t||"+"!=l&&"-"!=l||"-"==l&&(s=!s):(o+=n,n="",r=!0,t=!1)}return""==o||s}function Gv(e){for(var t=!1,r=!1,i="",n="",o="",s=0;s<e.length;s++){var a=e.charAt(s);a>="1"&&a<="9"?(o+=i+a,i="",r=!0):"0"==a?t?r?(o+=i+a,i=""):n+=a:r?(n+=a,i+=a):n+=a:t||"."!=a?("e"==a||"E"==a&&s+1<e.length)&&(parseInt(e.substring(s+1,e.length)),s=e.length):(o+=i,i="",t=!0)}return""==o?n:o}function Vv(e){for(var t=!1,r=!1,i="",n="",o=0,s=0,a=0;a<e.length;a++){var l=e.charAt(a);if(l>="1"&&l<="9")n+=i+l,i="",r=!0,t||(s++,o++);else if("0"==l)t?r?(n+=i+l,i=""):o--:(s++,r&&(o++,i+=l));else if(t||"."!=l){if("e"==l||"E"==l&&a+1<e.length){var p=parseInt(e.substring(a+1,e.length));o+=p,s+=p,a=e.length}}else n+=i,i="",t=!0}return""==n?s:o}function jv(e,t){var r=e.length-t-1;if(r<0)return"";if(r>=e.length-1)return e;var i=e.charAt(r+1),n=e.charAt(r),o=!1;if(i>"5")o=!0;else if("5"==i){for(var s=r+2;s<e.length;s++)"0"!=e.charAt(s)&&(o=!0);n%2==1&&(o=!0)}for(var a="",l=r;l>=0;l--){var p=e.charAt(l);if(o){var h=void 0;if("9"==p)h="0";else{switch(p){case"0":h="1";break;case"1":h="2";break;case"2":h="3";break;case"3":h="4";break;case"4":h="5";break;case"5":h="6";break;case"6":h="7";break;case"7":h="8";break;case"8":h="9"}o=!1}a=h+a}else a=p+a}return o&&(a="1"+a),a}class Yv extends a.Component{constructor(){var t;super(...arguments),t=this,j(this,"_errorTimeout",void 0),j(this,"_showError",(()=>{if(""!==this.props.value){var e=y(v.findDOMNode(this.refs.error));e.is(":visible")||e.css({top:50,opacity:.1}).show().animate({top:0,opacity:1},300)}})),j(this,"_hideError",(()=>{var e=y(v.findDOMNode(this.refs.error));e.is(":visible")&&e.animate({top:50,opacity:.1},300,(function(){y(this).hide()}))})),j(this,"change",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return gs.apply(t,r)})),j(this,"handleBlur",(()=>{this.props.onBlur([]),clearTimeout(this._errorTimeout),e.unitParse(this.props.value).parsed||this._showError()})),j(this,"handleChange",(e=>{this._hideError(),this.props.onChange({value:e.target.value})})),j(this,"simpleValidate",((e,t)=>Yv.validate(this.getUserInput(),e))),j(this,"getUserInput",(()=>this.props.value)),j(this,"getInputPaths",(()=>[[]])),j(this,"focusInputPath",(e=>{var t=v.findDOMNode(this.refs.input);t&&t.focus()})),j(this,"handleFocus",(()=>{this.props.onFocus([])})),j(this,"blurInputPath",(e=>{var t=v.findDOMNode(this.refs.input);t&&t.blur()})),j(this,"setInputValue",((e,t,r)=>{this.props.onChange({value:t},r)})),j(this,"getDOMNodeForPath",(()=>v.findDOMNode(this.refs.input))),j(this,"getGrammarTypeForPath",(e=>"unit"))}static validate(t,r){var i=e.unitParse(r.value).expr,n=e.unitParse(t);if(!n.parsed)return{type:"invalid",message:o._("I couldn't understand those units.")};var s,a,l,p=null,c=r.sigfigs,d=(s=n.coefficient,new Hv(s).sigFigs===c);d||(p=o._("Check your significant figures."));try{var u=new e.Var("x"),m=new e.Eq(i.simplify(),"=",new e.Mul(u,n.expr.simplify())).solveLinearEquationForVariable(u);a=Number(m.eval()).toPrecision(c)===Number(1).toPrecision(c)}catch(e){a=!1}a||(p=o._("That answer is numerically incorrect."));var g=$v(n.expr.simplify()),f=$v(i.simplify());return(l="all"===r.accepting?e.compare(g,f).equal:h(r.acceptingUnits).any((t=>{var r=$v(e.unitParse(t).unit.simplify());return e.compare(r,g).equal})))||(p=o._("Check your units.")),{type:"points",earned:l&&a&&d?1:0,total:1,message:p}}render(){var e=this.props.apiOptions.staticRender?a.createElement(es,{onChange:this.handleChange,ref:"input",className:Jt.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur}):a.createElement("input",{onChange:this.handleChange,ref:"input",className:Jt.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur});return a.createElement("div",{className:"old-unit-input"},e,a.createElement("div",{ref:"error",className:"error",style:{display:"none"}},o._("I don't understand that")))}componentDidUpdate(){clearTimeout(this._errorTimeout),e.unitParse(this.props.value).parsed?this._hideError():this._errorTimeout=setTimeout(this._showError,2e3)}componentWillUnmount(){clearTimeout(this._errorTimeout)}}j(Yv,"defaultProps",{apiOptions:Zt.defaults,value:""});var $v=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()},Xv={name:"unit-input",displayName:"Unit",defaultAlignment:"inline-block",widget:Yv,transform:e=>zv(e).del(["value"]).freeze(),version:{major:0,minor:1},hidden:!0};const Kv=F.large_24,Zv={small:{query:"(max-width: 767px)",totalColumns:4,gutterWidth:F.medium_16,marginWidth:F.medium_16},medium:{query:"(min-width: 768px) and (max-width: 1023px)",totalColumns:8,gutterWidth:F.xLarge_32,marginWidth:F.large_24},large:{query:"(min-width: 1024px)",totalColumns:12,gutterWidth:F.xLarge_32,marginWidth:Kv,maxWidth:1120+2*Kv}},Jv={large:{query:"(min-width: 1px)",totalColumns:12,gutterWidth:F.xLarge_32,marginWidth:F.medium_16}},Qv={small:{query:"(max-width: 767px)",totalColumns:4,gutterWidth:F.medium_16,marginWidth:F.medium_16},large:{query:"(min-width: 768px)",totalColumns:12,gutterWidth:F.xLarge_32,marginWidth:F.xxLarge_48}},ey={ssrSize:"large",mediaSpec:Zv};a.createContext(ey),[].concat(Object.values(Zv).map((e=>e.query)),Object.values(Jv).map((e=>e.query)),Object.values(Qv).map((e=>e.query))),m.create({grow:{flexGrow:1}});class ty extends a.Component{render(){const{size:e,style:t}=this.props;return a.createElement(A,{"aria-hidden":"true",style:[ry(e),t]})}}const ry=e=>({width:e,MsFlexBasis:e,MsFlexPreferredSize:e,WebkitFlexBasis:e,flexBasis:e,flexShrink:0});var iy=/^https?:\/\//,ny=e=>{var t,r,{location:i}=e,{useVideo:n}=ae(),[s,l]=iy.test(i)?[(t=i,r=t.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/),r&&11===r[7].length?r[7]:"videoNotFound"),"YOUTUBE_ID"]:[i,"READABLE_ID"],p=n(s,l);switch(p.status){case"loading":return a.createElement(A,null,o._("Loading..."));case"success":var h,c=null===(h=p.data)||void 0===h?void 0:h.video;return a.createElement(A,{style:oy.transcriptLink},a.createElement(P,null,null==c?void 0:c.title),a.createElement(ty,{size:10}),a.createElement(H,{href:"/transcript/"+((null==c?void 0:c.contentId)||"videoNotFound"),target:"_blank",className:"visited-no-recolor"},o._("See video transcript")));default:return a.createElement(A,null,o._("Something went wrong."))}},oy=m.create({transcriptLink:{flexDirection:"row",width:"100%",justifyContent:"center"}}),sy="{host}/embed_video?slug={slug}&internal_video_only=1",ay=/^https?:\/\//,ly=/(khanacademy\.org|localhost)/;class py extends a.Component{constructor(){var e;super(...arguments),e=this,j(this,"getUserInput",(()=>null)),j(this,"simpleValidate",(e=>py.validate(null,e))),j(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return gs.apply(e,r)}))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e,{InitialRequestUrl:t}=ae(),r=this.props.location;if(!r)return a.createElement("div",null);if(ay.test(r))e=r;else{e=sy.replace("{slug}",r);var i="https://www.khanacademy.org";ly.test(t.host)&&(i=t.origin),e=e.replace("{host}",i)}return a.createElement(A,null,a.createElement(or,{width:1280,height:720,key:r+this.props.alignment},a.createElement(A,{style:ml.srOnly},o._("Khan Academy video wrapper")),a.createElement("iframe",{className:"perseus-video-widget",sandbox:"allow-same-origin allow-scripts",width:1280,height:720,src:e,allowFullScreen:!0})),a.createElement(ny,{location:r}))}}var hy=[Kl,rp,lp,mp,sp,zd,ed,nd,Wd,Gd,$d,du,em,lm,wm,Km,Nm,Qm,Tg,zg,Vg,Pf,zs,Yg,Ff,Lf,zf,iv,av,mv,Lv,Xv,{name:"video",displayName:"Video",defaultAlignment:"block",supportedAlignments:["block","float-left","float-right","full-width"],widget:py}],cy=function(e){return go(jl),go(hy),e.skipMathJax?Promise.resolve():new Promise(((e,t)=>{MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:"none","HTML-CSS":{availableFonts:["TeX"],imageFont:null,scale:100,showMathMenu:!1}}),MathJax.Hub.Configured(),MathJax.Hub.Queue(e)}))},dy=[...jl,...hy];go(dy);var uy=yo();uy["::renderer::"]=q;var my={propTypes:{apiOptions:d.shape({customKeypad:d.bool,nativeKeypadProxy:d.func}),keypadStyle:d.any},getInitialState(){var e=this,t=null;return e.props.apiOptions&&e.props.apiOptions.customKeypad&&e.props.apiOptions.nativeKeypadProxy&&(t=e.props.apiOptions.nativeKeypadProxy((()=>e.blur&&e.blur()))),{keypadElement:t}},componentDidMount(){var e,t=this;t.props.apiOptions&&t.props.apiOptions.customKeypad&&!t.props.apiOptions.nativeKeypadProxy&&(t._keypadContainer=document.createElement("div"),null===(e=document.body)||void 0===e||e.appendChild(t._keypadContainer),v.render(a.createElement(n,{onElementMounted:e=>{t.setState({keypadElement:e})},onDismiss:()=>{t.blur&&t.blur()},style:t.props.keypadStyle}),t._keypadContainer))},componentWillUnmount(){var e=this;e._keypadContainer&&(v.unmountComponentAtNode(e._keypadContainer),e._keypadContainer.parentNode&&e._keypadContainer.parentNode.removeChild(e._keypadContainer),e._keypadContainer=null)},keypadElement(){return this.state.keypadElement}},gy=d.shape({content:d.string,widgets:d.objectOf(d.any),images:d.objectOf(d.any)});class fy extends a.Component{constructor(e){super(e),j(this,"_currentFocus",void 0),j(this,"keypadElement",(()=>my.keypadElement.call(this))),j(this,"_handleFocusChange",((e,t)=>{e?this._setCurrentFocus(e):this._onRendererBlur(t)})),j(this,"_setCurrentFocus",(e=>{var t=this.keypadElement(),r=this._currentFocus;this._currentFocus=e;var i=!1;if(this._currentFocus){var[n,...o]=this._currentFocus;i=this.refs[n].getInputPaths().some((e=>De.inputPathsEqual(e,o)))}null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,r,i&&t&&t.getDOMNode()),t&&(i?t.activate():t.dismiss())})),j(this,"_onRendererBlur",(e=>{var t=this._currentFocus;De.inputPathsEqual(e,t)&&setTimeout((()=>{De.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))})),j(this,"blur",(()=>{if(this._currentFocus){var[e,...t]=this._currentFocus;this.refs[e].blurPath(t)}})),j(this,"_sections",(()=>Array.isArray(this.props.json)?this.props.json:[this.props.json])),this.state=my.getInitialState.call(this)}componentDidMount(){my.componentDidMount.call(this),this._currentFocus=null}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}componentWillUnmount(){my.componentWillUnmount.call(this)}render(){var e=G(G(G({},Zt.defaults),this.props.apiOptions),{},{isArticle:!0}),t=s({"framework-perseus":!0,"perseus-article":!0,"bibliotron-article":this.props.useNewStyles,[Jt.MOBILE]:e.isMobile}),r=this._sections().map(((t,r)=>{var i="section-".concat(r);return a.createElement("div",{key:r,className:"clearfix"},a.createElement(Bo,Y({},t,{ref:i,key:r,key_:r,keypadElement:this.keypadElement(),apiOptions:G(G({},e),{},{onFocusChange:(e,t)=>{this._handleFocusChange(e&&[i].concat(e),t&&[i].concat(t))}}),linterContext:Ut.pushContextStack(this.props.linterContext,"article"),legacyPerseusLint:this.props.legacyPerseusLint})))}));return a.createElement("div",{className:t},r)}}j(fy,"propTypes",G(G({},my.propTypes),{},{apiOptions:d.shape({onFocusChange:d.func,isMobile:d.bool}),json:d.oneOfType([gy,d.arrayOf(gy)]).isRequired,useNewStyles:d.bool,linterContext:Gt,legacyPerseusLint:d.arrayOf(d.string)})),j(fy,"defaultProps",{apiOptions:{},useNewStyles:!1,linterContext:Vt});class vy extends a.Component{constructor(){super(...arguments),j(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),j(this,"restoreSerializedState",((e,t)=>{this.refs.renderer.restoreSerializedState(e,t)}))}render(){var{apiOptions:e,className:t,hint:r,lastHint:i,lastRendered:n,pos:l,totalHints:p}=this.props,{isMobile:h}=e,c=s(!h&&"perseus-hint-renderer",h&&g(yy.newHint),h&&n&&g(yy.lastRenderedNewHint),i&&"last-hint",n&&"last-rendered",t),d=G(G({},e),{},{customKeypad:!1,staticRender:!1});return a.createElement("div",{className:c,tabIndex:"-1"},!e.isMobile&&a.createElement("span",{className:"perseus-sr-only"},o._("Hint #%(pos)s",{pos:l+1})),!e.isMobile&&!e.satStyling&&p&&null!=l&&a.createElement("span",{className:"perseus-hint-label",style:{display:"block",color:e.hintProgressColor}},"".concat(l+1," / ").concat(p)),a.createElement(Bo,{ref:"renderer",widgets:r.widgets,content:r.content||"",images:r.images,apiOptions:d,findExternalWidgets:this.props.findExternalWidgets,linterContext:Ut.pushContextStack(this.props.linterContext,"hint")}))}}j(vy,"defaultProps",{linterContext:Vt});var yy=m.create({newHint:{marginBottom:24,borderLeftColor:"#F6F7F7",borderLeftStyle:"solid",borderLeftWidth:4,[$s.lgOrSmaller]:{paddingLeft:16},[$s.smOrSmaller]:{paddingLeft:0},":focus":{outline:"none"}},lastRenderedNewHint:{marginBottom:0,borderLeftColor:"#71B307"}});class by extends a.Component{constructor(){super(...arguments),j(this,"state",{isFinalHelpPage:!1}),j(this,"_hintsVisible",(()=>null==this.props.hintsVisible||-1===this.props.hintsVisible?this.props.hints.length:this.props.hintsVisible)),j(this,"_cacheImagesInHint",(e=>{h.each(e.images,((e,t)=>{(new Image).src=De.getRealImageUrl(t)}))})),j(this,"_cacheHintImages",(()=>{this._hintsVisible()>0?h.each(this.props.hints,this._cacheImagesInHint):this.props.hints.length>0&&this._cacheImagesInHint(this.props.hints[0])})),j(this,"getApiOptions",(()=>G(G(G({},Zt.defaults),this.props.apiOptions),{},{readOnly:!1}))),j(this,"getSerializedState",(()=>h.times(this._hintsVisible(),(e=>this.refs["hintRenderer"+e].getSerializedState())))),j(this,"restoreSerializedState",((e,t)=>{var r=1,i=()=>{--r,t&&0===r&&t()};h.each(e,((e,t)=>{var n=this.refs["hintRenderer"+t];n&&(++r,n.restoreSerializedState(e,i))})),i()}))}componentDidMount(){this._cacheHintImages()}UNSAFE_componentWillReceiveProps(e){e.hintsVisible-this.props.hintsVisible>1&&this.setState({isFinalHelpPage:!0})}componentDidUpdate(e,t){if(h.isEqual(e.hints,this.props.hints)&&e.hintsVisible===this.props.hintsVisible||this._cacheHintImages(),e.hintsVisible<this.props.hintsVisible){var r=this.props.hintsVisible-1;v.findDOMNode(this.refs["hintRenderer"+r]).focus()}}render(){var e=this.getApiOptions(),t=this._hintsVisible(),r=[],i=this.state.isFinalHelpPage;this.props.hints.slice(0,t).forEach(((n,o)=>{var s=o===this.props.hints.length-1&&!/\*\*/.test(n.content),l=o===t-1,p=a.createElement(vy,{lastHint:s,lastRendered:l,hint:n,pos:o,totalHints:this.props.hints.length,ref:"hintRenderer"+o,key:"hintRenderer"+o,apiOptions:e,findExternalWidgets:this.props.findExternalWidgets,linterContext:Ut.pushContextStack(this.props.linterContext,"hints["+o+"]")});i?r.push(p):n.replace&&r.length>0?r[r.length-1]=p:r.push(p)}));var{getAnotherHint:n}=e,l=n&&t>0&&t<this.props.hints.length,p="(".concat(t,"/").concat(this.props.hints.length,")"),h=s(this.props.className,e.isMobile&&t>0&&g(xy.mobileHintStylesHintsRenderer));return a.createElement("div",{className:h},e.isMobile&&t>0&&a.createElement("div",{className:g(xy.mobileHintStylesHintTitle,ta.responsiveLabel)},o._("Hints")),r,l&&a.createElement("button",{rel:"button",className:g(xy.linkButton,xy.getAnotherHintButton,e.isMobile&&xy.mobileHintStylesGetAnotherHintButton),onClick:e=>{e.preventDefault(),e.stopPropagation(),n&&n()}},a.createElement("span",{className:g(xy.plusText,e.isMobile&&xy.mobileHintStylesPlusText)},"+"),a.createElement("span",{className:g(xy.getAnotherHintText)},o._("Get another hint")," ",p)))}}j(by,"defaultProps",{linterContext:Vt});var xy=m.create({rendererMargins:{marginTop:16},linkButton:{cursor:"pointer",border:"none",backgroundColor:"transparent",fontSize:"100%",fontFamily:"inherit",fontWeight:"bold",color:"#71B307",padding:0,position:"relative"},plusText:{fontSize:20,position:"absolute",top:-3,left:0},getAnotherHintText:{marginLeft:16},mobileHintStylesHintsRenderer:{marginTop:64,border:"solid ".concat("#D6D8DA"),borderWidth:"1px 0 0 0",position:"relative",":before":{content:'""',display:"table",clear:"both"},":after":{content:'""',display:"table",clear:"both"}},mobileHintStylesHintTitle:{fontFamily:"inherit",fontStyle:"normal",fontWeight:"bold",color:ee,paddingTop:16,paddingBottom:24,[$s.lgOrSmaller]:{paddingLeft:0},[$s.smOrSmaller]:{paddingLeft:20}},getAnotherHintButton:{marginTop:24},mobileHintStylesGetAnotherHintButton:{[$s.lgOrSmaller]:{paddingLeft:0},[$s.smOrSmaller]:{paddingLeft:20}},mobileHintStylesPlusText:{[$s.lgOrSmaller]:{left:0},[$s.smOrSmaller]:{left:20}}}),{mapObject:wy}=_r;class Cy extends a.Component{constructor(e){super(e),j(this,"questionRenderer",void 0),j(this,"hintsRenderer",void 0),j(this,"_currentFocus",void 0),j(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),j(this,"handleInteractWithWidget",(e=>{var t=h.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),this.state=G(G({},my.getInitialState.call(this)),{},{hintsVisible:e.initialHintsVisible||0,questionCompleted:!1,questionHighlightedWidgets:[]})}componentDidMount(){my.componentDidMount.call(this),this.props.controlPeripherals&&this.props.apiOptions.setDrawingAreaAvailable&&this.props.apiOptions.setDrawingAreaAvailable(!0),this._currentFocus=null,this.update()}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(){this.update()}componentWillUnmount(){my.componentWillUnmount.call(this);var e=document.querySelector(this.props.workAreaSelector);null!=e&&f.unmountComponentAtNode(e);var t=document.querySelector(this.props.hintsAreaSelector);if(null!=t&&f.unmountComponentAtNode(t),this.props.controlPeripherals){var r=this.props.item.answerArea||{};r.calculator&&y("#calculator").hide(),r.periodicTable&&y(".periodic-table-info-box").hide(),r.zTable&&y(".z-table-info-box").hide(),r.tTable&&y(".t-table-info-box").hide(),r.chi2Table&&y(".chi2-table-info-box").hide()}}keypadElement(){return my.keypadElement.call(this)}update(){var e=G(G(G({},Zt.defaults),this.props.apiOptions),{},{onFocusChange:this._handleFocusChange}),t=document.querySelector(this.props.workAreaSelector),r=document.querySelector(this.props.hintsAreaSelector);if(t&&r){f.render(a.createElement(Bo,Y({ref:t=>{if(t){this.questionRenderer=t;var{answerableCallback:r}=e;if(r)r(0===this.questionRenderer.emptyWidgets().length)}},keypadElement:this.keypadElement(),problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,savedState:this.props.savedState,linterContext:Ut.pushContextStack(this.props.linterContext,"question")},this.props.item.question,{legacyPerseusLint:this.props.legacyPerseusLint})),t),f.render(a.createElement(by,{ref:e=>this.hintsRenderer=e,hints:this.props.item.hints,hintsVisible:this.state.hintsVisible,apiOptions:e,linterContext:Ut.pushContextStack(this.props.linterContext,"hints")}),r);var i=this.props.item.answerArea||{};this.props.controlPeripherals?(y("#calculator").toggle(i.calculator||!1),y(".periodic-table-info-box").toggle(i.periodicTable||!1),y(".z-table-info-box").toggle(i.zTable||!1),y(".t-table-info-box").toggle(i.tTable||!1),y(".chi2-table-info-box").toggle(i.chi2Table||!1)):(i.calculator&&this.props.onShowCalculator&&this.props.onShowCalculator(),i.periodicTable&&this.props.onShowPeriodicTable&&this.props.onShowPeriodicTable(),i.zTable&&this.props.onShowZTable&&this.props.onShowZTable(),i.tTable&&this.props.onShowTTable&&this.props.onShowTTable(),i.chi2Table&&this.props.onShowChi2Table&&this.props.onShowChi2Table())}}_setCurrentFocus(e){var t=this.keypadElement(),r=this._currentFocus;this._currentFocus=e;var i=this.getInputPaths(),n=this._currentFocus&&i.some((e=>De.inputPathsEqual(e,this._currentFocus)));null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,r,n&&t&&t.getDOMNode()),t&&(n?t.activate():t.dismiss())}_onRendererBlur(e){var t=this._currentFocus;De.inputPathsEqual(e,t)&&setTimeout((()=>{De.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))}_setWidgetProps(e,t,r){this.questionRenderer._setWidgetProps(e,t,r)}setInputValue(e,t,r){return this.questionRenderer.setInputValue(e,t,r)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}showHint(){this.state.hintsVisible<this.getNumHints()&&this.setState({hintsVisible:this.state.hintsVisible+1})}getNumHints(){return this.props.item.hints.length}scoreInput(){var e=this.questionRenderer.guessAndScore(),t=e[0],r=e[1],i=[t,[]],n=De.keScoreFromPerseusScore(r,i,this.questionRenderer.getSerializedState()),o=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:n.correct,questionHighlightedWidgets:o}),n}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){var e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),r=this.questionRenderer.getSerializedState();return wy(e,((e,i)=>De.keScoreFromPerseusScore(e,t[i],r[i])))}getSerializedState(){var e;return{question:this.questionRenderer.getSerializedState(),hints:null===(e=this.hintsRenderer)||void 0===e?void 0:e.getSerializedState()}}restoreSerializedState(e,t){var r,i=2,n=()=>{--i,t&&0===i&&t()};this.questionRenderer.restoreSerializedState(e.question,n),null===(r=this.hintsRenderer)||void 0===r||r.restoreSerializedState(e.hints,n)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){return a.createElement("div",null)}}j(Cy,"defaultProps",{apiOptions:Zt.defaults,controlPeripherals:!0,hintsAreaSelector:"#hintsarea",initialHintsVisible:0,workAreaSelector:"#workarea",reviewMode:!1,linterContext:Vt});var ky={onRendered:e=>{}},Ey=a.createContext(ky),{mapObject:Sy}=_r;class _y extends a.Component{constructor(e){super(e),j(this,"questionRenderer",void 0),j(this,"hintsRenderer",void 0),j(this,"_currentFocus",void 0),j(this,"_fullyRendered",void 0),j(this,"blurTimeoutID",void 0),j(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),j(this,"handleInteractWithWidget",(e=>{var t=h.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),j(this,"setAssetStatus",((e,t)=>{var r=G(G({},this.state.assetStatuses),{},{[e]:t});this.setState({assetStatuses:r})})),this.state={questionCompleted:!1,questionHighlightedWidgets:[],assetStatuses:{}},this._fullyRendered=!1}componentDidMount(){this._currentFocus=null,this._fullyRendered=!1}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(e,t){if(this.props.apiOptions.answerableCallback){var r=0===this.questionRenderer.emptyWidgets().length,{answerableCallback:i}=this.props.apiOptions;i&&i(r)}this._fullyRendered||Object.values(this.state.assetStatuses).every(Boolean)&&(this._fullyRendered=!0,this.props.onRendered(!0))}componentWillUnmount(){null!=this.blurTimeoutID&&(clearTimeout(this.blurTimeoutID),this.blurTimeoutID=null)}_setCurrentFocus(e){var{apiOptions:{isMobile:t,onFocusChange:r},keypadElement:i}=this.props,n=this._currentFocus;this._currentFocus=e;var o=this.getInputPaths(),s=this._currentFocus&&o.some((e=>De.inputPathsEqual(e,this._currentFocus)));null!=r&&r(this._currentFocus,n,s&&i&&i.getDOMNode(),s&&this.questionRenderer.getDOMNodeForPath(e)),i&&t&&(s?i.activate():i.dismiss())}_onRendererBlur(e){var t=this._currentFocus;h.isEqual(e,t)&&(this.blurTimeoutID=setTimeout((()=>{h.isEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}),0))}_setWidgetProps(e,t,r){this.questionRenderer._setWidgetProps(e,t,r)}setInputValue(e,t,r){return this.questionRenderer.setInputValue(e,t,r)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}getNumHints(){return this.props.item.hints.length}scoreInput(){var e=this.questionRenderer.guessAndScore(),t=e[0],r=e[1],i=[t,[]],n=De.keScoreFromPerseusScore(r,i,this.questionRenderer.getSerializedState()),o=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:n.correct,questionHighlightedWidgets:o}),n}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){var e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),r=this.questionRenderer.getSerializedState();return Sy(e,((e,i)=>De.keScoreFromPerseusScore(e,t[i],r)))}getSerializedState(){return{question:this.questionRenderer.getSerializedState(),hints:this.hintsRenderer.getSerializedState()}}restoreSerializedState(e,t){var r=2,i=()=>{--r,t&&0===r&&t()};this.questionRenderer.restoreSerializedState(e.question,i),this.hintsRenderer.restoreSerializedState(e.hints,i)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){var e=G(G(G({},Zt.defaults),this.props.apiOptions),{},{onFocusChange:this._handleFocusChange}),t={assetStatuses:this.state.assetStatuses,setAssetStatus:this.setAssetStatus},r=a.createElement(er.Provider,{value:t},a.createElement(Bo,{keypadElement:this.props.keypadElement,problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,ref:e=>{null!=e&&(this.questionRenderer=e)},content:this.props.item.question.content,widgets:this.props.item.question.widgets,images:this.props.item.question.images})),i=a.createElement(by,{hints:this.props.item.hints,hintsVisible:this.props.hintsVisible,apiOptions:e,ref:e=>this.hintsRenderer=e});return a.createElement("div",null,a.createElement("div",null,r),a.createElement("div",{className:e.isMobile?void 0:g(My.hintsContainer)},i))}}j(_y,"defaultProps",{apiOptions:{},onRendered:e=>{}});var My=m.create({hintsContainer:{marginLeft:50}}),Ty=a.forwardRef(((e,t)=>a.createElement(Ey.Consumer,null,(r=>{var{onRendered:i}=r;return a.createElement(_y,Y({},e,{onRendered:i,ref:t}))}))));class Iy extends a.Component{render(){return a.createElement(sd,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:a.createElement("span",null,"—")},{value:"->",content:a.createElement("span",null,"→")}],onChange:this.props.onChange})}}j(Iy,"defaultProps",{value:""});var Py=[mr.BLACK,mr.BLUE,mr.GREEN,mr.PINK,mr.PURPLE,mr.RED,mr.GRAY],Ny=[mr.LIGHT_BLUE,mr.LIGHT_ORANGE,mr.LIGHT_PINK,mr.LIGHT_GREEN,mr.LIGHT_PURPLE,mr.LIGHT_RED,"#fff"];class Ay extends a.Component{render(){var e=this.props.lightColors?Ny:Py;return a.createElement(sd,{value:this.props.value,allowEmpty:!1,buttons:h.map(e,(e=>({value:e,content:a.createElement("span",null,a.createElement("span",{className:"colorpicker-circle",style:{background:e}})," ")}))),onChange:this.props.onChange})}}j(Ay,"defaultProps",{value:mr.BLACK,lightColors:!1});class Ry extends a.Component{render(){return a.createElement(sd,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:a.createElement("span",null,"—")},{value:"-",content:a.createElement("span",null,"–––")},{value:"- ",content:a.createElement("span",null,"–  –")},{value:".",content:a.createElement("span",null,"····")},{value:". ",content:a.createElement("span",null,"· · ·")}],onChange:this.props.onChange})}}j(Ry,"defaultProps",{value:""});class Fy extends a.Component{constructor(e){super(e),j(this,"toggle",(e=>{e.preventDefault(),this.setState({show:!this.state.show})})),this.state={show:e.initiallyVisible}}render(){return a.createElement("div",{className:"perseus-interaction-element"},a.createElement("a",{href:"#",className:"perseus-interaction-element-title "+(this.state.show?"open":"closed"),onClick:this.toggle},this.state.show?a.createElement(X,vi):a.createElement(X,yi),this.props.title),a.createElement("div",{className:"perseus-interaction-element-content "+(this.state.show?"enter":"leave")},this.props.children,(null!=this.props.onUp||null!=this.props.onDown||null!=this.props.onDelete)&&a.createElement("div",{className:"edit-controls"},null!=this.props.onUp&&a.createElement("button",{onClick:this.props.onUp},a.createElement(X,wi)),null!=this.props.onDown&&a.createElement("button",{onClick:this.props.onDown},a.createElement(X,xi)),null!=this.props.onDelete&&a.createElement("button",{onClick:this.props.onDelete},a.createElement(X,Ii)))))}}j(Fy,"defaultProps",{initiallyVisible:!1,title:"More"});class Oy extends a.Component{constructor(){super(...arguments),j(this,"renderVisibleIcon",(()=>a.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:g(Dy.icon)},a.createElement("defs",null,a.createElement("path",{id:"a",d:"M7.401 10.035c-1.424.748-2.599 1.905-3.544 3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"})),a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),a.createElement("mask",{id:"b",fill:"#fff"},a.createElement("use",{href:"#a"})),a.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),a.createElement("g",{fill:"#fff",mask:"url(#b)"},a.createElement("path",{d:"M0 0h24v24H0z"})))))),j(this,"renderHiddenIcon",(()=>a.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:g(Dy.icon)},a.createElement("defs",null,a.createElement("path",{id:"a",d:"M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48.258.604.401 1.268.401 1.966 0 1.02-.305 1.967-.828 2.757l2.535 2.536a1 1 0 0 1-1.414 1.414l-12-12a1 1 0 0 1 1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 0-4.001-4.001l4 4.001zM6.072 8.486l2.976 2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 2.363-3.085 3.929-4z"})),a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),a.createElement("mask",{id:"b",fill:"#fff"},a.createElement("use",{href:"#a"})),a.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),a.createElement("g",{fill:"#fff",mask:"url(#b)"},a.createElement("path",{d:"M0 0h24v24H0z"}))))))}render(){var e,t;return this.props.enabled?(e=Dy.enabled,t=this.renderVisibleIcon()):(e=Dy.disabled,t=this.renderHiddenIcon()),a.createElement("button",{className:g(Dy.hud,this.props.fixedPosition&&Dy.hudFixedPosition,e),onClick:e=>{this.props.onClick()}},t,this.props.message)}}j(Oy,"propTypes",{message:d.string.isRequired,enabled:d.bool.isRequired,onClick:d.func.isRequired,fixedPosition:d.bool}),j(Oy,"defaultProps",{fixedPosition:!0});var Dy=m.create({hud:{boxSizing:"border-box",height:36,padding:"9px 16px",borderRadius:18,fontFamily:K,fontSize:"15px",lineHeight:"18px",color:Z,userSelect:"none",borderWidth:0},hudFixedPosition:{bottom:20,position:"fixed",right:20,zIndex:1},icon:{width:24,height:24,marginRight:8,marginTop:-3,verticalAlign:"middle"},enabled:{backgroundColor:"#f86700",":hover":{backgroundColor:"#df5c00"},":active":{backgroundColor:"#c75300"}},disabled:{backgroundColor:J,":hover":{backgroundColor:"#a1a5a9"},":active":{backgroundColor:Q}}});class Ly extends a.Component{constructor(){super(...arguments),j(this,"toggleSelect",(e=>{var t=(this.props.values||[]).slice(0),r=this.props.allowEmpty;t.indexOf(e)>=0&&(t.length>1||r)?t.splice(t.indexOf(e),1):t.indexOf(e)<0&&t.push(e),this.props.onChange(t)}))}focus(){var e;return null===(e=f.findDOMNode(this))||void 0===e||e.focus(),!0}render(){var e=this.props.values||[],t=this.props.buttons.map(((t,r)=>{var i=e.indexOf(t.value)>=0;return a.createElement("button",{title:t.title,type:"button",id:""+r,key:""+r,ref:"button"+r,className:g(By.buttonStyle,i&&By.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)}));return a.createElement("div",{style:{display:"inline-block"}},t)}}j(Ly,"defaultProps",{values:[],allowEmpty:!0});var By=m.create({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"}}),zy=E({displayName:"PropCheckBox",propTypes:{labelAlignment:d.oneOf(["left","right"])},DEFAULT_PROPS:{label:null,onChange:null,labelAlignment:"left"},getDefaultProps:function(){return this.DEFAULT_PROPS},propName:function(){var e=h.find(h.keys(this.props),(function(e){return!h.has(this.DEFAULT_PROPS,e)}),this);if(!e)throw new ce("Attempted to create a PropCheckBox with no prop!",pe.InvalidInput);return e},_labelAlignLeft:function(){return"left"===this.props.labelAlignment},render:function(){var e=this.propName();return a.createElement("label",null,this._labelAlignLeft()&&this.props.label,a.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)}}),Hy=()=>!0;class Wy extends a.Component{constructor(){super(...arguments),j(this,"onChange",((e,t)=>{var r=this.props.value;0===e?this.props.onChange([t,r[1]]):this.props.onChange([r[0],t])}))}render(){var e=this.props.value,t=this.props.checkValidity||Hy;return a.createElement("div",{className:"range-input"},a.createElement(Lm,Y({},this.props,{value:e[0],checkValidity:r=>t([r,e[1]]),onChange:this.onChange.bind(this,0),placeholder:this.props.placeholder[0]})),a.createElement(Lm,Y({},this.props,{value:e[1],checkValidity:r=>t([e[0],r]),onChange:this.onChange.bind(this,1),placeholder:this.props.placeholder[1]})))}}j(Wy,"propTypes",{value:d.array.isRequired,onChange:d.func.isRequired,placeholder:d.array,checkValidity:d.func}),j(Wy,"defaultProps",{placeholder:[null,null]});var qy=Object.freeze({__proto__:null,ButtonGroup:sd,Graph:Pu,Graphie:Nn,HUD:Oy,Icon:ua,InfoTip:jf,InlineIcon:X,MathInput:$o,MultiButtonGroup:Ly,NumberInput:Lm,PropCheckBox:zy,RangeInput:Wy,SvgImage:Vn,TextInput:rs,TexButtons:jo,TextListEditor:$t}),Uy=Object.freeze({__proto__:null,devices:{PHONE:"phone",TABLET:"tablet",DESKTOP:"desktop"},lintGutterWidth:36,perseusFrameBorderWidth:1}),Gy=a.createContext({setKeypadElement:e=>{},keypadElement:null,setRenderer:e=>{},renderer:null,setScrollableElement:e=>{},scrollableElement:null}),Vy=function(){},jy=function(e,t,r,i){var n=e.content;if(null!=e.content){var o=t(e.content);void 0!==o&&(n=o)}var s=_r.mapObject(e.widgets||{},(function(e,t){return null==e||null==e.type?e:r(e,t)})),a=h.extend({},e,{content:n,widgets:s}),l=i(a);return void 0!==l?l:a},Yy=function(e,t,r,i){return jy(e,t=t||Vy,function(e,t,r){return function i(n,o){var s,a,l=xo(n),p=vo(l.type);a=p&&(null===(s=l.version)||void 0===s?void 0:s.major)===p.major?Co(l,(t=>jy(t,e,i,r))):l;var h=t(a,o);return void 0!==h?h:a}}(t,r=r||Vy,i=i||Vy),i)},$y={type:"hint"},Xy=e=>({type:"array",elementShape:e}),Ky={content:{type:"content"},hint:$y,hints:Xy($y),tags:{type:"tags"},arrayOf:Xy,shape:e=>({type:"object",shape:e})};class Zy{constructor(e,t,r){j(this,"content",void 0),j(this,"hint",void 0),j(this,"tags",void 0),j(this,"array",void 0),this.content=e,this.hint=t,this.tags=r,this.array=Qy}setContentMapper(e){return new Zy(e,this.hint,this.tags)}setHintMapper(e){return new Zy(this.content,e,this.tags)}setTagsMapper(e){return new Zy(this.content,this.hint,e)}setArrayMapper(e){return new Jy(this.content,this.hint,this.tags,e)}mapTree(e,t){return tb(e,t,[],this)}}class Jy{constructor(e,t,r,i){j(this,"content",void 0),j(this,"hint",void 0),j(this,"tags",void 0),j(this,"array",void 0),this.content=e,this.hint=t,this.tags=r,this.array=i}setArrayMapper(e){return new Jy(this.content,this.hint,this.tags,e)}mapTree(e,t){return tb(e,t,[],this)}}function Qy(e){return e}function eb(){return new Zy(Qy,Qy,Qy)}function tb(e,t,r,i){if("content"===t.type){var n=e;return i.content(n,t,r)}if("hint"===t.type){var o=e;return i.hint(o,t,r)}if("tags"===t.type){var s=e;return i.tags(s,t,r)}if("array"===t.type){var a=e;if(!Array.isArray(a))throw new ce('Invalid object of type "'.concat(typeof a,'" found at path ')+"".concat(["<root>"].concat(r).join("."),". Expected array."),pe.Internal);var l=t.elementShape,p=a.map(((e,t)=>tb(e,l,r.concat(t),i)));return i.array(p,a,t,r)}if("object"===t.type){var h=e;if(h&&"object"!=typeof h)throw new ce('Invalid object of type "'.concat(typeof h,'" found at ')+"path ".concat(["<root>"].concat(r).join("."),". Expected ")+'"object" type.',pe.InvalidInput);var c=t.shape;if(!c)throw new ce("Unexpected shape ".concat(JSON.stringify(t)," at path ")+"".concat(["<root>"].concat(r).join("."),"."),pe.InvalidInput);var d={};return Object.keys(c).forEach((e=>{if(!(e in h))throw new ce('Key "'.concat(e,'" is missing from shape at path ')+"".concat(["<root>"].concat(r).join("."),"."),pe.InvalidInput);d[e]=tb(h[e],c[e],r.concat(e),i)})),d}throw new ce("unexpected shape type ".concat(t.type),pe.InvalidInput)}function rb(e){if("content"===e.type)return{__type:"content",content:"",images:{},widgets:{}};if("hint"===e.type)return{__type:"hint",replace:!1,content:"",images:{},widgets:{}};if("tags"===e.type)return[];if("array"===e.type)return[];if("object"===e.type){var t=e.shape,r={};return Object.keys(t).forEach((e=>{r[e]=rb(t[e])})),r}throw new ce("unexpected shape type ".concat(e.type),pe.InvalidInput)}function ib(e){if(Array.isArray(e))return e.length?"string"==typeof e[0]?Ky.tags:Ky.arrayOf(ib(e[0])):Ky.arrayOf(Ky.content);if("object"==typeof e&&("content"===e.__type||"item"===e.__type))return Ky.content;if("object"==typeof e&&"hint"===e.__type)return Ky.hint;if("object"==typeof e){var t={};return Object.keys(e).forEach((r=>{t[r]=ib(e[r])})),Ky.shape(t)}throw new ce("unexpected multi-item node ".concat(JSON.stringify(e)),pe.InvalidInput)}function nb(e){return e._multi}var ob=["item","children","shape","serializedState","onSerializedStateUpdated"];class sb extends a.Component{constructor(e){super(e),j(this,"rendererDataTreeMapper",void 0),j(this,"getRenderersMapper",void 0),j(this,"_handleSerializedStateUpdated",((e,t)=>{var{onSerializedStateUpdated:r}=this.props;if(r){var i=this._getSerializedState(this.props.serializedState);r(zv(i).set(e,t).freeze())}})),this.rendererDataTreeMapper=eb().setContentMapper(((e,t,r)=>this._makeContentRendererData(e,r))).setHintMapper((e=>this._makeHintRendererData(e))).setTagsMapper((e=>null)),this.getRenderersMapper=eb().setContentMapper((e=>e.makeRenderer())).setHintMapper((e=>e.makeRenderer())).setArrayMapper(((e,t,r)=>this._annotateRendererArray(e,t,r))),this.state=this._tryMakeRendererState(this.props)}UNSAFE_componentWillReceiveProps(e){e.item!==this.props.item&&this.setState(this._tryMakeRendererState(e))}_tryMakeRendererState(e){try{return{rendererDataTree:this._makeRendererDataTree(e.item,e.shape),renderError:null}}catch(e){return he.error("Error building tree state",pe.Internal,{cause:e}),{rendererDataTree:null,renderError:e}}}_getRendererProps(){return $(this.props,ob)}_makeContentRendererData(e,t){var r={ref:null,makeRenderer:null},i=e=>r.ref=e,n=e=>this._findWidgets(r,e),o=e=>this._handleSerializedStateUpdated(t,e);return r.makeRenderer=()=>a.createElement(Bo,Y({},this._getRendererProps(),e,{ref:i,findExternalWidgets:n,serializedState:this.props.serializedState?zv(this.props.serializedState).get(t):null,onSerializedStateUpdated:o})),r}_makeHintRendererData(e){var t=e=>this._findWidgets({},e);return{hint:e,findExternalWidgets:t,ref:null,makeRenderer:()=>a.createElement(by,Y({},this._getRendererProps(),{findExternalWidgets:t,hints:[e]}))}}_makeRendererDataTree(e,t){var r=nb(e);return this.rendererDataTreeMapper.mapTree(r,t)}_findWidgets(e,t){var r=[];return this._mapRenderers((i=>{e!==i&&i.ref&&r.push(...i.ref.findInternalWidgets(t))})),r}_mapRenderers(e){var{rendererDataTree:t}=this.state;return t?eb().setContentMapper(e).setHintMapper(e).mapTree(t,this.props.shape):null}_scoreFromRef(e){if(!e)return null;var t,[r,i]=e.guessAndScore();return e.getSerializedState&&(t=e.getSerializedState()),De.keScoreFromPerseusScore(i,r,t)}getScores(){return this._mapRenderers((e=>this._scoreFromRef(e.ref)))}score(){var e=[],t=[],r=this._mapRenderers((r=>{var i;return r.ref?(r.ref.getSerializedState&&t.push(r.ref.getSerializedState()),e.push(r.ref.score()),null===(i=r.ref)||void 0===i?void 0:i.getUserInput()):null})),i=e.reduce(De.combineScores);return De.keScoreFromPerseusScore(i,r,t)}_getSerializedState(e){return this._mapRenderers(((t,r,i)=>t.ref?t.ref.getSerializedState():e?zv(e).get(i):null))}restoreSerializedState(e,t){var r=0,i=()=>{r--,t&&0===r&&t()};this._mapRenderers(((t,n,o)=>{var s;if(t.ref){var a=zv(e).get(o);a&&(r++,null===(s=t.ref)||void 0===s||s.restoreSerializedState(a,i))}}))}_annotateRendererArray(e,t,r){if("hint"===r.elementShape.type){var i=t;(e=[...e]).firstN=e=>a.createElement(by,Y({},this._getRendererProps(),{findExternalWidgets:i[0]?i[0].findExternalWidgets:void 0,hints:i.map((e=>e.hint)),hintsVisible:e}))}return e}_getRenderers(){return this.getRenderersMapper.mapTree(this.state.rendererDataTree,this.props.shape)}render(){return this.state.renderError?a.createElement("div",{className:g(ab.error)},o.$_("Error rendering: %(error)s",{error:String(this.state.renderError)})):this.props.children({renderers:this._getRenderers()})}}var ab=m.create({error:{color:"red"}});function lb(e){if("content"===e.type)return d.shape({__type:d.oneOf(["content","item"]).isRequired,content:d.string,images:d.objectOf(d.any),widgets:d.objectOf(d.any)});if("hint"===e.type)return d.shape({__type:d.oneOf(["hint"]).isRequired,content:d.string,images:d.objectOf(d.any),widgets:d.objectOf(d.any),replace:d.bool});if("tags"===e.type)return d.arrayOf(d.string.isRequired);if("array"===e.type){var t=lb(e.elementShape);return d.arrayOf(t.isRequired)}if("object"===e.type){var r=e.shape,i={};return Object.keys(r).forEach((e=>{i[e]=lb(r[e]).isRequired})),d.shape(i)}throw new ce("unexpected shape type ".concat(e.type),pe.InvalidInput)}var pb={MultiRenderer:sb,shapes:Ky,buildPropTypeForShape:function(e){return d.oneOfType([d.shape({_multi:lb(e)}),d.oneOf([null,void 0])])},buildEmptyItemForShape:function(e){return{_multi:rb(e)}},findContentNodesInItem:function(e,t,r){var i=nb(e);eb().setContentMapper(r).mapTree(i,t)},findHintNodesInItem:function(e,t,r){var i=nb(e);eb().setHintMapper(r).mapTree(i,t)},inferItemShape:function(e){return ib(nb(e))}},{findContentNodesInItem:hb,inferItemShape:cb}=pb,db=function(e,t){var r=!0;return Yy(e,null,(function(e){r=r&&function(e,t){if(null==e||null==e.type)return!0;var r=xo(e);return function(e,t){if(null==t)return!1;var r=e.version||{major:0,minor:0};return t.major>r.major||!(t.major<r.major)&&t.minor>=r.minor}(r,t[r.type])}(e,t)})),r},ub=function(e,t){if(null==e||null==t)throw new ce("missing parameter to Perseus.isRenderable.item",pe.InvalidInput);if(e._multi){var r=cb(e),i=!0;return hb(e,r,(e=>{db(e,t)||(i=!1)})),i}return db(e.question,t)},{findContentNodesInItem:mb,inferItemShape:gb}=pb;function fb(e,t){Yy(e,null,(function(e){e.type&&!bo(e)&&t.push(e.type)}))}function vb(e){var t=[];if(e._multi){var r=gb(e);mb(e,r,(e=>fb(e,t)))}else fb(e.question,t);return h.uniq(t)}var yb=()=>{go(dy)},bb={serialize:function(){return h.omit(this.props,cs)}},xb=W,wb=q;export{Zt as ApiOptions,Iy as ArrowPicker,fy as ArticleRenderer,zl as BaseRadio,Kl as Categorizer,vs as Changeable,Jt as ClassNames,Ay as ColorPicker,Ry as DashPicker,le as Dependencies,bb as EditorJsonify,Fy as ElementContainer,pe as Errors,xs as Expression,Ad as GrapherUtil,zd as GrapherWidget,vy as HintRenderer,by as HintsRenderer,Ps as InputNumber,em as InteractiveGraphWidget,Cy as ItemRenderer,to as JiptParagraphs,Gy as KeypadContext,mr as KhanColors,de as KhanMath,Ey as LoadingContext,he as Log,Km as MatrixWidget,pb as MultiItems,Ds as NumericInput,ce as PerseusError,$e as PerseusMarkdown,Ff as PlotterWidget,Vl as Radio,Bo as Renderer,Ty as ServerItemRenderer,po as SizingUtils,mv as TableWidget,Lv as TransformerWidget,De as Util,cs as WIDGET_PROP_BLACKLIST,Ls as WidgetJsonifyDeprecated,Po as Widgets,xb as apiVersion,rb as buildEmptyItemTreeForShape,eb as buildMapper,qy as components,Uy as constants,Wv as displaySigFigs,Qa as globalConstants,nl as globalStyles,Ai as icons,cy as init,te as interactiveSizes,ub as isItemRenderableByVersion,wb as itemDataVersion,nb as itemToTree,uy as itemVersion,$s as mediaQueries,no as preprocessTex,yb as registerAllWidgetsForTesting,Ky as shapes,Yy as traverse,vb as violatingWidgets,dy as widgets};
7
+ */!function(){var e;function t(){if(t.is(arguments[0],I)){for(var e=arguments[0],r=qe[d](t,e.splice(0,3+t.is(e[0],M))),i=r.set(),s=0,o=e[y];s<o;s++){var l=e[s]||{};n[a](l.type)&&i[N](r[l.type]().attr(l))}return i}return qe[d](t,arguments)}e="".trim?function(e,t,r){e.setAttribute(t,String(r).trim())}:function(e,t,r){e.setAttribute(t,String(r))},t.version="1.5.2";var r,i=/[, ]+/,n={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},s=/\{(\d+)\}/g,o="prototype",a="hasOwnProperty",l=document,p=window,h={was:Object[o][a].call(p,"Raphael"),is:p.Raphael},c=function(){this.customAttributes={}},d="apply",u="createTouch"in l,m="",g=" ",f=String,v="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend".split(g),b={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},y="length",x=f[o].toLowerCase,C=Math,w=C.max,k=C.min,E=C.abs,S=C.pow,_=C.PI,M="number",T="string",I="array",P="fill",A=Object[o].toString,N="push",R=/^url\(['"]?([^\)]+?)['"]?\)$/i,F=/^\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,D={NaN:1,Infinity:1,"-Infinity":1},O=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,L=C.round,B=parseFloat,z=parseInt,q=" progid:DXImageTransform.Microsoft",H=f[o].toUpperCase,W={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},U={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},G="replace",V=/^(from|to|\d+%?)$/,j=/\s*,\s*/,Y={hs:1,rg:1},X=/,?([achlmqrstvxz]),?/gi,$=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/gi,K=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/gi,Z=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,J=function(e,t){return e.key-t.key};if(t.type=p.SVGAngle||l.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML","VML"==t.type){var Q,ee=l.createElement("div");if(ee.innerHTML='<v:shape adj="1"/>',(Q=ee.firstChild).style.behavior="url(#default#VML)",!Q||"object"!=typeof Q.adj)return t.type=null;ee=null}function te(){for(var e=[],t=0;t<32;t++)e[t]=(~~(16*C.random())).toString(16);return e[12]=4,e[16]=(3&e[16]|8).toString(16),"r-"+e.join("")}t.svg=!(t.vml="VML"==t.type),c[o]=t[o],r=c[o],t._id=0,t._oid=0,t.fn={},t.is=function(e,t){return"finite"==(t=x.call(t))?!D[a](+e):"null"==t&&null===e||t==typeof e||"object"==t&&e===Object(e)||"array"==t&&Array.isArray&&Array.isArray(e)||A.call(e).slice(8,-1).toLowerCase()==t},t.angle=function(e,r,i,n,s,o){if(null==s){var a=e-i,l=r-n;return a||l?(180*(a<0)+180*C.atan(-l/-a)/_+360)%360:0}return t.angle(e,r,s,o)-t.angle(i,n,s,o)},t.rad=function(e){return e%360*_/180},t.deg=function(e){return 180*e/_%360},t.snapTo=function(e,r,i){if(i=t.is(i,"finite")?i:10,t.is(e,I)){for(var n=e.length;n--;)if(E(e[n]-r)<=i)return e[n]}else{var s=r%(e=+e);if(s<i)return r-s;if(s>e-i)return r-s+e}return r},t.setWindow=function(e){l=(p=e).document};var re=function(e){if(t.vml){var r,i=/^\s+|\s+$/g;try{var n=new ActiveXObject("htmlfile");n.write("<body>"),n.close(),r=n.body}catch(e){r=createPopup().document.body}var s=r.createTextRange();re=oe((function(e){try{r.style.color=f(e)[G](i,m);var t=s.queryCommandValue("ForeColor");return"#"+("000000"+(t=(255&t)<<16|65280&t|(16711680&t)>>>16).toString(16)).slice(-6)}catch(e){return"none"}}))}else{var o=l.createElement("i");o.title="Raphaël Colour Picker",o.style.display="none",l.body.appendChild(o),re=oe((function(e){return o.style.color=e,l.defaultView.getComputedStyle(o,m).getPropertyValue("color")}))}return re(e)},ie=function(){return"hsb("+[this.h,this.s,this.b]+")"},ne=function(){return"hsl("+[this.h,this.s,this.l]+")"},se=function(){return this.hex};function oe(e,t,r){return function i(){var n=Array[o].slice.call(arguments,0),s=n.join("►"),l=i.cache=i.cache||{},p=i.count=i.count||[];return l[a](s)||(p[y]>=1e3&&delete l[p.shift()],p[N](s),l[s]=e[d](t,n)),r?r(l[s]):l[s]}}t.hsb2rgb=function(e,r,i,n){return t.is(e,"object")&&"h"in e&&"s"in e&&"b"in e&&(i=e.b,r=e.s,n=(e=e.h).o),t.hsl2rgb(e,r,i/2,n)},t.hsl2rgb=function(e,r,i,n){t.is(e,"object")&&"h"in e&&"s"in e&&"l"in e&&(i=e.l,r=e.s,e=e.h),(e>1||r>1||i>1)&&(e/=360,r/=100,i/=100);var s,o,a,l={},p=["r","g","b"];if(r){o=2*i-(s=i<.5?i*(1+r):i+r-i*r);for(var h=0;h<3;h++)(a=e+1/3*-(h-1))<0&&a++,a>1&&a--,l[p[h]]=6*a<1?o+6*(s-o)*a:2*a<1?s:3*a<2?o+(s-o)*(2/3-a)*6:o}else l={r:i,g:i,b:i};return l.r*=255,l.g*=255,l.b*=255,l.hex="#"+(16777216|l.b|l.g<<8|l.r<<16).toString(16).slice(1),t.is(n,"finite")&&(l.opacity=n),l.toString=se,l},t.rgb2hsb=function(e,r,i){if(null==r&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(i=e.b,r=e.g,e=e.r),null==r&&t.is(e,T)){var n=t.getRGB(e);e=n.r,r=n.g,i=n.b}(e>1||r>1||i>1)&&(e/=255,r/=255,i/=255);var s,o=w(e,r,i),a=k(e,r,i);if(a==o)return{h:0,s:0,b:o,toString:ie};var l=o-a;return s=e==o?(r-i)/l:r==o?2+(i-e)/l:4+(e-r)/l,(s/=6)<0&&s++,s>1&&s--,{h:s,s:l/o,b:o,toString:ie}},t.rgb2hsl=function(e,r,i){if(null==r&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(i=e.b,r=e.g,e=e.r),null==r&&t.is(e,T)){var n=t.getRGB(e);e=n.r,r=n.g,i=n.b}(e>1||r>1||i>1)&&(e/=255,r/=255,i/=255);var s,o,a=w(e,r,i),l=k(e,r,i),p=(a+l)/2;if(l==a)o={h:0,s:0,l:p};else{var h=a-l;s=e==a?(r-i)/h:r==a?2+(i-e)/h:4+(e-r)/h,(s/=6)<0&&s++,s>1&&s--,o={h:s,s:p<.5?h/(a+l):h/(2-a-l),l:p}}return o.toString=ne,o},t._path2string=function(){return this.join(",")[G](X,"$1")},t.getRGB=oe((function(e){if(!e||(e=f(e)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if("none"==e)return{r:-1,g:-1,b:-1,hex:"none"};!Y[a](e.toLowerCase().substring(0,2))&&"#"!=e.charAt()&&(e=re(e));var r,i,n,s,o,l,p=e.match(F);return p?(p[2]&&(n=z(p[2].substring(5),16),i=z(p[2].substring(3,5),16),r=z(p[2].substring(1,3),16)),p[3]&&(n=z((o=p[3].charAt(3))+o,16),i=z((o=p[3].charAt(2))+o,16),r=z((o=p[3].charAt(1))+o,16)),p[4]&&(l=p[4].split(j),r=B(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=B(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=B(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),"rgba"==p[1].toLowerCase().slice(0,4)&&(s=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(s/=100)),p[5]?(l=p[5].split(j),r=B(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=B(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=B(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(r/=360),"hsba"==p[1].toLowerCase().slice(0,4)&&(s=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(s/=100),t.hsb2rgb(r,i,n,s)):p[6]?(l=p[6].split(j),r=B(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=B(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=B(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(r/=360),"hsla"==p[1].toLowerCase().slice(0,4)&&(s=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(s/=100),t.hsl2rgb(r,i,n,s)):((p={r:r,g:i,b:n}).hex="#"+(16777216|n|i<<8|r<<16).toString(16).slice(1),t.is(s,"finite")&&(p.opacity=s),p)):{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},r=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})),r.hex},t.getColor.reset=function(){delete this.start},t.parsePathString=oe((function(e){if(!e)return null;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},i=[];return t.is(e,I)&&t.is(e[0],I)&&(i=le(e)),i[y]||f(e)[G]($,(function(e,t,n){var s=[],o=x.call(t);for(n[G](K,(function(e,t){t&&s[N](+t)})),"m"==o&&s[y]>2&&(i[N]([t].concat(s.splice(0,2))),o="l",t="m"==t?"l":"L");s[y]>=r[o]&&(i[N]([t].concat(s.splice(0,r[o]))),r[o]););})),i.toString=t._path2string,i})),t.findDotsAtSegment=function(e,t,r,i,n,s,o,a,l){var p=1-l,h=S(p,3)*e+3*S(p,2)*l*r+3*p*l*l*n+S(l,3)*o,c=S(p,3)*t+3*S(p,2)*l*i+3*p*l*l*s+S(l,3)*a,d=e+2*l*(r-e)+l*l*(n-2*r+e),u=t+2*l*(i-t)+l*l*(s-2*i+t),m=r+2*l*(n-r)+l*l*(o-2*n+r),g=i+2*l*(s-i)+l*l*(a-2*s+i),f=(1-l)*e+l*r,v=(1-l)*t+l*i,b=(1-l)*n+l*o,y=(1-l)*s+l*a,x=90-180*C.atan((d-m)/(u-g))/_;return(d>m||u<g)&&(x+=180),{x:h,y:c,m:{x:d,y:u},n:{x:m,y:g},start:{x:f,y:v},end:{x:b,y:y},alpha:x}};var ae=oe((function(e){if(!e)return{x:0,y:0,width:0,height:0};for(var t,r=0,i=0,n=[],s=[],o=0,a=(e=fe(e))[y];o<a;o++)if("M"==(t=e[o])[0])r=t[1],i=t[2],n[N](r),s[N](i);else{var l=ge(r,i,t[1],t[2],t[3],t[4],t[5],t[6]);n=n.concat(l.min.x,l.max.x),s=s.concat(l.min.y,l.max.y),r=t[5],i=t[6]}var p=k[d](0,n),h=k[d](0,s);return{x:p,y:h,width:w[d](0,n)-p,height:w[d](0,s)-h}})),le=function(e){var r=[];t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));for(var i=0,n=e[y];i<n;i++){r[i]=[];for(var s=0,o=e[i][y];s<o;s++)r[i][s]=e[i][s]}return r.toString=t._path2string,r},pe=oe((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var r=[],i=0,n=0,s=0,o=0,a=0;"M"==e[0][0]&&(s=i=e[0][1],o=n=e[0][2],a++,r[N](["M",i,n]));for(var l=a,p=e[y];l<p;l++){var h=r[l]=[],c=e[l];if(c[0]!=x.call(c[0]))switch(h[0]=x.call(c[0]),h[0]){case"a":h[1]=c[1],h[2]=c[2],h[3]=c[3],h[4]=c[4],h[5]=c[5],h[6]=+(c[6]-i).toFixed(3),h[7]=+(c[7]-n).toFixed(3);break;case"v":h[1]=+(c[1]-n).toFixed(3);break;case"m":s=c[1],o=c[2];default:for(var d=1,u=c[y];d<u;d++)h[d]=+(c[d]-(d%2?i:n)).toFixed(3)}else{h=r[l]=[],"m"==c[0]&&(s=c[1]+i,o=c[2]+n);for(var m=0,g=c[y];m<g;m++)r[l][m]=c[m]}var f=r[l][y];switch(r[l][0]){case"z":i=s,n=o;break;case"h":i+=+r[l][f-1];break;case"v":n+=+r[l][f-1];break;default:i+=+r[l][f-2],n+=+r[l][f-1]}}return r.toString=t._path2string,r}),0,le),he=oe((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var r=[],i=0,n=0,s=0,o=0,a=0;"M"==e[0][0]&&(s=i=+e[0][1],o=n=+e[0][2],a++,r[0]=["M",i,n]);for(var l=a,p=e[y];l<p;l++){var h=r[l]=[],c=e[l];if(c[0]!=H.call(c[0]))switch(h[0]=H.call(c[0]),h[0]){case"A":h[1]=c[1],h[2]=c[2],h[3]=c[3],h[4]=c[4],h[5]=c[5],h[6]=+(c[6]+i),h[7]=+(c[7]+n);break;case"V":h[1]=+c[1]+n;break;case"H":h[1]=+c[1]+i;break;case"M":s=+c[1]+i,o=+c[2]+n;default:for(var d=1,u=c[y];d<u;d++)h[d]=+c[d]+(d%2?i:n)}else for(var m=0,g=c[y];m<g;m++)r[l][m]=c[m];switch(h[0]){case"Z":i=s,n=o;break;case"H":i=h[1];break;case"V":n=h[1];break;case"M":s=r[l][r[l][y]-2],o=r[l][r[l][y]-1];default:i=r[l][r[l][y]-2],n=r[l][r[l][y]-1]}}return r.toString=t._path2string,r}),null,le),ce=function(e,t,r,i){return[e,t,r,i,r,i]},de=function(e,t,r,i,n,s){var o=1/3,a=2/3;return[o*e+a*r,o*t+a*i,o*n+a*r,o*s+a*i,n,s]},ue=function e(t,r,i,n,s,o,a,l,p,h){var c,d=120*_/180,u=_/180*(+s||0),m=[],g=oe((function(e,t,r){return{x:e*C.cos(r)-t*C.sin(r),y:e*C.sin(r)+t*C.cos(r)}}));if(h)T=h[0],I=h[1],S=h[2],M=h[3];else{t=(c=g(t,r,-u)).x,r=c.y;var f=(t-(l=(c=g(l,p,-u)).x))/2,v=(r-(p=c.y))/2,b=f*f/(i*i)+v*v/(n*n);b>1&&(i*=b=C.sqrt(b),n*=b);var x=i*i,w=n*n,k=(o==a?-1:1)*C.sqrt(E((x*w-x*v*v-w*f*f)/(x*v*v+w*f*f))),S=k*i*v/n+(t+l)/2,M=k*-n*f/i+(r+p)/2,T=C.asin(((r-M)/n).toFixed(9)),I=C.asin(((p-M)/n).toFixed(9));(T=t<S?_-T:T)<0&&(T=2*_+T),(I=l<S?_-I:I)<0&&(I=2*_+I),a&&T>I&&(T-=2*_),!a&&I>T&&(I-=2*_)}var P=I-T;if(E(P)>d){var A=I,N=l,R=p;I=T+d*(a&&I>T?1:-1),m=e(l=S+i*C.cos(I),p=M+n*C.sin(I),i,n,s,0,a,N,R,[I,A,S,M])}P=I-T;var F=C.cos(T),D=C.sin(T),O=C.cos(I),L=C.sin(I),B=C.tan(P/4),z=4/3*i*B,q=4/3*n*B,H=[t,r],W=[t+z*D,r-q*F],U=[l+z*L,p-q*O],G=[l,p];if(W[0]=2*H[0]-W[0],W[1]=2*H[1]-W[1],h)return[W,U,G].concat(m);for(var V=[],j=0,Y=(m=[W,U,G].concat(m).join().split(","))[y];j<Y;j++)V[j]=j%2?g(m[j-1],m[j],u).y:g(m[j],m[j+1],u).x;return V},me=function(e,t,r,i,n,s,o,a,l){var p=1-l;return{x:S(p,3)*e+3*S(p,2)*l*r+3*p*l*l*n+S(l,3)*o,y:S(p,3)*t+3*S(p,2)*l*i+3*p*l*l*s+S(l,3)*a}},ge=oe((function(e,t,r,i,n,s,o,a){var l,p=n-2*r+e-(o-2*n+r),h=2*(r-e)-2*(n-r),c=e-r,u=(-h+C.sqrt(h*h-4*p*c))/2/p,m=(-h-C.sqrt(h*h-4*p*c))/2/p,g=[t,a],f=[e,o];return E(u)>"1e12"&&(u=.5),E(m)>"1e12"&&(m=.5),u>0&&u<1&&(l=me(e,t,r,i,n,s,o,a,u),f[N](l.x),g[N](l.y)),m>0&&m<1&&(l=me(e,t,r,i,n,s,o,a,m),f[N](l.x),g[N](l.y)),p=s-2*i+t-(a-2*s+i),c=t-i,u=(-(h=2*(i-t)-2*(s-i))+C.sqrt(h*h-4*p*c))/2/p,m=(-h-C.sqrt(h*h-4*p*c))/2/p,E(u)>"1e12"&&(u=.5),E(m)>"1e12"&&(m=.5),u>0&&u<1&&(l=me(e,t,r,i,n,s,o,a,u),f[N](l.x),g[N](l.y)),m>0&&m<1&&(l=me(e,t,r,i,n,s,o,a,m),f[N](l.x),g[N](l.y)),{min:{x:k[d](0,f),y:k[d](0,g)},max:{x:w[d](0,f),y:w[d](0,g)}}})),fe=oe((function(e,t){for(var r=he(e),i=t&&he(t),n={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){if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C"].concat(ue[d](0,[t.x,t.y].concat(e.slice(1))));break;case"S":e=["C",t.x+(t.x-(t.bx||t.x)),t.y+(t.y-(t.by||t.y))].concat(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"].concat(de(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"].concat(de(t.x,t.y,e[1],e[2],e[3],e[4]));break;case"L":e=["C"].concat(ce(t.x,t.y,e[1],e[2]));break;case"H":e=["C"].concat(ce(t.x,t.y,e[1],t.y));break;case"V":e=["C"].concat(ce(t.x,t.y,t.x,e[1]));break;case"Z":e=["C"].concat(ce(t.x,t.y,t.X,t.Y))}return e},a=function(e,t){if(e[t][y]>7){e[t].shift();for(var n=e[t];n[y];)e.splice(t++,0,["C"].concat(n.splice(0,6)));e.splice(t,1),h=w(r[y],i&&i[y]||0)}},l=function(e,t,n,s,o){e&&t&&"M"==e[o][0]&&"M"!=t[o][0]&&(t.splice(o,0,["M",s.x,s.y]),n.bx=0,n.by=0,n.x=e[o][1],n.y=e[o][2],h=w(r[y],i&&i[y]||0))},p=0,h=w(r[y],i&&i[y]||0);p<h;p++){r[p]=o(r[p],n),a(r,p),i&&(i[p]=o(i[p],s)),i&&a(i,p),l(r,i,n,s,p),l(i,r,s,n,p);var c=r[p],u=i&&i[p],m=c[y],g=i&&u[y];n.x=c[m-2],n.y=c[m-1],n.bx=B(c[m-4])||n.x,n.by=B(c[m-3])||n.y,s.bx=i&&(B(u[g-4])||s.x),s.by=i&&(B(u[g-3])||s.y),s.x=i&&u[g-2],s.y=i&&u[g-1]}return i?[r,i]:r}),null,le),ve=oe((function(e){for(var r=[],i=0,n=e[y];i<n;i++){var s={},o=e[i].match(/^([^:]*):?([\d\.]*)/);if(s.color=t.getRGB(o[1]),s.color.error)return null;s.color=s.color.hex,o[2]&&(s.offset=o[2]+"%"),r[N](s)}for(i=1,n=r[y]-1;i<n;i++)if(!r[i].offset){for(var a=B(r[i-1].offset||0),l=0,p=i+1;p<n;p++)if(r[p].offset){l=r[p].offset;break}l||(l=100,p=n);for(var h=((l=B(l))-a)/(p-i+1);i<p;i++)a+=h,r[i].offset=a+"%"}return r})),be=function(e,r,i,n){var s;return t.is(e,T)||t.is(e,"object")?(s=t.is(e,T)?l.getElementById(e):e).tagName?null==r?{container:s,width:s.style.pixelWidth||s.offsetWidth,height:s.style.pixelHeight||s.offsetHeight}:{container:s,width:r,height:i}:void 0:{container:1,x:e,y:r,width:i,height:n}},ye=function e(t,r){var i=this;for(var n in r)if(r[a](n)&&!(n in t))switch(typeof r[n]){case"function":!function(e){t[n]=t===i?e:function(){return e[d](i,arguments)}}(r[n]);break;case"object":t[n]=t[n]||{},e.call(this,t[n],r[n]);break;default:t[n]=r[n]}},xe=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)},Ce=function(e,t){t.top!==e&&(xe(e,t),e.next=null,e.prev=t.top,t.top.next=e,t.top=e)},we=function(e,t){t.bottom!==e&&(xe(e,t),e.next=t.bottom,e.prev=null,t.bottom.prev=e,t.bottom=e)},ke=function(e,t,r){xe(e,r),t==r.top&&(r.top=e),t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e},Ee=function(e,t,r){xe(e,r),t==r.bottom&&(r.bottom=e),t.prev&&(t.prev.next=e),e.prev=t.prev,t.prev=e,e.next=t},Se=function(e){return function(){throw new Error("Raphaël: you are calling to method “"+e+"” of removed object")}};if(t.pathToRelative=pe,t.svg){r.svgns="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",L=function(e){return+e+.5*(~~e===e)};var _e=function(t,i){if(!i)return(t=l.createElementNS(r.svgns,t)).style.webkitTapHighlightColor="rgba(0,0,0,0)",t;for(var n in i)i[a](n)&&e(t,n,f(i[n]))};t.toString=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var Me=function(e,t){var r=_e("path");t.canvas&&t.canvas.appendChild(r);var i=new Ne(r,t);return i.type="path",Pe(i,{fill:"none",stroke:"#000",path:e}),i},Te=function(e,t,r){var i="linear",n=.5,s=.5,o=e.style;if(t=(t=f(t)[G](Z,(function(e,t,r){if(i="radial",t&&r){n=B(t);var o=2*((s=B(r))>.5)-1;S(n-.5,2)+S(s-.5,2)>.25&&(s=C.sqrt(.25-S(n-.5,2))*o+.5)&&.5!=s&&(s=s.toFixed(5)-1e-5*o)}return m}))).split(/\s*\-\s*/),"linear"==i){var a=t.shift();if(a=-B(a),isNaN(a))return null;var p=[0,0,C.cos(a*_/180),C.sin(a*_/180)],h=1/(w(E(p[2]),E(p[3]))||1);p[2]*=h,p[3]*=h,p[2]<0&&(p[0]=-p[2],p[2]=0),p[3]<0&&(p[1]=-p[3],p[3]=0)}var c=ve(t);if(!c)return null;var d=e.getAttribute(P);(d=d.match(/^url\(#(.*)\)$/))&&r.defs.removeChild(l.getElementById(d[1]));var u=_e(i+"Gradient");u.id=te(),_e(u,"radial"==i?{fx:n,fy:s}:{x1:p[0],y1:p[1],x2:p[2],y2:p[3]}),r.defs.appendChild(u);for(var g=0,v=c[y];g<v;g++){var b=_e("stop");_e(b,{offset:c[g].offset?c[g].offset:g?"100%":"0%","stop-color":c[g].color||"#fff"}),u.appendChild(b)}return _e(e,{fill:"url(#"+u.id+")",opacity:1,"fill-opacity":1}),o.fill=m,o.opacity=1,o.fillOpacity=1,1},Ie=function(e){var r=e.getBBox();_e(e.pattern,{patternTransform:t.format("translate({0},{1})",r.x,r.y)})},Pe=function(r,n){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]},o=r.node,p=r.attrs,h=r.rotate(),c=function(e,t){if(t=s[x.call(t)]){for(var r=e.attrs["stroke-width"]||"1",i={round:r,square:r,butt:0}[e.attrs["stroke-linecap"]||n["stroke-linecap"]]||0,a=[],l=t[y];l--;)a[l]=t[l]*r+(l%2?1:-1)*i;_e(o,{"stroke-dasharray":a.join(",")})}};n[a]("rotation")&&(h=n.rotation);var d=f(h).split(i);for(var u in d.length-1?(d[1]=+d[1],d[2]=+d[2]):d=null,B(h)&&r.rotate(0,!0),n)if(n[a](u)){if(!W[a](u))continue;var v=n[u];switch(p[u]=v,u){case"blur":r.blur(v);break;case"rotation":r.rotate(v,!0);break;case"href":case"title":case"target":var b=o.parentNode;if("a"!=x.call(b.tagName)){var C=_e("a");b.insertBefore(C,o),C.appendChild(o),b=C}"target"==u&&"blank"==v?b.setAttributeNS(r.paper.xlink,"show","new"):b.setAttributeNS(r.paper.xlink,u,v);break;case"cursor":o.style.cursor=v;break;case"clip-rect":var w=f(v).split(i);if(4==w[y]){r.clip&&r.clip.parentNode.parentNode.removeChild(r.clip.parentNode);var k=_e("clipPath"),E=_e("rect");k.id=te(),_e(E,{x:w[0],y:w[1],width:w[2],height:w[3]}),k.appendChild(E),r.paper.defs.appendChild(k),_e(o,{"clip-path":"url(#"+k.id+")"}),r.clip=E}if(!v){var S=l.getElementById(o.getAttribute("clip-path")[G](/(^url\(#|\)$)/g,m));S&&S.parentNode.removeChild(S),_e(o,{"clip-path":m}),delete r.clip}break;case"path":"path"==r.type&&_e(o,{d:v?p.path=he(v):"M0,0"});break;case"width":if(e(o,u,v),!p.fx)break;u="x",v=p.x;case"x":p.fx&&(v=-p.x-(p.width||0));case"rx":if("rx"==u&&"rect"==r.type)break;case"cx":d&&("x"==u||"cx"==u)&&(d[1]+=v-p[u]),e(o,u,v),r.pattern&&Ie(r);break;case"height":if(e(o,u,v),!p.fy)break;u="y",v=p.y;case"y":p.fy&&(v=-p.y-(p.height||0));case"ry":if("ry"==u&&"rect"==r.type)break;case"cy":d&&("y"==u||"cy"==u)&&(d[2]+=v-p[u]),e(o,u,v),r.pattern&&Ie(r);break;case"r":"rect"==r.type?_e(o,{rx:v,ry:v}):e(o,u,v);break;case"src":"image"==r.type&&o.setAttributeNS(r.paper.xlink,"href",v);break;case"stroke-width":o.style.strokeWidth=v,e(o,u,v),p["stroke-dasharray"]&&c(r,p["stroke-dasharray"]);break;case"stroke-dasharray":c(r,v);break;case"translation":var _=f(v).split(i);_[0]=+_[0]||0,_[1]=+_[1]||0,d&&(d[1]+=_[0],d[2]+=_[1]),vt.call(r,_[0],_[1]);break;case"scale":_=f(v).split(i),r.scale(+_[0]||1,+_[1]||+_[0]||1,isNaN(B(_[2]))?null:+_[2],isNaN(B(_[3]))?null:+_[3]);break;case P:var M=f(v).match(R);if(M){k=_e("pattern");var T=_e("image");k.id=te(),_e(k,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1}),_e(T,{x:0,y:0}),T.setAttributeNS(r.paper.xlink,"href",M[1]),k.appendChild(T);var I=l.createElement("img");I.style.cssText="position:absolute;left:-9999em;top-9999em",I.onload=function(){_e(k,{width:this.offsetWidth,height:this.offsetHeight}),_e(T,{width:this.offsetWidth,height:this.offsetHeight}),l.body.removeChild(this),r.paper.safari()},l.body.appendChild(I),I.src=M[1],r.paper.defs.appendChild(k),o.style.fill="url(#"+k.id+")",_e(o,{fill:"url(#"+k.id+")"}),r.pattern=k,r.pattern&&Ie(r);break}var A=t.getRGB(v);if(A.error){if(({circle:1,ellipse:1}[a](r.type)||"r"!=f(v).charAt())&&Te(o,v,r.paper)){p.gradient=v,p.fill="none";break}}else delete n.gradient,delete p.gradient,!t.is(p.opacity,"undefined")&&t.is(n.opacity,"undefined")&&_e(o,{opacity:p.opacity}),!t.is(p["fill-opacity"],"undefined")&&t.is(n["fill-opacity"],"undefined")&&_e(o,{"fill-opacity":p["fill-opacity"]});A[a]("opacity")&&_e(o,{"fill-opacity":A.opacity>1?A.opacity/100:A.opacity});case"stroke":A=t.getRGB(v),e(o,u,A.hex),"stroke"==u&&A[a]("opacity")&&_e(o,{"stroke-opacity":A.opacity>1?A.opacity/100:A.opacity});break;case"gradient":({circle:1,ellipse:1}[a](r.type)||"r"!=f(v).charAt())&&Te(o,v,r.paper);break;case"opacity":p.gradient&&!p[a]("stroke-opacity")&&_e(o,{"stroke-opacity":v>1?v/100:v});case"fill-opacity":if(p.gradient){var N=l.getElementById(o.getAttribute(P)[G](/^url\(#|\)$/g,m));if(N){var F=N.getElementsByTagName("stop");e(F[F[y]-1],"stop-opacity",v)}break}default:"font-size"==u&&(v=z(v,10)+"px");var D=u[G](/(\-.)/g,(function(e){return H.call(e.substring(1))}));o.style[D]=v,e(o,u,v)}}Ae(r,n),d?r.rotate(d.join(g)):B(h)&&r.rotate(h,!0)},Ae=function(e,r){if("text"==e.type&&(r[a]("text")||r[a]("font")||r[a]("font-size")||r[a]("x")||r[a]("y"))){var i=e.attrs,n=e.node,s=n.firstChild?z(l.defaultView.getComputedStyle(n.firstChild,m).getPropertyValue("font-size"),10):10;if(r[a]("text")){for(i.text=r.text;n.firstChild;)n.removeChild(n.firstChild);for(var o=f(r.text).split("\n"),p=0,h=o[y];p<h;p++)if(o[p]){var c=_e("tspan");p&&_e(c,{dy:1.2*s,x:i.x}),c.appendChild(l.createTextNode(o[p])),n.appendChild(c)}}else for(p=0,h=(o=n.getElementsByTagName("tspan"))[y];p<h;p++)p&&_e(o[p],{dy:1.2*s,x:i.x});_e(n,{y:i.y});var d=e.getBBox(),u=i.y-(d.y+d.height/2);u&&t.is(u,"finite")&&_e(n,{y:i.y+u})}},Ne=function(e,r){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.paper=r,this.attrs=this.attrs||{},this.transformations=[],this._={tx:0,ty:0,rt:{deg:0,cx:0,cy: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},Re=Ne[o];Ne[o].rotate=function(e,r,n){if(this.removed)return this;if(null==e)return this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(g):this._.rt.deg;var s=this.getBBox();return(e=f(e).split(i))[y]-1&&(r=B(e[1]),n=B(e[2])),e=B(e[0]),null!=r&&!1!==r?this._.rt.deg=e:this._.rt.deg+=e,null==n&&(r=null),this._.rt.cx=r,this._.rt.cy=n,r=null==r?s.x+s.width/2:r,n=null==n?s.y+s.height/2:n,this._.rt.deg?(this.transformations[0]=t.format("rotate({0} {1} {2})",this._.rt.deg,r,n),this.clip&&_e(this.clip,{transform:t.format("rotate({0} {1} {2})",-this._.rt.deg,r,n)})):(this.transformations[0]=m,this.clip&&_e(this.clip,{transform:m})),_e(this.node,{transform:this.transformations.join(g)}),this},Ne[o].hide=function(){return!this.removed&&(this.node.style.display="none"),this},Ne[o].show=function(){return!this.removed&&(this.node.style.display=""),this},Ne[o].remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this)delete this[e];this.removed=!0}},Ne[o].getBBox=function(){if(this.removed)return this;if("path"==this.type)return ae(this.attrs.path);if("none"==this.node.style.display){this.show();var e=!0}var t={};try{t=this.node.getBBox()}catch(e){}finally{t=t||{}}if("text"==this.type){t={x:t.x,y:1/0,width:0,height:0};for(var r=0,i=this.node.getNumberOfChars();r<i;r++){var n=this.node.getExtentOfChar(r);n.y<t.y&&(t.y=n.y),n.y+n.height-t.y>t.height&&(t.height=n.y+n.height-t.y),n.x+n.width-t.x>t.width&&(t.width=n.x+n.width-t.x)}}return e&&this.hide(),t},Ne[o].attr=function(e,r){if(this.removed)return this;if(null==e){var i={};for(var n in this.attrs)this.attrs[a](n)&&(i[n]=this.attrs[n]);return this._.rt.deg&&(i.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(i.scale=this.scale()),i.gradient&&"none"==i.fill&&(i.fill=i.gradient)&&delete i.gradient,i}if(null==r&&t.is(e,T))return"translation"==e?vt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(null==r&&t.is(e,I)){for(var s={},o=0,l=e.length;o<l;o++)s[e[o]]=this.attr(e[o]);return s}if(null!=r){var p={};p[e]=r}else null!=e&&t.is(e,"object")&&(p=e);for(var h in this.paper.customAttributes)if(this.paper.customAttributes[a](h)&&p[a](h)&&t.is(this.paper.customAttributes[h],"function")){var c=this.paper.customAttributes[h].apply(this,[].concat(p[h]));for(var d in this.attrs[h]=p[h],c)c[a](d)&&(p[d]=c[d])}return Pe(this,p),this},Ne[o].toFront=function(){if(this.removed)return this;this.node.parentNode.appendChild(this.node);var e=this.paper;return e.top!=this&&Ce(this,e),this},Ne[o].toBack=function(){return this.removed||this.node.parentNode.firstChild!=this.node&&(this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild),we(this,this.paper),this.paper),this},Ne[o].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.appendChild(this.node),ke(this,e,this.paper),this},Ne[o].insertBefore=function(e){if(this.removed)return this;var t=e.node||e[0].node;return t.parentNode.insertBefore(this.node,t),Ee(this,e,this.paper),this},Ne[o].blur=function(e){var t=this;if(0!=+e){var r=_e("filter"),i=_e("feGaussianBlur");t.attrs.blur=e,r.id=te(),_e(i,{stdDeviation:+e||1.5}),r.appendChild(i),t.paper.defs.appendChild(r),t._blur=r,_e(t.node,{filter:"url(#"+r.id+")"})}else t._blur&&(t._blur.parentNode.removeChild(t._blur),delete t._blur,delete t.attrs.blur),t.node.removeAttribute("filter")};var Fe=function(e,t,r,i){var n=_e("circle");e.canvas&&e.canvas.appendChild(n);var s=new Ne(n,e);return s.attrs={cx:t,cy:r,r:i,fill:"none",stroke:"#000"},s.type="circle",_e(n,s.attrs),s},De=function(e,t,r,i,n,s){var o=_e("rect");e.canvas&&e.canvas.appendChild(o);var a=new Ne(o,e);return a.attrs={x:t,y:r,width:i,height:n,r:s||0,rx:s||0,ry:s||0,fill:"none",stroke:"#000"},a.type="rect",_e(o,a.attrs),a},Oe=function(e,t,r,i,n){var s=_e("ellipse");e.canvas&&e.canvas.appendChild(s);var o=new Ne(s,e);return o.attrs={cx:t,cy:r,rx:i,ry:n,fill:"none",stroke:"#000"},o.type="ellipse",_e(s,o.attrs),o},Le=function(e,t,r,i,n,s){var o=_e("image");_e(o,{x:r,y:i,width:n,height:s,preserveAspectRatio:"none"}),o.setAttributeNS(e.xlink,"href",t),e.canvas&&e.canvas.appendChild(o);var a=new Ne(o,e);return a.attrs={x:r,y:i,width:n,height:s,src:t},a.type="image",a},Be=function(e,t,r,i){var n=_e("text");_e(n,{x:t,y:r,"text-anchor":"middle"}),e.canvas&&e.canvas.appendChild(n);var s=new Ne(n,e);return s.attrs={x:t,y:r,"text-anchor":"middle",text:i,font:W.font,stroke:"none",fill:"#000"},s.type="text",Pe(s,s.attrs),s},ze=function(t,r){return this.width=t||this.width,this.height=r||this.height,e(this.canvas,"width",this.width),e(this.canvas,"height",this.height),this},qe=function(){var e=be[d](0,arguments),r=e&&e.container,i=e.x,n=e.y,s=e.width,o=e.height;if(!r)throw new Error("SVG container not found.");var a=_e("svg");return i=i||0,n=n||0,_e(a,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:s=s||512,height:o=o||342}),1==r?(a.style.cssText="position:absolute;left:"+i+"px;top:"+n+"px",l.body.appendChild(a)):r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),(r=new c).width=s,r.height=o,r.canvas=a,ye.call(r,r,t.fn),r.clear(),r};r.clear=function(){for(var e=this.canvas;e.firstChild;)e.removeChild(e.firstChild);this.bottom=this.top=null,(this.desc=_e("desc")).appendChild(l.createTextNode("Created with Raphaël")),e.appendChild(this.desc),e.appendChild(this.defs=_e("defs"))},r.remove=function(){for(var e in this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Se(e)}}if(t.vml){var He,We={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},Ue=/([clmz]),?([^clmz]*)/gi,Ge=/ progid:\S+Blur\([^\)]+\)/g,Ve=/-?[^,\s-]+/g,je="1000 1000",Ye=10,Xe={path:1,rect:1};function $e(e,r,i,n,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,r,i-2*s,s,-s,n-2*s,2*s-i,2*s-n):t.format("M{0},{1}l{2},0,0,{3},{4},0z",e,r,i,n,-i)}t.toString=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version},Me=function(e,t){var r=He("group");r.style.cssText="position:absolute;left:0;top:0;width:"+t.width+"px;height:"+t.height+"px",r.coordsize=t.coordsize,r.coordorigin=t.coordorigin;var i=He("shape"),n=i.style;n.width=t.width+"px",n.height=t.height+"px",i.coordsize=je,i.coordorigin=t.coordorigin,r.appendChild(i);var s=new Ne(i,r,t),o={fill:"none",stroke:"#000"};return e&&(o.path=e),s.type="path",s.path=[],s.Path=m,Pe(s,o),t.canvas.appendChild(r),s},Pe=function(e,r){e.attrs=e.attrs||{};var n,s=e.node,o=e.attrs,p=s.style,h=(r.x!=o.x||r.y!=o.y||r.width!=o.width||r.height!=o.height||r.r!=o.r)&&"rect"==e.type,c=e;for(var d in r)r[a](d)&&(o[d]=r[d]);if(h&&(o.path=$e(o.x,o.y,o.width,o.height,o.r),e.X=o.x,e.Y=o.y,e.W=o.width,e.H=o.height),r.href&&(s.href=r.href),r.title&&(s.title=r.title),r.target&&(s.target=r.target),r.cursor&&(p.cursor=r.cursor),"blur"in r&&e.blur(r.blur),(r.path&&"path"==e.type||h)&&(s.path=function(e){var t=/[ahqstv]/gi,r=he;if(f(e).match(t)&&(r=fe),t=/[clmz]/g,r==he&&!f(e).match(t)){var i=f(e)[G](Ue,(function(e,t,r){var i=[],n="m"==x.call(t),s=We[t];return r[G](Ve,(function(e){n&&2==i[y]&&(s+=i+We["m"==t?"l":"L"],i=[]),i[N](L(e*Ye))})),s+i}));return i}var n,s,o=r(e);i=[];for(var a=0,l=o[y];a<l;a++){n=o[a],"z"==(s=x.call(o[a][0]))&&(s="x");for(var p=1,h=n[y];p<h;p++)s+=L(n[p]*Ye)+(p!=h-1?",":m);i[N](s)}return i.join(g)}(o.path)),null!=r.rotation&&e.rotate(r.rotation,!0),r.translation&&(n=f(r.translation).split(i),vt.call(e,n[0],n[1]),null!=e._.rt.cx&&(e._.rt.cx+=+n[0],e._.rt.cy+=+n[1],e.setBox(e.attrs,n[0],n[1]))),r.scale&&(n=f(r.scale).split(i),e.scale(+n[0]||1,+n[1]||+n[0]||1,+n[2]||null,+n[3]||null)),"clip-rect"in r){var u=f(r["clip-rect"]).split(i);if(4==u[y]){u[2]=+u[2]+ +u[0],u[3]=+u[3]+ +u[1];var v=s.clipRect||l.createElement("div"),b=v.style,C=s.parentNode;b.clip=t.format("rect({1}px {2}px {3}px {0}px)",u),s.clipRect||(b.position="absolute",b.top=0,b.left=0,b.width=e.paper.width+"px",b.height=e.paper.height+"px",C.parentNode.insertBefore(v,C),v.appendChild(C),s.clipRect=v)}r["clip-rect"]||s.clipRect&&(s.clipRect.style.clip=m)}if("image"==e.type&&r.src&&(s.src=r.src),"image"==e.type&&r.opacity&&(s.filterOpacity=q+".Alpha(opacity="+100*r.opacity+")",p.filter=(s.filterMatrix||m)+(s.filterOpacity||m)),r.font&&(p.font=r.font),r["font-family"]&&(p.fontFamily='"'+r["font-family"].split(",")[0][G](/^['"]+|['"]+$/g,m)+'"'),r["font-size"]&&(p.fontSize=r["font-size"]),r["font-weight"]&&(p.fontWeight=r["font-weight"]),r["font-style"]&&(p.fontStyle=r["font-style"]),null!=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"]){var E=(s=e.shape||s).getElementsByTagName(P)&&s.getElementsByTagName(P)[0],S=!1;if(!E&&(S=E=He(P)),"fill-opacity"in r||"opacity"in r){var _=((+o["fill-opacity"]+1||2)-1)*((+o.opacity+1||2)-1)*((+t.getRGB(r.fill).o+1||2)-1);_=k(w(_,0),1),E.opacity=_}if(r.fill&&(E.on=!0),null!=E.on&&"none"!=r.fill||(E.on=!1),E.on&&r.fill){var M=r.fill.match(R);M?(E.src=M[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}||"r"!=f(r.fill).charAt())&&Te(c,r.fill)&&(o.fill="none",o.gradient=r.fill))}S&&s.appendChild(E);var T=s.getElementsByTagName("stroke")&&s.getElementsByTagName("stroke")[0],I=!1;!T&&(I=T=He("stroke")),(r.stroke&&"none"!=r.stroke||r["stroke-width"]||null!=r["stroke-opacity"]||r["stroke-dasharray"]||r["stroke-miterlimit"]||r["stroke-linejoin"]||r["stroke-linecap"])&&(T.on=!0),("none"==r.stroke||null==T.on||0==r.stroke||0==r["stroke-width"])&&(T.on=!1);var A=t.getRGB(r.stroke);T.on&&r.stroke&&(T.color=A.hex),_=((+o["stroke-opacity"]+1||2)-1)*((+o.opacity+1||2)-1)*((+A.o+1||2)-1);var F=.75*(B(r["stroke-width"])||1);if(_=k(w(_,0),1),null==r["stroke-width"]&&(F=o["stroke-width"]),r["stroke-width"]&&(T.weight=F),F&&F<1&&(_*=F)&&(T.weight=1),T.opacity=_,r["stroke-linejoin"]&&(T.joinstyle=r["stroke-linejoin"]||"miter"),T.miterlimit=r["stroke-miterlimit"]||8,r["stroke-linecap"]&&(T.endcap="butt"==r["stroke-linecap"]?"flat":"square"==r["stroke-linecap"]?"square":"round"),r["stroke-dasharray"]){var D={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};T.dashstyle=D[a](r["stroke-dasharray"])?D[r["stroke-dasharray"]]:m}I&&s.appendChild(T)}if("text"==c.type)switch(p=c.paper.span.style,o.font&&(p.font=o.font),o["font-family"]&&(p.fontFamily=o["font-family"]),o["font-size"]&&(p.fontSize=o["font-size"]),o["font-weight"]&&(p.fontWeight=o["font-weight"]),o["font-style"]&&(p.fontStyle=o["font-style"]),c.node.string&&(c.paper.span.innerHTML=f(c.node.string)[G](/</g,"&#60;")[G](/&/g,"&#38;")[G](/\n/g,"<br>")),c.W=o.w=c.paper.span.offsetWidth,c.H=o.h=c.paper.span.offsetHeight,c.X=o.x,c.Y=o.y+L(c.H/2),o["text-anchor"]){case"start":c.node.style["v-text-align"]="left",c.bbx=L(c.W/2);break;case"end":c.node.style["v-text-align"]="right",c.bbx=-L(c.W/2);break;default:c.node.style["v-text-align"]="center"}},Te=function(e,t){e.attrs=e.attrs||{},e.attrs;var r,i="linear",n=".5 .5";if(e.attrs.gradient=t,t=(t=f(t)[G](Z,(function(e,t,r){return i="radial",t&&r&&(t=B(t),r=B(r),S(t-.5,2)+S(r-.5,2)>.25&&(r=C.sqrt(.25-S(t-.5,2))*(2*(r>.5)-1)+.5),n=t+g+r),m}))).split(/\s*\-\s*/),"linear"==i){var s=t.shift();if(s=-B(s),isNaN(s))return null}var o=ve(t);if(!o)return null;if(!(r=(e=e.shape||e.node).getElementsByTagName(P)[0]||He(P)).parentNode&&e.appendChild(r),o[y]){r.on=!0,r.method="none",r.color=o[0].color,r.color2=o[o[y]-1].color;for(var a=[],l=0,p=o[y];l<p;l++)o[l].offset&&a[N](o[l].offset+g+o[l].color);r.colors&&(r.colors.value=a[y]?a.join():"0% "+r.color),"radial"==i?(r.type="gradientradial",r.focus="100%",r.focussize=n,r.focusposition=n):(r.type="gradient",r.angle=(270-s)%360)}return 1},(Re=(Ne=function(e,r,i){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.X=0,this.Y=0,this.attrs={},this.Group=r,this.paper=i,this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1},!i.bottom&&(i.bottom=this),this.prev=i.top,i.top&&(i.top.next=this),i.top=this,this.next=null})[o]).rotate=function(e,t,r){return this.removed?this:null==e?this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(g):this._.rt.deg:((e=f(e).split(i))[y]-1&&(t=B(e[1]),r=B(e[2])),e=B(e[0]),null!=t?this._.rt.deg=e:this._.rt.deg+=e,null==r&&(t=null),this._.rt.cx=t,this._.rt.cy=r,this.setBox(this.attrs,t,r),this.Group.style.rotation=this._.rt.deg,this)},Re.setBox=function(e,t,r){if(this.removed)return this;var i=this.Group.style,n=this.shape&&this.shape.style||this.node.style;for(var s in e=e||{})e[a](s)&&(this.attrs[s]=e[s]);t=t||this._.rt.cx,r=r||this._.rt.cy;var o,l,p,h,c=this.attrs;switch(this.type){case"circle":o=c.cx-c.r,l=c.cy-c.r,p=h=2*c.r;break;case"ellipse":o=c.cx-c.rx,l=c.cy-c.ry,p=2*c.rx,h=2*c.ry;break;case"image":o=+c.x,l=+c.y,p=c.width||0,h=c.height||0;break;case"text":this.textpath.v=["m",L(c.x),", ",L(c.y-2),"l",L(c.x)+1,", ",L(c.y-2)].join(m),o=c.x-L(this.W/2),l=c.y-this.H/2,p=this.W,h=this.H;break;case"rect":case"path":if(this.attrs.path){var d=ae(this.attrs.path);o=d.x,l=d.y,p=d.width,h=d.height}else o=0,l=0,p=this.paper.width,h=this.paper.height;break;default:o=0,l=0,p=this.paper.width,h=this.paper.height}r=null==r?l+h/2:r;var u,g=(t=null==t?o+p/2:t)-this.paper.width/2,f=r-this.paper.height/2;i.left!=(u=g+"px")&&(i.left=u),i.top!=(u=f+"px")&&(i.top=u),this.X=Xe[a](this.type)?-g:o,this.Y=Xe[a](this.type)?-f:l,this.W=p,this.H=h,Xe[a](this.type)?(n.left!=(u=-g*Ye+"px")&&(n.left=u),n.top!=(u=-f*Ye+"px")&&(n.top=u)):"text"==this.type?(n.left!=(u=-g+"px")&&(n.left=u),n.top!=(u=-f+"px")&&(n.top=u)):(i.width!=(u=this.paper.width+"px")&&(i.width=u),i.height!=(u=this.paper.height+"px")&&(i.height=u),n.left!=(u=o-g+"px")&&(n.left=u),n.top!=(u=l-f+"px")&&(n.top=u),n.width!=(u=p+"px")&&(n.width=u),n.height!=(u=h+"px")&&(n.height=u))},Re.hide=function(){return!this.removed&&(this.Group.style.display="none"),this},Re.show=function(){return!this.removed&&(this.Group.style.display="block"),this},Re.getBBox=function(){return this.removed?this:Xe[a](this.type)?ae(this.attrs.path):{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}},Re.remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this.Group.parentNode.removeChild(this.Group),this.shape&&this.shape.parentNode.removeChild(this.shape),this)delete this[e];this.removed=!0}},Re.attr=function(e,r){if(this.removed)return this;if(null==e){var i={};for(var n in this.attrs)this.attrs[a](n)&&(i[n]=this.attrs[n]);return this._.rt.deg&&(i.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(i.scale=this.scale()),i.gradient&&"none"==i.fill&&(i.fill=i.gradient)&&delete i.gradient,i}if(null==r&&t.is(e,"string"))return"translation"==e?vt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(this.attrs&&null==r&&t.is(e,I)){var s,o={};for(n=0,s=e[y];n<s;n++)o[e[n]]=this.attr(e[n]);return o}var l;if(null!=r&&((l={})[e]=r),null==r&&t.is(e,"object")&&(l=e),l){for(var p in this.paper.customAttributes)if(this.paper.customAttributes[a](p)&&l[a](p)&&t.is(this.paper.customAttributes[p],"function")){var h=this.paper.customAttributes[p].apply(this,[].concat(l[p]));for(var c in this.attrs[p]=l[p],h)h[a](c)&&(l[c]=h[c])}l.text&&"text"==this.type&&(this.node.string=l.text),Pe(this,l),l.gradient&&({circle:1,ellipse:1}[a](this.type)||"r"!=f(l.gradient).charAt())&&Te(this,l.gradient),(!Xe[a](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this},Re.toFront=function(){return!this.removed&&this.Group.parentNode.appendChild(this.Group),this.paper.top!=this&&Ce(this,this.paper),this},Re.toBack=function(){return this.removed||this.Group.parentNode.firstChild!=this.Group&&(this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild),we(this,this.paper)),this},Re.insertAfter=function(e){return this.removed||(e.constructor==xt&&(e=e[e.length-1]),e.Group.nextSibling?e.Group.parentNode.insertBefore(this.Group,e.Group.nextSibling):e.Group.parentNode.appendChild(this.Group),ke(this,e,this.paper)),this},Re.insertBefore=function(e){return this.removed||(e.constructor==xt&&(e=e[0]),e.Group.parentNode.insertBefore(this.Group,e.Group),Ee(this,e,this.paper)),this},Re.blur=function(e){var r=this.node.runtimeStyle,i=r.filter;i=i.replace(Ge,m),0!=+e?(this.attrs.blur=e,r.filter=i+g+q+".Blur(pixelradius="+(+e||1.5)+")",r.margin=t.format("-{0}px 0 0 -{0}px",L(+e||1.5))):(r.filter=i,r.margin=0,delete this.attrs.blur)},Fe=function(e,t,r,i){var n=He("group"),s=He("oval");s.style,n.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",n.coordsize=je,n.coordorigin=e.coordorigin,n.appendChild(s);var o=new Ne(s,n,e);return o.type="circle",Pe(o,{stroke:"#000",fill:"none"}),o.attrs.cx=t,o.attrs.cy=r,o.attrs.r=i,o.setBox({x:t-i,y:r-i,width:2*i,height:2*i}),e.canvas.appendChild(n),o},De=function(e,t,r,i,n,s){var o=$e(t,r,i,n,s),a=e.path(o),l=a.attrs;return a.X=l.x=t,a.Y=l.y=r,a.W=l.width=i,a.H=l.height=n,l.r=s,l.path=o,a.type="rect",a},Oe=function(e,t,r,i,n){var s=He("group"),o=He("oval");o.style,s.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",s.coordsize=je,s.coordorigin=e.coordorigin,s.appendChild(o);var a=new Ne(o,s,e);return a.type="ellipse",Pe(a,{stroke:"#000"}),a.attrs.cx=t,a.attrs.cy=r,a.attrs.rx=i,a.attrs.ry=n,a.setBox({x:t-i,y:r-n,width:2*i,height:2*n}),e.canvas.appendChild(s),a},Le=function(e,t,r,i,n,s){var o=He("group"),a=He("image");o.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",o.coordsize=je,o.coordorigin=e.coordorigin,a.src=t,o.appendChild(a);var l=new Ne(a,o,e);return l.type="image",l.attrs.src=t,l.attrs.x=r,l.attrs.y=i,l.attrs.w=n,l.attrs.h=s,l.setBox({x:r,y:i,width:n,height:s}),e.canvas.appendChild(o),l},Be=function(e,r,i,n){var s=He("group"),o=He("shape"),a=o.style,l=He("path");l.style;var p=He("textpath");s.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",s.coordsize=je,s.coordorigin=e.coordorigin,l.v=t.format("m{0},{1}l{2},{1}",L(10*r),L(10*i),L(10*r)+1),l.textpathok=!0,a.width=e.width,a.height=e.height,p.string=f(n),p.on=!0,o.appendChild(p),o.appendChild(l),s.appendChild(o);var h=new Ne(p,s,e);return h.shape=o,h.textpath=l,h.type="text",h.attrs.text=n,h.attrs.x=r,h.attrs.y=i,h.attrs.w=1,h.attrs.h=1,Pe(h,{font:W.font,stroke:"none",fill:"#000"}),h.setBox(),e.canvas.appendChild(s),h},ze=function(e,t){var r=this.canvas.style;return e==+e&&(e+="px"),t==+t&&(t+="px"),r.width=e,r.height=t,r.clip="rect(0 "+e+" "+t+" 0)",this},l.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!l.namespaces.rvml&&l.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),He=function(e){return l.createElement("<rvml:"+e+' class="rvml">')}}catch(wt){He=function(e){return l.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}qe=function(){var e=be[d](0,arguments),r=e.container,i=e.height,n=e.width,s=e.x,o=e.y;if(!r)throw new Error("VML container not found.");var a=new c,p=a.canvas=l.createElement("div"),h=p.style;return s=s||0,o=o||0,(n=n||512)==+n&&(n+="px"),(i=i||342)==+i&&(i+="px"),a.width=1e3,a.height=1e3,a.coordsize="10000 10000",a.coordorigin="0 0",a.span=l.createElement("span"),a.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",p.appendChild(a.span),h.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",n,i),1==r?(l.body.appendChild(p),h.left=s+"px",h.top=o+"px",h.position="absolute"):r.firstChild?r.insertBefore(p,r.firstChild):r.appendChild(p),ye.call(a,a,t.fn),a},r.clear=function(){this.canvas.innerHTML=m,this.span=l.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},r.remove=function(){for(var e in this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Se(e);return!0}}var Ke=navigator.userAgent.match(/Version\/(.*?)\s/);"Apple Computer, Inc."==navigator.vendor&&(Ke&&Ke[1]<4||"iP"==navigator.platform.slice(0,2))?r.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});p.setTimeout((function(){e.remove()}))}:r.safari=function(){};for(var Ze=function(){this.returnValue=!1},Je=function(){return this.originalEvent.preventDefault()},Qe=function(){this.cancelBubble=!0},et=function(){return this.originalEvent.stopPropagation()},tt=l.addEventListener?function(e,t,r,i){var n=u&&b[t]?b[t]:t,s=function(n){if(u&&b[a](t))for(var s=0,o=n.targetTouches&&n.targetTouches.length;s<o;s++)if(n.targetTouches[s].target==e){var l=n;(n=n.targetTouches[s]).originalEvent=l,n.preventDefault=Je,n.stopPropagation=et;break}return r.call(i,n)};return e.addEventListener(n,s,!1),function(){return e.removeEventListener(n,s,!1),!0}}:l.attachEvent?function(e,t,r,i){var n=function(e){return(e=e||p.event).preventDefault=e.preventDefault||Ze,e.stopPropagation=e.stopPropagation||Qe,r.call(i,e)};return e.attachEvent("on"+t,n),function(){return e.detachEvent("on"+t,n),!0}}:void 0,rt=[],it=function(e){for(var t,r=e.clientX,i=e.clientY,n=l.documentElement.scrollTop||l.body.scrollTop,s=l.documentElement.scrollLeft||l.body.scrollLeft,o=rt.length;o--;){if(t=rt[o],u){for(var a,p=e.touches.length;p--;)if((a=e.touches[p]).identifier==t.el._drag.id){r=a.clientX,i=a.clientY,(e.originalEvent?e.originalEvent:e).preventDefault();break}}else e.preventDefault();r+=s,i+=n,t.move&&t.move.call(t.move_scope||t.el,r-t.el._drag.x,i-t.el._drag.y,r,i,e)}},nt=function e(r){t.unmousemove(it).unmouseup(e);for(var i,n=rt.length;n--;)(i=rt[n]).el._drag={},i.end&&i.end.call(i.end_scope||i.start_scope||i.move_scope||i.el,r);rt=[]},st=v[y];st--;)!function(e){t[e]=Ne[o][e]=function(r,i){return t.is(r,"function")&&(this.events=this.events||[],this.events.push({name:e,f:r,unbind:tt(this.shape||this.node||l,e,r,i||this)})),this},t["un"+e]=Ne[o]["un"+e]=function(t){for(var r=this.events,i=r[y];i--;)if(r[i].name==e&&r[i].f==t)return r[i].unbind(),r.splice(i,1),!r.length&&delete this.events,this;return this}}(v[st]);function ot(){return this.x+g+this.y}Re.hover=function(e,t,r,i){return this.mouseover(e,r).mouseout(t,i||r)},Re.unhover=function(e,t){return this.unmouseover(e).unmouseout(t)},Re.drag=function(e,r,i,n,s,o){return this._drag={},this.mousedown((function(a){(a.originalEvent||a).preventDefault();var p=l.documentElement.scrollTop||l.body.scrollTop,h=l.documentElement.scrollLeft||l.body.scrollLeft;this._drag.x=a.clientX+h,this._drag.y=a.clientY+p,this._drag.id=a.identifier,r&&r.call(s||n||this,a.clientX+h,a.clientY+p,a),!rt.length&&t.mousemove(it).mouseup(nt),rt.push({el:this,move:e,end:i,move_scope:n,start_scope:s,end_scope:o})})),this},Re.undrag=function(e,r,i){for(var n=rt.length;n--;)rt[n].el==this&&rt[n].move==e&&rt[n].end==i&&rt.splice(n++,1);!rt.length&&t.unmousemove(it).unmouseup(nt)},r.circle=function(e,t,r){return Fe(this,e||0,t||0,r||0)},r.rect=function(e,t,r,i,n){return De(this,e||0,t||0,r||0,i||0,n||0)},r.ellipse=function(e,t,r,i){return Oe(this,e||0,t||0,r||0,i||0)},r.path=function(e){return e&&!t.is(e,T)&&!t.is(e[0],I)&&(e+=m),Me(t.format[d](t,arguments),this)},r.image=function(e,t,r,i,n){return Le(this,e||"about:blank",t||0,r||0,i||0,n||0)},r.text=function(e,t,r){return Be(this,e||0,t||0,f(r))},r.set=function(e){return arguments[y]>1&&(e=Array[o].splice.call(arguments,0,arguments[y])),new xt(e)},r.setSize=ze,r.top=r.bottom=null,r.raphael=t,Re.resetScale=function(){if(this.removed)return this;this._.sx=1,this._.sy=1,this.attrs.scale="1 1"},Re.scale=function(t,r,i,n){if(this.removed)return this;if(null==t&&null==r)return{x:this._.sx,y:this._.sy,toString:ot};!+(r=r||t)&&(r=t);var s,o,a=this.attrs;if(0!=t){var l=this.getBBox(),p=l.x+l.width/2,h=l.y+l.height/2,c=E(t/this._.sx),d=E(r/this._.sy);i=+i||0==i?i:p,n=+n||0==n?n:h;var u=this._.sx>0,f=this._.sy>0,v=~~(t/E(t)),b=~~(r/E(r)),x=c*v,C=d*b,w=this.node.style,k=i+E(p-i)*x*(p>i==u?1:-1),S=n+E(h-n)*C*(h>n==f?1:-1),_=t*v>r*b?d:c;switch(this.type){case"rect":case"image":var M=a.width*c,T=a.height*d;this.attr({height:T,r:a.r*_,width:M,x:k-M/2,y:S-T/2});break;case"circle":case"ellipse":this.attr({rx:a.rx*c,ry:a.ry*d,r:a.r*_,cx:k,cy:S});break;case"text":this.attr({x:k,y:S});break;case"path":for(var I=pe(a.path),P=!0,A=u?x:c,N=f?C:d,R=0,F=I[y];R<F;R++){var D=I[R],O=H.call(D[0]);if("M"!=O||!P)if(P=!1,"A"==O)D[I[R][y]-2]*=A,D[I[R][y]-1]*=N,D[1]*=c,D[2]*=d,D[5]=+(v+b?!!+D[5]:!+D[5]);else if("H"==O)for(var L=1,B=D[y];L<B;L++)D[L]*=A;else if("V"==O)for(L=1,B=D[y];L<B;L++)D[L]*=N;else for(L=1,B=D[y];L<B;L++)D[L]*=L%2?A:N}var z=ae(I);s=k-z.x-z.width/2,o=S-z.y-z.height/2,I[0][1]+=s,I[0][2]+=o,this.attr({path:I})}!(this.type in{text:1,image:1})||1==v&&1==b?this.transformations?(this.transformations[2]=m,e(this.node,"transform",this.transformations.join(g)),a.fx=0,a.fy=0):(this.node.filterMatrix=m,w.filter=(this.node.filterMatrix||m)+(this.node.filterOpacity||m)):this.transformations?(this.transformations[2]="scale(".concat(v,",",b,")"),e(this.node,"transform",this.transformations.join(g)),s=-1==v?-a.x-(M||0):a.x,o=-1==b?-a.y-(T||0):a.y,this.attr({x:s,y:o}),a.fx=v-1,a.fy=b-1):(this.node.filterMatrix=q+".Matrix(M11=".concat(v,", M12=0, M21=0, M22=",b,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')"),w.filter=(this.node.filterMatrix||m)+(this.node.filterOpacity||m)),a.scale=[t,r,i,n].join(g),this._.sx=t,this._.sy=r}return this},Re.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 at={},lt=function e(r,i,n,s,o,a,l,p,h){if(r===n&&i===s&&o===l&&a==p){var c=l-r,d=p-i,u=Math.sqrt(c*c+d*d);if(null==h)return u;var m=h/u;return{start:{x:r,y:i},m:{x:r,y:i},n:{x:l,y:p},end:{x:l,y:p},x:r+m*c,y:i+m*d,alpha:90-180*C.atan(c/d)/_}}var g,f,v=0,b=100,y=[r,i,n,s,o,a,l,p].join(),x=at[y];(!x&&(at[y]=x={data:[]}),x.timer&&clearTimeout(x.timer),x.timer=setTimeout((function(){delete at[y]}),2e3),null!=h)&&(b=10*~~e(r,i,n,s,o,a,l,p));for(var w=0;w<b+1;w++){if(x.data[h]>w?f=x.data[w*b]:(f=t.findDotsAtSegment(r,i,n,s,o,a,l,p,w/b),x.data[w]=f),w&&(v+=S(S(g.x-f.x,2)+S(g.y-f.y,2),.5)),null!=h&&v>=h)return f;g=f}if(null==h)return v},pt=function(e,r){return function(i,n,s){for(var o,a,l,p,h,c="",d={},u=0,m=0,g=(i=fe(i)).length;m<g;m++){if("M"==(l=i[m])[0])o=+l[1],a=+l[2];else{if(u+(p=lt(o,a,l[1],l[2],l[3],l[4],l[5],l[6]))>n){if(r&&!d.start){if(c+=["C",(h=lt(o,a,l[1],l[2],l[3],l[4],l[5],l[6],n-u)).start.x,h.start.y,h.m.x,h.m.y,h.x,h.y],s)return c;d.start=c,c=["M",h.x,h.y+"C",h.n.x,h.n.y,h.end.x,h.end.y,l[5],l[6]].join(),u+=p,o=+l[5],a=+l[6];continue}if(!e&&!r)return{x:(h=lt(o,a,l[1],l[2],l[3],l[4],l[5],l[6],n-u)).x,y:h.y,alpha:h.alpha}}u+=p,o=+l[5],a=+l[6]}c+=l}return d.end=c,(h=e?u:r?d:t.findDotsAtSegment(o,a,l[1],l[2],l[3],l[4],l[5],l[6],1)).alpha&&(h={x:h.x,y:h.y,alpha:h.alpha}),h}},ht=pt(1),ct=pt(),dt=pt(0,1);Re.getTotalLength=function(){if("path"==this.type)return this.node.getTotalLength?this.node.getTotalLength():ht(this.attrs.path)},Re.getPointAtLength=function(e){if("path"==this.type)return ct(this.attrs.path,e)},Re.getSubpath=function(e,t){if("path"==this.type){if(E(this.getTotalLength()-t)<"1e-6")return dt(this.attrs.path,e).end;var r=dt(this.attrs.path,t,1);return e?dt(r,e).end:r}},t.easing_formulas={linear:function(e){return e},"<":function(e){return S(e,3)},">":function(e){return S(e-1,3)+1},"<>":function(e){return(e*=2)<1?S(e,3)/2:(S(e-=2,3)+2)/2},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return(e-=1)*e*((t+1)*e+t)+1},elastic:function(e){if(0==e||1==e)return e;return S(2,-10*e)*C.sin(2*_*(e-.075)/.3)+1},bounce:function(e){var t=7.5625,r=2.75;return e<1/r?t*e*e:e<2/r?t*(e-=1.5/r)*e+.75:e<2.5/r?t*(e-=2.25/r)*e+.9375:t*(e-=2.625/r)*e+.984375}};var ut=[],mt=function e(){for(var r=+new Date,i=0;i<ut[y];i++){var n=ut[i];if(!n.stop&&!n.el.removed){var s,o=r-n.start,l=n.ms,p=n.easing,h=n.from,c=n.diff,d=n.to,u=n.t,f=n.el,v={};if(o<l){var b=p(o/l);for(var x in h)if(h[a](x)){switch(U[x]){case"along":s=b*l*c[x],d.back&&(s=d.len-s);var C=ct(d[x],s);f.translate(c.sx-c.x||0,c.sy-c.y||0),c.x=C.x,c.y=C.y,f.translate(C.x-c.sx,C.y-c.sy),d.rot&&f.rotate(c.r+C.alpha,C.x,C.y);break;case M:s=+h[x]+b*l*c[x];break;case"colour":s="rgb("+[ft(L(h[x].r+b*l*c[x].r)),ft(L(h[x].g+b*l*c[x].g)),ft(L(h[x].b+b*l*c[x].b))].join(",")+")";break;case"path":s=[];for(var w=0,k=h[x][y];w<k;w++){s[w]=[h[x][w][0]];for(var E=1,S=h[x][w][y];E<S;E++)s[w][E]=+h[x][w][E]+b*l*c[x][w][E];s[w]=s[w].join(g)}s=s.join(g);break;case"csv":switch(x){case"translation":var _=b*l*c[x][0]-u.x,T=b*l*c[x][1]-u.y;u.x+=_,u.y+=T,s=_+g+T;break;case"rotation":s=+h[x][0]+b*l*c[x][0],h[x][1]&&(s+=","+h[x][1]+","+h[x][2]);break;case"scale":s=[+h[x][0]+b*l*c[x][0],+h[x][1]+b*l*c[x][1],2 in d[x]?d[x][2]:m,3 in d[x]?d[x][3]:m].join(g);break;case"clip-rect":for(s=[],w=4;w--;)s[w]=+h[x][w]+b*l*c[x][w]}break;default:var I=[].concat(h[x]);for(s=[],w=f.paper.customAttributes[x].length;w--;)s[w]=+I[w]+b*l*c[x][w]}v[x]=s}f.attr(v),f._run&&f._run.call(f)}else d.along&&(C=ct(d.along,d.len*!d.back),f.translate(c.sx-(c.x||0)+C.x-c.sx,c.sy-(c.y||0)+C.y-c.sy),d.rot&&f.rotate(c.r+C.alpha,C.x,C.y)),(u.x||u.y)&&f.translate(-u.x,-u.y),d.scale&&(d.scale+=m),f.attr(d),ut.splice(i--,1)}}t.svg&&f&&f.paper&&f.paper.safari(),ut[y]&&setTimeout(e)},gt=function(e,r,i,n,s){var o=i-n;r.timeouts.push(setTimeout((function(){t.is(s,"function")&&s.call(r),r.animate(e,o,e.easing)}),n))},ft=function(e){return w(k(e,255),0)},vt=function(e,t){if(null==e)return{x:this._.tx,y:this._.ty,toString:ot};switch(this._.tx+=+e,this._.ty+=+t,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 r=pe(this.attrs.path);r[0][1]+=+e,r[0][2]+=+t,this.attr({path:r})}return this};function bt(e){return function(r,i,n,s){var o={back:e};return t.is(n,"function")?s=n:o.rot=n,r&&r.constructor==Ne&&(r=r.attrs.path),r&&(o.along=r),this.animate(o,i,s)}}function yt(e,t,r,i,n,s){var o=3*t,a=3*(i-t)-o,l=1-o-a,p=3*r,h=3*(n-r)-p,c=1-p-h;function d(e){return((l*e+a)*e+o)*e}return function(e,t){var r=function(e,t){var r,i,n,s,p,h;for(n=e,h=0;h<8;h++){if(s=d(n)-e,E(s)<t)return n;if(E(p=(3*l*n+2*a)*n+o)<1e-6)break;n-=s/p}if(i=1,(n=e)<(r=0))return r;if(n>i)return i;for(;r<i;){if(s=d(n),E(s-e)<t)return n;e>s?r=n:i=n,n=(i-r)/2+r}return n}(e,t);return((c*r+h)*r+p)*r}(e,1/(200*s))}Re.animateWith=function(e,t,r,i,n){for(var s=0,o=ut.length;s<o;s++)ut[s].el.id==e.id&&(t.start=ut[s].start);return this.animate(t,r,i,n)},Re.animateAlong=bt(),Re.animateAlongBack=bt(1),Re.onAnimation=function(e){return this._run=e||0,this},Re.animate=function(e,r,n,s){var o=this;if(o.timeouts=o.timeouts||[],!t.is(n,"function")&&n||(s=n||null),o.removed)return s&&s.call(o),o;var l={},p={},h=!1,c={};for(var d in e)if(e[a](d)&&(U[a](d)||o.paper.customAttributes[a](d)))switch(h=!0,l[d]=o.attr(d),null==l[d]&&(l[d]=W[d]),p[d]=e[d],U[d]){case"along":var u=ht(e[d]),m=ct(e[d],u*!!e.back),g=o.getBBox();c[d]=u/r,c.tx=g.x,c.ty=g.y,c.sx=m.x,c.sy=m.y,p.rot=e.rot,p.back=e.back,p.len=u,e.rot&&(c.r=B(o.rotate())||0);break;case M:c[d]=(p[d]-l[d])/r;break;case"colour":l[d]=t.getRGB(l[d]);var v=t.getRGB(p[d]);c[d]={r:(v.r-l[d].r)/r,g:(v.g-l[d].g)/r,b:(v.b-l[d].b)/r};break;case"path":var b=fe(l[d],p[d]);l[d]=b[0];var x=b[1];c[d]=[];for(var C=0,w=l[d][y];C<w;C++){c[d][C]=[0];for(var k=1,E=l[d][C][y];k<E;k++)c[d][C][k]=(x[C][k]-l[d][C][k])/r}break;case"csv":var S=f(e[d]).split(i),_=f(l[d]).split(i);switch(d){case"translation":l[d]=[0,0],c[d]=[S[0]/r,S[1]/r];break;case"rotation":l[d]=_[1]==S[1]&&_[2]==S[2]?_:[0,S[1],S[2]],c[d]=[(S[0]-l[d][0])/r,0,0];break;case"scale":e[d]=S,l[d]=f(l[d]).split(i),c[d]=[(S[0]-l[d][0])/r,(S[1]-l[d][1])/r,0,0];break;case"clip-rect":for(l[d]=f(l[d]).split(i),c[d]=[],C=4;C--;)c[d][C]=(S[C]-l[d][C])/r}p[d]=S;break;default:for(S=[].concat(e[d]),_=[].concat(l[d]),c[d]=[],C=o.paper.customAttributes[d][y];C--;)c[d][C]=((S[C]||0)-(_[C]||0))/r}if(h){var T=t.easing_formulas[n];if(!T)if((T=f(n).match(O))&&5==T[y]){var I=T;T=function(e){return yt(e,+I[1],+I[2],+I[3],+I[4],r)}}else T=function(e){return e};ut.push({start:e.start||+new Date,ms:r,easing:T,from:l,diff:c,to:p,el:o,t:{x:0,y:0}}),t.is(s,"function")&&(o._ac=setTimeout((function(){s.call(o)}),r)),1==ut[y]&&setTimeout(mt)}else{var P,A=[];for(var N in e)e[a](N)&&V.test(N)&&(d={value:e[N]},"from"==N&&(N=0),"to"==N&&(N=100),d.key=z(N,10),A.push(d));for(A.sort(J),A[0].key&&A.unshift({key:0,value:o.attrs}),C=0,w=A[y];C<w;C++)gt(A[C].value,o,r/100*A[C].key,r/100*(A[C-1]&&A[C-1].key||0),A[C-1]&&A[C-1].value.callback);(P=A[A[y]-1].value.callback)&&o.timeouts.push(setTimeout((function(){P.call(o)}),r))}return this},Re.stop=function(){for(var e=0;e<ut.length;e++)ut[e].el.id==this.id&&ut.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},Re.translate=function(e,t){return this.attr({translation:e+" "+t})},Re.toString=function(){return"Raphaël’s object"},t.ae=ut;var xt=function e(t){if(this.items=[],this[y]=0,this.type="set",t)for(var r=0,i=t[y];r<i;r++)!t[r]||t[r].constructor!=Ne&&t[r].constructor!=e||(this[this.items[y]]=this.items[this.items[y]]=t[r],this[y]++)};for(var Ct in xt[o][N]=function(){for(var e,t,r=0,i=arguments[y];r<i;r++)!(e=arguments[r])||e.constructor!=Ne&&e.constructor!=xt||(this[t=this.items[y]]=this.items[t]=e,this[y]++);return this},xt[o].pop=function(){return delete this[this[y]--],this.items.pop()},Re)Re[a](Ct)&&(xt[o][Ct]=function(e){return function(){for(var t=0,r=this.items[y];t<r;t++)this.items[t][e][d](this.items[t],arguments);return this}}(Ct));xt[o].attr=function(e,r){if(e&&t.is(e,I)&&t.is(e[0],"object"))for(var i=0,n=e[y];i<n;i++)this.items[i].attr(e[i]);else for(var s=0,o=this.items[y];s<o;s++)this.items[s].attr(e,r);return this},xt[o].animate=function(e,r,i,n){(t.is(i,"function")||!i)&&(n=i||null);var s,o,a=this.items[y],l=a,p=this;for(n&&(o=function(){!--a&&n.call(p)}),i=t.is(i,T)?i:o,s=this.items[--l].animate(e,r,i,o);l--;)this.items[l]&&!this.items[l].removed&&this.items[l].animateWith(s,e,r,i,o);return this},xt[o].insertAfter=function(e){for(var t=this.items[y];t--;)this.items[t].insertAfter(e);return this},xt[o].getBBox=function(){for(var e=[],t=[],r=[],i=[],n=this.items[y];n--;){var s=this.items[n].getBBox();e[N](s.x),t[N](s.y),r[N](s.x+s.width),i[N](s.y+s.height)}return{x:e=k[d](0,e),y:t=k[d](0,t),width:w[d](0,r)-e,height:w[d](0,i)-t}},xt[o].clone=function(e){e=new xt;for(var t=0,r=this.items[y];t<r;t++)e[N](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:{}},r=e.face["font-family"];for(var i in e.face)e.face[a](i)&&(t.face[i]=e.face[i]);if(this.fonts[r]?this.fonts[r][N](t):this.fonts[r]=[t],!e.svg)for(var n in t.face["units-per-em"]=z(e.face["units-per-em"],10),e.glyphs)if(e.glyphs[a](n)){var s=e.glyphs[n];if(t.glyphs[n]={w:s.w,k:{},d:s.d&&"M"+s.d[G](/[mlcxtrv]/g,(function(e){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[e]||"M"}))+"z"},s.k)for(var o in s.k)s[a](o)&&(t.glyphs[n].k[o]=s.k[o])}return e},r.getFont=function(e,r,i,n){if(n=n||"normal",i=i||"normal",r=+r||{normal:400,bold:700,lighter:300,bolder:800}[r]||400,t.fonts){var s,o=t.fonts[e];if(!o){var l=new RegExp("(^|\\s)"+e[G](/[^\w\d\s+!~.:_-]/g,m)+"(\\s|$)","i");for(var p in t.fonts)if(t.fonts[a](p)&&l.test(p)){o=t.fonts[p];break}}if(o)for(var h=0,c=o[y];h<c&&((s=o[h]).face["font-weight"]!=r||s.face["font-style"]!=i&&s.face["font-style"]||s.face["font-stretch"]!=n);h++);return s}},r.print=function(e,r,n,s,o,a,l){a=a||"middle",l=w(k(l||0,1),-1);var p,h=this.set(),c=f(n).split(m),d=0;if(t.is(s,n)&&(s=this.getFont(s)),s){p=(o||16)/s.face["units-per-em"];for(var u=s.face.bbox.split(i),g=+u[0],v=+u[1]+("baseline"==a?u[3]-u[1]+ +s.face.descent:(u[3]-u[1])/2),b=0,x=c[y];b<x;b++){var C=b&&s.glyphs[c[b-1]]||{},E=s.glyphs[c[b]];d+=b?(C.w||s.w)+(C.k&&C.k[c[b]]||0)+s.w*l:0,E&&E.d&&h[N](this.path(E.d).attr({fill:"#000",stroke:"none",translation:[d,0]}))}h.scale(p,p,g,v).translate(e-g,r-v)}return h},t.format=function(e,r){var i=t.is(r,I)?[0].concat(r):arguments;return e&&t.is(e,T)&&i[y]-1&&(e=e[G](s,(function(e,t){return null==i[++t]?m:i[t]}))),e||m},t.ninja=function(){return h.was?p.Raphael=h.is:Raphael=void 0,t},t.el=Re,t.st=xt[o],cr.exports=t}();var dr={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",BLUE_A:"#CCFAFF",BLUE_B:"#80F6FF",BLUE_C:"#63D9EA",BLUE_D:"#11ACCD",BLUE_E:"#0C7F99",TEAL_A:"#94FFF5",TEAL_B:"#26EDD5",TEAL_C:"#01D1C1",TEAL_D:"#01A995",TEAL_E:"#208170",GREEN_A:"#B6FFB0",GREEN_B:"#8AF281",GREEN_C:"#74CF70",GREEN_D:"#1FAB54",GREEN_E:"#0D923F",GOLD_A:"#FFD0A9",GOLD_B:"#FFBB71",GOLD_C:"#FF9C39",GOLD_D:"#E07D10",GOLD_E:"#A75A05",RED_A:"#FCA9A9",RED_B:"#FF8482",RED_C:"#F9685D",RED_D:"#E84D39",RED_E:"#BC2612",MAROON_A:"#FFBDE0",MAROON_B:"#FF92C6",MAROON_C:"#ED5FA6",MAROON_D:"#CA337C",MAROON_E:"#9E034E",PURPLE_A:"#DDD7FF",PURPLE_B:"#C6B9FC",PURPLE_C:"#AA87FF",PURPLE_D:"#7854AB",PURPLE_E:"#543B78",MINT_A:"#F5F9E8",MINT_B:"#EDF2DF",MINT_C:"#E0E5CC",GRAY_A:"#F6F7F7",GRAY_B:"#F0F1F2",GRAY_C:"#E3E5E6",GRAY_D:"#D6D8DA",GRAY_E:"#BABEC2",GRAY_F:"#888D93",GRAY_G:"#626569",GRAY_H:"#3B3E40",GRAY_I:"#21242C",KA_BLUE:"#314453",KA_GREEN:"#71B307",_BACKGROUND:"#FDFDFD",INTERACTING:"#71B307",INTERACTIVE:"#71B307",DYNAMIC:"#6495ED"};function ur(e,t){var r=f(e).find("."+t);return 0===r.length?f("<span>").addClass(t).appendTo(f(e)):r}function mr(e,t){var r=0;!function i(){e.scrollHeight>18||r>=10?t():(r++,setTimeout(i,100))}()}var gr,fr,vr={processMath:(gr=function*(e,t,r,i){var n=f(e);if(null==n.attr("data-math-formula")||r){var s=ur(n,"katex-holder"),o=ur(n,"mathjax-holder"),a=o.find("script[type='math/tex']")[0];null==t&&(n.attr("data-math-formula")?t=n.attr("data-math-formula"):a&&(t=a.text||a.textContent)),t=null!=t?t+"":"",t=ce.cleanMath(t),n.attr("data-math-formula",t);var l=yield oe().getKaTeX();try{if(l.render(t,s[0],{colorIsTextColor:!0}),"mathjax"===n.attr("data-math-type")&&"undefined"!=typeof MathJax){var p=MathJax.Hub.getJaxFor(a);if(p){var h=p.SourceElement();h.previousSibling&&h.previousSibling.className&&p.Remove()}}return n.attr("data-math-type","katex"),void(i&&mr(e,i))}catch(e){if(oe().logKaTeXError(t,e),e instanceof l.ParseError)throw e}n.attr("data-math-type","mathjax"),a?"text"in a?a.text=t:a.textContent=t:o.append("<script type='math/tex'>"+t.replace(/<\//g,"< /")+"<\/script>"),"undefined"!=typeof MathJax&&(MathJax.Hub.Queue(["Reprocess",MathJax.Hub,o[0]]),i&&MathJax.Hub.Queue((function(){var t=MathJax.Callback((function(){}));return mr(e,(function(){i(),t()})),t})))}},fr=function(){var e=this,t=arguments;return new Promise((function(r,i){var n=gr.apply(e,t);function s(e){G(n,r,i,s,o,"next",e)}function o(e){G(n,r,i,s,o,"throw",e)}s(void 0)}))},function(e,t,r,i){return fr.apply(this,arguments)}),cleanupMath:function(e){var t=f(e);if(t.attr("data-math-formula")){if("undefined"!=typeof MathJax){var r=MathJax.Hub.getJaxFor(t.find("script")[0]);if(r){var i=r.SourceElement();i.previousSibling&&i.previousSibling.className&&r.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 f(e).attr("data-math-formula")}},{processMath:br}=vr;function yr(e,t){return"number"==typeof e&&(e=[e,e]),t=t*Math.PI/180,[e[0]*Math.cos(t),e[1]*Math.sin(t)]}var xr={unscaledSvgPath:function(e){return!0===e[0]?"":f.map(e,(function(e,t){return!0===e?"z":(0===t?"M":"L")+e[0]+" "+e[1]})).join("")},getDistance:function(e,t){return b.distanceToPoint(e,t)},coordDiff:function(e,t){return l.map(t,(function(r,i){return t[i]-e[i]}))},snapCoord:function(e,t){return l.map(e,(function(e,r){return ce.roundToNearest(t[r],e)}))},findAngle:function(e,t,r){if(void 0===r){var i=e[0]-t[0],n=e[1]-t[1];return i||n?(180+180*Math.atan2(-n,-i)/Math.PI+360)%360:0}return xr.findAngle(e,r)-xr.findAngle(t,r)},graphs:{}},Cr=xr.Graphie=function(){};l.extend(Cr.prototype,{cartToPolar:function(e,t){var r=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)),i=Math.atan2(e[1],e[0]);return i<0&&(i+=2*Math.PI),t||(i=180*i/Math.PI),[r,i]},polar:yr});var wr={center:[-.5,-.5],above:[-.5,-1],"above right":[0,-1],right:[0,-.5],"below right":[0,0],below:[-.5,0],"below left":[-1,0],left:[-1,-.5],"above left":[-1,-1]},kr={"stroke-width":null};xr.createGraphie=function(e){var t,r,i=40,n=40;f(e).css("position","relative");var s=cr.exports(e);f(e).children("div").css("position","absolute");var o={"stroke-width":2,fill:"none"},a=function e(t){if("number"==typeof t)return e([t,t]);var r=t[0],s=t[1];return[r*i,s*n]},p=function e(s){if("number"==typeof s)return e([s,s]);var o=s[0],a=s[1];return[(o-t[0])*i,(r[1]-a)*n]},h=function(e,t){var r=f(e),i=r.data("labelDirection"),[n,s]=t;if(0===n&&0===s&&([n,s]=[1,1],pe.log("Label size was 0x0 in graphie.js; using 1x1 instead")),r.css("visibility",""),"number"==typeof i){var o=Math.cos(i),a=Math.sin(i),l=Math.min(n/2/Math.abs(o),s/2/Math.abs(a));r.css({marginLeft:-n/2+o*l,marginTop:-s/2-a*l})}else{var p=wr[i||"center"];r.css({marginLeft:Math.round(n*p[0]),marginTop:Math.round(s*p[1])})}},c=function(e,t){return f.map(e,(function(e,r){if(!0===e)return"z";var i=t?e:p(e);return(0===r?"M":"L")+ce.bound(i[0])+" "+ce.bound(i[1])})).join("")},d=function(e,r,i){var n=function(t){return(e*t+r)*t+i};if(0===e){var s=l.map(t,(function(e){return[e,n(e)]}));return c(s)}var o=-r/(2*e),a=o+Math.max(Math.abs(o-t[0]),Math.abs(o-t[1])),h=[o,n(o)],d=[a,n(a)],u=[h[0],h[1]-(d[1]-h[1])],m=Math.abs(h[0]-d[0]),g=[h[0]-m,d[1]],f=[h[0]+m,d[1]],v=l.map([g,u,f],p),b=l.map(l.flatten(v),ce.bound);return"M"+b[0]+","+b[1]+" Q"+b[2]+","+b[3]+" "+b[4]+","+b[5]},u=function(e,r,i,n){for(var s=Math.abs(Math.PI/(2*r)),o=function(t){return e*Math.sin(r*t-i)+n},a=function(t){return e*r*Math.cos(i-r*t)},h=function(e,t){var r=e+s*t,i=r+s,n=[r,2*r/3+1*i/3,1*r/3+2*i/3,i],h=[o(r),o(r)+a(r)*(i-r)/3,o(i)-a(i)*(i-r)/3,o(i)];return l.map(l.zip(n,h),p)},c=t[1]-t[0],d=Math.ceil(c/s)+1,u=i/r,m=u-t[0],g=h(u-=s*Math.ceil(m/s),0),f="M"+g[0][0]+","+g[0][1]+" C"+g[1][0]+","+g[1][1]+" "+g[2][0]+","+g[2][1]+" "+g[3][0]+","+g[3][1],v=1;v<d;v++)f+=" C"+(g=h(u,v))[1][0]+","+g[1][1]+" "+g[2][0]+","+g[2][1]+" "+g[3][0]+","+g[3][1];return f};xr.svgPath=c;var m=function(e){var o={scale:function(e){"number"==typeof e&&(e=[e,e]),i=e[0],n=e[1],s.setSize((t[1]-t[0])*i,(r[1]-r[0])*n)},clipRect:function(e){var t=e[0],r=e[1];return t[1]+=r[1],{"clip-rect":p(t).concat(a(r)).join(" ")}},strokeWidth:function(e){return{"stroke-width":parseFloat(e)}},rx:function(e){return{rx:a([e,0])[0]}},ry:function(e){return{ry:a([0,e])[1]}},r:function(e){var t=a([e,e]);return{rx:t[0],ry:t[1]}}},l={};return f.each(e||{},(function(e,t){var r=o[e];if("function"==typeof r)f.extend(l,r(t));else{var i=e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase();l[i]=t}})),l},g=function e(t){var r=t.constructor.prototype;if(r===cr.exports.el){if("path"===t.type&&void 0===t.arrowheadsDrawn){var i=.6+.4*t.attr("stroke-width"),n=t.getTotalLength(),o=s.set(),a=s.path(b.isMobile?"M-4,4 C-4,4 -0.25,0 -0.25,0 C-0.25,0 -4,-4 -4,-4":"M-3 4 C-2.75 2.5 0 0.25 0.75 0C0 -0.25 -2.75 -2.5 -3 -4"),l=t.getPointAtLength(n-.4),p=t.getPointAtLength(n-.75*i),h=180*Math.atan2(l.y-p.y,l.x-p.x)/Math.PI,c=t.attr();delete c.path;var d=t.getSubpath(0,n-.75*i);return(d=s.path(d).attr(c)).arrowheadsDrawn=!0,t.remove(),a.rotate(h,b.isMobile?1e-5:.75,0).scale(i,i,.75,0).translate(p.x,p.y).attr(c).attr({"stroke-linejoin":"round","stroke-linecap":"round"}),a.arrowheadsDrawn=!0,o.push(d),o.push(a),o}}else if(r===cr.exports.st)for(var u=0,m=t.items.length;u<m;u++)e(t.items[u]);return t},v={circle:function(e,t){return s.ellipse(...p(e).concat(a([t,t])))},rect:function(e,t,r,i){var n=p([e,t+i]),o=a([r,i]),l=s.rect(...n.concat(o));return b.isMobile&&(l.node.style.shapeRendering="crispEdges"),l},ellipse:function(e,t){return s.ellipse(...p(e).concat(a(t)))},fixedEllipse:function(e,t,r,i){var n=p(e),s=a(t),o=2*s[0]*r+i,l=2*s[1]*r+i,h=n[0]-o/2,c=n[1]-l/2,d=document.createElement("div");return f(d).css({position:"absolute",width:o+"px",height:l+"px",left:h+"px",top:c+"px"}),{wrapper:d,visibleShape:cr.exports(d,o,l).ellipse(o/2,l/2,s[0],s[1])}},arc:function(e,t,r,i,n){r=(r%360+360)%360,i=(i%360+360)%360;var o=p(e),l=a(t),h=yr(t,r),c=yr(t,i),d=p([e[0]+h[0],e[1]+h[1]]),u=p([e[0]+c[0],e[1]+c[1]]),m=((i-r)%360+360)%360>180;return s.path("M"+d.join(" ")+"A"+l.join(" ")+" 0 "+(m?1:0)+" 0 "+u.join(" ")+(n?"L"+o.join(" ")+"z":""))},path:function(e){var t=s.path(c(e));return t.graphiePath=e,t},fixedPath:function(e,t,r){e=l.map(e,p),t=t?p(t):null,r=r||c;var i=l.min(l.pluck(e,0)),n=l.max(l.pluck(e,0)),s=l.min(l.pluck(e,1)),o=l.max(l.pluck(e,1)),a=[4,4],h=[i,s];e=l.map(e,(function(e){return y.add(y.subtract(e,h),y.scale(a,.5))}));var d=n-i+a[0],u=o-s+a[1],m=h[0]-a[0]/2,g=h[1]-a[1]/2,v=document.createElement("div");return f(v).css({position:"absolute",width:d+"px",height:u+"px",left:m+"px",top:g+"px",transformOrigin:t?d/2+t[0]+"px "+(u/2+t[1])+"px":null}),{wrapper:v,visibleShape:cr.exports(v,d,u).path(r(e))}},scaledPath:function(e){var t=s.path(c(e,!0));return t.graphiePath=e,t},line:function(e,t){var r=this.path([e,t]);return b.isMobile&&(r.node.style.shapeRendering="crispEdges"),r},parabola:function(e,t,r){return s.path(d(e,t,r))},fixedLine:function(e,t,r){var i=[r,r];e=p(e),t=p(t);var n=[Math.min(e[0],t[0]),Math.min(e[1],t[1])];e=y.add(y.subtract(e,n),y.scale(i,.5)),t=y.add(y.subtract(t,n),y.scale(i,.5));var s=n[0]-i[0]/2,o=n[1]-i[1]/2,a=Math.abs(e[0]-t[0])+i[0],l=Math.abs(e[1]-t[1])+i[1],h=document.createElement("div");f(h).css({position:"absolute",width:a+"px",height:l+"px",left:s+"px",top:o+"px",transformOrigin:e[0]+"px "+e[1]+"px"});var c=cr.exports(h,a,l),d="M"+e[0]+" "+e[1]+" L"+t[0]+" "+t[1],u=c.path(d);return u.graphiePath=[e,t],{wrapper:h,visibleShape:u}},sinusoid:function(e,t,r,i){return s.path(u(e,t,r,i))},grid:function(e,t){for(var r=o.step||[1,1],i=s.set(),n=r[0]*Math.ceil(e[0]/r[0]);n<=e[1];n+=r[0])i.push(this.line([n,t[0]],[n,t[1]]));for(var a=r[1]*Math.ceil(t[0]/r[1]);a<=t[1];a+=r[1])i.push(this.line([e[0],a],[e[1],a]));return i},label:function(t,r,i,n){n=void 0===n||n;var s=f("<span>").addClass("graphie-label"),a=o["label-distance"];s.css(f.extend({},{position:"absolute",padding:(null!=a?a:7)+"px",color:"black"})).data("labelDirection",i).appendTo(e),s.setPosition=function(e){var t=p(e);s.css({left:t[0],top:t[1]})},s.setPosition(t);var l=s[0];return s.processMath=function(e,t){br(l,e,t,(function(){var e=l.scrollWidth,t=l.scrollHeight;h(l,[e,t])}))},s.processText=function(e){s.html(e);var t=l.scrollWidth,r=l.scrollHeight;h(l,[t,r])},n?s.processMath(r,!1):s.processText(r),s},plotParametric:function(e,t,r,i){i=i||function(e){return[e,0]};var a=e=>Math.abs(e[1])>5e5?[e[0],Math.min(Math.max(e[1],-5e5),5e5)]:e,l=t=>a(e(t)),p=e=>a(i(e));o.strokeLinejoin||(o.strokeLinejoin="round"),o.strokeLinecap||(o.strokeLinecap="round");var h=t[0],c=t[1],d=(c-h)/(o["plot-points"]||800);0===d&&(d=1);for(var u=s.set(),m=[],g=xr.coordDiff(l(h),p(h)),f=h,v=h;v<=c;v+=d){var b=l(v),y=p(v),x=xr.coordDiff(b,y);if(x[1]<0!=g[1]<0&&Math.abs(x[1]-g[1])>2*n||isNaN(x[1])){if(r){m.push(b);for(var C=v-d;C>=f;C-=d)m.push(p(C));f=v}u.push(this.path(m)),m=[],r&&m.push(b)}else m.push(b);g=x}if(r)for(var w=c-d;w>=f;w-=d)m.push(p(w));return u.push(this.path(m)),u},plotPolar:function(e,t){var r=t[0],n=t[1];return o["plot-points"]||(o["plot-points"]=2*(n-r)*i),this.plotParametric((function(t){return yr(e(t),180*t/Math.PI)}),t)},plot:function(e,t,r,n,s){var a=t[0],l=t[1];if(o["plot-points"]||(o["plot-points"]=2*(l-a)*i),r){if(s)throw new he("Can't shade area between functions with swapped axes.",le.Internal);return this.plotParametric((function(t){return[e(t),t]}),t,n)}if(s){if(n)return this.plotParametric((function(t){return[t,e(t)]}),t,n,(function(e){return[e,s(e)]}));throw new he("fn2 should only be set when 'shade' is True.",le.Internal)}return this.plotParametric((function(t){return[t,e(t)]}),t,n)},plotPiecewise:function(e,t){var r=s.set(),i=this;return l.times(e.length,(function(n){var s=e[n],o=t[n],a=i.plotParametric((function(e){return[e,s(e)]}),o);l.each(a,(function(e){r.push(e)}))})),r},plotEndpointCircles:function(e){var t=s.set(),r=this;return l.each(e,(function(e,i){t.push(r.circle(e,.15))})),t},plotAsymptotes:function(e,t){for(var r=t[0],i=t[1],a=(i-r)/(o["plot-points"]||800),l=s.set(),p=e(r),h=r;h<=i;h+=a){var c=e(h);c<0!=p<0&&Math.abs(c-p)>2*n&&l.push(this.line([h,n],[h,-n])),p=c}return l}},b=new Cr;return l.extend(b,{raphael:s,init:function(o){var a=o.scale||[40,40];if(i=(a="number"==typeof a?[a,a]:a)[0],n=a[1],null==o.range)throw new he("range should be specified in graph init",le.Internal);t=o.range[0],r=o.range[1];var l=(t[1]-t[0])*i,p=(r[1]-r[0])*n;return s.setSize(l,p),f(e).css({width:l,height:p}),this.range=o.range,this.scale=a,this.dimensions=[l,p],this.xpixels=l,this.ypixels=p,this.isMobile=o.isMobile,this},style:function(e,t){var r=m(e);if("function"==typeof t){var i=o;o=f.extend({},o,r);var n=t.call(b);return o=i,n}f.extend(o,r)},scalePoint:p,scaleVector:a,unscalePoint:function e(s){if("number"==typeof s)return e([s,s]);var o=s[0],a=s[1];return[o/i+t[0],r[1]-a/n]},unscaleVector:function e(t){return"number"==typeof t?e([t,t]):[t[0]/i,t[1]/n]},svgPath:c,svgParabolaPath:d,svgSinusoidPath:u}),f.each(v,(function(e){b[e]=function(){var t,r=arguments[arguments.length-1],i=o;if("object"!=typeof r||l.isArray(r))o=f.extend({},o),t=v[e](...arguments);else{o=U(U({},o),m(r));var n=[].slice.call(arguments,0,arguments.length-1);t=v[e](...n)}var s=t.constructor.prototype;return s===cr.exports.el||s===cr.exports.st?(t.attr(o),o.arrows&&(t=g(t))):t instanceof f&&t.css(U(U({},o),kr)),o=i,t}})),b.graphInit=function(e){e=e||{},f.each(e,(function(t,r){t.match(/.*Opacity$/)||"range"===t||"number"!=typeof r||(e[t]=[r,r]),"range"!==t&&"gridRange"!==t||(r.constructor===Array?r[0].constructor!==Array&&(e[t]=[[-r[0],r[0]],[-r[1],r[1]]]):"number"==typeof r&&(e[t]=[[-r,r],[-r,r]]))}));var t=e.range||[[-10,10],[-10,10]],r=e.gridRange||e.range,i=e.scale||[20,20],n=null==e.grid||e.grid,s=e.gridOpacity||.1,o=e.gridStep||[1,1],a=null==e.axes||e.axes,p=e.axisArrows||"",h=e.axisOpacity||1,c=e.axisCenter||[Math.min(Math.max(t[0][0],0),t[0][1]),Math.min(Math.max(t[1][0],0),t[1][1])],d=null!=e.axisLabels&&e.axisLabels,u=null==e.ticks||e.ticks,m=e.tickStep||[2,2],g=e.tickLen||[5,5],v=e.tickOpacity||1,b=e.labels||e.labelStep||!1,y=e.labelStep||[1,1],x=e.labelOpacity||1,C=e.unityLabels||!1,w=e.labelFormat||function(e){return e},k=e.xLabelFormat||w,E=e.yLabelFormat||w,S=null==e.smartLabelPositioning||e.smartLabelPositioning,_=[[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)]];if(l.isArray(C)||(C=[C,C]),S){var M=function(e){return function(t){return(e(t)+"").replace(/-(\d)/g,"\\llap{-}$1")}};k=M(k),E=M(E)}if(this.init({range:_,scale:i,isMobile:e.isMobile}),n&&this.grid(r[0],r[1],{stroke:e.isMobile?dr.GRAY_C:"#000000",opacity:e.isMobile?1:s,step:o,strokeWidth:e.isMobile?1:2}),a&&("<->"===p||!0===p?this.style({stroke:e.isMobile?dr.GRAY_G:"#000000",opacity:e.isMobile?1:h,strokeWidth:e.isMobile?1:2,arrows:"->"},(function(){t[1][0]<0&&t[1][1]>0&&(this.path([c,[r[0][0],c[1]]]),this.path([c,[r[0][1],c[1]]])),t[0][0]<0&&t[0][1]>0&&(this.path([c,[c[0],r[1][0]]]),this.path([c,[c[0],r[1][1]]]))})):"->"!==p&&""!==p||this.style({stroke:"#000000",opacity:h,strokeWidth:2,arrows:p},(function(){this.path([[r[0][0],c[1]],[r[0][1],c[1]]]),this.path([[c[0],r[1][0]],[c[0],r[1][1]]])})),d&&2===d.length&&(this.label([r[0][1],c[1]],d[0],"right"),this.label([c[0],r[1][1]],d[1],"above"))),u){var T=e.isMobile;this.style({stroke:e.isMobile?dr.GRAY_G:"#000000",opacity:e.isMobile?1:v,strokeWidth:1},(function(){var e=o[0]*m[0],n=g[0]/i[1],s=r[0][0],a=r[0][1];if(t[1][0]<0&&t[1][1]>0){for(var l=e+c[0];l<=a;l+=e)(l<a||!p)&&this.line([l,-n+c[1]],[l,T?0:n+c[1]]);for(var h=-e+c[0];h>=s;h-=e)(h>s||!p)&&this.line([h,-n+c[1]],[h,T?0:n+c[1]])}if(e=o[1]*m[1],n=g[1]/i[0],s=r[1][0],a=r[1][1],t[0][0]<0&&t[0][1]>0){for(var d=e+c[1];d<=a;d+=e)(d<a||!p)&&this.line([-n+c[0],d],[T?0:n+c[0],d]);for(var u=-e+c[1];u>=s;u-=e)(u>s||!p)&&this.line([-n+c[0],u],[T?0:n+c[0],u])}}))}b&&this.style({stroke:e.isMobile?dr.GRAY_G:"#000000",opacity:e.isMobile?1:x},(function(){for(var e=o[0]*m[0]*y[0],t=r[0][0],i=r[0][1],n=c[0]<0?"above":"below",s=c[0]<0?"right":"left",a=0===c[0]&&0!==c[1],l=0!==c[0]&&0===c[1],h=0!==c[0]||0!==c[1],d=C[0]||h,u=C[1]||h,g=(a?0:e)+c[0];g<=i;g+=e)(g<i||!p)&&this.label([g,c[1]],k(g),n);for(var f=-e*(d?1:2)+c[0];f>=t;f-=e)(f>t||!p)&&this.label([f,c[1]],k(f),n);e=o[1]*m[1]*y[1],t=r[1][0],i=r[1][1];for(var v=(l?0:e)+c[1];v<=i;v+=e)(v<i||!p)&&this.label([c[0],v],E(v),s);for(var b=-e*(u?1:2)+c[1];b>=t;b-=e)(b>t||!p)&&this.label([c[0],b],E(b),s)}))},b},function(e,t,r,i){if(void 0!==e){var n="virtualMouseBindings",s="virtualTouchID",o="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),a="clientX clientY pageX pageY screenX screenY".split(" "),l=e.event.mouseHooks?e.event.mouseHooks.props:[],p=e.event.props.concat(l),h={},c=0,d=0,u=0,m=!1,g=[],f=!1,v=!1,b="addEventListener"in r,y=e(r),x=1,C=0;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var w=0;w<o.length;w++)e.event.special[o[w]]=L(o[w]);b&&r.addEventListener("click",(function(t){var r,i,n,o,a,l=g.length,p=t.target;if(l)for(r=t.clientX,i=t.clientY,threshold=e.vmouse.clickDistanceThreshold,n=p;n;){for(o=0;o<l;o++)if(a=g[o],n===p&&Math.abs(a.x-r)<threshold&&Math.abs(a.y-i)<threshold||e.data(n,s)===a.touchID)return t.preventDefault(),void t.stopPropagation();n=n.parentNode}}),!0)}function k(e){for(;e&&void 0!==e.originalEvent;)e=e.originalEvent;return e}function E(t){for(var r,i,s={};t;){for(i in r=e.data(t,n))r[i]&&(s[i]=s.hasVirtualBinding=!0);t=t.parentNode}return s}function S(){v=!0}function _(){v=!1}function M(){T(),c=setTimeout((function(){c=0,C=0,g.length=0,f=!1,S()}),e.vmouse.resetTimerDuration)}function T(){c&&(clearTimeout(c),c=0)}function I(t,r,i){var s;return(i&&i[t]||!i&&function(t,r){for(var i;t;){if((i=e.data(t,n))&&(!r||i[r]))return t;t=t.parentNode}return null}(r.target,t))&&(s=function(t,r){var i,n,s,o,l,h,c,d,u,m=t.type;if((t=e.Event(t)).type=r,i=t.originalEvent,n=e.event.props,m.search(/mouse/)>-1&&(n=p),i)for(c=n.length;c;)t[o=n[--c]]=i[o];if(m.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1),-1!==m.search(/^touch/)&&(m=(s=k(i)).touches,l=s.changedTouches,h=m&&m.length?m[0]:l&&l.length?l[0]:void 0))for(d=0,u=a.length;d<u;d++)t[o=a[d]]=h[o];return t}(r,t),e(r.target).trigger(s)),s}function P(t){var r=e.data(t.target,s);if(!(f||C&&C===r)){var i=I("v"+t.type,t);i&&(i.isDefaultPrevented()&&t.preventDefault(),i.isPropagationStopped()&&t.stopPropagation(),i.isImmediatePropagationStopped()&&t.stopImmediatePropagation())}}function A(t){var r,i,n=k(t).touches;if(n&&1===n.length&&(i=E(r=t.target)).hasVirtualBinding){C=x++,e.data(r,s,C),T(),_(),m=!1;var o=k(t).touches[0];d=o.pageX,u=o.pageY,I("vmouseover",t,i),I("vmousedown",t,i)}}function N(e){v||(m||I("vmousecancel",e,E(e.target)),m=!0,M())}function R(t){if(!v){var r=k(t).touches[0],i=s,n=e.vmouse.moveDistanceThreshold,s=s||Math.abs(r.pageX-d)>n||Math.abs(r.pageY-u)>n,o=E(t.target);s&&!i&&I("vmousecancel",t,o),I("vmousemove",t,o),M()}}function F(e){if(!v){S();var t,r=E(e.target);if(I("vmouseup",e,r),!m){var i=I("vclick",e,r);i&&i.isDefaultPrevented()&&(t=k(e).changedTouches[0],g.push({touchID:C,x:t.clientX,y:t.clientY}),f=!0)}I("vmouseout",e,r),m=!1,M()}}function D(t){var r,i=e.data(t,n);if(i)for(r in i)if(i[r])return!0;return!1}function O(){}function L(t){var r=t.substr(1);return{setup:function(i,s){D(this)||e.data(this,n,{}),e.data(this,n)[t]=!0,h[t]=(h[t]||0)+1,1===h[t]&&y.bind(r,P),e(this).bind(r,O),b&&(h.touchstart=(h.touchstart||0)+1,1===h.touchstart&&y.bind("touchstart",A).bind("touchend",F).bind("touchmove",R).bind("scroll",N))},teardown:function(i,s){--h[t],h[t]||y.unbind(r,P),b&&(--h.touchstart,h.touchstart||y.unbind("touchstart",A).unbind("touchmove",R).unbind("touchend",F).unbind("scroll",N));var o=e(this),a=e.data(this,n);a&&(a[t]=!1),o.unbind(r,O),D(this)||o.removeData(n)}}}}(window.jQuery,window,document);var Er={pluck:function(e,t){return l.object(l.map(e,(function(e,r){return[r,e[t]]})))},mapObject:function(e,t){var r={};return l.each(l.keys(e),(function(i){r[i]=t(e[i],i)})),r},mapObjectFromArray:function(e,t){var r={};return l.each(e,(function(e){r[e]=t(e)})),r}},Sr=l.extend({transform:function(e){var t=pr.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(),f(this.wrapper).remove()},getMouseTarget:function(){return this.visibleShape[0]},moveTo:function(e){var t=y.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),r=pr.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()}},Er.mapObjectFromArray(["attr","animate"],(function(e){return function(){this.visibleShape[e](...arguments)}}))),_r={maxScale:1,mouselayer:!1,shadow:!1,disableMouseEventsOnWrapper:!1},Mr=function(e,t,r,i){i=l.extend({},_r,i);var n=e.fixedEllipse(t,r,i.maxScale,i.padding);if(l.extend(this,n,{graphie:e,initialPoint:t}),i.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",i.interactiveKindForTesting),i.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),i.shadow){var s="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))",o=this.wrapper;o.style.webkitFilter=s,o.style.filter=s,this.moveTo=function(e){var t=y.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),r=pr.getCanUse3dTransform(),i="translateX("+Math.round(t[0])+"px) translateY("+Math.round(t[1])+"px)"+(r?" translateZ(0)":"");this.transform(i)}}i.disableMouseEventsOnWrapper&&(this.wrapper.style.pointerEvents="none",this.visibleShape.node.style.pointerEvents="auto")};l.extend(Mr.prototype,Sr);var Tr={thickness:2,mouselayer:!1},Ir=function(e,t,r,i){i=l.extend({},Tr,i);var n=[e.range[0][0],0],s=[e.range[0][1],0];l.extend(this,e.fixedLine(n,s,i.thickness)),i.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",i.interactiveKindForTesting),this.visibleShape.attr(i.normalStyle),l.extend(this,{graphie:e,initialPoint:e.scalePoint(n),initialLength:b.distanceToPoint(e.scalePoint(n),e.scalePoint(s))}),i.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),this.moveTo(t,r)};l.extend(Ir.prototype,Sr,{getMouseTarget:function(){return this.wrapper},moveTo:function(e,t){var r=this.graphie.scalePoint(e),i=this.graphie.scalePoint(t),n=y.polarDegFromCart(y.subtract(i,r)),s=n[0],o=ce.bound(n[1]),a=y.subtract(r,this.initialPoint),l=ce.bound(s/this.initialLength),p=pr.getCanUse3dTransform(),h="translateX("+a[0]+"px) translateY("+a[1]+"px) "+(p?" translateZ(0)":"")+"rotate("+o+"deg) scaleX("+l+") scaleY(1)";this.transform(h)}});var Pr={center:null,createPath:null,mouselayer:!1},Ar=function(e,t,r){r=l.extend({},Pr,r),l.extend(this,e.fixedPath(t,r.center,r.createPath)),l.extend(this,{graphie:e,initialPoint:e.scalePoint(l.head(t))}),r.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper)};l.extend(Ar.prototype,Sr);var{getCanUse3dTransform:Nr}=pr;function Rr(e){return l.reduce(e,(function(e,t){return e+t}),0)}function Fr(){var e=l.zip(...arguments);return l.map(e,Rr)}function Dr(e){return l.map(e,(function(e){return-1*e}))}function Or(e){var t=11.374597405497571;return 58.919514629750836*Math.exp(-.037587715462826674*e)+t}function Lr(e,t){return[e*Math.cos(t),e*Math.sin(t)*-1]}function Br(e,t){return Lr(e,t*Math.PI/180)}var zr=!1,qr={animate:function(){},attr:function(){},remove:function(){}};function Hr(e,t){this.set=e.raphael.set(),this.cx=t[0],this.cy=t[1];var r=this,i=e.unscaleVector(180.5)[0],n=e.scalePoint([this.cx-i,this.cy+i-e.unscaleVector(10.5)[1]]),s=e.mouselayer.image("https://ka-perseus-graphie.s3.amazonaws.com/e9d032f2ab8b95979f674fbfa67056442ba1ff6a.png",n[0],n[1],360,180);this.set.push(s),s.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});var o=function(r,n){var s=e.scaleVector(i);s[0]-=16,s[1]-=16;var o=e.scalePoint(t);return Math.sin((r+90)*Math.PI/180)*(s[0]+n)+o[0]+","+(Math.cos((r+90)*Math.PI/180)*(s[1]+n)+o[1])},a=e.raphael.path(" M"+o(180,6)+" L"+o(180,2)+" L"+o(183,10)+" L"+o(180,18)+" L"+o(180,14)+" A"+(e.scaleVector(i)[0]+10)+","+(e.scaleVector(i)[1]+10)+",0,0,1,"+o(170,14)+" L"+o(170,18)+" L"+o(167,10)+" L"+o(170,2)+" L"+o(170,6)+" A"+(e.scaleVector(i)[0]+10)+","+(e.scaleVector(i)[1]+10)+",0,0,0,"+o(180,6)+" Z").attr({stroke:null,fill:dr.INTERACTIVE});this.set.push(a),this.centerPoint=e.addMovablePoint({coord:t,visible:!1}),this.rotateHandle=e.addMovablePoint({bounded:!1,coord:[Math.sin(275*Math.PI/180)*i+this.cx,Math.cos(275*Math.PI/180)*i+this.cy],onMove:function(e,t){var i=180*Math.atan2(r.centerPoint.coord[1]-t,r.centerPoint.coord[0]-e)/Math.PI;r.rotate(-i-5,!0)}}),this.rotateHandle.constraints.fixedDistance.dist=i,this.rotateHandle.constraints.fixedDistance.point=this.centerPoint,this.rotateHandle.visibleShape.remove(),this.rotateHandle.mouseTarget.attr({scale:2});var l=!1,p=!1,h=function(){return p||l},c=f(this.rotateHandle.mouseTarget.getMouseTarget());c.bind("vmousedown",(function(e){l=!0,c.css("cursor","-webkit-grabbing"),c.css("cursor","grabbing"),a.animate({scale:1.5,fill:dr.INTERACTING},50),f(document).bind("vmouseup.rotateHandle",(function(e){l=!1,c.css("cursor","-webkit-grab"),c.css("cursor","grab"),h()||a.animate({scale:1,fill:dr.INTERACTIVE},50),f(document).unbind("vmouseup.rotateHandle")}))})),c.bind("vmouseover",(function(e){p=!0,a.animate({scale:1.5,fill:dr.INTERACTING},50)})),c.bind("vmouseout",(function(e){p=!1,h()||a.animate({scale:1,fill:dr.INTERACTIVE},50)}));var d=f.map(this.set,(function(e){return e.node}));return this.makeTranslatable=function(){f(d).css("cursor","move"),c.css("cursor","-webkit-grab"),c.css("cursor","grab"),f(d).bind("vmousedown",(function(t){t.preventDefault();var i=t.pageX-f(e.raphael.canvas.parentNode).offset().left,n=t.pageY-f(e.raphael.canvas.parentNode).offset().top;f(document).bind("vmousemove.protractor",(function(t){var s=t.pageX-f(e.raphael.canvas.parentNode).offset().left,o=t.pageY-f(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 a=s-i,l=o-n;f.each(r.set.items,(function(){this.translate(a,l)})),r.centerPoint.setCoord([r.centerPoint.coord[0]+a/e.scale[0],r.centerPoint.coord[1]-l/e.scale[1]]),r.rotateHandle.setCoord([r.rotateHandle.coord[0]+a/e.scale[0],r.rotateHandle.coord[1]-l/e.scale[1]]),i=s,n=o})),f(document).one("vmouseup",(function(e){f(document).unbind("vmousemove.protractor")}))}))},this.rotation=0,this.rotate=function(t,r){var i=e.scalePoint(this.centerPoint.coord);return r&&(this.rotation=0),this.set.rotate(this.rotation+t,i[0],i[1]),this.rotation=this.rotation+t,this},this.moveTo=function(t,i){var n=e.scalePoint(r.centerPoint.coord),s=e.scalePoint([t,i]),o=2*xr.getDistance(n,s);f({x:n[0],y:n[1]}).animate({x:s[0],y:s[1]},{duration:o,step:function(t,i){var n=0,s=0;"x"===i.prop?n=t-e.scalePoint(r.centerPoint.coord)[0]:"y"===i.prop&&(s=t-e.scalePoint(r.centerPoint.coord)[1]),f.each(r.set.items,(function(){this.translate(n,s)})),r.centerPoint.setCoord([r.centerPoint.coord[0]+n/e.scale[0],r.centerPoint.coord[1]-s/e.scale[1]]),r.rotateHandle.setCoord([r.rotateHandle.coord[0]+n/e.scale[0],r.rotateHandle.coord[1]-s/e.scale[1]])}})},this.rotateTo=function(e){Math.abs(this.rotation-e)>180&&(this.rotation+=360);var t=5*Math.abs(this.rotation-e);f({0:this.rotation}).animate({0:e},{duration:t,step:function(e,t){r.rotate(e,!0),r.rotateHandle.setCoord([Math.sin((e+275)*Math.PI/180)*i+r.centerPoint.coord[0],Math.cos((e+275)*Math.PI/180)*i+r.centerPoint.coord[1]])}})},this.remove=function(){this.set.remove()},this.makeTranslatable(),this}function Wr(e,t){l.defaults(t,{center:[0,0],pixelsPerUnit:40,ticksPerUnit:10,units:10,label:"",style:{fill:null,stroke:dr.GRAY}});var r,i=l.extend({},t.style,{strokeWidth:1}),n=l.extend({},t.style,{strokeWidth:2}),s=t.units*t.pixelsPerUnit,o=e.unscalePoint(y.subtract(e.scalePoint(t.center),y.scale([s,-50],.5))),a=t.pixelsPerUnit/e.scale[0],p=50/e.scale[0],h=y.add(o,[t.units*a,p]);if(10===t.ticksPerUnit)r={10:1,5:.55,1:.35};else{var c=[1,.6,.45,.3];r={};for(var d=t.ticksPerUnit;d>=1;d/=2)r[d]=1*(c.shift()||.2)}var u=l.keys(r).sort((function(e,t){return t-e}));var m=o[0],g=o[1],v=h[0],b=h[1],x=t.units*t.ticksPerUnit+1,C=e.raphael.set(),w=1/e.scale[0];C.push(e.line([m-w,g],[v+w,g],n)),C.push(e.line([m-w,b],[v+w,b],n)),l.times(x,(function(s){var o=s/t.ticksPerUnit,l=m+o*a,h=function(e){for(var t=0;t<u.length;t++){var i=u[t];if(e%i==0)return r[i]}return 0}(s)*p,c=0===s||s===x-1?n:i;if(C.push(e.line([l,g],[l,g+h],c)),o%1==0){var d,f,v=e.scalePoint([l,b]);0===o?f={mm:13,cm:11,m:8,km:11,in:8,ft:8,yd:10,mi:10}[d=t.label]||3*d.toString().length:(d=o,f=-3*(o.toString().length+1));var y=e.raphael.text(v[0]+f,v[1]+10,d);y.attr({"font-family":"KaTeX_Main","font-size":"12px",color:"#444"}),C.push(y)}}));var k=e.mouselayer.path(xr.svgPath([o,[m,b],h,[v,g],!0]));k.attr({fill:"#000",opacity:0,stroke:"#000","stroke-width":2}),C.push(k),k.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});var E=f.map(C,(function(e){return e.node}));f(E).css("cursor","move"),f(E).bind("vmousedown",(function(t){t.preventDefault();var r=t.pageX-f(e.raphael.canvas.parentNode).offset().left,i=t.pageY-f(e.raphael.canvas.parentNode).offset().top;f(document).bind("vmousemove.ruler",(function(t){var n=t.pageX-f(e.raphael.canvas.parentNode).offset().left,s=t.pageY-f(e.raphael.canvas.parentNode).offset().top;n=Math.max(10,Math.min(e.xpixels-10,n)),s=Math.max(10,Math.min(e.ypixels-10,s));var o=n-r,a=s-i;C.translate(o,a),S.setCoord([S.coord[0]+o/e.scale[0],S.coord[1]-a/e.scale[1]]),_.setCoord([_.coord[0]+o/e.scale[0],_.coord[1]-a/e.scale[1]]),r=n,i=s})),f(document).one("vmouseup",(function(e){f(document).unbind("vmousemove.ruler")}))}));var S=e.addMovablePoint({coord:o,normalStyle:{fill:dr.INTERACTIVE,"fill-opacity":0,stroke:dr.INTERACTIVE},highlightStyle:{fill:dr.INTERACTING,"fill-opacity":.1,stroke:dr.INTERACTING},pointSize:6,onMove:function(t,r){var i=_.coord[1]-r,n=_.coord[0]-t,s=180*Math.atan2(i,n)/Math.PI,o=y.scale(y.add([t,r],_.coord),.5),a=e.scalePoint(o),l=y.scale(y.add(S.coord,_.coord),.5),p=e.scalePoint(l),h=y.subtract(a,p);C.rotate(-s,p[0],p[1]),C.translate(h[0],h[1])}}),_=e.addMovablePoint({coord:[v,g],normalStyle:{fill:dr.INTERACTIVE,"fill-opacity":0,stroke:dr.INTERACTIVE},highlightStyle:{fill:dr.INTERACTING,"fill-opacity":.1,stroke:dr.INTERACTING},pointSize:6,onMove:function(t,r){var i=r-S.coord[1],n=t-S.coord[0],s=180*Math.atan2(i,n)/Math.PI,o=y.scale(y.add([t,r],S.coord),.5),a=e.scalePoint(o),l=y.scale(y.add(S.coord,_.coord),.5),p=e.scalePoint(l),h=y.subtract(a,p);C.rotate(-s,p[0],p[1]),C.translate(h[0],h[1])}});return S.constraints.fixedDistance.dist=s/e.scale[0],S.constraints.fixedDistance.point=_,_.constraints.fixedDistance.dist=s/e.scale[0],_.constraints.fixedDistance.point=S,this.remove=function(){C.remove(),S.remove(),_.remove()},this}function Ur(e,t){if(this.graphie=e,l.extend(this,t),l.defaults(this,{normalStyle:{stroke:dr.INTERACTIVE,"stroke-width":2,fill:dr.INTERACTIVE},highlightStyle:{stroke:dr.INTERACTING,"stroke-width":2,fill:dr.INTERACTING},labelStyle:{stroke:dr.DYNAMIC,"stroke-width":1,color:dr.DYNAMIC},angleStyle:{stroke:dr.DYNAMIC,"stroke-width":1,color:dr.DYNAMIC},allowReflex:!0}),!this.points||3!==this.points.length)throw new he("MovableAngle requires 3 points",le.InvalidInput);this.points=l.map(t.points,(function(t){return l.isArray(t)?e.addMovablePoint({coord:t,visible:!1,constraints:{fixed:!0},normalStyle:this.normalStyle}):t}),this),this.coords=l.pluck(this.points,"coord"),null==this.reflex&&(this.allowReflex?this.reflex=this._getClockwiseAngle(this.coords)>180:this.reflex=!1),this.rays=l.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()}l.extend(xr.Graphie.prototype,{addMouseLayer:function(e){var t=this;e=l.extend({allowScratchpad:!1,setDrawingAreaAvailable:function(){}},e);if(t.mouselayer=cr.exports(t.raphael.canvas.parentNode,t.xpixels,t.ypixels),f(t.mouselayer.canvas).css("z-index",2),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;f(t.mouselayer.canvas).on("vmousedown",(function(n){n.target===r[0]&&(e.onMouseDown&&e.onMouseDown(t.getMouseCoord(n)),i=!0,e.onMouseMove&&f(document).bind("vmousemove.mouseLayer",(function(r){i&&(r.preventDefault(),e.onMouseMove(t.getMouseCoord(r)))})),f(document).bind("vmouseup.mouseLayer",(function(r){f(document).unbind(".mouseLayer"),i&&e.onClick&&e.onClick(t.getMouseCoord(r)),i=!1})))})),e.onMouseOver&&f(t.mouselayer.canvas).on("vmouseover",(function(r){e.onMouseOver(t.getMouseCoord(r))})),e.onMouseOut&&f(t.mouselayer.canvas).on("vmouseout",(function(r){e.onMouseOut(t.getMouseCoord(r))}))}e.allowScratchpad||e.setDrawingAreaAvailable(!1),t._mouselayerWrapper=document.createElement("div"),f(t._mouselayerWrapper).css({position:"absolute",left:0,top:0,zIndex:2}),t._visiblelayerWrapper=document.createElement("div"),f(t._visiblelayerWrapper).css({position:"absolute",left:0,top:0});var n=t.raphael.canvas.parentNode;n.appendChild(t._visiblelayerWrapper),n.appendChild(t._mouselayerWrapper),t.addToMouseLayerWrapper=function(e){this._mouselayerWrapper.appendChild(e)},t.addToVisibleLayerWrapper=function(e){this._visiblelayerWrapper.appendChild(e)}},getMousePx:function(e){return[e.pageX-f(this.raphael.canvas.parentNode).offset().left,e.pageY-f(this.raphael.canvas.parentNode).offset().top]},getMouseCoord:function(e){return this.unscalePoint(this.getMousePx(e))},labelAngle:function(e){var t=this;l.defaults(e,{point1:[0,0],vertex:[0,0],point3:[0,0],label:null,numArcs:1,showRightAngleMarker:!0,pushOut:0,clockwise:!1,style:{}});var r,i,n=void 0===e.text?"":e.text,s=e.vertex,o=t.scalePoint(s);e.clockwise?(r=e.point1,i=e.point3):(r=e.point3,i=e.point1);var a=xr.findAngle(r,s),p=xr.findAngle(i,s),h=(p+360-a)%360,c=(a+h/2)%360,d=5*e.pushOut+Or(h),u=[];if(Math.abs(h-90)<1e-9&&e.showRightAngleMarker){var m=Fr(o,Br(d,a)),g=Fr(o,Br(d,p)),f=Fr(o,Br(d*=Math.SQRT2,c));l.each([m,g],(function(r){u.push(t.scaledPath([r,f],e.style))}))}else l.times(e.numArcs,(function(r){u.push(t.arc(s,t.unscaleVector(d),a,p,e.style)),d+=3}));if(n){var v=n.match(/\$deg(\d)?/);if(v){var b=v[1]||1;n=n.replace(v[0],ce.toFixedApprox(h,b)+"^{\\circ}")}var y=Fr(o,Br(d+15,c)),x=t.unscalePoint(y);e.label?(e.label.setPosition(x),e.label.processMath(n,!0)):t.label(x,n,"center",e.style)}return u},labelSide:function(e){var t,r,i=this;l.defaults(e,{point1:[0,0],point2:[0,0],label:null,text:"",numTicks:0,numArrows:0,clockwise:!1,style:{}}),e.clockwise?(t=e.point1,r=e.point2):(t=e.point2,r=e.point1);var n=[(t[0]+r[0])/2,(t[1]+r[1])/2],s=i.scalePoint(n),o=Math.atan2(r[1]-t[1],r[0]-t[0]),a=o+Math.PI/2,p=[],h=0;if(e.numTicks){var c=e.numTicks,d=l.extend({},e.style,{strokeWidth:2});l.times(c,(function(e){var t=Lr(5*(e-(c-1)/2),o),r=Lr(5,a),n=[Fr(s,t,r),Fr(s,t,Dr(r))];p.push(i.scaledPath(n,d))})),h+=5*(c-1)+15}if(e.numArrows){var u=e.numArrows,m=[t,r].sort((function(e,t){return e[1]===t[1]?e[0]-t[0]:e[1]-t[1]}))[0],g=i.scalePoint(m),f=l.extend({},e.style,{arrows:"->",strokeWidth:2});l.times(u,(function(e){var r=Lr(h+5*e,o);m!==t&&(r=Dr(r));var n=Fr(s,r);p.push(i.scaledPath([g,n],f))}))}var v=e.text;if(v){var b=v.match(/\$len(\d)?/);if(b){var y=xr.getDistance(t,r),x=b[1]||1;v=v.replace(b[0],ce.toFixedApprox(y,x))}var C=Lr(20,a),w=Fr(s,C),k=i.unscalePoint(w);e.label?(e.label.setPosition(k),e.label.processMath(v,!0)):i.label(k,v,"center",e.style)}return p},labelVertex:function(e){var t=this;if(l.defaults(e,{point1:null,vertex:[0,0],point3:null,label:null,text:"",clockwise:!1,style:{}}),e.text){var r,i,n=e.vertex,s=t.scalePoint(n);e.clockwise?(r=e.point1,i=e.point3):(r=e.point3,i=e.point1);var o,a=135;if(r&&i){var p=xr.findAngle(r,n);o=(p+(a=(xr.findAngle(i,n)+360-p)%360)/2+180)%360}else if(r){o=xr.findAngle(n,r)+90}else if(i){o=xr.findAngle(i,n)+90}else o=135;var h=Fr(s,Br(10+Or(360-a),o)),c=t.unscalePoint(h);e.label?(e.label.setPosition(c),e.label.processMath(e.text,!0)):t.label(c,e.text,"center",e.style)}},addMovablePoint:function(e){var t=f.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:dr.INTERACTING,stroke:dr.INTERACTING},labelStyle:{color:dr.INTERACTIVE},vertexLabel:"",mouseTarget:null},e),r=t.constraints.fixed?dr.DYNAMIC:dr.INTERACTIVE;t.normalStyle=l.extend({},{fill:r,stroke:r},e.normalStyle),void 0!==e.coordX&&(t.coord[0]=e.coordX),void 0!==e.coordY&&(t.coord[1]=e.coordY);var i=t.graph,n=function(e){t.visible&&t.bounded&&!t.constraints.fixed&&(e=i.constrainToBounds(e,10));var r=e[0],n=e[1];if(0!==t.snapX&&(r=Math.round(r/t.snapX)*t.snapX),0!==t.snapY&&(n=Math.round(n/t.snapY)*t.snapY),t.constraints.fixedDistance.snapPoints){var s=i.scalePoint(e),o=s[0],a=s[1],l=2*Math.PI/t.constraints.fixedDistance.snapPoints,p=t.constraints.fixedDistance.dist,h=t.constraints.fixedDistance.point,c=(h[0]-i.range[0][0])*i.scale[0],d=(-h[1]+i.range[1][1])*i.scale[1],u=o-c,m=-a+d,g=Math.atan(m/u);u<0&&(g+=Math.PI),g=Math.round(g/l)*l,o=(u=p*Math.cos(g))+c,a=-(m=p*Math.sin(g))+d,r=ce.roundTo(5,o/i.scale[0]+i.range[0][0]),n=ce.roundTo(5,i.range[1][1]-a/i.scale[1])}return t.applyConstraint([r,n])};t.applyConstraint=function(e,r,i){var n=e.slice(),s={};if(i?f.extend(s,{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},r):f.extend(s,this.constraints,r),s.constrainX)n=[this.coord[0],e[1]];else if(s.constrainY)n=[e[0],this.coord[1]];else if("number"==typeof s.fixedAngle.angle&&"number"==typeof s.fixedDistance.dist){var o=s.fixedAngle.vertex.coord||s.fixedAngle.vertex,a=s.fixedAngle.ref.coord||s.fixedAngle.ref,l=s.fixedDistance.point.coord||s.fixedDistance.point,p=(s.fixedAngle.angle+xr.findAngle(a,o))*Math.PI/180,h=s.fixedDistance.dist;n[0]=h*Math.cos(p)+l[0],n[1]=h*Math.sin(p)+l[1]}else if("number"==typeof s.fixedAngle.angle){var c=s.fixedAngle.vertex.coord||s.fixedAngle.vertex,d=s.fixedAngle.ref.coord||s.fixedAngle.ref,u=(s.fixedAngle.angle+xr.findAngle(d,c))*Math.PI/180,m=xr.findAngle(e,c)*Math.PI/180,g=xr.getDistance(e,c)*Math.cos(u-m);g=g<1?1:g,n[0]=g*Math.cos(u)+c[0],n[1]=g*Math.sin(u)+c[1]}else if("number"==typeof s.fixedDistance.dist){var v=s.fixedDistance.point.coord||s.fixedDistance.point,b=xr.findAngle(e,v),y=s.fixedDistance.dist;b=b*Math.PI/180,n[0]=y*Math.cos(b)+v[0],n[1]=y*Math.sin(b)+v[1]}else s.fixed&&(n=t.coord);return n},t.coord=n(t.coord);if(t.visible&&i.style(t.normalStyle,(function(){var e=[t.pointSize/i.scale[0],t.pointSize/i.scale[1]],r={maxScale:2,padding:2};t.visibleShape=new Mr(i,t.coord,e,r),t.visibleShape.attr(l.omit(t.normalStyle,"scale")),t.visibleShape.toFront()})),t.normalStyle.scale=1,t.highlightStyle.scale=2,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(e){e=e||[0,0],f(document).bind("vmousemove.point vmouseup.point",(function(r){r.preventDefault(),t.dragging=!0,zr=!0;var s,o,a=y.add(i.getMouseCoord(r),e),p=(a=n(a))[0],h=a[1];if("vmousemove"===r.type){var c=!0;if(l.isFunction(t.onMove)){var d=t.onMove(p,h);!1===d&&(c=!1),l.isArray(d)&&(p=d[0],h=d[1])}if(s=(p-i.range[0][0])*i.scale[0],o=(-h+i.range[1][1])*i.scale[1],c){var u=i.unscalePoint([s,o]);t.visibleShape.moveTo(u),t.mouseTarget.moveTo(u),t.coord=[p,h],t.updateLineEnds(),f(t).trigger("move")}t.drawLabel()}else if("vmouseup"===r.type){if(f(document).unbind(".point"),t.dragging=!1,zr=!1,l.isFunction(t.onMoveEnd)){var m=t.onMoveEnd(p,h);if(l.isArray(m)){p=m[0],h=m[1],s=(p-i.range[0][0])*i.scale[0],o=(-h+i.range[1][1])*i.scale[1];var g=i.unscalePoint([s,o]);t.visibleShape.moveTo(g),t.mouseTarget.moveTo(g),t.coord=[p,h]}}t.highlight||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight())}}))},t.visible&&!t.constraints.fixed){if(!t.mouseTarget){var s=i.unscaleVector(16);t.mouseTarget=new Mr(i,t.coord,s,{mouselayer:!0,padding:0,disableMouseEventsOnWrapper:!0,interactiveKindForTesting:"movable-point"}),t.mouseTarget.attr({fill:"#000",opacity:0})}var o=f(t.mouseTarget.getMouseTarget());o.css("cursor","move"),o.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)t.highlight=!0,zr||(t.visibleShape.animate(t.highlightStyle,50),t.onHighlight&&t.onHighlight());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||zr||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();var r=t.coord,n=i.getMouseCoord(e),s=!("ontouchstart"in window)?[0,0]:y.subtract(r,n);t.grab(s)}}))}return t.moveTo=function(e,r,i){var n=5*xr.getDistance(this.graph.scalePoint([e,r]),this.graph.scalePoint(this.coord)),s=i&&function(e){t.coord=e,t.updateLineEnds()};this.visibleShape.animateTo([e,r],n,s),this.mouseTarget.animateTo([e,r],n,s),this.coord=[e,r],l.isFunction(this.onMove)&&this.onMove(e,r)},t.updateLineEnds=function(){f(this.lineStarts).each((function(){this.coordA=t.coord,this.transform()})),f(this.lineEnds).each((function(){this.coordZ=t.coord,this.transform()})),f(this.polygonVertices).each((function(){this.transform()}))},t.setCoord=function(e){this.visible&&(this.visibleShape.moveTo(e),null!=this.mouseTarget&&this.mouseTarget.moveTo(e)),this.coord=e.slice()},t.setCoordConstrained=function(e){this.setCoord(n(e))},t.toBack=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toBack(),this.visibleShape.toBack())},t.toFront=function(){this.visible&&(null!=this.mouseTarget&&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},addMovableLineSegment:function(e){var t=f.extend({graph:this,coordA:[0,0],coordZ:[1,1],snapX:0,snapY:0,fixed:!1,ticks:0,normalStyle:{},highlightStyle:{stroke:dr.INTERACTING,"stroke-width":6},labelStyle:{stroke:dr.INTERACTIVE,color:dr.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=t.fixed?dr.DYNAMIC:dr.INTERACTIVE;t.normalStyle=l.extend({},{"stroke-width":2,stroke:r},e.normalStyle),t.arrowStyle=l.extend({},t.normalStyle,{color:t.normalStyle.stroke}),void 0!==e.pointA?(t.coordA=e.pointA.coord,t.pointA.lineStarts.push(t)):void 0!==e.coordA&&(t.coordA=e.coordA.slice()),void 0!==e.pointZ?(t.coordZ=e.pointZ.coord,t.pointZ.lineEnds.push(t)):void 0!==e.coordA&&(t.coordA=t.coordA.slice());var i=t.graph;i.style(t.normalStyle);for(var n=0;n<t.ticks;++n)t.tick[n]=qr;xr.unscaledSvgPath([[0,0],[1,0]]);for(var s=0;s<t.ticks;++s){var o=.5-(t.ticks-1+2*s)/i.scale[0];xr.unscaledSvgPath([[o,-7],[o,7]])}if(e={thickness:Math.max(t.normalStyle["stroke-width"],t.highlightStyle["stroke-width"])},t.visibleLine=new Ir(i,[0,0],[1,0],e),t.visibleLine.attr(t.normalStyle),!t.fixed){t.mouseTarget=new Ir(i,[0,0],[1,0],{thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"}),t.mouseTarget.attr({fill:"#000",opacity:0})}if(t.transform=function(e){e&&("object"==typeof this.pointA&&(this.coordA=this.pointA.coord),"object"==typeof this.pointZ&&(this.coordZ=this.pointZ.coord));var r=function(e,r,i){var n=(e=t.graph).range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),s=e.unscaleVector(y.cartFromPolarDeg(1,i)),o=y.scale(y.normalize(s),n),a=y.add(r,o),l=y.polarDegFromCart(s)[1];return e.constrainToBoundsOnAngle(a,4,l*Math.PI/180)},n=function(e){var t=e.graph.scalePoint(e.coordA),r=e.graph.scalePoint(e.coordZ);return y.polarDegFromCart(y.subtract(r,t))[1]}(this),s=this.coordA,o=this.coordZ;this.extendLine?(s=r(i,s,360-n),o=r(i,o,(540-n)%360)):this.extendRay&&(o=r(i,s,360-n));var a=[this.visibleLine];this.fixed||a.push(this.mouseTarget),l.each(a,(function(e){e.moveTo(s,o)}));var p=function(e,t){var i=[.75,0],n=[[-3,4],[-2.75,2.5],[0,.25],i,[0,-.25],[-2.75,-2.5],[-3,-4]];n=l.map(n,(function(e){var t=y.subtract(e,i),r=y.scale(t,1.4);return y.add(i,r)}));var s=l.map(n,e.unscalePoint),o={center:e.unscalePoint(i),createPath:function(e){for(var t="M"+e[0][0]+" "+e[0][1],r=1;r<e.length;r+=3)t+="C"+e[r][0]+" "+e[r][1]+" "+e[r+1][0]+" "+e[r+1][1]+" "+e[r+2][0]+" "+e[r+2][1];return t}},a=new Ar(e,s,o);return a.attr(l.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),a.toCoordAtAngle=function(t,n){var s=e.scalePoint(r(e,t,n)),o=Nr();a.transform("translateX("+(s[0]+1.4*i[0])+"px) translateY("+(s[1]+1.4*i[1])+"px) "+(o?"translateZ(0) ":"")+"rotate("+(360-ce.bound(n))+"deg)")},a};null==this._arrows&&(this._arrows=[],this.extendLine?(this._arrows.push(p(i,this.normalStyle)),this._arrows.push(p(i,this.normalStyle))):this.extendRay&&this._arrows.push(p(i,this.normalStyle)));var h=[this.coordA,this.coordZ],c=[360-n,(540-n)%360];l.each(this._arrows,(function(e,t){e.toCoordAtAngle(h[t],c[t])})),l.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=l.flatten(this.temp)},t.toBack=function(){t.fixed||t.mouseTarget.toBack(),t.visibleLine.toBack()},t.toFront=function(){t.fixed||t.mouseTarget.toFront(),t.visibleLine.toFront()},t.remove=function(){t.fixed||t.mouseTarget.remove(),t.visibleLine.remove(),t.labeledSide&&t.labeledSide.remove(),t.labeledVertices&&l.invoke(t.labeledVertices,"remove"),t._arrows&&l.invoke(t._arrows,"remove"),t.temp.length&&l.invoke(t.temp,"remove")},t.hide=function(){t.visibleLine.hide(),t.temp.length&&l.invoke(t.temp,"hide"),t._arrows&&l.invoke(t._arrows,"hide")},t.show=function(){t.visibleLine.show(),t.temp.length&&l.invoke(t.temp,"show"),t._arrows&&l.invoke(t._arrows,"show")},t.sideLabel&&(t.labeledSide=this.label([0,0],"","center",t.labelStyle)),t.vertexLabels.length&&(t.labeledVertices=l.map(t.vertexLabels,(function(e){return this.label([0,0],"","center",t.labelStyle)}),this)),!t.fixed&&!t.constraints.fixed){var a=f(t.mouseTarget.getMouseTarget());a.css("cursor","move"),a.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)zr||(t.highlight=!0,t.visibleLine.animate(t.highlightStyle,50),t.arrowStyle=l.extend({},t.arrowStyle,{color:t.highlightStyle.stroke,stroke:t.highlightStyle.stroke}),t.transform());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=l.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();var r=(e.pageX-f(i.raphael.canvas.parentNode).offset().left)/i.scale[0]+i.range[0][0],n=i.range[1][1]-(e.pageY-f(i.raphael.canvas.parentNode).offset().top)/i.scale[1];t.snapX>0&&(r=Math.round(r/t.snapX)*t.snapX),t.snapY>0&&(n=Math.round(n/t.snapY)*t.snapY);var s=[t.coordA[0]-r,t.coordA[1]-n],o=[t.coordZ[0]-r,t.coordZ[1]-n],a=-Math.min(i.scaleVector(s)[0],i.scaleVector(o)[0]),p=Math.max(i.scaleVector(s)[0],i.scaleVector(o)[0]),h=Math.max(i.scaleVector(s)[1],i.scaleVector(o)[1]),c=-Math.min(i.scaleVector(s)[1],i.scaleVector(o)[1]);f(document).bind("vmousemove.lineSegment vmouseup.lineSegment",(function(e){e.preventDefault(),t.dragging=!0,zr=!0;var r=e.pageX-f(i.raphael.canvas.parentNode).offset().left,n=e.pageY-f(i.raphael.canvas.parentNode).offset().top;r=Math.max(a+10,Math.min(i.xpixels-10-p,r)),n=Math.max(h+10,Math.min(i.ypixels-10-c,n));var d=r/i.scale[0]+i.range[0][0],u=i.range[1][1]-n/i.scale[1];if(t.snapX>0&&(d=Math.round(d/t.snapX)*t.snapX),t.snapY>0&&(u=Math.round(u/t.snapY)*t.snapY),"vmousemove"===e.type){t.constraints.constrainX&&(d=t.coordA[0]-s[0]),t.constraints.constrainY&&(u=t.coordA[1]-s[1]);var m=d+s[0]-t.coordA[0],g=u+s[1]-t.coordA[1];t.coordA=[d+s[0],u+s[1]],t.coordZ=[d+o[0],u+o[1]],t.transform(),t.movePointsWithLine&&("object"==typeof t.pointA&&t.pointA.setCoord([t.pointA.coord[0]+m,t.pointA.coord[1]+g]),"object"==typeof t.pointZ&&t.pointZ.setCoord([t.pointZ.coord[0]+m,t.pointZ.coord[1]+g])),l.isFunction(t.onMove)&&t.onMove(m,g)}else"vmouseup"===e.type&&(f(document).unbind(".lineSegment"),t.dragging=!1,zr=!1,t.highlight||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=l.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform()),l.isFunction(t.onMoveEnd)&&t.onMoveEnd());f(t).trigger("move")}))}}))}return void 0!==t.pointA&&t.pointA.toFront(),void 0!==t.pointZ&&t.pointZ.toFront(),t.transform(),t},addMovablePolygon:function(e){var t=this,r=f.extend({snapX:0,snapY:0,fixed:!1,constrainToGraph:!0,normalStyle:{},highlightStyle:{stroke:dr.INTERACTING,"stroke-width":2,fill:dr.INTERACTING,"fill-opacity":.05},pointHighlightStyle:{fill:dr.INTERACTING,stroke:dr.INTERACTING},labelStyle:{stroke:dr.DYNAMIC,"stroke-width":1,color:dr.DYNAMIC},angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],updateOnPointMove:!0,closed:!0},l.omit(e,"points")),i=r.fixed?dr.DYNAMIC:dr.INTERACTIVE;r.normalStyle=l.extend({"stroke-width":2,"fill-opacity":0,fill:i,stroke:i},e.normalStyle),r.points=e.points;var n=function(e){return!l.isArray(e)};if(r.update=function(){var e=r.points.length;r.coords=l.map(r.points,(function(e,t){return n(e)?e.coord:e})),r.left=l.min(l.pluck(r.coords,0)),r.right=l.max(l.pluck(r.coords,0)),r.top=l.max(l.pluck(r.coords,1)),r.bottom=l.min(l.pluck(r.coords,1));var i=l.map(r.coords,(function(e){return t.scalePoint(e)}));r.closed?i.push(!0):i=i.concat(l.clone(i).reverse()),r.path=xr.unscaledSvgPath(i),l.invoke(r.temp,"remove"),r.temp=[];var s,o,a=(s=r.coords,o=l.zip(s,s.slice(1).concat(s.slice(0,1))),Rr(l.map(o,(function(e){var t=e[0],r=e[1];return(r[0]-t[0])*(r[1]+t[1])})))>0);(r.angleLabels.length||r.showRightAngleMarkers.length)&&l.each(r.labeledAngles,(function(i,n){r.temp.push(t.labelAngle({point1:r.coords[(n-1+e)%e],vertex:r.coords[n],point3:r.coords[(n+1)%e],label:i,text:r.angleLabels[n],showRightAngleMarker:r.showRightAngleMarkers[n],numArcs:r.numArcs[n],clockwise:a,style:r.labelStyle}))})),r.sideLabels.length&&l.each(r.labeledSides,(function(i,n){r.temp.push(t.labelSide({point1:r.coords[n],point2:r.coords[(n+1)%e],label:i,text:r.sideLabels[n],numArrows:r.numArrows[n],numTicks:r.numTicks[n],clockwise:a,style:r.labelStyle}))})),r.vertexLabels.length&&l.each(r.labeledVertices,(function(i,n){t.labelVertex({point1:r.coords[(n-1+e)%e],vertex:r.coords[n],point3:r.coords[(n+1)%e],label:i,text:r.vertexLabels[n],clockwise:a,style:r.labelStyle})})),r.temp=l.flatten(r.temp)},r.transform=function(){r.update(),r.visibleShape.attr({path:r.path}),r.fixed||r.mouseTarget.attr({path:r.path})},r.remove=function(){r.visibleShape.remove(),r.fixed||r.mouseTarget.remove(),r.labeledAngles&&l.invoke(r.labeledAngles,"remove"),r.labeledSides&&l.invoke(r.labeledSides,"remove"),r.labeledVertices&&l.invoke(r.labeledVertices,"remove"),r.temp.length&&l.invoke(r.temp,"remove")},r.toBack=function(){r.fixed||r.mouseTarget.toBack(),r.visibleShape.toBack()},r.toFront=function(){r.fixed||r.mouseTarget.toFront(),r.visibleShape.toFront()},r.updateOnPointMove&&l.each(l.filter(r.points,n),(function(e){e.polygonVertices.push(r)})),r.coords=new Array(r.points.length),r.angleLabels.length){var s=Math.max(r.angleLabels.length,r.showRightAngleMarkers.length);r.labeledAngles=l.times(s,(function(){return this.label([0,0],"","center",r.labelStyle)}),this)}return r.sideLabels.length&&(r.labeledSides=l.map(r.sideLabels,(function(e){return this.label([0,0],"","center",r.labelStyle)}),this)),r.vertexLabels.length&&(r.labeledVertices=l.map(r.vertexLabels,(function(e){return this.label([0,0],"","center",r.labelStyle)}),this)),r.update(),r.visibleShape=t.raphael.path(r.path),r.visibleShape.attr(r.normalStyle),r.fixed||(r.mouseTarget=t.mouselayer.path(r.path),r.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"}),f(r.mouseTarget[0]).bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)zr&&!r.dragging||(r.highlight=!0,r.visibleShape.animate(r.highlightStyle,50),l.each(l.filter(r.points,n),(function(e){e.visibleShape.animate(r.pointHighlightStyle,50)})));else if("vmouseout"===e.type){if(r.highlight=!1,!r.dragging){r.visibleShape.animate(r.normalStyle,50);var i=l.filter(r.points,n);l.any(l.pluck(i,"dragging"))||l.each(i,(function(e){e.visibleShape.animate(e.normalStyle,50)}))}}else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),l.each(l.filter(r.points,n),(function(e){e.dragging=!0}));var s=(e.pageX-f(t.raphael.canvas.parentNode).offset().left)/t.scale[0]+t.range[0][0],o=t.range[1][1]-(e.pageY-f(t.raphael.canvas.parentNode).offset().top)/t.scale[1];r.snapX>0&&(s=Math.round(s/r.snapX)*r.snapX),r.snapY>0&&(o=Math.round(o/r.snapY)*r.snapY);var a=s,p=o,h=r.coords.slice(),c=(s-r.left)*t.scale[0],d=(r.right-s)*t.scale[0],u=(r.top-o)*t.scale[1],m=(o-r.bottom)*t.scale[1];f(document).bind("vmousemove.polygon vmouseup.polygon",(function(e){e.preventDefault(),r.dragging=!0,zr=!0;var i=e.pageX-f(t.raphael.canvas.parentNode).offset().left,g=e.pageY-f(t.raphael.canvas.parentNode).offset().top;r.constrainToGraph&&(i=Math.max(c+10,Math.min(t.xpixels-10-d,i)),g=Math.max(u+10,Math.min(t.ypixels-10-m,g)));var v=i/t.scale[0]+t.range[0][0],b=t.range[1][1]-g/t.scale[1];if(r.snapX>0&&(v=Math.round(v/r.snapX)*r.snapX),r.snapY>0&&(b=Math.round(b/r.snapY)*r.snapY),"vmousemove"===e.type){var y=v-s,x=b-o,C=!0;if(l.isFunction(r.onMove)){var w=r.onMove(y,x);!1===w?C=!1:l.isArray(w)&&(y=w[0],x=w[1],v=s+y,b=o+x)}var k=function(e){return[h[e][0]+y,h[e][1]+x]};C&&(l.each(r.points,(function(e,t){n(e)?e.setCoord(k(t)):r.points[t]=k(t)})),r.transform(),f(r).trigger("move"),a=v,p=b)}else if("vmouseup"===e.type){f(document).unbind(".polygon");var E=l.filter(r.points,n);l.each(E,(function(e){e.dragging=!1})),r.dragging=!1,zr=!1,r.highlight||(r.visibleShape.animate(r.normalStyle,50),l.each(E,(function(e){e.visibleShape.animate(e.normalStyle,50)}))),l.isFunction(r.onMoveEnd)&&r.onMoveEnd(a-s,p-o)}}))}}))),l.invoke(l.filter(r.points,n),"toFront"),r},constrainToBounds:function(e,t){var r=this.unscalePoint([t,this.ypixels-t]),i=this.unscalePoint([this.xpixels-t,t]);return[Math.max(r[0],Math.min(i[0],e[0])),Math.max(r[1],Math.min(i[1],e[1]))]},constrainToBoundsOnAngle:function(e,t,r){var i=this.unscalePoint([t,this.ypixels-t]),n=this.unscalePoint([this.xpixels-t,t]),s=e.slice();return s[0]<i[0]?s=[i[0],s[1]+(i[0]-s[0])*Math.tan(r)]:s[0]>n[0]&&(s=[n[0],s[1]-(s[0]-n[0])*Math.tan(r)]),s[1]<i[1]?s=[s[0]+(i[1]-s[1])/Math.tan(r),i[1]]:s[1]>n[1]&&(s=[s[0]-(s[1]-n[1])/Math.tan(r),n[1]]),s},addMovableAngle:function(e){return new Ur(this,e)},addCircleGraph:function(e){var t=this,r=f.extend({center:[0,0],radius:2,snapX:.5,snapY:.5,snapRadius:.5,minRadius:1,centerConstraints:{},centerNormalStyle:{},centerHighlightStyle:{stroke:dr.INTERACTING,fill:dr.INTERACTING},circleNormalStyle:{stroke:dr.INTERACTIVE,"fill-opacity":0},circleHighlightStyle:{stroke:dr.INTERACTING,fill:dr.INTERACTING,"fill-opacity":.05}},e),i=r.centerConstraints.fixed?dr.DYNAMIC:dr.INTERACTIVE,n=e?e.centerNormalStyle:null;r.centerNormalStyle=l.extend({},{fill:i,stroke:i},n),r.centerPoint=t.addMovablePoint({graph:t,coord:r.center,normalStyle:r.centerNormalStyle,snapX:r.snapX,snapY:r.snapY,constraints:r.centerConstraints}),r.circ=t.circle(r.center,r.radius,r.circleNormalStyle),r.perim=t.mouselayer.circle(t.scalePoint(r.center)[0],t.scalePoint(r.center)[1],t.scaleVector(r.radius)[0]).attr({"stroke-width":20,opacity:.002}),r.centerConstraints.fixed||f(r.centerPoint.mouseTarget.getMouseTarget()).on("vmouseover vmouseout",(function(e){r.centerPoint.highlight||r.centerPoint.dragging?r.circ.animate(r.circleHighlightStyle,50):r.circ.animate(r.circleNormalStyle,50)})),r.toFront=function(){r.circ.toFront(),r.perim.toFront(),r.centerPoint.visibleShape.toFront(),r.centerConstraints.fixed||r.centerPoint.mouseTarget.toFront()},r.centerPoint.onMove=function(e,i){r.toFront(),r.circ.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(i)[1]}),r.perim.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(i)[1]}),r.onMove&&r.onMove(e,i)},f(r.centerPoint).on("move",(function(){r.center=this.coord,f(r).trigger("move")})),r.setCenter=function(e,t){r.centerPoint.setCoord([e,t]),r.centerPoint.onMove(e,t),r.center=[e,t]},r.setRadius=function(e){r.radius=e,r.perim.attr({r:t.scaleVector(e)[0]}),r.circ.attr({rx:t.scaleVector(e)[0],ry:t.scaleVector(e)[1]})},r.remove=function(){r.centerPoint.remove(),r.circ.remove(),r.perim.remove()};var s=[[-1*Math.PI,-.875*Math.PI,"ew-resize"],[-.875*Math.PI,-.625*Math.PI,"nesw-resize"],[-.625*Math.PI,-.375*Math.PI,"ns-resize"],[-.375*Math.PI,-.125*Math.PI,"nwse-resize"],[-.125*Math.PI,.125*Math.PI,"ew-resize"],[.125*Math.PI,.375*Math.PI,"nesw-resize"],[.375*Math.PI,.625*Math.PI,"ns-resize"],[.625*Math.PI,.875*Math.PI,"nwse-resize"],[.875*Math.PI,1*Math.PI,"ew-resize"]];return f(r.perim.node).on("vmousemove",(e=>{var[t,i]=this.getMouseCoord(e);t-=r.center[0],i-=r.center[1];var n=Math.atan2(i,t);s.forEach((function(e){var[t,i,s]=e;n>=t&&n<i&&f(r.perim.node).css("cursor",s)}))})),f(r.perim.node).css("cursor","nesw-resize"),r.perim.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),f(r.perim.node).on("vmouseover vmouseout vmousedown",(function(e){if("vmouseover"===e.type)r.highlight=!0,zr||(r.circ.animate(r.circleHighlightStyle,50),r.centerPoint.visibleShape.animate(r.centerHighlightStyle,50));else if("vmouseout"===e.type)r.highlight=!1,r.dragging||r.centerPoint.dragging||(r.circ.animate(r.circleNormalStyle,50),r.centerPoint.visibleShape.animate(r.centerNormalStyle,50));else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),r.toFront();var i=r.radius;f(document).on("vmousemove vmouseup",(function(e){if(e.preventDefault(),r.dragging=!0,zr=!0,"vmousemove"===e.type){var n=t.constrainToBounds(t.getMouseCoord(e),10),s=xr.getDistance(r.centerPoint.coord,n);s=Math.max(r.minRadius,Math.round(s/r.snapRadius)*r.snapRadius);var o=r.radius,a=!0;if(r.onResize){var p=r.onResize(s,o);l.isNumber(p)?s=p:!1===p&&(a=!1)}a&&(r.setRadius(s),f(r).trigger("move"))}else"vmouseup"===e.type&&(f(document).off("vmousemove vmouseup"),r.dragging=!1,zr=!1,r.onResizeEnd&&r.onResizeEnd(r.radius,i))}))}})),r},addRotateHandle:function(e){var t=this,r=e.center,i=e.radius,n=e.lengthAngle||30,s=e.hideArrow||!1,o=e.mouseTarget,a=l.uniqueId("rotateHandle");l.isArray(r)&&(r={coord:r});var p=t.addMovablePoint({coord:b.addVector(r.coord,y.cartFromPolarDeg(i,e.angleDeg||0)),constraints:{fixedDistance:{dist:i,point:r}},mouseTarget:o});r.toFront();var h,c=r.coord,d=p.coord,u=d,m=!1,g=!1,v=function(i){if(!s){var o=y.subtract(i,r.coord),a=y.polarDegFromCart(o)[1];h&&h.remove(),h=function(e,t,r,i,n,s,o){var a=function(i,n){var o=r+n,a=y.cartFromPolarDeg(o,s+i),l=y.add(t,a),p=e.scalePoint(l);return p[0]+","+p[1]},l=e.scaleVector(r-i),p=e.scaleVector(r+i);return e.raphael.path(" M"+a(n,-i)+" L"+a(n,-3*i)+" L"+a(2*n,0)+" L"+a(n,3*i)+" L"+a(n,i)+" A"+p[0]+","+p[1]+",0,0,1,"+a(-n,i)+" L"+a(-n,3*i)+" L"+a(-2*n,0)+" L"+a(-n,-3*i)+" L"+a(-n,-i)+" A"+l[0]+","+l[1]+",0,0,0,"+a(n,-i)+" Z").attr({stroke:null,fill:o?dr.INTERACTING:dr.INTERACTIVE})}(t,r.coord,e.radius,m||g?e.hoverWidth/2:e.width/2,n,a,m||g)}};f(r).on("move."+a,(function(){var e=y.subtract(r.coord,c);p.setCoord(y.add(p.coord,e)),v(p.coord),c=r.coord,p.constraints.fixedDistance.point=r,d=p.coord})),p.onMove=function(t,i){m||(u=d,m=!0);var n=[t,i];if(e.onMove){var s=y.polarDegFromCart(y.subtract(d,r.coord)),o=y.polarDegFromCart(y.subtract(n,r.coord)),a=s[1],l=o[1],p=e.onMove(l,a);null!=p&&!0!==p&&(!1===p&&(p=a),n=y.add(r.coord,y.cartFromPolarDeg(s[0],p)))}return v(n),d=n,n},p.onMoveEnd=function(){if(m=!1,v(p.coord),e.onMoveEnd){var t=y.polarDegFromCart(y.subtract(u,r.coord)),i=y.polarDegFromCart(y.subtract(p.coord,r.coord));e.onMoveEnd(i[1],t[1])}},p.visibleShape.remove(),o||p.mouseTarget.attr({scale:2});var x=f(p.mouseTarget.getMouseTarget());x.bind("vmouseover",(function(e){g=!0,v(p.coord)})),x.bind("vmouseout",(function(e){g=!1,v(p.coord)})),v(p.coord);var C=p.remove;return p.remove=function(){C.call(p),h&&h.remove(),f(r).off("move."+a)},p.update=function(){v(p.coord)},p},addReflectButton:function(e){var t,r=this,i=e.line,n=r.addMovablePoint({constraints:e.constraints,coord:x.midpoint([i.pointA.coord,i.pointZ.coord]),snapX:r.snap[0],snapY:r.snap[1],onMove:function(e,t){return!1},onMoveEnd:function(t,r){e.onMoveEnd&&e.onMoveEnd.call(this,t,r)}}),s=!1,o=!1,a=function(){return s},p=l.map([0,1],(function(t){var r=t?e.highlightStyle:e.normalStyle;return l.map([0,1],(function(e){return l.defaults({"fill-opacity":e},r)}))})),h=function(e){return o&&(e=!e),p[+a()][+e]},c=function(i,n){t&&t.remove(),t=function(e,t,r,i,n,s,o){b.equal(r[0],r[1])&&(r=[r[0],b.addVector(r[0],[1,1])]);var a=y.normalize(y.subtract(r[1],r[0])),l=y.scale(a,i/2),p=y.scale(a,n),h=y.rotateDeg(p,90),c=y.rotateDeg(p,-90),d=y.negate(l),u=y.rotateDeg(l,90),m=y.rotateDeg(l,-90),g=b.addVectors(t,h),f=b.addVectors(t,c),v=b.addVectors(t,h,l,u),x=b.addVectors(t,h,d,u),C=b.addVectors(t,c,l,m),w=b.addVectors(t,c,d,m),k=e.path([g,v,x,!0],s),E=e.path([f,C,w,!0],o);return{remove:function(){k.remove(),E.remove()}}}(r,i,n,a()?1.5*e.size:e.size,a()?.125*e.size:.25,h(0),h(1))},d=function(e,t){e=e||i.pointA.coord,t=t||i.pointZ.coord;var r=x.midpoint([e,t]);n.setCoord(r),c(r,[e,t])};f(i).on("move",l.bind(d,n,null,null));var u=f(n.mouseTarget.getMouseTarget());u.on("vclick",(function(){!1!==e.onClick()&&(o=!o,c(n.coord,[i.pointA.coord,i.pointZ.coord]))})),i.pointA.toFront(),i.pointZ.toFront(),n.visibleShape.remove();var m=r.scaleVector(e.size)[0]/20;n.mouseTarget.attr({scale:1.5*m}),u.css("cursor","pointer"),u.bind("vmouseover",(function(e){s=!0,c(n.coord,[i.pointA.coord,i.pointZ.coord])})),u.bind("vmouseout",(function(e){s=!1,c(n.coord,[i.pointA.coord,i.pointZ.coord])}));var g=n.remove;return n.remove=function(){t.remove(),g.call(n)},n.update=d,n.isFlipped=function(){return o},d(),n},protractor:function(e){return new Hr(this,e)},ruler:function(e){return new Wr(this,e||{})},addPoints:Fr}),l.extend(Ur.prototype,{points:[],snapDegrees:0,snapOffsetDeg:0,angleLabel:"",numArcs:1,pushOut:0,fixed:!1,addMoveHandlers:function(){var e=this.graphie;function t(t,r){return xr.getDistance(e.scalePoint(t),e.scalePoint(r))<30}var r=this.points;r[1].onMove=function(i,n){var s=r[1].coord,o=[i,n],a=Fr(o,Dr(s)),p=!0,h={};return l.each([0,2],(function(i){var n=Fr(r[i].coord,a),s=xr.findAngle(o,n);s*=Math.PI/180,n=e.constrainToBoundsOnAngle(n,10,s),h[i]=n,t(o,n)&&(p=!1)})),p&&l.each(h,(function(e,t){r[t].setCoord(e)})),p};var i=this.snapDegrees,n=this.snapOffsetDeg;l.each([0,2],(function(s){r[s].onMove=function(s,o){var a=[s,o],l=r[1].coord;if(t(l,a))return!1;if(i){var p=xr.findAngle(a,l);p=Math.round((p-n)/i)*i+n;var h=xr.getDistance(a,l);return Fr(l,e.polar(h,p))}return!0}})),f(r).on("move",function(){this.update(),f(this).trigger("move")}.bind(this))},addHighlightHandlers:function(){var e=this.points[1];e.onHighlight=function(){l.each(this.points,(function(e){e.visibleShape.animate(this.highlightStyle,50)}),this),l.each(this.rays,(function(e){e.visibleLine.animate(this.highlightStyle,50),e.arrowStyle=l.extend({},e.arrowStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke})}),this),this.angleStyle=l.extend({},this.angleStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke}),this.update()}.bind(this),e.onUnhighlight=function(){l.each(this.points,(function(e){e.visibleShape.animate(this.normalStyle,50)}),this),l.each(this.rays,(function(e){e.visibleLine.animate(e.normalStyle,50),e.arrowStyle=l.extend({},e.arrowStyle,{color:e.normalStyle.stroke,stroke:e.normalStyle.stroke})}),this),this.angleStyle=l.extend({},this.angleStyle,{color:dr.DYNAMIC,stroke:dr.DYNAMIC}),this.update()}.bind(this)},_getClockwiseAngle:function(e){return xr.findAngle(e[2],e[0],e[1])+0},isReflex:function(){return this.reflex},isClockwise:function(){return this._getClockwiseAngle(this.coords)>180===this.reflex},getClockwiseCoords:function(){return this.isClockwise()?l.clone(this.coords):l.clone(this.coords).reverse()},update:function(e){var t=this.coords;this.coords=l.pluck(this.points,"coord"),l.invoke(this.points,"updateLineEnds");var r=this._getClockwiseAngle(t),i=this._getClockwiseAngle(this.coords),n=r>180,s=i>180;this.allowReflex&&(null==e&&(e=n!==s&&Math.abs(i-r)<180),e&&(this.reflex=!this.reflex)),l.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(){l.invoke(this.rays,"remove"),l.invoke(this.temp,"remove"),this.labeledAngle.remove()}});var Gr=De.nestedMap,Vr=De.deepEq;function jr(e){l.extend(this,e)}var Yr=function(){throw new he("Abstract method! Must be implemented by Graphie Movable"+this.constructor.displayName,le.NotAllowed)};l.extend(jr.prototype,{movableProps:[],add:Yr,modify:Yr,remove:Yr,toFront:function(){},componentDidMount:function(){}});var Xr=function(e){var t=function e(t){if(!(this instanceof e))throw new he("Use createElement or JSX with graphie movables",le.NotAllowed);return this.props=function(e,t){return l.extend({},e,{children:l.filter(l.flatten(t),l.identity)})}(t,t.children||[]),this};return e.displayName=e.displayName||l.uniqueId("GraphieClass"),t.displayName=e.displayName,(t.prototype=new jr(e)).constructor=t,t},$r={GraphieMovable:jr,createClass:Xr,createSimpleClass:function(e){return Xr({displayName:e.name||l.uniqueId("GraphieSimpleClass"),movableProps:["children"],add:function(t){this._elements=e(t,this.props),this._prevProps=this.props},modify:function(e){if(!Vr(this.props,this._prevProps))return this.remove(),this.add(e),this._prevProps=this.props,"reordered"},remove:function(){Gr(this._elements,(e=>{e&&e.remove()})),this._elements=null,this._prevProps=null},toFront:function(){Gr(this._elements,(e=>{l.isFunction(e.toFront)&&e.toFront()}))}})}},Kr=function(e){var t=e.graphie.scalePoint(e.coord(0)),r=e.graphie.scalePoint(e.coord(1));return y.polarDegFromCart(y.subtract(r,t))[1]},Zr=function(e,t,r){var i=e.range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),n=e.unscaleVector(y.cartFromPolarDeg(1,r)),s=y.scale(y.normalize(n),i),o=y.add(t,s),a=y.polarDegFromCart(n)[1];return e.constrainToBoundsOnAngle(o,4,a*Math.PI/180)},Jr=function(e,t){var r=[.75,0],i=[[-3,4],[-2.75,2.5],[0,.25],r,[0,-.25],[-2.75,-2.5],[-3,-4]];i=l.map(i,(function(e){var t=y.subtract(e,r),i=y.scale(t,1.4);return y.add(r,i)}));var n=l.map(i,e.unscalePoint),s={center:e.unscalePoint(r),createPath:function(e){for(var t="M"+e[0][0]+" "+e[0][1],r=1;r<e.length;r+=3)t+="C"+e[r][0]+" "+e[r][1]+" "+e[r+1][0]+" "+e[r+1][1]+" "+e[r+2][0]+" "+e[r+2][1];return t}},o=new Ar(e,n,s);return o.attr(l.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),o.toCoordAtAngle=function(t,i){var n=e.scalePoint(Zr(e,t,i));o.transform("translateX("+(n[0]+1.4*r[0])+"px) translateY("+(n[1]+1.4*r[1])+"px) translateZ(0) rotate("+(360-ce.bound(i))+"deg)")},o},Qr={draw:function(){this.draw()},pointsToFront:function(e){l.invoke(e.points,"toFront")}};Qr.standard=[Qr.draw,Qr.pointsToFront];var ei={draw:function(){this.draw()}};ei.standard=[ei.draw];var ti={basic:function(e){var t=this.graphie,r=this.coord(0),i=this.coord(1);if(!this.state.visibleShape){this.state.visibleShape=new Ir(t,r,i,{thickness:10}),this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}var n=Kr(this);e.extendLine?(r=Zr(t,r,360-n),i=Zr(t,i,(540-n)%360)):e.extendRay&&(i=Zr(t,i,360-n));var s=[this.state.visibleShape];this.mouseTarget()&&s.push(this.mouseTarget()),l.each(s,(function(e){e.moveTo(r,i)}))},arrows:function(e){null==this._arrows&&(this._arrows=[],e.extendLine?(this._arrows.push(Jr(this.graphie,this.normalStyle())),this._arrows.push(Jr(this.graphie,this.normalStyle()))):e.extendRay&&this._arrows.push(Jr(this.graphie,this.normalStyle())));var t=Kr(this),r=[360-t,(540-t)%360];l.each(this._arrows,(function(e,t){e.toCoordAtAngle(this.coord(t),r[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)}};ti.standard=[ti.basic,ti.arrows,ti.highlight];var ri={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},arrows:function(){null!=this._arrows&&l.invoke(this._arrows,"remove"),this._arrows=null}};ri.standard=[ri.basic,ri.arrows];var ni={fixed:function(){return function(){return!1}},snap:function(e){return function(t,r){if(null===e)return!0;var i=y.subtract(t,r);return e=e||this.graphie.snap,i=b.roundTo(i,e),y.add(r,i)}},bound:function(e,t,r){return void 0===r&&(r=void 0===e?10:0),function(i,n){var s=this.graphie,o=y.subtract(i,n);e=e||s.range,void 0===t&&(t=s.snap);var a=s.unscalePoint([r,s.ypixels-r]),p=s.unscalePoint([s.xpixels-r,r]);t&&(a=b.ceilTo(a,t),p=b.floorTo(p,t));var h=l.map(this.coords(),(function(e,t){var r=y.subtract(p,e);return[y.subtract(a,e),r]})),c=l.reduce(h,(function(e,t){var r=t[0],i=t[1];return[Math.max(r[0],Math.min(i[0],e[0])),Math.max(r[1],Math.min(i[1],e[1]))]}),o);return y.add(n,c)}},standard:null},si={updatePoints:function(e,t){var r=y.subtract(e,t);l.each(this.state.points,(function(e){e.setCoord(y.add(e.coord(),r))}))},standard:null},oi={add:Qr,modify:ei,draw:ti,remove:ri,onMoveStart:{standard:null},constraints:ni,onMove:si,onMoveEnd:{standard:null}},ai=pr.assert,li=pr.normalizeOptions,pi=["add","draw","remove","onMoveStart","constraints","onMove","onMoveEnd"],hi={points:null,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,extendLine:!1,extendRay:!1},ci={visibleShape:null,mouseTarget:null},di=function(e,t,r){ai(null!=e),ai(null!=r),l.extend(this,{graphie:e,movable:t,state:{id:l.uniqueId("movableLine")}}),this.modify(l.extend({},ci,r))};l.extend(di,oi),pr.createGettersFor(di,l.extend({},hi,ci)),pr.addMovableHelperMethodsTo(di),l.extend(di.prototype,{cloneState:function(){return l.extend(this.movable.cloneState(),{coords:this.coords()},this.state)},_createDefaultState:function(){return l.extend({id:this.state.id},li(pi,Er.pluck(oi,"standard")),hi)},modify:function(e){this.update(l.extend(this._createDefaultState(),e))},update:function(e){var t=this,r=this.graphie,i=t.state=l.extend(t.state,li(pi,e)),n=i.static?dr.DYNAMIC:dr.INTERACTIVE;if(i.normalStyle=l.extend({stroke:n,"stroke-width":2},i.normalStyle),i.highlightStyle=l.extend({stroke:dr.INTERACTING,"stroke-width":3},i.highlightStyle),!i.static&&!i.mouseTarget){i.mouseTarget=new Ir(r,this.coord(0),this.coord(1),{thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"}),i.mouseTarget.attr({fill:"#000",opacity:0})}i.static&&i.mouseTarget&&(i.mouseTarget.remove(),i.mouseTarget=null),t.movable.modify(l.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,r){var i=y.subtract(e,r);t._totalDelta=y.add(t._totalDelta,i);var n=y.add(t._initialRefCoord,t._totalDelta);!1!==(n=t._applyConstraints(n,t._prevRefCoord))&&(t._fireEvent(t.state.onMove,n,t._prevRefCoord),t._prevRefCoord=n)},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,l.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 l.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&&l.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()}});var ui={path:"M8.70710678,12.2928932 C8.31658249,11.9023689 7.68341751,11.9023689 7.29289322,12.2928932 C6.90236893,12.6834175 6.90236893,13.3165825 7.29289322,13.7071068 L9.82842712,16.2426407 C10.2207367,16.6349502 10.8574274,16.6328935 11.2471942,16.2380576 L16.7116603,10.7025237 C17.0996535,10.3094846 17.0955629,9.67633279 16.7025237,9.28833966 C16.3094846,8.90034653 15.6763328,8.90443714 15.2883397,9.29747629 L10.5309507,14.1167372 L8.70710678,12.2928932 Z",width:24,height:24},mi={path:"M6.072 10.4l6.175-7.058a1 1 0 1 1 1.506 1.317L6.769 12.64a1 1 0 0 1-1.55-.054L2.203 8.604a1 1 0 1 1 1.594-1.208L6.072 10.4z",width:16,height:16},gi={path:"M99.669 13.048q0 3.36-2.352 5.712l-41.664 41.664q-2.408 2.408-5.88 2.408t-5.712-2.408l-41.664-41.664q-2.408-2.24-2.408-5.712t2.408-5.88l4.76-4.816q2.52-2.352 5.88-2.352t5.656 2.352l31.136 31.136 31.08-31.136q2.352-2.352 5.712-2.352t5.88 2.352l4.816 4.816q2.352 2.52 2.352 5.88z",width:100,height:63.034},fi={path:"M62.808 49.728q0 3.36-2.352 5.88l-41.72 41.664q-2.352 2.408-5.768 2.408t-5.768-2.408l-4.872-4.76q-2.352-2.52-2.352-5.88t2.352-5.712l31.08-31.136-31.08-31.024q-2.352-2.52-2.352-5.88t2.352-5.712l4.872-4.76q2.296-2.408 5.768-2.408t5.768 2.408l41.72 41.664q2.352 2.296 2.352 5.656z",width:63.034,height:100},vi={path:"M100.035 50.046q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},bi={path:"M50.046 83.676q1.767 0 2.907-1.14l29.526-29.526q1.197-1.197 1.197-2.907t-1.197-2.964l-5.928-5.928q-1.197-1.14-2.964-1.14t-2.907 1.14l-12.312 12.312l0-32.661q0-1.71-1.254-2.964t-2.907-1.254l-8.322 0q-1.71 0-2.964 1.254t-1.254 2.964l0 32.661l-12.312-12.312q-1.197-1.254-2.907-1.254t-2.907 1.254l-5.928 5.928q-1.197 1.197-1.197 2.964t1.197 2.907l29.469 29.526q1.197 1.14 2.964 1.14zm49.989-33.63q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},yi={path:"M54.207 83.391q1.653 0 2.907-1.254t1.254-2.907l0-32.718l12.312 12.312q1.254 1.254 2.964 1.254t2.907-1.254l5.928-5.928q1.197-1.197 1.14-2.964 0-1.767-1.14-2.907l-29.526-29.526q-1.197-1.14-2.907-1.14t-2.964 1.14l-29.469 29.526q-1.197 1.254-1.197 2.964t1.197 2.907l5.928 5.928q1.197 1.197 2.907 1.197t2.907-1.197l12.312-12.312l0 32.718q0 1.653 1.254 2.907t2.964 1.254l8.322 0zm45.828-33.345q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},xi={path:"M50.046 8.322q-8.493 0-16.188 3.306-15.561 6.669-22.173 22.23-3.363 7.695-3.363 16.188t3.306 16.188 8.949 13.281q5.586 5.586 13.281 8.892t16.188 3.306 16.188-3.306 13.281-8.892 8.892-13.281 3.306-16.188-3.306-16.188-8.892-13.281-13.281-8.949q-7.695-3.306-16.188-3.306zm0 91.713q-13.623 0-25.137-6.726t-18.183-18.183q-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.126q-11.514 6.726-25.08 6.726z",width:100,height:99.944},Ci={path:"M58.368 81.225l0-12.369q0-.912-.57-1.539t-1.425-.627l-12.54 0q-.855-.057-1.482.627t-.684 1.539l0 12.369q-.057.855.627 1.482t1.539.684l12.54 0q.855 0 1.425-.627t.57-1.539zm1.026-62.871q0-1.596-2.223-1.71l-14.307 0q-2.109 0-2.223 1.71l1.14 40.47q0 .627.627 1.14t1.539.456l12.084 0q.912-.057 1.539-.513t.684-1.083zm-9.348-18.354q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669z",width:100,height:99.944},wi={path:"M37.964 76.048q-2.576 0-4.368-1.792l-31.864-31.864q-1.792-1.792-1.792-4.368t1.792-4.368l8.736-8.68q1.792-1.792 4.368-1.792t4.312 1.792l18.816 18.872 42-42.056q1.792-1.792 4.368-1.792t4.312 1.792l8.736 8.736q1.792 1.792 1.792 4.368t-1.792 4.312l-55.048 55.048q-1.792 1.792-4.368 1.792z",width:100,height:76.637},ki={path:"M99.758 43.09l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-29.45 0l0 29.45q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-29.45l-29.45 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l29.45 0l0-29.45q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836l0 29.45l29.45 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:100},Ei={path:"M100.464 80.808q0 3.404-2.368 5.772l-11.47 11.544q-2.368 2.368-5.772 2.368t-5.698-2.368l-24.864-24.864-24.864 24.864q-2.368 2.368-5.772 2.368t-5.772-2.368l-11.47-11.544q-2.368-2.368-2.368-5.772t2.368-5.698l24.864-24.864-24.864-24.864q-2.368-2.368-2.368-5.772t2.368-5.772l11.47-11.47q2.368-2.368 5.772-2.368t5.772 2.368l24.864 24.864 24.864-24.864q2.294-2.368 5.698-2.368t5.772 2.368l11.47 11.47q2.368 2.368 2.368 5.772t-2.368 5.772l-24.864 24.864 24.864 24.864q2.368 2.294 2.368 5.698z",width:100,height:100},Si={path:"M15.1052249,9.55978547 L22.0028147,9.55978545 C23.6568673,9.55978545 23.9349557,10.3753626 22.6181351,11.3858845 L16.9943688,15.7015366 L19.2518801,22.8294455 C19.7526645,24.4106317 19.0984455,24.8825885 17.769353,23.8673293 L12.0490577,19.4977438 L6.5116497,23.8422153 C5.20921411,24.8640642 4.53299569,24.4067544 5.00266927,22.8160582 L7.10332364,15.7015366 L1.42794544,11.3634306 C0.110226041,10.3562014 0.383967283,9.54239221 2.0409646,9.54574013 L8.9924676,9.55978547 L11.1485117,2.72669438 C11.6458693,1.15043244 12.4548928,1.15900049 12.9494787,2.72669438 L15.1052249,9.55978547 Z",width:24,height:24},_i={path:"M3.74890556,17.9799506 C2.19251241,16.1970909 1.10103636,13.4971457 1.13090903,11.1491783 C1.17160478,7.95052637 4.01704076,0.865059407 11.7028044,0.865059407 C19.388568,0.865059407 22.3026521,7.35203035 22.3026521,11.5879453 C22.3026521,15.8238603 19.386629,20.5574509 13.6832464,21.7131548 L13.6757539,17.3722171 C17.0812986,16.2190517 18.331158,14.1944123 18.3311578,11.5879451 C18.3311574,8.16554692 15.6664205,5.03476549 11.7028048,5.20494205 C7.73918903,5.37511861 5.59244567,8.66930079 5.59244567,11.1491783 C5.59244567,12.9090077 6.11128139,14.1753512 6.93640437,15.3053215 L8.14052356,14.2949456 C8.98559348,13.5858477 9.6994861,13.9070448 9.73489556,15.0076413 L9.91284941,20.5388014 C9.94832683,21.6415103 9.09967118,22.3514475 8.02194403,22.1254594 L2.60571602,20.9897332 C1.5259204,20.7633114 1.34338662,19.9984207 2.18070755,19.295825 L3.74890556,17.9799506 Z",width:23,height:23},Mi={path:"M31.293 37.506q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.218 0q-.912-.057-1.482-.627t-.57-1.482l0-37.506q0-2.109 2.052-2.109l4.218 0zm18.753 2.109l0 37.506q0 .912-.57 1.482t-1.539.627l-4.161 0q-1.995 0-2.109-2.109l0-37.506q.057-.912.627-1.482t1.482-.627l4.161 0q.969.057 1.539.627t.57 1.482zm14.592-2.109q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.161 0q-.969-.057-1.539-.627t-.57-1.482l0-37.506q0-2.109 2.109-2.109l4.161 0zm10.431 49.248l0-61.731l-58.368 0l0 61.731q.057 2.679.969 3.819t1.083 1.14l54.207 0q.171 0 1.14-1.083t.969-3.876zm-43.776-70.11l29.184 0l-3.135-7.581q-.456-.57-1.14-.741l-20.634 0q-.627.114-1.083.741zm-31.293 2.109q0-1.995 2.109-2.109l20.121 0l4.56-10.83q.969-2.394 3.477-4.104 2.565-1.71 5.187-1.71l20.805 0q2.622 0 5.187 1.71t3.477 4.104l4.56 10.83l20.178 0q.912.057 1.482.627t.57 1.482l0 4.161q0 1.995-2.052 2.109l-6.27 0l0 61.731q0 5.415-3.078 9.348t-7.353 3.933l-54.207 0q-4.275 0-7.353-3.819t-3.078-9.177l0-62.016l-6.213 0q-.969 0-1.539-.57t-.57-1.539l0-4.161z",width:91.681,height:100},Ti={path:"M10,6.6C10,7.2,9.8,8,9.3,9.1c0,0,0,0.1-0.1,0.1S9.2,9.3,9.2,9.4c0,0,0,0.1-0.1,0.1C9,9.6,9,9.6,8.9,9.6 c-0.1,0-0.1,0-0.1-0.1c0,0,0-0.1,0-0.1c0,0,0-0.1,0-0.1s0-0.1,0-0.1c0-0.3,0-0.5,0-0.7c0-0.4,0-0.7-0.1-1C8.6,7.1,8.5,6.9,8.4,6.7S8.2,6.3,8,6.1C7.8,5.9,7.6,5.8,7.4,5.7S6.9,5.5,6.7,5.5S6.1,5.4,5.8,5.4c-0.3,0-0.6,0-1,0H3.6v1.4c0,0.1,0,0.2-0.1,0.3C3.4,7.1,3.3,7.1,3.2,7.1C3.1,7.1,3,7.1,3,7L0.1,4.1C0,4.1,0,4,0,3.9s0-0.2,0.1-0.3L3,0.8C3,0.7,3.1,0.7,3.2,0.7c0.1,0,0.2,0,0.3,0.1C3.5,0.9,3.6,0.9,3.6,1v1.4h1.2c2.6,0,4.3,0.7,4.9,2.2C9.9,5.2,10,5.8,10,6.6z",width:10,height:10},Ii={path:"M8,13 L16,13 C16.5522847,13 17,12.5522847 17,12 C17,11.4477153 16.5522847,11 16,11 L8,11 C7.44771525,11 7,11.4477153 7,12 C7,12.5522847 7.44771525,13 8,13 Z",width:24,height:24},Pi=Object.freeze({__proto__:null,iconCheck:ui,iconCheckMedium:mi,iconChevronDown:gi,iconChevronRight:fi,iconCircle:vi,iconCircleArrowDown:bi,iconCircleArrowUp:yi,iconCircleThin:xi,iconDesktop:{path:"M94.208 52.119l0-43.746q0-.69-.506-1.15t-1.196-.506l-84.088 0q-.69 0-1.196.506t-.506 1.15l0 43.746q0 .69.506 1.196t1.196.506l84.088 0q.69 0 1.196-.506t.506-1.196zm6.716-43.746l0 57.224q0 3.45-2.484 5.934t-5.934 2.484l-28.566 0q0 3.128 2.53 7.774.828 1.61.828 2.622t-1.012 2.07q-1.012 1.012-2.346.966l-26.91 0q-1.38 0-2.392-1.012t-1.012-2.024q0-1.058 1.656-4.14t1.748-6.256l-28.612 0q-3.45 0-5.934-2.484t-2.484-5.934l0-57.224q0-3.45 2.484-5.934t5.934-2.438l84.088 0q3.45 0 5.98 2.438 2.438 2.484 2.438 5.934z",width:100,height:86.648},iconDropdownArrow:{path:"M9 9.8c0 .5.7 1.7 1.5 2.8 1.5 1.9 1.5 1.9 3 0C15.7 9.7 15.4 9 12 9c-1.6 0-3 .4-3 .8z",width:24,height:24},iconExclamationSign:Ci,iconGear:{path:"M1152 896q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm512-109v222q0 12-8 23t-20 13l-185 28q-19 54-39 91 35 50 107 138 10 12 10 25t-9 23q-27 37-99 108t-94 71q-12 0-26-9l-138-108q-44 23-91 38-16 136-29 186-7 28-36 28h-222q-14 0-24.5-8.5t-11.5-21.5l-28-184q-49-16-90-37l-141 107q-10 9-25 9-14 0-25-11-126-114-165-168-7-10-7-23 0-12 8-23 15-21 51-66.5t54-70.5q-27-50-41-99l-183-27q-13-2-21-12.5t-8-23.5v-222q0-12 8-23t19-13l186-28q14-46 39-92-40-57-107-138-10-12-10-24 0-10 9-23 26-36 98.5-107.5t94.5-71.5q13 0 26 10l138 107q44-23 91-38 16-136 29-186 7-28 36-28h222q14 0 24.5 8.5t11.5 21.5l28 184q49 16 90 37l142-107q9-9 24-9 13 0 25 10 129 119 165 170 7 8 7 22 0 12-8 23-15 21-51 66.5t-54 70.5q26 50 41 98l183 28q13 2 21 12.5t8 23.5z",width:1792,height:1792},iconMobilePhone:{path:"M36.04 89.557q0-2.584-1.836-4.42t-4.42-1.836-4.352 1.836q-1.836 1.836-1.836 4.42t1.836 4.352 4.42 1.836q2.652-.068 4.42-1.836t1.768-4.352zm16.184-12.444l0-54.74q0-1.088-.748-1.768t-1.768-.68l-39.78 0q-1.088 0-1.768.748t-.68 1.7l0 54.74q0 1.02.748 1.768t1.7.68l39.78 0q1.02-.068 1.768-.748t.748-1.7zm-14.892-65.892q0-1.224-1.292-1.292l-12.444 0q-1.224.068-1.224 1.292t1.224 1.224l12.444 0q1.292 0 1.292-1.224zm22.372-1.292l0 79.628q0 3.944-2.992 6.936t-7.004 2.992l-39.78 0q-4.012 0-7.004-2.924-2.924-2.924-2.924-7.004l0-79.628q0-4.012 2.924-6.936t7.004-2.992l39.78 0q4.012-.068 7.004 2.924t2.992 7.004z",width:60.013,height:100},iconOk:wi,iconPlus:ki,iconRemove:Ei,iconStar:Si,iconTryAgain:_i,iconTablet:{path:"M45.322 90.706q0-1.86-1.302-3.224-1.364-1.364-3.224-1.364t-3.224 1.364-1.302 3.224q0 1.86 1.364 3.224 1.302 1.364 3.162 1.302 1.86.062 3.224-1.302t1.302-3.224zm27.218-11.346l0-68.014q0-.93-.682-1.612t-1.55-.682l-58.962 0q-.93 0-1.612.682t-.682 1.612l0 68.014q0 .93.682 1.612t1.612.62l58.962 0q.992-.062 1.612-.682t.62-1.55zm9.114-68.014l0 77.066q0 4.65-3.348 7.998t-7.998 3.348l-58.962 0q-4.65 0-7.998-3.348t-3.348-7.998l0-77.066q0-4.65 3.348-7.998t7.998-3.348l58.962 0q4.65 0 7.998 3.348t3.348 7.998z",width:81.852,height:100},iconTrash:Mi,iconUndo:Ti,iconMinus:Ii}),Ai={constrain:function(){this.constrain()}};Ai.standard=[Ai.constrain];var Ni={draw:function(){this.draw()}};Ni.standard=[Ni.draw];var Ri={basic:function(e,t){var r=this.graphie;if(!this.state.visibleShape){var i=[this.pointSize()/r.scale[0],this.pointSize()/r.scale[1]],n={maxScale:Math.max(this.highlightStyle().scale,this.normalStyle().scale),padding:10,shadow:e.shadow};this.state.visibleShape=new Mr(r,this.coord(),i,n),this.state.visibleShape.attr(l.omit(this.normalStyle(),"scale")),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}e.normalStyle===t.normalStyle||l.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)}};Ri.standard=[Ri.basic,Ri.highlight];var Fi={basic:function(){this.state.visibleShape&&(this.state.visibleShape.remove(),this.state.visibleShape=null)}};Fi.standard=Fi.basic;var Di={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,b.roundTo(t,e))}},bound:function(e,t,r){return void 0===r&&(r=void 0===e?10:0),function(i,n,s){var o=this.graphie;e=e||o.range,void 0===t&&(t=o.snap);var a=o.unscalePoint([r,o.ypixels-r]),l=o.unscalePoint([o.xpixels-r,r]);return t&&(a=b.ceilTo(a,t),l=b.floorTo(l,t)),s&&s.onOutOfBounds?((i[0]>l[0]||i[0]<a[0]||i[1]>l[1]||i[1]<a[1])&&(s.onSkipRemaining(),s.onOutOfBounds()),i):[Math.max(a[0],Math.min(l[0],i[0])),Math.max(a[1],Math.min(l[1],i[1]))]}},standard:null},Oi={add:Ai,modify:Ni,draw:Ri,remove:Fi,onMoveStart:{standard:null},constraints:Di,onMove:{standard:null},onMoveEnd:{standard:null},onClick:{standard:null}},Li=pr.assert,Bi=pr.normalizeOptions,{processMath:zi}=vr,qi=l.keys(Oi),Hi={coord:[0,0],pointSize:4,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,shadow:!1,tooltip:!1},Wi={added:!1,hasMoved:!1,visibleShape:null,outOfBounds:!1,mouseTarget:null,touchOffset:null},Ui=[],Gi=function(e,t,r){l.extend(this,{graphie:e,movable:t,state:{id:l.uniqueId("movablePoint")}}),this.modify(l.extend({},Wi,r))};function Vi(e){var t,r=l.zip(e,e.slice(1).concat(e.slice(0,1))),i=l.map(r,(function(e){var t=e[0],r=e[1];return(r[0]-t[0])*(r[1]+t[1])}));return t=i,l.reduce(t,(function(e,t){return e+t}),0)>0}l.extend(Gi,Oi),pr.createGettersFor(Gi,l.extend({},Hi,Wi)),pr.addMovableHelperMethodsTo(Gi),l.extend(Gi.prototype,{cloneState:function(){return l.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return l.extend({id:this.state.id},Bi(qi,Er.pluck(Oi,"standard")),Hi)},modify:function(e){this.update(l.extend(this._createDefaultState(),e))},_showTooltip:function(e){this._tooltip||(this._tooltip=document.createElement("div"),this._tooltip.className="tooltip-content",this.state.visibleShape.wrapper.className="tooltip",this.state.visibleShape.wrapper.appendChild(this._tooltip),Ui.push((()=>{this.state.added&&this._hideTooltip()}))),this._tooltip.firstChild&&this._tooltip.removeChild(this._tooltip.firstChild),this.state.visibleShape.wrapper.className="tooltip visible",this._tooltip.appendChild(document.createElement("span")),"string"==typeof e?zi(this._tooltip.firstChild,e,!1):"function"==typeof e?e(this._tooltip.firstChild):this._tooltip.firstChild.appendChild(e)},_hideTooltip:function(){this._tooltip&&(this.state.visibleShape.wrapper.className="tooltip")},update:function(e){var t=this,r=t.graphie,i=l.extend(t.state,Bi(qi,e));Li(b.is(i.coord));var n=i.static?dr.DYNAMIC:dr.INTERACTIVE;if(i.normalStyle=l.extend({fill:n,stroke:n,scale:1},i.normalStyle),i.highlightStyle=l.extend({fill:dr.INTERACTING,stroke:dr.INTERACTING,scale:2},i.highlightStyle),!i.static&&!i.mouseTarget){var s=t.state.coord,o=r.unscaleVector(24);i.mouseTarget=new Mr(r,s,o,{mouselayer:!0,padding:0,interactiveKindForTesting:"movable-point"}),i.mouseTarget.attr({fill:"#000",opacity:0})}var p=()=>{this._showTooltip((e=>{m.render(a.createElement("span",{style:{fontSize:"2em"}},a.createElement(X,j({},Mi,{style:{position:"static",color:dr.INTERACTIVE,marginLeft:9,marginRight:9}}))),e)}))},h=i.coord;t.movable.modify(l.extend({},i,{add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:e=>{if(i.hasMoved=!1,h=i.coord,null==i.touchOffset){var r=!("ontouchstart"in window);i.touchOffset=r?[0,0]:y.subtract(h,e)}var n=i.visibleShape.wrapper;if(i.shadow){var s="none";n.style.webkitFilter=s,n.style.filter=s}if(i.showHairlines&&i.showHairlines(i.coord),Ui.forEach((e=>e())),i.tooltip&&(i.xOnlyTooltip?this._showTooltip("".concat(i.coord[0])):this._showTooltip("(".concat(i.coord[0],", ").concat(i.coord[1],")")),i.shadow)){var o=n.getElementsByClassName("tooltip-content")[0],a="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";o.style.webkitFilter=a,o.style.filter=a}t._fireEvent(i.onMoveStart,h,h),t.draw()},onMove:(e,r)=>{var n=y.add(e,i.touchOffset);t.moveTo(n),i.showHairlines&&(this.state.outOfBounds?i.hideHairlines():i.showHairlines(i.coord)),i.tooltip&&(this.state.outOfBounds||(i.xOnlyTooltip?this._showTooltip("".concat(i.coord[0])):this._showTooltip("(".concat(i.coord[0],", ").concat(i.coord[1],")")))),i.onRemove&&this.state.outOfBounds&&p()},onMoveEnd:()=>{t.isHovering()&&!i.hasMoved&&t._fireEvent(i.onClick,i.coord,h);var e=i.visibleShape.wrapper;if(i.shadow){var r="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=r,e.style.filter=r}if(i.hideHairlines&&i.hideHairlines(),i.hasMoved)this._hideTooltip();else if(i.onRemove){p();var n=e.getElementsByClassName("tooltip-content")[0];n.style.webkitFilter="none",n.style.filter="none",this._tooltip.firstChild.addEventListener("touchstart",(e=>{e.stopPropagation()}),!0),this._tooltip.firstChild.addEventListener("touchend",(e=>{i.onRemove(),e.stopPropagation()}),!0)}else i.tooltip&&this._hideTooltip();i.outOfBounds&&i.onRemove(),t._fireEvent(i.onMoveEnd,i.coord,h),i.hasMoved=!1,i.touchOffset=null,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 b.is(e)&&this.setCoord(e),!1!==e},setCoord:function(e){Li(b.is(e,2)),this.state.coord=l.clone(e),this.draw()},setCoordConstrained:function(e){Li(b.is(e,2));var t=this._applyConstraints(e,this.coord());!1!==t&&(this.state.coord=l.clone(t),this.draw())},moveTo:function(e){var t=this.state;this.state.outOfBounds=!1;var r=this._applyConstraints(e,t.coord,t.onRemove?{onOutOfBounds:()=>{this.state.outOfBounds=!0}}:{});if(!1!==r&&(b.is(r)&&(e=r),!b.equal(e,t.coord))){var i=t.coord;t.coord=e,t.hasMoved=!0,this._fireEvent(t.onMove,t.coord,i),this.draw()}},normalStyle:function(){return l.clone(this.state.normalStyle)},highlightStyle:function(){return l.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.state.touchOffset=[0,0],this.movable.grab(e),this.moveTo(e)}});var ji={constrain:function(){this.constrain()},pointsToFront:function(e){l.invoke(e.points,"toFront")}};ji.standard=[ji.constrain,ji.pointsToFront];var Yi={draw:function(){this.draw()}};Yi.standard=[Yi.draw];var Xi={basic:function(e,t){var r=this.graphie,i=this.path(e);this.state.visibleShape||(this.state.visibleShape=r.raphael.path(i),this.state.visibleShape.attr(this.normalStyle())),e.normalStyle===t.normalStyle||l.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.attr({path:i}),this.mouseTarget()&&this.mouseTarget().attr({path:i})},labels:function(e,t){var r=this.graphie,i=this,n=l.invoke(e.points,"coord"),s=Vi(n),o=n.length;null!=i.state._labelCache&&l.invoke(i.state._labelCache,"remove"),i.state._labelCache=[],(e.angleLabels.length||e.showRightAngleMarkers.length)&&(null==i.state._labeledAngles&&(i.state._labeledAngles=l.times(Math.max(e.angleLabels.length,e.showRightAngleMarkers.length),(function(){return r.label([0,0],"","center",e.labelStyle)}))),l.each(i.state._labeledAngles,(function(t,a){i.state._labelCache.push(r.labelAngle({point1:n[(a-1+o)%o],vertex:n[a],point3:n[(a+1)%o],label:t,text:e.angleLabels[a],showRightAngleMarker:e.showRightAngleMarkers[a],numArcs:e.numArcs[a],clockwise:s,style:e.labelStyle}))}))),e.sideLabels.length&&(null==i.state._labeledSides&&(i.state._labeledSides=l.map(e.sideLabels,(function(t){return r.label([0,0],"","center",e.labelStyle)}))),l.each(i.state._labeledSides,(function(t,a){i.state._labelCache.push(r.labelSide({point1:n[a],point2:n[(a+1)%o],label:t,text:e.sideLabels[a],numArrows:e.numArrows[a],numTicks:e.numTicks[a],clockwise:s,style:e.labelStyle}))}))),e.vertexLabels.length&&(null==i.state._labeledVertices&&(i.state._labeledVertices=l.map(e.vertexLabels,(function(t){return r.label([0,0],"","center",e.labelStyle)}))),l.each(i.state._labeledVertices,(function(t,a){i.state._labelCache.push(r.labelVertex({point1:n[(a-1+o)%o],vertex:n[a],point3:n[(a+1)%o],label:t,text:e.vertexLabels[a],clockwise:s,style:e.labelStyle}))}))),i.state._labelCache=l.flatten(i.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)}};Xi.standard=[Xi.basic,Xi.labels,Xi.highlight];var $i={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];l.each(e,(function(e){null!=e&&e.length&&l.invoke(e,"remove")}))}};$i.standard=[$i.basic,$i.labels];var Ki={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,b.roundTo(t,e))}},bound:function(e,t,r){return void 0===r&&(r=void 0===e?10:0),function(i,n){var s=this.graphie,o=y.subtract(i,n);e=e||s.range,void 0===t&&(t=s.snap);var a=s.unscalePoint([r,s.ypixels-r]),p=s.unscalePoint([s.xpixels-r,r]);t&&(a=b.ceilTo(a,t),p=b.floorTo(p,t));var h=l.map(this.coords(),(function(e,t){var r=y.subtract(p,e);return[y.subtract(a,e),r]})),c=l.reduce(h,(function(e,t){var r=t[0],i=t[1];return[Math.max(r[0],Math.min(i[0],e[0])),Math.max(r[1],Math.min(i[1],e[1]))]}),o);return y.add(n,c)}},standard:null},Zi={updatePoints:function(e,t){var r=y.subtract(e,t);l.each(this.state.points,(function(e){e.setCoord(y.add(e.coord(),r))}))},standard:null},Ji={add:ji,modify:Yi,draw:Xi,remove:$i,onMoveStart:{standard:null},constraints:Ki,onMove:Zi,onMoveEnd:{standard:null},onClick:{standard:null}},Qi=pr.assert,en=pr.normalizeOptions,tn=l.keys(Ji),rn={points:null,angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],closed:!0,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,labelStyle:null},nn={added:!1,hasMoved:!1,visibleShape:null,mouseTarget:null},sn=function(e,t,r){Qi(null!=e),Qi(null!=r),l.extend(this,{graphie:e,movable:t,state:{id:l.uniqueId("movablePolygon")}}),this.modify(l.extend({},nn,r))};l.extend(sn,Ji),pr.createGettersFor(sn,l.extend({},rn,nn)),pr.addMovableHelperMethodsTo(sn),l.extend(sn.prototype,{cloneState:function(){return l.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return l.extend({id:this.state.id},en(tn,Er.pluck(Ji,"standard")),rn)},modify:function(e){this.update(l.extend(this._createDefaultState(),e))},update:function(e){var t=this,r=t.graphie,i=l.extend(t.state,en(tn,e)),n=i.static?dr.DYNAMIC:dr.INTERACTIVE;i.normalStyle=l.extend({},i.normalStyle,{"stroke-width":2,"fill-opacity":0,fill:n,stroke:n},e.normalStyle),i.highlightStyle=l.extend({},{stroke:dr.INTERACTING,"stroke-width":2,fill:dr.INTERACTING,"fill-opacity":.05},i.highlightStyle),i.labelStyle=l.extend({},{stroke:dr.DYNAMIC,"stroke-width":1,color:dr.DYNAMIC},i.labelStyle),i.static||i.mouseTarget||(i.mouseTarget=r.mouselayer.path(this.path()),i.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"})),t.movable.modify(l.extend({},i,{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,r){var i=y.subtract(e,r);t._totalDelta=y.add(t._totalDelta,i);var n=y.add(t._initialRefCoord,t._totalDelta);!1!==(n=t._applyConstraints(n,t._prevRefCoord))&&(t._fireEvent(t.state.onMove,n,t._prevRefCoord),t._prevRefCoord=n)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),l.invoke(i.points,"listen","onMove",i.id,t.draw.bind(t)),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)},path:function(e){var t=this.graphie;e=e||this.state;var r=l.map(e.points,(function(e){return t.scalePoint(e.coord())}));return e.closed?r.push(!0):r=r.concat(l.clone(r).reverse()),xr.unscaledSvgPath(r)},coords:function(){return l.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&&l.invoke(this.state.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){if(null!=this.points&&0!==this.points.length){var e=this.coord(0),t=this._applyConstraints(e,e);!1!==t&&this._fireEvent(this.state.onMove,t,e)}},normalStyle:function(){return l.clone(this.state.normalStyle)},highlightStyle:function(){return l.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()}});var on=pr.normalizeOptions,an=pr.assert,ln=["add","modify","draw","remove","onMoveStart","onMove","onMoveEnd","onClick"],pn={cursor:null},hn={added:!1,isHovering:!1,isMouseOver:!1,isDragging:!1,mouseTarget:null},cn=function(e,t){l.extend(this,{graphie:e,state:{id:l.uniqueId("movable")}}),this.modify(l.extend({},hn,t))};pr.createGettersFor(cn,l.extend({},pn,hn)),pr.addMovableHelperMethodsTo(cn),l.extend(cn.prototype,{cloneState:function(){return l.clone(this.state)},_createDefaultState:function(){return l.extend({id:this.state.id,add:[],modify:[],draw:[],remove:[],onMoveStart:[],onMove:[],onMoveEnd:[],onClick:[]},pn)},modify:function(e){this.update(l.extend({},this._createDefaultState(),e))},grab:function(e){an(b.is(e));var t=this,r=t.graphie,i=t.state;i.isHovering=!0,i.isDragging=!0,r.isDragging=!0;var n=e,s=n;t._fireEvent(i.onMoveStart,n,n);var o=function(e){e.preventDefault();var n=r.getMouseCoord(e);t._fireEvent(i.onMove,n,s),t.draw(),s=n};f(document).bind("vmousemove",o),f(document).bind("vmouseup",(function e(a){f(document).unbind("vmousemove",o),f(document).unbind("vmouseup",e),i.isHovering&&t._fireEvent(i.onClick,s,n),i.isHovering=t.state.isMouseOver,i.isDragging=!1,r.isDragging=!1,t._fireEvent(i.onMoveEnd,s,n),t.draw()}))},update:function(e){var t,r=this,i=r.graphie,n=r.cloneState(),s=l.extend(r.state,on(ln,e));s.mouseTarget&&!n.mouseTarget&&(t=s.mouseTarget.getMouseTarget?f(s.mouseTarget.getMouseTarget()):f(s.mouseTarget[0]),!("ontouchstart"in window)&&(t.on("vmouseover",(function(){s.isMouseOver=!0,i.isDragging||(s.isHovering=!0),r.state.added&&r.draw()})),t.on("vmouseout",(function(){s.isMouseOver=!1,s.isDragging||(s.isHovering=!1),r.state.added&&r.draw()}))),t[0].addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),t.on("vmousedown",(function(e){if(0===e.which||1===e.which){e.preventDefault();var t=i.getMouseCoord(e);r.grab(t)}})));s.mouseTarget&&void 0!==s.cursor&&(s.mouseTarget.getMouseTarget?f(s.mouseTarget.getMouseTarget()):f(s.mouseTarget[0])).css("cursor",s.cursor||"");s.added||(r._fireEvent(s.modify,r.cloneState(),{}),s.added=!0,r.prevState=r.cloneState()),r._fireEvent(s.modify,r.cloneState(),r.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.mouseTarget&&(f(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()}});var dn={MovablePoint:Gi,addMovablePoint:function(e,t){var r=new cn(e,{});return new Gi(e,r,t)},MovableLine:di,addMovableLine:function(e,t){var r=new cn(e,{});return new di(e,r,t)},MovablePolygon:sn,addMovablePolygon:function(e,t){var r=new cn(e,{});return new sn(e,r,t)},addMaybeMobileMovablePoint:function(e,t){var r=e.props.apiOptions.isMobile,i=r?{stroke:"#ffffff","stroke-width":3,fill:dr.INTERACTIVE}:{stroke:dr.INTERACTIVE,fill:dr.INTERACTIVE},n=Object.assign(i,t.normalStyle),s=Object.assign(r?U(U({},i),{},{"stroke-width":0,scale:.75}):{},t.highlightStyle),o=Object.assign({normalStyle:n,highlightStyle:s,shadow:r,tooltip:r&&e.props.showTooltips,showHairlines:e.showHairlines,hideHairlines:e.hideHairlines},r?{pointSize:7}:{});return dn.addMovablePoint(e.graphie,Object.assign(t,o))}},un=$r.createClass({displayName:"MovablePoint",movableProps:["children"],_getProps:function(){if(this.props.isMobile){var e=this.props.isMobile,t=e?{stroke:"#ffffff","stroke-width":3,fill:dr.INTERACTIVE}:{stroke:dr.INTERACTIVE,fill:dr.INTERACTIVE},r=e?Object.assign(t,this.props.mobileStyleOverride||{}):Object.assign(t,this.props.normalStyle),i=e?U(U({},t),{},{"stroke-width":0,scale:.75}):this.props.highlightStyle,n=Object.assign({normalStyle:r,highlightStyle:i,shadow:e,tooltip:e&&this.props.showTooltips},e?{pointSize:7}:{});return Object.assign(this.props,n)}return this.props},add:function(e){this.point=dn.addMovablePoint(e,this._getProps())},modify:function(){this.point.modify(this._getProps())},remove:function(){this.point.remove()},toFront:function(){this.point.toFront()},grab:function(e){this.point.grab(e)}});l.extend(un,dn.MovablePoint);var mn=$r.createClass({displayName:"MovableLine",movableProps:["children"],add:function(e){var t=l.pluck(this.props.children,"point"),r=l.extend({},this.props,{points:t});this.line=dn.addMovableLine(e,r)},modify:function(){var e=l.pluck(this.props.children,"point"),t=l.extend({},this.props,{points:e});this.line.modify(t)},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}});l.extend(mn,dn.MovableLine);var gn=$r.createSimpleClass(((e,t)=>{var r=t.coord;t.unscaled&&(r=e.unscalePoint(r));var i=null;return oe().JIPT.useJIPT?(i=e.label(r,t.text,t.direction,!1,t.style),oe().graphieMovablesJiptLabels.addLabel(i,t.tex)):i=e.label(r,t.text,t.direction,t.tex,t.style),i})),fn=$r.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(l.extend({},e.style,{path:t}))},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}}),vn=$r.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(l.extend({},e.style,{path:t}))},remove:function(){this.parabola.remove()},toFront:function(){this.parabola.toFront()}}),bn=$r.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(l.extend({},e.style,{path:t}))},remove:function(){this.sinusoid.remove()},toFront:function(){this.sinusoid.toFront()}}),yn=$r.createSimpleClass(((e,t)=>e.plot(t.fn,t.range,t.style))),xn=$r.createSimpleClass(((e,t)=>e.plotParametric(t.fn,t.range,t.style))),Cn=$r.createSimpleClass(((e,t)=>e.ellipse(t.coord,e.unscaleVector([4,4]),{fill:t.color||dr.BLACK,stroke:t.color||dr.BLACK}))),wn=$r.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()}}),kn={Arc:$r.createSimpleClass(((e,t)=>{var r=t.center,i=t.radius;return t.unscaled&&(r=e.unscalePoint(r),i=e.unscaleVector(i)),e.arc(r,i,t.startAngle,t.endAngle,t.sector,t.style)})),Circle:$r.createSimpleClass(((e,t)=>e.circle(t.center,t.radius,t.style))),Label:gn,Line:fn,MovableLine:mn,MovablePoint:un,Parabola:vn,Path:wn,Plot:yn,PlotParametric:xn,Point:Cn,Sinusoid:bn,Rect:$r.createSimpleClass(((e,t)=>e.rect(t.x,t.y,t.width,t.height,t.style)))},En=$r.GraphieMovable,Sn=xr.createGraphie,{deepEq:_n,nestedMap:Mn}=De,{assert:Tn}=pr;class In extends a.Component{constructor(){super(...arguments),V(this,"getGraphie",(()=>this._graphie)),V(this,"_range",(()=>l.map(this.props.range,(e=>e[0]>=e[1]?[-10,10]:e)))),V(this,"_box",(()=>l.map(this.props.box,(e=>e>0?e:340)))),V(this,"_scale",(()=>{var e=this._box(),t=this._range();return l.map(e,((e,r)=>e/(t[r][1]-t[r][0])))})),V(this,"_setupGraphie",(()=>{this._removeMovables();var e=g.findDOMNode(this.refs.graphieDiv);f(e).empty();var t=this._graphie=Sn(e);t.init({range:this._range(),scale:this._scale(),isMobile:this.props.isMobile}),this.props.addMouseLayer&&t.addMouseLayer({onClick:this.props.onClick,onMouseDown:this.props.onMouseDown,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),t.snap=this.props.options.snapStep||[1,1],this.props.responsive&&(f(e).css({width:"100%",height:"100%"}),t.raphael.setSize("100%","100%")),this.props.setup(t,l.extend({range:this._range(),scale:this._scale()},this.props.options))})),V(this,"_removeMovables",(()=>{l.invoke(this._movables,"remove"),this._movables={}})),V(this,"_renderMovables",((e,t)=>{var r=t.graphie,i=t.oldMovables,n=t.newMovables,s=e=>{l.each(e.movableProps,(r=>{e.props[r]=this._renderMovables(e.props[r],t)}))},o=!1;return Mn(e,(e=>{if(!e)return t.nextKey++,e;var a=new e.type(e.props);Tn(a instanceof En,"All children of a Graphie component must be Graphie movables");var l=e.key,p=null==l?"_no_id_"+t.nextKey:l;t.nextKey++;var h=e.ref;s(a);var c=i[p];if(c)if(a.constructor===c.constructor){c.props=a.props,"reordered"===c.modify(r)&&(o=!0),n[p]=c}else null==l&&pe.error("Replacing a <Graphie> child with a child of a different type. Please add keys to your <Graphie> children",le.Internal),c.remove(),a.add(r),o=!0,n[p]=a;else a.add(r),o=!0,n[p]=a;return o&&n[p].toFront(),h&&(this.movables[h]=n[p]),n[p]}))})),V(this,"_updateMovables",(()=>{var e=this._graphie,t=this._movables,r={};this._movables=r,this.movables={},this._renderMovables(this.props.children,{nextKey:1,graphie:e,oldMovables:t,newMovables:r}),l.each(t,((e,t)=>{r[t]||e.remove()}))}))}componentDidMount(){this._setupGraphie(),this._updateMovables()}shouldComponentUpdate(e){return!l.isEqual(this.props,e)}componentDidUpdate(e){this.props.setup!==e.setup&&pe.error("<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.",le.Internal),_n(this.props.options,e.options)&&_n(this.props.box,e.box)&&_n(this.props.range,e.range)||this._setupGraphie(),this._updateMovables()}render(){return a.createElement("div",{className:"graphie-container"},a.createElement("div",{className:"graphie",ref:"graphieDiv"}))}}V(In,"propTypes",{addMouseLayer:h.bool,box:h.arrayOf(h.number).isRequired,children:h.node,isMobile:h.bool,onClick:h.func,onMouseDown:h.func,onMouseMove:h.func,onMouseUp:h.func,options:h.shape({snapStep:h.arrayOf(h.number)}),range:h.arrayOf(h.arrayOf(h.number)),responsive:h.bool,setDrawingAreaAvailable:h.func,setup:h.func.isRequired}),V(In,"defaultProps",{range:[[-10,10],[-10,10]],options:{},responsive:!1,addMouseLayer:!0}),l.extend(In,$r),l.extend(In,kn);var Pn="pending",An="loading",Nn="loaded",Rn="failed";class Fn extends a.Component{constructor(e){super(e),V(this,"img",void 0),V(this,"createLoader",(()=>{this.destroyLoader(),this.img=new Image,this.img.onload=this.handleLoad,this.img.onerror=this.handleError,this.img.src=this.props.src})),V(this,"destroyLoader",(()=>{this.img&&(this.img.onload=null,this.img.onerror=null,this.img=null)})),V(this,"handleLoad",(e=>{this.destroyLoader(),this.setState({status:Nn}),this.props.onLoad&&this.props.onLoad(e)})),V(this,"handleError",(e=>{this.destroyLoader(),this.setState({status:Rn}),this.props.onError&&this.props.onError(e)})),V(this,"renderImg",(()=>{var{src:e,imgProps:t}=this.props,r=null,i=null;null!=t.onClick&&(r=e=>{13!==e.keyCode&&32!==e.keyCode||t.onClick&&t.onClick(e)},i=e=>{32===e.keyCode&&e.preventDefault()});var n=oe().staticUrl;return a.createElement("img",j({src:n(e),onKeyUp:r,onKeyDown:i},t))})),this.state={status:e.src?An:Pn}}componentDidMount(){this.state.status===An&&this.createLoader()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({status:e.src?An:Pn})}componentDidUpdate(e,t){this.state.status!==An||this.img||this.createLoader(),t.status!==this.state.status&&this.props.onUpdate(this.state.status)}componentWillUnmount(){this.destroyLoader()}render(){switch(this.state.status){case Nn:return this.renderImg();case Rn:if(this.props.children)return this.props.children;break;default:if(this.props.preloader)return this.props.preloader()}return null}}var Dn={},On=/^file\+graphie\:/,Ln=/\/([^/]+)$/;function Bn(e){return/\.(jpg|jpeg)$/i.test(e)}function zn(){var{JIPT:e,kaLocale:t}=oe();return e.useJIPT?"en-pt":t}function qn(){return"en"!==zn()}var Hn=/\/(?=[^/]+$)/;function Wn(e){return a.createElement("span",{style:{background:"url(/images/spinner.gif) no-repeat",backgroundPosition:"center",width:"100%",height:"100%",position:"absolute",minWidth:"20px"}})}class Un extends a.Component{constructor(e){super(e),V(this,"_isMounted",void 0),V(this,"onDataLoaded",((e,t)=>{if(this._isMounted&&e.labels&&e.range){var r=e.labels.reduce(((e,t)=>U(U({},e),{},{[t.content]:!1})),{});this.setState({dataLoaded:!0,labelDataIsLocalized:t,labelsRendered:r,labels:e.labels,range:e.range})}})),V(this,"onImageLoad",(()=>{this.sizeProvided()?this.setState({imageLoaded:!0}):De.getImageSize(this.props.src,((e,t)=>{this._isMounted&&this.setState({imageLoaded:!0,imageDimensions:[e,t]})}))})),V(this,"setupGraphie",((e,t)=>{l.map(t.labels,(t=>{var{JIPT:r}=oe();if(r.useJIPT&&this.state.labelDataIsLocalized){var i=e.label(t.coordinates,t.content,t.alignment,!1);oe().svgImageJiptLabels.addLabel(i,t.typesetAsMath)}else if(t.coordinates){var n=e.label(t.coordinates,t.content,t.alignment,t.typesetAsMath,{"font-size":100*this.props.scale+"%"}),s=n[0].style,o=this._tryGetPixels(s.top),a=this._tryGetPixels(s.left);if(null===o||null===a){var p=n.position();o=p.top,a=p.left}var h=(this.props.height||0)*this.props.scale,c=(this.props.width||0)*this.props.scale;n.css({top:o/h*100+"%",left:a/c*100+"%"}),l.each(t.style,((e,t)=>{n.css(t,e)}))}this.setState({labelsRendered:U(U({},this.state.labelsRendered),{},{[t.content]:!0})})}))})),V(this,"_handleZoomClick",(e=>{(f(e.target).width()<this.props.width||this.props.zoomToFullSizeOnMobile)&&ir.handleZoomClick(e,this.props.zoomToFullSizeOnMobile),this.props.trackInteraction&&this.props.trackInteraction()})),V(this,"handleUpdate",(e=>{this.props.onUpdate(),De.isLabeledSVG(this.props.src)||"loaded"!==e||this.setState({imageLoaded:!0})})),e.setAssetStatus(e.src,!1),this._isMounted=!1,this.state={imageLoaded:!1,imageDimensions:null,dataLoaded:!1,labelDataIsLocalized:!1,labels:[],labelsRendered:{},range:[[0,0],[0,0]]}}componentDidMount(){this._isMounted=!0,De.isLabeledSVG(this.props.src)&&this.loadResources()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({imageLoaded:!1,dataLoaded:!1})}shouldComponentUpdate(e,t){return!l.isEqual(this.props,e)||this.isLoadedInState(this.state)!==this.isLoadedInState(t)}componentDidUpdate(e,t){var r=this.isLoadedInState(t),i=this.isLoadedInState(this.state);De.isLabeledSVG(this.props.src)&&!i&&this.loadResources(),!r&&i&&this.props.setAssetStatus(this.props.src,!0)}componentWillUnmount(){this._isMounted=!1}isLoadedInState(e){return De.isLabeledSVG(this.props.src)?e.imageLoaded&&e.dataLoaded:e.imageLoaded}loadResources(){var e=function(e){var t=e.match(Ln);if(null==t)throw new he("not a valid URL",le.InvalidInput);return t&&t[1]}(this.props.src);if(Dn[e])if(Dn[e].loaded){var{data:t,localized:r}=Dn[e];this.onDataLoaded(t,r)}else Dn[e].dataCallbacks.push(this.onDataLoaded);else{var i={loaded:!1,dataCallbacks:[this.onDataLoaded],data:null,localized:qn()};Dn[e]=i;var n=(t,r)=>{!function(e,t){t=U({callbackName:"callback",success:f.noop,error:f.noop},t);var r=document.createElement("script");function i(){document.head&&document.head.removeChild(r),delete window[t.callbackName]}r.setAttribute("async",""),r.setAttribute("src",e),window[t.callbackName]=function(){i(),t.success.apply(null,arguments)},r.addEventListener("error",(function(){i(),t.error.apply(null,arguments)})),document.head&&document.head.appendChild(r)}(t,{callbackName:"svgData"+e,success:e=>{i.data=e,i.loaded=!0,l.each(i.dataCallbacks,(e=>{e(i.data,i.localized)}))},error:r})};qn()?n(function(e){if(On.test(e))return De.getDataUrl(e);var[t,r]=De.getBaseUrl(e).split(Hn);return"".concat(t,"/").concat(zn(),"/").concat(r,"-data.json")}(this.props.src),((e,t,r)=>{i.localized=!1,n(De.getDataUrl(this.props.src),((e,t,r)=>{pe.error("Data load failed for svg-image",le.Service,{cause:r,loggedMetadata:{dataUrl:De.getDataUrl(this.props.src),status:t}})}))})):n(De.getDataUrl(this.props.src),((e,t,r)=>{pe.error("Data load failed for svg-image",le.Service,{cause:r,loggedMetadata:{dataUrl:De.getDataUrl(this.props.src),status:t}})}))}}sizeProvided(){return null!=this.props.width&&null!=this.props.height}_tryGetPixels(e){return(e=e||"").endsWith("px")&&parseFloat(e)||null}render(){var e=this.props.src,t={alt:this.props.alt,title:this.props.title,tabIndex:"0"};this.props.alt&&this.props.overrideAriaHidden&&(t["aria-hidden"]=!0);var r,i=this.props.width&&this.props.width*this.props.scale,n=this.props.height&&this.props.height*this.props.scale,s={width:i,height:n},p=this.props.responsive&&!(!i||!n);this.props.extraGraphie&&this.props.extraGraphie.labels.length&&(r=a.createElement(In,{box:this.props.extraGraphie.box,range:this.props.extraGraphie.range,options:{labels:this.props.extraGraphie.labels},responsive:!0,addMouseLayer:!1,setup:this.setupGraphie}));var h=void 0===this.props.preloader?Wn:this.props.preloader,c=h?()=>h(s):null;if(!De.isLabeledSVG(e)){if(p){var d=o({zoomable:(i||0)>700,"svg-image":!0});return t.onClick=this._handleZoomClick,a.createElement(nr,{className:d,width:i,height:n,constrainHeight:this.props.constrainHeight,allowFullBleed:this.props.allowFullBleed&&Bn(e)},a.createElement(Fn,{src:e,imgProps:t,preloader:c,onUpdate:this.handleUpdate}),r)}return t.style=s,a.createElement(Fn,{src:e,preloader:c,imgProps:t,onUpdate:this.handleUpdate})}var u,m=De.getSvgUrl(e);if(this.isLoadedInState(this.state)){var g;if(this.sizeProvided())g=[i,n];else{if(!this.state.imageDimensions)throw new he("svg-image has no dimensions",le.InvalidInput,{metadata:{src:this.props.src}});g=[this.state.imageDimensions[0]*this.props.scale,this.state.imageDimensions[1]*this.props.scale]}var f=[40*this.props.scale,40*this.props.scale];u=a.createElement(In,{ref:"graphie",box:g,scale:f,range:this.state.range,options:l.pick(this.state,"labels"),responsive:p,addMouseLayer:!1,setup:this.setupGraphie})}return p?a.createElement(nr,{className:"svg-image",width:i,height:n,constrainHeight:this.props.constrainHeight},a.createElement(Fn,{src:m,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:c,imgProps:t}),u,r):(t.style=s,a.createElement("div",{className:"unresponsive-svg-image",style:s},a.createElement(Fn,{src:m,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:c,imgProps:t}),u))}}V(Un,"defaultProps",{constrainHeight:!1,onUpdate:()=>{},responsive:!0,src:"",scale:1,zoomToFullSizeOnMobile:!1,setAssetStatus:(e,t)=>{}});class Gn extends a.Component{constructor(e){super(e),V(this,"_hasRendered",void 0),V(this,"handleRender",(()=>{this.props.onRender(),this.setState({rendered:!0}),this.props.onRender(),this._hasRendered||(this._hasRendered=!0,this.props.setAssetStatus(this.props.children,!0))})),this.props.setAssetStatus(this.props.children,!1),this.state={rendered:!1},this._hasRendered=!1}render(){var{TeX:e}=oe();return a.createElement(e,{onRender:this.handleRender},this.props.children)}}V(Gn,"defaultProps",{onRender:()=>{},setAssetStatus:(e,t)=>{}});class Vn extends a.Component{constructor(){super(...arguments),V(this,"_isMounted",void 0),V(this,"_observer",void 0),V(this,"_measuringInitialized",void 0),V(this,"_originalWidth",void 0),V(this,"_node",void 0),V(this,"state",{visible:!1,marginBottomPx:0,zoomed:!0}),V(this,"reset",(()=>{this._isMounted&&this.state.visible&&(this._originalWidth=null,this.setState({visible:!1,compactHeight:null,expandedHeight:null,zoomed:!0},(()=>{this.measureAndScaleChildToFit(!1)})))})),V(this,"stopPropagationIfZoomed",(e=>{this.state.zoomed||e.stopPropagation()})),V(this,"handleClickIfZoomed",(e=>{this.state.zoomed||(e.stopPropagation(),this.handleClick())})),V(this,"handleClick",(()=>{this.setState({zoomed:!this.state.zoomed})}))}componentDidMount(){this._isMounted=!0,this.maybeInitializeMeasuring()}componentDidUpdate(){this.maybeInitializeMeasuring()}componentWillUnmount(){window.removeEventListener("resize",this.reset),this._observer&&this._observer.disconnect(),this._isMounted=!1}maybeInitializeMeasuring(){var e=this.props.readyToMeasure&&!this._measuringInitialized;this._isMounted&&e&&(this._measuringInitialized=!0,this._node=g.findDOMNode(this),setTimeout((()=>this.measureAndScaleChildToFit(!1)),0),window.MutationObserver&&(this._observer=new MutationObserver((e=>{if(this._isMounted)for(var t of e)if(t.target!==this._node){this.measureAndScaleChildToFit(this.state.zoomed);break}})),this._observer.observe(this._node,{childList:!0,subtree:!0,attributes:!0})),window.addEventListener("resize",this.reset))}measureAndScaleChildToFit(e){if(this._isMounted){var t={width:this._node.offsetWidth,height:this._node.offsetHeight},r=this.props.computeChildBounds(this._node,t),i=r.width+1,n=r.height+1;if(i>t.width){var s=t.width/i;this.setState({scale:s,zoomed:e,compactHeight:Math.ceil(s*n),expandedHeight:n}),setTimeout((()=>{this._isMounted&&this.setState({visible:!0})}))}else this.setState({visible:!0})}}render(){var{visible:e,scale:t,compactHeight:r,expandedHeight:i,zoomed:n}=this.state,{animateHeight:s}=this.props,o=s?"opacity transform height":"opacity transform",l=e?{transitionProperty:o,WebkitTransitionProperty:o,msTransitionProperty:o,transitionDuration:"0.3s",WebkitTransitionDuration:"0.3s",msTransitionDuration:"0.3s",transitionTimingFunction:"ease-out",WebkitTransitionTimingfunction:"ease-out",msTransitionTmingFunction:"ease-out"}:{},p=e?"":" translate(0, 8px)",h=(null!=t?t:1).toString(),c=n?"scale(1, 1) ".concat(p):"scale(".concat(h,", ").concat(h,") ").concat(p),d=U({display:"block",width:"100%",height:n?i:r,transform:c,WebkitTransform:c,msTransform:c,transformOrigin:"0 0",WebkitTransformOrigin:"0 0",msTransformOrigin:"0 0",opacity:e?1:0,WebkitTapHighlightColor:"transparent"},l);return a.createElement("span",{onClick:this.handleClick,onClickCapture:this.handleClickIfZoomed,onTouchCancelCapture:this.stopPropagationIfZoomed,onTouchEndCapture:this.stopPropagationIfZoomed,onTouchStartCapture:this.stopPropagationIfZoomed,style:d},this.props.children)}}V(Vn,"defaultProps",{animateHeight:!1,readyToMeasure:!0,computeChildBounds:e=>{var t=e.firstElementChild;return{width:t.offsetWidth,height:t.offsetHeight}}});var jn=(e,t)=>{var r=e.querySelector(".katex-html")||e.querySelector(".MathJax"),i={width:r.offsetWidth,height:r.offsetHeight};return{width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)}};class Yn extends a.Component{constructor(){super(),V(this,"handleRender",(()=>{this.setState({isRendered:!0})})),this.state={isRendered:!1}}render(){return a.createElement(Vn,{readyToMeasure:this.state.isRendered,computeChildBounds:jn},a.createElement(Qt.Consumer,null,(e=>{var{setAssetStatus:t}=e;return a.createElement(Gn,{onRender:this.handleRender,setAssetStatus:t},this.props.children)})))}}class Xn extends a.Component{constructor(e){super(e),this.state={error:""}}componentDidCatch(e,t){this.setState({error:e.toString()}),pe.error("Perseus error boundary caught error",le.Internal,{cause:e,loggedMetadata:{info:t.toString()}})}render(){return this.state.error?a.createElement("svg",{height:"16",width:"16",viewBox:"0 0 16 16"},a.createElement("path",{d:"m8 16c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-3c0.55 0 1-0.45 1-1s-0.45-1-1-1-1 0.45-1 1 0.45 1 1 1zm0-9c-0.55 0-1 0.45-1 1v4c0 0.55.45 1 1 1s1-0.45 1-1v-4c0-0.55-0.45-1-1-1z",fill:"#d92916",fillRule:"evenodd"})):this.props.children}}function $n(){}class Kn{constructor(e,t,r,i){V(this,"_tracked",void 0),V(this,"setting",void 0),V(this,"track",void 0),V(this,"trackApi",void 0),V(this,"widgetID",void 0),V(this,"widgetType",void 0),V(this,"_track",(e=>{this._tracked&&!this.setting||(this._tracked=!0,this.trackApi(U({type:this.widgetType,id:this.widgetID},e)))})),e?(this._tracked=!1,this.trackApi=e,this.widgetType=t,this.widgetID=r,this.setting=i,this.track=this._track):this.track=$n}}var Zn={fence:{match:c.defaultRules.fence.match,order:1,parse:(e,t,r)=>e[3]},paragraph:{match:c.defaultRules.paragraph.match,order:2,parse:(e,t,r)=>e[1]}},Jn=c.parserFor(Zn),Qn={parseToArray:e=>{var t=e.replace(/^\n\s*\n/,"")+"\n\n";return Jn(t,{inline:!1})},joinFromArray:e=>e.join("\n\n")};class es{constructor(){V(this,"previousContent",null),V(this,"runLinter",p(((e,t)=>{"undefined"!=typeof KA&&e!==this.previousContent&&(this.previousContent=e,""!==e?fetch("/api/internal/translations/lint_poentry?preview=1&lang=en",{headers:{"Content-Type":"application/json"},body:JSON.stringify({msgid:e,msgstr:e,format:"perseus_text",filename:""}),method:"POST"}).then((e=>e.status>=400?{status:"error",message:"Could not run i18n linter."}:e.json()),(e=>({status:"error",message:"Could not run i18n linter."}))).then((e=>{"error"===e.status?t(["Some part of this text makes it untranslatable. The specific message from the i18n linter was: "+e.message.replace(/\n/g," ")]):t([])})):t([]))}),1e3))}applyLintErrors(e,t){if(t.length){var r=t.join("\n\n");e.unshift({content:{type:"text",content:""},insideTable:!1,message:r,ruleName:"legacy-error",severity:st.Severity.ERROR,type:"lint"})}}}class ts extends a.Component{render(){var e=this.props.className?"paragraph "+this.props.className:"paragraph";return a.createElement("div",{className:e,"data-perseus-component-index":this.props.translationIndex,"data-perseus-paragraph-index":this.props.paragraphIndex},this.props.children)}}var rs=e=>e.replace(/\{align[*]?\}/g,"{aligned}").replace(/[\u00a0]/g," "),{interactiveSizes:is}=te,ns={SMALL:"small",MEDIUM:"medium",LARGE:"large",XLARGE:"xlarge"},ss=e=>e?e<=512?ns.SMALL:e<=688?ns.MEDIUM:ns.LARGE:ns.MEDIUM,os=e=>e===ns.SMALL?[is.defaultBoxSizeSmall,is.defaultBoxSizeSmall]:[is.defaultBoxSize,is.defaultBoxSize],as=Object.freeze({__proto__:null,containerSizeClass:ns,getClassFromWidth:ss,getInteractiveBoxFromSizeClass:os}),ls=["default"],ps={},hs={},cs=(e,t)=>{ps[e]=t},ds=e=>{e.forEach((e=>{cs(e.name,e)})),ks()},us=e=>l.has(ps,e)?ps[e].getWidget?ps[e].getWidget():ps[e].widget:null,ms=e=>ps[e]?ps[e].version||{major:0,minor:0}:null,gs=()=>{var e={};return l.each(l.keys(ps),(function(t){e[t]=ms(t)})),e},fs=e=>{var t=ps[e.type].accessible;return"function"==typeof t?t(e.options):!!t},vs=e=>{var t=e.type;if(!l.isString(t))throw new he("widget type must be a string, but was: "+t,le.Internal);var r=ps[t];if(null==r)return e;var i=e.version||{major:0,minor:0},n=r.version||{major:0,minor:0};if(i.major>n.major||i.major===n.major&&i.minor>n.minor)return e;var s=l.clone(e.options)||{},o=r.propUpgrades||{};if(0!==l.keys(s).length)for(var a=i.major+1;a<=n.major;a++)o[String(a)]?s=o[String(a)](s):pe.error("No upgrade found for widget. Cannot render.",le.Internal,{loggedMetadata:{type:t,fromMajorVersion:a-1,toMajorVersion:a}});s=U(U({},t in hs?hs[t].defaultProps:{}),s);var p=e.alignment;null!=p&&"default"!==p||(p=xs(t)[0]);var h=e.static;return null==h&&(h=false),l.extend({},e,{version:n,graded:null==e.graded||e.graded,alignment:p,static:h,options:s})},bs=(e,t)=>{var r=e.type,i=ps[r];return null==i?e.options:(e.static?Es(r)||l.identity:i.transform||l.identity)(e.options,t)},ys=(e,t)=>{if(!t)throw new he("traverseRenderer must be provided, but was not",le.Internal);if(!e||!e.type||!ps[e.type])return e;var r=ps[e.type],i=e.options;if(r.traverseChildWidgets&&i){var n=r.traverseChildWidgets(i,t);return l.extend({},e,{options:n})}return e},xs=e=>{var t=ps[e];return t&&t.supportedAlignments||ls},Cs=e=>{var t=ps[e];return t&&(t.getDefaultAlignment?t.getDefaultAlignment():t.defaultAlignment)||"block"},ws=["block","inline-block","inline","float-left","float-right","full-width"],ks=()=>{l.each(ps,(function(e){if(e.defaultAlignment&&!l.contains(ws,e.defaultAlignment))throw new he("Widget '"+e.displayName+"' has an invalid defaultAlignment value: "+e.defaultAlignment,le.InvalidInput);if(e.supportedAlignments){var t=l.difference(e.supportedAlignments,ws);if(t.length)throw new he("Widget '"+e.displayName+"' has an invalid value for supportedAlignments: "+t.join(" "),le.InvalidInput)}}))},Es=e=>{var t=ps[e];return t&&t.staticTransform},Ss=e=>{var t=ps[e];return t&&t.tracking||""},_s=e=>{var t=ps[e];return t&&t.isLintable||false},Ms=Object.freeze({__proto__:null,registerWidget:cs,registerWidgets:ds,registerEditors:e=>{e.forEach((e=>{if(!e.widgetName)throw new he("Editor ".concat(e.displayName," doesn't have a widgetName property"),le.Internal);hs[e.widgetName]=e}))},getWidget:us,getEditor:e=>l.has(hs,e)?hs[e]:null,getTransform:e=>l.has(ps,e)?ps[e].transform||l.identity:null,getVersion:ms,getVersionVector:gs,getPublicWidgets:()=>l.pick(ps,l.reject(l.keys(ps),(function(e){return ps[e].hidden}))),isAccessible:fs,getAllWidgetTypes:()=>l.keys(ps),upgradeWidgetInfoToLatestVersion:vs,getRendererPropsForWidgetInfo:bs,traverseChildWidgets:ys,getSupportedAlignments:xs,getDefaultAlignment:Cs,validateAlignments:ks,supportsStaticMode:e=>{var t=ps[e];return t&&null!=t.staticTransform},getStaticTransform:Es,getTracking:Ss,isLintable:_s});class Ts extends a.Component{constructor(){super(...arguments),V(this,"state",{sizeClass:ns.MEDIUM,widgetProps:this.props.initialProps}),V(this,"getWidget",(()=>this.refs.widget)),V(this,"replaceWidgetProps",(e=>{this.setState({widgetProps:e})}))}componentDidMount(){if(this.state.widgetProps.apiOptions.isMobile){var e=g.findDOMNode(this).offsetWidth;this.setState({sizeClass:ss(e)})}}render(){var e=o({"perseus-widget-container":!0,"widget-highlight":this.props.shouldHighlight,"widget-nohighlight":!this.props.shouldHighlight}),t=this.props.type,r=us(t);if(null==r)return console.warn("Widget type '".concat(t,"' not found!")),a.createElement("div",{className:e});var i=this.state.widgetProps.alignment;"default"===i&&(i=Cs(t)),e+=" widget-"+i;var n=this.state.widgetProps.apiOptions,s=this.state.widgetProps.static||n.readOnly,l={width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:3},p=_s(t)?this.props.linterContext:U(U({},this.props.linterContext),{},{highlightLint:!1});return a.createElement("div",{className:e,style:s?{position:"relative",overflow:"visible"}:{}},a.createElement(r,j({},this.state.widgetProps,{linterContext:p,containerSizeClass:this.state.sizeClass,ref:"widget"})),s&&a.createElement("div",{style:l}))}UNSAFE_componentWillReceiveProps(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(e,t){return this.props.shouldHighlight!==e.shouldHighlight||this.props.type!==e.type||this.state.widgetProps!==t.widgetProps||this.state.sizeClass!==t.sizeClass}}V(Ts,"defaultProps",{linterContext:Gt});var{mapObject:Is,mapObjectFromArray:Ps}=Er,As=/\S/,Ns=/(web\+graphie|https):\/\/[^\s]*/,Rs=()=>{},Fs=["content","problemNum","widgets"];class Ds extends a.Component{constructor(e,t){var r;super(e,t),r=this,V(this,"_currentFocus",void 0),V(this,"_foundTextNodes",void 0),V(this,"_interactionTrackers",void 0),V(this,"_isMounted",void 0),V(this,"_isTwoColumn",void 0),V(this,"_notGorgon",void 0),V(this,"lastRenderedMarkdown",void 0),V(this,"reuseMarkdown",void 0),V(this,"translationIndex",void 0),V(this,"widgetIds",void 0),V(this,"getApiOptions",(()=>U(U({},Kt.defaults),this.props.apiOptions))),V(this,"_getInitialWidgetState",(e=>{var t=this._getAllWidgetsInfo(e);return{widgetInfo:t,widgetProps:this._getAllWidgetsStartProps(t,e)}})),V(this,"_getAllWidgetsInfo",(e=>Is(e.widgets,((e,t)=>{if(!e.type||!e.alignment){var r={};e.type||(r.type=t.split(" ")[0]),e.alignment||(r.alignment="default"),e=l.extend({},e,r)}return vs(e)})))),V(this,"_getAllWidgetsStartProps",((e,t)=>Is(e,(e=>bs(e,t.problemNum))))),V(this,"_getDefaultWidgetInfo",(e=>{var t=De.rTypeFromWidgetId.exec(e);return null==t?{}:{type:t[1],graded:!0,options:{}}})),V(this,"_getWidgetInfo",(e=>this.state.widgetInfo[e]||this._getDefaultWidgetInfo(e))),V(this,"renderWidget",((e,t,r)=>{var i=this.state.widgetInfo[t];if(i&&"full-width"===i.alignment&&(r.foundFullWidth=!0),i){var n=i&&i.type||e,s=l.contains(this.props.highlightedWidgets,t);return a.createElement(Xn,{key:"container:"+t},a.createElement(Ts,{ref:"container:"+t,type:n,initialProps:this.getWidgetProps(t),shouldHighlight:s,linterContext:Wt.pushContextStack(this.props.linterContext,"widget")}))}return null})),V(this,"getWidgetProps",(e=>{var t=this.getApiOptions(),i=this.state.widgetProps[e]||{},n=null,s=this.state.widgetInfo[e];this.props.reviewMode&&s&&(n=s.options),this._interactionTrackers||(this._interactionTrackers={});var o=this._interactionTrackers[e];return o||(o=this._interactionTrackers[e]=new Kn(t.trackInteraction,s&&s.type,e,Ss(s&&s.type))),U(U({},i),{},{ref:e,widgetId:e,alignment:s&&s.alignment,static:s&&s.static&&!this.props.problemNum,problemNum:this.props.problemNum,apiOptions:this.getApiOptions(),keypadElement:this.props.keypadElement,questionCompleted:this.props.questionCompleted,onFocus:l.partial(this._onWidgetFocus,e),onBlur:l.partial(this._onWidgetBlur,e),findWidgets:this.findWidgets,reviewModeRubric:n,onChange:function(t,i){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r._setWidgetProps(e,t,i,n)},trackInteraction:o.track,isLastUsedWidget:e===this.state.lastUsedWidgetId})})),V(this,"getSerializedState",(e=>Is(e||this.state.widgetProps,((e,t)=>{var r=this.getWidgetInstance(t);return r&&r.getSerializedState?r.getSerializedState():e})))),V(this,"restoreSerializedState",((e,t)=>{var r=l.keys(e),i=l.keys(this.state.widgetProps);if(r.length===i.length&&l.intersection(r,i).length===r.length){var n=1,s=()=>{--n,t&&0===n&&t()};this.setState({widgetProps:Is(e,((e,t)=>{var r=this.getWidgetInstance(t);if(r&&r.restoreSerializedState){++n;var i=r.restoreSerializedState(e,s);return l.extend({},this.state.widgetProps[t],i)}return e}))},(()=>{setTimeout(s,0)}))}else pe.error("Refusing to restore bad serialized state:",le.Internal,{loggedMetadata:{serializedState:JSON.stringify(e),currentProps:JSON.stringify(this.state.widgetProps)}})})),V(this,"showRationalesForCurrentlySelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{var t=this.getWidgetInstance(e);t&&t.showRationalesForCurrentlySelectedChoices&&t.showRationalesForCurrentlySelectedChoices(this._getWidgetInfo(e).options)}))})),V(this,"deselectIncorrectSelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{var t=this.getWidgetInstance(e);t&&t.deselectIncorrectSelectedChoices&&t.deselectIncorrectSelectedChoices()}))})),V(this,"findInternalWidgets",(e=>{var t;if("string"==typeof e)if(-1!==e.indexOf(" ")){var r=e;t=(e,t,i)=>e===r}else{var i=e;t=(e,t,r)=>t.type===i}else t=e;return this.widgetIds.filter((e=>{var r=this._getWidgetInfo(e),i=this.getWidgetInstance(e);return t(e,r,i)})).map(this.getWidgetInstance)})),V(this,"findWidgets",(e=>[...this.findInternalWidgets(e),...this.props.findExternalWidgets(e)])),V(this,"getWidgetInstance",(e=>{var t=this.refs["container:"+e];return t?t.getWidget():null})),V(this,"_onWidgetFocus",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!l.isArray(t))throw new he("widget props.onFocus focusPath must be an Array, but was"+JSON.stringify(t),le.Internal);r._setCurrentFocus([e].concat(t))})),V(this,"_onWidgetBlur",((e,t)=>{var r=this._currentFocus,i=[e].concat(t);l.isEqual(i,r)&&l.defer((()=>{l.isEqual(this._currentFocus,r)&&this._setCurrentFocus(null)}))})),V(this,"getContent",((e,t)=>t.jiptContent||e.content)),V(this,"shouldRenderJiptPlaceholder",((e,t)=>oe().JIPT.useJIPT&&null==t.jiptContent&&-1!==e.content.indexOf("crwdns"))),V(this,"replaceJiptContent",((e,t)=>{if(null==t)this.setState({jiptContent:e});else{/^\s*(`{3,}|~{3,})\s*(\S+)?\s*\n([\s\S]+?)\s*\1\s*$/.test(e)||(/\S\n\s*\n\S/.test(e)?e="$\\large{\\red{\\text{Please translate each paragraph to a single paragraph.}}}$":/^\s*$/.test(e)&&(e="$\\large{\\red{\\text{Translated paragraph is currently empty}}}$"));var r=this.getContent(this.props,this.state),i=Qn.parseToArray(r);i[t]=e,this.setState({jiptContent:Qn.joinFromArray(i)})}})),V(this,"outputMarkdown",((e,t)=>{if(l.isArray(e)){for(var r=t.key,i=[],n=!1,s=0;s<e.length;s++){t.key=s,t.paragraphIndex=s;var p=this.outputMarkdown(e[s],t),h="string"==typeof p;"string"==typeof p&&n?i[i.length-1]+=p:i.push(p),n=h}return t.key=r,i}this._foundTextNodes=!1,t.foundFullWidth=!1;var c,d=this.outputNested(e,t);return c=null!=this.translationIndex?null:o({"perseus-paragraph-centered":!this._foundTextNodes,"perseus-paragraph-full-width":t.foundFullWidth&&1===e.content.length}),a.createElement(ts,{key:t.key,className:c,translationIndex:this.translationIndex,paragraphIndex:t.paragraphIndex},a.createElement(Xn,null,d))})),V(this,"outputNested",((e,t)=>{if(l.isArray(e)){for(var r=t.key,i=[],n=!1,s=0;s<e.length;s++){t.key=s;var o=this.outputNested(e[s],t),a="string"==typeof o;"string"==typeof o&&n?i[i.length-1]+=o:i.push(o),n=a}return t.key=r,i}return this.outputNode(e,this.outputNested,t)})),V(this,"outputNode",((e,t,r)=>{var i=this.getApiOptions(),n=i.imagePlaceholder;if("widget"===e.type){var s=i.widgetPlaceholder;return s||(this._foundTextNodes=!0,l.contains(this.widgetIds,e.id)?a.createElement("span",{key:r.key,className:"renderer-widget-error"},["Widget [[","☃"," ",e.id,"]] already exists."].join("")):(this.widgetIds.push(e.id),this.renderWidget(e.widgetType,e.id,r)))}if("blockMath"===e.type){var o=rs(e.content),p={overflowX:"auto",overflowY:"hidden",paddingTop:10,paddingBottom:10,marginTop:-10,marginBottom:-10};if(i.isMobile){var h={marginLeft:-16,marginRight:-16},c={paddingLeft:16,paddingRight:16},d=U(U({},p),Os.mobileZoomableParentFix);return a.createElement("div",{key:r.key,className:"perseus-block-math",style:h},a.createElement(Xn,null,a.createElement("div",{className:"perseus-block-math-inner",style:U(U({},d),c)},a.createElement(Yn,null,o))))}return a.createElement("div",{key:r.key,className:"perseus-block-math"},a.createElement(Xn,null,a.createElement("div",{className:"perseus-block-math-inner",style:p},a.createElement(Qt.Consumer,null,(e=>{var{setAssetStatus:t}=e;return a.createElement(Gn,{setAssetStatus:t},o)})))))}if("math"===e.type){var u=e.content.replace(/\{align[*]?\}/g,"{aligned}");return a.createElement("span",{key:r.key,style:{whiteSpace:"nowrap"}},a.createElement(Xn,null,a.createElement("span",null),a.createElement(Qt.Consumer,null,(e=>{var{setAssetStatus:t}=e;return a.createElement(Gn,{onRender:this.props.onRender,setAssetStatus:t},u)})),a.createElement("span",null)))}if("image"===e.type){if(n)return n;var m=l.has(this.props.images,e.target)?this.props.images[e.target]:null,g=!r.inTable;return a.createElement(Xn,{key:r.key},a.createElement(Qt.Consumer,null,(t=>{var{setAssetStatus:r}=t;return a.createElement(Un,j({setAssetStatus:r,src:Ye.sanitizeUrl(e.target),alt:e.alt,title:e.title,responsive:g,onUpdate:this.props.onRender,zoomToFullSizeOnMobile:i.isMobile&&i.isArticle},m))})))}if("columns"===e.type)return this._isTwoColumn=!0,a.createElement(Xn,{key:r.key},Ye.ruleOutput(e,t,r));if("text"===e.type)return As.test(e.content)&&(this._foundTextNodes=!0),n&&Ns.test(e.content)?n:e.content;if("table"===e.type||"titledTable"===e.type){var f=Ye.ruleOutput(e,t,U(U({},r),{},{isMobile:i.isMobile,inTable:!0}));if(!i.isMobile)return f;var v={marginLeft:-16,marginRight:-16},b=U(U({},{paddingLeft:0,paddingRight:0}),Os.mobileZoomableParentFix),y=a.createElement("div",{style:U(U({},b),{},{overflowX:"auto"})},a.createElement(Xn,null,a.createElement(Vn,{animateHeight:!0},f)));return a.createElement("div",{style:v},y)}return a.createElement(Xn,{key:r.key},Ye.ruleOutput(e,t,r))})),V(this,"handleRender",(e=>{var t=this.props.onRender,r=e.onRender;if(t!==Rs||r!==Rs){var i=f(g.findDOMNode(this)).find("img");r!==Rs&&i.off("load",r),t!==Rs&&i.on("load",t)}t()})),V(this,"_setCurrentFocus",(e=>{var t,r,i=this.getApiOptions();if(t=e,r=this._currentFocus,!(null===t||null===r?t===r:l.every(t,((e,t)=>{if(null!=r)return l.isEqual(e,r[t])})))){var n=this._currentFocus;n&&this.blurPath(n),this._currentFocus=e,i.onFocusChange(this._currentFocus,n)}})),V(this,"focus",(()=>{for(var e,t,r,i=0;i<this.widgetIds.length;i++){var n=this.widgetIds[i],s=this.getWidgetInstance(n),o=s&&s.focus&&s.focus();if(o){e=n,t=o;break}}if(e)return"object"==typeof t?(r=[e].concat(t.path||[]),pe.error("Renderer received a focus result of type 'object' instead of the expected type 'boolean'",le.Internal,{loggedMetadata:{focusResult:JSON.stringify(t),currentProps:JSON.stringify(this.state.widgetProps)}})):r=[e],this._setCurrentFocus(r),!0})),V(this,"getDOMNodeForPath",(e=>{var t=l.first(e),r=l.rest(e),i=this.getWidgetInstance(t),n=i&&i.getDOMNodeForPath;return n?n(r):0===r.length?g.findDOMNode(i):void 0})),V(this,"getGrammarTypeForPath",(e=>{var t=l.first(e),r=l.rest(e),i=this.getWidgetInstance(t);if(i&&i.getGrammarTypeForPath)return i.getGrammarTypeForPath(r)})),V(this,"getInputPaths",(()=>{var e=[];return l.each(this.widgetIds,(t=>{var r=this.getWidgetInstance(t);if(r&&r.getInputPaths){var i=r.getInputPaths();l.each(i,(r=>{var i=[t].concat(r);e.push(i)}))}})),e})),V(this,"focusPath",(e=>{if(!l.isEqual(this._currentFocus,e)){this._currentFocus&&this.blurPath(this._currentFocus);var t=l.first(e),r=l.rest(e),i=this.getWidgetInstance(t);i&&i.focusInputPath&&i.focusInputPath(r)}})),V(this,"blurPath",(e=>{if(l.isEqual(this._currentFocus,e)){var t=l.first(e),r=l.rest(e);if(this.getWidgetInstance(t)){var i=this.getWidgetInstance(t);i&&i.blurInputPath&&i.blurInputPath(r)}}})),V(this,"blur",(()=>{this._currentFocus&&this.blurPath(this._currentFocus)})),V(this,"serialize",(()=>{var e={};return l.each(this.state.widgetInfo,(function(t,r){var i=this.getWidgetInstance(r).serialize();l.isEmpty(i)||(e[r]=i)}),this),e})),V(this,"emptyWidgets",(()=>l.filter(this.widgetIds,(e=>{var t=this._getWidgetInfo(e);if(t.static)return!1;var r=this.getWidgetInstance(e);if(r&&r.simpleValidate){var i=r.simpleValidate(t.options,null);return De.scoreIsEmpty(i)}})))),V(this,"_setWidgetProps",((e,t,r,i)=>{this.setState((r=>{var n=U(U({},r.widgetProps),{},{[e]:U(U({},r.widgetProps[e]),t)}),s=i?r.lastUsedWidgetId:e;return i||this.props.onSerializedStateUpdated(this.getSerializedState(n)),{lastUsedWidgetId:s,widgetProps:n}}),(()=>{setTimeout((()=>{var t=r&&r();i||this.props.onInteractWithWidget(e),!1!==t&&this._setCurrentFocus([e])}),0)}))})),V(this,"setInputValue",((e,t,r)=>{var i,n=l.first(e),s=l.rest(e),o=this.getWidgetInstance(n);null==o||null===(i=o.setInputValue)||void 0===i||i.call(o,s,t,r)})),V(this,"getUserInput",(()=>this.widgetIds.map((e=>{var t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),V(this,"getWidgetIds",(()=>this.widgetIds)),V(this,"getUserInputForWidgets",(()=>Ps(this.widgetIds,(e=>{var t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),V(this,"scoreWidgets",(()=>{var e=this.state.widgetInfo,t=this.getApiOptions().onInputError,r=l.filter(this.widgetIds,(t=>{var r=e[t],i=null==(null==r?void 0:r.graded)||r.graded,n=!(null==r||!r.static);return i&&!n})),i={};return l.each(r,(r=>{var n=e[r],s=this.getWidgetInstance(r);s&&s.simpleValidate&&(i[r]=s.simpleValidate(null==n?void 0:n.options,t))})),i})),V(this,"score",(()=>l.reduce(this.scoreWidgets(),De.combineScores,De.noScore))),V(this,"guessAndScore",(()=>[this.getUserInput(),this.score()])),V(this,"examples",(()=>{var e=this.widgetIds,t=l.compact(l.map(e,(e=>{var t=this.getWidgetInstance(e);return null!=t&&t.examples?t.examples():null})));return t.length&&l.all(t,(function(e){return l.isEqual(t[0],e)}))?t[0]:null})),V(this,"handleNotGorgonLintErrors",(e=>{this._isMounted&&this.setState({notGorgonLintErrors:e})})),this._notGorgon=new es,this.state=U({jiptContent:null,notGorgonLintErrors:[],lastUsedWidgetId:null},this._getInitialWidgetState(e))}componentDidMount(){this._isMounted=!0,this.handleRender({}),this._currentFocus=null,this.props.serializedState&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}UNSAFE_componentWillReceiveProps(e){l.isEqual(l.pick(this.props,Fs),l.pick(e,Fs))||this.setState(this._getInitialWidgetState(e))}shouldComponentUpdate(e,t){if(this.props.alwaysUpdate)return!0;var r=!l.isEqual(this.state,t);return!l.isEqual(this.props,e)||r}UNSAFE_componentWillUpdate(e,t){var r=this.shouldRenderJiptPlaceholder(this.props,this.state),i=this.shouldRenderJiptPlaceholder(e,t),n=this.getContent(this.props,this.state),s=this.getContent(e,t),o=this.props.highlightedWidgets,a=e.highlightedWidgets;this.reuseMarkdown=!r&&!i&&n===s&&l.isEqual(this.state.notGorgonLintErrors,t.notGorgonLintErrors)&&(!this.props.linterContext.highlightLint||l.isEqual(this.props.widgets,e.widgets))&&this.props.linterContext.highlightLint===e.linterContext.highlightLint&&o===a}componentDidUpdate(e,t){this.handleRender(e),l.each(this.widgetIds,(e=>{var t=this.refs["container:"+e];t&&t.replaceWidgetProps(this.getWidgetProps(e))})),this.props.serializedState&&!l.isEqual(this.props.serializedState,this.getSerializedState())&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}componentWillUnmount(){this.widgetIds=[],null!=this.translationIndex&&oe().rendererTranslationComponents.removeComponentAtIndex(this.translationIndex),this._isMounted=!1}render(){var e=this.getApiOptions(),{KatexProvider:t}=oe();if(this.reuseMarkdown)return this.lastRenderedMarkdown;var r=this.getContent(this.props,this.state);if(this.widgetIds=[],this.shouldRenderJiptPlaceholder(this.props,this.state)&&(this.translationIndex||(this.translationIndex=oe().rendererTranslationComponents.addComponent(this)),!e.isArticle))return a.createElement(t,null,a.createElement("div",{"data-perseus-component-index":this.translationIndex},r));this._isTwoColumn=!1;var i=Ye.parse(r,{isJipt:null!=this.translationIndex});if(this.props.linterContext.highlightLint){var n=U({content:this.props.content,widgets:this.props.widgets},this.props.linterContext);Wt.runLinter(i,n,!0),this._notGorgon.applyLintErrors(i,[...this.state.notGorgonLintErrors,...this.props.legacyPerseusLint||[]])}var s=this.outputMarkdown(i,{baseElements:e.baseElements}),l=o({[Zt.RENDERER]:!0,[Zt.RESPONSIVE_RENDERER]:!0,[Zt.TWO_COLUMN_RENDERER]:this._isTwoColumn});return this.lastRenderedMarkdown=a.createElement(t,null,a.createElement("div",{className:l},s)),this.lastRenderedMarkdown}}V(Ds,"defaultProps",{content:"",widgets:{},images:{},highlightedWidgets:[],questionCompleted:!1,onRender:Rs,onInteractWithWidget:function(){},findExternalWidgets:()=>[],alwaysUpdate:!1,reviewMode:!1,serializedState:null,onSerializedStateUpdated:()=>{},linterContext:Gt});var Os={mobileZoomableParentFix:{transform:"translate3d(0,0,0)"}},Ls={fontSize:"150%"},Bs={fontSize:"120%"},zs={fontSize:"130%"},qs=[()=>[a.createElement("span",{key:"plus",style:Bs},"+"),"+"],()=>[a.createElement("span",{key:"minus",style:Ls},"-"),"-"],e=>{var{TeX:t}=oe();return e.convertDotToTimes?[a.createElement(t,{key:"times",style:Ls},s.doNotTranslate("\\times")),"\\times"]:[a.createElement(t,{key:"times",style:Ls},s.doNotTranslate("\\cdot")),"\\cdot"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"frac",style:Ls},s.doNotTranslate("\\frac{x}{y}")),e=>{var t=e.latex();e.typedText("/"),e.latex()===t&&e.cmd("\\frac")}]}],Hs={basic:qs,"basic+div":qs.concat([()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"div"},s.doNotTranslate("\\div")),"\\div"]}]),trig:[()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"sin"},s.doNotTranslate("\\sin")),"\\sin"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"cos"},s.doNotTranslate("\\cos")),"\\cos"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"tan"},s.doNotTranslate("\\tan")),"\\tan"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"theta",style:zs},s.doNotTranslate("\\theta")),"\\theta"]},()=>{var{TeX:e}=oe();return[a.createElement("span",{key:"phi"},a.createElement("span",{className:"perseus-sr-only"},s.doNotTranslate("phi")),a.createElement(e,{key:"pi",style:zs},s.doNotTranslate("\\phi"))),"\\phi"]}],prealgebra:[()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"sqrt"},s.doNotTranslate("\\sqrt{x}")),"\\sqrt"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"nthroot"},s.doNotTranslate("\\sqrt[3]{x}")),e=>{e.typedText("nthroot3"),e.keystroke("Right")}]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"pow",style:Bs},s.doNotTranslate("a^b")),e=>{var t=e.latex();e.typedText("^"),e.latex()===t&&e.typedText("a^b")}]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"pi",style:Bs},s.doNotTranslate("\\pi")),"\\pi"]}],logarithms:[()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"log"},s.doNotTranslate("\\log")),"\\log"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"ln"},s.doNotTranslate("\\ln")),"\\ln"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"log_b"},s.doNotTranslate("\\log_b")),e=>{e.typedText("log_"),e.keystroke("Right"),e.typedText("("),e.keystroke("Left"),e.keystroke("Left")}]}],"basic relations":[()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"eq"},"="),"="]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"lt"},s.doNotTranslate("\\lt")),"\\lt"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"gt"},s.doNotTranslate("\\gt")),"\\gt"]}],"advanced relations":[()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"neq"},s.doNotTranslate("\\neq")),"\\neq"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"leq"},s.doNotTranslate("\\leq")),"\\leq"]},()=>{var{TeX:e}=oe();return[a.createElement(e,{key:"geq"},s.doNotTranslate("\\geq")),"\\geq"]}]},Ws=h.arrayOf(h.oneOf(l(Hs).keys()));class Us extends a.Component{render(){var e=l.sortBy(this.props.sets,(e=>l.keys(Hs).indexOf(e))),t=l(e).map((e=>Hs[e])),r=l(t).map((e=>e.map((e=>{var t=e(this.props);return a.createElement("button",{onClick:()=>this.props.onInsert(t[1]),className:"tex-button",key:t[0].key,type:"button"},t[0])})))),i=l(r).map(((e,t)=>a.createElement("div",{className:"clearfix tex-button-row",key:this.props.sets[t]},e)));return a.createElement("div",{className:"".concat(this.props.className||""," preview-measure")},i)}}V(Us,"propTypes",{sets:Ws.isRequired,onInsert:h.func.isRequired,className:h.string}),V(Us,"buttonSets",Hs),V(Us,"buttonSetsType",Ws);var Gs=h;class Vs extends a.Component{constructor(){super(...arguments),V(this,"mouseDown",void 0),V(this,"state",{focused:!1}),V(this,"handleFocus",(()=>{this.setState({focused:!0})})),V(this,"handleMouseDown",(e=>{var t=g.findDOMNode(this).contains(e.target);this.mouseDown=t,t||this.setState({focused:!1})})),V(this,"handleMouseUp",(()=>{this.mouseDown&&this.focus(),this.mouseDown=!1})),V(this,"handleBlur",(e=>{this.mouseDown||g.findDOMNode(this).contains(e.relatedTarget)||this.setState({focused:!1})})),V(this,"_shouldShowButtons",(()=>"always"===this.props.buttonsVisible||"never"!==this.props.buttonsVisible&&this.state.focused)),V(this,"insert",(e=>{var t=this.mathField();l(e).isFunction()?e(t):"\\"===e[0]?t.cmd(e).focus():t.write(e).focus(),t.focus()})),V(this,"mathField",(e=>k.getInterface(2).MathField(g.findDOMNode(this.refs.mathinput),e))),V(this,"focus",(()=>{this.mathField().focus(),this.setState({focused:!0})})),V(this,"blur",(()=>{this.mathField().blur(),this.setState({focused:!1})}))}render(){var e=o({"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=a.createElement(Us,{sets:this.props.buttonSets,className:"math-input-buttons absolute",convertDotToTimes:this.props.convertDotToTimes,onInsert:this.insert})),a.createElement("div",{style:{display:"inline-block"}},a.createElement("div",{style:{display:"inline-block"}},a.createElement("span",{className:e,ref:"mathinput","aria-label":this.props.labelText,onFocus:this.handleFocus,onBlur:this.handleBlur})),a.createElement("div",{style:{position:"relative"},onBlur:this.handleBlur},t))}componentWillUnmount(){window.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}componentDidMount(){window.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp);var e=!1;this.mathField({autoCommands:"pi theta phi sqrt nthroot",charsThatBreakOutOfSupSub:"+-*/=<>≠≤≥",supSubsRequireOperand:!0,spaceBehavesLikeTab:!0,handlers:{edited:t=>{var r=t.latex();if(r=r.replace(/<>/g,"\\ne"),this.props.convertDotToTimes){r=r.replace(/\\cdot/g,"\\times");var i=t.__controller.cursor[k.L];i&&"\\cdot "===i.ctrlSeq&&(t.__controller.backspace(),t.cmd("\\times"))}else r=r.replace(/\\times/g,"\\cdot");e&&this.props.value!==r&&this.props.onChange(r)},enter:()=>{f(g.findDOMNode(this.refs.mathinput)).submit()},upOutOf:e=>{e.typedText("^")}}}),this.mathField().latex(this.props.value),e=!0}}function js(e,t,r){var i=e.indexOf("{",t)+1,n=function(e,t){for(var r=0,i=t,n=e.length;i<n;i++){var s=e[i];if("{"===s?r++:"}"===s&&r--,r<0)return i}return e.length}(e,i);return{endpoint:n,expression:Xs(e.substring(i,n),r)}}function Ys(e,t){var r=e.indexOf("\\frac",t),i=e.indexOf("\\dfrac",t);return r>-1&&i>-1?Math.min(r,i):r>-1?r:i>-1?i:-1}function Xs(e,t){if(!e)return"";for(var r="",i=0,n=Ys(e,i);n>-1;){r+=e.substring(i,n);var s=js(e,i=n,t),o=js(e,i=s.endpoint+1,t);i=o.endpoint+1,r.length&&(r+=" "),r+=t(s.expression,o.expression),n=Ys(e,i)}return r+=e.slice(i)}V(Vs,"propTypes",{value:Gs.string,onChange:Gs.func.isRequired,convertDotToTimes:Gs.bool,buttonsVisible:Gs.oneOf(["always","never","focused"]),buttonSets:Us.buttonSetsType.isRequired,labelText:h.string,onFocus:Gs.func,onBlur:Gs.func}),V(Vs,"defaultProps",{value:"",convertDotToTimes:!1,buttonsVisible:"focused"});var $s=function(e){return Xs(e,(function(e,t){return e+"/"+t})).replace("\\%","%")},Ks=function(e){function t(e){return e.indexOf("\\frac")>-1||e.indexOf("\\dfrac")>-1}return Xs(e,(function(e,r){return(t(e)||t(r)?"\\dfrac":"\\frac")+" {"+e+"}{"+r+"}"}))};class Zs extends a.Component{constructor(){super(...arguments),V(this,"state",{focused:!1,selectorNamespace:l.uniqueId("math-output")}),V(this,"_getInputClassName",(()=>{var e="math-output "+Zt.INPUT+" "+Zt.INTERACTIVE;return this.state.focused&&(e+=" "+Zt.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),V(this,"_getDisplayValue",(e=>Ks(null!=e?""+e:""))),V(this,"getValue",(()=>this.props.value)),V(this,"focus",(()=>{this.state.focused||(this.props.onFocus(),this._bindBlurHandler(),this.setState({focused:!0}))})),V(this,"blur",(()=>{this.state.focused&&(this.props.onBlur(),this._unbindBlurHandler(),this.setState({focused:!1}))})),V(this,"_bindBlurHandler",(()=>{f(document).bind("vclick."+this.state.selectorNamespace,(e=>{f(e.target).closest(g.findDOMNode(this)).length||this.blur()}))})),V(this,"_unbindBlurHandler",(()=>{f(document).unbind("."+this.state.selectorNamespace)}))}render(){var{TeX:e}=oe();return a.createElement("span",{ref:"input",className:this._getInputClassName(),"aria-label":this.props.labelText,onMouseDown:this.focus,onTouchStart:this.focus},a.createElement("div",{style:{textAlign:"center"}},a.createElement(e,null,this._getDisplayValue(this.props.value))))}componentWillUnmount(){this._unbindBlurHandler()}}V(Zs,"propTypes",{value:h.oneOfType([h.string,h.number]),className:h.string,labelText:h.string,onFocus:h.func,onBlur:h.func}),V(Zs,"defaultProps",{value:"",onFocus:function(){},onBlur:function(){}});var Js=["labelText"];class Qs extends a.Component{constructor(){super(...arguments),V(this,"focus",(()=>{g.findDOMNode(this).focus()})),V(this,"blur",(()=>{g.findDOMNode(this).blur()})),V(this,"getValue",(()=>{var e;return null===(e=g.findDOMNode(this))||void 0===e?void 0:e.value})),V(this,"getStringValue",(()=>{var e;return null===(e=g.findDOMNode(this))||void 0===e?void 0:e.value.toString()})),V(this,"setSelectionRange",((e,t)=>{g.findDOMNode(this).setSelectionRange(e,t)})),V(this,"getSelectionStart",(()=>g.findDOMNode(this).selectionStart)),V(this,"getSelectionEnd",(()=>g.findDOMNode(this).selectionEnd))}render(){var e=this.props,{labelText:t}=e,r=Y(e,Js);return a.createElement("input",j({},r,{type:"text","aria-label":t,onChange:e=>this.props.onChange(e.target.value)}))}}V(Qs,"propTypes",{value:h.string,onChange:h.func.isRequired,className:h.string,labelText:h.string,onFocus:h.func,onBlur:h.func,disabled:h.bool}),V(Qs,"defaultProps",{value:"",disabled:!1});var eo=w({displayName:"Triangle",propTypes:{color:h.string.isRequired,left:h.number.isRequired,top:h.number.isRequired,width:h.number.isRequired,height:h.number.isRequired,horizontalDirection:h.oneOf(["left","right"]).isRequired,verticalDirection:h.oneOf(["top","bottom"]).isRequired},render:function(){var e,t,r,i,n="".concat(this.props.width,"px solid transparent");"right"===this.props.horizontalDirection?e=n:t=n;var s="".concat(this.props.height,"px solid ").concat(this.props.color);return"top"===this.props.verticalDirection?r=s:i=s,a.createElement("div",{style:{display:"block",height:0,width:0,position:"absolute",left:this.props.left,top:this.props.top,borderLeft:e,borderRight:t,borderTop:r,borderBottom:i}})}}),to=w({displayName:"TooltipArrow",propTypes:{position:h.string,visibility:h.string,left:h.number,top:h.number,color:h.string.isRequired,border:h.string.isRequired,width:h.number.isRequired,height:h.number.isRequired,horizontalDirection:h.oneOf(["left","right"]).isRequired,verticalDirection:h.oneOf(["top","bottom"]).isRequired},getDefaultProps:function(){return{position:"relative",visibility:"visible",left:0,top:0}},render:function(){var e="top"===this.props.verticalDirection,t=e?0:1,r=e?0:-1;return a.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:10}},a.createElement(eo,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.border,left:0,top:r,width:this.props.width+2,height:this.props.height+2}),a.createElement(eo,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.color,left:1,top:t,width:this.props.width,height:this.props.height}))}}),ro={top:{top:"-100%"},bottom:{top:0}},io={left:{targetLeft:0},right:{targetLeft:"100%"}},no={left:{tooltipLeft:0,arrowLeft:e=>0},right:{tooltipLeft:"-100%",arrowLeft:e=>-e-2}},so=w({displayName:"Tooltip",propTypes:{show:h.bool.isRequired,className:h.string,arrowSize:h.number,borderColor:h.string,verticalPosition:h.oneOf(Object.keys(ro)),horizontalPosition:h.oneOf(Object.keys(io)),horizontalAlign:h.oneOf(Object.keys(no)),children:h.arrayOf(h.element).isRequired,targetContainerStyle:h.any},getDefaultProps:function(){return{className:"",arrowSize:10,borderColor:"#ccc",verticalPosition:"bottom",horizontalPosition:"left",horizontalAlign:"left",targetContainerStyle:{}}},getInitialState:function(){return{height:null}},componentDidMount:function(){this._updateHeight()},UNSAFE_componentWillReceiveProps:function(){this.setState({height:null})},componentDidUpdate:function(){this._updateHeight()},_renderToolTipDiv:function(e){var t,r,i=Object.assign({},io[this.props.horizontalPosition],no[this.props.horizontalAlign],ro[this.props.verticalPosition]);return e?(t=a.createElement(to,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,position:"absolute",color:"white",border:this.props.borderColor,left:i.arrowLeft(this.props.arrowSize),top:2-this.props.arrowSize,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),r=a.createElement(to,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,visibility:"hidden",color:"white",border:this.props.borderColor,left:i.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10})):(t=a.createElement(to,{verticalDirection:"bottom",horizontalDirection:this.props.horizontalAlign,color:"white",border:this.props.borderColor,left:i.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),r=null),a.createElement("div",{style:{position:"relative",height:0,display:this.props.show?"block":"none"}},a.createElement("div",{ref:"tooltipContainer",className:"tooltipContainer",style:{position:"absolute",height:this.state.height||void 0,left:i.targetLeft}},t,a.createElement("div",{className:this.props.className,ref:"tooltipContent",style:{position:"relative",top:i.top,left:i.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:9}},this.props.children.slice(1)),r))},_updateHeight:function(){var e=g.findDOMNode(this.refs.tooltipContainer).offsetHeight;e!==this.state.height&&this.setState({height:e})},render:function(){var e="top"===this.props.verticalPosition;return a.createElement("span",null,e&&this._renderToolTipDiv(e),a.createElement("div",{style:this.props.targetContainerStyle},this.props.children[0]),!e&&this._renderToolTipDiv())}}),{captureScratchpadTouchStart:oo}=De;class ao extends a.Component{constructor(){super(...arguments),V(this,"state",{focused:!1,showExamples:!1}),V(this,"_getUniqueId",(()=>"input-with-examples-".concat(btoa(this.props.id).replace(/=/g,"")))),V(this,"_getInputClassName",(()=>{if("tex"===this.props.type)return this.props.className;var e=Zt.INPUT+" "+Zt.INTERACTIVE;return this.state.focused&&(e+=" "+Zt.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),V(this,"_getPropsForInputType",(()=>{var e={"aria-describedby":this._getUniqueId(),ref:"input",className:this._getInputClassName(),labelText:this.props.labelText,value:this.props.value,onFocus:this._handleFocus,onBlur:this._handleBlur,disabled:this.props.disabled};return"tex"===this.props.type?e:(l.extend(e,{onChange:this.props.onChange,onTouchStart:oo}),"math"===this.props.type?l.extend({buttonSet:this.props.buttonSet,buttonsVisible:this.props.buttonsVisible,convertDotToTimes:this.props.convertDotToTimes},e):"text"===this.props.type?l.extend({autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:"false"},e):void 0)})),V(this,"_getComponentForInputType",(()=>{switch(this.props.type){case"tex":return Zs;case"math":return Vs;case"text":return Qs;default:return null}})),V(this,"_renderInput",(()=>{var e=this._getPropsForInputType(),t=this._getComponentForInputType();return a.createElement(t,e)})),V(this,"_handleFocus",(()=>{this.props.onFocus(),this.setState({focused:!0,showExamples:!0})})),V(this,"show",(()=>{this.setState({showExamples:!0})})),V(this,"hide",(()=>{this.setState({showExamples:!1})})),V(this,"_handleBlur",(()=>{this.props.onBlur(),this.setState({focused:!1,showExamples:!1})})),V(this,"focus",(()=>{this.refs.input.focus()})),V(this,"blur",(()=>{this.refs.input.blur()})),V(this,"handleChange",(e=>{this.props.onChange(e.target.value)}))}render(){var e=this._renderInput();if("tex"===this.props.type)return e;var t=l.map(this.props.examples,(e=>"- "+e)).join("\n"),r=this.props.shouldShowExamples&&this.state.showExamples;return a.createElement(so,{ref:"tooltip",className:"perseus-formats-tooltip preview-measure",horizontalPosition:"left",horizontalAlign:"left",verticalPosition:"bottom",arrowSize:10,borderColor:"#ccc",show:r},e,a.createElement("div",{id:this._getUniqueId()},a.createElement(Ds,{content:t,linterContext:Wt.pushContextStack(this.props.linterContext,"input-with-examples")})))}}V(ao,"propTypes",{type:h.oneOf(["math","text","tex"]),value:h.string,onChange:h.func.isRequired,className:h.string,examples:h.arrayOf(h.string).isRequired,shouldShowExamples:h.bool,convertDotToTimes:h.bool,buttonSet:h.string,buttonsVisible:h.oneOf(["always","never","focused"]),labelText:h.string,onFocus:h.func,onBlur:h.func,disabled:h.bool,id:h.string.isRequired,linterContext:Ut}),V(ao,"defaultProps",{type:"text",shouldShowExamples:!0,onFocus:function(){},onBlur:function(){},disabled:!1,linterContext:Gt});var lo=["key","ref","containerSizeClass","widgetId","onChange","problemNum","apiOptions","questionCompleted","findWidgets","onRemove","id","onBlur","onFocus","trackInteraction","keypadElement"],po='Usage:\n this.change({propName: 5}, callback);\n this.change("propName", 5, callback);\n this.change("propName")',ho=function(e,t,r){var i=l.omit(e.props,lo),n=l.extend(i,t);e.props.onChange(n,r)},co=function e(t,r,i,n){if(void 0===i)return l.partial(e,t,r);var s={};s[r]=i,ho(t,s,n)},uo=function(e,t,r){if(l.isObject(e)&&void 0===r)return ho(this,e,r=t);if("string"==typeof e)return co(this,e,t,r);throw new he("Invalid types sent to this.change(): "+l.toArray(arguments).join()+"\n"+po,le.Internal)},mo={onChange:h.func.isRequired},go=Object.freeze({__proto__:null,change:uo,propTypes:mo}),fo=s._("Sorry, I don't understand that!"),vo=e=>e.replace(/([_^])([^{])/g,"$1{$2}");class bo extends a.Component{constructor(){var t;super(...arguments),t=this,V(this,"displayName","Expression"),V(this,"state",{showErrorTooltip:!1,showErrorText:!1}),V(this,"componentDidMount",(()=>{this._isMounted=!0})),V(this,"componentDidUpdate",(e=>{l.isEqual(this.props.value,e.value)&&l.isEqual(this.props.functions,e.functions)||(clearTimeout(this.errorTimeout),this.parse(this.props.value,this.props).parsed?this.setState({showErrorTooltip:!1}):this.errorTimeout=setTimeout((()=>{!1!==this.props.apiOptions.onInputError(null,this.props.value,fo)&&this.setState({showErrorTooltip:!0})}),2e3))})),V(this,"componentWillUnmount",(()=>{clearTimeout(this.errorTimeout),this._isMounted=!1})),V(this,"_isMounted",!1),V(this,"errorTimeout",null),V(this,"simpleValidate",((e,t)=>(t=t||function(){},bo.validate(this.getUserInput(),e,t)))),V(this,"getUserInput",(()=>bo.getUserInputFromProps(this.props))),V(this,"change",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return uo.apply(t,r)})),V(this,"parse",((t,r)=>{var i=l.pick(r||this.props,"functions");return l.extend(i,{decimal_separator:s.getDecimalSeparator()}),e.parse(vo(t),i)})),V(this,"changeAndTrack",((e,t)=>{this.change("value",e,t),this.props.trackInteraction()})),V(this,"_handleFocus",(()=>{this.props.onFocus([])})),V(this,"_handleBlur",(()=>{this.props.onBlur([])})),V(this,"focus",(()=>(this.props.apiOptions.customKeypad&&this.refs.input.focus(),!0))),V(this,"focusInputPath",(e=>{this.refs.input.focus()})),V(this,"blurInputPath",(e=>{this.refs.input.blur()})),V(this,"insert",(e=>{this.props.apiOptions.staticRender||this.refs.input.insert(e)})),V(this,"getInputPaths",(()=>[[]])),V(this,"getGrammarTypeForPath",(e=>"expression")),V(this,"setInputValue",((e,t,r)=>{this.props.onChange({value:t},r)}))}static validate(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},n=l.clone(r);l.extend(n,{decimal_separator:s.getDecimalSeparator()});var o,a,p,h,c,d=!0;for(var u of r.answerForms||[]){var m=(h=u,c=void 0,(c=e.parse(h.value,r)).parsed?me.expression.createValidatorFunctional(c.expr,l({}).extend(n,{simplify:h.simplify,form:h.form})):(pe.error("Unable to parse solution answer for expression",le.InvalidInput,{loggedMetadata:{rubric:JSON.stringify(r)}}),null));if(m){var g=m(t);if(g.correct){o=u,a=g.message||"";break}d=d&&g.empty,"correct"===u.considered&&g.ungraded&&!p&&(p=g)}}return o?"ungraded"===o.considered?{type:"invalid",message:!1===i(null,t,a)?null:a}:{type:"points",earned:"correct"===o.considered?1:0,total:1,message:a}:p?{type:"invalid",message:p.message,suppressAlmostThere:p.suppressAlmostThere}:d?{type:"invalid",message:null}:{type:"points",earned:0,total:1}}static getUserInputFromProps(e){return vo(e.value)}static getOneCorrectAnswerFromRubric(e){var t=(e.answerForms||[]).filter((e=>"correct"===e.considered));if(0!==t.length)return t[0].value}render(){if(this.props.apiOptions.customKeypad)return a.createElement(t,{ref:"input",value:this.props.value,keypadElement:this.props.keypadElement,onChange:this.changeAndTrack,onFocus:()=>{var e;null===(e=this.props.keypadElement)||void 0===e||e.configure(this.props.keypadConfiguration,(()=>{this._isMounted&&this._handleFocus()}))},onBlur:this._handleBlur});if(this.props.apiOptions.staticRender)return a.createElement(ao,{ref:"input",value:this.props.value,type:"tex",examples:[],shouldShowExamples:!1,onChange:this.changeAndTrack,onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,linterContext:this.props.linterContext});var e=a.createElement("span",{className:"error-tooltip",role:"tooltip"},a.createElement(so,{className:"error-text-container",horizontalPosition:"right",horizontalAlign:"left",verticalPosition:"top",arrowSize:10,borderColor:"#fcc335",show:this.state.showErrorText},a.createElement("span",{className:"error-icon","data-test-id":"test-error-icon",onMouseEnter:()=>{this.setState({showErrorText:!0})},onMouseLeave:()=>{this.setState({showErrorText:!1})},onClick:()=>{this.setState({showErrorText:!this.state.showErrorText})}},a.createElement(X,Ci)),a.createElement("div",{className:"error-text"},fo))),r=o({"perseus-widget-expression":!0,"show-error-tooltip":this.state.showErrorTooltip});return a.createElement("div",{className:r},a.createElement(Vs,{ref:"input",className:Zt.INTERACTIVE,value:this.props.value,onChange:this.changeAndTrack,convertDotToTimes:this.props.times,buttonsVisible:this.props.buttonsVisible||"focused",buttonSets:this.props.buttonSets,onFocus:this._handleFocus,onBlur:this._handleBlur}),this.state.showErrorTooltip&&e)}}V(bo,"defaultProps",{value:"",times:!1,functions:[],buttonSets:["basic","trig","prealgebra","logarithms"],onFocus:()=>{},onBlur:()=>{},apiOptions:Kt.defaults,linterContext:Gt});var yo=t=>{var i=r.EXPRESSION,n={},s={};for(var o of t.answerForms){var a=e.parse(o.value,t);a.parsed&&function(){var e=a.expr,t=e=>(e=>"pi"===e||"theta"===e)(e)?e.toUpperCase():e;for(var r of e.getVars())n[t(r)]=!0;for(var i of e.getConsts())s[t(i)]=!0}()}var l=Object.keys(n);l.sort();var p=Object.keys(s);p.sort();var h=[...l,...p];return h.length||h.push("PI"),{keypadType:i,extraKeys:h}},xo={name:"expression",displayName:"Expression / Equation",defaultAlignment:"inline-block",widget:bo,transform:e=>{var{times:t,functions:r,buttonSets:i,buttonsVisible:n}=e;return{keypadConfiguration:yo(e),times:t,functions:r,buttonSets:i,buttonsVisible:n}},version:{major:1,minor:0},propUpgrades:{1:e=>({times:e.times,buttonSets:e.buttonSets,functions:e.functions,buttonsVisible:e.buttonsVisible,answerForms:[{considered:"correct",form:e.form,simplify:e.simplify,value:e.value}]})},isLintable:!0};class Co extends a.Component{render(){var e=l.uniq(this.props.answers),t=l.map(e,(e=>a.createElement("dd",{key:e},e)));return a.createElement("dl",{className:"perseus-possible-answers"},a.createElement("dt",null,s.doNotTranslate("Correct Answer")),t)}}V(Co,"propTypes",{answers:h.arrayOf(h.string)});var wo=["keypadElement","onFocus","value"],ko=w({displayName:"SimpleKeypadInput",propTypes:{keypadElement:i,onFocus:h.func,value:h.oneOfType([h.string,h.number])},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},focus(){this.refs.input.focus()},blur(){this.refs.input.blur()},getValue:function(){return this.props.value},render(){var e=this,i=e.props,{keypadElement:n,onFocus:s,value:o}=i,l=Y(i,wo);return a.createElement(t,j({ref:"input",keypadElement:n,onFocus:()=>{n?n.configure({keypadType:r.FRACTION},(()=>{e._isMounted&&s&&s()})):s&&s()},value:null==o?"":""+o},l))}}),Eo=$s,So={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"}},_o={integer:function(e){return s._("an integer, like $6$")},proper:function(e){return"optional"===e.simplify?s._("a *proper* fraction, like $1/2$ or $6/10$"):s._("a *simplified proper* fraction, like $3/5$")},improper:function(e){return"optional"===e.simplify?s._("an *improper* fraction, like $10/7$ or $14/8$"):s._("a *simplified improper* fraction, like $7/4$")},mixed:function(e){return s._("a mixed number, like $1\\ 3/4$")},decimal:function(e){return s._("an *exact* decimal, like $0.75$")},percent:function(e){return s._("a percent, like $12.34\\%$")},pi:function(e){return s._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")}};class Mo extends a.Component{constructor(){super(...arguments),V(this,"shouldShowExamples",(()=>"number"!==this.props.answerType&&!this.props.apiOptions.staticRender)),V(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t)})),V(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),V(this,"_handleFocus",(()=>{this.props.onFocus([]);var{interactionCallback:e}=this.props.apiOptions;e&&e()})),V(this,"_handleBlur",(()=>{this.props.onBlur([])})),V(this,"focus",(()=>(this.refs.input.focus(),!0))),V(this,"focusInputPath",(e=>{this.refs.input.focus()})),V(this,"blurInputPath",(e=>{this.refs.input.blur()})),V(this,"getInputPaths",(()=>[[]])),V(this,"getGrammarTypeForPath",(e=>"number")),V(this,"setInputValue",((e,t,r)=>{this.props.onChange({currentValue:t},r)})),V(this,"getUserInput",(()=>Mo.getUserInputFromProps(this.props))),V(this,"simpleValidate",((e,t)=>(t=t||function(){},Mo.validate(this.getUserInput(),e,t)))),V(this,"examples",(()=>{var e=this.props.answerType,t=So[e].forms.split(/\s*,\s*/),r=l.map(t,(function(e){return _o[e](this.props)}),this);return[s._("**Your answer should be** ")].concat(r)}))}render(){if(this.props.apiOptions.customKeypad){var e=a.createElement(ko,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur});return this.props.rightAlign?a.createElement("div",{className:"perseus-input-right-align"},e):e}var t=this.props.reviewModeRubric,r=null,i=null;if(this.props.apiOptions.satStyling&&t){var n=this.simpleValidate(t);if(!(r="points"===n.type&&n.earned===n.total)){var s=String(t.value);t.inexact&&t.maxError&&(s+=" ± "+t.maxError);var l=[s];i=a.createElement(Co,{answers:l})}}var p={};p["perseus-input-size-"+this.props.size]=!0,p["perseus-input-right-align"]=this.props.rightAlign,p[Zt.CORRECT]=t&&r&&this.props.currentValue,p[Zt.INCORRECT]=t&&!r&&this.props.currentValue,p[Zt.UNANSWERED]=t&&!this.props.currentValue;var h=a.createElement(ao,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:o(p),type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,linterContext:this.props.linterContext});return i?a.createElement("span",{className:"perseus-input-with-answer-blurb"},h,i):h}static validate(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>{};null==t.answerType&&(t.answerType="number");var i=me.number.createValidatorFunctional(t.value,{simplify:t.simplify,inexact:t.inexact||void 0,maxError:t.maxError,forms:So[t.answerType].forms})(Eo(e.currentValue));return i.empty?{type:"invalid",message:!1===(null==r?void 0:r(null,e.currentValue,i.message))?null:i.message}:{type:"points",earned:i.correct?1:0,total:1,message:i.message}}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){if(null!=e.value){var t=String(e.value);return e.inexact&&e.maxError&&(t+=" ± "+e.maxError),t}}}V(Mo,"defaultProps",{currentValue:"",size:"normal",answerType:"number",rightAlign:!1,apiOptions:Kt.defaults,linterContext:Gt});var To={name:"input-number",displayName:"Number text box (old)",defaultAlignment:"inline-block",hidden:!0,widget:Mo,transform:e=>{var{simplify:t,size:r,answerType:i,rightAlign:n}=e;return{simplify:t,size:r,answerType:i,rightAlign:n}},isLintable:!0},Io=$s,Po=[{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:"π"}],Ao={integer:()=>s._("an integer, like $6$"),proper:e=>"optional"===e.simplify?s._("a *proper* fraction, like $1/2$ or $6/10$"):s._("a *simplified proper* fraction, like $3/5$"),improper:e=>"optional"===e.simplify?s._("an *improper* fraction, like $10/7$ or $14/8$"):s._("a *simplified improper* fraction, like $7/4$"),mixed:()=>s._("a mixed number, like $1\\ 3/4$"),decimal:()=>s._("an *exact* decimal, like $0.75$"),pi:()=>s._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")};class No extends a.Component{constructor(){super(...arguments),V(this,"state",{previousValues:[""]}),V(this,"getAnswerBlurb",(e=>{var t,r;if(this.props.apiOptions.satStyling&&e){var i=this.simpleValidate(e);if(!(t="points"===i.type&&i.earned===i.total)){var n=l.filter(e.answers,(e=>"correct"===e.status)),s=l.map(n,(e=>{var t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);var r=ce.toNumericString(e.value,t);return e.maxError&&(r+=" ± "+ce.toNumericString(e.maxError,t)),r}));r=a.createElement(Co,{answers:s})}}return[r,!!t]})),V(this,"getClasses",((e,t)=>{var r={};return r["perseus-input-size-"+this.props.size]=!0,r["perseus-input-right-align"]=this.props.rightAlign,r[Zt.CORRECT]=t&&e&&this.props.currentValue,r[Zt.INCORRECT]=t&&!e&&this.props.currentValue,r[Zt.UNANSWERED]=t&&!this.props.currentValue,r})),V(this,"examples",(()=>{var e,t=0!==(null===(e=this.props.answerForms)||void 0===e?void 0:e.length)?this.props.answerForms:l.map(l.keys(Ao),(e=>({name:e,simplify:"required"}))),r=l.map(t,(e=>Ao[e.name](e)));return r=l.uniq(r),[s._("**Your answer should be** ")].concat(r)})),V(this,"shouldShowExamples",(()=>{var e,t,r=0===(null===(e=this.props.answerForms)||void 0===e?void 0:e.length),i=l.uniq(null===(t=this.props.answerForms)||void 0===t?void 0:t.map((e=>e.name))).length>=l.size(Ao);return!r&&!i})),V(this,"simpleValidate",(e=>No.validate(this.getUserInput(),e))),V(this,"focus",(()=>(this.refs.input.focus(),!0))),V(this,"focusInputPath",(e=>{this.refs.input.focus()})),V(this,"blurInputPath",(e=>{this.refs.input.blur()})),V(this,"getInputPaths",(()=>[[]])),V(this,"getGrammarTypeForPath",(e=>"number")),V(this,"setInputValue",((e,t,r)=>{this.props.onChange({currentValue:t},r)})),V(this,"getUserInput",(()=>No.getUserInputFromProps(this.props))),V(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t),this.props.trackInteraction()})),V(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),V(this,"_handleFocus",(()=>{this.props.onFocus([]);var{interactionCallback:e}=this.props.apiOptions;e&&e()})),V(this,"_handleBlur",(()=>{this.props.onBlur([])}))}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){var t=l.filter(e.answers,(e=>"correct"===e.status)),r=l.map(t,(e=>{var t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);var r=ce.toNumericString(e.value,t);return e.maxError&&(r+=" ± "+ce.toNumericString(e.maxError,t)),r}));if(0!==r.length)return r[0]}static validate(e,t){var r=l.pluck(Po,"value"),i=e=>me.number.createValidatorFunctional(e.value,{message:e.message,simplify:"correct"===e.status?e.simplify:"optional",inexact:!0,maxError:e.maxError,forms:e.strict&&e.answerForms&&0!==e.answerForms.length?e.answerForms:r}),n=Io(e.currentValue),s=l.where(t.answers,{status:"correct"}),o=s.every((e=>Math.abs(e.value)<=1)),a=l.find(l.map(s,(e=>{var r=n;return t.coefficient&&(r?"-"===r&&(r=-1):r=1),i(e)(Ro(r,o))})),(e=>e.correct||e.empty));if(!a){var p=[].concat(l.where(t.answers,{status:"ungraded"}),l.where(t.answers,{status:"wrong"})),h=l.find(p,(e=>i(e)(Ro(n,o)).correct));a={empty:!!h&&"ungraded"===h.status,correct:!!h&&"correct"===h.status,message:h?h.message:null,guess:n}}return a.empty?{type:"invalid",message:a.message}:{type:"points",earned:a.correct?1:0,total:1,message:a.message}}render(){var e=this.props.reviewModeRubric,t=this.getAnswerBlurb(e),r=t[0],i=t[1],n=this.getClasses(i,e),l=this.props.labelText;null!=l&&""!==l||(l=s._("Your answer:"));if(this.props.apiOptions.customKeypad)return(e=>this.props.rightAlign?a.createElement("div",{className:"perseus-input-right-align"},e):e)(a.createElement(ko,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur}));var p=a.createElement(ao,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:o(n),labelText:l,type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,highlightLint:this.props.highlightLint});return r?a.createElement("span",{className:"perseus-input-with-answer-blurb"},p,r):this.props.apiOptions.satStyling?a.createElement("label",{className:"perseus-input-with-label"},a.createElement("span",{className:"perseus-input-label","aria-hidden":"true"},s.doNotTranslate("Answer:")),p):a.createElement("div",null,p)}}V(No,"defaultProps",{currentValue:"",size:"normal",rightAlign:!1,apiOptions:Kt.defaults,coefficient:!1,answerForms:[],labelText:"",linterContext:Gt,multipleNumberInput:!1});var Ro=(e,t)=>{if("string"!=typeof e||!e.endsWith("%"))return e;var r=parseFloat(e.slice(0,-1));return isNaN(r)?e:t?r/100:r},Fo={name:"numeric-input",displayName:"Number text box",defaultAlignment:"inline-block",accessible:!0,widget:No,transform:function(e){var t,r,i,n,s;return l.extend(l.omit(e,"answers"),{answerForms:(t=l.map(e.answers,(e=>l.map(e.answerForms,(t=>({simplify:e.simplify,name:t}))))),n=l.flatten(t),r=n,i=l.isEqual,s=l.reduce(r,((e,t)=>l.find(e,i.bind(null,t))?e:e.concat([t])),[]),l.sortBy(s,(e=>l.keys(Ao).indexOf(e.name))))})},isLintable:!0},Do={getUserInput:function(){return l.omit(this.props,lo)},getUserInputFromProps:function(e){return l.omit(e,lo)}};class Oo extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"displayName","PassageRef"),V(this,"_isMounted",void 0),V(this,"_throttledUpdateRange",void 0),V(this,"state",{lineRange:null,content:null}),V(this,"getUserInput",(()=>Do.getUserInput.call(this))),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"_deferredUpdateRange",(()=>{l.defer(this._updateRange)})),V(this,"_updateRange",(()=>{var e=this.props.findWidgets("passage "+this.props.passageNumber)[0],t=null;e&&(t=e.getReference(this.props.referenceNumber)),this._isMounted&&(t?this.setState({lineRange:[t.startLine,t.endLine],content:t.content}):this.setState({lineRange:null,content:null}))})),V(this,"simpleValidate",(e=>Oo.validate(this.getUserInput(),e)))}shouldComponentUpdate(e,t){return!l.isEqual(this.props,e)||!l.isEqual(this.state,t)}render(){var e,t,r=this.state.lineRange;if(e=r?r[0]===r[1]?s.$_("line %(lineNumber)s",{lineNumber:r[0]}):s.$_("lines %(lineRange)s",{lineRange:r[0]+"–"+r[1]}):s.$_("lines %(lineRange)s",{lineRange:"?".concat("–","?")}),this.props.summaryText){var i=Ye.parseInline(this.props.summaryText);t=a.createElement("span",{"aria-hidden":!0}," ","(“",Ye.basicOutput(i),"”)")}else t=null;return a.createElement("span",null,e,t,r&&a.createElement("div",{className:"perseus-sr-only"},this.state.content))}componentDidMount(){this._isMounted=!0,this._deferredUpdateRange(),this._throttledUpdateRange=l.throttle(this._deferredUpdateRange,500),window.addEventListener("resize",this._throttledUpdateRange)}componentDidUpdate(){this._deferredUpdateRange()}componentWillUnmount(){window.removeEventListener("resize",this._throttledUpdateRange),this._isMounted=!1}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}V(Oo,"defaultProps",{passageNumber:1,referenceNumber:1,summaryText:""});var Lo={name:"passage-ref",displayName:"PassageRef (SAT only)",defaultAlignment:"inline",widget:Oo,transform:e=>({passageNumber:e.passageNumber,referenceNumber:e.referenceNumber,summaryText:e.summaryText}),version:{major:0,minor:1}},{pureXsMax:Bo,pureSmMin:zo,pureSmMax:qo,pureMdMin:Ho,pureMdMax:Wo,pureLgMin:Uo,pureLgMax:Go,pureXlMin:Vo}=te,jo={xs:"@media screen and (max-width: ".concat(Bo,")"),sm:"@media screen and (min-width: ".concat(zo,") and ")+"(max-width: ".concat(qo,")"),md:"@media screen and (min-width: ".concat(Ho,") and ")+"(max-width: ".concat(Wo,")"),lg:"@media screen and (min-width: ".concat(Uo,") and ")+"(max-width: ".concat(Go,")"),xl:"@media screen and (min-width: ".concat(Vo,")"),xsOrSmaller:"@media screen and (max-width: ".concat(Bo,")"),smOrSmaller:"@media screen and (max-width: ".concat(qo,")"),mdOrSmaller:"@media screen and (max-width: ".concat(Wo,")"),lgOrSmaller:"@media screen and (max-width: ".concat(Go,")"),smOrLarger:"@media screen and (min-width: ".concat(zo,")"),mdOrLarger:"@media screen and (min-width: ".concat(Ho,")"),lgOrLarger:"@media screen and (min-width: ".concat(Uo,")"),xlOrLarger:"@media screen and (min-width: ".concat(Vo,")")},{zIndexAboveScratchpad:Yo,zIndexInteractiveComponent:Xo,radioBorderColor:$o,checkedColor:Ko,circleSize:Zo,radioMarginWidth:Jo}=te,Qo=d.create({perseusInteractive:{zIndex:Xo,position:"relative"},aboveScratchpad:{position:"relative",zIndex:Yo},blankBackground:{backgroundColor:"#FDFDFD"},perseusSrOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1},responsiveLabel:{[jo.smOrSmaller]:{fontSize:14,lineHeight:1.3},[jo.md]:{fontSize:17,lineHeight:1.4},[jo.lgOrLarger]:{fontSize:20,lineHeight:1.4}},responsiveInput:{display:"inline-block",WebkitAppearance:"none",appearance:"none","::-ms-check":{display:"none"},backgroundColor:"#fff",border:"2px solid #fff",boxShadow:"0 0px 0px 1px ".concat($o),outline:"none",boxSizing:"border-box",flexShrink:0,marginBottom:1,marginLeft:1,marginRight:1,marginTop:1,height:Zo-2,width:Zo-2},responsiveRadioInput:{borderRadius:"50%",":checked":{backgroundColor:Ko,border:"none",borderRadius:"50%",boxShadow:"inset 0px 0px 0px 2px white, "+"0 0px 0px 2px ".concat(Ko),marginTop:Jo,marginBottom:Jo,marginLeft:Jo,marginRight:Jo,height:Zo-2*Jo,width:Zo-2*Jo}},responsiveRadioInputActive:{backgroundColor:"#fff",border:"2px solid #fff",borderRadius:"50%",boxShadow:"0 0px 0px 2px ".concat(Ko),marginTop:Jo,marginBottom:Jo,marginLeft:Jo,marginRight:Jo,height:Zo-2*Jo,width:Zo-2*Jo,":checked":{backgroundColor:"#fff"}},disableTextSelection:{userSelect:"none"}});"undefined"==typeof HTMLElement||HTMLElement.prototype.scrollTo||(HTMLElement.prototype.scrollTo=function(e,t){this.scrollLeft=e,this.scrollTop=t});var ea=(e,t)=>{"function"==typeof e.scrollTo?e.scrollTo(0,t):"scrollTop"in e&&(e.scrollTop=t)},ta=e=>e===document.body||null==e?window:e.scrollHeight>e.clientHeight?e:ta(e.parentElement),ra=(e,t)=>{setTimeout((()=>{var r=ta(e),i=e.getBoundingClientRect(),n=r===window?{top:0,bottom:window.innerHeight}:r.getBoundingClientRect(),s=0,o=r===window?window.scrollY:r.scrollTop;if(i.bottom>n.bottom){var a=i.bottom-n.bottom;i.top+a<n.top&&(a=i.top-n.top),s=o+a}else if(i.top<n.top){s=o+(i.top-n.top)}!function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0,n=e===window?window.pageYOffset:e.scrollTop,s=t,o=s-n,a=17,l=r/a,p=0,h=setInterval((function(){if(p<l){var t=p/l,r=(1-Math.cos(Math.PI*t))/2;ea(e,n+o*r),p+=1}else ea(e,s),clearInterval(h),i&&i()}),a)}(r,s,750,t)}),0)};class ia extends a.Component{render(){var e={borderColor:this.props.visible?this.props.color:"transparent"};return a.createElement("span",{className:u(na.ring),style:e},this.props.children)}}V(ia,"defaultProps",{visible:!0,color:"#71B307"});var na=d.create({ring:{margin:"auto",display:"inline-block",borderRadius:"50%",borderWidth:2,padding:2,borderStyle:"solid"}});function sa(e){var t=s._("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z").split(" ");return e<t.length?t[e]:" "}class oa extends a.Component{constructStyles(e,t,r){var i,n="#0084CE",s="#0084CE";return e?t?(n="#009900",s=r?K:"#009900",i=r?"#009900":K):r&&(n="#990000",s=K,i="#990000"):r&&(s=K,i="#0084CE"),{color:s,backgroundColor:i,borderColor:n}}render(){var{letter:e,a11yText:t,reviewMode:r,checked:i,correct:n,crossedOut:s}=this.props,{color:o,backgroundColor:l,borderColor:p}=this.constructStyles(r,n,i);return a.createElement("div",{className:u(ha.iconWrapper)},a.createElement("div",{className:u(ha.satCircle),style:{backgroundColor:l,borderColor:p}}),a.createElement("div",{style:{color:o},className:u(ha.letter)},a.createElement("span",{className:"perseus-sr-only"},t),a.createElement("span",{"aria-hidden":"true"},e)),s&&a.createElement(la,{color:p,sat:!0}))}}class aa extends a.Component{getChoiceInner(){var{letter:e,showCorrectness:t,correct:r}=this.props;return t?r?a.createElement(X,j({},ui,{style:{position:"relative",top:-1}})):a.createElement(X,Ii):e}getDynamicStyles(){var{checked:e,showCorrectness:t,pressed:r,primaryProductColor:i,correct:n,transparentBackground:s}=this.props;if(!t&&r)return{borderColor:i,color:i,backgroundColor:s?"transparent":K};if(e){var o=t&&n?"#71B307":i;return{color:K,backgroundColor:o,borderColor:o}}return{borderColor:J,color:J}}render(){var{a11yText:e,checked:t,crossedOut:r,showCorrectness:i,correct:n,focused:s,primaryProductColor:o,previouslyAnswered:l}=this.props,p=this.getDynamicStyles();return a.createElement("div",{className:u(ha.iconWrapper)},a.createElement(ia,{color:o,visible:s},a.createElement("div",{style:p,className:u(ha.libraryCircle,i&&n&&ha.libraryCircleCorrect,i&&!n&&ha.libraryCircleIncorrect,i&&!n&&(t||l)&&ha.libraryCircleIncorrectAnswered),"data-is-radio-icon":!0},a.createElement("div",{className:"perseus-sr-only"},e),a.createElement("div",{"aria-hidden":!0},this.getChoiceInner()))),r&&a.createElement(la,{color:p.borderColor}))}}function la(e){var t=e.sat?29:28;return a.createElement("svg",{width:t,height:t,viewBox:"0 0 ".concat(t," ").concat(t),className:u(ha.crossOutLine)},a.createElement("line",{x1:2,x2:t-2,y1:t-2,y2:2,stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}))}class pa extends a.Component{a11yText(e){var{checked:t,correct:r,crossedOut:i,showCorrectness:n}=this.props;return n&&r?t?s._("(Choice %(letter)s, Checked, Correct)",{letter:e}):i?s._("(Choice %(letter)s, Crossed out, Correct)",{letter:e}):s._("(Choice %(letter)s, Correct)",{letter:e}):n&&!r?t?s._("(Choice %(letter)s, Checked, Incorrect)",{letter:e}):i?s._("(Choice %(letter)s, Crossed out, Incorrect)",{letter:e}):s._("(Choice %(letter)s, Incorrect)",{letter:e}):t?s._("(Choice %(letter)s, Checked)",{letter:e}):i?s._("(Choice %(letter)s, Crossed out)",{letter:e}):s._("(Choice %(letter)s)",{letter:e})}render(){var{pos:e,reviewMode:t,checked:r,crossedOut:i,correct:n,product:s,showCorrectness:o,pressed:l,focused:p,primaryProductColor:h,previouslyAnswered:c,transparentBackground:d}=this.props,u=sa(e);return"sat"===s?a.createElement(oa,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:r,correct:n,crossedOut:i}):a.createElement(aa,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:r,crossedOut:i,pressed:l,focused:p,correct:n,showCorrectness:o,primaryProductColor:h,previouslyAnswered:c,transparentBackground:d})}}V(pa,"defaultProps",{primaryProductColor:"#71B307"});var ha=d.create({satCircle:{display:"block",borderRadius:25,borderStyle:"solid",borderWidth:2,content:"''",height:25,width:25,top:1,left:1},iconWrapper:{display:"inline-block",position:"relative"},crossOutLine:{position:"absolute",top:"calc(50% - ".concat(14,"px)"),left:"calc(50% - ".concat(14,"px)")},libraryCircle:{width:24,height:24,boxSizing:"border-box",borderRadius:24,borderStyle:"solid",borderWidth:2,fontFamily:"'Proxima Nova',sans-serif",fontWeight:"bold",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1px"},libraryCircleCorrect:{fontSize:24},libraryCircleIncorrect:{fontSize:24,borderColor:J,color:J},libraryCircleIncorrectAnswered:{backgroundColor:"#F86700",borderColor:"#F86700",color:K},letter:{border:"2px solid transparent",width:25,height:25,position:"absolute",top:1,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:$,fontSize:13}});class ca extends a.Component{render(){var{color:e,pathClassName:t,className:r,title:i,style:n,alt:s}=this.props,{icon:o,size:l}=this.props,p="";"string"==typeof o&&(o={path:o,width:10,height:10}),"number"!=typeof l&&(l=1,p="em");var h=l,c=h/o.height*o.width,d=!!this.props.focusable;return a.createElement("svg",{role:"img",alt:s,"aria-label":i,"aria-hidden":!i||null,className:r,style:n,focusable:d.toString(),width:c+p,height:h+p,viewBox:"".concat(0," ").concat(0," ").concat(o.width," ").concat(o.height)},!!i&&a.createElement("title",null,i),a.createElement("path",{className:t,fill:e,d:o.path}))}}V(ca,"defaultProps",{color:"currentColor"});var da=Object.freeze({__proto__:null,black:"#000000",grayDarker:"#333333",grayDark:"#555555",gray:"#999999",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",white:"#FFFFFF",blue:"#005A88",blueDark:"#2C3747",green:"#76A005",red:"#CF5044",yellow:"#FFC40D",orange:"#BF4F04",pink:"#C3325F",purple:"#7A43B6",bodyBackground:"#FFFFFF",textColor:"#444444",linkColor:"#005987",linkColorHover:"#678D00",sansFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",serifFontFamily:"Georgia,'Times New Roman',Times,serif",monoFontFamily:"Monaco,Menlo,Consolas,'Courier New',monospace",baseFontSize:"14px",baseFontFamily:"inherit",baseLineHeight:"20px",altFontFamily:"Georgia,'Times New Roman',Times,serif",headingsFontFamily:"inherit",headingsFontWeight:"bold",headingsColor:"inherit",fontSizeLarge:"18px",fontSizeSmall:"12px",fontSizeMini:"10.5px",paddingLarge:"11px 19px",paddingSmall:"2px 10px",paddingMini:"0 6px",baseBorderRadius:"4px",borderRadiusLarge:"6px",borderRadiusSmall:"3px",tableBackground:"#000000",tableBackgroundAccent:"#F9F9F9",tableBackgroundHover:"#F5F5F5",tableBorder:"#DDDDDD",btnBackground:"#FFFFFF",btnBackgroundHighlight:"rgb(230, 230, 230)",btnBorder:"#CCCCCC",btnPrimaryBackground:"#0088CC",btnPrimaryBackgroundHighlight:"rgb(0, 68, 204)",btnInfoBackground:"#5BC0DE",btnInfoBackgroundHighlight:"#2F96B4",btnSuccessBackground:"#62C462",btnSuccessBackgroundHighlight:"#51A351",btnWarningBackground:"rgb(251, 180, 81)",btnWarningBackgroundHighlight:"#F89406",btnDangerBackground:"#EE5F5B",btnDangerBackgroundHighlight:"#BD362F",btnInverseBackground:"#444444",btnInverseBackgroundHighlight:"#222222",inputBackground:"#FFFFFF",inputBorder:"#CCCCCC",inputBorderRadius:"4px",inputDisabledBackground:"#EEEEEE",formActionsBackground:"#F5F5F5",inputHeight:"30px",dropdownBackground:"#FFFFFF",dropdownBorder:"rgba(0, 0, 0, 0.2)",dropdownDividerTop:"#E5E5E5",dropdownDividerBottom:"#FFFFFF",dropdownLinkColor:"#333333",dropdownLinkColorHover:"#FFFFFF",dropdownLinkColorActive:"#FFFFFF",dropdownLinkBackgroundActive:"#0088CC",dropdownLinkBackgroundHover:"#0088CC",zindexDropdown:1e3,zindexPopover:1010,zindexTooltip:1030,zindexFixedNavbar:1030,zindexHeader:1060,zindexModalBackdrop:1070,zindexModal:1080,zindexAboveModal:1090,iconSpritePath:"../img/glyphicons-halflings.png",iconWhiteSpritePath:"../img/glyphicons-halflings-white.png",placeholderText:"#999999",hrBorder:"#EEEEEE",horizontalComponentOffset:"180px",wellBackground:"#F5F5F5",navbarCollapseWidth:"979px",navbarCollapseDesktopWidth:"980px",navbarHeight:"40px",navbarBackgroundHighlight:"#FFFFFF",navbarBackground:"rgb(242, 242, 242)",navbarBorder:"rgb(212, 212, 212)",navbarText:"#777777",navbarLinkColor:"#777777",navbarLinkColorHover:"#333333",navbarLinkColorActive:"#555555",navbarLinkBackgroundHover:"#000000",navbarLinkBackgroundActive:"rgb(230, 230, 230)",navbarBrandColor:"#777777",navbarInverseBackground:"#111111",navbarInverseBackgroundHighlight:"#222222",navbarInverseBorder:"#252525",navbarInverseText:"#999999",navbarInverseLinkColor:"#999999",navbarInverseLinkColorHover:"#FFFFFF",navbarInverseLinkColorActive:"#FFFFFF",navbarInverseLinkBackgroundHover:"#000000",navbarInverseLinkBackgroundActive:"#111111",navbarInverseSearchBackground:"rgb(82, 82, 82)",navbarInverseSearchBackgroundFocus:"#FFFFFF",navbarInverseSearchBorder:"#111111",navbarInverseSearchPlaceholderColor:"#CCCCCC",navbarInverseBrandColor:"#999999",paginationBackground:"#FFFFFF",paginationBorder:"#DDDDDD",paginationActiveBackground:"#F5F5F5",heroUnitBackground:"#EEEEEE",heroUnitHeadingColor:"inherit",heroUnitLeadColor:"inherit",warningText:"#C09853",warningBackground:"#FCF8E3",warningBorder:"rgb(251, 239, 213)",errorText:"#B94A48",errorBackground:"#F2DEDE",errorBorder:"rgb(238, 211, 215)",successText:"#468847",successBackground:"#DFF0D8",successBorder:"rgb(212, 232, 197)",infoText:"#4A7C17",infoBackground:"#EDF2DF",infoBorder:"rgb(228, 232, 197)",tooltipColor:"#FFFFFF",tooltipBackground:"#000000",tooltipArrowWidth:"5px",tooltipArrowColor:"#000000",popoverBackground:"#FFFFFF",popoverArrowWidth:"10px",popoverArrowColor:"#FFFFFF",popoverTitleBackground:"rgb(247, 247, 247)",popoverArrowOuterWidth:"11px",popoverArrowOuterColor:"rgba(0, 0, 0, 0.25)",gridColumns:"12",gridColumnWidth:"60px",gridGutterWidth:"20px",gridRowWidth:"940px",gridColumnWidth1200:"70px",gridGutterWidth1200:"30px",gridRowWidth1200:"1170px",gridColumnWidth768:"42px",gridGutterWidth768:"20px",gridRowWidth768:"724px",fluidGridColumnWidth:"6.382978723404255%",fluidGridGutterWidth:"2.127659574468085%",fluidGridColumnWidth1200:"5.982905982905983%",fluidGridGutterWidth1200:"2.564102564102564%",fluidGridColumnWidth768:"5.801104972375691%",fluidGridGutterWidth768:"2.7624309392265194%",kaGreen:"#71B307",kaGreenLight:"#BED47A",kaBlue:"#314453",kaBlueLight:"#4D6779",grayExtraDark:"#111111",grayExtraLight:"#EEEEEE",graySuperLight:"#F7F7F7",whiteDark:"#FDFDFD",dark:"#21242C",blueDarkUnsaturated:"#3B414E",blueDarkSaturated:"#1F3043",blueLight:"#A9C0D1",greenLight:"#C6D1AD",greenDark:"#356700",yellowGreen:"#9DB63B",okGreen:"#A7CF5B",alertRed:"#C42420",coral:"#EE6666",grayBlue:"#9AB3B9",lightPageBackground:"#FDFDFD",yclaBlue:"#49BAD5",yclaTeal:"#56D0B3",yclaTealDark:"#50C1A7",yclaGreenDark:"#3D9A82",yclaGreen:"#81C262",learnstormBlue:"#4898FC",homepageBlue:"#46A8BF",backgroundBlue:"#00294A",teacherSignupBlue:"#335d7d",homepageGreen:"#2B8E7B",streakColor:"#F79734",facebookColor:"#1A60A2",blueGoogleColor:"#2CAFE2",redGoogleColor:"#BF4434",homepageColor:"#2D585E",lightTextColor:"#898989",fontSizeTiny:"11px",fontSizeNormal:"14px",fontSizeMedium:"16px",fontSizeExtraLarge:"24px",fontSizeHuge:"36px",fontSizeBakana:"48px",fontSizeBananas:"60px",fixedWidthFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",contentPadding:"20px",primaryButtonBackground:"#89B908",primaryButtonBorder:"#76A005",buttonTextColor:"rgb(122, 122, 122)",buttonBorderRadius:"3px",basicBorderColor:"#CCCCCC",minContainerWidth:"1000px",maxContainerWidth:"1200px",formHintColor:"#999999",guidelineExampleText:"#606060",hoverCardWidth:"450px",menuHighlightColor:"#96AB4F",menuHighlightBorderColor:"#76A005",menuActiveTextColor:"#FFFFFF",menuInactiveTextColor:"#444444",menuSubheaderTextColor:"rgb(120, 120, 120)",menuBorderColor:"#94A170",unreadBackgroundColor:"#ECEEF4",menuLineHeight:"18px",menuSubheaderLineHeight:"17px",menuSubheaderFontSize:"9px",notificationBarColor:"#4858A4",modalBodyTopPadding:"20px",modalDialogPadding:"15px",modalSectionPadding:"9px",mathDomain1:"#11ACCD",mathDomain2:"#63D9EA",mathDomain3:"#027d97",mathDomain4:"#085566",partnerContentDomain1:"#01A995",partnerContentDomain2:"#01D1C1",partnerContentDomain3:"#208170",partnerContentDomain4:"#144F44",csDomain1:"#1FAB54",csDomain2:"#74CF70",csDomain3:"#0D923F",csDomain4:"#085E29",economicsDomain1:"#E07D10",economicsDomain2:"#FFBE26",economicsDomain3:"#A75A05",economicsDomain4:"#953C02",collegeCareersMoreDomain1:"#01A995",collegeCareersMoreDomain2:"#01D1C1",collegeCareersMoreDomain3:"#208170",collegeCareersMoreDomain4:"#144F44",humanitiesDomain1:"#E84D39",humanitiesDomain2:"#FF8482",humanitiesDomain3:"#BE2612",humanitiesDomain4:"#8C1C0D",gtpDomain1:"#1865F2",gtpDomain2:"#1865F2",gtpDomain3:"#1865F2",gtpDomain4:"#1865F2",scienceDomain1:"#CA337C",scienceDomain2:"#FF92C6",scienceDomain3:"#9E034E",scienceDomain4:"#6B0235",testPrepDomain1:"#1865F2",testPrepDomain2:"#1865F2",testPrepDomain3:"#1865F2",testPrepDomain4:"#1865F2",defaultDomain1:"#1865F2",defaultDomain2:"#66afe9",defaultDomain3:"#1152b0",defaultDomain4:"#0d3d82",defaultDomainColor:"#314453",defaultSubjectColor:"#4D6779",defaultTopicColor:"#6A8DA6",defaultHoverColor:"#314453",defaultLinkColor:"#314453",defaultLinkHoverColor:"#6A8DA6",scienceDomainColor:"#94424F",scienceSubjectColor:"#9D4A5A",scienceTopicColor:"#C55F73",scienceHoverColor:"#94424F",scienceLinkColor:"#94424F",scienceLinkHoverColor:"#C55F73",humanitiesDomainColor:"#AD3434",humanitiesSubjectColor:"#C13B31",humanitiesTopicColor:"#D24A45",humanitiesHoverColor:"#AD3434",humanitiesLinkColor:"#AD3434",humanitiesLinkHoverColor:"#D24A45",economicsDomainColor:"#B77033",economicsSubjectColor:"#BF7B34",economicsTopicColor:"#D1933B",economicsHoverColor:"#B77033",economicsLinkColor:"#B77033",economicsLinkHoverColor:"#D1933B",csDomainColor:"#437A39",csSubjectColor:"#53893E",csTopicColor:"#689B51",csHoverColor:"#437A39",csLinkColor:"#437A39",csLinkHoverColor:"#689B51",partnerContentDomainColor:"#218270",partnerContentSubjectColor:"#2C8D7B",partnerContentTopicColor:"#329A86",partnerContentHoverColor:"#218270",partnerContentLinkColor:"#218270",partnerContentLinkHoverColor:"#329A86",essayDomainColor:"#0071B3",mathDomainColor:"#1C758A",mathSubjectColor:"#46A8BF",mathTopicColor:"#4FBAD4",mathHoverColor:"#1C758A",mathLinkColor:"#1C758A",mathLinkHoverColor:"#4FBAD4",testPrepDomainColor:"#644172",testPrepSubjectColor:"#7E5F8E",testPrepTopicColor:"#9A72AC",testPrepHoverColor:"#644172",testPrepLinkColor:"#644172",testPrepLinkHoverColor:"#9A72AC",collegeCareersMoreDomainColor:"#218270",collegeCareersMoreSubjectColor:"#2C8D7B",collegeCareersMoreTopicColor:"#329A86",collegeCareersMoreHoverColor:"#218270",collegeCareersMoreLinkColor:"#218270",collegeCareersMoreLinkHoverColor:"#329A86",satDomainColor:"#0084CE",satSubjectColor:"#0084CE",satTopicColor:"#0084CE",satHoverColor:"#0084CE",satLinkColor:"#0084CE",satLinkHoverColor:"#0084CE",colorProficient:"#1C758A",colorPracticed:"rgb(158, 221, 235)",colorMastery1:"rgb(90, 197, 221)",colorMastery2:"rgb(42, 174, 203)",colorMastery3:"#1C758A",colorSuggested:"#73982C",colorReview:"#E35D04",colorNotStarted:"#CCCCCC",colorStarted:"#C7E5F7",colorStruggling:"#C30202",colorPersonal:"#00809C",colorPractice:"#96D9FF",colorEnergyPoints:"#005987",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1200px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1199px"}),ua={white:"#FFFFFF",gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:"#BABEC2",gray72:"#999A9D",gray68:"#888D93",gray55:"#707378",gray41:"#626569",gray25:"#3B3E40",gray17:"#21242C",gray10:"#1499af",black:"#000000",alertRed:"#C42420",homepageBlue:"#46A8BF",kaBlue:"#314453",kaBlueLight:"#4D6779",kaGreen:"#71B307",kaGreenLight:"#BED47A",learnstormBlue:"#4898FC",backgroundBlue:"#00294A",adminGreen:"#78C008",kaBlueExtraLight:"#39c2db",kaBlueHover:"#0c7f99",kaGreenHover:"#518005",skyDark:"#001f4d",recommendationGold:"#ffbe26",starAced:"#ff9c39",google:"#C1432f",modernGoogle:"#be2612",modernGoogleHover:"#8c1c0d",facebook:"#4267B2",modernFacebook:"#4267B2",modernFacebookHover:"#00294a",wonderBlocksGold:"#FFB100",wonderBlocksLightBlue:"#37C5FD",breadcrumbs:"rgba(255, 255, 255, 0.7)"},ma={color:ua.breadcrumbs,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased"},ga={regular:"inherit"},fa={subjectHeadingDesktop:{fontFamily:"inherit",fontSize:50,fontWeight:"bold",lineHeight:"61px"},subjectHeadingMobile:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingDesktop:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingMobile:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingDesktop:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingMobile:{fontFamily:"inherit",fontSize:20,fontWeight:"bold",lineHeight:"24px"},smallSubheadingDesktop:{fontFamily:"inherit",fontSize:20,lineHeight:1.25},smallSubheadingMobile:{fontFamily:"inherit",fontSize:15,lineHeight:1.25},smallHeading:{color:ua.gray25,fontFamily:"inherit",fontSize:17,fontWeight:"bold",lineHeight:"23px"},smallHeadingMobile:{color:ua.gray25,fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},accentHeading:{color:ua.gray68,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase"},bodyLarge:{fontFamily:ga.regular,fontSize:20,lineHeight:"30px"},bodySmall:{fontFamily:ga.regular,fontSize:17,fontWeight:"normal",lineHeight:"23px"},bodySmallBold:{fontFamily:ga.regular,fontSize:17,fontWeight:"bold",lineHeight:"23px"},bodyXsmall:{fontFamily:ga.regular,fontSize:15,lineHeight:"22px"},bodyXsmallBold:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"22px"},breadcrumb:ma,breadcrumbSmall:U(U({},ma),{},{fontSize:12,lineHeight:"13px"}),labelLarge:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},labelMedium:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},labelSmall:{fontFamily:ga.regular,fontSize:12,lineHeight:"14px"},caption:{fontFamily:ga.regular,fontSize:14,fontStyle:"italic",lineHeight:"17px"},desktopScalingOnMobile:{MozTextSizeAdjust:"100%",MsTextSizeAdjust:"100%",WebkitTextSizeAdjust:"100%"},modalSubtitle:{fontSize:12,lineHeight:1.65,WebkitFontSmoothing:"antialiased",fontWeight:"bold"},wonderBlocksHeader:{paddingLeft:16,paddingRight:16,paddingBottom:24,paddingTop:34,[jo.mdOrLarger]:{paddingBottom:32}},wonderBlocksTitle:{color:ua.white,fontWeight:900,fontSize:28,lineHeight:"32px",margin:0,[jo.mdOrLarger]:{fontSize:36,lineHeight:"40px"}},wonderBlocksLabelLarge:{fontSize:16,lineHeight:"20px",fontWeight:700}},va=Object.freeze({__proto__:null,colors:ua,borderRadius:4,fonts:ga,typography:fa});class ba extends a.PureComponent{constructor(){super(...arguments),V(this,"_handleTooltipButtonRef",(e=>{e&&this.props.usingKeyboardFocus&&e.focus()}))}_getAriaLabel(){var{crossedOut:e,pos:t}=this.props,r=sa(t);return e?s._("Bring back Choice %(letter)s",{letter:r}):s._("Cross out Choice %(letter)s",{letter:r})}render(){var{crossedOut:e,pos:t,primaryProductColor:r,theme:i}=this.props,n="day"===i?r:E.white;return a.createElement("button",{type:"button","aria-label":this._getAriaLabel(),className:u([ya.tooltipButton]),onClick:()=>this.props.onClick(),onMouseDown:e=>e.preventDefault(),onFocus:()=>this.props.onFocus(),onBlur:()=>this.props.onBlur(),disabled:this.props.disabled,tabIndex:this.props.tabFocusable?0:-1,ref:this._handleTooltipButtonRef},a.createElement(pa,{pos:t,product:"library",crossedOut:!this.props.crossedOut,primaryProductColor:n,pressed:!0,checked:!1,focused:!1,correct:!1,showCorrectness:!1,reviewMode:!1,previouslyAnswered:!1,transparentBackground:!0}),a.createElement(S,{style:{color:n}},e?s._("Bring back"):s._("Cross out")))}}V(ba,"defaultProps",{primaryProductColor:ua.kaGreen});var ya=d.create({tooltipButton:{background:"none",border:"none",font:"inherit",padding:0,cursor:"pointer",textDecoration:"none",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"}});class xa{constructor(e,t,r){V(this,"_intersectionObserver",void 0),V(this,"_onVisibilityChange",void 0),V(this,"_handleIntersection",(e=>{for(var t of e)this._onVisibilityChange(t.isIntersecting,t.rootBounds)})),this._intersectionObserver=new IntersectionObserver(this._handleIntersection,{root:e,threshold:Number.EPSILON,rootMargin:r}),this._onVisibilityChange=t}setTargetElement(e){this._intersectionObserver.disconnect(),this._intersectionObserver.observe(e)}disconnect(){this._intersectionObserver.disconnect()}}class Ca extends a.PureComponent{render(){var{direction:e,pxFromStart:t,pxFromEnd:r}=this.props,i=[wa.wrapper,"horizontal"===e&&wa.wrapperHorizontal,"vertical"===e&&wa.wrapperVertical],n=[wa.content,"horizontal"===e&&wa.contentHorizontal,"vertical"===e&&wa.contentVertical];return 0===t?a.createElement("div",{className:u(...i)},a.createElement("div",{className:u(...n)},this.props.children)):0===r?a.createElement("div",{className:u(...i,wa.wrapperAlignToEnd)},a.createElement("div",{className:u(...n)},this.props.children)):a.createElement("div",{className:u(...i)},a.createElement("div",{style:{flexShrink:r,flexBasis:t}}),a.createElement("div",{className:u(...n)},this.props.children),a.createElement("div",{style:{flexShrink:t,flexBasis:r}}))}}var wa=d.create({wrapper:{display:"flex",overflow:"hidden"},wrapperHorizontal:{flexDirection:"row",width:"100%"},wrapperVertical:{flexDirection:"column",height:"100%"},wrapperAlignToEnd:{justifyContent:"flex-end"},content:{flex:"0 0 auto"},contentHorizontal:{maxWidth:"100%"},contentVertical:{maxHeight:"100%"}}),ka=parseInt("6px");function Ea(e){var{color:t,inverted:r}=e;return r?{backgroundColor:t,textColor:E.white}:{backgroundColor:E.white,textColor:t}}class Sa extends a.PureComponent{render(){var e,t,r,{onClick:i,onMouseEnter:n,onMouseLeave:s,side:o}=this.props.tooltipProps,{backgroundColor:l}=Ea(this.props.tooltipProps);if("top"===o)e=["0,0","".concat(9,",").concat(9),"".concat(18,",0")],t=18,r=9;else if("right"===o)e=["".concat(9,",0"),"0,".concat(9),"".concat(9,",").concat(18)],t=9,r=18;else if("bottom"===o)e=["0,".concat(9),"".concat(9,",0"),"".concat(18,",").concat(9)],t=18,r=9;else{if("left"!==o)throw new he("unexpected side ".concat(o),le.InvalidInput);e=["0,0","".concat(9,",").concat(9),"0,".concat(18)],t=9,r=18}return a.createElement("svg",{width:t,height:r,className:u(_a.tooltipArrow)},a.createElement("filter",{id:"tooltip-dropshadow-".concat(o),height:"150%"},a.createElement("feOffset",{dx:0,dy:1,result:"offsetblur"}),a.createElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:2}),a.createElement("feComponentTransfer",null,a.createElement("feFuncA",{type:"linear",slope:.1})),a.createElement("feMerge",null,a.createElement("feMergeNode",null),a.createElement("feMergeNode",{in:"SourceGraphic"}))),a.createElement("polyline",{fill:l,stroke:l,points:e.join(" "),className:u(i&&_a.tooltipArrowShapeWithOnClick),onClick:i,onMouseEnter:n,onMouseLeave:s}),a.createElement("polyline",{fill:l,points:e.join(" "),stroke:"rgba(0, 0, 0, 0.1)",filter:"url(#tooltip-dropshadow-".concat(o,")")}))}}var _a=d.create({tooltipArrow:{display:"block",userSelect:"none"},tooltipArrowShapeWithOnClick:{pointerEvents:"auto",cursor:"pointer"}}),Ma=d.create({srOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1}});class Ta extends a.PureComponent{constructor(){super(...arguments),V(this,"_handleClickClose",(()=>this.props.dismiss()))}_renderCloseButton(e){var{inverted:t,dismissOnClickClose:r}=this.props.tooltipProps;if(!r)return null;var i=e.get("button-description"),n=this.getA11yHeaderId(e);return a.createElement("button",{className:u(Ia.closeIcon),onClick:this._handleClickClose,"aria-describedby":"".concat(i," ").concat(n)},a.createElement(ca,{title:s._("Close"),icon:"M6.26353762,4.99851587 L9.73097464,1.53107884 C10.0836373,1.17841618 10.0842213,0.612127047 9.73530496,0.263210718 C9.38395604,-0.0881381913 8.81874474,-0.0837668714 8.46743686,0.267541014 L4.99999981,3.73497806 L1.5325628,0.267541051 C1.1812549,-0.0837668481 0.616043606, -0.0881381955 0.264694717,0.263210694 C-0.0842215912,0.612127004 -0.0836375768,1.17841613 0.269025093,1.5310788 L3.73646206,4.9985158 L0.269025109,8.46595276 C-0.083637537,8.81861541 -0.0842215923, 9.38490462 0.264694642,9.73382106 C0.616043456,10.0851701 1.18125469, 10.0807988 1.53256259,9.72949093 L4.99999988,6.26205363 L8.46743739, 9.72949117 C8.8187453,10.0807991 9.38395655,10.0851704 9.73530537, 9.73382138 C10.0842216,9.38490498 10.0836375,8.81861579 9.73097488, 8.46595313 L6.26353762,4.99851587 Z",size:10,color:t?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.15)"}),a.createElement("div",{id:i,className:u(Ma.srOnly)},s._("Closes the tooltip: ")))}getA11yHeaderId(e){var{tooltipProps:{a11y:t}}=this.props;return t&&t.title?"string"==typeof t.title?e.get("header"):t.title.id:this.getA11yContentId(e)}getA11yContentId(e){return e.get("content")}renderTooltip(e){var{content:t,dismissOnClickClose:r,noPadding:i,onClick:n,onMouseEnter:s,onMouseLeave:o,a11y:l,testId:p}=this.props.tooltipProps,h=l&&l.title,c=l&&l.assertiveness,{backgroundColor:d,textColor:m}=Ea(this.props.tooltipProps),g=this.getA11yHeaderId(e),f=this.getA11yContentId(e);return a.createElement("div",{className:u(Ia.tooltipBubble,!i&&Ia.tooltipBubbleWithPadding,r&&Ia.tooltipBubbleWithCloseIcon,n&&Ia.tooltipBubbleWithOnClick),onClick:n,onMouseEnter:s,onMouseLeave:o,style:{backgroundColor:d,color:m},role:"region","aria-labelledby":g,"aria-describedby":f===g?null:f,"data-test-id":p},this._renderCloseButton(e),a.createElement("div",{"aria-live":c},"string"==typeof h?a.createElement("div",{className:u(Ma.srOnly),id:g},h):null,a.createElement("div",{id:f,className:u(Ia.tooltipContent)},t)))}render(){return a.createElement(_,{mockOnFirstRender:!1,scope:"tooltip-bubble"},(e=>this.renderTooltip(e)))}}var Ia=d.create({tooltipBubble:U(U({boxSizing:"border-box",position:"relative"},fa.labelMedium),{},{borderRadius:ka,border:"1px solid rgba(0, 0, 0, 0.1)",boxShadow:"".concat(0,"px ").concat(1,"px ")+"".concat(4,"px 0px ")+"rgba(0, 0, 0, ".concat(.1,")"),userSelect:"none"}),tooltipBubbleWithPadding:{padding:"10px 23px"},tooltipBubbleWithCloseIcon:{paddingRight:34},tooltipBubbleWithOnClick:{cursor:"pointer"},tooltipContent:{userSelect:"auto"},closeIcon:{display:"block",position:"absolute",right:10,top:10,padding:0,background:"inherit",border:"none"}});class Pa extends a.PureComponent{constructor(){super(...arguments),V(this,"_mountRemeasureTimeout",void 0),V(this,"state",{targetElementClientRect:null,rootElementClientRect:null}),V(this,"_handleScroll",(e=>{var{rootElement:t,targetElement:r}=this.props,i=e.target;t.contains(i)&&i.contains(r)&&this.remeasure()})),V(this,"remeasure",(()=>{var{targetElement:e,rootElement:t}=this.props;this.setState({targetElementClientRect:e.getBoundingClientRect(),rootElementClientRect:t.getBoundingClientRect()})}))}componentDidMount(){this._mountRemeasureTimeout=setTimeout(this.remeasure,0),window.addEventListener("resize",this.remeasure),window.addEventListener("scroll",this._handleScroll,!0)}componentWillUnmount(){this._mountRemeasureTimeout&&clearTimeout(this._mountRemeasureTimeout),window.removeEventListener("resize",this.remeasure),window.removeEventListener("scroll",this._handleScroll,!0)}_computeTargetPointOffsets(e,t){var r,{offset:i,offsetFrom:n,side:s}=this.props.tooltipProps,o=e,a=t,l=i;if("arrow"===n&&(l+=9),"top"===s)r={left:o.left+o.width/2,top:o.top-l};else if("bottom"===s)r={left:o.left+o.width/2,top:o.bottom+l};else if("left"===s)r={left:o.left-l,top:o.top+o.height/2};else{if("right"!==s)throw new he("unexpected side ".concat(s),le.InvalidInput);r={left:o.right+l,top:o.top+o.height/2}}return{pxFromTop:r.top-a.top,pxFromBottom:a.bottom-r.top,pxFromLeft:r.left-a.left,pxFromRight:a.right-r.left}}_renderBubble(e){var t,{isAboveModal:r}=this.props,{side:i,tooltipMargin:n}=this.props.tooltipProps,s={},o={},l={};if("top"===i||"bottom"===i)t=Aa.tooltipBubblePositionerTopBottom,o.direction="horizontal",o.pxFromStart=e.pxFromLeft,o.pxFromEnd=e.pxFromRight,l.marginLeft=n,l.marginRight=n;else{if("left"!==i&&"right"!==i)throw new he("unexpected side ".concat(i),le.InvalidInput);t=Aa.tooltipBubblePositionerLeftRight,o.direction="vertical",o.pxFromStart=e.pxFromTop,o.pxFromEnd=e.pxFromBottom,l.marginTop=n,l.marginBottom=n}if("top"===i)s.bottom=e.pxFromBottom;else if("bottom"===i)s.top=e.pxFromTop;else if("left"===i)s.right=e.pxFromRight;else{if("right"!==i)throw new he("unexpected side ".concat(i),le.InvalidInput);s.left=e.pxFromLeft}return a.createElement("div",{className:u(Aa.tooltipBubblePositioner,t,r&&Aa.tooltipAboveModal),style:s},a.createElement(Ca,o,a.createElement("div",{className:u(Aa.tooltipBubbleWrapper),style:l},a.createElement(Ta,{tooltipProps:this.props.tooltipProps,dismiss:this.props.dismiss}))))}_renderArrow(e,t){var{isAboveModal:r}=this.props,{side:i,tooltipMargin:n}=this.props.tooltipProps,s={};if("top"===i)s.bottom=e.pxFromBottom-9+1;else if("bottom"===i)s.top=e.pxFromTop-9+1;else if("left"===i)s.right=e.pxFromRight-9+1;else{if("right"!==i)throw new he("unexpected side ".concat(i),le.InvalidInput);s.left=e.pxFromLeft-9+1}var o=n+ka;if("top"===i||"bottom"===i){var l=o,p=t.width-18-o;s.left=e.pxFromLeft-9,s.left=Math.min(s.left,p),s.left=Math.max(s.left,l)}else{if("left"!==i&&"right"!==i)throw new he("unexpected side ".concat(i),le.InvalidInput);var h=o,c=t.height-18-o;s.top=e.pxFromTop-9,s.top=Math.min(s.top,c),s.top=Math.max(s.top,h)}return a.createElement("div",{className:u(Aa.tooltipArrowPositioner,r&&Aa.tooltipAboveModal),style:s},a.createElement(Sa,{tooltipProps:this.props.tooltipProps}))}_buildMediaFilterStyle(){var{media:e}=this.props.tooltipProps;return e?d.create({mediaFilter:{display:"none",[e]:{display:"block"}}}).mediaFilter:null}render(){var{targetElementClientRect:e,rootElementClientRect:t}=this.state;if(!e||!t)return null;var r=this._computeTargetPointOffsets(e,t);return a.createElement("div",{className:u(this._buildMediaFilterStyle())},this._renderBubble(r),this._renderArrow(r,t))}}var Aa=d.create({tooltipBubblePositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"},tooltipAboveModal:{zIndex:1090},tooltipBubblePositionerTopBottom:{left:0,width:"100%"},tooltipBubblePositionerLeftRight:{top:0,height:"100%"},tooltipBubbleWrapper:{pointerEvents:"auto"},tooltipArrowPositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"}});class Na extends a.Component{constructor(){super(...arguments),V(this,"_mountNode",void 0),V(this,"_tooltipPositioner",void 0)}componentDidMount(){var e=document.createElement("div");this._mountNode=e,this.props.rootElement.appendChild(e),this._renderInMountNode(e)}componentDidUpdate(){var e=this._mountNode;e&&this._renderInMountNode(e)}componentWillUnmount(){var e=this._mountNode;e&&(g.unmountComponentAtNode(e),this.props.rootElement.removeChild(e))}remeasure(){this._tooltipPositioner&&this._tooltipPositioner.remeasure()}_renderInMountNode(e){var{tooltipProps:t,dismiss:r,rootElement:i,targetElement:n,isAboveModal:s}=this.props;g.render(a.createElement(Pa,{tooltipProps:t,dismiss:r,rootElement:i,targetElement:n,isAboveModal:s,ref:e=>this._tooltipPositioner=e}),e)}render(){return null}}var Ra=["children"],Fa=Object.freeze({side:"top",offset:0,offsetFrom:"bubble",tooltipMargin:0,noPadding:!1,color:ua.gray17,inverted:!1,dismissOnClickClose:!1,toggleOnHover:!0,showOnMount:!1});class Da extends a.PureComponent{constructor(e){super(e),V(this,"_rootElement",void 0),V(this,"_wrapper",void 0),V(this,"_targetElement",void 0),V(this,"_tooltipPortal",void 0),V(this,"_visibilityObserver",void 0),V(this,"_isMounted",void 0),V(this,"_targetElementMountTimeout",void 0),V(this,"_handleVisibilityChange",(e=>{this.setState({targetElementIsVisible:e})})),V(this,"_handleMouseEnter",(()=>{this.setState({hovered:!0})})),V(this,"_handleMouseLeave",(()=>{this.setState({hovered:!1})})),V(this,"_handleDismiss",(()=>{null==this.props.dismissed&&this.setState({dismissed:!0}),this.props.onDismiss&&this.props.onDismiss()})),this._isMounted=!1,this.state={dismissed:null!=e.dismissed&&e.dismissed,hovered:!1,targetElementIsVisible:!1}}componentDidMount(){this._isMounted=!0,this._registerVisibilityObserver()}UNSAFE_componentWillReceiveProps(e){null!=e.dismissed&&this.setState({dismissed:e.dismissed})}UNSAFE_componentWillUpdate(){this._registerVisibilityObserver()}componentWillUnmount(){this._isMounted=!1,this._targetElementMountTimeout&&clearTimeout(this._targetElementMountTimeout),this._visibilityObserver.disconnect()}_findRootElement(){return this.context.modalContainerElement||document.getElementById("mission-task-container")||document.getElementById("outer-wrapper")||document.body}_registerVisibilityObserver(){var e=this._findRootElement();if(!e)throw new he("Failed to mount NewTooltip: we need a #outer-wrapper or document.body element.",le.Internal);if(e!==this._rootElement){this._rootElement=e,this._visibilityObserver&&this._visibilityObserver.disconnect(),this._visibilityObserver=function(e,t,r){return new xa(e,t,r)}(e,this._handleVisibilityChange);var t=this._wrapper;if(!t)throw new he("NewTooltip expected a wrapper element after mount",le.Internal);for(var r=t;r.hasAttribute("data-tooltip-wrapper");)if(!(r=r.childNodes[0]))throw new he("NewTooltip expected wrapper element to have a child",le.Internal);this._targetElement=r,this._targetElementMountTimeout=setTimeout((()=>{var e=this._targetElement;if(!e)throw new he("NewTooltip should have a target element after mounting.",le.Internal);oe().isDevServer&&"inline"===getComputedStyle(e).display&&(pe.error("Warning: The children of a NewTooltip element must be block-like, but this element seems to have `display: inline`. This could break position tracking.",le.Internal),pe.log("NewTooltip Target Element:",{targetElement:e.outerHTML})),this._visibilityObserver.setTargetElement(e),this.forceUpdate()}),0)}}_shouldShowTooltip(){var{toggleOnHover:e,showOnMount:t}=this.props,{dismissed:r,targetElementIsVisible:i}=this.state;return!1!==i&&(!r&&(!!t||!(!e||!this.state.hovered)))}remeasure(){this._tooltipPortal&&this._tooltipPortal.remeasure()}render(){var{children:e,toggleOnHover:t}=this.props,r=Y(this.props,Ra);return a.createElement("div",{className:u(Oa.targetElement),onMouseEnter:t?this._handleMouseEnter:void 0,onMouseLeave:t?this._handleMouseLeave:void 0,ref:e=>this._wrapper=e,"data-tooltip-wrapper":!0,"data-test-id":"question-id"},e,this._targetElement&&this._shouldShowTooltip()&&a.createElement(Na,{tooltipProps:r,dismiss:this._handleDismiss,rootElement:this._rootElement,targetElement:this._targetElement,isAboveModal:!!this.context.modalContainerElement,ref:e=>this._tooltipPortal=e}))}}V(Da,"defaultProps",Fa),Da.contextTypes={modalContainerElement:h.instanceOf(HTMLElement)};var Oa=d.create({targetElement:{display:"inline"}});class La extends a.PureComponent{constructor(){super(...arguments),V(this,"_handleKeyDown",(e=>{"Tab"===e.key&&(this.props.onDismiss(),e.preventDefault())}))}_renderTooltipContent(){return a.createElement("div",{onKeyDown:this._handleKeyDown},a.createElement(ba,this.props.buttonProps))}render(){return a.createElement("div",null,a.createElement(Da,{content:this._renderTooltipContent(),offsetFrom:"arrow",offset:10,dismissed:this.props.dismissed,showOnMount:!0,toggleOnHover:!1,onClick:()=>this.props.buttonProps.onClick(),media:jo.mdOrLarger},this.props.children),!this.props.dismissed&&a.createElement(Ba,{onDismiss:this.props.onDismiss}))}}class Ba extends a.PureComponent{constructor(){super(...arguments),V(this,"_handleGlobalClick",(()=>{this.props.onDismiss()})),V(this,"_handleGlobalKeyup",(e=>{"Escape"===e.key&&this.props.onDismiss()}))}componentDidMount(){setTimeout((()=>{window.addEventListener("click",this._handleGlobalClick),window.addEventListener("keyup",this._handleGlobalKeyup)}),0)}componentWillUnmount(){window.removeEventListener("click",this._handleGlobalClick),window.removeEventListener("keyup",this._handleGlobalKeyup)}render(){return null}}var za={path:"M27.218 6.82l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:27.284};class qa extends a.PureComponent{constructor(){super(...arguments),V(this,"_menu",void 0),V(this,"_menuButton",void 0),V(this,"_crossOutButtonIsFocused",void 0),V(this,"state",{hovered:!1,opened:!1,slidePanelCovered:!0,usingKeyboardFocus:!1,wasCrossedOutOnLastOpen:!1}),V(this,"_openMenu",(()=>{var e=null!=this._menu&&this._menu.contains(document.activeElement);this.setState({opened:!0,usingKeyboardFocus:e,wasCrossedOutOnLastOpen:this.props.crossedOut})})),V(this,"_closeMenu",(()=>{this._crossOutButtonIsFocused&&this._menuButton&&this._menuButton.focus(),this.setState({opened:!1,slidePanelCovered:!0})})),V(this,"_handleMenuClick",((e,t)=>{t?this._openMenu():this._closeMenu(),e.preventDefault()})),V(this,"_handleCrossedOutButtonClick",(e=>{this.props.onCrossedOutChange(e),this._closeMenu()})),V(this,"_handleSlideTransitionEnd",(()=>{this.state.opened&&this.setState({slidePanelCovered:!1})}))}UNSAFE_componentWillReceiveProps(e){e.enabled||this._closeMenu()}_getButtonProps(e){var t=this.state.wasCrossedOutOnLastOpen;return{onClick:()=>{this._handleCrossedOutButtonClick(!t)},onFocus:()=>{this._crossOutButtonIsFocused=!0},onBlur:()=>{this._crossOutButtonIsFocused=!1},crossedOut:t,pos:this.props.pos,primaryProductColor:this.props.primaryProductColor,usingKeyboardFocus:this.state.usingKeyboardFocus,theme:e}}_getMenuIconColor(){return this.state.opened?this.props.primaryProductColor:this.state.hovered?E.offBlack:E.offBlack50}_renderMenu(){var{pos:e,isSatProduct:t}=this.props,{opened:r}=this.state,i=u(Ha.menu,t&&Ha.spacing);return a.createElement("div",{ref:e=>this._menu=e,className:i,onClick:e=>this._handleMenuClick(e,!r),onMouseEnter:()=>this.setState({hovered:!0}),onMouseLeave:()=>this.setState({hovered:!1})},a.createElement(La,{dismissed:!this.state.opened,onDismiss:this._closeMenu,buttonProps:this._getButtonProps("day")},a.createElement("button",{type:"button","aria-label":s._("Open menu for Choice %(letter)s",{letter:sa(e)}),className:u([Ha.menuButton]),onClick:e=>this._handleMenuClick(e,!r),onMouseDown:e=>e.preventDefault(),ref:e=>this._menuButton=e},a.createElement(ca,{className:u(Ha.menuIcon),icon:za,size:3,color:this._getMenuIconColor()}))))}_renderSlidePanel(){var e=this._getButtonProps("night"),{slidePanelCovered:t}=this.state;return a.createElement("div",{className:u(Ha.slidePanel,t&&Ha.slidePanelCovered),onClick:e.onClick,"aria-hidden":t},a.createElement(ba,j({},e,{disabled:t,tabFocusable:!t})))}render(){var{enabled:e}=this.props,{opened:t}=this.state;return a.createElement("div",{className:u(Ha.wrapper)},a.createElement("div",{className:u(Ha.slidingContent,e&&Ha.slidingContentEnabled,t&&Ha.slidingContentOpen),onTransitionEnd:this._handleSlideTransitionEnd},a.createElement("div",{className:u(Ha.content)},this.props.children),e&&this._renderMenu()),e&&this._renderSlidePanel())}}var Ha=d.create({wrapper:{display:"block",position:"relative"},slidingContent:{display:"flex",flexDirection:"row",alignItems:"stretch"},slidingContentEnabled:{[jo.smOrSmaller]:{transition:"transform 0.2s ease-out",backgroundColor:E.white}},slidingContentOpen:{[jo.smOrSmaller]:{transform:"translateX(-".concat(96,"px)")}},content:{display:"block",flex:"1 1 0"},menu:{cursor:"pointer",boxSizing:"border-box",width:32,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",[jo.smOrSmaller]:{paddingRight:8}},menuButton:{background:"none",border:"none",font:"inherit",padding:0,textAlign:"inherit",cursor:"pointer",display:"flex",flexDirection:"column",justifyContent:"center",height:16},menuIcon:{display:"block"},slidePanel:{position:"absolute",top:0,right:0,boxSizing:"border-box",width:96,height:"100%",paddingLeft:8,paddingRight:8,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",background:E.offBlack50,cursor:"pointer",[jo.mdOrLarger]:{display:"none"}},spacing:{paddingRight:12},slidePanelCovered:{zIndex:-1}});class Wa extends a.Component{_renderText(){var{checked:e,correct:t,crossedOut:r}=this.props;return t?e?s._("Correct (selected)"):r?s._("Correct (but you crossed it out)"):s._("Correct"):e?s._("Incorrect (selected)"):s._("Incorrect")}render(){var e,{checked:t,correct:r,previouslyAnswered:i}=this.props;return e=r?Ua.correct:t||i?Ua.incorrectAnswered:Ua.incorrect,a.createElement("div",{className:u(Ua.text,e)},this._renderText())}}var Ua=d.create({text:{alignItems:"center",display:"flex",fontSize:12,height:32,textTransform:"uppercase"},correct:{color:"#71B307"},incorrectAnswered:{color:"#F86700"},incorrect:{color:J}}),Ga=["inputRef","onChecked","goToPrevChoice","goToNextChoice"];class Va extends a.Component{constructor(){super(...arguments),V(this,"_inputElement",void 0),V(this,"handleClick",(e=>{this.props.onChecked(!this.props.checked)})),V(this,"handleKeyUp",(e=>{" "===e.key&&(this.props.onChecked(!this.props.checked),e.preventDefault())})),V(this,"handleChange",(e=>{!this.props.checked&&e.target.checked&&this.props.onChecked(!0)})),V(this,"handleKeyDown",(e=>{" "===e.key?e.preventDefault():"ArrowUp"===e.key||"ArrowLeft"===e.key?(this.props.goToPrevChoice(),e.preventDefault()):"ArrowDown"!==e.key&&"ArrowRight"!==e.key||(this.props.goToNextChoice(),e.preventDefault())})),V(this,"handleRef",(e=>{this._inputElement=e,this.props.inputRef&&this.props.inputRef(e)}))}render(){var e=Y(this.props,Ga);return a.createElement("input",j({},e,{type:"radio",onChange:this.handleChange,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,ref:this.handleRef}))}}V(Va,"propTypes",{checked:h.bool.isRequired,inputRef:h.func,onChecked:h.func.isRequired,goToPrevChoice:h.func.isRequired,goToNextChoice:h.func.isRequired});var ja={backgroundColor:"#E4F3F9",outline:"2px solid ".concat("#0084CE"),zIndex:1};class Ya extends a.Component{constructor(){super(...arguments),V(this,"justFinishedTouch",void 0),V(this,"justFinishedTimeoutID",void 0),V(this,"_input",void 0),V(this,"state",{isInputFocused:!1,isInputActive:!1}),V(this,"onInputFocus",(()=>{this.setState({isInputFocused:!0})})),V(this,"onInputBlur",(()=>{this.setState({isInputFocused:!1})})),V(this,"onInputMouseDown",(e=>{"mousedown"===e.type&&this.justFinishedTouch||(this.setState({isInputActive:!0}),this.props.apiOptions.satStyling&&this._input&&this._input.focus())})),V(this,"onInputMouseUp",(e=>{if("mouseup"!==e.type||!this.justFinishedTouch){if("touchend"===e.type)return this.justFinishedTouch=!0,null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID),void(this.justFinishedTimeoutID=setTimeout((()=>{this.setState({isInputActive:!1}),this.justFinishedTouch=!1}),10));this.setState({isInputActive:!1}),this.props.apiOptions.satStyling&&this._input&&this._input.focus()}})),V(this,"onInputMouseOut",(()=>{this.setState({isInputActive:!1})})),V(this,"inputRef",(e=>{this._input=e})),V(this,"renderOptionStatus",(()=>{var{correct:e,checked:t,crossedOut:r,reviewMode:i,previouslyAnswered:n}=this.props;return this.props.apiOptions.satStyling?null:i||n?a.createElement(Wa,{checked:t,correct:e,crossedOut:r,previouslyAnswered:n}):null})),V(this,"renderChoiceIcon",(()=>{var{radioStyleVersion:e,primaryProductColor:t}=this.props.apiOptions.styling;return void 0!==e&&"final"===e||this.props.apiOptions.satStyling?a.createElement(pa,{pos:this.props.pos,correct:this.props.correct,crossedOut:this.props.crossedOut,pressed:this.state.isInputActive,focused:this.state.isInputFocused,checked:this.props.checked,showCorrectness:this.props.showCorrectness,reviewMode:this.props.reviewMode,product:this.props.apiOptions.satStyling?"sat":"library",primaryProductColor:t,previouslyAnswered:this.props.previouslyAnswered}):null})),V(this,"_setChecked",(e=>{e?this._sendChange({checked:!0,crossedOut:!1}):this._sendChange({checked:!1})})),V(this,"_setCrossedOut",(e=>{e?this._sendChange({checked:!1,crossedOut:!0}):this._sendChange({crossedOut:!1})})),V(this,"_sendChange",(e=>{var t=null!=e.checked?e.checked:this.props.checked,r=null!=e.crossedOut?e.crossedOut:this.props.crossedOut;this.props.onChange({checked:t,crossedOut:r})})),V(this,"focusInput",(()=>{var e;null===(e=this._input)||void 0===e||e.focus()}))}UNSAFE_componentWillUpdate(e){this.state.isInputFocused&&e.disabled&&this.setState({isInputFocused:!1})}componentWillUnmount(){null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID)}render(){var e=this.props.apiOptions.satStyling,t=this.props.apiOptions.isMobile,{radioStyleVersion:r}=this.props.apiOptions.styling,i=void 0!==r&&"final"===r,n=o(this.props.className,"checkbox-label",u(Xa.label,t&&Qo.disableTextSelection,!e&&Xa.responsiveLabel,e&&Xa.satLabel)),s=o(u(this.state.isInputFocused&&Xa.satDescriptionInputFocused,this.state.isInputActive&&Xa.satDescriptionInputActive)),l=this.props.showCorrectness&&!this.props.correct,p=this.props.checked&&!l,h={type:this.props.type,name:this.props.groupName,id:"".concat(this.props.groupName,"-choice-").concat(this.props.pos),checked:p,disabled:this.props.disabled,onFocus:this.onInputFocus,onBlur:this.onInputBlur,className:u(!i&&Qo.perseusInteractive,!i&&Xa.input,!i&&Qo.responsiveInput,!i&&!e&&Qo.responsiveRadioInput,!i&&!e&&this.state.isInputActive&&Qo.responsiveRadioInputActive,i&&Qo.perseusSrOnly,e&&Qo.perseusSrOnly,e&&this.props.reviewMode&&Xa.satReviewInput)},c=null;c="radio"===this.props.type?a.createElement(Va,j({onChecked:e=>this._setChecked(e),goToPrevChoice:this.props.goToPrevChoice,goToNextChoice:this.props.goToNextChoice,inputRef:this.inputRef},h)):a.createElement("input",j({onChange:e=>this._setChecked(e.target.checked),ref:this.inputRef},h));var{reviewMode:d,correct:m,checked:g}=this.props,f=e&&d&&m,v=e&&d&&!m&&g,b=o("description",f&&"sat-correct",v&&"sat-incorrect",u(!e&&Xa.description,e&&Xa.satDescription,f&&Xa.satDescriptionCorrect,f&&g&&Xa.satDescriptionCorrectChecked,v&&Xa.satDescriptionIncorrectChecked)),y=o("checkbox",u(Qo.perseusInteractive,!e&&Xa.choiceIconWrapper,e&&Xa.satCheckboxOptionContent)),x=o("checkbox-and-option",u(!e&&Xa.intermediateResponsiveCheckbox,!e&&d&&Xa.intermediateResponsiveCheckboxReview)),C=o("perseus-radio-rationale-content",u(Xa.rationale,!e&&Xa.nonSatRationale,e&&Xa.satReviewRationale)),w=this.props.editMode?"div":"label",k=this.props.apiOptions.crossOutEnabled&&!this.props.showCorrectness,E=!e&&!d&&this.props.apiOptions.readOnly||k&&this.props.crossedOut;return a.createElement("div",{className:e?s:void 0},a.createElement(qa,{enabled:k,pos:this.props.pos,primaryProductColor:this.props.apiOptions.styling.primaryProductColor,crossedOut:this.props.crossedOut,onCrossedOutChange:this._setCrossedOut,isSatProduct:e},a.createElement(w,{htmlFor:this.props.editMode?void 0:h.id,className:n,style:{opacity:E?.5:1}},a.createElement("div",{className:b,onMouseDown:this.onInputMouseDown,onMouseUp:this.onInputMouseUp,onMouseOut:this.onInputMouseOut,onTouchStart:this.onInputMouseDown,onTouchEnd:this.onInputMouseUp},a.createElement("div",{className:x},a.createElement("span",{className:y},c,this.renderChoiceIcon()),a.createElement("span",{className:o(Zt.RADIO.OPTION_CONTENT,Zt.INTERACTIVE,u(e&&Xa.satRadioOptionContent,e&&d&&Xa.satReviewRadioOptionContent)),style:{cursor:"default"}},a.createElement("div",{className:u(Xa.optionStatusContainer)},this.renderOptionStatus()),a.createElement("div",null,this.props.content))),this.props.showRationale&&a.createElement("div",{className:C,"data-test-id":"perseus-radio-rationale-content-".concat(this.props.pos)},this.props.rationale)))))}}V(Ya,"propTypes",{apiOptions:h.shape({satStyling:h.bool,isMobile:h.bool,styling:h.shape({radioStyleVersion:h.oneOf(["intermediate","final"]),primaryProductColor:h.string}),readOnly:h.bool}),checked:h.bool,className:h.string,rationale:h.node,content:h.node,correct:h.bool,deselectEnabled:h.bool,disabled:h.bool,editMode:h.bool,groupName:h.string,isLastChoice:h.bool,pos:h.number,reviewMode:h.bool,showRationale:h.bool,showCorrectness:h.bool,type:h.string,crossedOut:h.bool,previouslyAnswered:h.bool,onChange:h.func,goToPrevChoice:h.func.isRequired,goToNextChoice:h.func.isRequired}),V(Ya,"defaultProps",{apiOptions:{styling:{}},checked:!1,classSet:{},correct:!1,disabled:!1,editMode:!1,onChange:function(){},showRationale:!1,type:"radio",pos:0,previouslyAnswered:!1});var Xa=d.create({description:{display:"inline-block",width:"100%"},satDescription:{display:"block",position:"relative",boxSizing:"border-box",cursor:"pointer",marginLeft:0,padding:"17px 14px"},satDescriptionInputFocused:U(U({},ja),{},{display:"block"}),satDescriptionInputActive:U(U({},ja),{},{backgroundColor:"#D0EDF4"}),satDescriptionCorrect:{color:"#009900"},satDescriptionCorrectChecked:{backgroundColor:"#E4F7E4"},satDescriptionIncorrectChecked:{color:"#990000",backgroundColor:"#F2EBEB"},input:{display:"inline-block",width:20,margin:3,marginLeft:-20,marginRight:0,float:"none"},satReviewInput:{pointerEvents:"none"},satRadioOptionContent:{userSelect:"text",display:"block",marginLeft:45,cursor:"inherit"},satReviewRadioOptionContent:{fontWeight:"bold"},satCheckboxOptionContent:{position:"absolute",display:"block",top:"50%",margin:"-16px 0 0 0",width:"auto"},choiceIconWrapper:{display:"flex",marginRight:12,flexShrink:0},optionStatusContainer:{display:"block"},rationale:{display:"block"},nonSatRationale:{padding:"16px 16px",paddingTop:0,marginLeft:44,[jo.smOrSmaller]:{padding:"12px 16px",paddingTop:0}},satReviewRationale:{marginTop:13,marginLeft:45},label:{display:"block",transition:"opacity 0.2s ease-out"},responsiveLabel:{WebkitTapHighlightColor:"transparent",display:"flex",alignItems:"stretch"},satLabel:{cursor:"pointer"},intermediateResponsiveCheckbox:{display:"flex",alignItems:"center",padding:"16px 16px",[jo.smOrSmaller]:{padding:"12px 16px"}},intermediateResponsiveCheckboxReview:{alignItems:"flex-start"}});class $a extends a.Component{constructor(){super(...arguments),V(this,"_choice",void 0),V(this,"focusInput",(()=>{this._choice.focusInput()}))}render(){var e=U(U({},this.props),{},{className:o(this.props.className,"none-of-above"),content:this.props.showContent?this.props.content:a.createElement(Ds,{key:"noneOfTheAboveRenderer",content:s._("None of the above")}),ref:e=>this._choice=e});return a.createElement(Ya,e)}}V($a,"propTypes",{className:h.string,content:h.node,showContent:h.bool}),V($a,"defaultProps",{showContent:!0});var{captureScratchpadTouchStart:Ka}=De,Za=h.arrayOf(h.shape({checked:h.bool,crossedOut:h.bool,content:h.node,rationale:h.node,hasRationale:h.bool,showRationale:h.bool,showCorrectness:h.bool,correct:h.bool,originalIndex:h.number,isNoneOfTheAbove:h.bool}));class Ja extends a.Component{constructor(){super(...arguments),V(this,"state",{radioGroupName:l.uniqueId("perseus_radio_")}),V(this,"updateChoice",((e,t)=>{var r;r=t.checked&&!this.props.multipleSelect?this.props.choices.map((e=>!1)):this.props.choices.map((e=>e.checked));var i=this.props.choices.map((e=>e.crossedOut));r[e]=t.checked,i[e]=t.crossedOut,this.props.onChange({checked:r,crossedOut:i})})),V(this,"focus",(e=>(g.findDOMNode(this.refs["radio"+(e||0)]).focus(),!0))),V(this,"getInstructionsText",(()=>this.props.multipleSelect?this.props.countChoices?s._("Choose %(numCorrect)s answers:",{numCorrect:this.props.numCorrect}):s._("Choose all answers that apply:"):s._("Choose 1 answer:"))),V(this,"deselectEnabled",(()=>this.props.apiOptions.isMobile||this.props.deselectEnabled)),V(this,"goToChoice",(e=>{var t=this.props.choices.length;e<0&&(e+=t),e>=t&&(e-=t);var r=this.refs["radio".concat(e)];if(r){r.focusInput();var i=this.props.choices.map((e=>e.crossedOut)),n=this.props.choices.map((e=>!1));this.props.choices[e].crossedOut||(n[e]=!0),this.props.onChange({checked:n,crossedOut:i})}else pe.error("found no choice at index ".concat(e,", even after ")+"wrapping it to be within bounds",le.Internal,{loggedMetadata:{choices:JSON.stringify(this.props.choices)}})}))}componentDidUpdate(e){var{apiOptions:t,choices:r,isLastUsedWidget:i,reviewModeRubric:n}=this.props;if(t.canScrollPage&&i&&n&&!e.reviewModeRubric){var s=r.findIndex((e=>e.checked));if(s>=0){var o=g.findDOMNode(this.refs["radio"+s]);ra(o)}}}render(){var e=this.props.multipleSelect?"checkbox":"radio",t=this.props.reviewModeRubric,r=!!t,i=Ja.styles,n=this.props.apiOptions.satStyling,s=this.props.apiOptions.isMobile,p=this.props.choices,h=p[0].highlighted,c=p[p.length-1].highlighted,d=o("perseus-widget-radio",!this.props.editMode&&"perseus-rendered-radio",u(i.radio,!n&&i.responsiveRadioContainer,!n&&h&&s&&i.radioContainerFirstHighlighted,!n&&c&&s&&i.radioContainerLastHighlighted,n&&i.satRadio)),m=o("instructions",u(i.instructions,s&&i.instructionsMobile)),g=this.getInstructionsText(),f=!n,v=u(i.responsiveFieldset),b=a.createElement("fieldset",{className:"perseus-widget-radio-fieldset ".concat(v)},a.createElement("legend",{className:"perseus-sr-only"},g),f&&a.createElement("div",{className:m},g),a.createElement("ul",{className:d},this.props.choices.map((function(s,p){var h=Ya,c={ref:"radio".concat(p),apiOptions:this.props.apiOptions,checked:s.checked,crossedOut:s.crossedOut,previouslyAnswered:s.previouslyAnswered,reviewMode:r,correct:s.correct,rationale:s.rationale,content:s.content,disabled:this.props.apiOptions.readOnly||s.disabled,editMode:this.props.editMode,groupName:this.state.radioGroupName,isLastChoice:p===this.props.choices.length-1,showCorrectness:r||!!s.showCorrectness,showRationale:s.hasRationale&&(r||s.showRationale),type:e,pos:p,deselectEnabled:this.deselectEnabled(),onChange:e=>{this.updateChoice(p,e)},goToPrevChoice:()=>this.goToChoice(p-1),goToNextChoice:()=>this.goToChoice(p+1)};s.isNoneOfTheAbove&&(h=$a,l.extend(c,{showContent:s.revealNoneOfTheAbove}));var d=this.props.choices[p+1],m=!!d&&d.highlighted,g=e=>{var o=n&&r&&e,a=n&&r&&d&&d.checked;return u(Qo.aboveScratchpad,i.item,!n&&i.responsiveItem,!n&&e&&i.selectedItem,!n&&e&&s.highlighted&&i.aboveBackdrop,!n&&e&&s.highlighted&&this.props.apiOptions.isMobile&&i.aboveBackdropMobile,!n&&m&&this.props.apiOptions.isMobile&&i.nextHighlighted,n&&i.satRadioOption,o&&!s.correct&&i.satRadioOptionIncorrect,o&&s.correct&&i.satRadioOptionCorrect,a&&!d.correct&&i.satRadioOptionNextIncorrect,a&&d.correct&&i.satRadioOptionNextCorrect,n&&t&&i.satReviewRadioOption)};g(!0);var f=o(g(s.checked),Zt.RADIO.OPTION,s.checked&&Zt.RADIO.SELECTED,r&&t.choices[p].correct&&Zt.CORRECT,r&&!t.choices[p].correct&&Zt.INCORRECT),v=null,b=null;return this.props.editMode&&(b=e=>{for(var t=e.target;t&&t!==v;){if(t.getAttribute("data-is-radio-icon"))return void this.updateChoice(p,{checked:!s.checked});t=t.parentNode}}),a.createElement("li",{key:p,ref:e=>v=e,className:f,onClick:b,onTouchStart:this.props.labelWrap?Ka:null},a.createElement(h,c))}),this)));return a.createElement("div",{className:u(!n&&i.responsiveContainer)},b)}}V(Ja,"propTypes",{apiOptions:h.shape({readOnly:h.bool,satStyling:h.bool,isMobile:h.bool,styling:h.shape({radioStyleVersion:h.oneOf(["intermediate","final"])}),canScrollPage:h.bool}),choices:Za,deselectEnabled:h.bool,editMode:h.bool,labelWrap:h.bool,countChoices:h.bool,numCorrect:h.number,multipleSelect:h.bool,reviewModeRubric:h.shape({choices:Za}),onChange:h.func,isLastUsedWidget:h.bool}),V(Ja,"styles",d.create({instructions:{display:"block",color:Q,fontSize:14,lineHeight:1.25,fontStyle:"normal",fontWeight:"bold",marginBottom:16},instructionsMobile:{fontSize:18,[jo.smOrSmaller]:{fontSize:16},[jo.xl]:{fontSize:20}},radio:{width:"100%"},responsiveRadioContainer:{borderBottom:"1px solid ".concat("#BABEC2"),borderTop:"1px solid ".concat("#BABEC2"),width:"auto",[jo.smOrSmaller]:{marginLeft:-16,marginRight:-16}},radioContainerFirstHighlighted:{borderTop:"1px solid rgba(0, 0, 0, 0)"},radioContainerLastHighlighted:{borderBottom:"1px solid rgba(0, 0, 0, 0)"},satRadio:{background:"none",marginLeft:0,userSelect:"none"},satRadioOption:{margin:0,padding:0,borderBottom:"1px solid #ccc",":first-child":{borderTop:"1px solid #ccc"}},satRadioOptionCorrect:{borderBottomColor:"#00CC00",":first-child":{borderTopColor:"#00CC00"}},satRadioOptionIncorrect:{borderBottomColor:"#CC5252",":first-child":{borderTopColor:"#CC5252"}},satRadioOptionNextCorrect:{borderBottomColor:"#00CC00"},satRadioOptionNextIncorrect:{borderBottomColor:"#CC5252"},satReviewRadioOption:{pointerEvents:"none"},item:{marginLeft:20},inlineItem:{display:"inline-block",paddingLeft:20,verticalAlign:"middle"},responsiveItem:{marginLeft:0,padding:0,":not(:last-child)":{borderBottom:"1px solid ".concat("#BABEC2")}},selectedItem:{background:"white"},aboveBackdrop:{position:"relative",zIndex:1062},aboveBackdropMobile:{boxShadow:"0 0 4px 0 rgba(0, 0, 0, 0.2),0 0 2px 0 rgba(0, 0, 0, 0.1)",":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},nextHighlighted:{":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},responsiveContainer:{overflow:"auto",marginLeft:-16,marginRight:-16,paddingLeft:16},responsiveFieldset:{paddingRight:16}})),V(Ja,"defaultProps",{editMode:!1});class Qa extends a.Component{constructor(){super(...arguments),V(this,"_renderRenderer",(e=>{var t=1,r={},i=(e=e||"").replace(/\{\{passage-ref (\d+) (\d+)(?: "([^"]*)")?\}\}/g,((e,i,n,s)=>{var o="passage-ref "+t;return t++,r[o]={type:"passage-ref",graded:!1,options:{passageNumber:parseInt(i),referenceNumber:parseInt(n),summaryText:s},version:Lo.version},"[["+De.snowman+" "+o+"]]"}));return a.createElement(Ds,{key:"choiceContentRenderer",content:i,widgets:r,findExternalWidgets:this.props.findWidgets,alwaysUpdate:!0,linterContext:U(U({},this.props.linterContext),{},{blockHighlight:!0})})})),V(this,"focus",(e=>this.refs.baseRadio.focus(e))),V(this,"updateChoices",(e=>{var t,{choiceStates:r,choices:i}=this.props;(t=r?r.map((e=>U({},e))):i.map((()=>({selected:!1,crossedOut:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1,readOnly:!1})))).forEach(((t,r)=>{t.selected=e.checked[r],t.crossedOut=e.crossedOut[r]})),this.props.onChange({choiceStates:t}),this.props.trackInteraction()})),V(this,"getUserInput",(()=>Qa.getUserInputFromProps(this.props))),V(this,"simpleValidate",(e=>Qa.validate(this.getUserInput(),e))),V(this,"showRationalesForCurrentlySelectedChoices",(e=>{var{choiceStates:t}=this.props;if(t){var r=this.simpleValidate(e),i="points"===r.type&&r.total===r.earned,n=t.map((e=>U(U({},e),{},{highlighted:e.selected,rationaleShown:e.selected||e.rationaleShown||i,readOnly:e.selected||e.readOnly||i,correctnessShown:e.selected||e.correctnessShown,previouslyAnswered:e.previouslyAnswered||e.selected})));this.props.onChange({choiceStates:n},null,!0)}})),V(this,"deselectIncorrectSelectedChoices",(()=>{if(this.props.choiceStates){var e=this.props.choiceStates.map(((e,t)=>U(U({},e),{},{selected:e.selected&&!!this.props.choices[t].correct,highlighted:!1})));this.props.onChange({choiceStates:e},null,!1)}}))}render(){var e,t=this.props.choices;return e=this.props.static?l.map(t,(e=>({selected:e.correct,crossedOut:e.crossedOut,readOnly:!0,highlighted:!1,rationaleShown:!0,correctnessShown:!0,previouslyAnswered:!1}))):this.props.choiceStates?this.props.choiceStates:this.props.values?l.map(this.props.values,(e=>({selected:e,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))):l.map(t,(()=>({selected:!1,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))),t=l.map(t,((t,r)=>{var i=t.isNoneOfTheAbove&&!t.content?s._("None of the above"):t.content,{selected:n,crossedOut:o,rationaleShown:a,correctnessShown:l,readOnly:p,highlighted:h,previouslyAnswered:c}=e[r],d=this.props.reviewModeRubric&&this.props.reviewModeRubric.choices[r];return{content:this._renderRenderer(i),checked:n,correct:void 0===t.correct?!!d&&d.correct:t.correct,disabled:p,hasRationale:!!t.clue,rationale:this._renderRenderer(t.clue),showRationale:a,showCorrectness:l,isNoneOfTheAbove:t.isNoneOfTheAbove,revealNoneOfTheAbove:this.props.questionCompleted&&n,crossedOut:o,highlighted:h,previouslyAnswered:c}})),a.createElement(Ja,{ref:"baseRadio",labelWrap:!0,multipleSelect:this.props.multipleSelect,countChoices:this.props.countChoices,numCorrect:this.props.numCorrect,choices:t,onChange:this.updateChoices,reviewModeRubric:this.props.reviewModeRubric,deselectEnabled:this.props.deselectEnabled,apiOptions:this.props.apiOptions,isLastUsedWidget:this.props.isLastUsedWidget})}static validate(e,t){var r=l.reduce(e.choicesSelected,((e,t)=>e+(t?1:0)),0);return 0===r?{type:"invalid",message:null}:e.numCorrect>1&&r!==e.numCorrect?{type:"invalid",message:s._("Please choose the correct number of answers.")}:e.noneOfTheAboveSelected&&r>1?{type:"invalid",message:s._("'None of the above' may not be selected when other answers are selected.")}:{type:"points",earned:l.all(e.choicesSelected,((r,i)=>(e.noneOfTheAboveIndex===i?l.all(t.choices,((e,t)=>i===t||!e.correct)):!!t.choices[i].correct)===r))?1:0,total:1,message:null}}static getUserInputFromProps(e){if(e.choiceStates){for(var t=null,r=!1,i=e.choiceStates,n=i.map((()=>!1)),s=e.countChoices,o=e.numCorrect,a=0;a<n.length;a++){var p=e.choices[a].originalIndex;n[p]=i[a].selected,e.choices[a].isNoneOfTheAbove&&(t=p,n[a]&&(r=!0))}return{countChoices:s,choicesSelected:n,numCorrect:o,noneOfTheAboveIndex:t,noneOfTheAboveSelected:r}}if(e.values){for(var h=null,c=!1,d=e.values.slice(),u=e.countChoices,m=e.numCorrect,g=0;g<e.values.length;g++){var f=e.choices[g].originalIndex;d[f]=e.values[g],e.choices[g].isNoneOfTheAbove&&(h=f,d[g]&&(c=!0))}return{choicesSelected:d,noneOfTheAboveIndex:h,noneOfTheAboveSelected:c,countChoices:u,numCorrect:m}}return{choicesSelected:l.map(e.choices,(()=>!1))}}}V(Qa,"defaultProps",{choices:[{}],displayCount:null,multipleSelect:!1,countChoices:!1,deselectEnabled:!1,linterContext:Gt});var{shuffle:el,random:tl}=De,rl=[[s._("False"),s._("True")],[s._("No"),s._("Yes")]],il=(e,t)=>{var r=((e,t)=>{var r,i,n=e.choices.slice();return n=l.map(n,((e,t)=>l.extend({},e,{originalIndex:t,correct:Boolean(e.correct)}))),function(e){var t=null,r=l.reject(e,(function(e,r){if(e.isNoneOfTheAbove)return t=e,!0}));return t&&r.push(t),r}((e=>{var t=e.map((e=>e.content));return rl.some((e=>l.isEqual(t,e)))?[e[1],e[0]]:e})((r=n,i=void 0===t?tl:t,e.randomize?el(r,null!=i?i:0):r)))})(e,t),i=l.reduce(e.choices,(function(e,t){return t.correct?e+1:e}),0),{hasNoneOfTheAbove:n,multipleSelect:s,countChoices:o,deselectEnabled:a}=e;return{numCorrect:i,hasNoneOfTheAbove:n,multipleSelect:s,countChoices:o,deselectEnabled:a,choices:r,selectedChoices:l.pluck(r,"correct")}},nl={name:"radio",displayName:"Multiple choice",accessible:!0,widget:Qa,transform:il,staticTransform:il,version:{major:1,minor:0},propUpgrades:{1:e=>{var t,r;if(e.noneOfTheAbove)throw new Error("radio widget v0 no longer supports auto noneOfTheAbove");return t=e.choices,r=!1,l.extend(l.omit(e,"noneOfTheAbove"),{choices:t,hasNoneOfTheAbove:r})}},isLintable:!0},sl=[nl,To,Fo,xo];class ol extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"state",{uniqueId:l.uniqueId("perseus_radio_")}),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"getUserInput",(()=>ol.getUserInputFromProps(this.props))),V(this,"onChange",((e,t)=>{var r=[...this.props.values];r[e]=t,this.change("values",r),this.props.trackInteraction()})),V(this,"simpleValidate",(e=>ol.validate(this.getUserInput(),e)))}render(){var e=this,t=this.props.apiOptions.isMobile,r=this.props.items.map(((e,t)=>[e,t]));this.props.randomizeItems&&(r=De.shuffle(r,this.props.problemNum));var i=a.createElement("table",{className:"categorizer-table "+u(ll.mobileTable)},a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null," "),this.props.categories.map(((e,t)=>a.createElement("th",{className:u(ll.header),key:t},a.createElement(Ds,{content:e,linterContext:this.props.linterContext})))))),a.createElement("tbody",null,r.map((r=>{var i=r[0],n=r[1],s=e.state.uniqueId+"_"+n;return a.createElement("tr",{key:n},a.createElement("td",null,a.createElement(Ds,{content:i,linterContext:this.props.linterContext})),e.props.categories.map(((r,i)=>{var o=e.props.values[n]===i;return a.createElement("td",{className:"category "+u(ll.cell),key:i},a.createElement("div",{className:Zt.INTERACTIVE,role:"button","aria-label":r,onClick:this.onChange.bind(this,n,i)},t&&a.createElement("input",{type:"radio",name:s,className:u(Qo.responsiveInput,Qo.responsiveRadioInput),checked:o,onChange:this.onChange.bind(this,n,i),onClick:e=>e.stopPropagation()}),!t&&a.createElement("span",{className:u(ll.radioSpan,o&&ll.checkedRadioSpan,this.props.static&&o&&ll.staticCheckedRadioSpan)},o?a.createElement(X,vi):a.createElement(X,xi))))})))})))),n=o({"categorizer-container":!0,"static-mode":this.props.static}),s=this.props.apiOptions.isMobile?[ll.fullBleedContainer]:[];return a.createElement("div",{className:n+" "+u(...s)},i)}static validate(e,t){var r=!0,i=!0;return l.each(t.values,(function(t,n){null==e.values[n]&&(r=!1),e.values[n]!==t&&(i=!1)})),r?{type:"points",earned:i?1:0,total:1,message:null}:{type:"invalid",message:s._("Make sure you select something for every row.")}}static getUserInputFromProps(e){return Do.getUserInputFromProps(e)}}V(ol,"defaultProps",{items:[],categories:[],values:[],linterContext:Gt});var al,ll=d.create({mobileTable:{[jo.smOrSmaller]:{minWidth:"auto"}},fullBleedContainer:{[jo.mdOrSmaller]:{marginLeft:-16,marginRight:-16,overflowX:"auto"}},header:{textAlign:"center",verticalAlign:"bottom"},cell:{textAlign:"center",padding:0,color:"#ccc",verticalAlign:"middle"},radioSpan:{fontSize:30,paddingRight:3,":hover":{color:"#999"}},checkedRadioSpan:{color:"#333"},staticCheckedRadioSpan:{color:"#888"}}),pl={name:"categorizer",displayName:"Categorizer",widget:ol,transform:e=>l.pick(e,"items","categories","randomizeItems"),staticTransform:e=>l.pick(e,"items","categories","values","randomizeItems"),isLintable:!0},hl=e=>new URL(e,(al||(al=window.location),al).origin),{updateQueryString:cl}=De;function dl(e){var t,{InitialRequestUrl:r}=oe(),i="/computer-programming/program/"+"".concat(e,"/embedded?embed=yes&author=no");return(t=r.protocol)&&"file:"===t.toLowerCase()?"https://khanacademy.org".concat(i):hl(i).href}class ul extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"handleMessageEvent",(e=>{var t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(!l.isUndefined(t.testsPassed)){var r=t.testsPassed?"correct":"incorrect";this.change({status:r,message:t.message})}})),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"simpleValidate",(e=>ul.validate({status:this.props.status,message:this.props.message},e)))}static validate(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}componentDidMount(){f(window).on("message",this.handleMessageEvent)}componentWillUnmount(){f(window).off("message",this.handleMessageEvent)}render(){if(!this.props.programID)return a.createElement("div",null);var e,t=!1,r=dl(this.props.programID),i={height:this.props.height,width:"100%"};if(this.props.showEditor?(r+="&editor=yes",e="perseus-scratchpad-editor"):(r+="&editor=no&width=".concat(688),e="perseus-scratchpad","webpage"!==this.props.programType&&(t=!0)),this.props.showButtons?(r+="&buttons=yes",i.height+=67):r+="&buttons=no",this.props.settings){var n={};l.each(this.props.settings,(function(e){e.name&&e.value&&(n[e.name]=e.value)})),r=cl(r,"settings",JSON.stringify(n))}var s=["allow-popups","allow-same-origin","allow-scripts","allow-top-navigation"].join(" ");return a.createElement("div",{className:u(ml.widthOverride,t&&ml.container)},a.createElement("iframe",{sandbox:s,src:r,style:i,className:e,allowFullScreen:!0}))}}V(ul,"propTypes",U(U({},mo),{},{programID:h.string,programType:h.oneOf(["pjs","sql","webpage"]),width:h.number,height:h.number,settings:h.array,showEditor:h.bool,showButtons:h.bool,status:h.oneOf(["incomplete","incorrect","correct"]),message:h.string})),V(ul,"defaultProps",{showEditor:!1,showButtons:!1,status:"incomplete",message:null});var ml=d.create({widthOverride:{width:820},container:{margin:"auto"}}),gl={name:"cs-program",displayName:"CS Program",supportedAlignments:["block","full-width"],widget:ul,hidden:!0};class fl extends a.Component{componentDidMount(){this.props.trackInteraction()}render(){return a.createElement(M,{style:bl.tooltipBody},a.createElement(Ds,{apiOptions:this.props.apiOptions,content:this.props.content,widgets:this.props.widgets}))}}V(fl,"propTypes",{apiOptions:Kt.propTypes,content:h.string,trackInteraction:h.func.isRequired,widgets:h.objectOf(h.any)});class vl extends a.Component{constructor(){super(...arguments),V(this,"getUserInput",(()=>({}))),V(this,"simpleValidate",(e=>vl.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e=a.createElement(fl,{apiOptions:this.props.apiOptions,content:this.props.definition,key:this.props.definition,trackInteraction:this.props.trackInteraction,widgets:this.props.widgets});return a.createElement(P,{content:e,placement:"top"},a.createElement("span",{className:"perseus-widget-definition"},a.createElement(M,{style:bl.definitionLink},this.props.togglePrompt)))}}V(vl,"defaultProps",{togglePrompt:"define me",definition:"definition goes here"});var bl={tooltipBody:{color:E.offBlack,display:"block",fontSize:20,fontWeight:500,lineHeight:"30px",margin:I.xSmall_8},definitionLink:{borderBottom:"dashed 1px ".concat(E.blue),color:E.blue,cursor:"pointer",display:"inline-block",textDecoration:"none"}},yl={name:"definition",displayName:"Definition",accessible:!0,defaultAlignment:"inline",widget:vl,transform:l.identity};class xl extends a.Component{constructor(){super(...arguments),V(this,"focus",(()=>(g.findDOMNode(this).focus(),!0))),V(this,"_handleChangeEvent",(e=>{this._handleChange(parseInt(e.target.value))})),V(this,"_handleChange",(e=>{this.props.trackInteraction(),this.props.onChange({selected:e})})),V(this,"getUserInput",(()=>({value:this.props.selected}))),V(this,"simpleValidate",(e=>xl.validate(this.getUserInput(),e)))}static validate(e,t){var r=e.value;return 0===r?{type:"invalid",message:null}:{type:"points",earned:t.choices[r-1].correct?1:0,total:1,message:null}}render(){var e=[a.createElement(A,{key:"placeholder",value:"0",disabled:!0,label:this.props.placeholder}),...this.props.choices.map(((e,t)=>a.createElement(A,{key:String(t+1),value:String(t+1),label:e})))];return a.createElement("div",{onClick:e=>{e.stopPropagation()},onTouchStart:e=>{e.stopPropagation()}},a.createElement(N,{onChange:e=>this._handleChange(parseInt(e)),selectedValue:String(this.props.selected),disabled:this.props.apiOptions.readOnly},e))}}V(xl,"defaultProps",{choices:[],selected:0,placeholder:"",apiOptions:Kt.defaults});var Cl={name:"dropdown",displayName:"Drop down",defaultAlignment:"inline-block",accessible:!0,widget:xl,transform:e=>({placeholder:e.placeholder,choices:l.map(e.choices,(e=>e.content))})};class wl extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"state",{expanded:!1}),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"_onClick",(()=>{this.setState({expanded:!this.state.expanded}),this.props.trackInteraction()})),V(this,"getUserInput",(()=>({}))),V(this,"simpleValidate",(e=>wl.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e,{Link:t}=this.props.apiOptions.baseElements,{isArticle:r,isMobile:i}=this.props.apiOptions,n=this.state.expanded?this.props.hidePrompt:this.props.showPrompt,s="javascript:void(0)",o=this._onClick;e=i?a.createElement("div",{className:u(_l.linkContainer)},a.createElement("a",{className:u(_l.mobileExplanationLink),href:s,onClick:o,role:"button","aria-expanded":this.state.expanded},n),this.state.expanded&&a.createElement("svg",{className:u(_l.disclosureArrow)},a.createElement("polygon",{style:{fill:Sl},points:"0,".concat(El," ")+"".concat(kl,",").concat(El," ")+"".concat(kl/2,",0")}))):r?a.createElement("div",{className:u(_l.linkContainer,_l.articleLink)},a.createElement(t,{className:u(_l.explanationLink),style:_l.explanationLink,href:s,onClick:o,role:"button","aria-expanded":this.state.expanded},"[".concat(n,"]"))):a.createElement("div",{className:u(_l.linkContainer,_l.exerciseLink)},a.createElement(t,{className:u(_l.explanationLink),href:s,onClick:o,role:"button","aria-expanded":this.state.expanded},"[".concat(n,"]")));var l=i?_l.contentExpandedMobile:_l.contentExpanded;return a.createElement("div",{className:u(_l.container)},e,this.state.expanded&&a.createElement("div",{className:u(_l.content,i&&_l.contentMobile,this.state.expanded&&l),ref:"content"},a.createElement(Ds,{apiOptions:this.props.apiOptions,content:this.props.explanation,widgets:this.props.widgets,linterContext:this.props.linterContext})))}}V(wl,"defaultProps",{showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{},linterContext:Gt});var kl=30,El=14,Sl="#F0F1F2",_l=d.create({container:{display:"inline",position:"relative"},linkContainer:{display:"inline-block"},explanationLink:{fontStyle:"italic",color:"#007d96"},articleLink:{fontSize:20,lineHeight:"30px"},exerciseLink:{fontSize:14,lineHeight:"19.6px"},mobileExplanationLink:{color:"#71B307",borderBottom:"dashed 1px ".concat("#71B307"),textDecoration:"none",[jo.xl]:{fontSize:22,lineHeight:1.4},[jo.lgOrSmaller]:{fontSize:20,lineHeight:1.5},[jo.smOrSmaller]:{fontSize:18,lineHeight:1.2}},content:{position:"relative",transition:"margin-top 0.1s"},contentExpanded:{borderLeft:"5px solid #ccc",marginLeft:-23,paddingLeft:23,paddingBottom:10,marginBottom:El,marginTop:El},contentExpandedMobile:{boxSizing:"content-box",paddingTop:32,paddingBottom:32,marginTop:El},contentMobile:{background:Sl,marginLeft:-16,marginRight:-16,paddingLeft:16,paddingRight:16},disclosureArrow:{bottom:-(El+5),height:El,left:"50%",marginLeft:-kl/2,position:"absolute",width:kl}}),Ml={name:"explanation",displayName:"Explanation",accessible:!0,defaultAlignment:"inline",widget:wl,transform:l.identity,isLintable:!0};class Tl extends a.Component{render(){var{apiOptions:e,answerBarState:t,onCheckAnswer:r,onNextQuestion:i}=this.props,n=U(U({},Il.answerBar),{},{backgroundColor:"CORRECT"===t?E.offWhite:"white",justifyContent:"CORRECT"!==t||i?"space-between":"center"}),o="INCORRECT"===t?a.createElement("span",{style:Il.text},a.createElement("span",{style:Il.tryAgainIcon},a.createElement(X,_i)),a.createElement("span",{style:{marginLeft:8}},s._("Keep trying"))):a.createElement("span",null);if("CORRECT"!==t){var l="INCORRECT"===t?s._("Try again"):s._("Check");return a.createElement("div",{style:n},o,a.createElement(R,{disabled:e.readOnly||"ACTIVE"!==t,onClick:r},l))}return a.createElement("div",{style:n},a.createElement("span",{style:Il.text},a.createElement("span",{style:{fontSize:28,color:E.green}},a.createElement(X,j({},Si,{style:{marginBottom:5}}))),a.createElement("span",{role:"alert","aria-label":s._("Correct!"),style:{marginLeft:8}},s._("Correct!"))),i&&a.createElement(R,{onClick:i},s._("Next question")))}}var Il={answerBar:{display:"flex",alignItems:"center",height:68,marginLeft:-16,marginRight:-16,marginBottom:-16,marginTop:16,paddingLeft:16,paddingRight:10,borderTop:"1px solid ".concat(E.offBlack50)},tryAgainIcon:{fontSize:28,color:"#63D9EA",transform:"scale(-1,1) rotate(-268deg)"},text:{display:"flex",flexDirection:"row",alignItems:"center",fontWeight:"bold",fontSize:17}},Pl="ungraded",Al="correct",Nl="incorrect",Rl="invalid",Fl=(e,t)=>{switch(e){case"HIDDEN":case"INACTIVE":return t?"ACTIVE":e;case"ACTIVE":return t?e:"INACTIVE";case"INCORRECT":return t?"ACTIVE":"INACTIVE";default:return e}},Dl=s._("We couldn't grade your answer."),Ol=s._("It looks like you left something blank or ")+s._("entered in an invalid answer.");class Ll extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"state",{status:Pl,showHint:!1,message:"",answerBarState:"HIDDEN"}),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"_onInteractWithWidget",(e=>{if(this.setState({status:Pl,message:""}),this.refs.renderer){this.change("widgets",this.props.widgets);var t=0===this.refs.renderer.emptyWidgets().length,r=this.state.answerBarState;this.setState({answerBarState:Fl(r,t)})}})),V(this,"_checkAnswer",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices();var e=this.refs.renderer.score(),t="points"===e.type?e.total===e.earned?Al:Nl:Rl,r="points"===e.type?e.message||"":e.message?"".concat(Dl," ").concat(e.message):"".concat(Dl," ").concat(Ol);this.setState({status:t,message:r,answerBarState:"correct"===t?"CORRECT":"INCORRECT"}),this.props.trackInteraction({status:t})})),V(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),V(this,"setInputValue",((e,t,r)=>this.refs.renderer.setInputValue(e,t,r))),V(this,"focus",(()=>this.refs.renderer.focus())),V(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),V(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){var e=l.extend({},Kt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}}),t=null,r=null;this.state.status===Al?(r=a.createElement(X,j({},wi,{style:{color:"#526f03"}})),t=s._("Correct")):this.state.status===Nl&&(r=a.createElement(X,j({},Ei,{style:{color:"#ff5454"}})),t=s._("Incorrect"));var i=this.props.inGradedGroupSet?u(Bl.gradedGroupInSet):u(Bl.gradedGroup),n=o({[i]:e.isMobile,"perseus-graded-group":!0,"answer-correct":!e.isMobile&&this.state.status===Al,"answer-incorrect":!e.isMobile&&this.state.status===Nl}),{answerBarState:p}=this.state,h="CORRECT"===p,c=e.readOnly||e.isMobile&&h;return a.createElement("div",{className:n},!!this.props.title&&a.createElement("div",{className:u(Bl.title)},this.props.title),a.createElement(Ds,j({},this.props,{ref:"renderer",apiOptions:U(U({},e),{},{readOnly:c}),onInteractWithWidget:this._onInteractWithWidget,linterContext:this.props.linterContext})),!e.isMobile&&r&&a.createElement("div",{className:"group-icon"},r),!e.isMobile&&t&&a.createElement("div",{className:u(Ma.srOnly),role:"alert","aria-label":t},t),!e.isMobile&&a.createElement("p",null,this.state.message),!e.isMobile&&a.createElement(R,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this._checkAnswer},s._("Check")),!e.isMobile&&h&&this.props.onNextQuestion&&a.createElement(R,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this.props.onNextQuestion,style:{marginLeft:5}},s._("Next question")),this.props.hint&&this.props.hint.content&&(this.state.showHint?a.createElement("div",null,a.createElement("button",{tabIndex:"0",className:u(Bl.explanationTitle),onClick:()=>this.setState({showHint:!1}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!1})}},s._("Hide explanation")),a.createElement(Ds,j({},this.props.hint,{ref:"hints-renderer",apiOptions:e,linterContext:this.props.linterContext}))):a.createElement("button",{tabIndex:"0",onClick:()=>this.setState({showHint:!0}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!0})},className:u(Bl.showHintLink)},s._("Explain"))),e.isMobile&&"HIDDEN"!==p&&a.createElement(Tl,{apiOptions:e,answerBarState:p,onCheckAnswer:this._checkAnswer,onNextQuestion:this.props.onNextQuestion}))}}V(Ll,"defaultProps",{title:"",content:"",widgets:{},images:{},hint:null,hasHint:!1,linterContext:Gt});var Bl=d.create({gradedGroupInSet:{marginLeft:0,paddingLeft:0},gradedGroup:{borderTop:"1px solid ".concat(Z),borderBottom:"1px solid ".concat(Z),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"},showHintLink:{backgroundColor:"unset",fontSize:14,padding:0,border:"none",marginTop:20,color:"#71B307",cursor:"pointer",display:"block",clear:"both"},explanationTitle:{backgroundColor:"unset",marginTop:20,color:"#71B307",marginBottom:10,cursor:"pointer",fontSize:14,padding:0,border:"none",display:"block",clear:"both"},title:{fontSize:12,color:Z,textTransform:"uppercase",marginBottom:11,letterSpacing:.8}}),zl={name:"graded-group",displayName:"Graded group (articles only)",widget:Ll,traverseChildWidgets:function(e,t){return l.extend({},e,t(e))},hidden:!1,tracking:"all",isLintable:!0},ql=zl.widget;class Hl extends a.Component{render(){for(var e=this,t=[],r=function(r){t.push(a.createElement("div",{role:"button","aria-label":s._("Skip to %(title)s",{title:e.props.groupTitles[r]}),key:r,className:u(Gl.indicator,r===e.props.currentGroup&&Gl.selectedIndicator),onClick:()=>e.props.onChangeCurrentGroup(r)}))},i=0;i<this.props.numGroups;i++)r(i);return a.createElement("div",{className:u(Gl.indicatorContainer)},t)}}class Wl extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"_childGroup",void 0),V(this,"state",{currentGroup:0}),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"getInputPaths",(()=>this._childGroup.getInputPaths())),V(this,"setInputValue",((e,t,r)=>this._childGroup.setInputValue(e,t,r))),V(this,"focus",(()=>this._childGroup.focus())),V(this,"focusInputPath",(e=>{this._childGroup.focusInputPath(e)})),V(this,"blurInputPath",(e=>{this._childGroup.blurInputPath(e)})),V(this,"handleNextQuestion",(()=>{var{currentGroup:e}=this.state;e<this.props.gradedGroups.length-1&&this.setState({currentGroup:e+1})}))}shouldComponentUpdate(e,t){return e.gradedGroups,e!==this.props||t!==this.state}render(){var{JIPT:e}=oe();if(e.useJIPT&&this.props.gradedGroups.length>1)return a.createElement("div",{className:u(Gl.container)},this.props.gradedGroups.map(((e,t)=>a.createElement(ql,j({key:t},this.props,e,{inGradedGroupSet:!1,linterContext:this.props.linterContext})))));var t=this.props.gradedGroups[this.state.currentGroup];if(!t)return a.createElement("span",null,s.doNotTranslate("No current group..."));var r=this.props.gradedGroups.length,i=this.state.currentGroup<r-1?this.handleNextQuestion:null;return a.createElement("div",{className:u(Gl.container)},a.createElement("div",{className:u(Gl.top)},a.createElement("div",{className:u(Gl.title)},t.title),a.createElement("div",{className:u(Gl.spacer)}),a.createElement(Hl,{numGroups:r,currentGroup:this.state.currentGroup,groupTitles:this.props.gradedGroups.map((e=>e.title)),onChangeCurrentGroup:e=>this.setState({currentGroup:e})})),a.createElement(ql,j({key:this.state.currentGroup,ref:e=>this._childGroup=e},this.props,t,{inGradedGroupSet:!0,title:null,onNextQuestion:i,linterContext:this.props.linterContext})))}}V(Wl,"defaultProps",{gradedGroups:[],linterContext:Gt});var Ul={name:"graded-group-set",displayName:"Graded group set (articles only)",widget:Wl,traverseChildWidgets:function(e,t){return{groups:e.gradedGroups.map(t)}},hidden:!1,tracking:"all",isLintable:!0},Gl=d.create({top:{display:"flex",flexDirection:"row"},spacer:{flex:1},title:{fontSize:12,color:Z,textTransform:"uppercase",marginBottom:11,letterSpacing:.8},indicatorContainer:{display:"flex",flexDirection:"row"},indicator:{width:10,height:10,borderRadius:5,backgroundColor:"#AAAAAA",marginLeft:5,cursor:"pointer"},selectedIndicator:{backgroundColor:"#71B307"},container:{borderTop:"1px solid ".concat(Z),borderBottom:"1px solid ".concat(Z),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"}});class Vl extends a.Component{constructor(){super(...arguments),V(this,"container",void 0)}componentWillUnmount(){this.container=null}focus(){if(this.container)return this.container.focus(),!0}toggleSelect(e){var t=this.props.value;this.props.allowEmpty?this.props.onChange(t!==e?e:null):this.props.onChange(e)}render(){var e=this.props.value,t=this.props.buttons.map(((t,r)=>a.createElement("button",{title:t.title,type:"button",id:""+r,ref:"button"+r,key:""+r,className:u(jl.buttonStyle,t.value===e&&jl.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)));return a.createElement("div",{style:{display:"inline-block"},ref:e=>this.container=e},t)}}V(Vl,"defaultProps",{value:null,allowEmpty:!0});var jl=d.create({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"}}),Yl={url:null};function Xl(e){var t=e[0],r=e[1],i=e[2],n=e[3];t<0&&(t*=-1,r*=-1,i*=-1);var s=2*Math.PI;for(r<0&&(r*=-1,i*=-1,i+=s/2);i>0;)i-=s;for(;i<0;)i+=s;return[t,r,i,n]}function $l(e){var t=e[0],r=e[1],i=e[2],n=e[3];t<0&&(t*=-1,r*=-1,i*=-1);var s=Math.PI;for(r<0&&(r*=-1,i*=-1,i+=s/2);i>0;)i-=s;for(;i<0;)i+=s;return[t,r,i,n]}var Kl={areEqual:function(e,t){return De.deepEq(e,t)},Movable:In.Plot,getPropsForCoeffs:function(e){return{fn:l.partial(this.getFunctionForCoeffs,e)}}},Zl=l.extend({},Kl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/67aaf581e6d9ef9038c10558a1f70ac21c11c9f8.png",defaultCoords:[[.25,.75],[.75,.75]],getCoefficients:function(e){var t=e[0],r=e[1],i=r[0]-t[0],n=r[1]-t[1];if(0!==i){var s=n/i;return[s,r[1]-s*r[0]]}},getFunctionForCoeffs:function(e,t){return e[0]*t+e[1]},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1];return"y = "+r.toFixed(3)+"x + "+i.toFixed(3)}}),Jl=l.extend({},Kl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/e23d36e6fc29ee37174e92c9daba2a66677128ab.png",defaultCoords:[[.5,.5],[.75,.75]],Movable:In.Parabola,getCoefficients:function(e){var t=e[0],r=e[1],i=t[0],n=t[1],s=(r[1]-n)/((r[0]-i)*(r[0]-i));return[s,-2*i*s,s*i*i+n]},getFunctionForCoeffs:function(e,t){return(e[0]*t+e[1])*t+e[2]},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2]}},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1],n=t[2];return"y = "+r.toFixed(3)+"x^2 + "+i.toFixed(3)+"x + "+n.toFixed(3)}}),Ql=l.extend({},Kl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/3d68e7718498475f53b206c2ab285626baf8857e.png",defaultCoords:[[.5,.5],[.6,.6]],Movable:In.Sinusoid,getCoefficients:function(e){var t=e[0],r=e[1],i=r[1]-t[1],n=Math.PI/(2*(r[0]-t[0]));return[i,n,t[0]*n,t[1]]},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2],s=e[3];return r*Math.sin(i*t-n)+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),r=t[0],i=t[1],n=t[2],s=t[3];return"y = "+r.toFixed(3)+" sin("+i.toFixed(3)+"x - "+n.toFixed(3)+") + "+s.toFixed(3)},areEqual:function(e,t){return De.deepEq(Xl(e),Xl(t))}}),ep=l.extend({},Kl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/7db80d23c35214f98659fe1cf0765811c1bbfbba.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){var t=e[0],r=e[1],i=r[1]-t[1],n=Math.PI/(4*(r[0]-t[0]));return[i,n,t[0]*n,t[1]]},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2],s=e[3];return r*Math.tan(i*t-n)+s},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1],n=t[2],s=t[3];return"y = "+r.toFixed(3)+" sin("+i.toFixed(3)+"x - "+n.toFixed(3)+") + "+s.toFixed(3)},areEqual:function(e,t){return De.deepEq($l(e),$l(t))}}),tp=l.extend({},Kl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/9cbfad55525e3ce755a31a631b074670a5dad611.png",defaultCoords:[[.5,.55],[.75,.75]],defaultAsymptote:[[0,.5],[1,.5]],extraCoordConstraint:function(e,t,r,i,n){var s=l.head(i)[1];return l.all(r,(e=>e[1]!==s))},extraAsymptoteConstraint:function(e,t,r,i,n){var s=e[1];if(l.all(r,(e=>e[1]>s))||l.all(r,(e=>e[1]<s)))return[t[0],s];var o=t[1];if(l.all(r,(e=>e[1]>o))){var a=l.min(l.map(r,(e=>e[1])));return[t[0],a-n.snapStep[1]]}var p=l.max(l.map(r,(e=>e[1])));return[t[0],p+n.snapStep[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){var r=e[0],i=e[1],n=l.head(t)[1],s=Math.log((r[1]-n)/(i[1]-n))/(r[0]-i[0]);return[(r[1]-n)/Math.exp(s*r[0]),s,n]},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2];return r*Math.exp(i*t)+n},getEquationString:function(e,t){if(!t)return null;var r=this.getCoefficients(e,t),i=r[0],n=r[1],s=r[2];return"y = "+i.toFixed(3)+"e^("+n.toFixed(3)+"x) + "+s.toFixed(3)}}),rp=l.extend({},Kl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/f6491e99d34af34d924bfe0231728ad912068dc3.png",defaultCoords:[[.55,.5],[.75,.75]],defaultAsymptote:[[.5,0],[.5,1]],extraCoordConstraint:function(e,t,r,i,n){var s=l.head(i)[0];return l.all(r,(e=>e[0]!==s))&&r[0][1]!==r[1][1]},extraAsymptoteConstraint:function(e,t,r,i,n){var s=e[0];if(l.all(r,(e=>e[0]>s))||l.all(r,(e=>e[0]<s)))return[s,t[1]];var o=t[0];return l.all(r,(e=>e[0]>o))?[l.min(l.map(r,(e=>e[0])))-n.snapStep[0],t[1]]:[l.max(l.map(r,(e=>e[0])))+n.snapStep[0],t[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){var r=e=>[e[1],e[0]],i=tp.getCoefficients(l.map(e,r),l.map(t,r)),n=-i[2]/i[0],s=1/i[0];return[1/i[1],s,n]},getFunctionForCoeffs:function(e,t,r){var i=e[0],n=e[1],s=e[2];return i*Math.log(n*t+s)},getEquationString:function(e,t){if(!t)return null;var r=this.getCoefficients(e,t),i=r[0],n=r[1],s=r[2];return"y = ln("+i.toFixed(3)+"x + "+n.toFixed(3)+") + "+s.toFixed(3)}}),ip=l.extend({},Kl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/8256a630175a0cb1d11de223d6de0266daf98721.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){var t=e[0],r=e[1],i=r[0]-t[0],n=r[1]-t[1];if(0!==i){var s=Math.abs(n/i);return r[1]<t[1]&&(s*=-1),[s,t[0],t[1]]}},getFunctionForCoeffs:function(e,t){var r=e[0],i=e[1],n=e[2];return r*Math.abs(t-i)+n},getEquationString:function(e){var t=this.getCoefficients(e),r=t[0],i=t[1],n=t[2];return"y = "+r.toFixed(3)+"| x - "+i.toFixed(3)+"| + "+n.toFixed(3)}}),np={linear:Zl,quadratic:Jl,sinusoid:Ql,tangent:ep,exponential:tp,logarithm:rp,absolute_value:ip},sp=l.keys(np);function op(e){return np[e]}var ap=(e,t)=>{if(e.type!==t.correct.type)return{type:"points",earned:0,total:1,message:null};if(null==e.coords)return{type:"invalid",message:null};var r=op(e.type),i=r.getCoefficients(e.coords,e.asymptote),n=r.getCoefficients(t.correct.coords,t.correct.asymptote);return null==i||null==n?{type:"invalid",message:null}:r.areEqual(i,n)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}},lp=(e,t,r,i)=>e.map((e=>{var n=e.map(((e,i)=>{var n=t[i],s=r[i],o=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,s),a=Math.round(e*o);return n[0]+s*a}));return b.roundTo(n,i)})),pp=(e,t,r,i)=>e?lp(e,t,r,i):e,hp=(e,t)=>{var r=op(e),i=De.snapStepFromGridStep([1,1]);return{type:e,asymptote:pp(r.defaultAsymptote,t.range,t.step,i),coords:null}},cp=l.first,dp=(e,t)=>{var r=e.gridStep||De.getGridStep(e.range,e.step,t);return{gridStep:r,snapStep:e.snapStep||De.snapStepFromGridStep(r)}},up={labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:Yl,markings:"graph",rulerLabel:"",rulerTicks:10,valid:!0,showTooltips:!1},mp=hp("linear",up),gp={graph:up,plot:mp,availableTypes:[mp.type]},fp=e=>{var t=e.charAt(0).toUpperCase()+e.substring(1),r=oe().staticUrl;return{value:e,title:t,content:a.createElement("img",{src:r(op(e).url),alt:t})}},vp=Object.freeze({__proto__:null,DEFAULT_BACKGROUND_IMAGE:Yl,allTypes:sp,functionForType:op,validate:ap,getEquationString:e=>{var t=e.plot;return t.type&&t.coords&&op(t.type).getEquationString(t.coords,t.asymptote)||""},pointsFromNormalized:lp,maybePointsFromNormalized:pp,defaultPlotProps:hp,chooseType:cp,getGridAndSnapSteps:dp,DEFAULT_GRAPHER_PROPS:gp,typeToButton:fp}),bp=In.MovablePoint,yp=In.MovableLine;var xp={padding:"5px 5px"};class Cp extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"_coords",(()=>{var e=this.props,t=e.graph,r=e.model&&pp(e.model.defaultCoords,t.range,t.step,t.snapStep);return e.coords||r||null})),V(this,"_asymptote",(()=>this.props.asymptote)),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"renderPlot",(()=>{var e=this.props.model,t=this.props.graph.range[0],r=U({stroke:this.props.isMobile?dr.BLUE_C:dr.DYNAMIC},this.props.isMobile?{"stroke-width":3}:{}),i=e.getCoefficients(this._coords(),this._asymptote());if(i){var n=e.getPropsForCoeffs(i,t);return a.createElement(e.Movable,j({},n,{key:this.props.model.url,range:t,style:r}))}})),V(this,"renderAsymptote",(()=>{var e=this.props.model,t=this.props.graph,r=this._asymptote(),i={strokeDasharray:"- "};return r&&a.createElement(yp,{onMove:(e,t)=>{var r=y.subtract(e,t),i=l.map(this._asymptote(),(e=>y.add(e,r)));this.props.onChange({asymptote:i})},constraints:[dn.MovableLine.constraints.bound(),dn.MovableLine.constraints.snap(),(r,i)=>{var n=y.subtract(r,i),s=l.map(this._asymptote(),(e=>y.add(e,n)));return!e.extraAsymptoteConstraint||e.extraAsymptoteConstraint(r,i,this._coords(),s,t)}],normalStyle:i,highlightStyle:i},l.map(r,((e,t)=>a.createElement(bp,{key:"asymptoteCoord-".concat(t),coord:e,static:!0,draw:null,extendLine:!0,showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))))}))}render(){var e=l.map(this._coords(),((e,t)=>a.createElement(bp,{key:t,coord:e,static:this.props.static,constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),e=>{var r=l.all(this._coords(),((r,i)=>t===i||!r||!v.equal(e[0],r[0])));if(!r)return!1;if(this.props.model&&this.props.model.extraCoordConstraint){var i=this.props.model.extraCoordConstraint,n=l.clone(this._coords()),s=l.clone(n[t]);return n[t]=e,i(e,s,n,this._asymptote(),this.props.graph)}return r}],onMove:(e,r)=>{var i,n=this._asymptote();i=n&&this.props.model.allowReflectOverAsymptote&&function(e,t,r){var i=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1]);return i(r[0],r[1],t)>0!=i(r[0],r[1],e)>0}(e,r,n)?l.map(this._coords(),(e=>b.reflectOverLine(e,n))):l.clone(this._coords()),i[t]=e,this.props.onChange({coords:i})},showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))),t=this.props.graph.box,r=this.props.graph.backgroundImage,i=null;if(r.url){var n=t[0]/ee.defaultBoxSize;i=a.createElement(Un,{src:r.url,width:r.width,height:r.height,scale:n})}return a.createElement("div",{className:"perseus-widget perseus-widget-grapher",style:{width:t[0],height:t[1],boxSizing:"initial"}},a.createElement("div",{className:"graphie-container above-scratchpad",style:{width:t[0],height:t[1]}},i,a.createElement(In,j({},this.props.graph,{setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this.props.model&&this.renderPlot(),this.props.model&&this.renderAsymptote(),this.props.model&&e)))}}V(Cp,"defaultProps",{graph:{range:[[-10,10],[-10,10]],step:[1,1]},coords:null,asymptote:null,isMobile:!1});class wp extends a.Component{constructor(){super(...arguments),V(this,"horizHairline",void 0),V(this,"vertHairline",void 0),V(this,"handlePlotChanges",(e=>{var t=l.extend({},this.props.plot,e);this.props.onChange({plot:t}),this.props.trackInteraction()})),V(this,"handleActiveTypeChange",(e=>{var t=this.props.graph,r=l.extend({},this.props.plot,hp(e,t));this.props.onChange({plot:r})})),V(this,"_setupGraphie",((e,t)=>{var r=this.props.apiOptions.isMobile;if("graph"===t.markings?(e.graphInit({range:t.range,scale:l.pluck(t.gridConfig,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,snapStep:t.snapStep,tickStep:r?this._calculateMobileTickStep(t.gridStep,t.step,t.range):l.pluck(t.gridConfig,"tickStep"),labelStep:1,unityLabels:l.pluck(t.gridConfig,"unityLabel"),isMobile:r}),e.label([0,t.range[1][1]],t.labels[1],r?"below right":"above"),e.label([t.range[0][1],0],t.labels[0],r?"above left":"right")):"grid"===t.markings?e.graphInit({range:t.range,scale:l.pluck(t.gridConfig,"scale"),gridStep:t.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:r}):"none"===t.markings&&e.init({range:t.range,scale:l.pluck(t.gridConfig,"scale")}),this.props.apiOptions.isMobile){var i={normalStyle:{strokeWidth:1}};this.horizHairline=new Ir(e,[0,0],[0,0],i),this.horizHairline.attr({stroke:dr.INTERACTIVE}),this.horizHairline.hide(),this.vertHairline=new Ir(e,[0,0],[0,0],i),this.vertHairline.attr({stroke:dr.INTERACTIVE}),this.vertHairline.hide()}})),V(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.props.graph.range[0][0],e[1]],[this.props.graph.range[0][1],e[1]]),this.horizHairline.show(),this.vertHairline.moveTo([e[0],this.props.graph.range[1][0]],[e[0],this.props.graph.range[1][1]]),this.vertHairline.show())})),V(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&(this.horizHairline.hide(),this.vertHairline.hide())}))}render(){var e=this.props.plot.type,t=this.props.plot.coords,r=this.props.plot.asymptote,i=a.createElement("div",{style:xp,className:"above-scratchpad"},a.createElement(Vl,{value:e,allowEmpty:!0,buttons:l.map(this.props.availableTypes,fp),onChange:this.handleActiveTypeChange})),n=os(this.props.containerSizeClass),s=U(U(U({},this.props.graph),dp(this.props.graph,n[0])),{},{gridConfig:this._getGridConfig(U(U({},this.props.graph),{},{box:n},dp(this.props.graph,n[0])))}),o={graph:{box:n,range:s.range,step:s.step,snapStep:s.snapStep,backgroundImage:s.backgroundImage,options:s,setup:this._setupGraphie},onChange:this.handlePlotChanges,model:e&&op(e),coords:t,asymptote:r,static:this.props.static,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile,showTooltips:this.props.graph.showTooltips,showHairlines:this.showHairlines,hideHairlines:this.hideHairlines};return a.createElement("div",null,a.createElement(Cp,o),this.props.availableTypes.length>1&&i)}_getGridConfig(e){return e.step.map(((t,r)=>De.gridDimensionConfig(t,e.range[r],e.box[r],e.gridStep[r])))}_calculateMobileTickStep(e,t,r){var i=De.constrainedTickStepsFromTickSteps(t,r);return i[0]=i[0]/e[0],i[1]=i[1]/e[1],i}simpleValidate(e){return ap(this.getUserInput(),e)}getUserInput(){return wp.getUserInputFromProps(this.props)}focus(){}static validate(e,t){return ap(e,t)}static getUserInputFromProps(e){return e.plot}}V(wp,"defaultProps",gp);var kp=e=>{var t={availableTypes:e.availableTypes,graph:e.graph};if(1===t.availableTypes.length){var r=t.graph,i=cp(t.availableTypes);t.plot=hp(i,r)}return t},Ep={name:"grapher",displayName:"Grapher",widget:wp,transform:kp,staticTransform:e=>U(U({},kp(e)),{},{availableTypes:[e.correct.type],plot:e.correct})};class Sp extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"getUserInput",(()=>this.refs.renderer.getUserInput())),V(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),V(this,"restoreSerializedState",((e,t)=>(this.refs.renderer.restoreSerializedState(e,t),null))),V(this,"simpleValidate",(e=>this.refs.renderer.score())),V(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),V(this,"setInputValue",((e,t,r)=>this.refs.renderer.setInputValue(e,t,r))),V(this,"focus",(()=>this.refs.renderer.focus())),V(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),V(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)})),V(this,"showRationalesForCurrentlySelectedChoices",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices()}))}componentDidMount(){this.forceUpdate()}render(){var e=l.extend({},Kt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}}),t=l.indexOf(this.props.findWidgets("group"),this),r=this.props.apiOptions.groupAnnotator(t,this.props.widgetId),i=this.refs.renderer&&this.refs.renderer.score(),n=i&&"invalid"!==i.type,s=i&&"invalid"===i.type;return a.createElement("div",{className:o({"perseus-group":!0,"perseus-group-valid-answer":n,"perseus-group-invalid-answer":s})},r,a.createElement(Ds,j({},this.props,{ref:"renderer",apiOptions:e,findExternalWidgets:this.props.findWidgets,reviewMode:!!this.props.reviewModeRubric,onInteractWithWidget:e=>{this.refs.renderer&&this.change("widgets",this.refs.renderer.props.widgets)},linterContext:this.props.linterContext})),this.props.icon&&a.createElement("div",{className:"group-icon"},this.props.icon))}}V(Sp,"defaultProps",{content:"",widgets:{},images:{},linterContext:Gt});var _p={name:"group",displayName:"Group (SAT only)",widget:Sp,traverseChildWidgets:function(e,t){return l.extend({},e,t(e))},hidden:!1,isLintable:!0},{updateQueryString:Mp}=De;class Tp extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"getUserInput",(()=>Do.getUserInput.call(this))),V(this,"handleMessageEvent",(e=>{var t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(!l.isUndefined(t.testsPassed)){var r=t.testsPassed?"correct":"incorrect";this.change({status:r,message:t.message})}})),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"simpleValidate",(e=>Tp.validate(this.getUserInput(),e)))}componentDidMount(){f(window).on("message",this.handleMessageEvent)}componentWillUnmount(){f(window).off("message",this.handleMessageEvent)}render(){var e={width:String(this.props.width),height:String(this.props.height)},{InitialRequestUrl:t}=oe();Object.entries(e).forEach((t=>{var[r,i]=t;i.endsWith("%")||i.endsWith("px")||(e[r]=i+"px")}));var r=this.props.url;if(r&&r.length&&0!==r.indexOf("http")&&(r=Mp(r="https://www.khanacademy.org/computer-programming/program/"+r+"/embedded?buttons=no&embed=yes&editor=no&author=no","width",this.props.width),r=Mp(r,"height",this.props.height),r=Mp(r,"origin",t.origin)),this.props.settings){var i={};l.each(this.props.settings,(function(e){e.name&&e.value&&(i[e.name]=e.value)})),r=Mp(r,"settings",JSON.stringify(i))}return" allow-top-navigation",a.createElement("iframe",{sandbox:"allow-same-origin allow-scripts allow-top-navigation",style:e,src:r,allowFullScreen:this.props.allowFullScreen})}}V(Tp,"propTypes",U(U({},mo),{},{width:h.oneOfType([h.string,h.number]),height:h.oneOfType([h.string,h.number]),url:h.string,settings:h.array,status:h.oneOf(["incomplete","incorrect","correct"]),message:h.string,allowFullScreen:h.bool,allowTopNavigation:h.bool})),V(Tp,"defaultProps",{status:"incomplete",message:null,allowFullScreen:!1,allowTopNavigation:!1}),l.extend(Tp,{validate:function(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}});var Ip={name:"iframe",displayName:"Iframe",widget:Tp,hidden:!0},Pp=[0,10];class Ap extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"getUserInput",(()=>null)),V(this,"simpleValidate",(e=>Ap.validate(this.getUserInput(),e))),V(this,"focus",(()=>{}))}render(){var e,t,r,i,{apiOptions:n}=this.props,s=this.props.backgroundImage;if(s.url&&(e=a.createElement(Un,{src:s.url,alt:this.props.alt,overrideAriaHidden:!0,width:s.width,height:s.height,preloader:n.imagePreloader,extraGraphie:{box:this.props.box,range:this.props.range,labels:this.props.labels},trackInteraction:this.props.trackInteraction,zoomToFullSizeOnMobile:n.isMobile,constrainHeight:n.isMobile,allowFullBleed:n.isMobile})),this.props.alt&&(t=a.createElement("span",{className:"perseus-sr-only"},a.createElement(Ds,{content:this.props.alt,apiOptions:n,linterContext:this.props.linterContext}))),n.isMobile){var l;if(this.props.title||this.props.caption){var p=this.props.title;p&&(this.props.caption&&!/[.?!"']\s*$/.test(p)&&(p+="."),p="**".concat(p,"** "));var h=o({"perseus-image-caption":!0,"has-title":!!p}),c=this.props.alignment,d="block"===c||"full-width"===c?null:"0 !important";l=a.createElement("div",{className:h},a.createElement("div",{className:u(Np.caption),style:{minWidth:d}},a.createElement(Ds,{content:p+this.props.caption,apiOptions:n,linterContext:this.props.linterContext})))}return a.createElement("div",{className:"perseus-image-widget"},e,t,l)}return this.props.title&&(r=a.createElement("div",{className:"perseus-image-title"},a.createElement(Ds,{content:this.props.title,apiOptions:n,linterContext:this.props.linterContext}))),this.props.caption&&(i=a.createElement("div",{className:"perseus-image-caption"},a.createElement(Ds,{content:this.props.caption,apiOptions:n,linterContext:this.props.linterContext}))),a.createElement("div",{className:"perseus-image-widget"},r,e,t,i)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}V(Ap,"defaultProps",{alignment:"block",title:"",range:[Pp,Pp],box:[400,400],backgroundImage:{url:null,width:0,height:0},labels:[],alt:"",caption:"",linterContext:Gt});var Np=d.create({caption:{display:"inline-block",marginTop:16,maxWidth:640,[jo.lgOrSmaller]:{maxWidth:540},[jo.smOrSmaller]:{maxWidth:450}}}),Rp={name:"image",accessible:e=>{var t=e.backgroundImage;return!(t&&t.url&&!e.alt)},defaultAlignment:"block",supportedAlignments:["block","full-width"],displayName:"Image",widget:Ap,isLintable:!0},Fp=In.Label,Dp=In.Line,Op=In.MovablePoint,Lp=In.MovableLine,Bp=In.Plot,zp=In.PlotParametric,qp=In.Point,Hp=In.Rect,{unescapeMathMode:Wp}=De,Up=(e,t)=>{for(var r=e+"||"+(t=t||{}).decimal_separator+"||",i=t.functions,n=i?i.length:0,s=0;s<n;s++)r+=i[s]+"|";return r},Gp=Object.create(null),Vp=(t,r)=>{var i=Up(t,r),n=Gp[i];return n||(n=e.parse(t,r),Gp[i]=n,n)},jp=Object.create(null),Yp=(t,r)=>{var i=Up(t,r),n=jp[i];if(n)return n;var s=e.parse(t,r).expr;return n=s?s.compile():function(){return 0},jp[i]=n,n};class Xp extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"state",{variables:$p(this.props.elements),functions:Kp(this.props.elements)}),V(this,"_setupGraphie",((e,t)=>{e.graphInit(l.extend({},t,{grid:l.contains(["graph","grid"],this.props.graph.markings),axes:l.contains(["graph"],this.props.graph.markings),ticks:l.contains(["graph"],this.props.graph.markings),labels:l.contains(["graph"],this.props.graph.markings),labelFormat:function(e){return"\\small{"+e+"}"},axisArrows:"<->",unityLabels:!1}))})),V(this,"_updatePointLocation",((e,t)=>{var r=l.clone(this.state.variables);r["x_"+e]=t[0],r["y_"+e]=t[1],this.setState({variables:r}),this.props.trackInteraction()})),V(this,"_updateLineLocation",((e,t)=>{var r=this._eval("("+e.endX+")-("+e.startX+")"),i=this._eval("("+e.endY+")-("+e.startY+")"),n=y.add(t,[r,i]),s=l.clone(this.state.variables);s["x_"+e.startSubscript]=t[0],s["y_"+e.startSubscript]=t[1],s["x_"+e.endSubscript]=n[0],s["y_"+e.endSubscript]=n[1],this.setState({variables:s}),this.props.trackInteraction()})),V(this,"_eval",((e,t)=>{var r=Yp(e,{functions:this.state.functions}),i=l.extend({},this.state.variables,t);return l.each(l.keys(i),(e=>{if(l.isString(i[e])){var t=Yp(i[e],{functions:this.state.functions});i[e]=function(e){return t(l.extend({},i,{x:e}))}}})),r(i)||0})),V(this,"_extractVars",(e=>{if(null==e)return[];var t=[];return l.each(e.args(),(function(e){e&&"Expr"===e.constructor.name&&(t=t.concat(this._extractVars(e)))}),this),"Var"===e.name()&&t.push(e.prettyPrint()),t})),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"getUserInput",(()=>({}))),V(this,"simpleValidate",(e=>Xp.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){l.isEqual(this.props.elements,e.elements)||this.setState({variables:$p(e.elements),functions:Kp(e.elements)})}render(){var e=this.props.graph.range,t=this.props.graph.labels;return"graph"===this.props.graph.markings&&(t=this.props.graph.labels.map((e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e))),a.createElement(In,{box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable},"graph"===this.props.graph.markings&&a.createElement(Fp,{coord:[0,e[1][1]],text:t[1],direction:"above"}),"graph"===this.props.graph.markings&&a.createElement(Fp,{coord:[e[0][1],0],text:t[0],direction:"right"}),l.map(this.props.elements,(function(e,t){if("point"===e.type)return a.createElement(qp,{key:e.key,coord:[this._eval(e.options.coordX),this._eval(e.options.coordY)],color:e.options.color});if("line"===e.type){var r=[this._eval(e.options.startX),this._eval(e.options.startY)],i=[this._eval(e.options.endX),this._eval(e.options.endY)];return a.createElement(Dp,{key:e.key,start:r,end:i,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,arrows:e.options.arrows}})}if("movable-point"===e.type){var n=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];return"snap"===e.options.constraint?n.push(Op.constraints.snap(e.options.snap)):"x"===e.options.constraint?n.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&n.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})])),a.createElement(Op,{key:e.key,coord:[this.state.variables["x_"+e.options.varSubscript],this.state.variables["y_"+e.options.varSubscript]],constraints:n,foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap,onMove:l.partial(this._updatePointLocation,e.options.varSubscript)})}if("movable-line"===e.type){var s=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];"snap"===e.options.constraint?s.push(Op.constraints.snap(e.options.snap)):"x"===e.options.constraint?s.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&s.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})]));var o=[this.state.variables["x_"+e.options.startSubscript],this.state.variables["y_"+e.options.startSubscript]],p=[this.state.variables["x_"+e.options.endSubscript],this.state.variables["y_"+e.options.endSubscript]];return a.createElement(Lp,{key:e.key,constraints:s,onMove:l.bind(this._updateLineLocation,this,e.options),foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap},a.createElement(Op,{coord:o,static:!0,normalStyle:{stroke:"none",fill:"none"}}),a.createElement(Op,{coord:p,static:!0,normalStyle:{stroke:"none",fill:"none"}}))}if("function"===e.type){var h=l.without(this._extractVars(Vp(e.options.value).expr),"x"),c=l.object(h,l.map(h,(e=>this.state.variables[e]))),d=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return a.createElement(Bp,{key:e.key,fn:t=>this._eval(e.options.value,{x:t}),foo_fn:e.options.value,foo_varvalues:c,range:d,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("parametric"===e.type){var u=l.without(this._extractVars(Vp(e.options.x).expr).concat(this._extractVars(Vp(e.options.y).expr)),"t"),m=l.object(u,l.map(u,(e=>this.state.variables[e]))),g=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return a.createElement(zp,{key:e.key,fn:t=>[this._eval(e.options.x,{t:t}),this._eval(e.options.y,{t:t})],foo_fnx:e.options.x,foo_fny:e.options.y,foo_varvalues:m,range:g,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("label"===e.type){var f=[this._eval(e.options.coordX),this._eval(e.options.coordY)];return a.createElement(Fp,{key:t+1,coord:f,text:Wp(e.options.label),style:{color:e.options.color}})}return"rectangle"===e.type?a.createElement(Hp,{key:t+1,x:this._eval(e.options.coordX),y:this._eval(e.options.coordY),width:l.max([this._eval(e.options.width),0]),height:l.max([this._eval(e.options.height),0]),style:{stroke:"none",fill:e.options.color}}):void 0}),this))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}V(Xp,"defaultProps",{graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]});var $p=e=>{var t={};return l.each(l.where(e,{type:"movable-point"}),(e=>{var r=e.options.varSubscript,i=Vp(e.options.startX||"0").expr,n=Vp(e.options.startY||"0").expr,s=0,o=0;i&&(s=i.eval({})||0),n&&(o=n.eval({})||0),t["x_"+r]=s,t["y_"+r]=o})),l.each(l.where(e,{type:"movable-line"}),(e=>{var r=e.options.startSubscript,i=e.options.endSubscript,n=Vp(e.options.startX||"0").expr,s=Vp(e.options.startY||"0").expr,o=Vp(e.options.endX||"0").expr,a=Vp(e.options.endY||"0").expr,l=0,p=0,h=0,c=0;n&&(l=n.eval({})||0),s&&(p=s.eval({})||0),o&&(h=o.eval({})||0),a&&(c=a.eval({})||0),t["x_"+r]=l,t["y_"+r]=p,t["x_"+i]=h,t["y_"+i]=c})),l.each(l.where(e,{type:"function"}),(e=>{t[e.options.funcName]=e.options.value})),t},Kp=e=>l.map(l.where(e,{type:"function"}),(e=>e.options.funcName)),Zp={name:"interaction",displayName:"Interaction",widget:Xp,transform:l.identity,hidden:!0},Jp={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"},Qp={position:"relative",top:"25%"};class eh extends a.Component{constructor(){super(...arguments),V(this,"protractor",void 0),V(this,"ruler",void 0),V(this,"_graphie",void 0),V(this,"_hasSetupGraphieThisUpdate",void 0),V(this,"_shouldSetupGraphie",void 0),V(this,"reset",(()=>{this._setupGraphie(!1)})),V(this,"graphie",(()=>this._graphie)),V(this,"pointsFromNormalized",((e,t)=>{var r=this;return l.map(e,(function(e){return l.map(e,(function(e,i){var n=r.props.range[i];if(t)return n[0]+(n[1]-n[0])*e;var s=r.props.step[i],o=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,s),a=Math.round(e*o);return n[0]+s*a}))}))})),V(this,"_setupGraphie",(e=>{if(!this._hasSetupGraphieThisUpdate){var t=g.findDOMNode(this.refs.graphieDiv);f(t).empty();var r=this.props.labels.map((e=>De.unescapeMathMode(e))),i=this.props.range,n=this._graphie=xr.createGraphie(t),s=this._getGridConfig();n.snap=this.props.snapStep,"graph"===this.props.markings?(n.graphInit({range:i,scale:l.pluck(s,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:this.props.gridStep,tickStep:l.pluck(s,"tickStep"),labelStep:1,unityLabels:l.pluck(s,"unityLabel"),isMobile:this.props.isMobile}),n.label([0,i[1][1]],r[1],this.props.isMobile?"below right":"above"),n.label([i[0][1],0],r[0],this.props.isMobile?"above left":"right")):"grid"===this.props.markings?n.graphInit({range:i,scale:l.pluck(s,"scale"),gridStep:this.props.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:this.props.isMobile}):"none"===this.props.markings&&n.init({range:i,scale:l.pluck(s,"scale"),isMobile:this.props.isMobile});var o;if(this.props.instructions){o=f("<div/>"),l.each(Jp,(function(e,t){o.css(t,e)})),o.css("opacity",.5);var a=f("<span/>",{text:this.props.instructions});l.each(Qp,(function(e,t){a.css(t,e)})),o.append(a),f(t).append(o)}else o=void 0;var p=o||this.props.onMouseDown?l.bind((function(e){o&&(o.remove(),o=null),this.props.onMouseDown(e)}),this):null,h=o?function(){o&&o.css("opacity",0)}:null,c=o?function(){o&&o.css("opacity",.5)}:null;n.addMouseLayer({onClick:this.props.onClick,onMouseDown:p,onMouseOver:h,onMouseOut:c,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,allowScratchpad:!0,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this._updateProtractor(),this._updateRuler(),this._hasSetupGraphieThisUpdate=!0,!e&&this.props.onGraphieUpdated&&this.props.onGraphieUpdated(n)}})),V(this,"_getGridConfig",(()=>{var e=this;return l.map(e.props.step,(function(t,r){return De.gridDimensionConfig(t,e.props.range[r],e.props.box[r],e.props.gridStep[r])}))})),V(this,"_updateProtractor",(()=>{if(this.protractor&&this.protractor.remove(),this.props.showProtractor){var e=this.pointsFromNormalized([[.5,.05]])[0];this.protractor=this._graphie.protractor(e)}})),V(this,"_updateRuler",(()=>{if(this.ruler&&this.ruler.remove(),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)})}})),V(this,"toJSON",(()=>l.pick(this.props,"range","step","markings","labels","backgroundImage","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep")))}render(){var e,t=this.props.backgroundImage;if(t.url){var r=this.props.box[0]/ee.defaultBoxSize;e=a.createElement(Un,{src:t.url,width:t.width,height:t.height,scale:r,responsive:!1})}else e=null;return a.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,a.createElement("div",{className:"graphie",ref:"graphieDiv"}))}componentDidMount(){this._setupGraphie(!0)}componentDidUpdate(){this._hasSetupGraphieThisUpdate=!1,this._shouldSetupGraphie&&(this._setupGraphie(!1),this._shouldSetupGraphie=!1)}UNSAFE_componentWillReceiveProps(e){var t=this;l.each(["labels","range","step","markings","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep"],(function(r){l.isEqual(t.props[r],e[r])||(t._shouldSetupGraphie=!0)}))}}V(eh,"propTypes",{box:h.array.isRequired,labels:h.arrayOf(h.string),range:h.arrayOf(h.arrayOf(h.number)),step:h.arrayOf(h.number),gridStep:h.arrayOf(h.number),snapStep:h.arrayOf(h.number),markings:h.string,backgroundImage:h.shape({url:h.string}),showProtractor:h.bool,showRuler:h.bool,rulerLabel:h.string,rulerTicks:h.number,onGraphieUpdated:h.func,instructions:h.string,onClick:h.func,setDrawingAreaAvailable:h.func,isMobile:h.bool}),V(eh,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[.5,.5],markings:"graph",backgroundImage:{url:null},showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,instructions:null,onGraphieUpdated:null,onClick:null,onMouseDown:null,isMobile:!1});var{DeprecationMixin:th}=De,rh=De.eq,ih=De.deepEq;function nh(e,t,r){return(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1])}function sh(e,t,r){return rh(nh(e,t,r),0)}function oh(e){return rh(e,0)?0:e>0?1:-1}function ah(e,t,r){return r[0]<=Math.max(e[0],t[0])&&r[0]>=Math.min(e[0],t[0])&&r[1]<=Math.max(e[1],t[1])&&r[1]>=Math.min(e[1],t[1])}function lh(e,t){var r=[[e[0],e[1],t[0]],[e[0],e[1],t[1]],[t[0],t[1],e[0]],[t[0],t[1],e[1]]],i=l.map(r,(function(e){return oh(nh(...e))}));if(i[0]!==i[1]&&i[2]!==i[3])return!0;for(var n=0;n<4;n++)if(0===i[n]&&ah(...r[n]))return!0;return!1}function ph(e,t){return l.map(l.zip(e,t),(function(e){return e[0]-e[1]}))}function hh(e){return Math.sqrt(l.reduce(e,(function(e,t){return e+Math.pow(t,2)}),0))}function ch(e){return l.zip(e,fh(e)).map((function(e){return hh(ph(...e))}))}function dh(e){var t=l.zip(fh(e,-1),e,fh(e,1)),r=l.map(t,(function(e){var t,r,i=ph(e[1],e[0]),n=ph(e[2],e[1]),s=Math.acos((t=i,r=n,l.reduce(l.zip(t,r),(function(e,t){return e+t[0]*t[1]}),0)/(hh(i)*hh(n))));return oh(nh(...e))>0?s:-s})),i=l.reduce(r,(function(e,t){return e+t}),0);return l.map(r,(function(e){return i>0?Math.PI-e:Math.PI+e}))}function uh(e,t,r){if(e.length!==t.length)return!1;for(var i=e.length,n=dh(e),s=dh(t),o=ch(e),a=ch(t),p=0;p<2*i;p++){var h=s.slice(),c=a.slice();if(p>=i&&(h.reverse(),c.reverse(),c=fh(c,1)),h=fh(h,p),c=fh(c,p),ih(n,h)){var d=function(){var e=l.zip(o,c),t=l.map(e,(function(e){return e[0]/e[1]})),i=l.all(t,(function(e){return rh(t[0],e)})),n=l.all(e,(function(e){return v.equal(e[0],e[1],r)}));if(i&&n)return{v:!0}}();if("object"==typeof d)return d.v}}return!1}function mh(e,t){return e<t||rh(e,t)}function gh(e){var[t,r,i,n]=e;t<0&&(t*=-1,r*=-1,i*=-1);var s=2*Math.PI;for(r<0&&(r*=-1,i*=-1,i+=s/2);i>0;)i-=s;for(;i<0;)i+=s;return[t,r,i,n]}function fh(e,t){return t=void 0===t?1:t%e.length,e.slice(t).concat(e.slice(0,t))}function vh(e){return e.replace(/(?:^|-)(.)/g,(function(e,t){return t.toUpperCase()}))}function bh(e,t){if(rh(e[0],t[0]))return"x = "+e[0].toFixed(3);var r=(t[1]-e[1])/(t[0]-e[0]),i=e[1]-r*e[0];return"y = "+r.toFixed(3)+"x + "+i.toFixed(3)}var yh={showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},xh=e=>Ch(e)&&(null==e.graph.coords||0===e.graph.coords.length),Ch=e=>"point"===e.graph.type&&"unlimited"===e.graph.numPoints||"polygon"===e.graph.type&&"unlimited"===e.graph.numSides,wh=(e,t)=>new he("".concat(e," called but current graph type is not a '").concat(t,"'"),le.NotAllowed,{metadata:{graphType:t}});class kh extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"angle",void 0),V(this,"circle",void 0),V(this,"graphie",void 0),V(this,"horizHairline",void 0),V(this,"line",void 0),V(this,"lines",void 0),V(this,"parabola",void 0),V(this,"pointA",void 0),V(this,"pointB",void 0),V(this,"pointC",void 0),V(this,"points",void 0),V(this,"polygon",void 0),V(this,"shouldResetGraphie",void 0),V(this,"sinusoid",void 0),V(this,"trashCan",void 0),V(this,"vertHairline",void 0),V(this,"state",{shouldShowInstructions:xh(this.props)}),V(this,"_getShouldShowInstructions",(e=>(e=e||this.props,this.isClickToAddPoints(e)&&(null==e.graph.coords||0===e.graph.coords.length)))),V(this,"deprecatedProps",yh),V(this,"setGraphie",(e=>{this.graphie=e,this.setupGraphie()})),V(this,"handleAddPointsMouseDown",(e=>{if(!this.isClickToAddPoints())throw new he("handleAddPointsClick should not be registeredwhen isClickToAddPoints() is false",le.NotAllowed);if(!this.isCoordInTrash(e)){var t;if("point"===this.props.graph.type){if(!(t=this.createPointForPointsType(e,this.points.length)).constrain())return void t.remove();this.points.push(t);var r=this.points.length-1;this.points[r].grab(e),this.updateCoordsFromPoints()}else if("polygon"===this.props.graph.type){var i;if(null!==(i=this.polygon)&&void 0!==i&&i.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})}})),V(this,"resetGraphie",(()=>{this.shouldResetGraphie=!1,this.parabola=null,this.sinusoid=null,this.refs.graph.reset()})),V(this,"setupGraphie",(()=>{var e,t;(this.setTrashCanVisibility(0),this.isClickToAddPoints()&&this.setTrashCanVisibility(.5),this.props.apiOptions.isMobile)&&(this.horizHairline=new Ir(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:dr.INTERACTIVE}),null===(e=this.horizHairline)||void 0===e||e.hide(),this.vertHairline=new Ir(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.vertHairline.attr({stroke:dr.INTERACTIVE}),null===(t=this.vertHairline)||void 0===t||t.hide());this["add"+vh(this.props.graph.type)+"Controls"]()})),V(this,"showHairlines",(e=>{var t,r,i,n;this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(null===(t=this.horizHairline)||void 0===t||t.moveTo([this.props.range[0][0],e[1]],[this.props.range[0][1],e[1]]),null===(r=this.horizHairline)||void 0===r||r.show(),null===(i=this.vertHairline)||void 0===i||i.moveTo([e[0],this.props.range[1][0]],[e[0],this.props.range[1][1]]),null===(n=this.vertHairline)||void 0===n||n.show())})),V(this,"hideHairlines",(()=>{var e,t;this.props.apiOptions.isMobile&&(null===(e=this.horizHairline)||void 0===e||e.hide(),null===(t=this.vertHairline)||void 0===t||t.hide())})),V(this,"setTrashCanVisibility",(e=>{var t=this.graphie;if(v.equal(e,0))this.trashCan&&(this.trashCan.remove(),this.trashCan=null);else if(!this.props.apiOptions.isMobile){var r,i;if(!this.trashCan)this.trashCan=null==t||null===(i=t.raphael)||void 0===i?void 0:i.image("https://ka-perseus-graphie.s3.amazonaws.com/b1452c0d79fd0f7ff4c3af9488474a0a0decb361.png",t.xpixels-40,t.ypixels-40,40,40);null===(r=this.trashCan)||void 0===r||r.attr({opacity:e})}})),V(this,"isClickToAddPoints",(e=>(e=e||this.props,Ch(e)))),V(this,"_lineStroke",(()=>this.props.isMobile?{"stroke-width":3}:{})),V(this,"addLine",(e=>{var t=this,r=t.graphie,i=kh.getLineCoords(t.props.graph,t.props),n=t.points=l.map(i,(e=>dn.addMaybeMobileMovablePoint(this,{coord:e,constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap()],onMove:()=>{var e=l.extend({},t.props.graph,{coords:l.invoke(n,"coord")});t.onChange({graph:e})}}))),s={points:n,static:!0,normalStyle:U({stroke:this.props.apiOptions.isMobile?dr.BLUE_C:dr.INTERACTIVE},this._lineStroke())};"line"===e?s.extendLine=!0:"ray"===e&&(s.extendRay=!0),t.line=dn.addMovableLine(r,s),n[0].listen("constraints","isLine",(e=>!b.equal(e,n[1].coord()))),n[1].listen("constraints","isLine",(e=>!b.equal(e,n[0].coord())))})),V(this,"removeLine",(()=>{var e;l.invoke(this.points,"remove"),null===(e=this.line)||void 0===e||e.remove()})),V(this,"addLinearControls",(()=>{this.addLine("line")})),V(this,"removeLinearControls",(()=>{this.removeLine()})),V(this,"addQuadraticControls",(()=>{if("quadratic"!==this.props.graph.type)throw wh("addQuadraticControls","quadratic");var e=this.props.graph.coords;e||(e=kh.defaultQuadraticCoords(this.props));var t=()=>{var e=l.extend({},this.props.graph,{coords:[r.coord(),i.coord(),n.coord()]});this.onChange({graph:e}),this.updateQuadratic()},r=null;r=this.pointA=dn.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),e=>!r||e[0]!==i.coord()[0]&&e[0]!==n.coord()[0]],onMove:t});var i=null;i=this.pointB=dn.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),e=>!i||e[0]!==r.coord()[0]&&e[0]!==n.coord()[0]],onMove:t});var n=null;n=this.pointC=dn.addMaybeMobileMovablePoint(this,{coord:e[2],constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),e=>!n||e[0]!==r.coord()[0]&&e[0]!==i.coord()[0]],onMove:t}),this.updateQuadratic()})),V(this,"updateQuadratic",(()=>{var e=kh.getCurrentQuadraticCoefficients(this.props);if(e){var t=e[0],r=e[1],i=e[2];if(this.parabola){var n,s,o=null===(n=this.graphie)||void 0===n?void 0:n.svgParabolaPath(t,r,i);null===(s=this.parabola)||void 0===s||s.attr({path:o})}else{var a,l,p;this.parabola=null===(a=this.graphie)||void 0===a?void 0:a.parabola(t,r,i),null===(l=this.parabola)||void 0===l||l.attr(U({stroke:this.props.apiOptions.isMobile?dr.BLUE_C:dr.DYNAMIC},this._lineStroke())),null===(p=this.parabola)||void 0===p||p.toBack()}}})),V(this,"removeQuadraticControls",(()=>{var e,t,r;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),null===(r=this.pointC)||void 0===r||r.remove(),this.parabola&&(this.parabola.remove(),this.parabola=null)})),V(this,"addSinusoidControls",(()=>{if("sinusoid"!==this.props.graph.type)throw wh("addSinusoidControls","sinusoid");var e=this.props.graph.coords;e||(e=kh.defaultSinusoidCoords(this.props));var t=()=>{var e=l.extend({},this.props.graph,{coords:[r.coord(),i.coord()]});this.onChange({graph:e}),this.updateSinusoid()},r=null;r=this.pointA=dn.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),e=>!r||e[0]!==i.coord()[0]],onMove:t});var i=this.pointB=dn.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),e=>!r||e[0]!==r.coord()[0]],onMove:t});this.updateSinusoid()})),V(this,"updateSinusoid",(()=>{var e=kh.getCurrentSinusoidCoefficients(this.props);if(e){var t=e[0],r=e[1],i=e[2],n=e[3];if(this.sinusoid){var s,o,a=null===(s=this.graphie)||void 0===s?void 0:s.svgSinusoidPath(t,r,i,n);null===(o=this.sinusoid)||void 0===o||o.attr({path:a})}else{var l,p,h;this.sinusoid=null===(l=this.graphie)||void 0===l?void 0:l.sinusoid(t,r,i,n),null===(p=this.sinusoid)||void 0===p||p.attr(U({stroke:this.props.apiOptions.isMobile?dr.BLUE_C:dr.DYNAMIC},this._lineStroke())),null===(h=this.sinusoid)||void 0===h||h.toBack()}}})),V(this,"removeSinusoidControls",(()=>{var e,t;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),this.sinusoid&&(this.sinusoid.remove(),this.sinusoid=null)})),V(this,"addCircleControls",(()=>{var e=this.graphie,t=l.min(e.snap),r=this.circle=null==e?void 0:e.addCircleGraph({center:this.props.graph.center||[0,0],radius:this.props.graph.radius||l.min(this.props.step),snapX:e.snap[0],snapY:e.snap[1],minRadius:t,snapRadius:t});f(r).on("move",(()=>{var e=l.extend({},this.props.graph,{center:r.center,radius:r.radius});this.onChange({graph:e})}))})),V(this,"removeCircleControls",(()=>{var e;null===(e=this.circle)||void 0===e||e.remove()})),V(this,"addLinearSystemControls",(()=>{var t=this.graphie,r=kh.getLinearSystemCoords(this.props.graph,this.props),i=[dr.INTERACTIVE,dr.GREEN],n=this.points=l.map(r,((t,r)=>{for(var n=[],s=function(s){var o=t[s];n.push(dn.addMaybeMobileMovablePoint(e,{coord:o,constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),e=>{var t=n[1-s];if(t)return!b.equal(e,t.coord())}],onMove:()=>{var t=l.extend({},e.props.graph,{coords:l.map(e.points,(e=>l.invoke(e,"coord")))});e.onChange({graph:t})},normalStyle:{fill:i[r]},highlightStyle:{fill:i[r]}}))},o=0;o<t.length;o+=1)s(o);return n}));this.lines=l.map(n,((e,r)=>dn.addMovableLine(t,{points:e,static:!0,extendLine:!0,normalStyle:{stroke:i[r]}})))})),V(this,"removeLinearSystemControls",(()=>{l.invoke(this.lines,"remove"),l.map(this.points,(e=>l.invoke(e,"remove")))})),V(this,"isCoordInTrash",(e=>{if(this.props.apiOptions.isMobile)return!1;var t=this.graphie,r=null==t?void 0:t.scalePoint(e);return r[0]>=t.xpixels-40&&r[1]>=t.ypixels-40})),V(this,"createPointForPointsType",((e,t)=>{var r=this,i=()=>{r.points=l.filter(r.points,(function(e){return e!==n})),r.updateCoordsFromPoints(),setTimeout(n.remove.bind(n),0)},n=null;return n=dn.addMaybeMobileMovablePoint(this,U({coord:e,constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),function(e){return l.all(r.points,(function(t){return n===t||!b.equal(e,t.coord())}))}],onMoveStart:function(){r.isClickToAddPoints()&&r.setTrashCanVisibility(1)},onMove:r.updateCoordsFromPoints,onMoveEnd:function(e){r.isClickToAddPoints()&&(r.isCoordInTrash(e)&&i(),r.setTrashCanVisibility(.5))}},this.props.apiOptions.isMobile&&r.isClickToAddPoints()?{onRemove:i}:{})),n})),V(this,"removePoint",(e=>{var t=null;return this.points=l.filter(this.points,(function(r,i){return r!==e||(t=i,!1)})),t})),V(this,"createPointForPolygonType",((e,t)=>{if("polygon"!==this.props.graph.type)throw wh("createPointForPolygonType","polygon");var r=!l.contains(["angles","sides"],this.props.graph.snapTo),i=e=>(t+e+this.points.length)%this.points.length,n=()=>{var e,t,r=this.removePoint(o);null!==(e=this.polygon)&&void 0!==e&&e.closed()&&(this.points=fh(this.points,r),null===(t=this.polygon)||void 0===t||t.update({closed:!1}));this.updatePolygon(),this.clearCoords(),setTimeout(o.remove.bind(o),0)},s=F(((e,t)=>{e.state.isInitialMove=t}),1e3),o=dn.addMaybeMobileMovablePoint(this,U({coord:e,constraints:[dn.MovablePoint.constraints.bound(),r?dn.MovablePoint.constraints.snap():null,e=>{if(null==this.points||0===this.points.length)return!0;var r,n,s,o=l.invoke(this.points,"coord");if(o[t]=e,!this.isClickToAddPoints()){if(sh(o[i(-2)],o[i(-1)],o[t])||sh(o[i(-1)],o[t],o[i(1)])||sh(o[t],o[i(1)],o[i(2)]))return!1;var a=l.zip(o,fh(o));if(this.points.length>3)for(var p=-1;p<=0;p++)for(var h=a[i(p)],c=l.without(a,h,a[i(p-1)],a[i(p+1)]),d=0;d<c.length;d++){if(lh(h,c[d]))return!1}}if("angles"===this.props.graph.snapTo&&this.points.length>2){var u,m,g=l.map(dh(o),(function(e){return 180*e/Math.PI}));l.each([-1,1],(function(e){g[i(e)]=Math.round(g[i(e)])}));var f=function(e,t,r){return(xr.findAngle(o[i(e)],o[i(r)],o[i(t)])+360)%360},v=[g[i(-1)]-f(-2,-1,1),g[i(1)]-f(-1,1,2)];if(v[2]=180-(v[0]+v[1]),l.any(v,(function(e){return mh(e,1)})))return!1;var b=hh(ph(o[i(-1)],o[i(1)])),y=1===oh(nh(o[i(-1)],o[i(1)],o[t])),x=Math.sin(v[1]*Math.PI/180)/Math.sin(v[2]*Math.PI/180)*b,C=xr.findAngle(o[i(1)],o[i(-1)]),w=null===(u=this.graphie)||void 0===u?void 0:u.polar(x,C+(y?1:-1)*v[0]);return null===(m=this.graphie)||void 0===m?void 0:m.addPoints(o[i(-1)],w)}if("sides"===this.props.graph.snapTo&&this.points.length>1){var k,E,S=l.map([[o[i(-1)],o[t]],[o[t],o[i(1)]],[o[i(-1)],o[i(1)]]],(function(e){return hh(ph(...e))}));if(l.each([0,1],(function(e){S[e]=Math.round(S[e])})),mh(S[1]+S[2],S[0])||mh(S[0]+S[2],S[1])||mh(S[0]+S[1],S[2]))return!1;var _=(r=S[0],n=S[2],s=S[1],180*Math.acos((r*r+n*n-s*s)/(2*r*n))/Math.PI),M=xr.findAngle(o[i(1)],o[i(-1)]),T=1===oh(nh(o[i(-1)],o[i(1)],o[t])),I=null===(k=this.graphie)||void 0===k?void 0:k.polar(S[0],M+(T?1:-1)*_);return null===(E=this.graphie)||void 0===E?void 0:E.addPoints(o[i(-1)],I)}return!0}],onMoveStart:()=>{this.isClickToAddPoints()&&this.setTrashCanVisibility(1)},onMove:()=>{var e;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&this.updateCoordsFromPoints()},onMoveEnd:e=>{var t=this.points.length>1&&(o===this.points[0]&&b.equal(e,l.last(this.points).coord())||o===l.last(this.points)&&b.equal(e,this.points[0].coord()));if(this.isClickToAddPoints()){if(this.isCoordInTrash(e))n();else if(t){var r,i,a=this.points.pop();if(this.points.length>2)null===(r=this.polygon)||void 0===r||r.update({closed:!0}),this.updateCoordsFromPoints();else null===(i=this.polygon)||void 0===i||i.update({closed:!1}),this.clearCoords();this.updatePolygon(),setTimeout(a.remove.bind(a),0)}else{if(l.any(this.points,(function(t){return t!==o&&b.equal(t.coord(),e)}))){var p,h;if(this.removePoint(o),this.points.length<3)null===(h=this.polygon)||void 0===h||h.update({closed:!1}),this.clearCoords();else null!==(p=this.polygon)&&void 0!==p&&p.closed()&&this.updateCoordsFromPoints();this.updatePolygon(),setTimeout(o.remove.bind(o),0)}else{var c,d,u=o===l.head(this.points)||o===l.last(this.points),m=!o.hasMoved(),g=!o.state.isInitialMove,f=!(null!==(c=this.polygon)&&void 0!==c&&c.closed()),v=this.points.length>2;if(u&&m&&g&&f&&v)null===(d=this.polygon)||void 0===d||d.update({closed:!0}),this.updatePolygon(),this.updateCoordsFromPoints()}}this.setTrashCanVisibility(.5)}s(o,!1)}},this.props.apiOptions.isMobile&&this.isClickToAddPoints()?{onRemove:n}:{}));return o.state.isInitialMove=!0,o})),V(this,"updateCoordsFromPoints",(()=>{var e=l.extend({},this.props.graph,{coords:l.map(this.points,(function(e){return l.result(e,"coord")}))});this.onChange({graph:e})})),V(this,"clearCoords",(()=>{var e=l.extend({},this.props.graph,{coords:null});this.onChange({graph:e})})),V(this,"onChange",(e=>{this.props.onChange(e),this.props.trackInteraction()})),V(this,"addPointControls",(()=>{if("point"!==this.props.graph.type)throw wh("addPointControls","point");var e=kh.getPointCoords(this.props.graph,this.props);this.points=[],this.points=l.map(e,this.createPointForPointsType,this)})),V(this,"removePointControls",(()=>{l.invoke(this.points,"remove")})),V(this,"addSegmentControls",(()=>{if("segment"!==this.props.graph.type)throw wh("addSegmentControls","segment");var e=this,t=this.graphie,r=kh.getSegmentCoords(this.props.graph,this.props),i=e=>dn.addMaybeMobileMovablePoint(this,e);this.points=[],this.lines=l.map(r,(function(r,n){for(var s=function(){var t=l.extend({},e.props.graph,{coords:l.invoke(e.lines,"coords")});e.onChange({graph:t})},o=[],a=function(e){var t=r[e];o.push(i({coord:t,constraints:[dn.MovablePoint.constraints.bound(),dn.MovablePoint.constraints.snap(),t=>{var r=o[1-e];return!!r&&!b.equal(t,r.coord())}],onMove:s}))},p=0;p<r.length;p+=1)a(p);e.points=e.points.concat(o);var h=dn.addMovableLine(t,{points:o,static:!1,constraints:[dn.MovableLine.constraints.bound(),dn.MovableLine.constraints.snap()],onMove:[dn.MovableLine.onMove.updatePoints,s],normalStyle:U({stroke:this.props.apiOptions.isMobile?dr.BLUE_C:dr.INTERACTIVE},this._lineStroke()),highlightStyle:U({stroke:this.props.apiOptions.isMobile?dr.BLUE_C:dr.INTERACTING},this._lineStroke())});return l.invoke(o,"toFront"),h}),this)})),V(this,"removeSegmentControls",(()=>{l.invoke(this.points,"remove"),l.invoke(this.lines,"remove")})),V(this,"addRayControls",(()=>{this.addLine("ray")})),V(this,"removeRayControls",(()=>{this.removeLine()})),V(this,"addPolygonControls",(()=>{this.polygon=null;var e=kh.getPolygonCoords(this.props.graph,this.props);this.points=[],this.points=l.map(e,this.createPointForPolygonType,this),this.updatePolygon()})),V(this,"updatePolygon",(()=>{if("polygon"!==this.props.graph.type)throw wh("updatePolygon","polygon");var e;e=this.polygon?this.polygon.closed():this.points.length>=3;var t=this.graphie,r=this.points.length,i=!l.contains(["angles","sides"],this.props.graph.snapTo),n=l.times(r,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==r-1)?"angles"===this.props.graph.snapTo?"$deg0":"$deg1":""}),this),s=l.times(r,(function(t){return e||0!==t&&t!==r-1}),this),o=l.times(r,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==r-1)?1:0}),this),a=l.times(r,(function(t){return!this.props.graph.showSides||!e&&t===r-1?"":"sides"===this.props.graph.snapTo?"$len0":"$len1"}),this);if(null==this.polygon){var p=this;p.polygon=dn.addMovablePolygon(t,{constraints:[dn.MovablePolygon.constraints.bound(),i?dn.MovablePolygon.constraints.snap():null],closed:e,points:p.points,angleLabels:n,showRightAngleMarkers:s,numArcs:o,sideLabels:a,onMove:[dn.MovablePolygon.onMove.updatePoints,function(){this.closed()&&p.updateCoordsFromPoints()}],normalStyle:U({stroke:this.props.apiOptions.isMobile?dr.BLUE_C:dr.INTERACTIVE},this._lineStroke())})}else this.polygon.update({closed:e,points:this.points,angleLabels:n,showRightAngleMarkers:s,numArcs:o,sideLabels:a})})),V(this,"removePolygonControls",(()=>{var e;l.invoke(this.points,"remove"),null===(e=this.polygon)||void 0===e||e.remove()})),V(this,"addAngleControls",(()=>{if("angle"!==this.props.graph.type)throw wh("addAngleControls","angle");var e,t,r=this.props.graph,i=this.graphie,n=kh.getAngleCoords(this.props.graph,this.props);this.points=n.map((function(e,t){return null==i?void 0:i.addMovablePoint(l.extend({coord:e,normalStyle:{stroke:dr.INTERACTIVE,fill:dr.INTERACTIVE}},1===t?{snapX:i.snap[0],snapY:i.snap[1]}:{}))})),this.angle=null==i?void 0:i.addMovableAngle({points:this.points,snapDegrees:r.snapDegrees||1,snapOffsetDeg:r.angleOffsetDeg||0,angleLabel:r.showAngles?"$deg0":"",pushOut:2,allowReflex:(e=r.allowReflexAngles,t=!0,null==e?t:e)}),f(this.angle).on("move",(()=>{var e;this.onChange({graph:U(U({},r),{},{coords:null===(e=this.angle)||void 0===e?void 0:e.getClockwiseCoords()})})}))})),V(this,"removeAngleControls",(()=>{var e;l.invoke(this.points,"remove"),null===(e=this.angle)||void 0===e||e.remove()})),V(this,"toggleShowAngles",(()=>{if("polygon"!==this.props.graph.type)throw wh("toggleShowAngles","polygon");var e=l.extend({},this.props.graph,{showAngles:!this.props.graph.showAngles});this.onChange({graph:e})})),V(this,"toggleShowSides",(()=>{if("polygon"!==this.props.graph.type)throw wh("toggleShowSides","polygon");var e=l.extend({},this.props.graph,{showSides:!this.props.graph.showSides});this.onChange({graph:e})})),V(this,"getUserInput",(()=>kh.getUserInputFromProps(this.props))),V(this,"simpleValidate",(e=>kh.validate(this.getUserInput(),e,this))),V(this,"focus",f.noop)}UNSAFE_componentWillMount(){th.UNSAFE_componentWillMount.call(this)}componentDidMount(){this.setGraphie(this.refs.graph.graphie())}UNSAFE_componentWillReceiveProps(e){var t,r;this.isClickToAddPoints()!==this.isClickToAddPoints(e)&&(this.shouldResetGraphie=!0,this.setState({shouldShowInstructions:xh(e)})),(null===(t=this.props.backgroundImage)||void 0===t?void 0:t.url)===(null===(r=e.backgroundImage)||void 0===r?void 0:r.url)&&this.props.backgroundImage===e.backgroundImage&&this.props.containerSizeClass===e.containerSizeClass||(this.shouldResetGraphie=!0)}componentDidUpdate(e,t){var r=e.graph.type,i=this.props.graph.type;(r!==i||"angle"===e.graph.type&&"angle"===this.props.graph.type&&this.areAngleGraphsEqual(e.graph,this.props.graph)||"point"===e.graph.type&&"point"===this.props.graph.type&&this.arePointGraphsEqual(e.graph,this.props.graph)||"polygon"===e.graph.type&&"polygon"===this.props.graph.type&&this.arePolygonGraphsEqual(e.graph,this.props.graph)||"segment"===e.graph.type&&"segment"===this.props.graph.type&&this.areSegmentGraphsEqual(e.graph,this.props.graph))&&(this["remove"+vh(r)+"Controls"](),this["add"+vh(i)+"Controls"]()),this.shouldResetGraphie&&this.resetGraphie()}areAngleGraphsEqual(e,t){return e.allowReflexAngles!==t.allowReflexAngles||e.angleOffsetDeg!==t.angleOffsetDeg||e.snapDegrees!==t.snapDegrees}arePointGraphsEqual(e,t){return e.numPoints!==t.numPoints}arePolygonGraphsEqual(e,t){return e.numSides!==t.numSides||e.showAngles!==t.showAngles||e.showSides!==t.showSides||e.snapTo!==t.snapTo}areSegmentGraphsEqual(e,t){return e.numSegments!==t.numSegments}render(){var e,t=os(this.props.containerSizeClass);this.isClickToAddPoints()&&this.state.shouldShowInstructions?"point"===this.props.graph.type?e=s._("Click to add points"):"polygon"===this.props.graph.type&&(e=s._("Click to add vertices")):e=void 0;var r=this.isClickToAddPoints()?this.handleAddPointsMouseDown:null,i=this.props.gridStep||De.getGridStep(this.props.range,this.props.step,t[0]),n=this.props.snapStep||De.snapStepFromGridStep(i),o=this.props.apiOptions.isMobile;return a.createElement("div",{className:"perseus-widget perseus-widget-interactive-graph",style:{width:t[0],height:t[1]}},a.createElement(eh,{instructions:e,ref:"graph",box:t,labels:this.props.labels,range:this.props.range,step:o?De.constrainedTickStepsFromTickSteps(this.props.step,this.props.range):this.props.step,gridStep:i,snapStep:n,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:r,onGraphieUpdated:this.setGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:o}))}static getQuadraticCoefficients(e){var t=e[0],r=e[1],i=e[2],n=(t[0]-r[0])*(t[0]-i[0])*(r[0]-i[0]);if(0!==n)return[(i[0]*(r[1]-t[1])+r[0]*(t[1]-i[1])+t[0]*(i[1]-r[1]))/n,(i[0]*i[0]*(t[1]-r[1])+r[0]*r[0]*(i[1]-t[1])+t[0]*t[0]*(r[1]-i[1]))/n,(r[0]*i[0]*(r[0]-i[0])*t[1]+i[0]*t[0]*(i[0]-t[0])*r[1]+t[0]*r[0]*(t[0]-r[0])*i[1])/n]}static getSinusoidCoefficients(e){var t=e[0],r=e[1],i=r[1]-t[1],n=Math.PI/(2*(r[0]-t[0]));return[i,n,t[0]*n,t[1]]}static getLineCoords(e,t){return e.coords||kh.pointsFromNormalized(t,[[.25,.75],[.75,.75]])}static getPointCoords(e,t){var r=e.numPoints||1,i=e.coords;if(i)return i;switch(r){case 1:i=[e.coord||[0,0]];break;case 2:i=[[-5,0],[5,0]];break;case 3:i=[[-5,0],[0,0],[5,0]];break;case 4:i=[[-6,0],[-2,0],[2,0],[6,0]];break;case 5:i=[[-6,0],[-3,0],[0,0],[3,0],[6,0]];break;case 6:i=[[-5,0],[-3,0],[-1,0],[1,0],[3,0],[5,0]];break;case"unlimited":i=[]}var n=kh.normalizeCoords(i,[[-10,10],[-10,10]]);return kh.pointsFromNormalized(t,n)}static getLinearSystemCoords(e,t){return e.coords||l.map([[[.25,.75],[.75,.75]],[[.25,.25],[.75,.25]]],(e=>kh.pointsFromNormalized(t,e)))}static getPolygonCoords(e,t){if("polygon"!==e.type)throw wh("toggleShowSides","polygon");var r=e.coords;if(r)return r;var i=e.numSides||3;if("unlimited"===i)r=[];else{var n=2*Math.PI/i,s=(1/i-.5)*Math.PI,o="sides"===e.snapTo?Math.sqrt(3)/3*7:4;r=l.times(i,(function(e){return[o*Math.cos(e*n+s),o*Math.sin(e*n+s)]}))}r=kh.normalizeCoords(r,[[-10,10],[-10,10]]);var a=!l.contains(["angles","sides"],e.snapTo);return r=kh.pointsFromNormalized(t,r,!a)}static getSegmentCoords(e,t){var r=e.coords;if(r)return r;var i=e.numSegments||1,n=[[-10,10],[-10,10]];return{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]}[i].map((function(e){var r=[[-5,e],[5,e]];return r=kh.normalizeCoords(r,n),r=kh.pointsFromNormalized(t,r)}))}static getAngleCoords(e,t){var r=e.coords;if(r)return r;for(var i=e.snapDegrees||1,n=i;n<20;)n+=i;n=n*Math.PI/180;var s=(e.angleOffsetDeg||0)*Math.PI/180;r=kh.pointsFromNormalized(t,[[.85,.5],[.5,.5]]);var o=hh(ph(...r));return r[0]=[r[1][0]+o*Math.cos(s),r[1][1]+o*Math.sin(s)],r[2]=[r[1][0]+o*Math.cos(n+s),r[1][1]+o*Math.sin(n+s)],r}static normalizeCoords(e,t){return l.map(e,(function(e){return l.map(e,(function(e,r){var i=t[r][1]-t[r][0];return(e+t[r][1])/i}))}))}static getEquationString(e){var t="get"+vh(e.graph.type)+"EquationString";return kh[t](e)}static pointsFromNormalized(e,t,r){return l.map(t,(function(t){return l.map(t,(function(t,i){var n=e.range[i];if(r)return n[0]+(n[1]-n[0])*t;var s=e.step[i],o=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,s),a=Math.round(t*o);return n[0]+s*a}))}))}static getLinearEquationString(e){var t=kh.getLineCoords(e.graph,e);if(rh(t[0][0],t[1][0]))return"x = "+t[0][0].toFixed(3);var r=(t[1][1]-t[0][1])/(t[1][0]-t[0][0]),i=t[0][1]-r*t[0][0];return rh(r,0)?"y = "+i.toFixed(3):"y = "+r.toFixed(3)+"x + "+i.toFixed(3)}static getCurrentQuadraticCoefficients(e){var t=e.graph.coords||kh.defaultQuadraticCoords(e);return kh.getQuadraticCoefficients(t)}static defaultQuadraticCoords(e){return kh.pointsFromNormalized(e,[[.25,.75],[.5,.25],[.75,.75]])}static getQuadraticEquationString(e){var t=kh.getCurrentQuadraticCoefficients(e);return"y = "+t[0].toFixed(3)+"x^2 + "+t[1].toFixed(3)+"x + "+t[2].toFixed(3)}static getCurrentSinusoidCoefficients(e){var t=e.graph.coords||kh.defaultSinusoidCoords(e);return kh.getSinusoidCoefficients(t)}static defaultSinusoidCoords(e){return kh.pointsFromNormalized(e,[[.5,.5],[.65,.6]])}static getSinusoidEquationString(e){var t=kh.getCurrentSinusoidCoefficients(e);return"y = "+t[0].toFixed(3)+"sin("+t[1].toFixed(3)+"x - "+t[2].toFixed(3)+") + "+t[3].toFixed(3)}static getCircleEquationString(e){var t=e.graph,r=t.center||[0,0],i=t.radius||2;return"center ("+r[0]+", "+r[1]+"), radius "+i}static getLinearSystemEquationString(e){var t=kh.getLinearSystemCoords(e.graph,e);return"\n"+bh(t[0][0],t[0][1])+"\n"+bh(t[1][0],t[1][1])+"\n"+function(e,t){var r=e[0][0],i=e[0][1],n=e[1][0],s=e[1][1],o=t[0][0],a=t[0][1],l=t[1][0],p=t[1][1],h=(r-n)*(a-p)-(i-s)*(o-l);if(Math.abs(h)<1e-9)return"Lines are parallel";var c=((r*s-i*n)*(a-p)-(i-s)*(o*p-a*l))/h;return"Intersection: ("+(((r*s-i*n)*(o-l)-(r-n)*(o*p-a*l))/h).toFixed(3)+", "+c.toFixed(3)+")"}(t[0],t[1])}static getPointEquationString(e){if("point"!==e.graph.type)throw wh("getPointEquationString","point");return kh.getPointCoords(e.graph,e).map((function(e){return"("+e[0]+", "+e[1]+")"})).join(", ")}static getSegmentEquationString(e){if("segment"!==e.graph.type)throw wh("getSegmentEquationString","segment");var t=kh.getSegmentCoords(e.graph,e);return l.map(t,(function(e){return"["+l.map(e,(function(e){return"("+e.join(", ")+")"})).join(" ")+"]"})).join(" ")}static getRayEquationString(e){if("ray"!==e.graph.type)throw wh("createPointForPolygonType","ray");var t=kh.getLineCoords(e.graph,e),r=t[0],i=t[1],n=kh.getLinearEquationString(e);return r[0]>i[0]?n+=" (for x <= "+r[0].toFixed(3)+")":r[0]<i[0]?n+=" (for x >= "+r[0].toFixed(3)+")":r[1]>i[1]?n+=" (for y <= "+r[1].toFixed(3)+")":n+=" (for y >= "+r[1].toFixed(3)+")",n}static getPolygonEquationString(e){if("polygon"!==e.graph.type)throw wh("getPolygonEquationString","polygon");var t=kh.getPolygonCoords(e.graph,e);return l.map(t,(function(e){return"("+e.join(", ")+")"})).join(" ")}static getAngleEquationString(e){if("angle"!==e.graph.type)throw wh("getAngleEquationString","angle");var t=kh.getAngleCoords(e.graph,e);return xr.findAngle(t[2],t[0],t[1]).toFixed(0)+"° angle at ("+t[1].join(", ")+")"}static validate(e,t,r){var i=!!(e.coords||e.center&&e.radius);if(e.type===t.correct.type&&i)if("linear"===e.type&&"linear"===t.correct.type&&null!=e.coords){var n=e.coords,s=t.correct.coords;if(sh(s[0],s[1],n[0])&&sh(s[0],s[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("linear-system"===e.type&&"linear-system"===t.correct.type&&null!=e.coords){var o=e.coords,a=t.correct.coords;if(sh(a[0][0],a[0][1],o[0][0])&&sh(a[0][0],a[0][1],o[0][1])&&sh(a[1][0],a[1][1],o[1][0])&&sh(a[1][0],a[1][1],o[1][1])||sh(a[0][0],a[0][1],o[1][0])&&sh(a[0][0],a[0][1],o[1][1])&&sh(a[1][0],a[1][1],o[0][0])&&sh(a[1][0],a[1][1],o[0][1]))return{type:"points",earned:1,total:1,message:null}}else if("quadratic"===e.type&&"quadratic"===t.correct.type&&null!=e.coords){var p=this.getQuadraticCoefficients(e.coords),h=this.getQuadraticCoefficients(t.correct.coords);if(ih(p,h))return{type:"points",earned:1,total:1,message:null}}else if("sinusoid"===e.type&&"sinusoid"===t.correct.type&&null!=e.coords){var c=this.getSinusoidCoefficients(e.coords),d=this.getSinusoidCoefficients(t.correct.coords),u=gh(c),m=gh(d);if(ih(u,m))return{type:"points",earned:1,total:1,message:null}}else if("circle"===e.type&&"circle"===t.correct.type){if(ih(e.center,t.correct.center)&&rh(e.radius,t.correct.radius))return{type:"points",earned:1,total:1,message:null}}else if("point"===e.type&&"point"===t.correct.type&&null!=e.coords){var g,f=kh.getPointCoords(t.correct,r),b=null===(g=e.coords)||void 0===g?void 0:g.slice();if(f=f.slice(),null==b||b.sort(),f.sort(),ih(b,f))return{type:"points",earned:1,total:1,message:null}}else if("polygon"===e.type&&"polygon"===t.correct.type&&null!=e.coords){var y,x,C,w=null===(y=e.coords)||void 0===y?void 0:y.slice(),k=null===(x=t.correct.coords)||void 0===x?void 0:x.slice();if("similar"===t.correct.match?C=uh(w,k,Number.POSITIVE_INFINITY):"congruent"===t.correct.match?C=uh(w,k,v.DEFAULT_TOLERANCE):"approx"===t.correct.match?C=uh(w,k,.1):(w.sort(),k.sort(),C=ih(w,k)),C)return{type:"points",earned:1,total:1,message:null}}else if("segment"===e.type&&"segment"===t.correct.type&&null!=e.coords){var E,S=e.coords.slice(),_=null===(E=t.correct.coords)||void 0===E?void 0:E.slice();if(S=l.invoke(S,"sort").sort(),_=l.invoke(_,"sort").sort(),ih(S,_))return{type:"points",earned:1,total:1,message:null}}else if("ray"===e.type&&"ray"===t.correct.type&&null!=e.coords){var M=e.coords,T=t.correct.coords;if(ih(M[0],T[0])&&sh(T[0],T[1],M[1]))return{type:"points",earned:1,total:1,message:null}}else if("angle"===e.type&&"angle"===t.correct.type){var I,P=e.coords,A=t.correct.coords;if("congruent"===t.correct.match){var N=l.map([P,A],(function(e){return(xr.findAngle(e[2],e[0],e[1])+360)%360}));I=rh(...N)}else I=ih(P[1],A[1])&&sh(A[1],A[0],P[0])&&sh(A[1],A[2],P[2]);if(I)return{type:"points",earned:1,total:1,message:null}}return!i||l.isEqual(e,t.graph)?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}static getUserInputFromProps(e){return e.graph}}V(kh,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showTooltips:!1,showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,graph:{type:"linear"}});var Eh={name:"interactive-graph",displayName:"Interactive graph",widget:kh};class Sh extends a.Component{constructor(){super(...arguments),V(this,"_input",void 0),V(this,"state",{isInputFocused:!1})}focusInput(){this._input&&this._input.focus()}handleClick(e){var{checked:t,onChange:r}=this.props;e.preventDefault(),this.focusInput(),r(!t)}handleKeyDown(e){var{onFocusPrevAnswer:t,onFocusNextAnswer:r}=this.props;switch(e.key){case"ArrowUp":e.preventDefault(),t();break;case"ArrowDown":e.preventDefault(),r()}}handleInputChange(e){e.preventDefault()}handleInputFocus(){this.setState({isInputFocused:!0})}handleInputBlur(){this.setState({isInputFocused:!1})}renderCheckmark(){var{checked:e}=this.props;return a.createElement("span",{className:u(Mh.checkmarkContainer)},e&&a.createElement(ca,{icon:mi,size:16,color:E.offBlack}))}render(){var{content:e,checked:t,groupName:r,index:i,inputType:n}=this.props,{isInputFocused:s}=this.state,o="".concat(r,"-").concat(i);return a.createElement("div",{className:u(Mh.answerChoice,s&&Mh.answerFocused),onClick:e=>this.handleClick(e),onKeyDown:e=>this.handleKeyDown(e)},a.createElement("span",{className:u(Mh.answerInputWrapper)},a.createElement("input",{className:u(Qo.perseusSrOnly),checked:t,name:r,id:o,type:n,onChange:e=>this.handleInputChange(e),onFocus:()=>this.handleInputFocus(),onBlur:()=>this.handleInputBlur(),ref:e=>this._input=e}),this.renderCheckmark()),a.createElement("label",{htmlFor:o},a.createElement(Ds,{content:e})))}}class _h extends a.Component{constructor(e){super(e),V(this,"_choices",void 0),this._choices=[],this.state={groupName:l.uniqueId("answer_choices_")}}focusAnswer(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.props.choices.length;e<0?e+=t:e>=t&&(e-=t);var r=this._choices[e];r&&r.focusInput()}onAnswerChange(e,t){for(var{choices:r,multipleSelect:i,onChange:n}=this.props,s=[],o=0;o<r.length;o++)s.push(i?o===e?t:r[o].checked:o===e&&t);n(s)}onFocusAnswer(e){this.focusAnswer(e)}render(){var{choices:e,multipleSelect:t}=this.props,{groupName:r}=this.state;return a.createElement("fieldset",null,e.map(((e,i)=>a.createElement(Sh,j({},e,{key:e.content,groupName:r,index:i,inputType:t?"checkbox":"radio",onChange:e=>this.onAnswerChange(i,e),onFocusPrevAnswer:()=>this.onFocusAnswer(i-1),onFocusNextAnswer:()=>this.onFocusAnswer(i+1),ref:e=>this._choices[i]=e})))))}}var Mh=d.create({answerChoice:{display:"flex",alignItems:"center",userSelect:"none",padding:"10px 16px 10px 0px",fontWeight:"bold",border:"solid 2px transparent",borderRadius:2,":active":{backgroundColor:"rgba(33, 36, 44, 0.08)"}},answerFocused:{borderColor:"#1865f2",":active":{borderColor:"transparent"}},answerInputWrapper:{marginRight:8},checkmarkContainer:{display:"flex",position:"relative",width:16,height:16,marginLeft:8}});class Th extends a.Component{constructor(){super(...arguments),V(this,"_icon",void 0),V(this,"state",{isFocused:!1})}handleFocus(){this.setState({isFocused:!0})}handleBlur(){this.setState({isFocused:!1})}renderIcon(){var e,t,{selected:r,showCorrectness:i,showSelected:n,showPulsate:s}=this.props,{isFocused:o}=this.state,l=n||o;return i?(e=a.createElement(ca,{icon:"correct"===i?ui:Ii,size:24,color:E.white}),t="correct"===i?[Ih.markerCorrect,l&&Ih.markerCorrectSelected]:[Ih.markerIncorrect,l&&Ih.markerIncorrectSelected]):t=r&&r.length>0?[Ih.markerFilled,l&&Ih.markerFilledSelected]:[l?Ih.markerUnfilledSelected:s&&Ih.markerUnfilledPulsate],a.createElement("div",{className:u(Ih.markerIcon,...t),ref:e=>this._icon=e},e)}render(){var{label:e,x:t,y:r,showCorrectness:i}=this.props,n="correct"===i;return a.createElement("button",{"aria-label":e,className:u(Ih.unstyledButton,Ih.marker,n&&Ih.disabled),style:{left:"".concat(t,"%"),top:"".concat(r,"%")},tabIndex:n?-1:0,onFocus:()=>this.handleFocus(),onBlur:()=>this.handleBlur(),onClick:e=>this.props.onClick(e),onKeyDown:e=>this.props.onKeyDown(e)},this.renderIcon())}}V(Th,"defaultProps",{selected:[]});var Ih=d.create({unstyledButton:{padding:0,overflow:"visible",color:"inherit",font:"inherit",lineHeight:"normal",background:"none",border:"none"},marker:{position:"absolute",width:30,height:30,marginLeft:-15,marginTop:-15},disabled:{pointerEvents:"none"},markerIcon:{display:"flex",position:"relative",boxSizing:"content-box",width:16,height:16,marginLeft:5,cursor:"pointer",backgroundColor:"#1865f2",border:"solid 2px #ffffff",borderRadius:16,boxShadow:"0 2px 6px 0 ".concat("rgba(33, 36, 44, 0.32)")},markerUnfilledPulsate:{animationName:{"0%":{transform:"scale(1)"},"100%":{transform:"scale(1.5)"}},animationDirection:"alternate",animationDuration:"0.8s",animationIterationCount:"infinite",animationTimingFunction:"ease-in",transformOrigin:"50% 50%"},markerUnfilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:20,height:20,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:20},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerFilled:{width:8,height:8,marginLeft:9,borderRadius:8,boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerFilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:12,height:12,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:12},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerCorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#00a60e",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerCorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#167b1f",boxShadow:"none","::before":{display:"none"}}},markerIncorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#909195",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerIncorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#6c6e73",boxShadow:"none","::before":{display:"none"}}}});class Ph extends a.Component{static gradeMarker(e){var t={hasAnswers:!1,isCorrect:!1};return e.selected&&e.selected.length>0&&(t.hasAnswers=!0),e.answers.length>0?e.selected&&e.selected.length===e.answers.length&&(t.isCorrect=e.selected.every((t=>e.answers.includes(t)))):e.selected&&0!==e.selected.length||(t.isCorrect=!0),t}static validate(e,t){var r=0,i=0;for(var n of e.markers){var s=Ph.gradeMarker(n);s.hasAnswers&&r++,s.isCorrect&&i++}return r!==e.markers.length?{type:"invalid",message:null}:{type:"points",earned:i===e.markers.length?1:0,total:1,message:null}}static pointInTriangle(e,t,r,i){var n=(e,t,r)=>(e.x-r.x)*(t.y-r.y)-(t.x-r.x)*(e.y-r.y),s=n(e,t,r)<0,o=n(e,r,i)<0,a=n(e,i,t)<0;return s===o&&o===a}static imageSideForMarkerPosition(e,t){if(e<20)return"left";if(e>80)return"right";var r={x:20,y:0},i={x:80,y:0},n={x:80,y:100},s={x:20,y:100},o={x:50,y:50},a={top:[r,i,o],right:[o,i,n],bottom:[s,o,n],left:[r,o,s]},l={x:e,y:t};for(var p of Object.keys(a)){var h=a[p];if(Ph.pointInTriangle(l,...h))return p}return"center"}static navigateToMarkerIndex(e,t,r){var i=t[r],n=t.map(((e,t)=>{var r=e.x-i.x,n=e.y-i.y,s=Math.sqrt(r**2+n**2);return{index:t,dist:s,dir:{x:0!==s?r/s:0,y:0!==s?n/s:0}}})).filter((e=>e.index!==r&&"correct"!==t[e.index].showCorrectness)).sort(((t,r)=>{var i,n,s=Math.round(t.dist*(e.x*t.dir.x+e.y*t.dir.y)),o=Math.round(r.dist*(e.x*r.dir.x+e.y*r.dir.y));return e.x>0?(i=t.dir.x>0&&0!==s,n=r.dir.x>0&&0!==o):e.x<0?(i=t.dir.x<0&&0!==s,n=r.dir.x<0&&0!==o):e.y>0?(i=t.dir.y>0&&0!==s,n=r.dir.y>0&&0!==o):e.y<0&&(i=t.dir.y<0&&0!==s,n=r.dir.y<0&&0!==o),i!==n?i?-1:1:s-o}));return n.length>0?n[0].index:r}constructor(e){super(e),V(this,"_markers",void 0),V(this,"_selectedMarkerPopup",void 0),V(this,"_answerChoices",void 0),V(this,"handleDocumentClick",(e=>{if(this._selectedMarkerPopup&&this._answerChoices){var t=g.findDOMNode(this._answerChoices),r=e.target;(function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return t&&(t.contains(r)||i>0&&e(t.parentElement,i-1))})(t)||this.dismissMarkerPopup()}})),V(this,"handleDocumentKeyDown",(e=>{this._selectedMarkerPopup&&27===e.keyCode&&(e.stopPropagation(),this.dismissMarkerPopup())})),this._markers=[],this.state={selectedMarkerIndex:-1,markersInteracted:!1}}componentDidMount(){document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeyDown,!0)}componentWillUnmount(){document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeyDown,!0)}simpleValidate(e){return Ph.validate(this.getUserInput(),e)}getUserInput(){var{markers:e}=this.props;return{markers:e}}showRationalesForCurrentlySelectedChoices(e){var{markers:t}=this.props,{onChange:r}=this.props;r({markers:t.map((e=>{var t=Ph.gradeMarker(e);return U(U({},e),{},{showCorrectness:t.hasAnswers?t.isCorrect?"correct":"incorrect":void 0})}))},null,!0)}dismissMarkerPopup(){var{selectedMarkerIndex:e}=this.state;-1!==e&&this.setState({selectedMarkerIndex:-1},(()=>{var t=this._markers[e];t&&g.findDOMNode(t).focus()}))}handleMarkerChange(e,t){var{markers:r,onChange:i}=this.props;i({markers:[...r.slice(0,e),U(U({},t),{},{showCorrectness:void 0}),...r.slice(e+1)]})}handleMarkerClick(e,t){var{selectedMarkerIndex:r}=this.state;t.preventDefault(),r!==e?this.setState({selectedMarkerIndex:e,markersInteracted:!0},(()=>{setTimeout((()=>{this._answerChoices&&this._answerChoices.focusAnswer()}),100)})):this.dismissMarkerPopup()}handleMarkerKeyDown(e,t){var{markers:r}=this.props;if(!(r.length<2)){var i={ArrowUp:{x:0,y:-1},ArrowRight:{x:1,y:0},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0}}[t.key];if(i){t.preventDefault();var n=this._markers[Ph.navigateToMarkerIndex(i,r,e)];n&&g.findDOMNode(n).focus()}}}handleAnswerChoicesChangeForMarker(e,t){var{choices:r,markers:i,multipleAnswers:n}=this.props,s=r.filter(((e,r)=>t[r]));this.handleMarkerChange(e,U(U({},i[e]),{},{selected:s})),n||this.dismissMarkerPopup()}renderAnswerChoicesForMarker(e,t){var{choices:r,multipleAnswers:i}=this.props,n=t.selected;return a.createElement("div",{className:o("perseus-label-image-widget-answer-choices",u(Ah.scrollableChoices))},a.createElement(_h,{choices:r.map((e=>({content:e,checked:!!n&&n.includes(e)}))),multipleSelect:i,onChange:t=>this.handleAnswerChoicesChangeForMarker(e,t),ref:e=>this._answerChoices=e}))}renderMarkers(){var{markers:e,questionCompleted:t}=this.props,{selectedMarkerIndex:r,markersInteracted:i}=this.state;return e.map(((e,n)=>{var s,o=Ph.gradeMarker(e),l=a.createElement(Th,j({},e,{showCorrectness:t&&o.hasAnswers&&o.isCorrect?"correct":e.showCorrectness,showSelected:n===r,showPulsate:!i,key:"".concat(e.x,".").concat(e.y),onClick:e=>this.handleMarkerClick(n,e),onKeyDown:e=>this.handleMarkerKeyDown(n,e),ref:e=>this._markers[n]=e}));return n!==r?l:(s=window.matchMedia(jo.xsOrSmaller.replace("@media ","")).matches?e.y>50?"top":"bottom":{left:"right",top:"bottom",right:"left",bottom:"top",center:"top"}[Ph.imageSideForMarkerPosition(e.x,e.y)],a.createElement(D,{content:()=>a.createElement(O,{style:Ah.choicesPopover},this.renderAnswerChoicesForMarker(n,e)),placement:s,opened:!0,key:"".concat(e.x,".").concat(e.y),ref:e=>this._selectedMarkerPopup=e},l))}))}renderInstructions(){var{apiOptions:{isMobile:e},choices:t,multipleAnswers:r,hideChoicesFromInstructions:i}=this.props,n=e?r?s._("Tap each dot on the image to select all answers that apply."):s._("Tap each dot on the image to select an answer."):r?s._("Click each dot on the image to select all answers that apply."):s._("Click each dot on the image to select an answer."),l=s._("Choices:");return a.createElement("div",{className:o("perseus-label-image-widget-instructions",u(Ah.instructions))},a.createElement("div",{className:u(Ah.instructionsCaption)},n," ",!i&&l),!i&&a.createElement("div",{className:u(Ah.instructionsChoices)},t.map(((e,t)=>a.createElement("div",{className:u(Ah.instructionsChoice),key:t},a.createElement(Ds,{content:e}))))))}render(){var{imageAlt:e,imageUrl:t,imageWidth:r,imageHeight:i}=this.props,{selectedMarkerIndex:n}=this.state;return a.createElement("div",null,this.renderInstructions(),a.createElement("div",{className:u(Ah.markersCanvas),style:{maxWidth:r,maxHeight:i}},a.createElement("div",{className:u(Ah.imageContainer,-1!==n&&Ah.imageInteractionDisabled)},a.createElement(Qt.Consumer,null,(n=>{var{setAssetStatus:s}=n;return a.createElement(Un,{alt:e,src:t,width:r,height:i,setAssetStatus:s})}))),this.renderMarkers()))}}var Ah=d.create({instructions:{paddingBottom:16},instructionsCaption:U(U({},fa.bodyXsmallBold),{},{paddingBottom:16}),instructionsChoices:{display:"flex",flexWrap:"wrap",margin:"-8px 0"},instructionsChoice:{display:"flex",alignItems:"center",margin:"8px 0",":not(:last-child)":{"::after":{content:"''",display:"inline-block",position:"relative",width:2,height:2,marginLeft:5,marginRight:5,background:"rgba(33, 36, 44, 0.32)",borderRadius:2}}},markersCanvas:{position:"relative"},imageContainer:{display:"flex"},imageInteractionDisabled:{pointerEvents:"none"},scrollableChoices:{paddingTop:8,paddingBottom:8,[jo.xsOrSmaller]:{maxHeight:250,overflowY:"auto"}},choicesPopover:{padding:0}}),Nh={name:"label-image",displayName:"Label Image",widget:Ph,accessible:!0,isLintable:!0},Rh={display:"table",tableLayout:"fixed"},Fh={display:"table-row"},Dh={display:"table-cell",padding:5},Oh={borderRadius:10,cursor:"pointer"},Lh={padding:5,display:"inline-block"},Bh={float:"right",paddingRight:5},zh={plus:()=>[[!1,!0,!1],[!0,!0,!0],[!1,!0,!1]],x:()=>[[!0,!1,!0],[!1,!0,!1],[!0,!1,!0]],"plus/x":e=>e%2?zh.x():zh.plus()};class qh extends a.Component{constructor(){super(...arguments),V(this,"_flip",(()=>{this.props.onChange(!this.props.value)}))}render(){var e=this.props.value?"#55dd55":"#115511",t=l.extend({},Oh,{width:this.props.size,height:this.props.size,backgroundColor:e});return a.createElement("div",{style:t,onClick:this._flip})}}V(qh,"propTypes",{value:h.bool.isRequired,size:h.number.isRequired});class Hh extends a.Component{render(){return a.createElement("div",{style:Rh,className:"no-select"},l.map(this.props.cells,((e,t)=>a.createElement("div",{key:t,style:Fh},l.map(e,((e,r)=>a.createElement("div",{key:r,style:Dh},a.createElement(qh,{value:e,size:this.props.size,onChange:l.partial(this.props.onChange,t,r)}))))))))}}V(Hh,"propTypes",{cells:h.arrayOf(h.arrayOf(h.bool)).isRequired,size:h.number.isRequired});var Wh=(e,t,r,i)=>((e,t)=>l.map(e,((e,r)=>l.map(e,((e,i)=>t(r,i)?!e:e)))))(e,((e,n)=>{var s=e-t,o=n-r;return Math.abs(s)<=1&&Math.abs(o)<=1&&i[s+1][o+1]}));class Uh extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"_currPattern",void 0),V(this,"_nextPattern",void 0),V(this,"_patternIndex",void 0),V(this,"getUserInput",(()=>Do.getUserInput.call(this))),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"_width",(()=>0!==this.props.cells.length?this.props.cells[0].length:0)),V(this,"_initNextPatterns",(()=>{this._currPattern=zh[this.props.flipPattern](0),this._nextPattern=zh[this.props.flipPattern](1),this._patternIndex=2})),V(this,"_shiftPatterns",(()=>{this._currPattern=this._nextPattern,this._nextPattern=zh[this.props.flipPattern](this._patternIndex),this._patternIndex++})),V(this,"_flipTile",((e,t)=>{var r=Wh(this.props.cells,e,t,this._currPattern);this._shiftPatterns(),this.change({cells:r,moveCount:this.props.moveCount+1})})),V(this,"_reset",(()=>{this.change({cells:this.props.startCells,moveCount:0})})),V(this,"simpleValidate",(e=>Gh(e,this.getUserInput())))}render(){var e=60*this._width();return a.createElement("div",null,a.createElement(Hh,{cells:this.props.cells,size:50,onChange:this._flipTile}),a.createElement("div",{style:{width:e}},a.createElement("div",{style:Lh},s.ngettext("Moves: %(num)s","Moves: %(num)s",this.props.moveCount)),a.createElement("div",{style:Bh},a.createElement("input",{type:"button",value:"Reset",onClick:this._reset,className:"simple-button"}))),a.createElement("div",{className:"clearfix"}))}componentDidMount(){this._initNextPatterns()}componentDidUpdate(e){e.flipPattern!==this.props.flipPattern&&this._initNextPatterns()}}V(Uh,"propTypes",U(U({},mo),{},{cells:h.arrayOf(h.arrayOf(h.bool)),startCells:h.arrayOf(h.arrayOf(h.bool)),flipPattern:h.string.isRequired,moveCount:h.number.isRequired})),V(Uh,"defaultProps",{cells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",moveCount:0});var Gh=function(e,t){return l.all(t.cells,((t,r)=>l.all(t,((t,i)=>t===e.startCells[r][i]))))?{type:"invalid",message:s._("Click on the tiles to change the lights.")}:l.all(t.cells,(e=>l.all(e,(e=>e))))?{type:"points",earned:1,total:1,message:null}:e.gradeIncompleteAsWrong?{type:"points",earned:0,total:1,message:null}:{type:"invalid",message:s._("You must turn on all of the lights to continue.")}},Vh={name:"lights-puzzle",displayName:"Lights Puzzle",hidden:!0,widget:Uh,transform:function(e){return{cells:e.startCells,startCells:e.startCells,flipPattern:e.flipPattern}}},jh=(e,t)=>{var r=e.offsetParent();return{top:t.top+r.scrollTop(),left:t.left+r.scrollLeft()}};class Yh extends a.Component{render(){var{layout:e}=this.props,t=u(Kh.card,Kh.placeholder,"horizontal"===e&&Kh.horizontalCard),r={width:this.props.width,height:this.props.height};return null!=this.props.margin&&(r.margin=this.props.margin),a.createElement("li",{className:t,style:r})}}V(Yh,"propTypes",{layout:h.oneOf(["horizontal","vertical"]),width:h.number.isRequired,height:h.number.isRequired});class Xh extends a.Component{constructor(){super(...arguments),V(this,"animationFrameRequest",null),V(this,"isMouseMoveUpBound",void 0),V(this,"_mounted",void 0),V(this,"state",{startPosition:{left:0,top:0},startMouse:{left:0,top:0},mouse:{left:0,top:0}}),V(this,"getCurrentPosition",(()=>({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}))),V(this,"bindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!0,f(document).on("mousemove",this.onMouseMove),f(document).on("mouseup",this.onMouseUp)})),V(this,"unbindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!1,f(document).off("mousemove",this.onMouseMove),f(document).off("mouseup",this.onMouseUp)})),V(this,"onMouseDown",(e=>{if("static"===this.props.type&&(0===e.button||null!=e.touches&&1===e.touches.length)){e.preventDefault();var t=De.extractPointerLocation(e);this.animationFrameRequest=requestAnimationFrame((()=>{var e=f(g.findDOMNode(this)),r=e.position(),i=jh(e,r);t&&this._mounted&&this.setState({startPosition:i,startMouse:t,mouse:t,dragging:!0},(function(){this.bindMouseMoveUp(),this.props.onMouseDown()}))}))}})),V(this,"onMouseMove",(e=>{if(!("dragging"!==this.props.type||!this.state.dragging)){e.preventDefault();var t=De.extractPointerLocation(e);t&&(this.animationFrameRequest=requestAnimationFrame((()=>{this.setState({mouse:t},this.props.onMouseMove)})))}})),V(this,"onMouseUp",(e=>{"dragging"!==this.props.type||!this.state.dragging||(e.preventDefault(),De.extractPointerLocation(e)&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp()))}))}componentDidMount(){this._mounted=!0,this.isMouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!De.supportsPassiveEvents()&&{passive:!1})}componentWillUnmount(){this._mounted=!1,this.isMouseMoveUpBound&&this.unbindMouseMoveUp(),this.animationFrameRequest&&cancelAnimationFrame(this.animationFrameRequest),document.removeEventListener("touchmove",this.onMouseMove)}render(){var{includePadding:e,layout:t,type:r}=this.props,i=u(Kh.card,Kh.draggable,"horizontal"===t&&Kh.horizontalCard,"vertical"===t&&Kh.verticalCard,"dragging"===r&&Kh.dragging,"disabled"===r&&Kh.disabled,!e&&Kh.unpaddedCard)+" "+Zt.INTERACTIVE+" perseus-sortable-draggable";e||(i+=" perseus-sortable-draggable-unpadded");var n={position:"static"};return"dragging"!==this.props.type&&"animating"!==this.props.type||l.extend(n,{position:"absolute"},this.getCurrentPosition()),this.props.width&&(n.width=this.props.width+1),this.props.height&&(n.height=this.props.height),null!=this.props.margin&&(n.margin=this.props.margin),a.createElement("li",{className:i,style:n,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,onTouchMove:this.onMouseMove,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},a.createElement(Ds,{content:this.props.content,linterContext:Wt.pushContextStack(this.props.linterContext,"draggable"),onRender:this.props.onRender}))}componentDidUpdate(e){if(this.props.type!==e.type)if("animating"===this.props.type){var t=this.getCurrentPosition(),r=15*Math.sqrt(Math.sqrt(Math.pow(this.props.endPosition.left-t.left,2)+Math.pow(this.props.endPosition.top-t.top,2)));f(g.findDOMNode(this)).animate(this.props.endPosition,{duration:Math.max(r,1),complete:this.props.onAnimationEnd})}else"static"===this.props.type&&f(g.findDOMNode(this)).finish()}}V(Xh,"propTypes",{content:h.string.isRequired,endPosition:h.object.isRequired,includePadding:h.bool,layout:h.oneOf(["horizontal","vertical"]),onAnimationEnd:h.func.isRequired,onMouseDown:h.func.isRequired,onMouseMove:h.func.isRequired,onMouseUp:h.func.isRequired,onRender:h.func.isRequired,type:h.oneOf(["static","dragging","animating","disabled"]),linterContext:Ut}),V(Xh,"defaultProps",{includePadding:!0,type:"static",linterContext:Gt});class $h extends a.Component{constructor(e){super(e),V(this,"remeasureItems",l.debounce((()=>{this.setState({items:$h.clearItemMeasurements(this.state.items)})}),20)),this.state={items:$h.itemsFromProps(this.props),katex:null}}UNSAFE_componentWillReceiveProps(e){var t=this.props;l.isEqual(e.options,t.options)?e.layout===t.layout&&e.padding===t.padding&&e.disabled===t.disabled&&l.isEqual(e.constraints,t.constraints)||this.setState({items:$h.clearItemMeasurements(this.state.items)}):this.setState({items:$h.itemsFromProps(e)})}componentDidUpdate(){!this.state.items.length||this.state.items[0].width||this.state.items[0].height||setTimeout((()=>{this.measureItems()}),0)}componentDidMount(){oe().getKaTeX().then((e=>{this.setState({katex:e})}))}static itemsFromProps(e){var t=e.disabled?"disabled":"static";return e.options.map(((e,r)=>({option:e,key:r,type:t,endPosition:{},width:0,height:0})))}static clearItemMeasurements(e){return e.map((e=>U(U({},e),{},{width:0,height:0})))}measureItems(){var e=l.clone(this.state.items),t=l.map(e,(function(e){return f(g.findDOMNode(this.refs[e.key]))}),this),r=l.invoke(t,"outerWidth"),i=l.invoke(t,"outerHeight"),{constraints:n,layout:s}=this.props,o=null;null!=n&&n.width?o=l.max(r.concat(n.width)):"vertical"===s&&(o=l.max(r));var a=null;null!=n&&n.height?a=l.max(i.concat(n.height)):"horizontal"===s&&(a=l.max(i)),e=l.map(e,(function(e,t){return e.width=o||r[t],e.height=a||i[t],e})),this.setState({items:e},(()=>{this.props.onMeasure&&this.props.onMeasure({widths:r,heights:i})}))}render(){var e,t;if(this.props.waitForKatexLoad&&!this.state.katex)return a.createElement(L,null);var r=[],{layout:i}=this.props,n=u(Kh.sortable)+" perseus-sortable",s=(null===(e=this.props.constraints)||void 0===e?void 0:e.width)||"vertical"===i,o=(null===(t=this.props.constraints)||void 0===t?void 0:t.height)||"horizontal"===i;return l.each(this.state.items,(function(e,t,n){var l,p=t===n.length-1,h="static"===e.type||"disabled"===e.type;"horizontal"===this.props.layout?l="0 "+this.props.margin+"px 0 0":"vertical"===this.props.layout&&(l="0 0 "+this.props.margin+"px 0"),r.push(a.createElement(Xh,{content:e.option,key:e.key,type:e.type,ref:e.key,width:s?e.width:void 0,height:o?e.height:void 0,layout:i,includePadding:this.props.padding,margin:p&&h?0:l,endPosition:e.endPosition,linterContext:Wt.pushContextStack(this.props.linterContext,"sortable"),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)})),"dragging"!==e.type&&"animating"!==e.type||r.push(a.createElement(Yh,{key:"placeholder_"+e.key,ref:"placeholder_"+e.key,width:e.width,height:e.height,layout:i,margin:p?0:l}))}),this),a.createElement("ul",{className:n},r)}onMouseDown(e){var t=l.map(this.state.items,(function(t){return t.key===e&&(t.type="dragging"),t}));this.setState({items:t})}moveOptionToIndex(e,t){var{items:r}=this.state;if(t<0||t>r.length)throw new Error("index ".concat(t," out of bounds"));var i=l.clone(r),n=r.filter((t=>t.option===e))[0];if(null==n)throw new Error("option ".concat(e," not found"));var s=r.findIndex((e=>e.key===n.key));i.splice(s,1),i.splice(t,0,n),this.setState({items:i}),this.props.onChange&&this.props.onChange({})}onMouseMove(e){var t=f(g.findDOMNode(this.refs[e])),r=f(g.findDOMNode(this)),i=l.clone(this.state.items),n=l.findWhere(this.state.items,{key:e}),s=this.props.margin||0,o=l.indexOf(i,n),a=0;if(i.splice(o,1),"horizontal"===this.props.layout){var p,h=t.offset().left-r.offset().left,c=0;l.each(i,(function(e){p=e.width,h>c+p/2&&(a+=1),c+=p+s}))}else{var d,u=t.offset().top-r.offset().top,m=0;l.each(i,(function(e){d=e.height,u>m+d/2&&(a+=1),m+=d+s}))}a!==o&&(i.splice(a,0,n),this.setState({items:i}))}onMouseUp(e){var t=requestAnimationFrame((()=>{var t=l.map(this.state.items,(function(t){if(t.key===e){t.type="animating";var r=f(g.findDOMNode(this.refs["placeholder_"+e])),i=r.position(),n=jh(r,i);t.endPosition=n}return t}),this);this.setState({items:t}),this.props.onChange&&this.props.onChange({})}));this.animationFrameRequest=t}onAnimationEnd(e){var t=l.map(this.state.items,(function(t){return t.key===e&&(t.type="static"),t}));this.setState({items:t})}getOptions(){return l.pluck(this.state.items,"option")}}V($h,"defaultProps",{layout:"horizontal",padding:!0,disabled:!1,constraints:{},onMeasure:function(){},margin:5,onChange:function(){},linterContext:Gt,waitForKatexLoad:!0});var Kh=d.create({sortable:{boxSizing:"border-box",float:"left",padding:0,margin:0},card:{boxSizing:"border-box",background:"#fff",border:"1px solid #ddd",borderRadius:4,cursor:"pointer",minWidth:25,minHeight:44,padding:10,listStyleType:"none",userSelect:"none",touchAction:"none"},placeholder:{background:"#ddd",border:"1px solid #ccc"},draggable:{textAlign:"center"},horizontalCard:{float:"left",cursor:"ew-resize"},verticalCard:{maxWidth:"100%",cursor:"ns-resize"},unpaddedCard:{padding:0},dragging:{background:"#ffedcd",opacity:.8},disabled:{backgroundColor:"inherit",border:"1px solid transparent",cursor:"default"}}),{shuffle:Zh,seededRNG:Jh}=De;class Qh extends a.Component{constructor(){super(...arguments),V(this,"state",{leftHeight:0,rightHeight:0,katex:null}),V(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),V(this,"onMeasureLeft",(e=>{var t=l.max(e.heights);this.setState({leftHeight:t})})),V(this,"onMeasureRight",(e=>{var t=l.max(e.heights);this.setState({rightHeight:t})})),V(this,"getUserInput",(()=>this.state.katex?{left:this.refs.left.getOptions(),right:this.refs.right.getOptions()}:{left:[],right:[]})),V(this,"moveLeftOptionToIndex",((e,t)=>{this.refs.left.moveOptionToIndex(e,t)})),V(this,"moveRightOptionToIndex",((e,t)=>{this.refs.right.moveOptionToIndex(e,t)})),V(this,"simpleValidate",(e=>Qh.validate(this.getUserInput(),e)))}componentDidMount(){oe().getKaTeX().then((e=>this.setState({katex:e})))}render(){if(!this.state.katex)return a.createElement(L,null);var e,t=Jh(this.props.problemNum);e=this.props.orderMatters?Zh(this.props.left,t,!0):this.props.left;var r=Zh(this.props.right,t,!0),i=l.any(this.props.labels),n={height:l.max([this.state.leftHeight,this.state.rightHeight])},s=this.props.apiOptions.isMobile?8:5;return a.createElement("table",{className:u(ec.widget)+" perseus-widget-matcher"},a.createElement("tbody",null,i&&a.createElement("tr",{className:u(ec.row)},a.createElement("th",{className:u(ec.column,ec.columnLabel)},a.createElement(Ds,{content:this.props.labels[0]||"...",linterContext:this.props.linterContext})),a.createElement("th",{className:u(ec.column,ec.columnRight,ec.columnLabel)},a.createElement(Ds,{content:this.props.labels[1]||"...",linterContext:this.props.linterContext}))),a.createElement("tr",{className:u(ec.row)},a.createElement("td",{className:u(ec.column)},a.createElement($h,{options:e,layout:"vertical",padding:this.props.padding,disabled:!this.props.orderMatters,constraints:n,onMeasure:this.onMeasureLeft,onChange:this.changeAndTrack,margin:s,linterContext:this.props.linterContext,ref:"left"})),a.createElement("td",{className:u(ec.column,ec.columnRight)},a.createElement($h,{options:r,layout:"vertical",padding:this.props.padding,constraints:n,onMeasure:this.onMeasureRight,onChange:this.changeAndTrack,margin:s,linterContext:this.props.linterContext,ref:"right"})))))}}V(Qh,"propTypes",{apiOptions:Kt.propTypes,labels:h.array,left:h.array,onChange:h.func,orderMatters:h.bool,padding:h.bool,problemNum:h.number,right:h.array,trackInteraction:h.func.isRequired,linterContext:Ut}),V(Qh,"defaultProps",{left:[],right:[],labels:["",""],orderMatters:!1,padding:!0,problemNum:0,onChange:function(){},linterContext:Gt}),l.extend(Qh,{validate:function(e,t){return{type:"points",earned:l.isEqual(e.left,t.left)&&l.isEqual(e.right,t.right)?1:0,total:1,message:null}}});var ec=d.create({widget:{paddingTop:5,maxWidth:"100%",minWidth:"auto"},row:{border:0},column:{padding:0,border:0},columnRight:{borderLeft:"1px solid #444"},columnLabel:{fontWeight:"inherit",borderBottom:"1px solid #444",padding:"0 ".concat(5,"px ").concat(5,"px ").concat(5,"px"),textAlign:"center"}}),tc={name:"matcher",displayName:"Two column matcher",widget:Qh,isLintable:!0},rc=["onFormatChange","checkValidity","useArrowKeys"],{firstNumericalParse:ic,captureScratchpadTouchStart:nc}=De,sc=ce.toNumericString,oc=ce.getNumericFormat;class ac extends a.Component{constructor(){super(...arguments),V(this,"state",{format:this.props.format}),V(this,"getValue",(()=>this.parseInputValue(g.findDOMNode(this.refs.input).value))),V(this,"getStringValue",(()=>g.findDOMNode(this.refs.input).value.toString())),V(this,"parseInputValue",(e=>{if(""===e){var t=this.props.placeholder;return l.isFinite(t)?+t:null}var r=ic(e);return l.isFinite(r)?r:this.props.value})),V(this,"focus",(()=>{g.findDOMNode(this.refs.input).focus(),this._handleFocus()})),V(this,"blur",(()=>{g.findDOMNode(this.refs.input).blur(),this._handleBlur()})),V(this,"setSelectionRange",((e,t)=>{g.findDOMNode(this).setSelectionRange(e,t)})),V(this,"getSelectionStart",(()=>g.findDOMNode(this).selectionStart)),V(this,"getSelectionEnd",(()=>g.findDOMNode(this).selectionEnd)),V(this,"_checkValidity",(e=>{if(null==e)return!0;var t=ic(e),r=this.props.checkValidity;return l.isFinite(t)&&r(t)})),V(this,"_handleChange",(e=>{var t=e.target.value,r=this.parseInputValue(t),i=oc(t);this.props.onChange(r),i&&(this.props.onFormatChange(r,i),this.setState({format:i}))})),V(this,"_handleFocus",(()=>{this.props.onFocus&&this.props.onFocus()})),V(this,"_handleBlur",(e=>{e&&"keypress"===e.type&&13!==e.keyCode||(this._setValue(this.props.value,this.state.format),this.props.onBlur&&this.props.onBlur())})),V(this,"_onKeyDown",(e=>{if(this.props.onKeyDown&&this.props.onKeyDown(e),this.props.useArrowKeys&&l.contains(["ArrowUp","ArrowDown"],e.key)){var t=this.getValue();t===Math.floor(t)&&("ArrowUp"===e.key?t+=1:"ArrowDown"===e.key&&(t-=1),this._checkValidity(t)&&this.props.onChange(t))}})),V(this,"_setValue",((e,t)=>{f(g.findDOMNode(this.refs.input)).val(sc(e,t))}))}render(){var e=o({"number-input":!0,"invalid-input":!this._checkValidity(this.props.value),mini:"mini"===this.props.size,small:"small"===this.props.size,normal:"normal"===this.props.size});null!=this.props.className&&(e=e+" "+this.props.className);var t=Y(this.props,rc);return a.createElement("input",j({},t,{className:e,type:"text",ref:"input",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,onKeyPress:this._handleBlur,onKeyDown:this._onKeyDown,onTouchStart:nc,defaultValue:sc(this.props.value,this.state.format),value:void 0}))}componentDidUpdate(e){v.equal(this.getValue(),this.props.value)||this._setValue(this.props.value,this.state.format)}}V(ac,"propTypes",{value:h.number,format:h.string,placeholder:h.oneOfType([h.string,h.number]),onChange:h.func.isRequired,onFormatChange:h.func,checkValidity:h.func,size:h.string,label:h.oneOf(["put your labels outside your inputs!"])}),V(ac,"defaultProps",{value:null,placeholder:null,format:null,onFormatChange:()=>null,checkValidity:()=>!0,useArrowKeys:!1});var{assert:lc}=pr,{stringArrayOfSize:pc}=De,hc={INPUT_MARGIN:4,INPUT_HEIGHT:38,INPUT_WIDTH:82},cc={INPUT_MARGIN:3,INPUT_HEIGHT:30,INPUT_WIDTH:40},dc={INPUT_MARGIN:4,INPUT_HEIGHT:36,INPUT_WIDTH:64};function uc(e,t){return[""+e,""+t]}var mc=function(){return uc(0,0)},gc=function(e){return lc(l.isArray(e)&&2===e.length),+e[0]},fc=function(e){return lc(l.isArray(e)&&2===e.length),+e[1]},vc=function(e){return"answer"+gc(e)+","+fc(e)},bc=function(e){var t=[1,1];return l(e).each(((e,r)=>{var i=0;l(e).each(((e,t)=>{null!=e&&e.toString().length&&(i=t+1)})),t[1]=Math.max(t[1],i),i>0&&(t[0]=Math.max(t[0],r+1))})),t};class yc extends a.Component{constructor(){super(...arguments),V(this,"cursorPosition",void 0),V(this,"state",{enterTheMatrix:0}),V(this,"getInputPaths",(()=>{var e=[],t=this.props.matrixBoardSize[0],r=this.props.matrixBoardSize[1];return l(t).times((t=>{l(r).times((r=>{var i=uc(t,r);e.push(i)}))})),e})),V(this,"getGrammarTypeForPath",(e=>"number")),V(this,"_handleFocus",((e,t)=>{this.props.onFocus(uc(e,t))})),V(this,"_handleBlur",((e,t)=>{this.props.onBlur(uc(e,t))})),V(this,"focus",(()=>(this.focusInputPath(mc()),!0))),V(this,"focusInputPath",(e=>{var t=vc(e);this.refs[t].focus()})),V(this,"blurInputPath",(e=>{0===e.length&&(e=mc());var t=vc(e);this.refs[t].blur()})),V(this,"getDOMNodeForPath",(e=>{var t=vc(e);return g.findDOMNode(this.refs[t])})),V(this,"setInputValue",((e,t,r)=>{var i=gc(e),n=fc(e);this.onValueChange(i,n,t,r)})),V(this,"handleKeyDown",((e,t,r)=>{var i=this.props.matrixBoardSize[0],n=this.props.matrixBoardSize[1],s=null,o=this.refs[vc(uc(e,t))],a=o.getStringValue(),l=o.getSelectionStart(),p=o.getSelectionEnd(),h=null;if("ArrowUp"===r.key&&e>0?h=uc(e-1,t):"ArrowDown"===r.key&&e+1<i?h=uc(e+1,t):"ArrowLeft"===r.key&&t>0?0===l&&0===p&&(h=uc(e,t-1)):"ArrowRight"===r.key&&t+1<n?l===a.length&&(h=uc(e,t+1)):"Enter"===r.key?s=this.state.enterTheMatrix+1:"Escape"===r.key&&(s=0),h){r.preventDefault();var c=this.refs[vc(h)],d=2*c.getStringValue().length;c.focus(),"ArrowRight"===r.key?c.setSelectionRange(0,0):c.setSelectionRange(d,d)}null!=s&&this.setState({enterTheMatrix:s})})),V(this,"onValueChange",((e,t,r,i)=>{var n=l.map(this.props.answers,l.clone);n[e]||(n[e]=[]),n[e][t]=r,this.props.onChange({answers:n},i),this.props.trackInteraction()})),V(this,"getUserInput",(()=>({answers:this.props.answers}))),V(this,"simpleValidate",(e=>yc.validate(this.getUserInput(),e)))}componentDidMount(){this.cursorPosition=[0,0]}render(){var e;e=this.props.apiOptions.customKeypad?dc:this.props.apiOptions.staticRender?hc:cc;var{INPUT_MARGIN:t,INPUT_HEIGHT:r,INPUT_WIDTH:i}=e,n=bc(this.props.answers),s=this.props.matrixBoardSize[0],p=this.props.matrixBoardSize[1],h=this.props.cursorPosition[0],c=this.props.cursorPosition[1],d=Math.max(h,n[0]-1),u=Math.max(c,n[1]-1),m=(d+1)*(r+2*t),g=(u+1)*(i+2*t),f=o({"perseus-matrix":!0,"static-mode":this.props.static,"the-matrix":this.state.enterTheMatrix>=5});return a.createElement("div",{className:f},this.props.prefix&&a.createElement("div",{className:"matrix-prefix"},a.createElement(Ds,{content:this.props.prefix,linterContext:this.props.linterContext})),a.createElement("div",{className:"matrix-input"},a.createElement("div",{className:"matrix-bracket bracket-left",style:{height:m}}),a.createElement("div",{className:"matrix-bracket bracket-right",style:{height:m,left:g}}),l(s).times((e=>{var n=this.props.answers[e];return a.createElement("div",{className:"matrix-row",key:e},l(p).times((s=>{var o,l=e>d||s>u,p={className:l?"outside":"inside",ref:vc(uc(e,s)),value:n?n[s]:null,style:{height:r,width:i,margin:t},disabled:this.props.apiOptions.readOnly,onFocus:()=>{this.cursorPosition=[e,s],this.props.onChange({cursorPosition:[e,s]},(()=>!1)),this._handleFocus(e,s)},onBlur:()=>{e===this.cursorPosition[0]&&s===this.cursorPosition[1]&&this.props.onChange({cursorPosition:[0,0]},(()=>!1)),this._handleBlur(e,s)},onKeyDown:t=>{this.handleKeyDown(e,s,t)},onChange:(t,r)=>{this.onValueChange(e,s,t,r)}};if(this.props.apiOptions.customKeypad){var h={margin:t,minWidth:i,minHeight:r,boxSizing:"border-box",backgroundColor:l?"#f3f3f3":"#fff"};o=a.createElement(ko,j({},p,{style:h,scrollable:!0,keypadElement:this.props.keypadElement}))}else o=this.props.apiOptions.staticRender?a.createElement(Zs,p):this.props.numericInput?a.createElement(ac,p):a.createElement(Qs,p);return a.createElement("span",{key:s,className:"matrix-input-field"},o)})))}))),this.props.suffix&&a.createElement("div",{className:"matrix-suffix"},a.createElement(Ds,{content:this.props.suffix,linterContext:this.props.linterContext})))}}V(yc,"defaultProps",{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0],apiOptions:Kt.defaults,linterContext:Gt}),l.extend(yc,{validate:function(e,t){var r=t.answers,i=e.answers,n=bc(r),o=bc(i),a=n[0]!==o[0]||n[1]!==o[1],p=me.number.createValidatorFunctional,h=null,c=!1,d=!1;return l(o[0]).times((e=>{l(o[1]).times((t=>{if(null!=i[e][t]&&0!==i[e][t].toString().length||(c=!0),!a){var n=p(r[e][t],{simplify:!0})(i[e][t]);n.message&&(h=n.message),n.correct||(d=!0)}}))})),c?{type:"invalid",message:s._("Make sure you fill in all cells in the matrix.")}:a?{type:"points",earned:0,total:1,message:null}:{type:"points",earned:d?0:1,total:1,message:h}}});var xc={name:"matrix",displayName:"Matrix",widget:yc,transform:e=>{var t=l(e.matrixBoardSize[0]).times((function(){return pc(e.matrixBoardSize[1])}));return e=l.pick(e,"matrixBoardSize","prefix","suffix"),l.extend(e,{answers:t})},staticTransform:e=>{var t=l.pick(e,"matrixBoardSize","prefix","suffix");return t.answers=l.map(e.answers,(e=>l.map(e,(e=>null!=e?String(e):"")))),t},isLintable:!0},Cc={url:null,top:0,left:0},wc=w({displayName:"Measurer",propTypes:{apiOptions:Kt.propTypes,box:h.arrayOf(h.number),image:h.shape({url:h.string,top:h.number,left:h.number}),showProtractor:h.bool,protractorX:h.number,protractorY:h.number,showRuler:h.bool,rulerLabel:h.string,rulerTicks:h.number,rulerPixels:h.number,rulerLength:h.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=l.extend({},Cc,this.props.image);return a.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&&a.createElement("div",{style:{position:"relative",top:e.top,left:e.left}},a.createElement(Un,{src:e.url})),a.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this.setupGraphie()},componentDidUpdate:function(e){l.any(["box","showProtractor","showRuler","rulerLabel","rulerTicks","rulerPixels","rulerLength"],(function(t){return e[t]!==this.props[t]}),this)&&this.setupGraphie()},setupGraphie:function(){var e=g.findDOMNode(this.refs.graphieDiv);f(e).empty();var t=this.graphie=xr.createGraphie(e),r=[40,40],i=[[0,this.props.box[0]/r[0]],[0,this.props.box[1]/r[1]]];t.init({range:i,scale:r}),t.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),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:[(i[0][0]+i[0][1])/2,(i[1][0]+i[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 wc.validate(this.getUserInput(),e)},focus:f.noop});l.extend(wc,{validate:function(e,t){return{type:"points",earned:1,total:1,message:null}}});var kc={name:"measurer",displayName:"Measurer",widget:wc,version:{major:1,minor:0},propUpgrades:{1:e=>l(e).chain().omit("imageUrl","imageTop","imageLeft").extend({image:{url:e.imageUrl,top:e.imageTop,left:e.imageLeft}}).value()}};function Ec(e,t){var r=new Path2D;e.lineWidth=Ic.lineWidth,e.strokeStyle=Ic.fgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r)}var Sc={text:function(e,t){null!==t.value&&(e.fillStyle=Ic.fgColor,e.font=Ic.font,e.fillText(t.value,t.pos[0]-Ic.fontSizePx/2+1,t.pos[1]+Ic.fontSizePx/2))},"line:single":Ec,"line:double":function(e,t){var r=new Path2D;e.lineWidth=5*Ic.lineWidth,e.strokeStyle=Ic.fgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r),r=new Path2D,e.lineWidth=3*Ic.lineWidth,e.strokeStyle=Ic.bgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r)},"line:triple":function(e,t){var r=new Path2D;e.lineWidth=7*Ic.lineWidth,e.strokeStyle=Ic.fgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r),r=new Path2D,e.lineWidth=5*Ic.lineWidth,e.strokeStyle=Ic.bgColor,r.moveTo(t.startPos[0],t.startPos[1]),r.lineTo(t.endPos[0],t.endPos[1]),e.stroke(r),Ec(e,t)}};var _c={"line:single":0,"line:double":0,"line:triple":0,text:1};function Mc(e,t){return _c[e.type]-_c[t.type]}function Tc(e,t){t.sort(Mc).forEach(function(e){return function(t){Sc[t.type](e,t)}}(e))}var Ic={bgColor:"rgb(255, 255, 255)",fgColor:"rgb(0, 0, 0)",fontSizePx:12,lineWidth:1,font:"12px sans"};function Pc(e,t,r,i){var n=e.symbol;if("C"===n&&1!==Object.keys(t).length&&(n=null),"1,0"===e.idx){var s=[0,0];return e.pos=s,e.baseAngle=-30+i,{type:"text",value:n,pos:s,idx:e.idx}}var o=t[e.connections.find((function(e){return t[e].pos}))],a=o.connections.indexOf(e.idx),l=60,p=120;4===o.connections.length?(p=90,l=90):(r.find((t=>"triple"===t.bondType&&t.to===e.idx))||r.find((e=>"triple"===e.bondType&&e.to===o.idx)))&&(p=0,l=0);var h=0,c=o.idx.split(":"),d=c[c.length-1].split(",")[0];h=parseInt(d)%2!=0?o.baseAngle-(l-p*a):o.baseAngle+(l-p*a);var u=function(e,t,r){var i=e[0],n=e[1];return[i+Math.cos(2*t*Math.PI/360)*r,n+-1*Math.sin(2*t*Math.PI/360)*r]}(o.pos,h,30);return e.pos=u,e.baseAngle=h,{type:"text",value:n,pos:u,idx:e.idx}}function Ac(e,t){var r=function(e,t){var r=[e.pos[0],e.pos[1]],i=[t.pos[0],t.pos[1]];return"C"!==e.symbol&&(r=[t.pos[0]-.75*(t.pos[0]-e.pos[0]),t.pos[1]-.75*(t.pos[1]-e.pos[1])]),"C"!==t.symbol&&(i=[e.pos[0]-.75*(e.pos[0]-t.pos[0]),e.pos[1]-.75*(e.pos[1]-t.pos[1])]),[r,i]}(t[e.from],t[e.to]);return{type:"line:"+e.bondType,startPos:r[0],endPos:r[1]}}function Nc(e){return e.join(":")}function Rc(e,t,r){if(null===r)return[e,t];if("atom"===r.type){var i=Nc(r.idx);e[i]={idx:i,symbol:r.symbol,connections:[]},r.bonds&&r.bonds.forEach((function(r){var n=Nc(r.to.idx);e[i].connections.push(n),t.push({from:i,to:n,bondType:r.bondType}),Rc(e,t,r.to),e[n].connections.push(i)}))}return[e,t]}function Fc(e,t,r,i,n){if(0===t.length)return e;var s=t.shift(),o=r[s];return o.connections.forEach((function(e){r[e].pos||t.push(e)})),Fc(e.concat(Pc(o,r,i,n)),t,r,i,n)}function Dc(e,t,r){return 0===r.length?e:Dc(e.concat(Ac(r[0],t)),t,r.slice(1))}var Oc={layout:function(e,t){var r=Rc({},[],e),i=r[0],n=r[1];return Dc(Fc([],["1,0"],i,n,t),i,n)},_atomLayout:Pc,_bondLayout:Ac,_bondLength:30,_convertTree:Rc},Lc=new RegExp("^[A-Za-z\\[\\]()=#+-]*$"),Bc=new RegExp("^(Cl|Br|[CONPSFBI]|\\[)");function zc(e){this.message=e}function qc(e,t,r){var i,n=t[0],s=t.slice(1);i=Array.isArray(e)?[...e]:U({},e||{});var o=r;return s.length>0&&(o=qc(i[n],s,r)),i[n]=o,i}function Hc(e,t){if(0===t.length)return e;if(""===e)throw new zc("Mismatched parentheses");var r=e[0],i=e.slice(1);return Hc(i,"("===r?t.concat(r):")"===r?t.slice(1):t)}function Wc(e,t){var r,i,n,s=e[0],o=e.slice(1);if("("===s){var a=U(U({},t),{},{parens:t.parens+"("});r=t,i=["idx",t.idx.length-1,1],n=i.reduce((function(e,t){return e[t]}),r),a=qc(r,i,n+1);var l=-1;t.idx[t.idx.length-1][0]%2==0&&(l=0);var p=Gc(o,U(U({},a),{},{idx:a.idx.concat([[l,0]]),parens:a.parens.concat("(")})),h=Gc(Hc(o,["("]),a);return[p].concat(h)}if(")"===s){if("("!==t.parens[t.parens.length-1])throw new zc("Mismatched parentheses");return null}throw new zc("Invalid bare character: "+s)}function Uc(e,t){var r=function(e,t){var r=null,i=null;if("["===e[0]){var n=e.indexOf("]");if(-1===n)return["",e];r=e.slice(1,n),i=e.slice(n+1)}else r=Bc.exec(e)[1],i=e.slice(r.length);return[r,i]}(e),i=r[0];if(""===i)return["error","Unable to parse bracketed atom."];var n=r[1],s=qc(t,["idx",t.idx.length-1],[1+t.idx[t.idx.length-1][0],0]),o=Gc(n,qc(s,["bond","bondType"],"single"));!Array.isArray(o)&&o&&(o=[o]);var a={type:"atom",symbol:i,bonds:o,idx:s.idx};return t.bond?{type:"bond",bondType:t.bond.bondType,to:a}:a}function Gc(e,t){if(!function(e){return Lc.test(e)}(e))throw new zc("Invalid input.");return e&&0!==e.length?(r=e,Bc.test(r)?Uc(e,t||{idx:[[0,0]],parens:[],stack:[],bondModifiers:[]}):function(e){return"="===e||"#"===e}(e[0])?function(e,t){var r=e[0],i=e.slice(1);if("="===r)return Gc(i,qc(t,["bond","bondType"],"double"));if("#"===r)return Gc(i,qc(t,["bond","bondType"],"triple"));throw new zc("Invalid character: "+r)}(e,t):Wc(e,t)):null;var r}var Vc=Gc,jc=zc,{layout:Yc}=Oc,Xc=Vc,$c=jc;class Kc extends a.Component{constructor(){super(...arguments),V(this,"state",{parsedSmiles:null,error:null}),V(this,"stateFromSmiles",(e=>{try{this.setState({parsedSmiles:Xc(e),error:null})}catch(e){if(!(e instanceof $c))throw e;this.setState({error:e.message})}})),V(this,"setCanvasBounds",((e,t)=>{var r=Math.max(...t.map((e=>e.pos?e.pos[0]:-1/0))),i=Math.max(...t.map((e=>e.pos?e.pos[1]:-1/0))),n=Math.min(...t.map((e=>e.pos?e.pos[0]:1/0))),s=Math.min(...t.map((e=>e.pos?e.pos[1]:1/0))),o=r-n+60,a=i-s+60;return e.width=o,e.height=a,[30-n,30-s]})),V(this,"canvasRender",(()=>{if(!this.state.error&&this.state.parsedSmiles){var e=Yc(this.state.parsedSmiles,this.props.rotationAngle),t=this.refs.canvas,r=this.setCanvasBounds(t,e),i=t.getContext("2d");i.clearRect(0,0,t.width,t.height),i.save(),i.translate(r[0],r[1]),Tc(i,e),i.restore()}}))}UNSAFE_componentWillMount(){this.stateFromSmiles(this.props.smiles)}componentDidMount(){this.canvasRender()}UNSAFE_componentWillReceiveProps(e){this.stateFromSmiles(e.smiles)}componentDidUpdate(){this.canvasRender()}render(){var e=a.createElement("canvas",{className:"molecule-canvas",id:this.props.id+"-molecule",ref:"canvas"},s.$_("A molecular structure drawing. SMILES notation: %(content)s",{content:this.props.smiles}));return this.state.error&&(e=a.createElement("div",{className:"error"},this.state.error)),a.createElement("div",{className:"molecule-canvas"},e)}}V(Kc,"propTypes",{id:h.string.isRequired,rotationAngle:h.number,smiles:h.string});class Zc extends a.Component{constructor(){super(...arguments),V(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),V(this,"getUserInput",(()=>[])),V(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null})))}render(){return a.createElement(Kc,{id:this.props.widgetId,smiles:this.props.smiles,rotationAngle:this.props.rotationAngle})}}V(Zc,"propTypes",{rotationAngle:h.number,smiles:h.string,widgetId:h.string}),V(Zc,"defaultProps",{rotationAngle:0});var Jc={name:"molecule-renderer",displayName:"Molecule renderer",hidden:!0,widget:Zc},Qc=In.MovablePoint,ed=In.Line,{assert:td}=pr,rd={ge:"le",gt:"lt",le:"ge",lt:"gt"},id={ge:"gt",gt:"ge",le:"lt",lt:"le"};function nd(e,t){return 1===t?""+e:"\\dfrac{".concat(e,"}{").concat(t,"}")}function sd(e,t){if(e<0)return"-"+sd(-e,t);var r=Math.floor(e/t);return 0===r?nd(e,t):e-r*t==0?""+r:r+nd(e-r*t,t)}var od=(e,t,r,i,n)=>{if(i=i||r,"decimal"===t||"decimal ticks"===t)return e.label([r,-.53],Math.round(100*i)/100,"center");if("improper"===t){var s=ce.toFraction(i);return e.label([r,-.17],nd(s[0],s[1]),"below")}if("mixed"===t){var o=ce.toFraction(i);return e.label([r,-.17],sd(o[0],o[1]),"below")}if("non-reduced"===t){var a=ce.toFraction(i);return e.label([r,-.17],function(e,t,r){return nd(e*Math.floor(r/t),r)}(a[0],a[1],n),"below")}},ad=In.createSimpleClass(((e,t)=>{if(!l.isFinite(t.tickStep)||t.tickStep<=0)return[];var r,i=[],n=t.range,s=t.labelRange,o=null==s[0]?n[0]:s[0],a=null==s[1]?n[1]:s[1];if("non-reduced"===t.labelStyle){for(var p=[o,a],h=0;h<=t.numDivisions;h++){var c=n[0]+h*t.tickStep;p.push(c)}var d=l.map(p,(e=>v.toFraction(e)[1]));r=l.reduce(d,((e,t)=>ce.getLCM(e,t)))}else r=void 0;for(var u=0;u<=t.numDivisions;u++){var m=n[0]+u*t.tickStep;i.push(e.line([m,-.2],[m,.2])),(t.labelTicks||"decimal ticks"===t.labelStyle)&&i.push(od(e,t.labelStyle,m,m,r))}return i.push(e.style(t.isMobile?{color:dr.BLUE_D}:{},(()=>od(e,t.labelStyle,o,o,r)))),i.push(e.style(t.isMobile?{color:dr.BLUE_D}:{},(()=>od(e,t.labelStyle,a,a,r)))),e.style({stroke:t.isMobile?dr.BLUE_D:dr.DYNAMIC,strokeWidth:3.5},(()=>{i.push(e.line([o,-.2],[o,.2])),i.push(e.line([a,-.2],[a,.2]))})),i}));class ld extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"state",{numDivisionsEmpty:!1}),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"isValid",(()=>{var e=this.props.range,t=this.props.numLinePosition,r=this.props.divisionRange;return t=null==t?e[0]:t,e[0]<e[1]&&v.sign(t-e[0])>=0&&v.sign(t-e[1])<=0&&r[0]<r[1]&&0<this.props.numDivisions&&0<this.props.snapDivisions})),V(this,"onNumDivisionsChange",((e,t)=>{var r=this.props.divisionRange.slice(),i=this.props.range[1]-this.props.range[0];if(e=(e=Math.round(e))<0?-1*e:e){var n=l.extend({},this.props,{tickStep:i/e}),s=this.snapNumLinePosition(n,this.props.numLinePosition);this.setState({numDivisionsEmpty:!1},(()=>{this.props.onChange({divisionRange:r,numDivisions:e,numLinePosition:s},t)}))}else this.setState({numDivisionsEmpty:!0},t)})),V(this,"_handleTickCtrlFocus",(()=>{this.props.onFocus(["tick-ctrl"])})),V(this,"_handleTickCtrlBlur",(()=>{this.props.onBlur(["tick-ctrl"])})),V(this,"focus",(()=>{if(this.props.isTickCtrl)return this.refs["tick-ctrl"].focus(),!0})),V(this,"focusInputPath",(e=>{1===e.length&&this.refs[e[0]].focus()})),V(this,"blurInputPath",(e=>{1===e.length&&this.refs[e[0]].blur()})),V(this,"getInputPaths",(()=>this.props.isTickCtrl?[["tick-ctrl"]]:[])),V(this,"getDOMNodeForPath",(e=>{if(1===e.length)return g.findDOMNode(this.refs[e[0]])})),V(this,"getGrammarTypeForPath",(e=>{if(1===e.length&&"tick-ctrl"===e[0])return"number"})),V(this,"setInputValue",((e,t,r)=>{1===e.length&&"tick-ctrl"===e[0]&&this.onNumDivisionsChange(t,r)})),V(this,"_renderGraphie",(()=>{var e=this.props.range,t=e[1]-e[0],r=l.pick(this.props,["range","isTickCtrl"]),i=l.extend({},this.props,{tickStep:t/this.props.numDivisions});return a.createElement(In,{ref:"graphie",key:this.props.labelStyle,box:[this.props.apiOptions.isMobile?288:460,80],options:r,onMouseDown:e=>{this.refs.graphie.movables.numberLinePoint.grab(e)},setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile},a.createElement(ad,j({},l.pick(i,["range","numDivisions","labelTicks","labelStyle","labelRange","tickStep"]),{isMobile:this.props.apiOptions.isMobile})),this._renderInequality(i),this._renderNumberLinePoint(i))})),V(this,"snapNumLinePosition",((e,t)=>{var r=e.range[0],i=e.range[1],n=e.tickStep/e.snapDivisions,s=((e,t,r)=>Math.min(Math.max(e,t),r))(t,r,i);return s=r+v.roundTo(s-r,n),td(l.isFinite(s)),s})),V(this,"movePosition",(e=>{this.change({numLinePosition:e}),this.props.trackInteraction()})),V(this,"_renderNumberLinePoint",(e=>{var t=l(["lt","gt"]).contains(e.rel),r={fill:t?dr._BACKGROUND:e.static?dr.DYNAMIC:dr.INTERACTIVE,stroke:e.static?dr.DYNAMIC:dr.INTERACTIVE,"stroke-width":t?3:1},i={fill:t?dr._BACKGROUND:dr.INTERACTING,"stroke-width":t?3:1},n=e.isInequality?{stroke:dr.INTERACTIVE,"fill-opacity":t?0:1}:{};return a.createElement(Qc,{ref:"numberLinePoint",pointSize:6,coord:[e.numLinePosition,0],constraints:[(e,t)=>[e[0],t[1]],(t,r)=>[this.snapNumLinePosition(e,t[0]),t[1]]],normalStyle:r,highlightStyle:i,onMove:e=>{this.movePosition(e[0])},isMobile:this.props.apiOptions.isMobile,mobileStyleOverride:n,showTooltips:this.props.showTooltips,xOnlyTooltip:!0})})),V(this,"handleReverse",(()=>{var e=rd[this.props.rel];this.props.onChange({rel:e})})),V(this,"handleToggleStrict",(()=>{var e=id[this.props.rel];this.props.onChange({rel:e})})),V(this,"_getInequalityEndpoint",(e=>{var t=l(["ge","gt"]).contains(e.rel),r=e.range,i=30*((r[1]-r[0])/400),n=r[0]-i,s=r[1]+i;return t?[s,0]:[n,0]})),V(this,"_renderInequality",(e=>{if(e.isInequality){var t=this._getInequalityEndpoint(e),r={arrows:"->",stroke:this.props.apiOptions.isMobile?dr.INTERACTIVE:dr.DYNAMIC,strokeWidth:3.5},i=["ge","gt"].includes(e.rel);return a.createElement(ed,{start:[(i?.4:-.4)+e.numLinePosition,0],end:t,style:r})}return null})),V(this,"_setupGraphie",((e,t)=>{if(this.isValid()){var r=this.props.apiOptions.isMobile?228:400,i=t.range,n=(i[1]-i[0])/r,s=30*n,o=i[0]-s,a=i[1]+s,l="improper"===this.props.labelStyle||"mixed"===this.props.labelStyle||"non-reduced"===this.props.labelStyle?-1.5:-1;e.init({range:[[o,a],[l,1]],scale:[1/n,40],isMobile:this.props.apiOptions.isMobile});var p=(i[0]+i[1])/2;e.line([p,0],[a,0],{arrows:"->"}),e.line([p,0],[o,0],{arrows:"->"})}})),V(this,"getUserInput",(()=>({numLinePosition:this.props.numLinePosition,rel:this.props.isInequality?this.props.rel:"eq",numDivisions:this.props.numDivisions,divisionRange:this.props.divisionRange}))),V(this,"simpleValidate",(e=>ld.validate(this.getUserInput(),e)))}render(){var e,t,r=this.props.divisionRange,i=r[0]+"–"+r[1],n=this.props.numDivisions<r[0]||this.props.numDivisions>r[1],o=a.createElement("div",null,a.createElement("input",{type:"button",className:"simple-button",value:s._("Switch direction"),onClick:this.handleReverse}),a.createElement("input",{type:"button",className:"simple-button",value:l(["le","ge"]).contains(this.props.rel)?s._("Make circle open"):s._("Make circle filled"),onClick:this.handleToggleStrict}));this.props.isTickCtrl&&(t=this.props.apiOptions.customKeypad?ko:this.props.apiOptions.staticRender?Zs:ac,e=a.createElement("label",null,s._("Number of divisions:")," ",a.createElement(t,{ref:"tick-ctrl",value:this.state.numDivisionsEmpty?null:this.props.numDivisions||r[0],checkValidity:e=>e>=r[0]&&e<=r[1],onChange:this.onNumDivisionsChange,onFocus:this._handleTickCtrlFocus,onBlur:this._handleTickCtrlBlur,useArrowKeys:!0,keypadElement:this.props.keypadElement})));return a.createElement("div",{className:"perseus-widget perseus-widget-interactive-number-line"},e,this.isValid()?this.props.isTickCtrl&&n?a.createElement("div",{className:"perseus-error"},s.$_("Please make sure the number of divisions is in the range %(divRangeString)s.",{divRangeString:i})):this._renderGraphie():a.createElement("div",{className:"perseus-error"},s.doNotTranslate("Invalid number line configuration.")),!this.props.static&&this.props.isInequality&&o)}}V(ld,"defaultProps",{range:[0,10],labelStyle:"decimal",labelRange:[null,null],divisionRange:[1,12],labelTicks:!0,isTickCtrl:!1,isInequality:!1,numLinePosition:0,snapDivisions:2,showTooltips:!1,rel:"ge",apiOptions:Kt.defaults}),l.extend(ld,{validate:function(e,t){var r=t.range,i=e.divisionRange,n=null!=t.initialX?t.initialX:r[0],s=t.isInequality?"ge":"eq",o=t.correctRel||"eq",a=v.equal(e.numLinePosition,t.correctX||0),l=e.numDivisions>i[1]||e.numDivisions<i[0];return e.isTickCrtl&&l?{type:"invalid",message:"Number of divisions is outside the allowed range."}:a&&o===e.rel?{type:"points",earned:1,total:1,message:null}:e.numLinePosition===n&&e.rel===s?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}});var pd={name:"number-line",displayName:"Number line",widget:ld,transform:e=>{var t,r=l.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isTickCtrl","isInequality","showTooltips"]),i=null!=e.initialX?e.initialX:e.range[0],n=e.range[1]-e.range[0];return t=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?n/e.tickStep:void 0,l.extend(r,{numLinePosition:i,numDivisions:t,snapDivisions:r.snapDivisions||void 0}),r},staticTransform:e=>{var t,r=l.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isInequality"]),i=null!=e.correctX?e.correctX:e.range[0],n=e.range[1]-e.range[0];return t=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?n/e.tickStep:void 0,l.extend(r,{numLinePosition:i,numDivisions:t,rel:e.isInequality?e.correctRel:null,snapDivisions:r.snapDivisions||void 0}),r}};class hd extends a.Component{render(){return a.createElement("div",{className:"card-wrap "+Zt.INTERACTIVE,style:{width:this.props.width}},a.createElement("div",{className:"card placeholder",style:{height:this.props.height}}))}}V(hd,"propTypes",{width:h.number.isRequired,height:h.number.isRequired});class cd extends a.Component{render(){return a.createElement("div",{className:"card-wrap "+Zt.INTERACTIVE},a.createElement("div",{className:"card drag-hint"}))}}var dd=h.shape({left:h.number,top:h.number});class ud extends a.Component{constructor(){super(...arguments),V(this,"mouseMoveUpBound",void 0),V(this,"state",{dragging:!1}),V(this,"bindMouseMoveUp",(()=>{this.mouseMoveUpBound=!0,f(document).on("mousemove",this.onMouseMove),f(document).on("mouseup",this.onMouseUp)})),V(this,"unbindMouseMoveUp",(()=>{this.mouseMoveUpBound=!1,f(document).off("mousemove",this.onMouseMove),f(document).off("mouseup",this.onMouseUp)})),V(this,"onMouseDown",(e=>{e.preventDefault();var t=De.extractPointerLocation(e);t&&(this.setState({dragging:!0}),this.bindMouseMoveUp(),this.props.onMouseDown&&this.props.onMouseDown(t,this))})),V(this,"onMouseMove",(e=>{if(this.state.dragging){e.preventDefault();var t=De.extractPointerLocation(e);t&&this.props.onMouseMove&&this.props.onMouseMove(t)}})),V(this,"onMouseUp",(e=>{e.preventDefault();var t=De.extractPointerLocation(e);t&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp&&this.props.onMouseUp(t))}))}render(){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 r=l.pick(this.props,"content"),i=this.props.animating?f.noop:this.onMouseDown;return a.createElement("div",{className:"card-wrap "+Zt.INTERACTIVE,style:e,onMouseDown:i,onTouchStart:i,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},a.createElement("div",{className:t.join(" ")},a.createElement(Ds,j({},r,{linterContext:this.props.linterContext}))))}shouldComponentUpdate(e,t){return this.props.floating||e.floating||this.props.content!==e.content||this.props.fakeRef!==e.fakeRef}componentDidMount(){this.mouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!De.supportsPassiveEvents()&&{passive:!1})}componentDidUpdate(e,t){if(this.props.animating&&!e.animating){var r=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)));f(g.findDOMNode(this)).animate(this.props.animateTo,Math.max(r,1),this.props.onAnimationEnd)}}componentWillUnmount(){this.mouseMoveUpBound&&(pe.error("Removing an element with bound event handlers.",le.Internal),this.unbindMouseMoveUp(),De.resetTouchHandlers()),document.removeEventListener("touchmove",this.onMouseMove)}}V(ud,"propTypes",{floating:h.bool.isRequired,animating:h.bool,width:h.number,stack:h.bool,onMouseDown:h.func,onMouseMove:h.func,onMouseUp:h.func,startMouse:dd,startOffset:dd,animateTo:dd,onAnimationEnd:h.func,linterContext:Ut}),V(ud,"defaultProps",{stack:!1,animating:!1,linterContext:Gt});class md extends a.Component{constructor(){super(...arguments),V(this,"state",{current:[],dragging:!1,placeholderIndex:null,dragKey:null,animating:!1,dragContent:null,dragWidth:null,dragHeight:null,offsetPos:null,animateTo:null,grabPos:null}),V(this,"onClick",((e,t,r,i)=>{var n,s=f(g.findDOMNode(i)),o=this.state.current.slice(),a=null;"current"===e?(o.splice(t,1),n=this.state.current[t],a=t):"bank"===e&&(n=this.props.options[t]),this.setState({current:o,dragging:!0,placeholderIndex:a,dragKey:n.key,dragContent:n.content,dragWidth:s.width(),dragHeight:s.height(),grabPos:r,mousePos:r,offsetPos:s.position()})})),V(this,"onRelease",(e=>{var t=this.refs.dragging;if(null!=t){var r=this.isCardInBank(t),i=this.state.placeholderIndex||0,n=()=>{var e=this.state.current.slice();if(!r){var t={content:this.state.dragContent,key:l.uniqueId("perseus_draggable_card_"),width:this.state.dragWidth};e.splice(i,0,t)}this.props.onChange({current:e}),this.setState({current:e,dragging:!1,placeholderIndex:null,animating:!1}),this.props.trackInteraction()},s=f(g.findDOMNode(t)).position(),o=null;r?l.each(this.props.options,(function(e,t){if(e.content===this.state.dragContent){var r=g.findDOMNode(this.refs["bank"+t]);o=f(r).position()}}),this):null!=this.refs.placeholder&&(o=f(g.findDOMNode(this.refs.placeholder)).position()),null==o?n():this.setState({offsetPos:s,animateTo:o,onAnimationEnd:n,animating:!0,dragging:!1})}})),V(this,"onMouseMove",(e=>{var t,r=this.refs.dragging;null!=r&&(t=this.isCardInBank(r)?null:this.findCorrectIndex(r,this.state.current),this.setState({mousePos:e,placeholderIndex:t}))})),V(this,"findCorrectIndex",((e,t)=>{var r="horizontal"===this.props.layout,i=f(g.findDOMNode(this.refs.dragList)),n=i.offset().left,s=i.offset().top,o=f(g.findDOMNode(e)).offset().left-n,a=f(g.findDOMNode(e)).offset().top-s,p=0,h=0,c=0;return r?l.each(t,(function(e,t){var r=g.findDOMNode(this.refs["sortable"+t]),i=f(r).outerWidth(!0);o>h+i/2&&(p+=1),h+=i}),this):l.each(t,(function(e,t){var r=g.findDOMNode(this.refs["sortable"+t]),i=f(r).outerHeight(!0);a>c+i/2&&(p+=1),c+=i}),this),p})),V(this,"isCardInBank",(e=>{if(null==e)return!1;var t="horizontal"===this.props.layout,r=f(g.findDOMNode(e)),i=f(g.findDOMNode(this.refs.bank)),n=r.offset(),s=i.offset(),o=r.outerHeight(!0),a=i.outerHeight(!0),l=i.outerWidth(!0),p=g.findDOMNode(this.refs.dragList);f(p).width();var h=r.outerWidth(!0);return t?n.top+o/2<s.top+a:n.left+h/2<s.left+l})),V(this,"setListValues",(e=>{var t=e.map((e=>({content:e})));this.props.onChange({current:t}),this.setState({current:t})})),V(this,"getUserInput",(()=>({current:l.map(this.props.current,(function(e){return e.content}))}))),V(this,"simpleValidate",(e=>md.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){l.isEqual(this.props.current,e.current)||this.setState({current:e.current})}render(){var e=this.state.dragging&&a.createElement(ud,{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",linterContext:this.props.linterContext}),t=this.state.animating&&a.createElement(ud,{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",linterContext:this.props.linterContext}),r=l.map(this.state.current,(function(e,t){return a.createElement(ud,{key:"sortableCard".concat(t),ref:"sortable"+t,fakeRef:"sortable"+t,floating:!1,content:e.content,width:e.width,linterContext:this.props.linterContext,onMouseDown:this.state.animating?f.noop:this.onClick.bind(null,"current",t)})}),this);if(null!=this.state.placeholderIndex){var i=a.createElement(hd,{ref:"placeholder",width:this.state.dragWidth,height:this.state.dragHeight,key:"placeholder"});r.splice(this.state.placeholderIndex,0,i)}var n=r.length>0;r.push(e,t);var s=a.createElement("div",{className:"perseus-clearfix draggable-box"},!n&&a.createElement(cd,null),a.createElement("div",{ref:"dragList"},r)),o=a.createElement("div",{ref:"bank",className:"bank perseus-clearfix"},l.map(this.props.options,((e,t)=>a.createElement(ud,{ref:"bank"+t,floating:!1,content:e.content,stack:!0,key:t,linterContext:this.props.linterContext,onMouseDown:this.state.animating?f.noop:this.onClick.bind(null,"bank",t),onMouseMove:this.onMouseMove,onMouseUp:this.onRelease})),this));return a.createElement("div",{className:"draggy-boxy-thing orderer height-"+this.props.height+" layout-"+this.props.layout+" above-scratchpad blank-background perseus-clearfix "+Zt.INTERACTIVE,ref:"orderer"},o,s)}}V(md,"defaultProps",{current:[],options:[],correctOptions:[],height:"normal",layout:"horizontal",linterContext:Gt}),l.extend(md,{validate:function(e,t){return 0===e.current.length?{type:"invalid",message:null}:{type:"points",earned:l.isEqual(e.current,l.pluck(t.correctOptions,"content"))?1:0,total:1,message:null}}});var gd={name:"orderer",displayName:"Orderer",widget:md,isLintable:!0};class fd extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"getUserInput",(()=>Do.getUserInput.call(this))),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"simpleValidate",(e=>fd.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){return a.createElement(Ds,{content:this.props.content,inline:!0,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext})}}V(fd,"propTypes",U(U({},mo),{},{content:h.string,linterContext:Ut})),V(fd,"defaultProps",{content:"",linterContext:Gt});var vd={name:"passage-ref-target",displayName:"PassageRefTarget",defaultAlignment:"inline",widget:fd,hidden:!0,transform:e=>l.pick(e,"content"),version:{major:0,minor:0},isLintable:!0};function bd(e,t,r,i){var n;return n="start"===t&&"start"===i?Range.START_TO_START:"start"===t&&"end"===i?Range.END_TO_START:"end"===t&&"start"===i?Range.START_TO_END:Range.END_TO_END,e.compareBoundaryPoints(n,r)}function yd(e,t){var r=e.cloneRange();return r.setEnd(t.endContainer,t.endOffset),r}function xd(e,t){return!(bd(e,"end",t,"start")<0||bd(t,"end",e,"start")<0)}function Cd(e,t,r,i,n){for(var s=-1,o=i,a=n,l=0;o<=a;){if(++l>2*t.length)throw new Error("Assertion error: Binary search isn't terminating? "+"lower=".concat(o,", upper=").concat(a));var p=Math.floor((o+a)/2);if("first"===r)bd(t[p],"end",e,"start")<=0?o=p+1:(s=p,a=p-1);else bd(t[p],"start",e,"end")>=0?a=p-1:(s=p,o=p+1)}return s}function wd(e,t){var r,i,n={},s=t.domRange,o=t.firstWordIndex,a=t.lastWordIndex;for(var l of Object.keys(e)){var p=e[l],h=xd(r=p.domRange,i=s)?yd(bd(r,"start",i,"start")<0?r:i,bd(r,"end",i,"end")>0?r:i):null;h?(s=h,o=Math.min(p.firstWordIndex,o),a=Math.max(p.lastWordIndex,a)):n[l]=p}var c={firstWordIndex:o,lastWordIndex:a,domRange:s},d=function(e){var t="".concat((new Date).getTime());if(!e.includes(t))return t;var r,i=0;do{r="".concat(t,"-").concat(i),i++}while(e.includes(r));return r}(Object.keys(n));return n[d]=c,n}function kd(e,t,r){for(var i of Object.keys(e)){var n=e[i].domRange;if(bd(s=n,"start",o=r,"start")<=0&&bd(s,"end",o,"end")>=0)return null}var s,o,a=function(e,t){var r=Cd(e,t,"first",0,t.length-1);if(r<0)return null;var i=Cd(e,t,"last",r,t.length-1);return i<0?null:[r,i]}(r,t);if(!a)return null;var[l,p]=a;return{firstWordIndex:l,lastWordIndex:p,domRange:yd(t[l],t[p])}}function Ed(e,t){var{firstWordIndex:r,lastWordIndex:i}=e.range,n=t[r];if(!n)throw new he("first word index ".concat(n," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),le.InvalidInput,{metadata:{firstWord:n,wordRanges:JSON.stringify(t)}});var s=t[i];if(!s)throw new he("last word index ".concat(s," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),le.InvalidInput,{metadata:{lastWord:s,wordRanges:JSON.stringify(t)}});return{firstWordIndex:r,lastWordIndex:i,domRange:yd(n,s)}}function Sd(e){var{firstWordIndex:t,lastWordIndex:r}=e;return{range:{type:"word-indexes",firstWordIndex:t,lastWordIndex:r}}}function _d(e,t){return{left:e.left-t.left,top:e.top-t.top}}function Md(e,t){var{left:r,top:i,width:n,height:s}=e;return U(U({},_d({left:r,top:i},t)),{},{width:n,height:s})}function Td(e){var t=[];return Id(e.commonAncestorContainer,e,t),t}function Id(e,t,r){var i,n,s=new Range;if(s.selectNodeContents(e),e.nodeType===Node.TEXT_NODE){var o=xd(i=t,n=s)?yd(bd(i,"start",n,"start")>0?i:n,bd(i,"end",n,"end")<0?i:n):null;o&&function(e,t,r){var i=e.parentElement,n=window.getComputedStyle(i),s=null;if("string"==typeof n.lineHeight&&n.lineHeight.endsWith("px")){var o=parseFloat(n.lineHeight);isNaN(o)||(s=o)}var a=Array.from(t.getClientRects());for(var l of a){var p={left:l.left,top:l.top,height:l.height,width:l.width};if(null!==s){var h=s-p.height;p.top-=h,p.height=s}r.push(p)}}(e,o,r)}else if(e.nodeType===Node.ELEMENT_NODE){if(!xd(t,s))return;for(var a of Array.from(e.childNodes))Id(a,t,r)}}class Pd extends a.PureComponent{constructor(){super(...arguments),V(this,"state",{cachedHighlightRects:this._computeRects(this.props),tooltipIsHovered:!1})}UNSAFE_componentWillReceiveProps(e){this.props.highlight===e.highlight&&this.props.offsetParent===e.offsetParent||this.setState({cachedHighlightRects:this._computeRects(e)})}_computeRects(e){var{highlight:t,offsetParent:r}=e,i=Td(t.domRange),{left:n,top:s}=r.getBoundingClientRect();return i.map((e=>Md(e,{left:n,top:s})))}_rectIsHovered(e,t){var r=_d(t,{left:e.left,top:e.top});return 0<=r.left&&r.left<e.width&&0<=r.top&&r.top<e.height}isHovered(e){if(!e)return!1;var{offsetParent:t}=this.props,{cachedHighlightRects:r}=this.state,{left:i,top:n}=t.getBoundingClientRect(),s=_d(e,{left:i,top:n});return r.some((e=>this._rectIsHovered(e,s)))}render(){var e=this.state.cachedHighlightRects;return a.createElement("div",null,e.map(((e,t)=>a.createElement("div",{key:t,className:u(Ad.highlightRect),style:{position:"absolute",width:e.width,height:e.height,top:e.top,left:e.left,zIndex:this.props.zIndexes.belowContent}}))))}}var Ad=d.create({highlightRect:{background:"#fffabe"}});class Nd extends a.PureComponent{constructor(){super(...arguments),V(this,"_tooltip",void 0)}componentDidUpdate(e){var t;this.props.focusNode===e.focusNode&&this.props.focusOffset===e.focusOffset&&this.props.offsetParent===e.offsetParent||(null===(t=this._tooltip)||void 0===t||t.remeasure())}_getFocusRect(){var{focusNode:e,focusOffset:t,offsetParent:r}=this.props,i=document.createRange();i.setStart(e,t),i.setEnd(e,t);var n=i.getClientRects()[0];if(!n)return pe.log('[Highlighting] Known bug: Could not determine the focus position, so did not show an "Add Highlight" tooltip. https://app.asana.com/0/329800276300868/413878480039713 (see also /r/asana-links)'),null;var{left:s,top:o}=r.getBoundingClientRect();return Md({left:n.left,top:n.top,width:n.width,height:n.height},{left:s,top:o})}render(){var e=this._getFocusRect();if(!e)return null;var t=a.createElement("div",{className:u(Rd.tooltipLabel)},this.props.label);return a.createElement(Da,{content:t,color:ua.kaBlue,inverted:!0,onClick:this.props.onClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,toggleOnHover:!1,showOnMount:!0,ref:e=>this._tooltip=e},a.createElement("div",{style:{position:"absolute",left:e.left,top:e.top,height:e.height}}))}}var Rd=d.create({tooltipLabel:{userSelect:"none"}});class Fd extends a.PureComponent{constructor(){super(...arguments),V(this,"state",{hoveredHighlightKey:null,hoveringTooltipFor:null}),V(this,"_highlightRenderers",{}),V(this,"_handleMouseMove",(e=>{var t={left:e.clientX,top:e.clientY},r=this._getHoveredHighlightKey(t);this.setState({hoveredHighlightKey:r})}))}componentDidMount(){this._updateEditListeners(!1,this.props.editable)}UNSAFE_componentWillReceiveProps(e){this._updateEditListeners(this.props.editable,e.editable),null==this.state.hoveredHighlightKey||this.state.hoveredHighlightKey in e.highlights||this.setState({hoveredHighlightKey:null}),null==this.state.hoveringTooltipFor||this.state.hoveringTooltipFor in e.highlights||this.setState({hoveringTooltipFor:null})}componentWillUnmount(){this._updateEditListeners(this.props.editable,!1)}_updateEditListeners(e,t){!e&&t?window.addEventListener("mousemove",this._handleMouseMove):e&&!t&&(window.removeEventListener("mousemove",this._handleMouseMove),this.setState({hoveredHighlightKey:null,hoveringTooltipFor:null}))}_getHoveredHighlightKey(e){var{hoveringTooltipFor:t}=this.state;return"string"==typeof t?t:Object.keys(this.props.highlights).find((t=>{var r=this._highlightRenderers[t];return r&&r.isHovered(e)}))}_renderTooltip(){var{hoveredHighlightKey:e}=this.state;if(null==e)return null;var t=this.props.highlights[e];return a.createElement(Nd,{label:s._("Remove highlight"),focusNode:t.domRange.endContainer,focusOffset:t.domRange.endOffset,offsetParent:this.props.offsetParent,onClick:()=>this.props.onRemoveHighlight(e),onMouseEnter:()=>this.setState({hoveringTooltipFor:e}),onMouseLeave:()=>this.setState({hoveringTooltipFor:null})})}render(){return a.createElement("div",null,Object.keys(this.props.highlights).map((e=>a.createElement(Pd,{ref:t=>{t?this._highlightRenderers[e]=t:delete this._highlightRenderers[e]},key:e,highlight:this.props.highlights[e],highlightKey:e,offsetParent:this.props.offsetParent,zIndexes:this.props.zIndexes}))),this.props.editable&&this._renderTooltip())}}class Dd extends a.PureComponent{constructor(){super(...arguments),V(this,"state",{mouseState:"up",trackedSelection:null}),V(this,"_handleSelectionChange",(()=>{this._updateTrackedSelection(this.props.buildHighlight),"down"===this.state.mouseState&&this.setState({mouseState:"down-and-selecting"})})),V(this,"_handleMouseDown",(()=>{this.setState({mouseState:"down"})})),V(this,"_handleMouseUp",(()=>{this.setState({mouseState:"up"})}))}componentDidMount(){this._updateListeners(!1,this.props.enabled)}UNSAFE_componentWillReceiveProps(e){this.props.buildHighlight!==e.buildHighlight&&this._updateTrackedSelection(e.buildHighlight),this._updateListeners(this.props.enabled,e.enabled)}componentWillUnmount(){this._updateListeners(this.props.enabled,!1)}_updateListeners(e,t){!e&&t?(window.addEventListener("mousedown",this._handleMouseDown),window.addEventListener("mouseup",this._handleMouseUp),document.addEventListener("selectionchange",this._handleSelectionChange)):e&&!t&&(window.removeEventListener("mousedown",this._handleMouseDown),window.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("selectionchange",this._handleSelectionChange),this.setState({mouseState:"up",trackedSelection:null}))}_computeFocusAndRange(){var e=document.getSelection();if(!e||0===e.rangeCount)return null;var t=e.getRangeAt(0);return t.collapsed?null:{focusNode:e.focusNode,focusOffset:e.focusOffset,range:t}}_computeTrackedSelection(e){var t=this._computeFocusAndRange();if(!t)return null;var{focusNode:r,focusOffset:i,range:n}=t,s=e(n);return s?{focusNode:r,focusOffset:i,proposedHighlight:s}:null}_updateTrackedSelection(e){var t=this._computeTrackedSelection(e);this.setState({trackedSelection:t})}render(){var{mouseState:e,trackedSelection:t}=this.state,r="down-and-selecting"===e;return this.props.children?a.createElement("div",null,this.props.children(t,r)):null}}class Od extends a.PureComponent{_handleAddHighlight(e){this.props.onAddHighlight(e);var t=document.getSelection();t&&t.collapseToEnd()}_selectionIsValid(e){if(!e)return!1;var{contentNode:t}=this.props,r=new Range;r.selectNodeContents(t);var i=new Range;return i.setStart(e.focusNode,e.focusOffset),i.collapse(!0),xd(r,i)}render(){return a.createElement(Dd,{buildHighlight:this.props.buildHighlight,enabled:this.props.editable},((e,t)=>a.createElement("div",null,a.createElement(Fd,{editable:this.props.editable&&!this._selectionIsValid(e),highlights:this.props.highlights,offsetParent:this.props.offsetParent,onRemoveHighlight:this.props.onRemoveHighlight,zIndexes:this.props.zIndexes}),this._selectionIsValid(e)&&!t&&a.createElement(Nd,{label:s._("Add highlight"),onClick:()=>this._handleAddHighlight(e.proposedHighlight),focusNode:e.focusNode,focusOffset:e.focusOffset,offsetParent:this.props.offsetParent}))))}}class Ld extends a.PureComponent{constructor(){super(...arguments),V(this,"_container",void 0)}componentDidMount(){this._sendWordsUpdate()}componentDidUpdate(){this._sendWordsUpdate()}_sendWordsUpdate(){this.props.onWordsUpdate(this._getWordRanges())}_getWordRanges(){var e=this._container;if(!e)throw new he("invariant violation: `this._container` is not defined, but this method is only called after mount/update",le.NotAllowed);for(var t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,(()=>NodeFilter.FILTER_ACCEPT),!1),r=[],i=null;t.nextNode();){var n=t.currentNode;if(n.nodeType===Node.ELEMENT_NODE)"inline"!==getComputedStyle(n).display&&(i=null);else if(n.nodeType===Node.TEXT_NODE){for(var s=n.nodeValue,o=/\S+/g,a=void 0,l=null;null!==(a=o.exec(s));){var p=a.index,h=a.index+a[0].length,c=void 0;0===p&&i?(c=i).setEnd(n,h):((c=n.ownerDocument.createRange()).setStart(n,p),c.setEnd(n,h),r.push(c)),h===s.length&&(l=c)}i=l}}return r}render(){return a.createElement("div",{ref:e=>this._container=e},this.props.children)}}class Bd extends a.PureComponent{constructor(){super(...arguments),V(this,"_container",void 0),V(this,"_content",void 0),V(this,"state",{wordRanges:[]}),V(this,"_handleAddHighlight",(e=>{var t=wd(this._getDOMHighlights(),e),r={};for(var i of Object.keys(t))r[i]=Sd(t[i]);this.props.onSerializedHighlightsUpdate(r)})),V(this,"_handleRemoveHighlight",(e=>{var{serializedHighlights:t}=this.props,r=U({},t);delete r[e],this.props.onSerializedHighlightsUpdate(r)})),V(this,"_handleWordsUpdate",(e=>{this.setState({wordRanges:e})}))}_buildHighlight(e){return kd(this._getDOMHighlights(),this.state.wordRanges,e)}_getDOMHighlights(){var{serializedHighlights:e}=this.props,{wordRanges:t}=this.state,r={};for(var i of Object.keys(e))r[i]=Ed(e[i],t);return r}render(){var e=this._getDOMHighlights();return a.createElement("div",{className:u(zd.container),ref:e=>this._container=e},a.createElement("div",null,this.props.enabled&&this._container&&this._content&&a.createElement(Od,{buildHighlight:e=>this._buildHighlight(e),contentNode:this._content,editable:this.props.editable,highlights:e,offsetParent:this._container,zIndexes:{belowContent:0},onAddHighlight:this._handleAddHighlight,onRemoveHighlight:this._handleRemoveHighlight})),a.createElement("div",{className:u(zd.content),ref:e=>this._content=e},a.createElement(Ld,{onWordsUpdate:this._handleWordsUpdate},this.props.children)))}}var zd=d.create({container:{position:"relative",zIndex:0},content:{position:"relative",zIndex:1}}),qd={display:"inline-block",width:0,visibility:"hidden"},Hd={display:"inline",whiteSpace:"nowrap"},Wd={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",paddingLeft:10,paddingRight:10,userSelect:"none",WebkitUserSelect:"none"},Ud={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"};class Gd extends a.Component{constructor(){super(...arguments),V(this,"getRefContent",(()=>this.props.refContent))}render(){return a.createElement("span",{style:qd},s.doNotTranslate("_"))}}V(Gd,"propTypes",{refContent:h.node.isRequired});class Vd extends a.Component{render(){return a.createElement("span",{style:qd},s.doNotTranslate("_"))}}var jd={newline:c.defaultRules.newline,paragraph:c.defaultRules.paragraph,escape:c.defaultRules.escape,passageFootnote:{order:c.defaultRules.escape.order+.1,match:c.inlineRegex(/^\^/),parse:(e,t,r)=>{var i=r.lastFootnote.id+1,n={id:i,text:1===i?"*":""+i};return"*"===r.lastFootnote.text&&(r.lastFootnote.text=""+r.lastFootnote.id),r.lastFootnote=n,n},react:(e,t,r)=>a.createElement("sup",{key:r.key},e.text)},refStart:{order:c.defaultRules.escape.order+.2,match:function(e,t){var r=/^\{\{/.exec(e);if(r){for(var i=2,n=0;i<e.length;){var s=e.slice(i,i+2);if("{{"===s)n++,i++;else if("}}"===s){if(!(n>0))break;n--,i++}i++}var o=e.slice(2,i);return[r[0],o]}return null},parse:(e,t,r)=>{if(!r.useRefs)return{ref:null,refContent:null};var i=r.lastRef+1;return r.lastRef=i,r.currentRef.push(i),{ref:i,refContent:t("(“"+e[1]+"”)\n\n",l.defaults({useRefs:!1},Yd))}},react:(e,t,r)=>{if(null==e.ref)return null;var i=t(e.refContent,{});return a.createElement(Gd,{ref:"start-ref-"+e.ref,key:"start-ref-"+e.ref,refContent:i})}},refEnd:{order:c.defaultRules.escape.order+.3,match:c.inlineRegex(/^\}\}/),parse:(e,t,r)=>r.useRefs?{ref:r.currentRef.pop()||null}:{ref:null},react:(e,t,r)=>null!=e.ref?a.createElement(Vd,{ref:"end-ref-"+e.ref,key:"end-ref-"+e.ref}):null},squareLabel:{order:c.defaultRules.escape.order+.4,match:c.inlineRegex(/^\[\[(\w+)\]\]( *)/),parse:(e,t,r)=>(r.firstQuestionRef||(r.firstQuestionRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,r)=>[a.createElement("span",{key:"visual-square",className:"perseus-passage-square-label",style:Hd,"aria-hidden":"true"},a.createElement("span",{style:Wd},e.content)),a.createElement("span",{key:"alt-text",className:"perseus-sr-only"},s.$_("[Marker for question %(number)s]",{number:e.content})),e.space?" ":null]},circleLabel:{order:c.defaultRules.escape.order+.5,match:c.inlineRegex(/^\(\((\w+)\)\)( *)/),parse:(e,t,r)=>({content:e[1],space:e[2].length>0}),react:(e,t,r)=>[a.createElement("span",{key:"visual-circle",className:"perseus-passage-circle-label",style:Hd,"aria-hidden":!0},a.createElement("span",{style:Ud},e.content)),a.createElement("span",{key:"alt-text",className:"perseus-sr-only"},s.$_("[Circle marker %(number)s]",{number:e.content})),e.space?" ":null]},squareBracketRef:{order:c.defaultRules.escape.order+.6,match:c.inlineRegex(/^\[(\d+)\]( *)/),parse:(e,t,r)=>(r.firstSentenceRef||(r.firstSentenceRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,r)=>[a.createElement("span",{key:"visual-brackets",className:"perseus-passage-bracket-label","aria-hidden":"true"},"[",e.content,"]"),a.createElement("span",{key:"alt-text",className:"perseus-sr-only"},s.$_("[Sentence %(number)s]",{number:e.content})),e.space?" ":null]},highlight:{order:c.defaultRules.escape.order+.7,match:c.inlineRegex(/^{highlighting.start}(.+?){highlighting.end}/),parse:(e,t,r)=>({content:e[1]}),react:(e,t,r)=>[a.createElement("span",{key:0,className:"perseus-highlight"},e.content)]},reviewHighlight:{order:c.defaultRules.escape.order+.7,match:c.inlineRegex(/^{review-highlighting.start}(.+?){review-highlighting.end}/),parse:(e,t,r)=>({content:e[1]}),react:(e,t,r)=>[a.createElement("span",{key:0,className:"perseus-review-highlight"},e.content)]},strong:c.defaultRules.strong,u:c.defaultRules.u,em:c.defaultRules.em,del:c.defaultRules.del,text:U(U({},c.defaultRules.text),{},{react:(e,t,r)=>a.createElement("span",{key:r.key},e.content)})},Yd={currentRef:[],useRefs:!0,lastRef:0,lastFootnote:{id:0,text:""}},Xd=c.parserFor(jd),$d={parse:(e,t)=>(t=t||{},Xd(e+"\n\n",l.extend(t,Yd))),output:c.reactFor(c.ruleOutput(jd,"react")),START_REF_PREFIX:"start-ref-",END_REF_PREFIX:"end-ref-",_rulesForTesting:jd};class Kd extends a.Component{constructor(){super(...arguments),V(this,"_cachedLineHeight",void 0),V(this,"$body",void 0),V(this,"$end",void 0)}measureLineHeight(){return"number"!=typeof this._cachedLineHeight&&this.forceMeasureLineHeight(),this._cachedLineHeight}forceMeasureLineHeight(){var e;this.$body.text(" €"),this._cachedLineHeight=(e=this.$body,this.$end.offset().top-e.offset().top),this.$body.text("")}render(){return a.createElement("div",{className:u(Zd.measurer)},a.createElement("div",null,a.createElement("div",{ref:e=>this.$body=f(e),className:"paragraph"}),a.createElement("div",{ref:e=>this.$end=f(e)})))}}var Zd=d.create({measurer:{position:"absolute",width:"100%",top:0,left:0}});class Jd extends a.Component{constructor(){super(...arguments),V(this,"_onResize",void 0),V(this,"_lineHeightMeasurer",void 0),V(this,"_stylesAppiedTimer",void 0),V(this,"state",{nLines:null,startLineNumbersAfter:0,stylesAreApplied:!1}),V(this,"_handleSerializedHighlightsUpdate",(e=>{this.props.onChange({highlights:e})}))}componentDidMount(){this._updateState(),this._onResize=l.throttle((()=>{this.shouldRenderJipt()||(this._lineHeightMeasurer.forceMeasureLineHeight(),this._updateState())}),500),window.addEventListener("resize",this._onResize),this._stylesAppiedTimer=window.setTimeout((()=>{this.setState({stylesAreApplied:!0})}),0)}shouldComponentUpdate(e,t){return!l.isEqual(this.props,e)||!l.isEqual(this.state,t)}componentDidUpdate(){this._updateState()}componentWillUnmount(){window.removeEventListener("resize",this._onResize),clearTimeout(this._stylesAppiedTimer)}_updateState(){this.shouldRenderJipt()||this.setState({nLines:this._measureLines(),startLineNumbersAfter:this._getInitialLineNumber()})}_measureLines(){var e=f(g.findDOMNode(this.refs.content)).height(),t=this._getLineHeight();return Math.round(e/t)}_getInitialLineNumber(){var e=!0;return this.props.findWidgets(((t,r)=>"passage"===r.type&&(t===this.props.widgetId&&(e=!1),e))).map((e=>e.getLineCount())).reduce(((e,t)=>e+t),0)}_getLineHeight(){return this._lineHeightMeasurer.measureLineHeight()}getLineCount(){return null!=this.state.nLines?this.state.nLines:this._measureLines()}_getStartRefLineNumber(e){var t=$d.START_REF_PREFIX+e,r=this.refs[t];if(!r)return null;var i=f(g.findDOMNode(r)),n=i.next();0===n.length&&(n=i);var s=n.offset().top;return this.state.startLineNumbersAfter+1+this._convertPosToLineNumber(s)}_getEndRefLineNumber(e){var t=$d.END_REF_PREFIX+e,r=this.refs[t];if(!r)return null;var i=f(g.findDOMNode(r)),n=i.prev();0===n.length&&(n=i);var s=n.height(),o=n.offset().top,a=this._convertPosToLineNumber(o+s);return 0===s&&(a+=1),this.state.startLineNumbersAfter+a}_convertPosToLineNumber(e){var t=e-f(g.findDOMNode(this.refs.content)).offset().top,r=this._getLineHeight();return Math.round(t/r)}_getRefContent(e){var t=$d.START_REF_PREFIX+e,r=this.refs[t];return r?r.getRefContent():null}getReference(e){var t=this._getStartRefLineNumber(e),r=this._getEndRefLineNumber(e);return null==t||null==r?null:{startLine:t,endLine:r,content:this._getRefContent(e)}}getUserInput(){return null}simpleValidate(e){return Jd.validate(this.getUserInput(),e)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}_renderInstructions(e){var t=e.firstQuestionRef,r=e.firstSentenceRef,i="";t&&(i+=s._("The symbol %(questionSymbol)s indicates that question %(questionNumber)s references this portion of the passage.",{questionSymbol:"[["+t+"]]",questionNumber:t})),r&&(i+=s._(" The symbol %(sentenceSymbol)s indicates that the following sentence is referenced in a question.",{sentenceSymbol:"["+r+"]"}));var n=$d.parse(i);return a.createElement("div",{className:"perseus-widget-passage-instructions"},$d.output(n))}shouldRenderJipt(){var{JIPT:e}=oe();return e.useJIPT&&-1!==this.props.passageText.indexOf("crwdns")}_renderContent(e){var t=this.state.stylesAreApplied,r=!this.props.reviewModeRubric;return a.createElement(Bd,{editable:r,enabled:t,onSerializedHighlightsUpdate:this._handleSerializedHighlightsUpdate,serializedHighlights:this.props.highlights},a.createElement("div",{ref:"content"},a.createElement(Kd,{ref:e=>this._lineHeightMeasurer=e}),$d.output(e)))}_hasFootnotes(){var e=this.props.footnotes;return!/^\s*$/.test(e)}_renderFootnotes(){var e=this.props.footnotes,t=$d.parse(e);return $d.output(t)}render(){var e,t=this.state.nLines;this.props.showLineNumbers&&t&&(e=l.range(1,t+1).map((e=>{var t=e+this.state.startLineNumbersAfter;if(4===t){var r=s._("Line ");return a.createElement("span",{key:"line-marker",className:"line-marker"},r)}return a.createElement("span",{key:e},t)})));var r={firstSentenceRef:null,firstQuestionRef:null},i=this.props.passageText.replace(/("{1})([^"]*)("{1})/g,"“$2”"),n=$d.parse(i,r),o=/\S/.test(this.props.passageTitle);return a.createElement("div",null,a.createElement("div",{className:"perseus-widget-passage-container"},this._renderInstructions(r),a.createElement("div",{className:"perseus-widget-passage"},o&&a.createElement("h3",{className:"passage-title"},a.createElement(Ds,{content:this.props.passageTitle,linterContext:this.props.linterContext})),e&&a.createElement("div",{className:"line-numbers","aria-hidden":!0},e),!o&&a.createElement("h3",{className:"perseus-sr-only"},s._("Beginning of reading passage.")),a.createElement("div",{className:"passage-text"},this.shouldRenderJipt()?a.createElement(Ds,{content:this.props.passageText}):this._renderContent(n)),this._hasFootnotes()&&[a.createElement("h4",{key:"footnote-start",className:"perseus-sr-only"},s._("Beginning of reading passage footnotes.")),a.createElement("div",{key:"footnotes",className:"footnotes"},this._renderFootnotes())],a.createElement("div",{className:"perseus-sr-only"},s._("End of reading passage.")))))}}V(Jd,"defaultProps",{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0,highlights:{},linterContext:Gt});var Qd={name:"passage",displayName:"Passage (SAT only)",widget:Jd,transform:e=>l.pick(e,"passageTitle","passageText","footnotes","showLineNumbers"),isLintable:!0},{deepEq:eu}=De;h.oneOf(["bar","line","pic","histogram","dotplot"]),h.arrayOf(h.string),h.arrayOf(h.oneOfType([h.number,h.string])),h.number,h.number,h.number,h.number,h.number,h.string,h.arrayOf(h.number),h.number,h.arrayOf(h.number),h.bool;class tu extends a.Component{constructor(){super(...arguments),V(this,"shouldSetupGraphie",void 0),V(this,"_isMounted",!1),V(this,"horizHairline",void 0),V(this,"hairlineRange",void 0),V(this,"graphie",void 0),V(this,"state",{values:this.props.starting||[1],categoryHeights:{}}),V(this,"DOT_PLOT_POINT_SIZE",(()=>this.props.apiOptions.isMobile?6:4)),V(this,"DOT_PLOT_POINT_PADDING",(()=>8)),V(this,"DOT_TICK_POINT_SIZE",(()=>2)),V(this,"setupGraphie",(e=>{var t=this;t.shouldSetupGraphie=!1;var r=g.findDOMNode(t.refs.graphieDiv);f(r).empty();var i=xr.createGraphie(r);t.graphie=i,t.graphie.pics=[],t.graphie.dotTicks=[];var n="bar"===t.props.type,o="line"===t.props.type,a="pic"===t.props.type,p="histogram"===t.props.type,h="dotplot"===t.props.type,c=a||h,d={},u=d,m=this.props.apiOptions.isMobile;u.graph={lines:[],bars:[],points:[],dividers:[]},u.scaleY=t.props.scaleY,u.dimX=t.props.categories.length;var v=m?[288,336]:t.props.plotDimensions;if(o)u.dimX+=m?-.2:1;else if(p)u.barPad=0,u.barWidth=1;else if(n)u.barPad=m?.08:.15,u.barWidth=1-2*u.barPad,u.dimX+=(m?-2:2)*u.barPad;else if(c){u.picBoxHeight=t.props.picBoxHeight,u.picBoxWidthPx=v[0]/t.props.categories.length;var b=v[0]-u.dimX*u.picBoxWidthPx;u.picPad=b/(2*u.dimX+2);var y=u.picBoxWidthPx+2*u.picPad;u.picPad=u.picPad/y,u.picBoxWidth=u.picBoxWidthPx/y,u.dimX+=2*u.picPad}h&&(u.picBoxHeight=2*this.DOT_PLOT_POINT_SIZE()+this.DOT_PLOT_POINT_PADDING()),u.dimY=Math.ceil(t.props.maxY/u.scaleY)*u.scaleY;var x=25;(n||o)&&m&&(x=0!==t.props.labels[1].length?17:11),h&&(x/=2),m&&c&&0===t.props.labels[1].length&&(x=0);var C=25,w=75;if(m&&(n||c)){var k=Math.max(0,...Object.values(t.state.categoryHeights));if(k){var E=25;c&&(E+=10),w=E+k}}if(u.scale=m?[(v[0]-4*x)/u.dimX,(v[1]-(C+w))/u.dimY]:l.map([u.dimX,u.dimY],(function(e,t){return v[t]/e})),c&&(u.scale[1]=u.picBoxHeight/u.scaleY),x/=u.scale[0],C/=u.scale[1],w/=u.scale[1],i.init({range:[[-3*x,u.dimX+x],[-w,u.dimY+C]],scale:u.scale,isMobile:this.props.apiOptions.isMobile}),i.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!c)for(var S=function(e){i.label([0,e],ce.roundToApprox(e,2),"left",!0),i.style({stroke:m?"#e9ebec":"#000",strokeWidth:1,opacity:m?1:.3},(function(){i.line([0,e],[u.dimX,e])}))},_=m?u.scaleY:0;_<=u.dimY;_+=u.scaleY)S(_);(n||o)&&m&&(t.graphie.dragPrompt=i.label([u.dimX/2,u.dimY/2],s._("Drag handles to make graph"),"center",!1).css("font-weight","bold").css("color",dr.KA_GREEN).css("display","none")),t.setupCategories(d),c&&m&&(t.graphie.dotPrompt=i.label([u.dimX/2,u.dimY/2],s._("Tap to add points"),"center",!1).css("font-weight","bold").css("color",dr.KA_GREEN).css("display","none")),c&&t.drawPicHeights(t.state.values,e.values),i.style({stroke:"#000",strokeWidth:2,opacity:1},(function(){c?h?i.style({stroke:m?dr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([m?0:.5,0],[u.dimX-(m?0:.5),0]))):(i.line([0,0],[u.dimX,0]),0===t.props.labels[1].length&&m||i.style({stroke:m?dr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([0,0],[0,u.dimY])))):(i.style({stroke:m?dr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([m?3*-x:0,0],[u.dimX+(m?x:0),0]))),(n||o)&&m||i.style({stroke:m?dr.GRAY_G:"#000",strokeWidth:m?1:2},(()=>i.line([0,0],[0,u.dimY]))))})),i.label([u.dimX/2,m?-w:-35/u.scale[1]],t.props.labels[0],m?"above":"below",!1).css("font-weight","bold").css("color",m&&dr.GRAY_F),i.label([(m?-35:-60)/u.scale[0],u.dimY/2],t.props.labels[1],"center",!1).css("font-weight","bold").css("color",m&&dr.GRAY_F).addClass("rotate"),this.props.apiOptions.isMobile&&(this.horizHairline=new Ir(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:dr.INTERACTIVE}),this.horizHairline.hide(),this.hairlineRange=[[0,u.dimX],[0,u.dimY]])})),V(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.hairlineRange[0][0],e[1]],[this.hairlineRange[0][1],e[1]]),this.horizHairline.show())})),V(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&this.horizHairline.hide()})),V(this,"labelCategory",((e,t)=>{var r=this.props.apiOptions.isMobile,i=this.graphie,n=!1,s=(t+="").match(/^\$(.*)\$$/);s&&(t=s[1],n=!0);var o=Math.PI/180*45,a="translateX(-50%) translateX(".concat(5,"px) ")+"translateY(-50%) rotate(-".concat(45,"deg)"),l=r&&!s;return new Promise((s=>{i.style({color:r?dr.GRAY_G:"inherit",transform:l?a:"none",transformOrigin:"100%"},(()=>{var a=i.label([e,r?-.5:0],t,"below",n),p=14+(l?Math.round(a.height()*Math.cos(o)+(a.width()+5)*Math.sin(o)):a.height());s({category:t,height:p})}))}))})),V(this,"setupCategories",(e=>{var t=this,r=e,i=t.graphie,n=this.props.apiOptions.isMobile,s=[];"histogram"===t.props.type?(l.times(t.props.categories.length-1,(function(r){t.setupBar({index:r,startHeight:t.state.values[r],config:e,isHistogram:!0})})),l.each(t.props.categories,(function(e,o){var a=.5+o*r.barWidth;s.push(t.labelCategory(a,e));var l=6/r.scale[1];i.style({stroke:"#000",strokeWidth:n?1:2,opacity:1},(function(){i.line([a,-l],[a,0])}))}))):l.each(t.props.categories,(function(o,a){var l,p=t.state.values[a];"bar"===t.props.type?l=t.setupBar({index:a,startHeight:p,config:e,isHistogram:!1}):"line"===t.props.type?l=t.setupLine(a,p,e):"pic"===t.props.type?l=t.setupPic(a,e):"dotplot"===t.props.type&&(l=t.setupDotplot(a,e));var h=0,c=-6/r.scale[1];"dotplot"!==t.props.type||n||(h=-c),"dotplot"===t.props.type?a%t.props.labelInterval!=0&&a!==t.props.categories.length-1||(s.push(t.labelCategory(l,o)),h*=1.5,c*=1.5):s.push(t.labelCategory(l,o)),i.style({stroke:n?dr.GRAY_G:"#000",strokeWidth:n?1:2,opacity:1},(function(){i.line([l,h],[l,c])}))})),Promise.all(s).then((e=>{if(t._isMounted){var r={};e.forEach((e=>{var{category:t,height:i}=e;return r[t]=i})),t.setState({categoryHeights:r})}}))})),V(this,"_clampValue",((e,t,r)=>Math.max(Math.min(e,r),t))),V(this,"_maybeShowDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="inline")})),V(this,"_maybeHideDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="none")})),V(this,"setupBar",(e=>{var t,r=this.props.apiOptions.isMobile,i=e.index,n=e.startHeight,s=e.config,o=e.isHistogram,a=this,p=a.graphie,h=s.barWidth/2;t=o?.5+i*s.barWidth+h:(r?h:.5+s.barPad)+i;var c=function(e,t){var i=p.scalePoint(0);if(s.graph.bars[e].scale(1,Math.max(r?.2:.01,t/s.scaleY),i[0],i[1]),o){var n=s.graph.dividers[e-1],l=s.graph.dividers[e];if(n){var h=Math.min(a.state.values[e-1],t);n.scale(1,Math.max(.01,h/s.scaleY),i[0],i[1])}if(l){var c=Math.min(a.state.values[e+1],t);l.scale(1,Math.max(.01,c/s.scaleY),i[0],i[1])}}};if(p.style({stroke:"none",fill:r?dr.BLUE_C:dr.LIGHT_BLUE,opacity:1},(function(){s.graph.bars[i]=p.path([[t-h,0],[t-h,s.scaleY],[t+h,s.scaleY],[t+h,0],[t-h,0]])})),o&&i>0&&p.style({stroke:"#000",strokeWidth:1,opacity:.3},(function(){s.graph.dividers.push(p.path([[t-h,0],[t-h,s.scaleY]]))})),r){var d=s.scaleY/a.props.snapsPerLine;s.graph.lines[i]=dn.addMaybeMobileMovablePoint(this,{coord:[t,n],constraints:[(e,r,i)=>[t,this._clampValue(Math.round(e[1]/d)*d,0,s.dimY)]],onMoveStart:function(){s.graph.bars[i].attr({fill:dr.INTERACTIVE})},onMove:function(){var e=s.graph.lines[i].coord()[1],t=l.clone(a.state.values);t[i]=e,a.setState({values:t}),a.changeAndTrack({values:t}),a._maybeHideDragPrompt(),c(i,e)},onMoveEnd:function(){s.graph.bars[i].attr({fill:dr.BLUE_C})}}),s.graph.lines[i].state.visibleShape.wrapper.style.zIndex="1",a._maybeShowDragPrompt()}else s.graph.lines[i]=p.addMovableLineSegment({coordA:[t-h,n],coordZ:[t+h,n],snapY:s.scaleY/a.props.snapsPerLine,constraints:{constrainX:!0},normalStyle:{stroke:dr.INTERACTIVE,"stroke-width":this.props.static?0:4}}),s.graph.lines[i].onMove=function(e,t){var r=this.coordA[1];(r<0||r>s.dimY)&&(r=Math.min(Math.max(r,0),s.dimY),this.coordA[1]=this.coordZ[1]=r,this.transform());var n=l.clone(a.state.values);n[i]=r,a.setState({values:n}),a.changeAndTrack({values:n}),c(i,r)};return c(i,n),t})),V(this,"setupLine",((e,t,r)=>{var i=this.props.apiOptions.isMobile,n=this,s=r,o=n.graphie,a=e+(i?.4:1);if(i){var p=r.scaleY/n.props.snapsPerLine;s.graph.points[e]=dn.addMaybeMobileMovablePoint(this,{coord:[a,t],constraints:[(e,t,i)=>[a,this._clampValue(Math.round(e[1]/p)*p,0,r.dimY)]],onMove:function(){var t=s.graph.points[e].coord()[1],r=l.clone(n.state.values);r[e]=t,n.setState({values:r}),n.changeAndTrack({values:r}),n._maybeHideDragPrompt()}}),n._maybeShowDragPrompt(),e>0&&(s.graph.lines[e]=dn.addMovableLine(o,{points:[s.graph.points[e-1],s.graph.points[e]],constraints:dn.MovablePoint.constraints.fixed(),normalStyle:{stroke:dr.BLUE_C,"stroke-width":2},highlightStyle:{stroke:dr.BLUE_C,"stroke-width":2}}))}else s.graph.points[e]=o.addMovablePoint({coord:[a,t],constraints:{constrainX:!0},normalStyle:{fill:dr.INTERACTIVE,stroke:dr.INTERACTIVE},snapY:s.scaleY/n.props.snapsPerLine}),s.graph.points[e].onMove=function(t,r){r=Math.min(Math.max(r,0),s.dimY);var i=l.clone(n.state.values);return i[e]=r,n.setState({values:i}),n.changeAndTrack({values:i}),[t,r]},e>0&&(s.graph.lines[e]=o.addMovableLineSegment({pointA:s.graph.points[e-1],pointZ:s.graph.points[e],constraints:{fixed:!0},normalStyle:{stroke:"#9ab8ed","stroke-width":2}}));return a})),V(this,"setupDotplot",((e,t)=>{var r=this.graphie,i=this.props.apiOptions.isMobile;return this.setupTiledPlot(e,i?.5:1,t,((e,t)=>r.ellipse([e,t],[this.DOT_PLOT_POINT_SIZE()/r.scale[0],this.DOT_PLOT_POINT_SIZE()/r.scale[1]],{fill:dr.INTERACTIVE,stroke:dr.INTERACTIVE})))})),V(this,"setupPic",((e,t)=>{var r=this.graphie;return this.setupTiledPlot(e,0,t,((e,t)=>{var i=r.scalePoint([e,t]),n=this.props.picSize;return r.raphael.image(this.props.picUrl,i[0]-n/2,i[1]-n/2,n,n)}))})),V(this,"setupTiledPlot",((e,t,r,i)=>{var n=this,s=r,o=n.graphie,a=o.pics,p=o.dotTicks,h=e+.5+s.picPad;o.mouselayer.canvas.style.touchAction="none",a[e]=[],p[e]=[];var c=Math.round(s.dimY/s.scaleY)+1;return l(c).times((function(r){var l=((r-=1)+.5)*s.scaleY,c=h-s.picBoxWidth/2,d=l+.5*s.scaleY,u=o.scalePoint([c,d+t]),m=o.mouselayer.rect(u[0],u[1],s.picBoxWidthPx,s.picBoxHeight);f(m[0]).css({fill:"#000",opacity:0,cursor:"pointer"}).on("vmousedown",(function(r){r.preventDefault(),n.whichPicClicked=e,n.setPicHeight(e,d),f(document).on("vmouseup.plotTile",(function(e){f(document).unbind(".plotTile")})),f(document).on("vmousemove.plotTile",(function(e){e.preventDefault();var r=o.getMouseCoord(e)[1],i=Math.floor(r-t),a=(Math.max(-1,Math.floor(i/s.scaleY))+.5)*s.scaleY,l=Math.min(a+.5*s.scaleY,s.dimY);n.setPicHeight(n.whichPicClicked,l)}))})),r<0||(a[e][r]=i(h,l+t),p[e][r]=o.ellipse([h,l+t],[n.DOT_TICK_POINT_SIZE()/o.scale[0],n.DOT_TICK_POINT_SIZE()/o.scale[1]],{fill:"#dee1e3",stroke:"#dee1e3"}))})),h})),V(this,"setPicHeight",((e,t)=>{var r=l.clone(this.state.values);r[e]=t,this.drawPicHeights(r,this.state.values),this.setState({values:r}),this.changeAndTrack({values:r})})),V(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),V(this,"drawPicHeights",((e,t)=>{var r=this,i=r.graphie,n=i.pics,s=this.props.apiOptions.isMobile;if(s){var o=e.every((e=>0===e));i.dotPrompt[0].style.display=o?"inline":"none"}l.each(n,(function(n,o){l.each(n,(function(n,a){var l=(a+1)*r.props.scaleY,p=l<=e[o];if("dotplot"===r.props.type){var h=l<=t[o];p&&!h&&n.animate({"stroke-width":8},75,(()=>n.animate({"stroke-width":2},75)))}f(n[0]).css({display:p?"inline":"none"}),i.dotTicks[o][a][0].style.display=p||!s?"none":"inline"}))}))})),V(this,"getUserInput",(()=>this.state.values)),V(this,"simpleValidate",(e=>tu.validate(this.getUserInput(),e)))}render(){var e={marginBottom:this.props.labels[0]?75:0};return a.createElement("div",{className:"perseus-widget-plotter graphie "+Zt.INTERACTIVE,ref:"graphieDiv",style:e})}componentDidUpdate(e,t){this.shouldSetupGraphie=this.shouldSetupGraphie||!l.isEqual(this.state.categoryHeights,t.categoryHeights),this.shouldSetupGraphie&&this.setupGraphie(t)}componentDidMount(){this._isMounted=!0,this.setupGraphie(this.state)}UNSAFE_componentWillReceiveProps(e){this.shouldSetupGraphie=l.any(["type","labels","categories","scaleY","maxY","snapsPerLine","picUrl","labelInterval","static"],(function(t){return!l.isEqual(this.props[t],e[t])}),this),l.isEqual(this.props.starting,e.starting)||l.isEqual(this.state.values,e.starting)||(this.shouldSetupGraphie=!0,this.setState({values:e.starting}))}componentWillUnmount(){this._isMounted=!1}}V(tu,"propTypes",{onChange:h.func.isRequired,trackInteraction:h.func.isRequired}),V(tu,"defaultProps",{type:"bar",labels:["",""],categories:[""],scaleY:1,maxY:10,snapsPerLine:2,picSize:40,picBoxHeight:48,picUrl:"",plotDimensions:[380,300],labelInterval:1}),l.extend(tu,{validate:function(e,t){return eu(e,t.starting)?{type:"invalid",message:null}:{type:"points",earned:eu(e,t.correct)?1:0,total:1,message:null}}});var ru=l.identity,iu={name:"plotter",displayName:"Plotter",widget:tu,staticTransform:ru};class nu extends a.Component{constructor(){super(...arguments),V(this,"arrowLength",100),V(this,"drawArrow",(()=>{var e=this.refs["arrowCanvas"+this.props.index],t=e.getContext("2d");t.clearRect(0,0,e.width,e.height);var r=new Path2D;t.strokeStyle="rgb(0,0,0)",t.lineWidth=1.2,t.lineCap="round";r.moveTo(5,e.height/2),r.lineTo(e.width-5,e.height/2),r.moveTo(e.width-10,e.height/2-5),r.lineTo(e.width-5,e.height/2),r.moveTo(e.width-10,e.height/2+5),r.lineTo(e.width-5,e.height/2),t.stroke(r)}))}componentDidMount(){this.drawArrow()}componentDidUpdate(){this.drawArrow()}render(){return a.createElement("div",{className:"arrow-container"},a.createElement("div",{className:"above-text"},this.props.data.topText),a.createElement("canvas",{height:"30",id:"arrowCanvas"+this.props.index,ref:"arrowCanvas"+this.props.index,width:this.arrowLength},s._("Reaction arrow pointing to the right.")),a.createElement("div",{className:"below-text"},this.props.data.bottomText))}}V(nu,"propTypes",{data:h.any,index:h.number});class su extends a.Component{constructor(){super(...arguments),V(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),V(this,"getUserInput",(()=>[])),V(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null}))),V(this,"focus",(()=>!0))}render(){return a.createElement("div",{className:"reaction",ref:"reaction"},this.props.smiles.map(((e,t)=>{var r=this.props.widgetId+"-"+t;return a.createElement("div",{key:r,className:"molecule-container"},a.createElement(Kc,{id:r,rotationAngle:this.props.rotationAngle[t],smiles:e}),t===this.props.smiles.length-1?null:a.createElement(nu,{data:this.props.separators[t],index:t}))})))}}V(su,"propTypes",{rotationAngle:h.arrayOf(h.number),separators:h.arrayOf(h.object),smiles:h.arrayOf(h.string),widgetId:h.string}),V(su,"defaultProps",{smiles:[],rotationAngle:[],separators:[]});var ou={name:"reaction-diagram",displayName:"Chemical reaction",hidden:!0,widget:su};class au extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"state",{visible:1}),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"_handleInteraction",(e=>{var t=parseInt(e.split(" ")[1]);if(t===this.state.visible-1){var r=this.refs.renderer.getWidgetInstance("group "+t);r.showRationalesForCurrentlySelectedChoices();var i=r.simpleValidate();"points"===i.type&&i.total===i.earned&&(this.setState({visible:this.state.visible+1}),this.props.trackInteraction({visible:this.state.visible+1}))}}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){var e=a.createElement(X,j({},wi,{style:{color:"green"}})),t=l.chain(this.props.json).first(this.state.visible).map(((e,t)=>"[[".concat(De.snowman," group ").concat(t,"]]"))).join("\n\n").value(),r={};return l.each(this.props.json,((t,i)=>{var n="group ".concat(i);r[n]={type:"group",graded:!0,version:{major:0,minor:0},options:l.extend({},t,{icon:i<this.state.visible-1?e:null})}})),a.createElement("div",{className:"perseus-sequence"},a.createElement(Ds,{ref:"renderer",content:t,widgets:r,onInteractWithWidget:this._handleInteraction,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext}))}}V(au,"propTypes",U(U({},mo),{},{apiOptions:Kt.propTypes,json:h.arrayOf(h.shape({content:h.string,images:h.objectOf(h.any),widgets:h.objectOf(h.any)})),trackInteraction:h.func.isRequired,linterContext:Ut})),V(au,"defaultProps",{json:[{content:"",widgets:{},images:{}}],linterContext:Gt});var lu={name:"sequence",displayName:"Graded Sequence",widget:au,traverseChildWidgets:function(e,t){var r=e.json;l.isArray(r)||(r=[r]);var i=l.map(r,(e=>t(e)));return l.extend({},e,{json:i})},tracking:"all",hidden:!0,isLintable:!0},pu="#aaa",hu="#ccc",cu="#fff",du={borderBottom:"9px solid transparent",borderTop:"9px solid transparent",content:'" "',height:"0",position:"absolute",top:"0",width:"0"},uu=d.create({infoTip:{display:"inline-block",marginLeft:"5px",position:"relative"},infoTipContainer:{position:"absolute",top:"-12px",left:"22px",zIndex:1e3},infoTipTriangle:{height:"10px",left:"0",position:"absolute",top:"8px",width:"0",zIndex:1,":before":U(U({},du),{},{borderRight:"9px solid #bbb",right:"0"}),":after":U(U({},du),{},{borderRight:"9px solid ".concat(cu),right:"-1px"})},verticalShadow:{border:"1px solid ".concat(hu),boxShadow:"0 1px 3px ".concat(hu),borderBottom:"1px solid ".concat(pu)},infoTipContentContainer:{background:cu,padding:"5px 10px",width:"240px"}});class mu extends a.Component{constructor(){super(...arguments),V(this,"state",{hover:!1}),V(this,"handleMouseEnter",(()=>{this.setState({hover:!0})})),V(this,"handleMouseLeave",(()=>{this.setState({hover:!1})}))}render(){return a.createElement("div",{className:u(uu.infoTip)},a.createElement("img",{alt:"",width:10,height:10,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo2N2M3NTAxYS04YmVlLTQ0M2MtYmRiNS04OGM2N2IxN2NhYzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUJCRTk4Qjc4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUJCRTk4QjY4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NGE5ZDI0OTMtODk1NC00OGFkLTlhMTgtZDAwM2MwYWNjNDJlIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjY3Yzc1MDFhLThiZWUtNDQzYy1iZGI1LTg4YzY3YjE3Y2FjMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pqm89uYAAADMSURBVHjaXJA9DoJAEIUH1M4TUHIFsCMGen9OwCGw1YRGW2ntKel0exsojHIBC0ouQAyUviFDstmXfNmZeS+zm7XSNCXRFiRgJf0bXIHixpbhGdxBBJYC1w/xaA424MhNEATkui71fU9KqfEU78UbD9PdbJRlOdae55GmhIP+1NV1TcMwkOM41DSNHvRtMhTHMRVFQW3b6mOLgx99kue5GRp/gIOZuZGvNpTNwjD8oliANU+qqqKu6/TQBdymN57AHjzBT+B6Jx79BRgAvc49kQA4yxgAAAAASUVORK5CYII=",onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave}),a.createElement("div",{className:u(uu.infoTipContainer),style:{display:this.state.hover?"block":"none"}},a.createElement("div",{className:u(uu.infoTipTriangle)}),a.createElement("div",{className:u(uu.verticalShadow,uu.infoTipContentContainer)},this.props.children)))}}class gu extends a.Component{constructor(){super(...arguments),V(this,"state",{didMount:!1})}componentDidMount(){this.setState({didMount:!0})}render(){return this.state.didMount?a.createElement(mu,this.props):a.createElement("div",null)}}var{assert:fu}=pr,{Path:vu,Arc:bu,Circle:yu,Label:xu,Line:Cu,MovablePoint:wu,MovableLine:ku}=In;class Eu extends a.Component{constructor(){super(...arguments),V(this,"_renderThresholdLine",(()=>{var e=[0,this._range()[1][1]],t=l.map(e,(e=>[this.state.threshold,e]));return a.createElement(ku,{onMove:this.handleMouseInteraction},l.map(t,((e,t)=>a.createElement(wu,{key:t,static:!0,coord:e,normalStyle:{stroke:"none",fill:"none"}}))))})),V(this,"_renderCircle",(()=>{var e,t=this.props.data,r=l.reduce(t,((e,t)=>e+t),0),i=l.reduce(t,((e,t,r)=>null!=this.state.threshold&&r<=this.state.threshold?e+t:e),0),n=i/r,s=1e-5,o=[this.props.box[0]-30,30],p=this._range()[0],h=Math.min(Math.max(this.state.threshold,p[0]),p[1]).toFixed(2);return[n>0&&(e={key:"below",center:o,radius:20,startAngle:0,endAngle:n<1?360*n:359.99999,sector:1!==n,unscaled:!0,style:{fill:dr.LIGHT_RED,stroke:dr.RED}},a.createElement(bu,e)),n<1&&(()=>{var e={key:"above",center:o,radius:20,startAngle:n>0?360*n:s,endAngle:360,sector:0!==n,unscaled:!0,style:{fill:dr.LIGHT_BLUE,stroke:dr.BLUE}};return a.createElement(bu,e)})(),(()=>{var e={key:"label",coord:[o[0],o[1]+30],text:i+" of "+r+" results below "+h+"%",direction:"center",tex:!1,unscaled:!0,style:{fontSize:"12px"}};return a.createElement(xu,e)})()]})),V(this,"_renderData",(()=>{var e=this.props.data;this._range();return l.map(e,((e,t)=>{if(e){var r=null!=this.state.threshold&&t<=this.state.threshold,i={fill:r?dr.LIGHT_RED:dr.LIGHT_BLUE,stroke:r?dr.RED:dr.BLUE},n=[[t,0],[t,e],[t+1,e],[t+1,0]];return a.createElement(vu,{key:t,coords:n,style:i})}}))})),V(this,"_setupGraphie",((e,t)=>{var r=t.data,i=t.range,n=t.scale,s=i[0][1]-i[0][0],o=i[1][1]-0,a=Math.ceil(o/20);if(l.each(l.range(0,i[1][1],a),(t=>{r&&e.label([i[0][0],t],ce.roundToApprox(t,2),"left",!0),e.line([i[0][0],t],[i[0][1],t],{stroke:"#000",strokeWidth:1,opacity:.3})})),r){var p=Math.ceil(s/15);l.each(l.range(i[0][0],i[0][1],p),(t=>{e.label([t,0],v.round(t,2),"below",!0);e.line([t,0],[t,-8/n[1]],{stroke:"#000",strokeWidth:1})}))}var h=[i[0][0],0],c=[i[0][0],i[1][1]];e.line(h,c,{stroke:"#000",strokeWidth:2,opacity:1});var d=i[0][0]+s/2,u=r?25:0;e.label([d,-u/n[1]],t.xAxisLabel,"below",!1).css("font-weight","bold");var m=0+o/2,g=r?55:28;e.label([i[0][0]-g/n[0],m],t.yAxisLabel,"center",!1).css("font-weight","bold").css("-webkit-transform","rotate(-90deg)")})),V(this,"handleMouseInteraction",(e=>{this.setState({threshold:e[0]})})),V(this,"_range",(e=>(e=e||this.props).data?this._getRangeForData(e.data):[[0,100],[-1,10]])),V(this,"_getRangeForData",(e=>{var t=l.indexOf(e,l.find(e,(e=>e>0))),r=Math.max(0,t-10),i=l.lastIndexOf(e,l.last(l.filter(e,(e=>e>0))));return[[r,Math.min(101,i+1+10)],[-1,l.max(e)]]})),V(this,"_getInitialThreshold",(e=>{var t=e[0];return t[0]+(t[1]-t[0])/3})),V(this,"state",{threshold:this._getInitialThreshold(this._range())})}UNSAFE_componentWillReceiveProps(e){var t=this._range(),r=this._range(e);De.deepEq(t,r)||this.setState({threshold:this._getInitialThreshold(r)})}render(){var e=this.props.data,t=this._range(),r={xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,box:this.props.box,range:t,data:e,scale:[De.scaleFromExtent(t[0],this.props.box[0]),De.scaleFromExtent(t[1],this.props.box[1])]},i=[t[0][0],0],n=[t[0][1],0];return a.createElement(In,{box:r.box,range:r.range,options:r,setup:this._setupGraphie,onMouseMove:this.handleMouseInteraction,onMouseDown:this.handleMouseInteraction,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable},a.createElement(Cu,{start:i,end:n,style:{stroke:"#000",strokeWidth:1,opacity:1}}),e&&this._renderData(),e&&this._renderCircle(),e&&this._renderThresholdLine())}}V(Eu,"propTypes",{data:h.arrayOf(h.number),xAxisLabel:h.string,yAxisLabel:h.string,box:h.arrayOf(h.number)}),V(Eu,"defaultProps",{data:null,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",box:[400,400]});class Su extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"generateNumber",void 0),V(this,"state",{invalidInput:!1}),V(this,"calculateDisplayProportion",(()=>{var e=this.props.userProportion;return"percentage"===this.props.proportionOrPercentage?Math.round(100*e):e})),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)})),V(this,"checkProportionValidity",(e=>e>=0&&"proportion"===this.props.proportionOrPercentage&&e<=1||"percentage"===this.props.proportionOrPercentage&&e<=100)),V(this,"handleUserProportionChange",((e,t)=>{var r;null!=(r="percentage"===this.props.proportionOrPercentage?e/100:e)&&(r=Math.min(1,Math.max(0,r))),this.props.onChange({userProportion:r},t)})),V(this,"handleSampleSizeChange",((e,t)=>{null!=e&&(e=Math.min(1e3,Math.max(0,Math.floor(e)))),this.props.onChange({sampleSize:e},t)})),V(this,"handleRunSimulation",(()=>{null!=this.props.numTrials&&null!=this.props.userProportion&&null!=this.props.sampleSize?(this.setState({invalidInput:!1}),this.props.onChange({data:this.generateData()}),this.props.trackInteraction()):this.setState({invalidInput:!0})})),V(this,"generateData",(e=>((e,t,r)=>{var i=()=>this.generateNumber()<r,n=l.times(101,(()=>0));return l.times(t,(()=>{var t=l.times(e,i),r=l.filter(t,l.identity).length,s=Math.floor(100*r/e);n[s]++})),n})((e=e||this.props).sampleSize,e.numTrials,e.userProportion))),V(this,"getInputPaths",(()=>[["userProportion"],["sampleSize"]])),V(this,"focus",(()=>{var e=l.head(this.getInputPaths());return this.focusInputPath(e),!0})),V(this,"focusInputPath",(e=>{fu(e.length>0);var t=l.head(e);this.refs[t].focus()})),V(this,"blurInputPath",(e=>{fu(e.length>0);var t=l.head(e);this.refs[t].blur()})),V(this,"getDOMNodeForPath",(e=>{fu(e.length>0);var t=l.head(e);return g.findDOMNode(this.refs[t])})),V(this,"getGrammarTypeForPath",(e=>(fu(e.length>0),"number"))),V(this,"setInputValue",((e,t,r)=>{fu(e.length>0);var i=l.head(e);this["handle"+(i.charAt(0).toUpperCase()+i.slice(1))+"Change"](t,r)})),V(this,"getUserInput",(()=>null)),V(this,"simpleValidate",(e=>Su.validate(this.getUserInput(),e)))}UNSAFE_componentWillMount(){null!=this.props.randomSeed&&(this.generateNumber=De.seededRNG(this.props.randomSeed))}UNSAFE_componentWillReceiveProps(e){e.randomSeed!==this.props.randomSeed&&(this.generateNumber=De.seededRNG(e.randomSeed))}render(){var e={marginLeft:"5px"},t="0px 0px 0px 2px rgba(255, 165, 0, 1)",r=l.extend({},e,{WebkitBoxShadow:t,MozBoxShadow:t,boxShadow:t,transition:"all 0.15s"}),i=l.extend({},e,{transition:"all 0.15s"}),n=this.state.invalidInput?r:i,o=this.props.apiOptions.staticRender?Zs:ac,p=a.createElement("div",null,a.createElement(o,{ref:"userProportion",style:n,value:this.calculateDisplayProportion(),checkValidity:this.checkProportionValidity,disabled:this.props.apiOptions.readOnly,onChange:this.handleUserProportionChange,onFocus:()=>this.props.onFocus(["userProportion"]),onBlur:()=>this.props.onBlur(["userProportion"])}),a.createElement(gu,null,a.createElement("p",null,s._("This controls the proportion or percentage that will be used in your simulation.")))),h=a.createElement("div",null,a.createElement(o,{ref:"sampleSize",style:n,value:this.props.sampleSize,checkValidity:e=>e>=0,disabled:this.props.apiOptions.readOnly,onChange:this.handleSampleSizeChange,onFocus:()=>this.props.onFocus(["sampleSize"]),onBlur:()=>this.props.onBlur(["sampleSize"])}),a.createElement(gu,null,a.createElement("p",null,s._("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.")))),c=a.createElement("div",{style:{textAlign:"right"}},a.createElement("b",null,this.props.numTrials),a.createElement(gu,null,a.createElement("p",null,s._("This is the number of trials used in the simulation. For example, if set to 50, then the survey will be conducted 50 times.")))),d=[{title:this.props.proportionLabel+":",value:p},{title:s._("Sample size:"),value:h},{title:s._("Number of trials:"),value:c}],u=a.createElement("button",{className:"simple-button",style:{margin:"20px 0"},disabled:this.props.apiOptions.readOnly,onClick:this.handleRunSimulation},s._("Run simulation")),m={paddingBottom:this.props.data?40:0},g=a.createElement("div",{style:m},a.createElement(Eu,{data:this.props.data,xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}));return a.createElement("div",null,(e=>{var t=a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,s._("Parameter")),a.createElement("th",null,s._("Value")))),r=a.createElement("tbody",null,l.map(e,((e,t)=>a.createElement("tr",{key:t},a.createElement("td",null,e.title),a.createElement("td",null,e.value)))));return a.createElement("table",null,t,r)})(d),u,g)}}V(Su,"propTypes",U(U({},mo),{},{apiOptions:Kt.propTypes,data:h.arrayOf(h.number),numTrials:h.number,proportionLabel:h.string,proportionOrPercentage:h.string,randomSeed:h.number,sampleSize:h.number,trackInteraction:h.func.isRequired,userProportion:h.number,xAxisLabel:h.string,yAxisLabel:h.string})),V(Su,"defaultProps",{data:null,userProportion:null,sampleSize:null,numTrials:null,randomSeed:0,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion",apiOptions:Kt.defaults}),l.extend(Su,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var _u={name:"simulator",displayName:"Simulator",widget:Su,transform:e=>{var t=l.clone(e);return t.randomSeed=e.problemNum,t},hidden:!0},{shuffle:Mu}=De;class Tu extends a.Component{constructor(){super(...arguments),V(this,"_isMounted",void 0),V(this,"state",{changed:!1}),V(this,"handleChange",(e=>{this._isMounted&&this.setState({changed:!0},(()=>{setTimeout((()=>{this.props.onChange(e),this.props.trackInteraction()}),0)}))})),V(this,"getUserInput",(()=>({options:this.refs.sortable.getOptions()}))),V(this,"moveOptionToIndex",((e,t)=>{this.refs.sortable.moveOptionToIndex(e,t)})),V(this,"simpleValidate",(e=>this.state.changed?Tu.validate(this.getUserInput(),e):{type:"invalid",message:null}))}static validate(e,t){return{type:"points",earned:l.isEqual(e.options,t.correct)?1:0,total:1,message:null}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1}render(){var e=Mu(this.props.correct,this.props.problemNum,!0),{apiOptions:t}=this.props,r=t.isMobile?8:5;return a.createElement("div",{className:"perseus-widget-sorter perseus-clearfix"},a.createElement($h,{options:e,layout:this.props.layout,margin:r,padding:this.props.padding,onChange:this.handleChange,linterContext:this.props.linterContext,ref:"sortable"}))}}V(Tu,"propTypes",{apiOptions:Kt.propTypes,correct:h.array,layout:h.oneOf(["horizontal","vertical"]),onChange:h.func,padding:h.bool,problemNum:h.number,trackInteraction:h.func.isRequired,linterContext:Ut}),V(Tu,"defaultProps",{correct:[],layout:"horizontal",padding:!0,problemNum:0,onChange:function(){},linterContext:Gt});var Iu,Pu={name:"sorter",displayName:"Sorter",widget:Tu,isLintable:!0},{assert:Au}=pr,Nu=function(e,t){return[""+e,""+t]},Ru=function(e){return Au(l.isArray(e)&&2===e.length),+e[0]},Fu=function(e){return Au(l.isArray(e)&&2===e.length),+e[1]},Du=function(e){return"answer"+Ru(e)+","+Fu(e)};class Ou extends a.Component{constructor(){super(...arguments),V(this,"_getRows",(()=>this.props.answers.length)),V(this,"_getColumns",(()=>this.props.answers[0].length)),V(this,"getUserInput",(()=>l.map(this.props.answers,l.clone))),V(this,"onValueChange",((e,t,r)=>{var i=l.map(this.props.answers,l.clone);i[e][t]=r.target?r.target.value:r,this.props.onChange({answers:i}),this.props.trackInteraction()})),V(this,"onHeaderChange",((e,t)=>{var r=this.props.headers.slice();r[e]=t.content,this.props.onChange({headers:r})})),V(this,"simpleValidate",(e=>Ou.validate(this.getUserInput(),e))),V(this,"_handleFocus",(e=>{this.props.onFocus(e)})),V(this,"_handleBlur",(e=>{this.props.onBlur(e)})),V(this,"focus",(()=>(this.focusInputPath(Nu(0,0)),!0))),V(this,"focusInputPath",(e=>{var t=Du(e),r=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?r.focus():g.findDOMNode(r).focus()})),V(this,"blurInputPath",(e=>{var t=Du(e),r=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?r.blur():g.findDOMNode(r).blur()})),V(this,"getDOMNodeForPath",(e=>{var t=Du(e);return g.findDOMNode(this.refs[t])})),V(this,"getInputPaths",(()=>{var e=this._getRows(),t=this._getColumns(),r=[];return l(e).times((e=>{l(t).times((t=>{var i=Nu(e,t);r.push(i)}))})),r})),V(this,"getGrammarTypeForPath",(e=>"number")),V(this,"setInputValue",((e,t,r)=>{var i=Ru(e),n=Fu(e),s=l.map(this.props.answers,l.clone);s[i][n]=t,this.props.onChange({answers:s},r)}))}render(){var e,t,r=this._getRows(),i=this._getColumns(),n=this.props.headers,s={};return this.props.apiOptions.customKeypad?(e=ko,t={width:80},s.keypadElement=this.props.keypadElement):this.props.apiOptions.staticRender?(e=Zs,t={}):(e="input",t={}),a.createElement("table",{className:"perseus-widget-table-of-values non-markdown"},a.createElement("thead",null,a.createElement("tr",null,l.map(n,((e,t)=>this.props.editableHeaders?a.createElement("th",{key:t},a.createElement(this.props.Editor,{ref:"columnHeader"+t,apiOptions:this.props.apiOptions,content:e,widgetEnabled:!1,onChange:l.partial(this.onHeaderChange,t)})):a.createElement("th",{key:t},a.createElement(Ds,{content:e,linterContext:this.props.linterContext})))))),a.createElement("tbody",null,l(r).times((r=>a.createElement("tr",{key:r},l(i).times((i=>a.createElement("td",{key:i},a.createElement(e,j({ref:Du(Nu(r,i)),type:"text",value:this.props.answers[r][i],disabled:this.props.apiOptions.readOnly,onFocus:l.partial(this._handleFocus,Nu(r,i)),onBlur:l.partial(this._handleBlur,Nu(r,i)),onChange:l.partial(this.onValueChange,r,i),style:t},s))))))))))}}V(Ou,"propTypes",{answers:h.arrayOf(h.arrayOf(h.string)),editableHeaders:h.bool,Editor:h.func,headers:h.arrayOf(h.string),keypadElement:i,trackInteraction:h.func.isRequired,linterContext:Ut}),V(Ou,"defaultProps",(Iu=l(4).times((function(){return De.stringArrayOfSize(1)})),{apiOptions:Kt.defaults,headers:[""],editableHeaders:!1,rows:4,columns:1,answers:Iu,linterContext:Gt})),l.extend(Ou,{validate:function(e,t){var r=function(e){return l.filter(e,(function(e){return l.some(e,l.identity)}))},i=r(t.answers),n=r(e);if(l.some(n,(function(e){return l.some(e,(function(e){return""===e}))}))||!n.length)return{type:"invalid",message:null};if(n.length!==i.length)return{type:"points",earned:0,total:1,message:null};var s=me.number.createValidatorFunctional,o=null;return{type:"points",earned:l.every(i,(function(e){var t;for(t=0;t<n.length;t++){var r=n[t],i=l.every(r,(function(t,r){var i=e[r],n=s(i,{simplify:!0})(t);return n.message&&(o=n.message),n.correct}));if(i)return n.splice(t,1),!0}return!1}))?1:0,total:1,message:o}}});var Lu={name:"table",displayName:"Table of values",accessible:!0,widget:Ou,transform:e=>{var t=e.answers.length,r=e.answers[0].length,i=l(t).times((function(){return De.stringArrayOfSize(r)}));return l.extend({},e,{answers:i})},hidden:!0,isLintable:!0},{deepEq:Bu,getGridStep:zu,captureScratchpadTouchStart:qu}=De,{assert:Hu}=pr,Wu={url:null};var Uu={apiOptions:Kt.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:[]}};function Gu(e){return e.constraints.fixed?dr.DYNAMIC:dr.INTERACTIVE}function Vu(e){return String(ce.roundTo(9,e))}function ju(e){var{TeX:t}=oe();return[a.createElement(t,{key:"("},"("),Vu(e[0]),a.createElement(t,{key:","},", {}"),Vu(e[1]),a.createElement(t,{key:")"},")")]}function Yu(e){var{TeX:t}=oe();return[a.createElement(t,{key:"<"},s.doNotTranslate("\\langle")),Vu(e[0]),a.createElement(t,{key:","},", {}"),Vu(e[1]),a.createElement(t,{key:">"},s.doNotTranslate("\\rangle"))]}function Xu(e,t){return e=l.clone(e).sort(b.compare),t=l.clone(t).sort(b.compare),l.all(l.map(e,(function(e,r){var i=t[r];return b.equal(e,i)})))}var $u=e=>e.customKeypad?ko:e.staticRender?Zs:ac,Ku={apply:function(e){return Zu[e.type].isValid(e)?Zu[e.type].apply(e):l.identity},append:function(e,t){var r=Ku._appendAndCollapseLastTwo(e,t);return Ku._collapseFinalNoOps(r)},_collapseFinalNoOps:function(e){return e.length&&Ku.isNoOp(l.last(e))?l.initial(e):e},_appendAndCollapseLastTwo:function(e,t){if(!e.length)return[t];var r=Ku.collapse(l.last(e),t);return l.initial(e).concat(r)},isNoOp:function(e){return Zu[e.type].isNoOp(e)},collapse:function(e,t){return e.type!==t.type?[e,t]:Ku.isEmpty(e)&&Ku.isEmpty(t)?[]:Ku.isValid(e)&&Ku.isValid(t)?Ku._collapseValidMonotypedTransforms(e,t):[e,t]},isValid:function(e){return Zu[e.type].isValid(e)},isEmpty:function(e){return Zu[e.type].isEmpty(e)},_collapseValidMonotypedTransforms:function(e,t){var r=Zu[e.type].collapse(e,t);return r?(l.isArray(r)||(r=[r]),l.each(r,(function(t){t.type=e.type})),r):[e,t]},toTeX:function(e){return Zu[e.type].toTeX(e)},ListItem:w({displayName:"ListItem",render:function(){if("dynamic"===this.props.mode)return a.createElement("div",null,Ku.toTeX(this.props.transform));if("interactive"===this.props.mode){var e=Zu[this.props.transform.type].Input;return a.createElement(e,j({ref:"transform",onChange:this.handleChange,onFocus:this.props.onFocus,onBlur:this.props.onBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions},this.props.transform))}throw new he("Invalid mode: "+this.props.mode,le.InvalidInput)},value:function(){return"interactive"===this.props.mode?l.extend({type:this.props.transform.type},this.refs.transform.value()):this.props.transform},handleChange:l.debounce((function(e){this.props.onChange(this.value(),e)}),300),_getComponentAtPath:function(e){var t=this.refs.transform,r=l.head(e);return t.refs[r]},focus:function(){var e=this.refs.transform,t=l.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 g.findDOMNode(this._getComponentAtPath(e))},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,r){t.length&&(t=parseFloat(t),isNaN(t))||this.refs.transform.setInputValue(e,t,r)},getInputPaths:function(){return"dynamic"===this.props.mode?[]:this.refs.transform.getInputPaths()}})},Zu={translation:{verbName:s._("Translate"),nounName:s._("Translation"),lowerNounName:s._("translation"),apply:function(e){return function(t){return y.add(t,e.vector)}},isValid:function(e){return l.isFinite(e.vector[0])&&l.isFinite(e.vector[1])},isEmpty:function(e){return null===e.vector[0]&&null===e.vector[1]},isNoOp:function(e){return y.equal(e.vector,[0,0])},collapse:function(e,t){return{vector:y.add(e.vector,t.vector)}},toTeX:function(e){return s.$_("Translation by %(vector)s",{vector:Yu(e.vector)})},Input:class extends a.Component{constructor(){super(...arguments),V(this,"state",{vector:this.props.vector||[null,null]}),V(this,"value",(()=>({vector:[this.refs.x.getValue(),this.refs.y.getValue()]}))),V(this,"setInputValue",((e,t,r)=>{var i=l.first(e),n=l.clone(this.state.vector);"x"===i?n[0]=t:"y"===i&&(n[1]=t),this.setState({vector:n},(()=>{this.props.onChange(r)}))})),V(this,"getInputPaths",(()=>[["x"],["y"]]))}componentDidUpdate(e){Bu(this.props,e)||this.setState({vector:this.props.vector})}render(){var e=$u(this.props.apiOptions),{TeX:t}=oe(),r=[a.createElement(t,{key:"<"},s.doNotTranslate("\\langle")),a.createElement(e,{key:"vec_x",ref:"x",placeholder:0,value:this.state.vector[0],useArrowKeys:!0,onChange:e=>{var t=this.state.vector[1];this.setState({vector:[e,t]},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"x"),onBlur:l.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"vec_y",ref:"y",placeholder:0,value:this.state.vector[1],useArrowKeys:!0,onChange:e=>{var t=this.state.vector[0];this.setState({vector:[t,e]},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"y"),onBlur:l.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:">"},s.doNotTranslate("\\rangle"))];return a.createElement("div",null,s.$_("Translation by %(vector)s",{vector:r}))}}},rotation:{verbName:s._("Rotate"),nounName:s._("Rotation"),lowerNounName:s._("rotation"),apply:function(e){return function(t){return b.rotateDeg(t,e.angleDeg,e.center)}},isValid:function(e){return l.isFinite(e.angleDeg)&&l.isFinite(e.center[0])&&l.isFinite(e.center[1])},isEmpty:function(e){return null===e.angleDeg&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return v.equal(e.angleDeg,0)},collapse:function(e,t){return!!b.equal(e.center,t.center)&&{center:e.center,angleDeg:e.angleDeg+t.angleDeg}},toTeX:function(e){return s.$_("Rotation by %(degrees)s about %(point)s",{degrees:(t=e.angleDeg,Vu(t)+"°"),point:ju(e.center)});var t},Input:class extends a.Component{constructor(){super(...arguments),V(this,"state",{center:this.props.center||[null,null],angleDeg:this.props.angleDeg||null}),V(this,"value",(()=>({angleDeg:this.refs.angleDeg.getValue(),center:[this.refs.centerX.getValue(),this.refs.centerY.getValue()]}))),V(this,"setInputValue",((e,t,r)=>{var i=l.first(e),n=l.clone(this.state.angleDeg),s=l.clone(this.state.center);"angleDeg"===i?n=t:"centerX"===i?s[0]=t:"centerY"===i&&(s[1]=t),this.setState({angleDeg:n,center:s},(()=>{this.props.onChange(r)}))})),V(this,"getInputPaths",(()=>[["centerX"],["centerY"],["angleDeg"]]))}componentDidUpdate(e){Bu(this.props,e)||this.setState({center:this.props.center,angleDeg:this.props.angleDeg})}render(){var e=$u(this.props.apiOptions),{TeX:t}=oe(),r=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"X",ref:"centerX",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{var t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"centerX"),onBlur:l.partial(this.props.onBlur,"centerX"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"Y",ref:"centerY",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{var t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"centerY"),onBlur:l.partial(this.props.onBlur,"centerY"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")],i=[a.createElement(e,{key:"deg",ref:"angleDeg",placeholder:0,value:this.state.angleDeg,useArrowKeys:!0,onChange:e=>{this.setState({angleDeg:e},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"angleDeg"),onBlur:l.partial(this.props.onBlur,"angleDeg"),keypadElement:this.props.keypadElement}),"°"],n=s.$_("Rotation about %(point)s by %(degrees)s",{point:r,degrees:i});return a.createElement("div",null,n)}}},reflection:{verbName:s._("Reflect"),nounName:s._("Reflection"),lowerNounName:s._("reflection"),apply:function(e){return function(t){return b.reflectOverLine(t,e.line)}},isValid:function(e){return l.all(l.flatten(e.line),l.isFinite)&&!b.equal(e.line[0],e.line[1])},isEmpty:function(e){return l.all(l.flatten(e.line),l.isNull)},isNoOp:function(e){return!1},collapse:function(e,t){return!!x.equal(e.line,t.line)&&[]},toTeX:function(e){var t=e.line[0],r=e.line[1];return s.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:ju(t),point2:ju(r)})},Input:class extends a.Component{constructor(){super(...arguments),V(this,"state",{line:this.props.line||[[null,null],[null,null]]}),V(this,"changePoint",((e,t,r,i)=>{var n=l.map(this.state.line,l.clone);n[e][t]=r,this.setState({line:n},(()=>{this.props.onChange(i)}))})),V(this,"value",(()=>({line:[[this.refs.x1.getValue(),this.refs.y1.getValue()],[this.refs.x2.getValue(),this.refs.y2.getValue()]]}))),V(this,"setInputValue",((e,t,r)=>{var i,n,s=l.first(e);"x"===s[0]?i=0:"y"===s[0]&&(i=1),"1"===s[1]?n=0:"2"===s[1]&&(n=1),this.changePoint(n,i,t,r)})),V(this,"getInputPaths",(()=>[["x1"],["y1"],["x2"],["y2"]]))}componentDidUpdate(e){Bu(this.props,e)||this.setState({line:this.props.line})}render(){var e=$u(this.props.apiOptions),{TeX:t}=oe(),r=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"x1",ref:"x1",value:this.state.line[0][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,0),onFocus:l.partial(this.props.onFocus,"x1"),onBlur:l.partial(this.props.onBlur,"x1"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"y1",ref:"y1",value:this.state.line[0][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,1),onFocus:l.partial(this.props.onFocus,"y1"),onBlur:l.partial(this.props.onBlur,"y1"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")],i=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"x2",ref:"x2",value:this.state.line[1][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,0),onFocus:l.partial(this.props.onFocus,"x2"),onBlur:l.partial(this.props.onBlur,"x2"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"y2",ref:"y2",value:this.state.line[1][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,1),onFocus:l.partial(this.props.onFocus,"y2"),onBlur:l.partial(this.props.onBlur,"y2"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")];return a.createElement("div",null,s.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:r,point2:i}))}}},dilation:{verbName:s._("Dilate"),nounName:s._("Dilation"),lowerNounName:s._("dilation"),apply:function(e){return function(t){return function(e,t,r){var i=y.subtract(e,t),n=y.scale(i,r);return y.add(t,n)}(t,e.center,e.scale)}},isValid:function(e){return l.isFinite(e.scale)&&l.isFinite(e.center[0])&&l.isFinite(e.center[1])},isEmpty:function(e){return null===e.scale&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return v.equal(e.scale,1)},collapse:function(e,t){return!!b.equal(e.center,t.center)&&{center:e.center,scale:e.scale*t.scale}},toTeX:function(e){var t,r,i=(t=e.scale,1===(r=ce.toFraction(t,v.DEFAULT_TOLERANCE))[1]?Vu(t):Vu(r[0])+"/"+Vu(r[1]));return s.$_("Dilation of scale %(scale)s about %(point)s",{scale:i,point:ju(e.center)})},Input:class extends a.Component{constructor(){super(...arguments),V(this,"state",{center:this.props.center||[null,null],scale:this.props.scale||null}),V(this,"value",(()=>({scale:this.refs.scale.getValue(),center:[this.refs.x.getValue(),this.refs.y.getValue()]}))),V(this,"setInputValue",((e,t,r)=>{var i=l.first(e),n=this.state.scale,s=l.clone(this.state.center);"x"===i?s[0]=t:"y"===i?s[1]=t:"scale"===i&&(n=t),this.setState({scale:n,center:s},(()=>{this.props.onChange(r)}))})),V(this,"getInputPaths",(()=>[["x"],["y"],["scale"]]))}componentDidUpdate(e){Bu(this.props,e)||this.setState({center:this.props.center,scale:this.props.scale})}render(){var e=$u(this.props.apiOptions),{TeX:t}=oe(),r=[a.createElement(t,{key:"("},"("),a.createElement(e,{key:"point_x",ref:"x",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{var t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"x"),onBlur:l.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:","},", {}"),a.createElement(e,{key:"point_y",ref:"y",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{var t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"y"),onBlur:l.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),a.createElement(t,{key:")"},")")],i=a.createElement(e,{ref:"scale",placeholder:1,value:this.state.scale,useArrowKeys:!0,onChange:e=>{this.setState({scale:e},(()=>{this.props.onChange()}))},onFocus:l.partial(this.props.onFocus,"scale"),onBlur:l.partial(this.props.onBlur,"scale"),keypadElement:this.props.keypadElement});return a.createElement("div",null,s.$_("Dilation about %(point)s by %(scale)s",{point:r,scale:i}))}}}},Ju={getPointCountForType:function(e){var t=e.split("-");return"polygon"===t[0]?t[1]||3:"line"===t[0]||"lineSegment"===t[0]?2:"angle"===t[0]?3:"circle"===t[0]?2:"point"===t[0]?1:void 0},addMovableShape:function(e,t){if(t.editable&&t.translatable)throw new he("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously. options: "+JSON.stringify(t),le.InvalidInput);var r=l.map(t.shape.coords,(function(n){var s=!1,o=n,a=e.addMovablePoint({coord:n,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:function(e,n){s||(o=a.coord,s=!0);var p=y.subtract([e,n],a.coord);t.onMove&&(p=t.onMove(p[0],p[1])),t.translatable&&l.each(r,(function(e){e!==a&&e.setCoord(y.add(e.coord,p))}));var h=a.coord,c=y.add(a.coord,p);return a.coord=c,i.update(),a.coord=h,c},onMoveEnd:function(){if(t.onMoveEnd&&s){s=!1;var e=y.subtract(a.coord,o);t.onMoveEnd(e[0],e[1])}i.update()}});return a.bounded=!0,a})),i=Ju.addShape(e,t,r),n=i.remove;return i.remove=function(){n.apply(i),l.invoke(r,"remove")},i},addShape:function(e,t,r){r=r||t.shape.coords;var i=Ju._typesOf(t.shape),n=t.shape.options||Ju.defaultOptions(i),s=Ju._mapTypes(i,r,(function(r,i,s){var o=l.extend({},t,n[s]);return Ju._addType(e,r,i,o)})),o=l.filter(l.pluck(s,"update"),l.identity),a=l.filter(l.pluck(s,"remove"),l.identity),p=function(){return l.map(s,(function(e){return e.getOptions?e.getOptions():{}}))};return{type:i,points:r,update:function(){l.invoke(o,"call")},remove:function(){l.invoke(a,"call")},toJSON:function(){var e=l.map(r,(function(e){return l.isArray(e)?e:e.coord}));return{type:i,coords:e,options:p()}},getOptions:p}},equal:function(e,t){var r=Ju._typesOf(e),i=Ju._typesOf(t);if(r.length!==i.length)return!1;var n=Ju._mapTypes(r,e.coords,Ju._combine),s=Ju._mapTypes(i,t.coords,Ju._combine);return l.all(l.map(n,(function(e,t){var r=s[t];return e.type===r.type&&Ju._forType(e.type).equal(e.coords,r.coords)})))},_typesOf:function(e){var t=e.type;return l.isArray(t)||(t=[t]),l.map(t,(function(e){return"polygon"===e?"polygon-3":e}))},defaultOptions:function(e){return l.map(e,(function(e){var t=Ju._forType(e).defaultOptions;return l.extend({},t)}))},_forType:function(e){var t=e.split("-")[0];return Ju[t]},_mapTypes:function(e,t,r,i){return l.map(e,(function(e,n){var s=Ju.getPointCountForType(e),o=l.first(t,s);return t=l.rest(t,s),r.call(i,e,o,n)}))},_addType:function(e,t,r,i){var n=l.isArray(r[0])?{coordA:r[0],coordZ:r[1]}:{pointA:r[0],pointZ:r[1]};if("polygon"===(t=t.split("-")[0])){var s=e.addMovablePolygon(l.extend({},i,{fixed:!i.editable,snapX:i.snap&&i.snap[0]||0,snapY:i.snap&&i.snap[1]||0,points:r,constrainToGraph:!1}));return{update:s.transform.bind(s),remove:s.remove.bind(s)}}if("line"===t||"lineSegment"===t){var o=e.addMovableLineSegment(l.extend({},i,n,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:"line"===t}));return{update:o.transform.bind(o,!0),remove:o.remove.bind(o)}}if("angle"===t){var a=!!i.editable&&null,p=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:r,normalStyle:i.normalStyle,reflex:i.reflex});return l.isArray(r[0])||i.editable||(r[0].remove(),r[2].remove()),{update:p.update.bind(p,a),remove:p.remove.bind(p),getOptions:function(){return{reflex:p.isReflex()}}}}if("circle"===t){var h={remove:l.identity},c=function(){var t=r[0].coord||r[0],n=r[1].coord||r[1],s=b.distanceToPoint(t,n);h.remove(),h=e.circle(t,s,l.extend({stroke:dr.DYNAMIC,"stroke-width":2},i.normalStyle))};return c(),r[1].remove&&!i.editable&&r[1].remove(),{update:c,remove:function(){h.remove()}}}if("point"===t)return{update:null,remove:null};throw new he("Invalid shape type "+t,le.InvalidInput)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:Xu},line:{equal:x.equal},lineSegment:{equal:Xu},angle:{equal:function(e,t){if(!b.equal(e[1],t[1]))return!1;var r=[e[1],e[0]],i=[e[1],e[2]],n=[t[1],t[0]],s=[t[1],t[2]],o=C.equal(r,n)&&C.equal(i,s),a=C.equal(r,s)&&C.equal(i,n);return o||a},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){var r=b.distanceToPoint(e[0],e[1]),i=b.distanceToPoint(t[0],t[1]);return b.equal(e[0],t[0])&&v.equal(r,i)}},point:{equal:b.equal}},Qu=Ku.ListItem;class em extends a.Component{constructor(){super(...arguments),V(this,"_transformationRefs",(()=>l.times(this.props.transformations.length,(e=>this.refs["transformation"+e])))),V(this,"value",(()=>l.invoke(this._transformationRefs(),"value"))),V(this,"handleChange",((e,t)=>{this.props.onChange(this.value(),t)})),V(this,"focusLast",(()=>{var e=this._transformationRefs();0!==e.length&&l.last(e).focus()}))}render(){if("static"===this.props.mode)return a.createElement("span",null);var e=l.map(this.props.transformations,(function(e,t){return a.createElement(Qu,{ref:"transformation"+t,key:"transformation"+t,transform:e,mode:this.props.mode,onChange:this.handleChange,onFocus:l.partial(this.props.onFocus,""+t),onBlur:l.partial(this.props.onBlur,""+t),keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions})}),this);return a.createElement("div",{className:"perseus-transformation-list"},e)}}class tm extends a.Component{render(){var e=this.props.toggled?"simple-button exercise-orange toggled highlighted-tool-button":"simple-button";return a.createElement("button",{type:"button",className:e,disabled:this.props.disabled,onClick:this.props.onClick,onTouchStart:qu},this.props.children)}}class rm extends a.Component{constructor(){super(...arguments),V(this,"state",{selected:null}),V(this,"changeSelected",(e=>{this.props.removeTool(this.state.selected),e&&e!==this.state.selected?(this.props.addTool(e),this.setState({selected:e})):this.setState({selected:null})}))}render(){var e=l.map(Zu,(function(e,t){if(this.props.enabled[t])return a.createElement(tm,{key:t,disabled:this.props.apiOptions.readOnly,toggled:this.state.selected===t,onClick:this.changeSelected.bind(this,t)},e.verbName)}),this);return a.createElement("div",{className:"transformer-tools-bar"},a.createElement("span",{className:"simple-button-group"},e),a.createElement("button",{className:"transformer-undo-button simple-button",type:"button",disabled:this.props.apiOptions.readOnly,onClick:this.props.onUndoClick,onTouchStart:qu},a.createElement(X,Ti)," "+s._("Undo")),a.createElement("div",{className:"clear"}))}}class im extends a.Component{constructor(){super(...arguments),V(this,"changeSelected",(e=>{e&&this.props.addTool(e)}))}render(){var e=l.map(Zu,(function(e,t){if(this.props.enabled[t])return a.createElement(tm,{key:t,toggled:!1,disabled:this.props.apiOptions.readOnly,onClick:this.changeSelected.bind(this,t)},a.createElement(X,ki)," ",e.nounName)}),this);return a.createElement("div",{className:"transformer-tools-bar"},e,a.createElement("button",{className:"transformer-undo-button simple-button",type:"button",onClick:this.props.onUndoClick,disabled:this.props.apiOptions.readOnly,onTouchStart:qu},a.createElement(X,Ti)," "+s._("Undo")),a.createElement("div",{className:"clear"}))}}class nm extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"tools",void 0),V(this,"currentTool",void 0),V(this,"transformations",void 0),V(this,"shape",void 0),V(this,"dilationCircle",void 0),V(this,"rotatePoint",void 0),V(this,"rotateHandle",void 0),V(this,"shouldSetupGraphie",((e,t)=>!Bu(t.starting,e.starting)||(t.graphMode!==e.graphMode||(t.listMode!==e.listMode||(t.drawSolutionShape!==e.drawSolutionShape||(!(!e.drawSolutionShape||Bu(t.correct.shape,e.correct.shape))||!Bu(this.tools,e.tools))))))),V(this,"graphie",(()=>this.refs.graph.graphie())),V(this,"setupGraphie",(e=>{this.props.drawSolutionShape&&this.props.correct.shape&&this.props.correct.shape.coords&&Ju.addShape(e,{fixed:!0,shape:this.props.correct.shape,normalStyle:{stroke:dr.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:l.clone(this.props.tools.translation),rotation:l.clone(this.props.tools.rotation),reflection:l.clone(this.props.tools.reflection),dilation:l.clone(this.props.tools.dilation)}})),V(this,"setTransformations",(e=>{this.resetCoords(),this.transformations=l.clone(e),l.each(this.transformations,this.applyTransform)})),V(this,"addTransformerShape",((e,t)=>{var r=this,i=this.graphie();this.shape=Ju.addMovableShape(i,{shape:e,editable:!1,showPoints:"static"!==this.props.graphMode,translatable:t,onMove:function(e,t){return e=ce.roundToNearest(i.snap[0],e),t=ce.roundToNearest(i.snap[1],t),r.addTransform({type:"translation",vector:[e,t]}),[e,t]},normalPointStyle:{fill:t?dr.INTERACTIVE:dr.DYNAMIC,stroke:t?dr.INTERACTIVE:dr.DYNAMIC},highlightPointStyle:{fill:dr.INTERACTING,stroke:dr.INTERACTING}})})),V(this,"addTool",(e=>{var t=this;if("interactive"===this.props.graphMode)if("translation"===e)this.currentTool=this.addTranslationTool();else if("rotation"===e)this.currentTool=this.addRotationTool();else if("reflection"===e)this.currentTool=this.addReflectionTool();else{if("dilation"!==e)throw new he("Invalid tool id: "+e,le.InvalidInput);this.currentTool=this.addDilationTool()}else{var r;if("translation"===e)r={type:"translation",vector:[null,null]};else if("rotation"===e)r={type:"rotation",center:[null,null],angleDeg:null};else if("reflection"===e)r={type:"reflection",line:[[null,null],[null,null]]};else{if("dilation"!==e)throw new he("Invalid tool id: "+e,le.InvalidInput);r={type:"dilation",center:[null,null],scale:null}}this.doTransform(r,(function(){t.refs.transformationList.focusLast()}))}})),V(this,"removeTool",(e=>{this.currentTool&&this.currentTool.remove(),this.currentTool=null})),V(this,"addTranslationTool",(()=>{var e,t,r=this;return null===(e=this.shape)||void 0===e||e.remove(),this.addTransformerShape(null===(t=this.shape)||void 0===t?void 0:t.toJSON(),!0),{remove:function(){var e,t;null===(e=r.shape)||void 0===e||e.remove(),r.addTransformerShape(null===(t=r.shape)||void 0===t?void 0:t.toJSON(),!1)}}})),V(this,"snapCoord",(e=>{var t=this.graphie();return l.map(e,(function(e,r){return ce.roundToNearest(t.snap[r],e)}))})),V(this,"normalizeReflectionCoords",(e=>{var t=this.snapCoord(x.midpoint(e)),r=y.polarDegFromCart(y.subtract(e[0],e[1])),i=y.cartFromPolarDeg(1,ce.roundToNearest(45,r[1]));return l.map([-1,1],(function(e){var r=y.add(t,y.scale(i,e*this.scaleToCurrentRange(2)));return this.snapCoord(r)}),this)})),V(this,"addReflectionTool",(()=>{var e=this.props.tools.reflection;if(e.enabled){var t,r=this,i=this.refs.graph.graphie(),n=function(){r.changeTool("reflection",{coords:l.pluck(o,"coord")})},s=this.normalizeReflectionCoords(e.coords),o=l.map(s,(function(e){return i.addMovablePoint({coord:e,visible:!1})}),this),a=Gu(e);i.style({},(function(){t=i.addMovableLineSegment({fixed:e.constraints.fixed,constraints:e.constraints,pointA:o[0],pointZ:o[1],snapX:i.snap[0],snapY:i.snap[1],extendLine:!0,normalStyle:{stroke:a,"stroke-width":2,"stroke-dasharray":"- "},highlightStyle:{stroke:dr.INTERACTING,"stroke-width":2,"stroke-dasharray":"- "},movePointsWithLine:!0,onMoveEnd:n})}));var p=i.addReflectButton({fixed:e.constraints.fixed,line:t,size:this.scaleToCurrentRange(1),onClick:function(){r.doTransform({type:"reflection",line:l.pluck(o,"coord")}),h&&(h.setCoord(y.add(p.coord,y.subtract(p.coord,h.coord))),h.update())},normalStyle:{stroke:a,"stroke-width":2,fill:a},highlightStyle:{stroke:dr.INTERACTING,"stroke-width":3,fill:dr.INTERACTING},onMoveEnd:n}),h=null;if(!e.constraints.fixed){var c=y.polarDegFromCart(y.subtract(o[1].coord,o[0].coord))[1]+90;h=i.addRotateHandle({center:p,radius:this.scaleToCurrentRange(2),angleDeg:c,width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),lengthAngle:17,onMove:function(e){return ce.roundToNearest(45,e)},onMoveEnd:n})}return f(t).on("move",(function(){p.update(),f(p).trigger("move")})),h&&f(h).on("move",(function(){var e=r.snapCoord(h.coord),i=y.subtract(e,p.coord),n=p.isFlipped()?1:0;o[n].setCoord(y.add(p.coord,y.rotateDeg(i,90))),o[1-n].setCoord(y.add(p.coord,y.rotateDeg(i,-90))),t.transform(!0),p.update()})),{remove:function(){p.remove(),h&&h.remove(),t.remove(),o[0].remove(),o[1].remove()}}}})),V(this,"scaleToCurrentRange",(e=>function(e,t){var r=t[0][1]-t[0][0],i=t[1][1]-t[1][0];return e*Math.max(r,i)/20}(e,this.refs.graph.props.range))),V(this,"addRotationTool",(()=>{var e=this.props.tools.rotation;if(e.enabled){var t=this,r=this.refs.graph.graphie(),i=Gu(e);return this.rotatePoint=r.addMovablePoint({constraints:e.constraints,coord:e.coord,snapX:r.snap[0],snapY:r.snap[1],normalStyle:{"stroke-dasharray":"",stroke:i,fill:i},highlightStyle:{"stroke-dasharray":"",stroke:dr.INTERACTING,fill:dr.INTERACTING}}),this.rotateHandle=r.addRotateHandle({center:this.rotatePoint,radius:this.scaleToCurrentRange(1.5),width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),onMove:function(e,r){var i=t.getRotationTransformFromAngle(t.rotatePoint.coord,e-r);return t.doTransform(i),r+i.angleDeg}}),this.rotatePoint.onMoveEnd=(e,r)=>{t.changeTool("rotation",{coord:[e,r]})},{remove:function(){var e,r;null===(e=t.rotateHandle)||void 0===e||e.remove(),null===(r=t.rotatePoint)||void 0===r||r.remove()}}}})),V(this,"addDilationTool",(()=>{var e=this.props.tools.dilation;if(e.enabled){var t=this,r=this.refs.graph.graphie(),i=Gu(e);t.dilationCircle=r.addCircleGraph({centerConstraints:e.constraints,center:e.coord,radius:t.scaleToCurrentRange(2),snapX:r.snap[0],snapY:r.snap[1],minRadius:t.scaleToCurrentRange(1),snapRadius:t.scaleToCurrentRange(.5),onResize:function(e,r){t.doTransform({type:"dilation",center:t.dilationCircle.centerPoint.coord,scale:e/r})},circleNormalStyle:{stroke:i,"stroke-width":2,"stroke-dasharray":"- ","fill-opacity":0},circleHighlightStyle:{stroke:dr.INTERACTING,"stroke-width":2,"stroke-dasharray":"",fill:dr.INTERACTING,"fill-opacity":.05},centerNormalStyle:{stroke:i,fill:i,"stroke-width":2,"stroke-dasharray":""},centerHighlightStyle:{stroke:i,fill:i,"stroke-width":2,"stroke-dasharray":""}});var n=this.dilationCircle.centerPoint.onMoveEnd;return this.dilationCircle.centerPoint.onMoveEnd=function(){if(n){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];n(r)}t.changeTool("dilation",{coord:t.dilationCircle.centerPoint.coord})},{remove:function(){var e;null===(e=t.dilationCircle)||void 0===e||e.remove()}}}})),V(this,"getRotationTransformFromAngle",((e,t)=>((t=(t+360)%360)>180&&(t-=360),{type:"rotation",center:e,angleDeg:15*Math.round(t/15)}))),V(this,"doTransform",((e,t)=>{this.applyTransform(e),this.addTransform(e,t)})),V(this,"applyTransform",(e=>{if("static"!==this.props.graphMode){var t=Ku.apply(e);this.applyCoordTransformation(t)}})),V(this,"applyCoordTransformation",(e=>{var t;l.each(this.shape.points,(function(t){var r=e(t.coord);t.setCoord(r)})),null===(t=this.shape)||void 0===t||t.update()})),V(this,"resetCoords",(()=>{var e,t=this.props.starting.shape.coords;l.each(this.shape.points,(function(e,r){e.setCoord(t[r])})),null===(e=this.shape)||void 0===e||e.update()})),V(this,"handleUndoClick",(()=>{this.refs.toolsBar.changeSelected(null),this.props.transformations.length&&this.props.onChange({transformations:l.initial(this.props.transformations)})})),V(this,"setTransformationProps",((e,t)=>{this.props.onChange({transformations:e},t)})),V(this,"addTransform",((e,t)=>{this.transformations=Ku.append(this.transformations,e),this.props.onChange({transformations:l.clone(this.transformations)},t)})),V(this,"changeTool",((e,t)=>{var r=l.clone(this.props.tools);r[e]=l.extend({},this.props.tools[e],t),this.tools[e]=l.clone(r[e]),this.props.onChange({tools:r}),this.props.trackInteraction()})),V(this,"simpleValidate",(e=>nm.validate(this.getUserInput(),e))),V(this,"getCoords",(()=>{var e=this.props.starting.shape.coords,t=this.props.transformations;return l.reduce(t,(function(e,t){return l.map(e,Ku.apply(t))}),e)})),V(this,"getEditorJSON",(()=>{var e=l.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})),V(this,"getUserInput",(()=>{var e;return{transformations:this.props.transformations,shape:{type:this.shape.type,coords:this.getCoords(),options:null===(e=this.shape)||void 0===e?void 0:e.getOptions()}}})),V(this,"_handleFocus",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];e.props.onFocus(r)})),V(this,"_handleBlur",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];e.props.onBlur(r)})),V(this,"_getTransformationForID",(e=>{var t=["transformationList","transformation"+e],r=this;return l.each(t,(e=>{r=r.refs[e]})),r})),V(this,"getInputPaths",(()=>{if("static"===this.props.listMode)return[];var e=[];return l.each(this.props.transformations,((t,r)=>{var i=this._getTransformationForID(r).getInputPaths(),n=l.map(i,(e=>[""+r].concat(e)));e=e.concat(n)})),e})),V(this,"_passToInner",(function(e,t){if(t&&t.length){for(var r=l.rest(t),i=l.head(t),n=this._getTransformationForID(i),s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return n[e](r,...o)}})),V(this,"focus",(()=>{var e=this.getInputPaths();return e.length>0&&(this.focusInputPath(e[0]),!0)})),V(this,"focusInputPath",(e=>0!==e.length&&(Hu(e.length>=2),this._passToInner("focusInputPath",e)))),V(this,"blurInputPath",(e=>0!==e.length&&(Hu(e.length>=2),this._passToInner("blurInputPath",e)))),V(this,"setInputValue",((e,t,r)=>(Hu(e.length>=2),this._passToInner("setInputValue",e,t,r)))),V(this,"getDOMNodeForPath",(e=>(Hu(e.length>=2),this._passToInner("getDOMNodeForPath",e)))),V(this,"getGrammarTypeForPath",(e=>(Hu(e.length>=2),this._passToInner("getGrammarTypeForPath",e))))}render(){var e,t,r,i,n,o,p,h=l.extend((e=this.props.graph,t=400,r=(e=e||{}).labels||["x","y"],i=e.range||[[-10,10],[-10,10]],n=e.step||[1,1],{box:[t,t],labels:r,range:i,step:n,gridStep:e.gridStep||zu(i,n,t),valid:!0,backgroundImage:Wu,markings:"grid",showProtractor:!1}),this.props.graph),c="interactive"===this.props.graphMode,d=c?rm:im,u=a.createElement("div",{style:{width:h.box[0]}},a.createElement(d,{ref:"toolsBar",enabled:(o=this.props.tools,p="enabled",l.object(l.map(o,(function(e,t){return[t,e[p]]})))),apiOptions:this.props.apiOptions,addTool:this.addTool,removeTool:this.removeTool,onUndoClick:this.handleUndoClick}));return a.createElement("div",{className:"perseus-widget perseus-widget-transformer"},a.createElement(eh,{ref:"graph",box:h.box,range:h.range,labels:h.labels,step:h.step,gridStep:h.gridStep,markings:h.markings,backgroundImage:h.backgroundImage,showProtractor:h.showProtractor,onGraphieUpdated:this.setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!c&&s._("Add transformations below:"),"static"===this.props.graphMode&&[a.createElement("br",{key:"static-br"}),a.createElement("em",{key:"static-nomove"}," ",s._("Note: For this question, the shape will not move.")," ")],c&&u,a.createElement(em,{ref:"transformationList",mode:this.props.listMode,transformations:this.props.transformations,onChange:this.setTransformationProps,onFocus:this._handleFocus,onBlur:this._handleBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions}),!c&&u)}componentDidMount(){this.setupGraphie(this.graphie())}componentDidUpdate(e){this.shouldSetupGraphie(this.props,e)?this.refs.graph.reset():Bu(this.props.transformations,this.transformations)||this.setTransformations(this.props.transformations)}static validate(e,t){var r=function(r){if(t.tools[r].required){var i=l.any(l.map(e.transformations,(function(e){return e.type===r&&!Ku.isEmpty(e)&&!Ku.isNoOp(e)})));if(!i)return{v:{type:"invalid",message:s._("Your transformation must use a %(type)s.",{type:Zu[r].lowerNounName})}}}};for(var i in Zu){var n=r(i);if("object"==typeof n)return n.v}return Ju.equal(e.shape,t.correct.shape)?{type:"points",earned:1,total:1,message:null}:!t.gradeEmpty&&Bu(e.shape.coords,t.starting.shape.coords)?{type:"invalid",message:s._("Use the interactive graph to define a correct transformation.")}:{type:"points",earned:0,total:1,message:null}}}V(nm,"defaultProps",l.defaults({transformations:[]},Uu));var sm,om={name:"transformer",displayName:"Transformer",widget:nm},am={exports:{}};sm=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){var r=function(e){return e===Object(e)},i=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];if(r)for(var i in r)e[i]=r[i]}return e};e.exports={isObject:r,merge:i,clone:function(e){return r(e)?Array.isArray(e)?e.slice():i(e):e}}},function(e,t,r){var i=r(0),n=i.clone,s=i.isObject,o=i.merge,a=r(2),l=r(3),p=r(4),h=function(e){return Array.isArray(e)?a:s(e)?l:"string"==typeof e?p:void 0},c=function e(t){if(t instanceof e)return t;if(!(this instanceof e))return new e(t);var r=h(t);this._wrapped=r.thaw?r.thaw(t):t};c.prototype.freeze=function(){var e=this._wrapped,t=h(e);return t.freeze?t.freeze(e):e},c.prototype.zoom=function(e){return void 0===this._zoomStack&&(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){for(var t=this._wrapped,r=0;r<e.length;r++)t=h(t).get(t,e[r]);return t},c.prototype.mod=function(e,t){var r=this._wrapped,i=n(r),s=h(r);if(0===e.length)this._wrapped=t(this._wrapped);else if(1===e.length)this._wrapped=s.mod(i,e[0],t);else{var o=e[0],a=e.slice(1);i[o]=c(r[o]).mod(a,t).freeze(),this._wrapped=i}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,r=h(t);if(1===e.length)this._wrapped=r.del(t,e[0]);else{var i=e[0],s=e.slice(1),o=n(t);o[i]=c(t[i]).del(s).freeze(),this._wrapped=o}return this},c.prototype.set=function(e,t){return this.mod(e,(function(){return t}))},e.exports=c},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,r){var i=e.splice();return i[t]=r,i},mod:function(e,t,r){var i=e.slice();return i[t]=r(e[t]),i},del:function(e,t){var r=e.slice();return r.splice(t,1),r}}},function(e,t,r){var i=r(0).clone;e.exports={get:function(e,t){return e[t]},set:function(e,t,r){var n=i(e);return n[t]=r,n},mod:function(e,t,r){var n=i(e);return n[t]=r(e[t]),n},del:function(e,t){var r=i(e);return delete r[t],r}}},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,r){var i=e.splice();return i[t]=r,i},mod:function(e,t,r){var i=e.splice();return i[t]=r(e[t]),i},del:function(e,t){var r=e.slice();return r.splice(t),r}}}])};var lm=hr(am.exports=sm());class pm{constructor(e){V(this,"order",void 0),V(this,"mantissa",void 0),V(this,"positive",void 0),V(this,"sigFigs",void 0),V(this,"sigDecs",void 0),this.order=mm(e),this.mantissa=um(e),this.positive=dm(e),this.sigFigs=this.mantissa.length,this.sigDecs=this.order-this.mantissa.length}}function hm(e,t,r,i){var n,s,o,a=""+e,l=mm(a),p=um(a),h=dm(a),c=!1;if(0==e||""==p||"0"==p){p="";for(var d=0;d<t;d++)p+="0";l=t+r,r<0&&-r>=t&&(c=!0)}else{if(s=l-p.length-r,o=t-p.length,(n=Math.min(o,s))<0){var u=gm(p,-n);u.length>p.length+n&&(l++,s>o&&(u=gm(u,1))),p=u}else if(n>0)for(var m=0;m<n;m++)p+="0";""!=p&&"0"!=p||(p="0",h=!0,0!=(l=1+r)&&(c=!0))}var g="";if(h||(g+="-"),i||p.length>20||l>4||l<-2||l-p.length>0&&cm(p)>0||c)g+=p.charAt(0),p.length>1&&(g+="."+p.substring(1,p.length)),l-1!=0&&(g+=" x 10^"+(l-1));else{var f="",v="",b=!0;if(l>0)if(p.length>l)f=p.substring(0,l),v=p.substring(l,p.length);else{f=p,b=0!=cm(p);for(var y=0;y<l-p.length;y++)f+="0"}else{for(var x=0;x<-l;x++)v+="0";v+=p}g+=(""==f?"0":f)+(b?".":"")+v}return g}function cm(e){for(var t=0,r=e.length-1;r>=0;r--){if("0"!=e.charAt(r))return t;t++}return t}function dm(e){for(var t=!0,r=!1,i=!1,n="",s="",o=!0,a=0;a<e.length;a++){var l=e.charAt(a);l>="1"&&l<="9"?(s+=n+l,n="",i=!0,t=!1):"0"==l?(r?i&&(s+=n+l,n=""):i&&(n+=l),t=!1):r||"."!=l?"e"==l||"E"==l&&a+1<e.length?(parseInt(e.substring(a+1,e.length)),a=e.length):!t||"+"!=l&&"-"!=l||"-"==l&&(o=!o):(s+=n,n="",r=!0,t=!1)}return""==s||o}function um(e){for(var t=!1,r=!1,i="",n="",s="",o=0;o<e.length;o++){var a=e.charAt(o);a>="1"&&a<="9"?(s+=i+a,i="",r=!0):"0"==a?t?r?(s+=i+a,i=""):n+=a:r?(n+=a,i+=a):n+=a:t||"."!=a?("e"==a||"E"==a&&o+1<e.length)&&(parseInt(e.substring(o+1,e.length)),o=e.length):(s+=i,i="",t=!0)}return""==s?n:s}function mm(e){for(var t=!1,r=!1,i="",n="",s=0,o=0,a=0;a<e.length;a++){var l=e.charAt(a);if(l>="1"&&l<="9")n+=i+l,i="",r=!0,t||(o++,s++);else if("0"==l)t?r?(n+=i+l,i=""):s--:(o++,r&&(s++,i+=l));else if(t||"."!=l){if("e"==l||"E"==l&&a+1<e.length){var p=parseInt(e.substring(a+1,e.length));s+=p,o+=p,a=e.length}}else n+=i,i="",t=!0}return""==n?o:s}function gm(e,t){var r=e.length-t-1;if(r<0)return"";if(r>=e.length-1)return e;var i=e.charAt(r+1),n=e.charAt(r),s=!1;if(i>"5")s=!0;else if("5"==i){for(var o=r+2;o<e.length;o++)"0"!=e.charAt(o)&&(s=!0);n%2==1&&(s=!0)}for(var a="",l=r;l>=0;l--){var p=e.charAt(l);if(s){var h=void 0;if("9"==p)h="0";else{switch(p){case"0":h="1";break;case"1":h="2";break;case"2":h="3";break;case"3":h="4";break;case"4":h="5";break;case"5":h="6";break;case"6":h="7";break;case"7":h="8";break;case"8":h="9"}s=!1}a=h+a}else a=p+a}return s&&(a="1"+a),a}class fm extends a.Component{constructor(){var t;super(...arguments),t=this,V(this,"_errorTimeout",void 0),V(this,"_showError",(()=>{if(""!==this.props.value){var e=f(g.findDOMNode(this.refs.error));e.is(":visible")||e.css({top:50,opacity:.1}).show().animate({top:0,opacity:1},300)}})),V(this,"_hideError",(()=>{var e=f(g.findDOMNode(this.refs.error));e.is(":visible")&&e.animate({top:50,opacity:.1},300,(function(){f(this).hide()}))})),V(this,"change",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return uo.apply(t,r)})),V(this,"handleBlur",(()=>{this.props.onBlur([]),clearTimeout(this._errorTimeout),e.unitParse(this.props.value).parsed||this._showError()})),V(this,"handleChange",(e=>{this._hideError(),this.props.onChange({value:e.target.value})})),V(this,"simpleValidate",((e,t)=>fm.validate(this.getUserInput(),e))),V(this,"getUserInput",(()=>this.props.value)),V(this,"getInputPaths",(()=>[[]])),V(this,"focusInputPath",(e=>{var t=g.findDOMNode(this.refs.input);t&&t.focus()})),V(this,"handleFocus",(()=>{this.props.onFocus([])})),V(this,"blurInputPath",(e=>{var t=g.findDOMNode(this.refs.input);t&&t.blur()})),V(this,"setInputValue",((e,t,r)=>{this.props.onChange({value:t},r)})),V(this,"getDOMNodeForPath",(()=>g.findDOMNode(this.refs.input))),V(this,"getGrammarTypeForPath",(e=>"unit"))}static validate(t,r){var i=e.unitParse(r.value).expr,n=e.unitParse(t);if(!n.parsed)return{type:"invalid",message:s._("I couldn't understand those units.")};var o,a,p,h=null,c=r.sigfigs,d=(o=n.coefficient,new pm(o).sigFigs===c);d||(h=s._("Check your significant figures."));try{var u=new e.Var("x"),m=new e.Eq(i.simplify(),"=",new e.Mul(u,n.expr.simplify())).solveLinearEquationForVariable(u);a=Number(m.eval()).toPrecision(c)===Number(1).toPrecision(c)}catch(e){a=!1}a||(h=s._("That answer is numerically incorrect."));var g=vm(n.expr.simplify()),f=vm(i.simplify());return(p="all"===r.accepting?e.compare(g,f).equal:l(r.acceptingUnits).any((t=>{var r=vm(e.unitParse(t).unit.simplify());return e.compare(r,g).equal})))||(h=s._("Check your units.")),{type:"points",earned:p&&a&&d?1:0,total:1,message:h}}render(){var e=this.props.apiOptions.staticRender?a.createElement(Zs,{onChange:this.handleChange,ref:"input",className:Zt.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur}):a.createElement("input",{onChange:this.handleChange,ref:"input",className:Zt.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur});return a.createElement("div",{className:"old-unit-input"},e,a.createElement("div",{ref:"error",className:"error",style:{display:"none"}},s._("I don't understand that")))}componentDidUpdate(){clearTimeout(this._errorTimeout),e.unitParse(this.props.value).parsed?this._hideError():this._errorTimeout=setTimeout(this._showError,2e3)}componentWillUnmount(){clearTimeout(this._errorTimeout)}}V(fm,"defaultProps",{apiOptions:Kt.defaults,value:""});var vm=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()},bm={name:"unit-input",displayName:"Unit",defaultAlignment:"inline-block",widget:fm,transform:e=>lm(e).del(["value"]).freeze(),version:{major:0,minor:1},hidden:!0},ym=/^https?:\/\//,xm=e=>{var t,r,{location:i}=e,{useVideo:n}=oe(),[o,l]=ym.test(i)?[(t=i,r=t.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/),r&&11===r[7].length?r[7]:"videoNotFound"),"YOUTUBE_ID"]:[i,"READABLE_ID"],p=n(o,l);switch(p.status){case"loading":return a.createElement(M,null,s._("Loading..."));case"success":var h,c=null===(h=p.data)||void 0===h?void 0:h.video;return a.createElement(M,{style:Cm.transcriptLink},a.createElement(T,null,null==c?void 0:c.title),a.createElement(B,{size:10}),a.createElement(z,{href:"/transcript/"+((null==c?void 0:c.contentId)||"videoNotFound"),target:"_blank",className:"visited-no-recolor"},s._("See video transcript")));default:return a.createElement(M,null,s._("Something went wrong."))}},Cm=d.create({transcriptLink:{flexDirection:"row",width:"100%",justifyContent:"center"}}),wm="{host}/embed_video?slug={slug}&internal_video_only=1",km=/^https?:\/\//,Em=/(khanacademy\.org|localhost)/;class Sm extends a.Component{constructor(){var e;super(...arguments),e=this,V(this,"getUserInput",(()=>null)),V(this,"simpleValidate",(e=>Sm.validate(null,e))),V(this,"change",(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return uo.apply(e,r)}))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e,{InitialRequestUrl:t}=oe(),r=this.props.location;if(!r)return a.createElement("div",null);if(km.test(r))e=r;else{e=wm.replace("{slug}",r);var i="https://www.khanacademy.org";Em.test(t.host)&&(i=t.origin),e=e.replace("{host}",i)}return a.createElement(M,null,a.createElement(nr,{width:1280,height:720,key:r+this.props.alignment},a.createElement(M,{style:Ma.srOnly},s._("Khan Academy video wrapper")),a.createElement("iframe",{className:"perseus-video-widget",sandbox:"allow-same-origin allow-scripts",width:1280,height:720,src:e,allowFullScreen:!0})),a.createElement(xm,{location:r}))}}var _m=[pl,gl,Cl,Ml,yl,Ep,zl,Ul,_p,Ip,Rp,Zp,Eh,Nh,Vh,xc,tc,kc,Jc,pd,gd,Qd,Lo,vd,iu,ou,lu,_u,Pu,Lu,om,bm,{name:"video",displayName:"Video",defaultAlignment:"block",supportedAlignments:["block","float-left","float-right","full-width"],widget:Sm}],Mm=function(e){return ds(sl),ds(_m),e.skipMathJax?Promise.resolve():new Promise(((e,t)=>{MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:"none","HTML-CSS":{availableFonts:["TeX"],imageFont:null,scale:100,showMathMenu:!1}}),MathJax.Hub.Configured(),MathJax.Hub.Queue(e)}))},Tm=[...sl,..._m];ds(Tm);var Im=gs();Im["::renderer::"]=H;var Pm={propTypes:{apiOptions:h.shape({customKeypad:h.bool,nativeKeypadProxy:h.func}),keypadStyle:h.any},getInitialState(){var e=this,t=null;return e.props.apiOptions&&e.props.apiOptions.customKeypad&&e.props.apiOptions.nativeKeypadProxy&&(t=e.props.apiOptions.nativeKeypadProxy((()=>e.blur&&e.blur()))),{keypadElement:t}},componentDidMount(){var e,t=this;t.props.apiOptions&&t.props.apiOptions.customKeypad&&!t.props.apiOptions.nativeKeypadProxy&&(t._keypadContainer=document.createElement("div"),null===(e=document.body)||void 0===e||e.appendChild(t._keypadContainer),g.render(a.createElement(n,{onElementMounted:e=>{t.setState({keypadElement:e})},onDismiss:()=>{t.blur&&t.blur()},style:t.props.keypadStyle}),t._keypadContainer))},componentWillUnmount(){var e=this;e._keypadContainer&&(g.unmountComponentAtNode(e._keypadContainer),e._keypadContainer.parentNode&&e._keypadContainer.parentNode.removeChild(e._keypadContainer),e._keypadContainer=null)},keypadElement(){return this.state.keypadElement}},Am=h.shape({content:h.string,widgets:h.objectOf(h.any),images:h.objectOf(h.any)});class Nm extends a.Component{constructor(e){super(e),V(this,"_currentFocus",void 0),V(this,"keypadElement",(()=>Pm.keypadElement.call(this))),V(this,"_handleFocusChange",((e,t)=>{e?this._setCurrentFocus(e):this._onRendererBlur(t)})),V(this,"_setCurrentFocus",(e=>{var t=this.keypadElement(),r=this._currentFocus;this._currentFocus=e;var i=!1;if(this._currentFocus){var[n,...s]=this._currentFocus;i=this.refs[n].getInputPaths().some((e=>De.inputPathsEqual(e,s)))}null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,r,i&&t&&t.getDOMNode()),t&&(i?t.activate():t.dismiss())})),V(this,"_onRendererBlur",(e=>{var t=this._currentFocus;De.inputPathsEqual(e,t)&&setTimeout((()=>{De.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))})),V(this,"blur",(()=>{if(this._currentFocus){var[e,...t]=this._currentFocus;this.refs[e].blurPath(t)}})),V(this,"_sections",(()=>Array.isArray(this.props.json)?this.props.json:[this.props.json])),this.state=Pm.getInitialState.call(this)}componentDidMount(){Pm.componentDidMount.call(this),this._currentFocus=null}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}componentWillUnmount(){Pm.componentWillUnmount.call(this)}render(){var e=U(U(U({},Kt.defaults),this.props.apiOptions),{},{isArticle:!0}),t=o({"framework-perseus":!0,"perseus-article":!0,"bibliotron-article":this.props.useNewStyles,[Zt.MOBILE]:e.isMobile}),r=this._sections().map(((t,r)=>{var i="section-".concat(r);return a.createElement("div",{key:r,className:"clearfix"},a.createElement(Ds,j({},t,{ref:i,key:r,key_:r,keypadElement:this.keypadElement(),apiOptions:U(U({},e),{},{onFocusChange:(e,t)=>{this._handleFocusChange(e&&[i].concat(e),t&&[i].concat(t))}}),linterContext:Wt.pushContextStack(this.props.linterContext,"article"),legacyPerseusLint:this.props.legacyPerseusLint})))}));return a.createElement("div",{className:t},r)}}V(Nm,"propTypes",U(U({},Pm.propTypes),{},{apiOptions:h.shape({onFocusChange:h.func,isMobile:h.bool}),json:h.oneOfType([Am,h.arrayOf(Am)]).isRequired,useNewStyles:h.bool,linterContext:Ut,legacyPerseusLint:h.arrayOf(h.string)})),V(Nm,"defaultProps",{apiOptions:{},useNewStyles:!1,linterContext:Gt});class Rm extends a.Component{constructor(){super(...arguments),V(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),V(this,"restoreSerializedState",((e,t)=>{this.refs.renderer.restoreSerializedState(e,t)}))}render(){var{apiOptions:e,className:t,hint:r,lastHint:i,lastRendered:n,pos:l,totalHints:p}=this.props,{isMobile:h}=e,c=o(!h&&"perseus-hint-renderer",h&&u(Fm.newHint),h&&n&&u(Fm.lastRenderedNewHint),i&&"last-hint",n&&"last-rendered",t),d=U(U({},e),{},{customKeypad:!1,staticRender:!1});return a.createElement("div",{className:c,tabIndex:"-1"},!e.isMobile&&a.createElement("span",{className:"perseus-sr-only"},s._("Hint #%(pos)s",{pos:l+1})),!e.isMobile&&!e.satStyling&&p&&null!=l&&a.createElement("span",{className:"perseus-hint-label",style:{display:"block",color:e.hintProgressColor}},"".concat(l+1," / ").concat(p)),a.createElement(Ds,{ref:"renderer",widgets:r.widgets,content:r.content||"",images:r.images,apiOptions:d,findExternalWidgets:this.props.findExternalWidgets,linterContext:Wt.pushContextStack(this.props.linterContext,"hint")}))}}V(Rm,"defaultProps",{linterContext:Gt});var Fm=d.create({newHint:{marginBottom:24,borderLeftColor:"#F6F7F7",borderLeftStyle:"solid",borderLeftWidth:4,[jo.lgOrSmaller]:{paddingLeft:16},[jo.smOrSmaller]:{paddingLeft:0},":focus":{outline:"none"}},lastRenderedNewHint:{marginBottom:0,borderLeftColor:"#71B307"}});class Dm extends a.Component{constructor(){super(...arguments),V(this,"state",{isFinalHelpPage:!1}),V(this,"_hintsVisible",(()=>null==this.props.hintsVisible||-1===this.props.hintsVisible?this.props.hints.length:this.props.hintsVisible)),V(this,"_cacheImagesInHint",(e=>{l.each(e.images,((e,t)=>{(new Image).src=De.getRealImageUrl(t)}))})),V(this,"_cacheHintImages",(()=>{this._hintsVisible()>0?l.each(this.props.hints,this._cacheImagesInHint):this.props.hints.length>0&&this._cacheImagesInHint(this.props.hints[0])})),V(this,"getApiOptions",(()=>U(U(U({},Kt.defaults),this.props.apiOptions),{},{readOnly:!1}))),V(this,"getSerializedState",(()=>l.times(this._hintsVisible(),(e=>this.refs["hintRenderer"+e].getSerializedState())))),V(this,"restoreSerializedState",((e,t)=>{var r=1,i=()=>{--r,t&&0===r&&t()};l.each(e,((e,t)=>{var n=this.refs["hintRenderer"+t];n&&(++r,n.restoreSerializedState(e,i))})),i()}))}componentDidMount(){this._cacheHintImages()}UNSAFE_componentWillReceiveProps(e){e.hintsVisible-this.props.hintsVisible>1&&this.setState({isFinalHelpPage:!0})}componentDidUpdate(e,t){if(l.isEqual(e.hints,this.props.hints)&&e.hintsVisible===this.props.hintsVisible||this._cacheHintImages(),e.hintsVisible<this.props.hintsVisible){var r=this.props.hintsVisible-1;g.findDOMNode(this.refs["hintRenderer"+r]).focus()}}render(){var e=this.getApiOptions(),t=this._hintsVisible(),r=[],i=this.state.isFinalHelpPage;this.props.hints.slice(0,t).forEach(((n,s)=>{var o=s===this.props.hints.length-1&&!/\*\*/.test(n.content),l=s===t-1,p=a.createElement(Rm,{lastHint:o,lastRendered:l,hint:n,pos:s,totalHints:this.props.hints.length,ref:"hintRenderer"+s,key:"hintRenderer"+s,apiOptions:e,findExternalWidgets:this.props.findExternalWidgets,linterContext:Wt.pushContextStack(this.props.linterContext,"hints["+s+"]")});i?r.push(p):n.replace&&r.length>0?r[r.length-1]=p:r.push(p)}));var{getAnotherHint:n}=e,l=n&&t>0&&t<this.props.hints.length,p="(".concat(t,"/").concat(this.props.hints.length,")"),h=o(this.props.className,e.isMobile&&t>0&&u(Om.mobileHintStylesHintsRenderer));return a.createElement("div",{className:h},e.isMobile&&t>0&&a.createElement("div",{className:u(Om.mobileHintStylesHintTitle,Qo.responsiveLabel)},s._("Hints")),r,l&&a.createElement("button",{rel:"button",className:u(Om.linkButton,Om.getAnotherHintButton,e.isMobile&&Om.mobileHintStylesGetAnotherHintButton),onClick:e=>{e.preventDefault(),e.stopPropagation(),n&&n()}},a.createElement("span",{className:u(Om.plusText,e.isMobile&&Om.mobileHintStylesPlusText)},"+"),a.createElement("span",{className:u(Om.getAnotherHintText)},s._("Get another hint")," ",p)))}}V(Dm,"defaultProps",{linterContext:Gt});var Om=d.create({rendererMargins:{marginTop:16},linkButton:{cursor:"pointer",border:"none",backgroundColor:"transparent",fontSize:"100%",fontFamily:"inherit",fontWeight:"bold",color:"#71B307",padding:0,position:"relative"},plusText:{fontSize:20,position:"absolute",top:-3,left:0},getAnotherHintText:{marginLeft:16},mobileHintStylesHintsRenderer:{marginTop:64,border:"solid ".concat("#D6D8DA"),borderWidth:"1px 0 0 0",position:"relative",":before":{content:'""',display:"table",clear:"both"},":after":{content:'""',display:"table",clear:"both"}},mobileHintStylesHintTitle:{fontFamily:"inherit",fontStyle:"normal",fontWeight:"bold",color:Q,paddingTop:16,paddingBottom:24,[jo.lgOrSmaller]:{paddingLeft:0},[jo.smOrSmaller]:{paddingLeft:20}},getAnotherHintButton:{marginTop:24},mobileHintStylesGetAnotherHintButton:{[jo.lgOrSmaller]:{paddingLeft:0},[jo.smOrSmaller]:{paddingLeft:20}},mobileHintStylesPlusText:{[jo.lgOrSmaller]:{left:0},[jo.smOrSmaller]:{left:20}}}),{mapObject:Lm}=Er;class Bm extends a.Component{constructor(e){super(e),V(this,"questionRenderer",void 0),V(this,"hintsRenderer",void 0),V(this,"_currentFocus",void 0),V(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),V(this,"handleInteractWithWidget",(e=>{var t=l.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),this.state=U(U({},Pm.getInitialState.call(this)),{},{hintsVisible:e.initialHintsVisible||0,questionCompleted:!1,questionHighlightedWidgets:[]})}componentDidMount(){Pm.componentDidMount.call(this),this.props.controlPeripherals&&this.props.apiOptions.setDrawingAreaAvailable&&this.props.apiOptions.setDrawingAreaAvailable(!0),this._currentFocus=null,this.update()}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(){this.update()}componentWillUnmount(){Pm.componentWillUnmount.call(this);var e=document.querySelector(this.props.workAreaSelector);null!=e&&m.unmountComponentAtNode(e);var t=document.querySelector(this.props.hintsAreaSelector);if(null!=t&&m.unmountComponentAtNode(t),this.props.controlPeripherals){var r=this.props.item.answerArea||{};r.calculator&&f("#calculator").hide(),r.periodicTable&&f(".periodic-table-info-box").hide(),r.zTable&&f(".z-table-info-box").hide(),r.tTable&&f(".t-table-info-box").hide(),r.chi2Table&&f(".chi2-table-info-box").hide()}}keypadElement(){return Pm.keypadElement.call(this)}update(){var e=U(U(U({},Kt.defaults),this.props.apiOptions),{},{onFocusChange:this._handleFocusChange}),t=document.querySelector(this.props.workAreaSelector),r=document.querySelector(this.props.hintsAreaSelector);if(t&&r){m.render(a.createElement(Ds,j({ref:t=>{if(t){this.questionRenderer=t;var{answerableCallback:r}=e;if(r)r(0===this.questionRenderer.emptyWidgets().length)}},keypadElement:this.keypadElement(),problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,savedState:this.props.savedState,linterContext:Wt.pushContextStack(this.props.linterContext,"question")},this.props.item.question,{legacyPerseusLint:this.props.legacyPerseusLint})),t),m.render(a.createElement(Dm,{ref:e=>this.hintsRenderer=e,hints:this.props.item.hints,hintsVisible:this.state.hintsVisible,apiOptions:e,linterContext:Wt.pushContextStack(this.props.linterContext,"hints")}),r);var i=this.props.item.answerArea||{};this.props.controlPeripherals?(f("#calculator").toggle(i.calculator||!1),f(".periodic-table-info-box").toggle(i.periodicTable||!1),f(".z-table-info-box").toggle(i.zTable||!1),f(".t-table-info-box").toggle(i.tTable||!1),f(".chi2-table-info-box").toggle(i.chi2Table||!1)):(i.calculator&&this.props.onShowCalculator&&this.props.onShowCalculator(),i.periodicTable&&this.props.onShowPeriodicTable&&this.props.onShowPeriodicTable(),i.zTable&&this.props.onShowZTable&&this.props.onShowZTable(),i.tTable&&this.props.onShowTTable&&this.props.onShowTTable(),i.chi2Table&&this.props.onShowChi2Table&&this.props.onShowChi2Table())}}_setCurrentFocus(e){var t=this.keypadElement(),r=this._currentFocus;this._currentFocus=e;var i=this.getInputPaths(),n=this._currentFocus&&i.some((e=>De.inputPathsEqual(e,this._currentFocus)));null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,r,n&&t&&t.getDOMNode()),t&&(n?t.activate():t.dismiss())}_onRendererBlur(e){var t=this._currentFocus;De.inputPathsEqual(e,t)&&setTimeout((()=>{De.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))}_setWidgetProps(e,t,r){this.questionRenderer._setWidgetProps(e,t,r)}setInputValue(e,t,r){return this.questionRenderer.setInputValue(e,t,r)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}showHint(){this.state.hintsVisible<this.getNumHints()&&this.setState({hintsVisible:this.state.hintsVisible+1})}getNumHints(){return this.props.item.hints.length}scoreInput(){var e=this.questionRenderer.guessAndScore(),t=e[0],r=e[1],i=[t,[]],n=De.keScoreFromPerseusScore(r,i,this.questionRenderer.getSerializedState()),s=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:n.correct,questionHighlightedWidgets:s}),n}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){var e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),r=this.questionRenderer.getSerializedState();return Lm(e,((e,i)=>De.keScoreFromPerseusScore(e,t[i],r[i])))}getSerializedState(){var e;return{question:this.questionRenderer.getSerializedState(),hints:null===(e=this.hintsRenderer)||void 0===e?void 0:e.getSerializedState()}}restoreSerializedState(e,t){var r,i=2,n=()=>{--i,t&&0===i&&t()};this.questionRenderer.restoreSerializedState(e.question,n),null===(r=this.hintsRenderer)||void 0===r||r.restoreSerializedState(e.hints,n)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){return a.createElement("div",null)}}V(Bm,"defaultProps",{apiOptions:Kt.defaults,controlPeripherals:!0,hintsAreaSelector:"#hintsarea",initialHintsVisible:0,workAreaSelector:"#workarea",reviewMode:!1,linterContext:Gt});var zm={onRendered:e=>{}},qm=a.createContext(zm),{mapObject:Hm}=Er;class Wm extends a.Component{constructor(e){super(e),V(this,"questionRenderer",void 0),V(this,"hintsRenderer",void 0),V(this,"_currentFocus",void 0),V(this,"_fullyRendered",void 0),V(this,"blurTimeoutID",void 0),V(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),V(this,"handleInteractWithWidget",(e=>{var t=l.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),V(this,"setAssetStatus",((e,t)=>{var r=U(U({},this.state.assetStatuses),{},{[e]:t});this.setState({assetStatuses:r})})),this.state={questionCompleted:!1,questionHighlightedWidgets:[],assetStatuses:{}},this._fullyRendered=!1}componentDidMount(){this._currentFocus=null,this._fullyRendered=!1}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(e,t){if(this.props.apiOptions.answerableCallback){var r=0===this.questionRenderer.emptyWidgets().length,{answerableCallback:i}=this.props.apiOptions;i&&i(r)}this._fullyRendered||Object.values(this.state.assetStatuses).every(Boolean)&&(this._fullyRendered=!0,this.props.onRendered(!0))}componentWillUnmount(){null!=this.blurTimeoutID&&(clearTimeout(this.blurTimeoutID),this.blurTimeoutID=null)}_setCurrentFocus(e){var{apiOptions:{isMobile:t,onFocusChange:r},keypadElement:i}=this.props,n=this._currentFocus;this._currentFocus=e;var s=this.getInputPaths(),o=this._currentFocus&&s.some((e=>De.inputPathsEqual(e,this._currentFocus)));null!=r&&r(this._currentFocus,n,o&&i&&i.getDOMNode(),o&&this.questionRenderer.getDOMNodeForPath(e)),i&&t&&(o?i.activate():i.dismiss())}_onRendererBlur(e){var t=this._currentFocus;l.isEqual(e,t)&&(this.blurTimeoutID=setTimeout((()=>{l.isEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}),0))}_setWidgetProps(e,t,r){this.questionRenderer._setWidgetProps(e,t,r)}setInputValue(e,t,r){return this.questionRenderer.setInputValue(e,t,r)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}getNumHints(){return this.props.item.hints.length}scoreInput(){var e=this.questionRenderer.guessAndScore(),t=e[0],r=e[1],i=[t,[]],n=De.keScoreFromPerseusScore(r,i,this.questionRenderer.getSerializedState()),s=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:n.correct,questionHighlightedWidgets:s}),n}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){var e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),r=this.questionRenderer.getSerializedState();return Hm(e,((e,i)=>De.keScoreFromPerseusScore(e,t[i],r)))}getSerializedState(){return{question:this.questionRenderer.getSerializedState(),hints:this.hintsRenderer.getSerializedState()}}restoreSerializedState(e,t){var r=2,i=()=>{--r,t&&0===r&&t()};this.questionRenderer.restoreSerializedState(e.question,i),this.hintsRenderer.restoreSerializedState(e.hints,i)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){var e=U(U(U({},Kt.defaults),this.props.apiOptions),{},{onFocusChange:this._handleFocusChange}),t={assetStatuses:this.state.assetStatuses,setAssetStatus:this.setAssetStatus},r=a.createElement(Qt.Provider,{value:t},a.createElement(Ds,{keypadElement:this.props.keypadElement,problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,ref:e=>{null!=e&&(this.questionRenderer=e)},content:this.props.item.question.content,widgets:this.props.item.question.widgets,images:this.props.item.question.images})),i=a.createElement(Dm,{hints:this.props.item.hints,hintsVisible:this.props.hintsVisible,apiOptions:e,ref:e=>this.hintsRenderer=e});return a.createElement("div",null,a.createElement("div",null,r),a.createElement("div",{className:e.isMobile?void 0:u(Um.hintsContainer)},i))}}V(Wm,"defaultProps",{apiOptions:{},onRendered:e=>{}});var Um=d.create({hintsContainer:{marginLeft:50}}),Gm=a.forwardRef(((e,t)=>a.createElement(qm.Consumer,null,(r=>{var{onRendered:i}=r;return a.createElement(Wm,j({},e,{onRendered:i,ref:t}))}))));class Vm extends a.Component{render(){return a.createElement(Vl,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:a.createElement("span",null,"—")},{value:"->",content:a.createElement("span",null,"→")}],onChange:this.props.onChange})}}V(Vm,"defaultProps",{value:""});var jm=[dr.BLACK,dr.BLUE,dr.GREEN,dr.PINK,dr.PURPLE,dr.RED,dr.GRAY],Ym=[dr.LIGHT_BLUE,dr.LIGHT_ORANGE,dr.LIGHT_PINK,dr.LIGHT_GREEN,dr.LIGHT_PURPLE,dr.LIGHT_RED,"#fff"];class Xm extends a.Component{render(){var e=this.props.lightColors?Ym:jm;return a.createElement(Vl,{value:this.props.value,allowEmpty:!1,buttons:l.map(e,(e=>({value:e,content:a.createElement("span",null,a.createElement("span",{className:"colorpicker-circle",style:{background:e}})," ")}))),onChange:this.props.onChange})}}V(Xm,"defaultProps",{value:dr.BLACK,lightColors:!1});class $m extends a.Component{render(){return a.createElement(Vl,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:a.createElement("span",null,"—")},{value:"-",content:a.createElement("span",null,"–––")},{value:"- ",content:a.createElement("span",null,"–  –")},{value:".",content:a.createElement("span",null,"····")},{value:". ",content:a.createElement("span",null,"· · ·")}],onChange:this.props.onChange})}}V($m,"defaultProps",{value:""});class Km extends a.Component{constructor(e){super(e),V(this,"toggle",(e=>{e.preventDefault(),this.setState({show:!this.state.show})})),this.state={show:e.initiallyVisible}}render(){return a.createElement("div",{className:"perseus-interaction-element"},a.createElement("a",{href:"#",className:"perseus-interaction-element-title "+(this.state.show?"open":"closed"),onClick:this.toggle},this.state.show?a.createElement(X,gi):a.createElement(X,fi),this.props.title),a.createElement("div",{className:"perseus-interaction-element-content "+(this.state.show?"enter":"leave")},this.props.children,(null!=this.props.onUp||null!=this.props.onDown||null!=this.props.onDelete)&&a.createElement("div",{className:"edit-controls"},null!=this.props.onUp&&a.createElement("button",{onClick:this.props.onUp},a.createElement(X,yi)),null!=this.props.onDown&&a.createElement("button",{onClick:this.props.onDown},a.createElement(X,bi)),null!=this.props.onDelete&&a.createElement("button",{onClick:this.props.onDelete},a.createElement(X,Mi)))))}}V(Km,"defaultProps",{initiallyVisible:!1,title:"More"});class Zm extends a.Component{constructor(){super(...arguments),V(this,"renderVisibleIcon",(()=>a.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:u(Jm.icon)},a.createElement("defs",null,a.createElement("path",{id:"a",d:"M7.401 10.035c-1.424.748-2.599 1.905-3.544 3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"})),a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),a.createElement("mask",{id:"b",fill:"#fff"},a.createElement("use",{href:"#a"})),a.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),a.createElement("g",{fill:"#fff",mask:"url(#b)"},a.createElement("path",{d:"M0 0h24v24H0z"})))))),V(this,"renderHiddenIcon",(()=>a.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:u(Jm.icon)},a.createElement("defs",null,a.createElement("path",{id:"a",d:"M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48.258.604.401 1.268.401 1.966 0 1.02-.305 1.967-.828 2.757l2.535 2.536a1 1 0 0 1-1.414 1.414l-12-12a1 1 0 0 1 1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 0-4.001-4.001l4 4.001zM6.072 8.486l2.976 2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 2.363-3.085 3.929-4z"})),a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),a.createElement("mask",{id:"b",fill:"#fff"},a.createElement("use",{href:"#a"})),a.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),a.createElement("g",{fill:"#fff",mask:"url(#b)"},a.createElement("path",{d:"M0 0h24v24H0z"}))))))}render(){var e,t;return this.props.enabled?(e=Jm.enabled,t=this.renderVisibleIcon()):(e=Jm.disabled,t=this.renderHiddenIcon()),a.createElement("button",{className:u(Jm.hud,this.props.fixedPosition&&Jm.hudFixedPosition,e),onClick:e=>{this.props.onClick()}},t,this.props.message)}}V(Zm,"propTypes",{message:h.string.isRequired,enabled:h.bool.isRequired,onClick:h.func.isRequired,fixedPosition:h.bool}),V(Zm,"defaultProps",{fixedPosition:!0});var Jm=d.create({hud:{boxSizing:"border-box",height:36,padding:"9px 16px",borderRadius:18,fontFamily:$,fontSize:"15px",lineHeight:"18px",color:K,userSelect:"none",borderWidth:0},hudFixedPosition:{bottom:20,position:"fixed",right:20,zIndex:1},icon:{width:24,height:24,marginRight:8,marginTop:-3,verticalAlign:"middle"},enabled:{backgroundColor:"#f86700",":hover":{backgroundColor:"#df5c00"},":active":{backgroundColor:"#c75300"}},disabled:{backgroundColor:Z,":hover":{backgroundColor:"#a1a5a9"},":active":{backgroundColor:J}}});class Qm extends a.Component{constructor(){super(...arguments),V(this,"toggleSelect",(e=>{var t=(this.props.values||[]).slice(0),r=this.props.allowEmpty;t.indexOf(e)>=0&&(t.length>1||r)?t.splice(t.indexOf(e),1):t.indexOf(e)<0&&t.push(e),this.props.onChange(t)}))}focus(){var e;return null===(e=m.findDOMNode(this))||void 0===e||e.focus(),!0}render(){var e=this.props.values||[],t=this.props.buttons.map(((t,r)=>{var i=e.indexOf(t.value)>=0;return a.createElement("button",{title:t.title,type:"button",id:""+r,key:""+r,ref:"button"+r,className:u(eg.buttonStyle,i&&eg.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)}));return a.createElement("div",{style:{display:"inline-block"}},t)}}V(Qm,"defaultProps",{values:[],allowEmpty:!0});var eg=d.create({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"}}),tg=w({displayName:"PropCheckBox",propTypes:{labelAlignment:h.oneOf(["left","right"])},DEFAULT_PROPS:{label:null,onChange:null,labelAlignment:"left"},getDefaultProps:function(){return this.DEFAULT_PROPS},propName:function(){var e=l.find(l.keys(this.props),(function(e){return!l.has(this.DEFAULT_PROPS,e)}),this);if(!e)throw new he("Attempted to create a PropCheckBox with no prop!",le.InvalidInput);return e},_labelAlignLeft:function(){return"left"===this.props.labelAlignment},render:function(){var e=this.propName();return a.createElement("label",null,this._labelAlignLeft()&&this.props.label,a.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)}}),rg=()=>!0;class ig extends a.Component{constructor(){super(...arguments),V(this,"onChange",((e,t)=>{var r=this.props.value;0===e?this.props.onChange([t,r[1]]):this.props.onChange([r[0],t])}))}render(){var e=this.props.value,t=this.props.checkValidity||rg;return a.createElement("div",{className:"range-input"},a.createElement(ac,j({},this.props,{value:e[0],checkValidity:r=>t([r,e[1]]),onChange:this.onChange.bind(this,0),placeholder:this.props.placeholder[0]})),a.createElement(ac,j({},this.props,{value:e[1],checkValidity:r=>t([e[0],r]),onChange:this.onChange.bind(this,1),placeholder:this.props.placeholder[1]})))}}V(ig,"propTypes",{value:h.array.isRequired,onChange:h.func.isRequired,placeholder:h.array,checkValidity:h.func}),V(ig,"defaultProps",{placeholder:[null,null]});var ng=Object.freeze({__proto__:null,ButtonGroup:Vl,Graph:eh,Graphie:In,HUD:Zm,Icon:ca,InfoTip:gu,InlineIcon:X,MathInput:Vs,MultiButtonGroup:Qm,NumberInput:ac,PropCheckBox:tg,RangeInput:ig,SvgImage:Un,TextInput:Qs,TexButtons:Us,TextListEditor:Yt}),sg=Object.freeze({__proto__:null,devices:{PHONE:"phone",TABLET:"tablet",DESKTOP:"desktop"},lintGutterWidth:36,perseusFrameBorderWidth:1}),og=a.createContext({setKeypadElement:e=>{},keypadElement:null,setRenderer:e=>{},renderer:null,setScrollableElement:e=>{},scrollableElement:null}),ag=function(){},lg=function(e,t,r,i){var n=e.content;if(null!=e.content){var s=t(e.content);void 0!==s&&(n=s)}var o=Er.mapObject(e.widgets||{},(function(e,t){return null==e||null==e.type?e:r(e,t)})),a=l.extend({},e,{content:n,widgets:o}),p=i(a);return void 0!==p?p:a},pg=function(e,t,r,i){return lg(e,t=t||ag,function(e,t,r){return function i(n,s){var o,a,l=vs(n),p=ms(l.type);a=p&&(null===(o=l.version)||void 0===o?void 0:o.major)===p.major?ys(l,(t=>lg(t,e,i,r))):l;var h=t(a,s);return void 0!==h?h:a}}(t,r=r||ag,i=i||ag),i)},hg={type:"hint"},cg=e=>({type:"array",elementShape:e}),dg={content:{type:"content"},hint:hg,hints:cg(hg),tags:{type:"tags"},arrayOf:cg,shape:e=>({type:"object",shape:e})};class ug{constructor(e,t,r){V(this,"content",void 0),V(this,"hint",void 0),V(this,"tags",void 0),V(this,"array",void 0),this.content=e,this.hint=t,this.tags=r,this.array=gg}setContentMapper(e){return new ug(e,this.hint,this.tags)}setHintMapper(e){return new ug(this.content,e,this.tags)}setTagsMapper(e){return new ug(this.content,this.hint,e)}setArrayMapper(e){return new mg(this.content,this.hint,this.tags,e)}mapTree(e,t){return vg(e,t,[],this)}}class mg{constructor(e,t,r,i){V(this,"content",void 0),V(this,"hint",void 0),V(this,"tags",void 0),V(this,"array",void 0),this.content=e,this.hint=t,this.tags=r,this.array=i}setArrayMapper(e){return new mg(this.content,this.hint,this.tags,e)}mapTree(e,t){return vg(e,t,[],this)}}function gg(e){return e}function fg(){return new ug(gg,gg,gg)}function vg(e,t,r,i){if("content"===t.type){var n=e;return i.content(n,t,r)}if("hint"===t.type){var s=e;return i.hint(s,t,r)}if("tags"===t.type){var o=e;return i.tags(o,t,r)}if("array"===t.type){var a=e;if(!Array.isArray(a))throw new he('Invalid object of type "'.concat(typeof a,'" found at path ')+"".concat(["<root>"].concat(r).join("."),". Expected array."),le.Internal);var l=t.elementShape,p=a.map(((e,t)=>vg(e,l,r.concat(t),i)));return i.array(p,a,t,r)}if("object"===t.type){var h=e;if(h&&"object"!=typeof h)throw new he('Invalid object of type "'.concat(typeof h,'" found at ')+"path ".concat(["<root>"].concat(r).join("."),". Expected ")+'"object" type.',le.InvalidInput);var c=t.shape;if(!c)throw new he("Unexpected shape ".concat(JSON.stringify(t)," at path ")+"".concat(["<root>"].concat(r).join("."),"."),le.InvalidInput);var d={};return Object.keys(c).forEach((e=>{if(!(e in h))throw new he('Key "'.concat(e,'" is missing from shape at path ')+"".concat(["<root>"].concat(r).join("."),"."),le.InvalidInput);d[e]=vg(h[e],c[e],r.concat(e),i)})),d}throw new he("unexpected shape type ".concat(t.type),le.InvalidInput)}function bg(e){if("content"===e.type)return{__type:"content",content:"",images:{},widgets:{}};if("hint"===e.type)return{__type:"hint",replace:!1,content:"",images:{},widgets:{}};if("tags"===e.type)return[];if("array"===e.type)return[];if("object"===e.type){var t=e.shape,r={};return Object.keys(t).forEach((e=>{r[e]=bg(t[e])})),r}throw new he("unexpected shape type ".concat(e.type),le.InvalidInput)}function yg(e){if(Array.isArray(e))return e.length?"string"==typeof e[0]?dg.tags:dg.arrayOf(yg(e[0])):dg.arrayOf(dg.content);if("object"==typeof e&&("content"===e.__type||"item"===e.__type))return dg.content;if("object"==typeof e&&"hint"===e.__type)return dg.hint;if("object"==typeof e){var t={};return Object.keys(e).forEach((r=>{t[r]=yg(e[r])})),dg.shape(t)}throw new he("unexpected multi-item node ".concat(JSON.stringify(e)),le.InvalidInput)}function xg(e){return e._multi}var Cg=["item","children","shape","serializedState","onSerializedStateUpdated"];class wg extends a.Component{constructor(e){super(e),V(this,"rendererDataTreeMapper",void 0),V(this,"getRenderersMapper",void 0),V(this,"_handleSerializedStateUpdated",((e,t)=>{var{onSerializedStateUpdated:r}=this.props;if(r){var i=this._getSerializedState(this.props.serializedState);r(lm(i).set(e,t).freeze())}})),this.rendererDataTreeMapper=fg().setContentMapper(((e,t,r)=>this._makeContentRendererData(e,r))).setHintMapper((e=>this._makeHintRendererData(e))).setTagsMapper((e=>null)),this.getRenderersMapper=fg().setContentMapper((e=>e.makeRenderer())).setHintMapper((e=>e.makeRenderer())).setArrayMapper(((e,t,r)=>this._annotateRendererArray(e,t,r))),this.state=this._tryMakeRendererState(this.props)}UNSAFE_componentWillReceiveProps(e){e.item!==this.props.item&&this.setState(this._tryMakeRendererState(e))}_tryMakeRendererState(e){try{return{rendererDataTree:this._makeRendererDataTree(e.item,e.shape),renderError:null}}catch(e){return pe.error("Error building tree state",le.Internal,{cause:e}),{rendererDataTree:null,renderError:e}}}_getRendererProps(){return Y(this.props,Cg)}_makeContentRendererData(e,t){var r={ref:null,makeRenderer:null},i=e=>r.ref=e,n=e=>this._findWidgets(r,e),s=e=>this._handleSerializedStateUpdated(t,e);return r.makeRenderer=()=>a.createElement(Ds,j({},this._getRendererProps(),e,{ref:i,findExternalWidgets:n,serializedState:this.props.serializedState?lm(this.props.serializedState).get(t):null,onSerializedStateUpdated:s})),r}_makeHintRendererData(e){var t=e=>this._findWidgets({},e);return{hint:e,findExternalWidgets:t,ref:null,makeRenderer:()=>a.createElement(Dm,j({},this._getRendererProps(),{findExternalWidgets:t,hints:[e]}))}}_makeRendererDataTree(e,t){var r=xg(e);return this.rendererDataTreeMapper.mapTree(r,t)}_findWidgets(e,t){var r=[];return this._mapRenderers((i=>{e!==i&&i.ref&&r.push(...i.ref.findInternalWidgets(t))})),r}_mapRenderers(e){var{rendererDataTree:t}=this.state;return t?fg().setContentMapper(e).setHintMapper(e).mapTree(t,this.props.shape):null}_scoreFromRef(e){if(!e)return null;var t,[r,i]=e.guessAndScore();return e.getSerializedState&&(t=e.getSerializedState()),De.keScoreFromPerseusScore(i,r,t)}getScores(){return this._mapRenderers((e=>this._scoreFromRef(e.ref)))}score(){var e=[],t=[],r=this._mapRenderers((r=>{var i;return r.ref?(r.ref.getSerializedState&&t.push(r.ref.getSerializedState()),e.push(r.ref.score()),null===(i=r.ref)||void 0===i?void 0:i.getUserInput()):null})),i=e.reduce(De.combineScores);return De.keScoreFromPerseusScore(i,r,t)}_getSerializedState(e){return this._mapRenderers(((t,r,i)=>t.ref?t.ref.getSerializedState():e?lm(e).get(i):null))}restoreSerializedState(e,t){var r=0,i=()=>{r--,t&&0===r&&t()};this._mapRenderers(((t,n,s)=>{var o;if(t.ref){var a=lm(e).get(s);a&&(r++,null===(o=t.ref)||void 0===o||o.restoreSerializedState(a,i))}}))}_annotateRendererArray(e,t,r){if("hint"===r.elementShape.type){var i=t;(e=[...e]).firstN=e=>a.createElement(Dm,j({},this._getRendererProps(),{findExternalWidgets:i[0]?i[0].findExternalWidgets:void 0,hints:i.map((e=>e.hint)),hintsVisible:e}))}return e}_getRenderers(){return this.getRenderersMapper.mapTree(this.state.rendererDataTree,this.props.shape)}render(){return this.state.renderError?a.createElement("div",{className:u(kg.error)},s.$_("Error rendering: %(error)s",{error:String(this.state.renderError)})):this.props.children({renderers:this._getRenderers()})}}var kg=d.create({error:{color:"red"}});function Eg(e){if("content"===e.type)return h.shape({__type:h.oneOf(["content","item"]).isRequired,content:h.string,images:h.objectOf(h.any),widgets:h.objectOf(h.any)});if("hint"===e.type)return h.shape({__type:h.oneOf(["hint"]).isRequired,content:h.string,images:h.objectOf(h.any),widgets:h.objectOf(h.any),replace:h.bool});if("tags"===e.type)return h.arrayOf(h.string.isRequired);if("array"===e.type){var t=Eg(e.elementShape);return h.arrayOf(t.isRequired)}if("object"===e.type){var r=e.shape,i={};return Object.keys(r).forEach((e=>{i[e]=Eg(r[e]).isRequired})),h.shape(i)}throw new he("unexpected shape type ".concat(e.type),le.InvalidInput)}var Sg={MultiRenderer:wg,shapes:dg,buildPropTypeForShape:function(e){return h.oneOfType([h.shape({_multi:Eg(e)}),h.oneOf([null,void 0])])},buildEmptyItemForShape:function(e){return{_multi:bg(e)}},findContentNodesInItem:function(e,t,r){var i=xg(e);fg().setContentMapper(r).mapTree(i,t)},findHintNodesInItem:function(e,t,r){var i=xg(e);fg().setHintMapper(r).mapTree(i,t)},inferItemShape:function(e){return yg(xg(e))}},{findContentNodesInItem:_g,inferItemShape:Mg}=Sg,Tg=function(e,t){var r=!0;return pg(e,null,(function(e){r=r&&function(e,t){if(null==e||null==e.type)return!0;var r=vs(e);return function(e,t){if(null==t)return!1;var r=e.version||{major:0,minor:0};return t.major>r.major||!(t.major<r.major)&&t.minor>=r.minor}(r,t[r.type])}(e,t)})),r},Ig=function(e,t){if(null==e||null==t)throw new he("missing parameter to Perseus.isRenderable.item",le.InvalidInput);if(e._multi){var r=Mg(e),i=!0;return _g(e,r,(e=>{Tg(e,t)||(i=!1)})),i}return Tg(e.question,t)},{findContentNodesInItem:Pg,inferItemShape:Ag}=Sg;function Ng(e,t){pg(e,null,(function(e){e.type&&!fs(e)&&t.push(e.type)}))}function Rg(e){var t=[];if(e._multi){var r=Ag(e);Pg(e,r,(e=>Ng(e,t)))}else Ng(e.question,t);return l.uniq(t)}var Fg=()=>{ds(Tm)},Dg={serialize:function(){return l.omit(this.props,lo)}},Og=q,Lg=H;export{Kt as ApiOptions,Vm as ArrowPicker,Nm as ArticleRenderer,Ja as BaseRadio,pl as Categorizer,go as Changeable,Zt as ClassNames,Xm as ColorPicker,$m as DashPicker,ae as Dependencies,Dg as EditorJsonify,Km as ElementContainer,le as Errors,bo as Expression,vp as GrapherUtil,Ep as GrapherWidget,Rm as HintRenderer,Dm as HintsRenderer,To as InputNumber,Eh as InteractiveGraphWidget,Bm as ItemRenderer,Qn as JiptParagraphs,og as KeypadContext,dr as KhanColors,ce as KhanMath,qm as LoadingContext,pe as Log,xc as MatrixWidget,Sg as MultiItems,Fo as NumericInput,he as PerseusError,Ye as PerseusMarkdown,iu as PlotterWidget,nl as Radio,Ds as Renderer,Gm as ServerItemRenderer,as as SizingUtils,Lu as TableWidget,om as TransformerWidget,De as Util,lo as WIDGET_PROP_BLACKLIST,Do as WidgetJsonifyDeprecated,Ms as Widgets,Og as apiVersion,bg as buildEmptyItemTreeForShape,fg as buildMapper,ng as components,sg as constants,hm as displaySigFigs,da as globalConstants,va as globalStyles,Pi as icons,Mm as init,ee as interactiveSizes,Ig as isItemRenderableByVersion,Lg as itemDataVersion,xg as itemToTree,Im as itemVersion,jo as mediaQueries,rs as preprocessTex,Fg as registerAllWidgetsForTesting,dg as shapes,pg as traverse,Rg as violatingWidgets,Tm as widgets};
16
8
  //# sourceMappingURL=index.js.map